diff options
4 files changed, 92 insertions, 1 deletions
diff --git a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj index ea9cc9bd4..7c8dd3144 100644 --- a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj +++ b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj @@ -296,6 +296,7 @@ <ClCompile Include="..\..\..\tools\gfx-unit-test\sampler-array.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\shared-buffers-tests.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\shared-textures-tests.cpp" />
+ <ClCompile Include="..\..\..\tools\gfx-unit-test\swap-chain-resize-test.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\texture-types-tests.cpp" />
<ClCompile Include="..\..\..\tools\unit-test\slang-unit-test.cpp" />
</ItemGroup>
@@ -326,6 +327,9 @@ <ProjectReference Include="..\gfx-util\gfx-util.vcxproj">
<Project>{F5ADB74E-02A7-44FB-AA3B-FC02F8AC7A4B}</Project>
</ProjectReference>
+ <ProjectReference Include="..\platform\platform.vcxproj">
+ <Project>{3565FE5E-4FA3-11EB-AE93-0242AC130002}</Project>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters index d49f305fe..fd4b2707f 100644 --- a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters +++ b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters @@ -89,6 +89,9 @@ <ClCompile Include="..\..\..\tools\gfx-unit-test\shared-textures-tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\tools\gfx-unit-test\swap-chain-resize-test.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="..\..\..\tools\gfx-unit-test\texture-types-tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/premake5.lua b/premake5.lua index 75d093612..20dc6557c 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1389,7 +1389,7 @@ tool "slangd" uuid "092DAB9F-1DA5-4538-ADD7-1A8D1DBFD519" includedirs { "." } addSourceDir "tools/unit-test" - links { "core", "slang", "gfx", "gfx-util" } + links { "core", "slang", "gfx", "gfx-util", "platform" } toolSharedLibrary "slang-unit-test" uuid "0162864E-7651-4B5E-9105-C571105276EA" diff --git a/tools/gfx-unit-test/swap-chain-resize-test.cpp b/tools/gfx-unit-test/swap-chain-resize-test.cpp new file mode 100644 index 000000000..903deba30 --- /dev/null +++ b/tools/gfx-unit-test/swap-chain-resize-test.cpp @@ -0,0 +1,84 @@ +#include "tools/unit-test/slang-unit-test.h" + +#include "slang-gfx.h" +#include "gfx-test-util.h" +#include "tools/gfx-util/shader-cursor.h" +#include "tools/platform/window.h" +#include "source/core/slang-basic.h" + +using namespace gfx; +using namespace Slang; + +namespace gfx_test +{ + struct SwapchainResizeTest + { + IDevice* device; + UnitTestContext* context; + + RefPtr<platform::Window> window; + ComPtr<ICommandQueue> queue; + ComPtr<ISwapchain> swapchain; + + static const GfxCount width = 500; + static const GfxCount height = 500; + static const int kSwapchainImageCount = 2; + + void init(IDevice* device, UnitTestContext* context) + { + this->device = device; + this->context = context; + } + + void createRequiredResources() + { + platform::Application::init(); + + platform::WindowDesc windowDesc; + windowDesc.title = ""; + windowDesc.width = width; + windowDesc.height = height; + windowDesc.style = platform::WindowStyle::Default; + window = platform::Application::createWindow(windowDesc); + + ICommandQueue::Desc queueDesc = {}; + queueDesc.type = ICommandQueue::QueueType::Graphics; + queue = device->createCommandQueue(queueDesc); + + ISwapchain::Desc swapchainDesc = {}; + swapchainDesc.format = Format::R8G8B8A8_UNORM; + swapchainDesc.width = width; + swapchainDesc.height = height; + swapchainDesc.imageCount = kSwapchainImageCount; + swapchainDesc.queue = queue; + WindowHandle windowHandle = window->getNativeHandle().convert<WindowHandle>(); + if (SLANG_FAILED(device->createSwapchain(swapchainDesc, windowHandle, swapchain.writeRef()))) + SLANG_IGNORE_TEST; + } + + void run() + { + createRequiredResources(); + // TODO: Extend test by drawing for a few frames before and after resize to ensure swapchain remains usable + GFX_CHECK_CALL(swapchain->resize(700, 700)); + } + }; + + void swapchainResizeTestImpl(IDevice* device, UnitTestContext* context) + { + SwapchainResizeTest t; + t.init(device, context); + t.run(); + } + + SLANG_UNIT_TEST(swapchainResizeD3D12) + { + runTestImpl(swapchainResizeTestImpl, unitTestContext, RenderApiFlag::D3D12); + } + + SLANG_UNIT_TEST(swapchainResizeVulkan) + { + runTestImpl(swapchainResizeTestImpl, unitTestContext, RenderApiFlag::Vulkan); + } + +} |
