void FlatDX::PopulateCommandList(const size_t i) { const auto CL = GraphicsCommandLists[i].Get(); const auto SCR = SwapChainResources[i].Get(); const auto SCHandle = GetCPUDescriptorHandle(SwapChainDescriptorHeap.Get(), D3D12_DESCRIPTOR_HEAP_TYPE_RTV, static_cast<UINT>(i)); const auto CA = CommandAllocators[0].Get(); VERIFY_SUCCEEDED(CL->Reset(CA, PipelineState.Get())); { CL->RSSetViewports(static_cast<UINT>(Viewports.size()), Viewports.data()); CL->RSSetScissorRects(static_cast<UINT>(ScissorRects.size()), ScissorRects.data()); ResourceBarrier(CL, SCR, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); { ClearColor(CL, SCHandle, DirectX::Colors::SkyBlue); { const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> RTDescriptorHandles = { SCHandle }; CL->OMSetRenderTargets(static_cast<UINT>(RTDescriptorHandles.size()), RTDescriptorHandles.data(), FALSE, nullptr); } CL->SetGraphicsRootSignature(RootSignature.Get()); CL->IASetPrimitiveTopology(GetPrimitiveTopology()); CL->ExecuteIndirect(IndirectCommandSignature.Get(), 1, IndirectBufferResource.Get(), 0, nullptr, 0); } ResourceBarrier(CL, SCR, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT); } VERIFY_SUCCEEDED(CL->Close()); }
void FontTests::TestLongFontNameScenario() { wistd::unique_ptr<wchar_t[]> expandedLongFontPath; VERIFY_SUCCEEDED(ExpandPathToMutable(pwszLongFontPath, expandedLongFontPath)); if (!CheckIfFileExists(expandedLongFontPath.get())) { Log::Comment(L"Lucida Sans Typewriter doesn't exist; skipping long font test."); Log::Result(WEX::Logging::TestResults::Result::Skipped); return; } const HANDLE hConsoleOutput = GetStdOutputHandle(); CONSOLE_FONT_INFOEX cfieSetLong = { 0 }; cfieSetLong.cbSize = sizeof(cfieSetLong); cfieSetLong.FontFamily = 54; cfieSetLong.dwFontSize.Y = 12; VERIFY_SUCCEEDED(StringCchCopy(cfieSetLong.FaceName, ARRAYSIZE(cfieSetLong.FaceName), L"Lucida Sans Typewriter")); VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::SetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfieSetLong)); CONSOLE_FONT_INFOEX cfiePostLong = { 0 }; cfiePostLong.cbSize = sizeof(cfiePostLong); VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::GetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfiePostLong)); Log::Comment(NoThrowString().Format(L"%ls %ls", cfieSetLong.FaceName, cfiePostLong.FaceName)); VERIFY_ARE_EQUAL(0, NoThrowString(cfieSetLong.FaceName).CompareNoCase(cfiePostLong.FaceName)); }
void FileTests::TestWriteFileDisableNewlineAutoReturn() { bool fDisableAutoReturn; VERIFY_SUCCEEDED(TestData::TryGetValue(L"fDisableAutoReturn", fDisableAutoReturn)); bool fProcessedOn; VERIFY_SUCCEEDED(TestData::TryGetValue(L"fProcessedOn", fProcessedOn)); HANDLE const hOut = GetStdOutputHandle(); VERIFY_IS_NOT_NULL(hOut, L"Verify we have the standard output handle."); CONSOLE_SCREEN_BUFFER_INFOEX csbiexOriginal = { 0 }; csbiexOriginal.cbSize = sizeof(csbiexOriginal); VERIFY_WIN32_BOOL_SUCCEEDED(GetConsoleScreenBufferInfoEx(hOut, &csbiexOriginal), L"Retrieve screen buffer properties at beginning of test."); DWORD dwMode = 0; WI_SetFlagIf(dwMode, DISABLE_NEWLINE_AUTO_RETURN, fDisableAutoReturn); WI_SetFlagIf(dwMode, ENABLE_PROCESSED_OUTPUT, fProcessedOn); VERIFY_WIN32_BOOL_SUCCEEDED(SetConsoleMode(hOut, dwMode), L"Set console mode for test."); COORD const coordZero = { 0 }; VERIFY_ARE_EQUAL(coordZero, csbiexOriginal.dwCursorPosition, L"Cursor should be at 0,0 in fresh buffer."); CONSOLE_SCREEN_BUFFER_INFOEX csbiexBefore = { 0 }; csbiexBefore.cbSize = sizeof(csbiexBefore); CONSOLE_SCREEN_BUFFER_INFOEX csbiexAfter = { 0 }; csbiexAfter.cbSize = sizeof(csbiexAfter); COORD coordExpected = { 0 }; WriteFileHelper(hOut, csbiexBefore, csbiexAfter, "abc", 3); coordExpected = csbiexBefore.dwCursorPosition; coordExpected.X += 3; VERIFY_ARE_EQUAL(coordExpected, csbiexAfter.dwCursorPosition, L"Cursor should have moved right to the end of the text written."); WriteFileHelper(hOut, csbiexBefore, csbiexAfter, "\n", 1); if (fProcessedOn) { if (fDisableAutoReturn) { coordExpected = csbiexBefore.dwCursorPosition; coordExpected.Y += 1; } else { coordExpected = csbiexBefore.dwCursorPosition; coordExpected.Y += 1; coordExpected.X = 0; } } else { coordExpected = csbiexBefore.dwCursorPosition; coordExpected.X += 1; } VERIFY_ARE_EQUAL(coordExpected, csbiexAfter.dwCursorPosition, L"Cursor should move to expected position."); }
void FileTests::TestWriteFileVTProcessing() { bool fVtOn; VERIFY_SUCCEEDED(TestData::TryGetValue(L"fVtOn", fVtOn)); bool fProcessedOn; VERIFY_SUCCEEDED(TestData::TryGetValue(L"fProcessedOn", fProcessedOn)); HANDLE const hOut = GetStdOutputHandle(); VERIFY_IS_NOT_NULL(hOut, L"Verify we have the standard output handle."); CONSOLE_SCREEN_BUFFER_INFOEX csbiexOriginal = { 0 }; csbiexOriginal.cbSize = sizeof(csbiexOriginal); VERIFY_WIN32_BOOL_SUCCEEDED(GetConsoleScreenBufferInfoEx(hOut, &csbiexOriginal), L"Retrieve screen buffer properties at beginning of test."); DWORD dwFlags = 0; WI_SetFlagIf(dwFlags, ENABLE_VIRTUAL_TERMINAL_PROCESSING, fVtOn); WI_SetFlagIf(dwFlags, ENABLE_PROCESSED_OUTPUT, fProcessedOn); VERIFY_WIN32_BOOL_SUCCEEDED(SetConsoleMode(hOut, dwFlags), L"Turn on relevant flags for test."); COORD const coordZero = { 0 }; VERIFY_ARE_EQUAL(coordZero, csbiexOriginal.dwCursorPosition, L"Cursor should be at 0,0 in fresh buffer."); PCSTR pszTestString = "\x1b" "[14m"; DWORD const cchTest = (DWORD)strlen(pszTestString); CONSOLE_SCREEN_BUFFER_INFOEX csbiexBefore = { 0 }; csbiexBefore.cbSize = sizeof(csbiexBefore); CONSOLE_SCREEN_BUFFER_INFOEX csbiexAfter = { 0 }; csbiexAfter.cbSize = sizeof(csbiexAfter); WriteFileHelper(hOut, csbiexBefore, csbiexAfter, pszTestString, cchTest); // We only expect characters to be processed and not printed if both processed mode and VT mode are on. bool const fProcessedNotPrinted = fProcessedOn && fVtOn; if (fProcessedNotPrinted) { PCSTR pszReadBackExpected = " "; DWORD const cchReadBackExpected = (DWORD)strlen(pszReadBackExpected); VERIFY_ARE_EQUAL(csbiexBefore.dwCursorPosition, csbiexAfter.dwCursorPosition, L"Verify cursor didn't move because the VT sequence was processed instead of printed."); wistd::unique_ptr<char[]> pszReadBack; ReadBackHelper(hOut, coordZero, cchReadBackExpected, pszReadBack); VERIFY_ARE_EQUAL(String(pszReadBackExpected), String(pszReadBack.get()), L"Verify that nothing was printed into the buffer."); } else { COORD coordExpected = csbiexBefore.dwCursorPosition; coordExpected.X += (SHORT)cchTest; VERIFY_ARE_EQUAL(coordExpected, csbiexAfter.dwCursorPosition, L"Verify cursor moved as characters should have been emitted, not consumed."); wistd::unique_ptr<char[]> pszReadBack; ReadBackHelper(hOut, coordZero, cchTest, pszReadBack); VERIFY_ARE_EQUAL(String(pszTestString), String(pszReadBack.get()), L"Verify that original test string was printed into the buffer."); } }
void FontTests::TestCurrentFontAPIsInvalid() { DWORD dwConsoleOutput; bool bMaximumWindow; String strOperation; VERIFY_SUCCEEDED(TestData::TryGetValue(L"dwConsoleOutput", dwConsoleOutput), L"Get output handle value"); VERIFY_SUCCEEDED(TestData::TryGetValue(L"bMaximumWindow", bMaximumWindow), L"Get maximized window value"); VERIFY_SUCCEEDED(TestData::TryGetValue(L"strOperation", strOperation), L"Get operation value"); const bool bUseValidOutputHandle = (dwConsoleOutput == 1); HANDLE hConsoleOutput; if (bUseValidOutputHandle) { hConsoleOutput = GetStdOutputHandle(); } else { hConsoleOutput = (HANDLE)dwConsoleOutput; } if (strOperation == L"Get") { CONSOLE_FONT_INFO cfi = {0}; if (bUseValidOutputHandle) { VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::GetCurrentConsoleFont(hConsoleOutput, (BOOL)bMaximumWindow, &cfi)); } else { VERIFY_WIN32_BOOL_FAILED(OneCoreDelay::GetCurrentConsoleFont(hConsoleOutput, (BOOL)bMaximumWindow, &cfi)); } } else if (strOperation == L"GetEx") { CONSOLE_FONT_INFOEX cfie = {0}; VERIFY_WIN32_BOOL_FAILED(OneCoreDelay::GetCurrentConsoleFontEx(hConsoleOutput, (BOOL)bMaximumWindow, &cfie)); } else if (strOperation == L"SetEx") { CONSOLE_FONT_INFOEX cfie = {0}; VERIFY_WIN32_BOOL_FAILED(OneCoreDelay::SetCurrentConsoleFontEx(hConsoleOutput, (BOOL)bMaximumWindow, &cfie)); } else { VERIFY_FAIL(L"Unrecognized operation"); } }
void NormalMapVK::PopulateCommandBuffer(const size_t i) { const auto CB = CommandPools[0].second[i];//CommandBuffers[i]; //const auto SCB = SecondaryCommandBuffers[i]; const auto FB = Framebuffers[i]; const auto Image = SwapchainImages[i]; const VkCommandBufferBeginInfo BeginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, nullptr }; VERIFY_SUCCEEDED(vkBeginCommandBuffer(CB, &BeginInfo)); { vkCmdSetViewport(CB, 0, static_cast<uint32_t>(Viewports.size()), Viewports.data()); vkCmdSetScissor(CB, 0, static_cast<uint32_t>(ScissorRects.size()), ScissorRects.data()); ClearColor(CB, Image, Colors::SkyBlue); const VkRenderPassBeginInfo RenderPassBeginInfo = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, RenderPass, FB, ScissorRects[0], 0, nullptr }; vkCmdBeginRenderPass(CB, &RenderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); { if (!DescriptorSets.empty()) { vkCmdBindDescriptorSets(CB, VK_PIPELINE_BIND_POINT_GRAPHICS, PipelineLayout, 0, static_cast<uint32_t>(DescriptorSets.size()), DescriptorSets.data(), 0, nullptr); } vkCmdBindPipeline(CB, VK_PIPELINE_BIND_POINT_GRAPHICS, Pipeline); vkCmdDrawIndirect(CB, IndirectBuffer, 0, 1, 0); } vkCmdEndRenderPass(CB); } VERIFY_SUCCEEDED(vkEndCommandBuffer(CB)); }
void FileTests::TestWriteFileWrapEOL() { bool fFlagOn; VERIFY_SUCCEEDED(TestData::TryGetValue(L"fFlagOn", fFlagOn)); HANDLE const hOut = GetStdOutputHandle(); VERIFY_IS_NOT_NULL(hOut, L"Verify we have the standard output handle."); CONSOLE_SCREEN_BUFFER_INFOEX csbiexOriginal = { 0 }; csbiexOriginal.cbSize = sizeof(csbiexOriginal); VERIFY_WIN32_BOOL_SUCCEEDED(GetConsoleScreenBufferInfoEx(hOut, &csbiexOriginal), L"Retrieve screen buffer properties at beginning of test."); if (fFlagOn) { VERIFY_WIN32_BOOL_SUCCEEDED(SetConsoleMode(hOut, ENABLE_WRAP_AT_EOL_OUTPUT), L"Set wrap at EOL."); } else { VERIFY_WIN32_BOOL_SUCCEEDED(SetConsoleMode(hOut, 0), L"Make sure wrap at EOL is off."); } COORD const coordZero = { 0 }; VERIFY_ARE_EQUAL(coordZero, csbiexOriginal.dwCursorPosition, L"Cursor should be at 0,0 in fresh buffer."); // Fill first row of the buffer with Z characters until 1 away from the end. for (SHORT i = 0; i < csbiexOriginal.dwSize.X - 1; i++) { WriteFile(hOut, "Z", 1, nullptr, nullptr); } CONSOLE_SCREEN_BUFFER_INFOEX csbiexBefore = { 0 }; csbiexBefore.cbSize = sizeof(csbiexBefore); CONSOLE_SCREEN_BUFFER_INFOEX csbiexAfter = { 0 }; csbiexAfter.cbSize = sizeof(csbiexAfter); COORD coordExpected = { 0 }; VERIFY_WIN32_BOOL_SUCCEEDED(GetConsoleScreenBufferInfoEx(hOut, &csbiexBefore), L"Get cursor position information before attempting to wrap at end of line."); VERIFY_WIN32_BOOL_SUCCEEDED(WriteFile(hOut, "Y", 1, nullptr, nullptr), L"Write of final character in line succeeded."); VERIFY_WIN32_BOOL_SUCCEEDED(GetConsoleScreenBufferInfoEx(hOut, &csbiexAfter), L"Get cursor position information after attempting to wrap at end of line."); if (fFlagOn) { Log::Comment(L"Cursor should go down a row if we tried to print at end of line."); coordExpected = csbiexBefore.dwCursorPosition; coordExpected.Y++; coordExpected.X = 0; } else { Log::Comment(L"Cursor shouldn't move when printing at end of line."); coordExpected = csbiexBefore.dwCursorPosition; } VERIFY_ARE_EQUAL(coordExpected, csbiexAfter.dwCursorPosition, L"Verify cursor moved as expected based on flag state."); }
void FontTests::TestGetFontSizeInvalid() { DWORD dwConsoleOutput; VERIFY_SUCCEEDED(TestData::TryGetValue(L"dwConsoleOutput", dwConsoleOutput), L"Get input handle value"); // Need to make sure that last error is cleared so that we can verify that lasterror was set by GetConsoleFontSize SetLastError(0); COORD coordFontSize = OneCoreDelay::GetConsoleFontSize((HANDLE)dwConsoleOutput, 0); VERIFY_ARE_EQUAL(coordFontSize, c_coordZero, L"Ensure (0,0) coord returned to indicate failure"); VERIFY_ARE_EQUAL(GetLastError(), (DWORD)ERROR_INVALID_HANDLE, L"Ensure last error was set appropriately"); }
void ComputeVK::PopulateCommandBuffer(const size_t i) { const auto CB = CommandPools[0].second[i];//CommandBuffers[i]; const VkCommandBufferBeginInfo BeginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, nullptr }; VERIFY_SUCCEEDED(vkBeginCommandBuffer(CB, &BeginInfo)); { if (!DescriptorSets.empty()) { vkCmdBindDescriptorSets(CB, VK_PIPELINE_BIND_POINT_COMPUTE, PipelineLayout, 0, static_cast<uint32_t>(DescriptorSets.size()), DescriptorSets.data(), 0, nullptr); } vkCmdBindPipeline(CB, VK_PIPELINE_BIND_POINT_COMPUTE, Pipeline); vkCmdDispatchIndirect(CB, IndirectBuffer, 0); } VERIFY_SUCCEEDED(vkEndCommandBuffer(CB)); }
void FontTests::TestFontScenario() { const HANDLE hConsoleOutput = GetStdOutputHandle(); Log::Comment(L"1. Ensure that the various GET APIs for font information align with each other."); CONSOLE_FONT_INFOEX cfie = {0}; cfie.cbSize = sizeof(cfie); VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::GetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfie)); CONSOLE_FONT_INFO cfi = {0}; VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::GetCurrentConsoleFont(hConsoleOutput, FALSE, &cfi)); VERIFY_ARE_EQUAL(cfi.nFont, cfie.nFont, L"Ensure regular and Ex APIs return same nFont"); VERIFY_ARE_NOT_EQUAL(cfi.dwFontSize, c_coordZero, L"Ensure non-zero font size"); VERIFY_ARE_EQUAL(cfi.dwFontSize, cfie.dwFontSize, L"Ensure regular and Ex APIs return same dwFontSize"); const COORD coordCurrentFontSize = OneCoreDelay::GetConsoleFontSize(hConsoleOutput, cfi.nFont); VERIFY_ARE_EQUAL(coordCurrentFontSize, cfi.dwFontSize, L"Ensure GetConsoleFontSize output matches GetCurrentConsoleFont"); // --------------------- Log::Comment(L"2. Ensure that our font settings round-trip appropriately through the Ex APIs"); CONSOLE_FONT_INFOEX cfieSet = {0}; cfieSet.cbSize = sizeof(cfieSet); cfieSet.dwFontSize.Y = 12; VERIFY_SUCCEEDED(StringCchCopy(cfieSet.FaceName, ARRAYSIZE(cfieSet.FaceName), L"Lucida Console")); VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::SetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfieSet)); CONSOLE_FONT_INFOEX cfiePost = {0}; cfiePost.cbSize = sizeof(cfiePost); VERIFY_WIN32_BOOL_SUCCEEDED(OneCoreDelay::GetCurrentConsoleFontEx(hConsoleOutput, FALSE, &cfiePost)); // Ensure that the two values we attempted to set did accurately round-trip through the API. // The other unspecified values may have been adjusted/updated by GDI. if (0 != NoThrowString(cfieSet.FaceName).CompareNoCase(cfiePost.FaceName)) { Log::Comment(L"We cannot test changing fonts on systems that do not have alternatives available. Skipping test."); Log::Result(WEX::Logging::TestResults::Result::Skipped); return; } VERIFY_ARE_EQUAL(cfieSet.dwFontSize.Y, cfiePost.dwFontSize.Y); // Ensure that the entire structure we received matches what we expect to usually get for this Lucida Console Size 12 ask. CONSOLE_FONT_INFOEX cfieFullExpected = { 0 }; cfieFullExpected.cbSize = sizeof(cfieFullExpected); wcscpy_s(cfieFullExpected.FaceName, L"Lucida Console"); if (!OneCoreDelay::IsIsWindowPresent()) { // On OneCore Windows without GDI, this is what we expect to get. cfieFullExpected.dwFontSize.X = 8; cfieFullExpected.dwFontSize.Y = 12; cfieFullExpected.FontFamily = 4; cfieFullExpected.FontWeight = 0; } else { // On client Windows with GDI, this is what we expect to get. cfieFullExpected.dwFontSize.X = 7; cfieFullExpected.dwFontSize.Y = 12; cfieFullExpected.FontFamily = 54; cfieFullExpected.FontWeight = 400; } VERIFY_ARE_EQUAL(cfieFullExpected, cfiePost); }