diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-09-13 15:59:15 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-13 15:59:15 -0400 |
| commit | c2e5d2468ad6a38cdb8a067da0678302f6cc6066 (patch) | |
| tree | 97c448d28e54068d84c422e9f172996b7a95f1ed | |
| parent | 0b6321b3f08c48e37e6b8256d420f05d9727fb5a (diff) | |
Refactor render-test to make cross platform (#1053)
* First pass of render-test refactor.
* Make window construction a function that can choose an implementation.
* Remove OpenGL as currently has windows dependency.
* Disable Vulkan as Renderer impl has dependency on windows.
* Pass Window in as parameter of 'update'.
* Add win-window.cpp as was missing.
* Fix warning on windows about signs during comparison.
| -rw-r--r-- | examples/hello-world/main.cpp | 2 | ||||
| -rw-r--r-- | examples/model-viewer/main.cpp | 2 | ||||
| -rw-r--r-- | premake5.lua | 64 | ||||
| -rw-r--r-- | slang.sln | 11 | ||||
| -rw-r--r-- | tools/cpu-render-test/cpu-render-test-tool.vcxproj | 213 | ||||
| -rw-r--r-- | tools/cpu-render-test/cpu-render-test-tool.vcxproj.filters | 60 | ||||
| -rw-r--r-- | tools/gfx/d3d/d3d-util.cpp (renamed from tools/gfx/d3d-util.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d/d3d-util.h (renamed from tools/gfx/d3d-util.h) | 4 | ||||
| -rw-r--r-- | tools/gfx/d3d11/render-d3d11.cpp (renamed from tools/gfx/render-d3d11.cpp) | 8 | ||||
| -rw-r--r-- | tools/gfx/d3d11/render-d3d11.h (renamed from tools/gfx/render-d3d11.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/circular-resource-heap-d3d12.cpp (renamed from tools/gfx/circular-resource-heap-d3d12.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/circular-resource-heap-d3d12.h (renamed from tools/gfx/circular-resource-heap-d3d12.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/descriptor-heap-d3d12.cpp (renamed from tools/gfx/descriptor-heap-d3d12.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/descriptor-heap-d3d12.h (renamed from tools/gfx/descriptor-heap-d3d12.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.cpp (renamed from tools/gfx/render-d3d12.cpp) | 8 | ||||
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.h (renamed from tools/gfx/render-d3d12.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/resource-d3d12.cpp (renamed from tools/gfx/resource-d3d12.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/d3d12/resource-d3d12.h (renamed from tools/gfx/resource-d3d12.h) | 4 | ||||
| -rw-r--r-- | tools/gfx/gfx.vcxproj | 54 | ||||
| -rw-r--r-- | tools/gfx/gfx.vcxproj.filters | 72 | ||||
| -rw-r--r-- | tools/gfx/open-gl/render-gl.cpp (renamed from tools/gfx/render-gl.cpp) | 4 | ||||
| -rw-r--r-- | tools/gfx/open-gl/render-gl.h (renamed from tools/gfx/render-gl.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/render.cpp | 33 | ||||
| -rw-r--r-- | tools/gfx/render.h | 5 | ||||
| -rw-r--r-- | tools/gfx/vulkan/render-vk.cpp (renamed from tools/gfx/render-vk.cpp) | 4 | ||||
| -rw-r--r-- | tools/gfx/vulkan/render-vk.h (renamed from tools/gfx/render-vk.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-api.cpp (renamed from tools/gfx/vk-api.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-api.h (renamed from tools/gfx/vk-api.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-device-queue.cpp (renamed from tools/gfx/vk-device-queue.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-device-queue.h (renamed from tools/gfx/vk-device-queue.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-module.cpp (renamed from tools/gfx/vk-module.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-module.h (renamed from tools/gfx/vk-module.h) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-swap-chain.cpp (renamed from tools/gfx/vk-swap-chain.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-swap-chain.h (renamed from tools/gfx/vk-swap-chain.h) | 2 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-util.cpp (renamed from tools/gfx/vk-util.cpp) | 0 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-util.h (renamed from tools/gfx/vk-util.h) | 2 | ||||
| -rw-r--r-- | tools/gfx/windows/win-window.cpp (renamed from tools/gfx/window.cpp) | 5 | ||||
| -rw-r--r-- | tools/render-test/cpu-memory-binding.cpp | 2 | ||||
| -rw-r--r-- | tools/render-test/render-test-main.cpp | 377 | ||||
| -rw-r--r-- | tools/render-test/render-test-tool.vcxproj | 3 | ||||
| -rw-r--r-- | tools/render-test/render-test-tool.vcxproj.filters | 9 | ||||
| -rw-r--r-- | tools/render-test/window.cpp | 21 | ||||
| -rw-r--r-- | tools/render-test/window.h | 45 | ||||
| -rw-r--r-- | tools/render-test/windows/win-window.cpp | 185 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 23 |
45 files changed, 534 insertions, 688 deletions
diff --git a/examples/hello-world/main.cpp b/examples/hello-world/main.cpp index bac378d96..4a15bd4fa 100644 --- a/examples/hello-world/main.cpp +++ b/examples/hello-world/main.cpp @@ -33,7 +33,7 @@ // design choices in their abstraction layer. // #include "gfx/render.h" -#include "gfx/render-d3d11.h" +#include "gfx/d3d11/render-d3d11.h" #include "gfx/window.h" using namespace gfx; diff --git a/examples/model-viewer/main.cpp b/examples/model-viewer/main.cpp index 66a53c245..5dcc51257 100644 --- a/examples/model-viewer/main.cpp +++ b/examples/model-viewer/main.cpp @@ -18,7 +18,7 @@ // #include "gfx/model.h" #include "gfx/render.h" -#include "gfx/render-d3d11.h" +#include "gfx/d3d11/render-d3d11.h" #include "gfx/vector-math.h" #include "gfx/window.h" #include "gfx/gui.h" diff --git a/premake5.lua b/premake5.lua index 63f83b00e..a1e729113 100644 --- a/premake5.lua +++ b/premake5.lua @@ -501,42 +501,26 @@ toolSharedLibrary "slang-reflection-test" -- TODO: Fix that requirement. -- -if isTargetWindows then - toolSharedLibrary "render-test" - uuid "61F7EB00-7281-4BF3-9470-7C2EA92620C3" - - includedirs { ".", "external", "source", "tools/gfx" } - links { "core", "slang", "gfx" } - - systemversion "10.0.14393.0" - - removefiles { "tools/render-test/cpu-render-test-main.cpp" } - - -- For Windows targets, we want to copy - -- dxcompiler.dll, and dxil.dll from the Windows SDK redistributable - -- directory into the output directory. - -- d3dcompiler_47.dll is copied from the external/slang-binaries submodule. - postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/" "windows-%{cfg.platform:lower()}"'} - -end - -toolSharedLibrary "cpu-render-test" - uuid "5701695E-7324-4B4D-977A-8D56C2A041B1" +toolSharedLibrary "render-test" + uuid "61F7EB00-7281-4BF3-9470-7C2EA92620C3" includedirs { ".", "external", "source", "tools/gfx" } links { "core", "slang", "gfx" } + + removefiles { "tools/render-test/cpu-render-test-main.cpp" } - addSourceDir("tools/render-test") - - removefiles { "tools/render-test/render-test-main.cpp" } - - if isTargetWindows then + if isTargetWindows then + addSourceDir "tools/render-test/windows" + + systemversion "10.0.14393.0" + -- For Windows targets, we want to copy -- dxcompiler.dll, and dxil.dll from the Windows SDK redistributable -- directory into the output directory. -- d3dcompiler_47.dll is copied from the external/slang-binaries submodule. - postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/"'} - end + postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/" "windows-%{cfg.platform:lower()}"'} + end + -- -- `gfx` is a utility library for doing GPU rendering -- and compute, which is used by both our testing and exmaples. @@ -561,15 +545,25 @@ tool "gfx" -- directory into the output directory. -- d3dcompiler_47.dll is copied from the external/slang-binaries submodule. postbuildcommands { '"$(SolutionDir)tools\\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/%{cfg.platform:lower()}/" "%{cfg.targetdir}/"'} + + addSourceDir "tools/gfx/vulkan" + addSourceDir "tools/gfx/open-gl" + addSourceDir "tools/gfx/d3d" + addSourceDir "tools/gfx/d3d11" + addSourceDir "tools/gfx/d3d12" + + addSourceDir "tools/gfx/windows" + + elseif targetDetail == "mingw" or targetDetail == "cygwin" then + -- Don't support any render techs... + elseif os.target() == "macosx" then + --addSourceDir "tools/gfx/open-gl" else - removefiles { "tools/gfx/circular-resource-heap-d3d12.cpp", "tools/gfx/d3d-util.cpp", "tools/gfx/descriptor-heap-d3d12.cpp", "tools/gfx/render-d3d11.cpp", "tools/gfx/render-d3d12.cpp", "tools/gfx/render-gl.cpp", "tools/gfx/resource-d3d12.cpp", "tools/gfx/render-vk.cpp", "tools/gfx/vk-swap-chain.cpp", "tools/gfx/window.cpp" } + -- Linux like + --addSourceDir "tools/gfx/vulkan" + --addSourceDir "tools/gfx/open-gl" end - - -- Remove VK from OSX gfx build - if os.target() == "macosx" then - removefiles { "tools/gfx/render-vk.cpp", "tools/gfx/vk-device-queue.cpp", "tools/gfx/vk-api.cpp", "tools/gfx/vk-module.cpp", "tools/gfx/vk-swap-chain.cpp", "tools/gfx/vk-util.cpp" } - end - + filter { "system:linux" } -- might be able to do pic(true) buildoptions{"-fPIC"} @@ -23,8 +23,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang-reflection-test-tool" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "render-test-tool", "tools\render-test\render-test-tool.vcxproj", "{61F7EB00-7281-4BF3-9470-7C2EA92620C3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpu-render-test-tool", "tools\cpu-render-test\cpu-render-test-tool.vcxproj", "{5701695E-7324-4B4D-977A-8D56C2A041B1}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slangc", "source\slangc\slangc.vcxproj", "{D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "slang", "source\slang\slang.vcxproj", "{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}" @@ -106,14 +104,6 @@ Global {61F7EB00-7281-4BF3-9470-7C2EA92620C3}.Release|Win32.Build.0 = Release|Win32 {61F7EB00-7281-4BF3-9470-7C2EA92620C3}.Release|x64.ActiveCfg = Release|x64 {61F7EB00-7281-4BF3-9470-7C2EA92620C3}.Release|x64.Build.0 = Release|x64 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Debug|Win32.ActiveCfg = Debug|Win32 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Debug|Win32.Build.0 = Debug|Win32 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Debug|x64.ActiveCfg = Debug|x64 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Debug|x64.Build.0 = Debug|x64 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Release|Win32.ActiveCfg = Release|Win32 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Release|Win32.Build.0 = Release|Win32 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Release|x64.ActiveCfg = Release|x64 - {5701695E-7324-4B4D-977A-8D56C2A041B1}.Release|x64.Build.0 = Release|x64 {D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}.Debug|Win32.ActiveCfg = Debug|Win32 {D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}.Debug|Win32.Build.0 = Debug|Win32 {D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}.Debug|x64.ActiveCfg = Debug|x64 @@ -150,6 +140,5 @@ Global {222F7498-B40C-4F3F-A704-DDEB91A4484A} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13} {C5ACCA6E-C04D-4B36-8516-3752B3C13C2F} = {57B5AA5E-C340-1823-CC51-9B17385C7423} {61F7EB00-7281-4BF3-9470-7C2EA92620C3} = {57B5AA5E-C340-1823-CC51-9B17385C7423} - {5701695E-7324-4B4D-977A-8D56C2A041B1} = {57B5AA5E-C340-1823-CC51-9B17385C7423} EndGlobalSection EndGlobal diff --git a/tools/cpu-render-test/cpu-render-test-tool.vcxproj b/tools/cpu-render-test/cpu-render-test-tool.vcxproj deleted file mode 100644 index 975aa61b6..000000000 --- a/tools/cpu-render-test/cpu-render-test-tool.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{5701695E-7324-4B4D-977A-8D56C2A041B1}</ProjectGuid> - <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> - <Keyword>Win32Proj</Keyword> - <RootNamespace>cpu-render-test-tool</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v140</PlatformToolset> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>..\..\bin\windows-x86\debug\</OutDir> - <IntDir>..\..\intermediate\windows-x86\debug\cpu-render-test-tool\</IntDir> - <TargetName>cpu-render-test-tool</TargetName> - <TargetExt>.dll</TargetExt> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <OutDir>..\..\bin\windows-x64\debug\</OutDir> - <IntDir>..\..\intermediate\windows-x64\debug\cpu-render-test-tool\</IntDir> - <TargetName>cpu-render-test-tool</TargetName> - <TargetExt>.dll</TargetExt> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>..\..\bin\windows-x86\release\</OutDir> - <IntDir>..\..\intermediate\windows-x86\release\cpu-render-test-tool\</IntDir> - <TargetName>cpu-render-test-tool</TargetName> - <TargetExt>.dll</TargetExt> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <OutDir>..\..\bin\windows-x64\release\</OutDir> - <IntDir>..\..\intermediate\windows-x64\release\cpu-render-test-tool\</IntDir> - <TargetName>cpu-render-test-tool</TargetName> - <TargetExt>.dll</TargetExt> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>_DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - <Optimization>Disabled</Optimization> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <ImportLibrary>..\..\bin\windows-x86\debug\cpu-render-test-tool.lib</ImportLibrary> - </Link> - <PostBuildEvent> - <Command>"$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/debug/"</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>_DEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - <Optimization>Disabled</Optimization> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <ImportLibrary>..\..\bin\windows-x64\debug\cpu-render-test-tool.lib</ImportLibrary> - </Link> - <PostBuildEvent> - <Command>"$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/debug/"</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <Optimization>Full</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <MinimalRebuild>false</MinimalRebuild> - <StringPooling>true</StringPooling> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <ImportLibrary>..\..\bin\windows-x86\release\cpu-render-test-tool.lib</ImportLibrary> - </Link> - <PostBuildEvent> - <Command>"$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x86/" "../../bin/windows-x86/release/"</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <PrecompiledHeader>NotUsing</PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <PreprocessorDefinitions>NDEBUG;SLANG_SHARED_LIBRARY_TOOL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\..;..\..\external;..\..\source;..\gfx;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <Optimization>Full</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <MinimalRebuild>false</MinimalRebuild> - <StringPooling>true</StringPooling> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <ImportLibrary>..\..\bin\windows-x64\release\cpu-render-test-tool.lib</ImportLibrary> - </Link> - <PostBuildEvent> - <Command>"$(SolutionDir)tools\copy-hlsl-libs.bat" "$(WindowsSdkDir)Redist/D3D/x64/" "../../bin/windows-x64/release/"</Command> - </PostBuildEvent> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="..\render-test\cpu-compute-util.h" /> - <ClInclude Include="..\render-test\cpu-memory-binding.h" /> - <ClInclude Include="..\render-test\options.h" /> - <ClInclude Include="..\render-test\png-serialize-util.h" /> - <ClInclude Include="..\render-test\shader-input-layout.h" /> - <ClInclude Include="..\render-test\shader-renderer-util.h" /> - <ClInclude Include="..\render-test\slang-support.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\render-test\cpu-compute-util.cpp" /> - <ClCompile Include="..\render-test\cpu-memory-binding.cpp" /> - <ClCompile Include="..\render-test\cpu-render-test-main.cpp" /> - <ClCompile Include="..\render-test\options.cpp" /> - <ClCompile Include="..\render-test\png-serialize-util.cpp" /> - <ClCompile Include="..\render-test\shader-input-layout.cpp" /> - <ClCompile Include="..\render-test\shader-renderer-util.cpp" /> - <ClCompile Include="..\render-test\slang-support.cpp" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\..\source\core\core.vcxproj"> - <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project> - </ProjectReference> - <ProjectReference Include="..\..\source\slang\slang.vcxproj"> - <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project> - </ProjectReference> - <ProjectReference Include="..\gfx\gfx.vcxproj"> - <Project>{222F7498-B40C-4F3F-A704-DDEB91A4484A}</Project> - </ProjectReference> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/tools/cpu-render-test/cpu-render-test-tool.vcxproj.filters b/tools/cpu-render-test/cpu-render-test-tool.vcxproj.filters deleted file mode 100644 index 2b822a5be..000000000 --- a/tools/cpu-render-test/cpu-render-test-tool.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <Filter Include="Header Files"> - <UniqueIdentifier>{21EB8090-0D4E-1035-B6D3-48EBA215DCB7}</UniqueIdentifier> - </Filter> - <Filter Include="Source Files"> - <UniqueIdentifier>{E9C7FDCE-D52A-8D73-7EB0-C5296AF258F6}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\render-test\cpu-compute-util.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\render-test\cpu-memory-binding.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\render-test\options.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\render-test\png-serialize-util.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\render-test\shader-input-layout.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\render-test\shader-renderer-util.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\render-test\slang-support.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ClCompile Include="..\render-test\cpu-compute-util.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\cpu-memory-binding.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\cpu-render-test-main.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\options.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\png-serialize-util.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\shader-input-layout.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\shader-renderer-util.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\render-test\slang-support.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/tools/gfx/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp index 3f25ff46c..3f25ff46c 100644 --- a/tools/gfx/d3d-util.cpp +++ b/tools/gfx/d3d/d3d-util.cpp diff --git a/tools/gfx/d3d-util.h b/tools/gfx/d3d/d3d-util.h index 6bcee054c..fd7a31d3a 100644 --- a/tools/gfx/d3d-util.h +++ b/tools/gfx/d3d/d3d-util.h @@ -8,9 +8,9 @@ #include "../../slang-com-ptr.h" #include "../../source/core/slang-list.h" -#include "flag-combiner.h" +#include "../flag-combiner.h" -#include "render.h" +#include "../render.h" #include <D3Dcommon.h> #include <DXGIFormat.h> diff --git a/tools/gfx/render-d3d11.cpp b/tools/gfx/d3d11/render-d3d11.cpp index 5911d6e9c..cf2ae75e2 100644 --- a/tools/gfx/render-d3d11.cpp +++ b/tools/gfx/d3d11/render-d3d11.cpp @@ -5,17 +5,17 @@ #include "render-d3d11.h" //WORKING: #include "options.h" -#include "render.h" -#include "d3d-util.h" +#include "../render.h" +#include "../d3d/d3d-util.h" -#include "surface.h" +#include "../surface.h" // In order to use the Slang API, we need to include its header //#include <slang.h> #include "../../slang-com-ptr.h" -#include "flag-combiner.h" +#include "../flag-combiner.h" // We will be rendering with Direct3D 11, so we need to include // the Windows and D3D11 headers diff --git a/tools/gfx/render-d3d11.h b/tools/gfx/d3d11/render-d3d11.h index 9e671d541..9e671d541 100644 --- a/tools/gfx/render-d3d11.h +++ b/tools/gfx/d3d11/render-d3d11.h diff --git a/tools/gfx/circular-resource-heap-d3d12.cpp b/tools/gfx/d3d12/circular-resource-heap-d3d12.cpp index 685dd364f..685dd364f 100644 --- a/tools/gfx/circular-resource-heap-d3d12.cpp +++ b/tools/gfx/d3d12/circular-resource-heap-d3d12.cpp diff --git a/tools/gfx/circular-resource-heap-d3d12.h b/tools/gfx/d3d12/circular-resource-heap-d3d12.h index bf9f412cf..bf9f412cf 100644 --- a/tools/gfx/circular-resource-heap-d3d12.h +++ b/tools/gfx/d3d12/circular-resource-heap-d3d12.h diff --git a/tools/gfx/descriptor-heap-d3d12.cpp b/tools/gfx/d3d12/descriptor-heap-d3d12.cpp index 382fc3219..382fc3219 100644 --- a/tools/gfx/descriptor-heap-d3d12.cpp +++ b/tools/gfx/d3d12/descriptor-heap-d3d12.cpp diff --git a/tools/gfx/descriptor-heap-d3d12.h b/tools/gfx/d3d12/descriptor-heap-d3d12.h index a546395d8..a546395d8 100644 --- a/tools/gfx/descriptor-heap-d3d12.h +++ b/tools/gfx/d3d12/descriptor-heap-d3d12.h diff --git a/tools/gfx/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index e3ce7161a..ad7b898f5 100644 --- a/tools/gfx/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -4,9 +4,9 @@ #include "render-d3d12.h" //WORKING:#include "options.h" -#include "render.h" +#include "../render.h" -#include "surface.h" +#include "../surface.h" // In order to use the Slang API, we need to include its header @@ -26,13 +26,13 @@ #include <d3dcompiler.h> #include "../../slang-com-ptr.h" -#include "flag-combiner.h" +#include "../flag-combiner.h" #include "resource-d3d12.h" #include "descriptor-heap-d3d12.h" #include "circular-resource-heap-d3d12.h" -#include "d3d-util.h" +#include "../d3d/d3d-util.h" // We will use the C standard library just for printing error messages. #include <stdio.h> diff --git a/tools/gfx/render-d3d12.h b/tools/gfx/d3d12/render-d3d12.h index b8a3104c0..b8a3104c0 100644 --- a/tools/gfx/render-d3d12.h +++ b/tools/gfx/d3d12/render-d3d12.h diff --git a/tools/gfx/resource-d3d12.cpp b/tools/gfx/d3d12/resource-d3d12.cpp index 27de868b6..27de868b6 100644 --- a/tools/gfx/resource-d3d12.cpp +++ b/tools/gfx/d3d12/resource-d3d12.cpp diff --git a/tools/gfx/resource-d3d12.h b/tools/gfx/d3d12/resource-d3d12.h index 1764adf9d..9e3c3262b 100644 --- a/tools/gfx/resource-d3d12.h +++ b/tools/gfx/d3d12/resource-d3d12.h @@ -1,4 +1,4 @@ -// resource-d3d12.h +// resource-d3d12.h #pragma once #define WIN32_LEAN_AND_MEAN @@ -11,7 +11,7 @@ #include <d3d12.h> #include "../../slang-com-ptr.h" -#include "d3d-util.h" +#include "../d3d/d3d-util.h" namespace gfx { diff --git a/tools/gfx/gfx.vcxproj b/tools/gfx/gfx.vcxproj index 059a99618..d4b1885a8 100644 --- a/tools/gfx/gfx.vcxproj +++ b/tools/gfx/gfx.vcxproj @@ -171,47 +171,47 @@ </PostBuildEvent> </ItemDefinitionGroup> <ItemGroup> - <ClInclude Include="circular-resource-heap-d3d12.h" /> - <ClInclude Include="d3d-util.h" /> - <ClInclude Include="descriptor-heap-d3d12.h" /> + <ClInclude Include="d3d\d3d-util.h" /> + <ClInclude Include="d3d11\render-d3d11.h" /> + <ClInclude Include="d3d12\circular-resource-heap-d3d12.h" /> + <ClInclude Include="d3d12\descriptor-heap-d3d12.h" /> + <ClInclude Include="d3d12\render-d3d12.h" /> + <ClInclude Include="d3d12\resource-d3d12.h" /> <ClInclude Include="flag-combiner.h" /> <ClInclude Include="gui.h" /> <ClInclude Include="model.h" /> - <ClInclude Include="render-d3d11.h" /> - <ClInclude Include="render-d3d12.h" /> - <ClInclude Include="render-gl.h" /> - <ClInclude Include="render-vk.h" /> + <ClInclude Include="open-gl\render-gl.h" /> <ClInclude Include="render.h" /> - <ClInclude Include="resource-d3d12.h" /> <ClInclude Include="surface.h" /> <ClInclude Include="vector-math.h" /> - <ClInclude Include="vk-api.h" /> - <ClInclude Include="vk-device-queue.h" /> - <ClInclude Include="vk-module.h" /> - <ClInclude Include="vk-swap-chain.h" /> - <ClInclude Include="vk-util.h" /> + <ClInclude Include="vulkan\render-vk.h" /> + <ClInclude Include="vulkan\vk-api.h" /> + <ClInclude Include="vulkan\vk-device-queue.h" /> + <ClInclude Include="vulkan\vk-module.h" /> + <ClInclude Include="vulkan\vk-swap-chain.h" /> + <ClInclude Include="vulkan\vk-util.h" /> <ClInclude Include="window.h" /> </ItemGroup> <ItemGroup> - <ClCompile Include="circular-resource-heap-d3d12.cpp" /> - <ClCompile Include="d3d-util.cpp" /> - <ClCompile Include="descriptor-heap-d3d12.cpp" /> + <ClCompile Include="d3d\d3d-util.cpp" /> + <ClCompile Include="d3d11\render-d3d11.cpp" /> + <ClCompile Include="d3d12\circular-resource-heap-d3d12.cpp" /> + <ClCompile Include="d3d12\descriptor-heap-d3d12.cpp" /> + <ClCompile Include="d3d12\render-d3d12.cpp" /> + <ClCompile Include="d3d12\resource-d3d12.cpp" /> <ClCompile Include="flag-combiner.cpp" /> <ClCompile Include="gui.cpp" /> <ClCompile Include="model.cpp" /> - <ClCompile Include="render-d3d11.cpp" /> - <ClCompile Include="render-d3d12.cpp" /> - <ClCompile Include="render-gl.cpp" /> - <ClCompile Include="render-vk.cpp" /> + <ClCompile Include="open-gl\render-gl.cpp" /> <ClCompile Include="render.cpp" /> - <ClCompile Include="resource-d3d12.cpp" /> <ClCompile Include="surface.cpp" /> - <ClCompile Include="vk-api.cpp" /> - <ClCompile Include="vk-device-queue.cpp" /> - <ClCompile Include="vk-module.cpp" /> - <ClCompile Include="vk-swap-chain.cpp" /> - <ClCompile Include="vk-util.cpp" /> - <ClCompile Include="window.cpp" /> + <ClCompile Include="vulkan\render-vk.cpp" /> + <ClCompile Include="vulkan\vk-api.cpp" /> + <ClCompile Include="vulkan\vk-device-queue.cpp" /> + <ClCompile Include="vulkan\vk-module.cpp" /> + <ClCompile Include="vulkan\vk-swap-chain.cpp" /> + <ClCompile Include="vulkan\vk-util.cpp" /> + <ClCompile Include="windows\win-window.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/tools/gfx/gfx.vcxproj.filters b/tools/gfx/gfx.vcxproj.filters index 95b5f31d2..1c27e4f24 100644 --- a/tools/gfx/gfx.vcxproj.filters +++ b/tools/gfx/gfx.vcxproj.filters @@ -9,61 +9,61 @@ </Filter> </ItemGroup> <ItemGroup> - <ClInclude Include="circular-resource-heap-d3d12.h"> + <ClInclude Include="d3d\d3d-util.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="d3d-util.h"> + <ClInclude Include="d3d11\render-d3d11.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="descriptor-heap-d3d12.h"> + <ClInclude Include="d3d12\circular-resource-heap-d3d12.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="flag-combiner.h"> + <ClInclude Include="d3d12\descriptor-heap-d3d12.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="gui.h"> + <ClInclude Include="d3d12\render-d3d12.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="model.h"> + <ClInclude Include="d3d12\resource-d3d12.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="render-d3d11.h"> + <ClInclude Include="flag-combiner.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="render-d3d12.h"> + <ClInclude Include="gui.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="render-gl.h"> + <ClInclude Include="model.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="render-vk.h"> + <ClInclude Include="open-gl\render-gl.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="render.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="resource-d3d12.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="surface.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="vector-math.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="vk-api.h"> + <ClInclude Include="vulkan\render-vk.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="vulkan\vk-api.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="vk-device-queue.h"> + <ClInclude Include="vulkan\vk-device-queue.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="vk-module.h"> + <ClInclude Include="vulkan\vk-module.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="vk-swap-chain.h"> + <ClInclude Include="vulkan\vk-swap-chain.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="vk-util.h"> + <ClInclude Include="vulkan\vk-util.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="window.h"> @@ -71,61 +71,61 @@ </ClInclude> </ItemGroup> <ItemGroup> - <ClCompile Include="circular-resource-heap-d3d12.cpp"> + <ClCompile Include="d3d\d3d-util.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="d3d-util.cpp"> + <ClCompile Include="d3d11\render-d3d11.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="descriptor-heap-d3d12.cpp"> + <ClCompile Include="d3d12\circular-resource-heap-d3d12.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="flag-combiner.cpp"> + <ClCompile Include="d3d12\descriptor-heap-d3d12.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="gui.cpp"> + <ClCompile Include="d3d12\render-d3d12.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="model.cpp"> + <ClCompile Include="d3d12\resource-d3d12.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="render-d3d11.cpp"> + <ClCompile Include="flag-combiner.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="render-d3d12.cpp"> + <ClCompile Include="gui.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="render-gl.cpp"> + <ClCompile Include="model.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="render-vk.cpp"> + <ClCompile Include="open-gl\render-gl.cpp"> <Filter>Source Files</Filter> </ClCompile> <ClCompile Include="render.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="resource-d3d12.cpp"> + <ClCompile Include="surface.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="surface.cpp"> + <ClCompile Include="vulkan\render-vk.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="vk-api.cpp"> + <ClCompile Include="vulkan\vk-api.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="vk-device-queue.cpp"> + <ClCompile Include="vulkan\vk-device-queue.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="vk-module.cpp"> + <ClCompile Include="vulkan\vk-module.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="vk-swap-chain.cpp"> + <ClCompile Include="vulkan\vk-swap-chain.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="vk-util.cpp"> + <ClCompile Include="vulkan\vk-util.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="window.cpp"> + <ClCompile Include="windows\win-window.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> diff --git a/tools/gfx/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp index 975b4e140..91c31b71d 100644 --- a/tools/gfx/render-gl.cpp +++ b/tools/gfx/open-gl/render-gl.cpp @@ -2,7 +2,7 @@ #include "render-gl.h" //WORKING:#include "options.h" -#include "render.h" +#include "../render.h" #include <stdio.h> #include <stdlib.h> @@ -10,7 +10,7 @@ #include "core/slang-secure-crt.h" #include "external/stb/stb_image_write.h" -#include "surface.h" +#include "../surface.h" // TODO(tfoley): eventually we should be able to run these // tests on non-Windows targets to confirm that cross-compilation diff --git a/tools/gfx/render-gl.h b/tools/gfx/open-gl/render-gl.h index 055031d38..055031d38 100644 --- a/tools/gfx/render-gl.h +++ b/tools/gfx/open-gl/render-gl.h diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp index 44bb4fb04..785343927 100644 --- a/tools/gfx/render.cpp +++ b/tools/gfx/render.cpp @@ -3,6 +3,11 @@ #include "../../source/core/slang-math.h" +#include "d3d11/render-d3d11.h" +#include "d3d12/render-d3d12.h" +#include "open-gl/render-gl.h" +#include "vulkan/render-vk.h" + namespace gfx { using namespace Slang; @@ -404,4 +409,32 @@ ProjectionStyle RendererUtil::getProjectionStyle(RendererType type) } } +/* static */ RendererUtil::CreateFunc RendererUtil::getCreateFunc(RendererType type) +{ + switch (type) + { +#if SLANG_WINDOWS_FAMILY + case RendererType::DirectX11: + { + return &createD3D11Renderer; + } + case RendererType::DirectX12: + { + return &createD3D12Renderer; + } + case RendererType::OpenGl: + { + return &createGLRenderer; + } + case RendererType::Vulkan: + { + return &createVKRenderer; + } +#endif + + default: return nullptr; + } +} + + } // renderer_test diff --git a/tools/gfx/render.h b/tools/gfx/render.h index 4a8458e96..42cf5fe60 100644 --- a/tools/gfx/render.h +++ b/tools/gfx/render.h @@ -972,6 +972,8 @@ inline void Renderer::setVertexBuffer(UInt slot, BufferResource* buffer, UInt st /// Functions that are around Renderer and it's types struct RendererUtil { + typedef Renderer* (*CreateFunc)(); + /// Gets the size in bytes of a Format type. Returns 0 if a size is not defined/invalid SLANG_FORCE_INLINE static size_t getFormatSize(Format format) { return s_formatSize[int(format)]; } /// Given a renderer type, gets a projection style @@ -986,6 +988,9 @@ struct RendererUtil /// Get as text static Slang::UnownedStringSlice toText(RendererType type); + /// Given a type returns a function that can construct it, or nullptr if there isn't one + static CreateFunc getCreateFunc(RendererType type); + private: static void compileTimeAsserts(); static const uint8_t s_formatSize[]; // Maps Format::XXX to a size in bytes; diff --git a/tools/gfx/render-vk.cpp b/tools/gfx/vulkan/render-vk.cpp index 77b593565..2221187ed 100644 --- a/tools/gfx/render-vk.cpp +++ b/tools/gfx/vulkan/render-vk.cpp @@ -2,7 +2,7 @@ #include "render-vk.h" //WORKING:#include "options.h" -#include "render.h" +#include "../render.h" #include "../../source/core/slang-smart-pointer.h" @@ -11,7 +11,7 @@ #include "vk-device-queue.h" #include "vk-swap-chain.h" -#include "surface.h" +#include "../surface.h" // Vulkan has a different coordinate system to ogl // http://anki3d.org/vulkan-coordinate-system/ diff --git a/tools/gfx/render-vk.h b/tools/gfx/vulkan/render-vk.h index 14a8e403a..14a8e403a 100644 --- a/tools/gfx/render-vk.h +++ b/tools/gfx/vulkan/render-vk.h diff --git a/tools/gfx/vk-api.cpp b/tools/gfx/vulkan/vk-api.cpp index 50f80aa26..50f80aa26 100644 --- a/tools/gfx/vk-api.cpp +++ b/tools/gfx/vulkan/vk-api.cpp diff --git a/tools/gfx/vk-api.h b/tools/gfx/vulkan/vk-api.h index 001f44d19..001f44d19 100644 --- a/tools/gfx/vk-api.h +++ b/tools/gfx/vulkan/vk-api.h diff --git a/tools/gfx/vk-device-queue.cpp b/tools/gfx/vulkan/vk-device-queue.cpp index 10a3d0e3b..10a3d0e3b 100644 --- a/tools/gfx/vk-device-queue.cpp +++ b/tools/gfx/vulkan/vk-device-queue.cpp diff --git a/tools/gfx/vk-device-queue.h b/tools/gfx/vulkan/vk-device-queue.h index d57483ec0..d57483ec0 100644 --- a/tools/gfx/vk-device-queue.h +++ b/tools/gfx/vulkan/vk-device-queue.h diff --git a/tools/gfx/vk-module.cpp b/tools/gfx/vulkan/vk-module.cpp index 4e92a3d2c..4e92a3d2c 100644 --- a/tools/gfx/vk-module.cpp +++ b/tools/gfx/vulkan/vk-module.cpp diff --git a/tools/gfx/vk-module.h b/tools/gfx/vulkan/vk-module.h index 4d18823ca..4d18823ca 100644 --- a/tools/gfx/vk-module.h +++ b/tools/gfx/vulkan/vk-module.h diff --git a/tools/gfx/vk-swap-chain.cpp b/tools/gfx/vulkan/vk-swap-chain.cpp index 5cf2e96ae..5cf2e96ae 100644 --- a/tools/gfx/vk-swap-chain.cpp +++ b/tools/gfx/vulkan/vk-swap-chain.cpp diff --git a/tools/gfx/vk-swap-chain.h b/tools/gfx/vulkan/vk-swap-chain.h index f8ad98a83..57d1173b8 100644 --- a/tools/gfx/vk-swap-chain.h +++ b/tools/gfx/vulkan/vk-swap-chain.h @@ -4,7 +4,7 @@ #include "vk-api.h" #include "vk-device-queue.h" -#include "render.h" +#include "../render.h" #include "../../source/core/slang-list.h" diff --git a/tools/gfx/vk-util.cpp b/tools/gfx/vulkan/vk-util.cpp index e8940d1b2..e8940d1b2 100644 --- a/tools/gfx/vk-util.cpp +++ b/tools/gfx/vulkan/vk-util.cpp diff --git a/tools/gfx/vk-util.h b/tools/gfx/vulkan/vk-util.h index edba3a7d2..c8194789d 100644 --- a/tools/gfx/vk-util.h +++ b/tools/gfx/vulkan/vk-util.h @@ -2,7 +2,7 @@ #pragma once #include "vk-api.h" -#include "render.h" +#include "../render.h" // Macros to make testing vulkan return codes simpler diff --git a/tools/gfx/window.cpp b/tools/gfx/windows/win-window.cpp index 02a083ef2..45315a27a 100644 --- a/tools/gfx/window.cpp +++ b/tools/gfx/windows/win-window.cpp @@ -1,5 +1,5 @@ -// window.cpp -#include "window.h" +// win-window.cpp +#include "../window.h" #include <stdio.h> @@ -12,7 +12,6 @@ #include <stdint.h> - #if _WIN32 #include <Windows.h> #include <Windowsx.h> diff --git a/tools/render-test/cpu-memory-binding.cpp b/tools/render-test/cpu-memory-binding.cpp index c2d853aa8..3bf1f1bbd 100644 --- a/tools/render-test/cpu-memory-binding.cpp +++ b/tools/render-test/cpu-memory-binding.cpp @@ -91,7 +91,7 @@ SlangResult CPUMemoryBinding::init(slang::ShaderReflection* reflection, int entr } { - auto entryPointCount = reflection->getEntryPointCount(); + auto entryPointCount = int(reflection->getEntryPointCount()); if (entryPointIndex < 0 || entryPointIndex >= entryPointCount) { SLANG_ASSERT(!"Entry point index out of range"); diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 5b9621142..d2ef2a746 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -1,11 +1,9 @@ // render-test-main.cpp +#define _CRT_SECURE_NO_WARNINGS 1 + #include "options.h" #include "render.h" -#include "render-d3d11.h" -#include "render-d3d12.h" -#include "render-gl.h" -#include "render-vk.h" #include "slang-support.h" #include "surface.h" @@ -21,20 +19,12 @@ #include <stdio.h> #include <stdlib.h> +#include "window.h" + #include "../../source/core/slang-test-tool-util.h" #include "cpu-compute-util.h" -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include <Windows.h> -#undef WIN32_LEAN_AND_MEAN -#undef NOMINMAX - -#ifdef _MSC_VER -#pragma warning(disable: 4996) -#endif - namespace renderer_test { using Slang::Result; @@ -42,141 +32,6 @@ using Slang::Result; int gWindowWidth = 1024; int gWindowHeight = 768; -class Window: public RefObject -{ -public: - SlangResult initialize(int width, int height); - - void show(); - - void* getHandle() const { return m_hwnd; } - - Window() {} - ~Window(); - - static LRESULT CALLBACK windowProc(HWND windowHandle, - UINT message, - WPARAM wParam, - LPARAM lParam); - -protected: - - HINSTANCE m_hinst = nullptr; - HWND m_hwnd = nullptr; -}; - -// -// We use a bare-minimum window procedure to get things up and running. -// - -/* static */LRESULT CALLBACK Window::windowProc( - HWND windowHandle, - UINT message, - WPARAM wParam, - LPARAM lParam) -{ - switch (message) - { - case WM_CLOSE: - PostQuitMessage(0); - return 0; - } - - return DefWindowProcW(windowHandle, message, wParam, lParam); -} - -static ATOM _getWindowClassAtom(HINSTANCE hinst) -{ - static ATOM s_windowClassAtom; - - if (s_windowClassAtom) - { - return s_windowClassAtom; - } - WNDCLASSEXW windowClassDesc; - windowClassDesc.cbSize = sizeof(windowClassDesc); - windowClassDesc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - windowClassDesc.lpfnWndProc = &Window::windowProc; - windowClassDesc.cbClsExtra = 0; - windowClassDesc.cbWndExtra = 0; - windowClassDesc.hInstance = hinst; - windowClassDesc.hIcon = 0; - windowClassDesc.hCursor = 0; - windowClassDesc.hbrBackground = 0; - windowClassDesc.lpszMenuName = 0; - windowClassDesc.lpszClassName = L"SlangRenderTest"; - windowClassDesc.hIconSm = 0; - s_windowClassAtom = RegisterClassExW(&windowClassDesc); - - return s_windowClassAtom; -} - -SlangResult Window::initialize(int widthIn, int heightIn) -{ - // Do initial window-creation stuff here, rather than in the renderer-specific files - - m_hinst = GetModuleHandleA(0); - - // First we register a window class. - ATOM windowClassAtom = _getWindowClassAtom(m_hinst); - if (!windowClassAtom) - { - fprintf(stderr, "error: failed to register window class\n"); - return SLANG_FAIL; - } - - // Next, we create a window using that window class. - - // We will create a borderless window since our screen-capture logic in GL - // seems to get thrown off by having to deal with a window frame. - DWORD windowStyle = WS_POPUP; - DWORD windowExtendedStyle = 0; - - RECT windowRect = { 0, 0, widthIn, heightIn }; - AdjustWindowRectEx(&windowRect, windowStyle, /*hasMenu=*/false, windowExtendedStyle); - - { - auto width = windowRect.right - windowRect.left; - auto height = windowRect.bottom - windowRect.top; - - LPWSTR windowName = L"Slang Render Test"; - m_hwnd = CreateWindowExW( - windowExtendedStyle, - (LPWSTR)windowClassAtom, - windowName, - windowStyle, - 0, 0, // x, y - width, height, - NULL, // parent - NULL, // menu - m_hinst, - NULL); - } - if (!m_hwnd) - { - fprintf(stderr, "error: failed to create window\n"); - return SLANG_FAIL; - } - - return SLANG_OK; -} - - -void Window::show() -{ - // Once initialization is all complete, we show the window... - int showCommand = SW_SHOW; - ShowWindow(m_hwnd, showCommand); -} - -Window::~Window() -{ - if (m_hwnd) - { - DestroyWindow(m_hwnd); - } -} - // // For the purposes of a small example, we will define the vertex data for a // single triangle directly in the source file. It should be easy to extend @@ -200,16 +55,19 @@ static const int kVertexCount = SLANG_COUNT_OF(kVertexData); using namespace Slang; -class RenderTestApp +class RenderTestApp : public WindowListener { public: - // At initialization time, we are going to load and compile our Slang shader - // code, and then create the API objects we need for rendering. - Result initialize(SlangSession* session, Renderer* renderer, Options::ShaderProgramType shaderType, const ShaderCompilerUtil::Input& input); - void runCompute(); - void renderFrame(); - void finalize(); + // WindowListener + virtual Result update(Window* window) SLANG_OVERRIDE; + + // At initialization time, we are going to load and compile our Slang shader + // code, and then create the API objects we need for rendering. + Result initialize(SlangSession* session, Renderer* renderer, const Options& options, const ShaderCompilerUtil::Input& input); + void runCompute(); + void renderFrame(); + void finalize(); BindingStateImpl* getBindingState() const { return m_bindingState; } @@ -235,11 +93,15 @@ class RenderTestApp ShaderInputLayout m_shaderInputLayout; ///< The binding layout int m_numAddedConstantBuffers; ///< Constant buffers can be added to the binding directly. Will be added at the end. + + Options m_options; }; -SlangResult RenderTestApp::initialize(SlangSession* session, Renderer* renderer, Options::ShaderProgramType shaderType, const ShaderCompilerUtil::Input& input) +SlangResult RenderTestApp::initialize(SlangSession* session, Renderer* renderer, const Options& options, const ShaderCompilerUtil::Input& input) { - SLANG_RETURN_ON_FAIL(_initializeShaders(session, renderer, shaderType, input)); + m_options = options; + + SLANG_RETURN_ON_FAIL(_initializeShaders(session, renderer, options.shaderType, input)); m_numAddedConstantBuffers = 0; m_renderer = renderer; @@ -260,7 +122,7 @@ SlangResult RenderTestApp::initialize(SlangSession* session, Renderer* renderer, // TODO: Should probably be more sophisticated than this - with 'dynamic' constant buffer/s binding always being specified // in the test file RefPtr<BufferResource> addedConstantBuffer; - switch(shaderType) + switch(m_options.shaderType) { default: break; @@ -298,7 +160,7 @@ SlangResult RenderTestApp::initialize(SlangSession* session, Renderer* renderer, return SLANG_FAIL; { - switch(shaderType) + switch(m_options.shaderType) { default: assert(!"unexpected test shader type"); @@ -435,6 +297,52 @@ Result RenderTestApp::writeScreen(const char* filename) return PngSerializeUtil::write(filename, surface); } +Result RenderTestApp::update(Window* window) +{ + // Whenever we don't have Windows events to process, we render a frame. + if (m_options.shaderType == Options::ShaderProgramType::Compute) + { + runCompute(); + } + else + { + static const float kClearColor[] = { 0.25, 0.25, 0.25, 1.0 }; + m_renderer->setClearColor(kClearColor); + m_renderer->clearFrame(); + + renderFrame(); + } + + // If we are in a mode where output is requested, we need to snapshot the back buffer here + if (m_options.outputPath) + { + // Submit the work + m_renderer->submitGpuWork(); + // Wait until everything is complete + m_renderer->waitForGpu(); + + if (gOptions.shaderType == Options::ShaderProgramType::Compute || gOptions.shaderType == Options::ShaderProgramType::GraphicsCompute) + { + SLANG_RETURN_ON_FAIL(writeBindingOutput(gOptions.outputPath)); + } + else + { + SlangResult res = writeScreen(gOptions.outputPath); + if (SLANG_FAILED(res)) + { + fprintf(stderr, "ERROR: failed to write screen capture to file\n"); + return res; + } + } + // We are done + window->postQuit(); + return SLANG_OK; + } + + m_renderer->presentFrame(); + return SLANG_OK; +} + } // namespace renderer_test SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSession* session, int argcIn, const char*const* argvIn) @@ -449,8 +357,6 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe // Declare window pointer before renderer, such that window is released after renderer RefPtr<renderer_test::Window> window; - // Renderer is constructed (later) using the window - Slang::RefPtr<Renderer> renderer; ShaderCompilerUtil::Input input; @@ -465,7 +371,6 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe switch (gOptions.rendererType) { case RendererType::DirectX11: - renderer = createD3D11Renderer(); input.target = SLANG_DXBC; input.profile = "sm_5_0"; nativeLanguage = SLANG_SOURCE_LANGUAGE_HLSL; @@ -474,7 +379,6 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe break; case RendererType::DirectX12: - renderer = createD3D12Renderer(); input.target = SLANG_DXBC; input.profile = "sm_5_0"; nativeLanguage = SLANG_SOURCE_LANGUAGE_HLSL; @@ -489,7 +393,6 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe break; case RendererType::OpenGl: - renderer = createGLRenderer(); input.target = SLANG_GLSL; input.profile = "glsl_430"; nativeLanguage = SLANG_SOURCE_LANGUAGE_GLSL; @@ -497,7 +400,6 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe break; case RendererType::Vulkan: - renderer = createVKRenderer(); input.target = SLANG_SPIRV; input.profile = "glsl_430"; nativeLanguage = SLANG_SOURCE_LANGUAGE_GLSL; @@ -540,18 +442,59 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe rendererName << "'" << gOptions.adapter << "'"; } - - if (renderer) + // If it's CPU testing we don't need a window or a renderer + if (gOptions.rendererType == RendererType::CPU) { + if (gOptions.onlyStartup) + { + // Need generic C/C++ + if (SLANG_FAILED(spSessionCheckPassThroughSupport(session, SLANG_PASS_THROUGH_GENERIC_C_CPP))) + { + return SLANG_FAIL; + } + // Should work ... + return SLANG_OK; + } + + ShaderCompilerUtil::OutputAndLayout compilationAndLayout; + SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, gOptions.sourcePath, gOptions.shaderType, input, compilationAndLayout)); + + CPUComputeUtil::Context context; + SLANG_RETURN_ON_FAIL(CPUComputeUtil::calcBindings(compilationAndLayout, context)); + SLANG_RETURN_ON_FAIL(CPUComputeUtil::execute(compilationAndLayout, context)); + + // Dump everything out that was written + return CPUComputeUtil::writeBindings(compilationAndLayout.layout, context.buffers, gOptions.outputPath); + } + + // Renderer is constructed (later) using the window + Slang::RefPtr<Renderer> renderer; + + { + RendererUtil::CreateFunc createFunc = RendererUtil::getCreateFunc(gOptions.rendererType); + if (createFunc) + { + renderer = createFunc(); + } + + if (!renderer) + { + if (!gOptions.onlyStartup) + { + fprintf(stderr, "Unable to create renderer %s\n", rendererName.getBuffer()); + } + return SLANG_FAIL; + } + Renderer::Desc desc; desc.width = gWindowWidth; desc.height = gWindowHeight; desc.adapter = gOptions.adapter; - window = new renderer_test::Window; + window = renderer_test::Window::create(); SLANG_RETURN_ON_FAIL(window->initialize(gWindowWidth, gWindowHeight)); - SlangResult res = renderer->initialize(desc, (HWND)window->getHandle()); + SlangResult res = renderer->initialize(desc, window->getHandle()); if (SLANG_FAILED(res)) { if (!gOptions.onlyStartup) @@ -570,105 +513,19 @@ SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSe } } } - else - { - if (gOptions.rendererType != RendererType::CPU) - { - if (!gOptions.onlyStartup) - { - fprintf(stderr, "Unable to create renderer %s\n", rendererName.getBuffer()); - } - return SLANG_FAIL; - } - } - + // If the only test is we can startup, then we are done if (gOptions.onlyStartup) { return SLANG_OK; } - if (!renderer) - { - ShaderCompilerUtil::OutputAndLayout compilationAndLayout; - SLANG_RETURN_ON_FAIL(ShaderCompilerUtil::compileWithLayout(session, gOptions.sourcePath, gOptions.shaderType, input, compilationAndLayout)); - - CPUComputeUtil::Context context; - SLANG_RETURN_ON_FAIL(CPUComputeUtil::calcBindings(compilationAndLayout, context)); - SLANG_RETURN_ON_FAIL(CPUComputeUtil::execute(compilationAndLayout, context)); - - // Dump everything out that was written - return CPUComputeUtil::writeBindings(compilationAndLayout.layout, context.buffers, gOptions.outputPath); - } - { - RenderTestApp app; - SLANG_RETURN_ON_FAIL(app.initialize(session, renderer, gOptions.shaderType, input)); - + RefPtr<RenderTestApp> app(new RenderTestApp); + SLANG_RETURN_ON_FAIL(app->initialize(session, renderer, gOptions, input)); window->show(); - - // ... and enter the event loop: - for (;;) - { - MSG message; - - int result = PeekMessageW(&message, NULL, 0, 0, PM_REMOVE); - if (result != 0) - { - if (message.message == WM_QUIT) - { - return (int)message.wParam; - } - - TranslateMessage(&message); - DispatchMessageW(&message); - } - else - { - // Whenever we don't have Windows events to process, we render a frame. - if (gOptions.shaderType == Options::ShaderProgramType::Compute) - { - app.runCompute(); - } - else - { - static const float kClearColor[] = { 0.25, 0.25, 0.25, 1.0 }; - renderer->setClearColor(kClearColor); - renderer->clearFrame(); - - app.renderFrame(); - } - // If we are in a mode where output is requested, we need to snapshot the back buffer here - if (gOptions.outputPath) - { - // Submit the work - renderer->submitGpuWork(); - // Wait until everything is complete - renderer->waitForGpu(); - - if (gOptions.shaderType == Options::ShaderProgramType::Compute || gOptions.shaderType == Options::ShaderProgramType::GraphicsCompute) - { - SLANG_RETURN_ON_FAIL(app.writeBindingOutput(gOptions.outputPath)); - } - else - { - SlangResult res = app.writeScreen(gOptions.outputPath); - - if (SLANG_FAILED(res)) - { - fprintf(stderr, "ERROR: failed to write screen capture to file\n"); - return res; - } - } - return SLANG_OK; - } - - renderer->presentFrame(); - } - } + return window->runLoop(app); } - - return SLANG_OK; } int main(int argc, char** argv) diff --git a/tools/render-test/render-test-tool.vcxproj b/tools/render-test/render-test-tool.vcxproj index 3e0c0ae56..3cc813300 100644 --- a/tools/render-test/render-test-tool.vcxproj +++ b/tools/render-test/render-test-tool.vcxproj @@ -186,6 +186,7 @@ <ClInclude Include="shader-input-layout.h" /> <ClInclude Include="shader-renderer-util.h" /> <ClInclude Include="slang-support.h" /> + <ClInclude Include="window.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="cpu-compute-util.cpp" /> @@ -196,6 +197,8 @@ <ClCompile Include="shader-input-layout.cpp" /> <ClCompile Include="shader-renderer-util.cpp" /> <ClCompile Include="slang-support.cpp" /> + <ClCompile Include="window.cpp" /> + <ClCompile Include="windows\win-window.cpp" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\source\core\core.vcxproj"> diff --git a/tools/render-test/render-test-tool.vcxproj.filters b/tools/render-test/render-test-tool.vcxproj.filters index 769d53aed..7091fce6b 100644 --- a/tools/render-test/render-test-tool.vcxproj.filters +++ b/tools/render-test/render-test-tool.vcxproj.filters @@ -30,6 +30,9 @@ <ClInclude Include="slang-support.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="window.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="cpu-compute-util.cpp"> @@ -56,5 +59,11 @@ <ClCompile Include="slang-support.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="window.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="windows\win-window.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> </Project>
\ No newline at end of file diff --git a/tools/render-test/window.cpp b/tools/render-test/window.cpp new file mode 100644 index 000000000..0ab4ff412 --- /dev/null +++ b/tools/render-test/window.cpp @@ -0,0 +1,21 @@ +// window.cpp + +#include "window.h" + +namespace renderer_test { +using namespace Slang; + +#if SLANG_WINDOWS_FAMILY +extern Window* createWinWindow(); +#endif + +/* static */Window* Window::create() +{ +#if SLANG_WINDOWS_FAMILY + return createWinWindow(); +#else + return nullptr; +#endif +} + +} // renderer_test diff --git a/tools/render-test/window.h b/tools/render-test/window.h new file mode 100644 index 000000000..e647a602c --- /dev/null +++ b/tools/render-test/window.h @@ -0,0 +1,45 @@ +// window.h +#pragma once + +#include <slang.h> +#include "../../source/core/slang-smart-pointer.h" + +namespace renderer_test { + +class Window; + +class WindowListener : public Slang::RefObject +{ +public: + virtual SlangResult update(Window* window) = 0; +}; + +class Window : public Slang::RefObject +{ +public: + virtual SlangResult initialize(int width, int height) = 0; + + virtual void show() = 0; + virtual void* getHandle() const = 0; + virtual void postQuit() { m_isQuitting = true; } + + /// Run the event loop. Events will be sent to the WindowListener + virtual SlangResult runLoop(WindowListener* listener) = 0; + + bool isQuitting() const { return m_isQuitting; } + int getQuitValue() const { return m_quitValue; } + + static Window* create(); + + virtual ~Window() {} + +protected: + Window() {} + + bool m_isQuitting = false; + int m_quitValue = 0; +}; + +Window* createWindow(); + +} // renderer_test diff --git a/tools/render-test/windows/win-window.cpp b/tools/render-test/windows/win-window.cpp new file mode 100644 index 000000000..7f45f9789 --- /dev/null +++ b/tools/render-test/windows/win-window.cpp @@ -0,0 +1,185 @@ +// win-window.cpp + +#define _CRT_SECURE_NO_WARNINGS 1 + +#include <slang.h> +#include <slang-com-helper.h> + +#include "../window.h" + +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include <Windows.h> +#undef WIN32_LEAN_AND_MEAN +#undef NOMINMAX + +#ifdef _MSC_VER +#pragma warning(disable: 4996) +#endif + +#include <stdio.h> + +namespace renderer_test { + +class WinWindow : public Window +{ +public: + virtual SlangResult initialize(int width, int height) SLANG_OVERRIDE; + + virtual void show() SLANG_OVERRIDE; + virtual void* getHandle() const SLANG_OVERRIDE { return m_hwnd; } + virtual SlangResult runLoop(WindowListener* listener) SLANG_OVERRIDE; + + virtual ~WinWindow(); + + static LRESULT CALLBACK windowProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam); + +protected: + + HINSTANCE m_hinst = nullptr; + HWND m_hwnd = nullptr; +}; + +// +// We use a bare-minimum window procedure to get things up and running. +// + +/* static */LRESULT CALLBACK WinWindow::windowProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_CLOSE: + PostQuitMessage(0); + return 0; + } + return DefWindowProcW(windowHandle, message, wParam, lParam); +} + +static ATOM _getWindowClassAtom(HINSTANCE hinst) +{ + static ATOM s_windowClassAtom; + + if (s_windowClassAtom) + { + return s_windowClassAtom; + } + WNDCLASSEXW windowClassDesc; + windowClassDesc.cbSize = sizeof(windowClassDesc); + windowClassDesc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + windowClassDesc.lpfnWndProc = &WinWindow::windowProc; + windowClassDesc.cbClsExtra = 0; + windowClassDesc.cbWndExtra = 0; + windowClassDesc.hInstance = hinst; + windowClassDesc.hIcon = 0; + windowClassDesc.hCursor = 0; + windowClassDesc.hbrBackground = 0; + windowClassDesc.lpszMenuName = 0; + windowClassDesc.lpszClassName = L"SlangRenderTest"; + windowClassDesc.hIconSm = 0; + s_windowClassAtom = RegisterClassExW(&windowClassDesc); + + return s_windowClassAtom; +} + +SlangResult WinWindow::initialize(int widthIn, int heightIn) +{ + // Do initial window-creation stuff here, rather than in the renderer-specific files + + m_hinst = GetModuleHandleA(0); + + // First we register a window class. + ATOM windowClassAtom = _getWindowClassAtom(m_hinst); + if (!windowClassAtom) + { + fprintf(stderr, "error: failed to register window class\n"); + return SLANG_FAIL; + } + + // Next, we create a window using that window class. + + // We will create a borderless window since our screen-capture logic in GL + // seems to get thrown off by having to deal with a window frame. + DWORD windowStyle = WS_POPUP; + DWORD windowExtendedStyle = 0; + + RECT windowRect = { 0, 0, widthIn, heightIn }; + AdjustWindowRectEx(&windowRect, windowStyle, /*hasMenu=*/false, windowExtendedStyle); + + { + auto width = windowRect.right - windowRect.left; + auto height = windowRect.bottom - windowRect.top; + + LPWSTR windowName = L"Slang Render Test"; + m_hwnd = CreateWindowExW( + windowExtendedStyle, + (LPWSTR)windowClassAtom, + windowName, + windowStyle, + 0, 0, // x, y + width, height, + NULL, // parent + NULL, // menu + m_hinst, + NULL); + } + if (!m_hwnd) + { + fprintf(stderr, "error: failed to create window\n"); + return SLANG_FAIL; + } + + return SLANG_OK; +} + + +void WinWindow::show() +{ + // Once initialization is all complete, we show the window... + int showCommand = SW_SHOW; + ShowWindow(m_hwnd, showCommand); +} + +SlangResult WinWindow::runLoop(WindowListener* listener) +{ + // ... and enter the event loop: + while (!m_isQuitting) + { + MSG message; + int result = PeekMessageW(&message, NULL, 0, 0, PM_REMOVE); + if (result != 0) + { + if (message.message == WM_QUIT) + { + m_quitValue = (int)message.wParam; + return SLANG_OK; + } + + TranslateMessage(&message); + DispatchMessageW(&message); + } + else + { + if (listener) + { + SLANG_RETURN_ON_FAIL(listener->update(this)); + } + } + } + + return SLANG_OK; +} + +WinWindow::~WinWindow() +{ + if (m_hwnd) + { + DestroyWindow(m_hwnd); + } +} + +Window* createWinWindow() +{ + return new WinWindow; +} + +} // namespace renderer_test diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 42b9e9331..26d611181 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -751,26 +751,11 @@ static SlangResult _extractReflectionTestRequirements(const CommandLine& cmdLine return SLANG_OK; } -static SlangResult _tryUseCPURenderTest(TestContext* context, CommandLine& ioCmdLine) -{ - String exeName = Path::getFileNameWithoutExt(ioCmdLine.m_executable); - - if (exeName == "render-test") - { - bool useCPU = ioCmdLine.findArgIndex(UnownedStringSlice::fromLiteral("-cpu")) >= 0; - if (useCPU) - { - ioCmdLine.setExecutablePath(Path::combine(context->options.binDir, String("cpu-render-test") + ProcessUtil::getExecutableSuffix())); - } - } - return SLANG_OK; -} - static SlangResult _extractTestRequirements(const CommandLine& cmdLine, TestRequirements* ioInfo) { String exeName = Path::getFileNameWithoutExt(cmdLine.m_executable); - if (exeName == "render-test" || exeName == "cpu-render-test") + if (exeName == "render-test") { return _extractRenderTestRequirements(cmdLine, ioInfo); } @@ -830,8 +815,6 @@ static RenderApiFlags _getAvailableRenderApiFlags(TestContext* context) builder << "-" << RenderApiUtil::getApiName(apiType); cmdLine.addArg(builder); - _tryUseCPURenderTest(context, cmdLine); - // Run the render-test tool and see if the device could startup ExecuteResult exeRes; if (SLANG_SUCCEEDED(spawnAndWaitSharedLibrary(context, "device-startup", cmdLine, exeRes)) @@ -2071,8 +2054,6 @@ TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, cons auto actualOutputFile = outputStem + ".actual.txt"; cmdLine.addArg(actualOutputFile); - _tryUseCPURenderTest(context, cmdLine); - if (context->isExecuting()) { // clear the stale actual output file first. This will allow us to detect error if render-test fails and outputs nothing. @@ -2188,8 +2169,6 @@ TestResult doRenderComparisonTestRun(TestContext* context, TestInput& input, cha cmdLine.addArg("-o"); cmdLine.addArg(outputStem + outputKind + ".png"); - _tryUseCPURenderTest(context, cmdLine); - ExecuteResult exeRes; TEST_RETURN_ON_DONE(spawnAndWait(context, outputStem, input.spawnType, cmdLine, exeRes)); |
