diff options
Diffstat (limited to 'tools/render-test')
| -rw-r--r-- | tools/render-test/main.cpp | 235 | ||||
| -rw-r--r-- | tools/render-test/options.cpp | 46 | ||||
| -rw-r--r-- | tools/render-test/options.h | 5 | ||||
| -rw-r--r-- | tools/render-test/render-test-shared-library.vcxproj | 210 | ||||
| -rw-r--r-- | tools/render-test/render-test-shared-library.vcxproj.filters | 48 | ||||
| -rw-r--r-- | tools/render-test/shader-renderer-util.cpp | 2 | ||||
| -rw-r--r-- | tools/render-test/slang-support.cpp | 4 | ||||
| -rw-r--r-- | tools/render-test/slang-support.h | 5 |
8 files changed, 443 insertions, 112 deletions
diff --git a/tools/render-test/main.cpp b/tools/render-test/main.cpp index 93de67907..631085c2b 100644 --- a/tools/render-test/main.cpp +++ b/tools/render-test/main.cpp @@ -17,6 +17,8 @@ #include <stdio.h> #include <stdlib.h> +#include "../../source/core/slang-app-context.h" + #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include <Windows.h> @@ -34,6 +36,141 @@ 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 @@ -355,88 +492,20 @@ Result RenderTestApp::writeScreen(const char* filename) return PngSerializeUtil::write(filename, surface); } -// -// We use a bare-minimum window procedure to get things up and running. -// +} // namespace renderer_test -static LRESULT CALLBACK windowProc( - HWND windowHandle, - UINT message, - WPARAM wParam, - LPARAM lParam) +SLANG_SHARED_LIBRARY_TOOL_API SlangResult innerMain(Slang::AppContext* appContext, SlangSession* session, int argcIn, const char*const* argvIn) { - switch (message) - { - case WM_CLOSE: - PostQuitMessage(0); - return 0; - } + using namespace renderer_test; + using namespace Slang; - return DefWindowProcW(windowHandle, message, wParam, lParam); -} + AppContext::setSingleton(appContext); -SlangResult innerMain(int argc, char** argv) -{ // Parse command-line options - SLANG_RETURN_ON_FAIL(parseOptions(&argc, argv)); - - // Do initial window-creation stuff here, rather than in the renderer-specific files - - HINSTANCE instance = GetModuleHandleA(0); - int showCommand = SW_SHOW; - - // First we register a window class. - - WNDCLASSEXW windowClassDesc; - windowClassDesc.cbSize = sizeof(windowClassDesc); - windowClassDesc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - windowClassDesc.lpfnWndProc = &windowProc; - windowClassDesc.cbClsExtra = 0; - windowClassDesc.cbWndExtra = 0; - windowClassDesc.hInstance = instance; - windowClassDesc.hIcon = 0; - windowClassDesc.hCursor = 0; - windowClassDesc.hbrBackground = 0; - windowClassDesc.lpszMenuName = 0; - windowClassDesc.lpszClassName = L"HelloWorld"; - windowClassDesc.hIconSm = 0; - ATOM windowClassAtom = RegisterClassExW(&windowClassDesc); - if (!windowClassAtom) - { - fprintf(stderr, "error: failed to register window class\n"); - return SLANG_FAIL; - } + SLANG_RETURN_ON_FAIL(parseOptions(argcIn, argvIn, AppContext::getStdError())); - // 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, gWindowWidth, gWindowHeight }; - AdjustWindowRectEx(&windowRect, windowStyle, /*hasMenu=*/false, windowExtendedStyle); - - auto width = windowRect.right - windowRect.left; - auto height = windowRect.bottom - windowRect.top; - - LPWSTR windowName = L"Slang Render Test"; - HWND windowHandle = CreateWindowExW( - windowExtendedStyle, - (LPWSTR)windowClassAtom, - windowName, - windowStyle, - 0, 0, // x, y - width, height, - NULL, // parent - NULL, // menu - instance, - NULL); - if (!windowHandle) - { - fprintf(stderr, "error: failed to create window\n"); - return SLANG_FAIL; - } + RefPtr<renderer_test::Window> window(new renderer_test::Window); + SLANG_RETURN_ON_FAIL(window->initialize(gWindowWidth, gWindowHeight)); Slang::RefPtr<Renderer> renderer; @@ -500,7 +569,7 @@ SlangResult innerMain(int argc, char** argv) desc.height = gWindowHeight; { - Result res = renderer->initialize(desc, windowHandle); + SlangResult res = renderer->initialize(desc, (HWND)window->getHandle()); if (SLANG_FAILED(res)) { fprintf(stderr, "Unable to initialize renderer\n"); @@ -512,6 +581,8 @@ SlangResult innerMain(int argc, char** argv) shaderCompiler.renderer = renderer; shaderCompiler.target = slangTarget; shaderCompiler.profile = profileName; + shaderCompiler.slangSession = session; + switch (gOptions.inputLanguageID) { case Options::InputLanguageID::Slang: @@ -533,8 +604,7 @@ SlangResult innerMain(int argc, char** argv) SLANG_RETURN_ON_FAIL(app.initialize(renderer, &shaderCompiler)); - // Once initialization is all complete, we show the window... - ShowWindow(windowHandle, showCommand); + window->show(); // ... and enter the event loop: for (;;) @@ -581,7 +651,7 @@ SlangResult innerMain(int argc, char** argv) } else { - Result res = app.writeScreen(gOptions.outputPath); + SlangResult res = app.writeScreen(gOptions.outputPath); if (SLANG_FAILED(res)) { @@ -600,11 +670,12 @@ SlangResult innerMain(int argc, char** argv) return SLANG_OK; } -} // namespace renderer_test int main(int argc, char** argv) { - SlangResult res = renderer_test::innerMain(argc, argv); + SlangSession* session = spCreateSession(nullptr); + SlangResult res = innerMain(Slang::AppContext::initDefault(), session, argc, argv); + spDestroySession(session); return SLANG_FAILED(res) ? 1 : 0; } diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp index d99ba355e..bd5640020 100644 --- a/tools/render-test/options.cpp +++ b/tools/render-test/options.cpp @@ -6,8 +6,12 @@ #include <stdlib.h> #include <string.h> +#include "../../source/core/slang-writer.h" + namespace renderer_test { +static const Options gDefaultOptions; + Options gOptions; // Only set it, if the @@ -16,17 +20,20 @@ void setDefaultRendererType(RendererType type) gOptions.rendererType = (gOptions.rendererType == RendererType::Unknown) ? type : gOptions.rendererType; } -SlangResult parseOptions(int* argc, char** argv) +SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper stdError) { + // Reset the options + gOptions = gDefaultOptions; + + List<const char*> positionalArgs; + typedef Options::ShaderProgramType ShaderProgramType; typedef Options::InputLanguageID InputLanguageID; + //int argCount = argc; - int argCount = *argc; char const* const* argCursor = argv; - char const* const* argEnd = argCursor + argCount; - - char const** writeCursor = (char const**) argv; + char const* const* argEnd = argCursor + argc; // first argument is the application name if( argCursor != argEnd ) @@ -40,7 +47,7 @@ SlangResult parseOptions(int* argc, char** argv) char const* arg = *argCursor++; if( arg[0] != '-' ) { - *writeCursor++ = arg; + positionalArgs.Add(arg); continue; } @@ -48,8 +55,7 @@ SlangResult parseOptions(int* argc, char** argv) { while(argCursor != argEnd) { - char const* arg = *argCursor++; - *writeCursor++ = arg; + positionalArgs.Add(*argCursor++); } break; } @@ -57,7 +63,7 @@ SlangResult parseOptions(int* argc, char** argv) { if( argCursor == argEnd ) { - fprintf(stderr, "expected argument for '%s' option\n", arg); + stdError.print("expected argument for '%s' option\n", arg); return SLANG_FAIL; } gOptions.outputPath = *argCursor++; @@ -98,12 +104,12 @@ SlangResult parseOptions(int* argc, char** argv) if( argCursor == argEnd ) { - fprintf(stderr, "expected argument for '%s' option\n", arg); + stdError.print("expected argument for '%s' option\n", arg); return SLANG_FAIL; } if( gOptions.slangArgCount == Options::kMaxSlangArgs ) { - fprintf(stderr, "maximum number of '%s' options exceeded (%d)\n", arg, Options::kMaxSlangArgs); + stdError.print("maximum number of '%s' options exceeded (%d)\n", arg, Options::kMaxSlangArgs); return SLANG_FAIL; } gOptions.slangArgs[gOptions.slangArgCount++] = *argCursor++; @@ -145,30 +151,26 @@ SlangResult parseOptions(int* argc, char** argv) } else { - fprintf(stderr, "unknown option '%s'\n", arg); + stdError.print("unknown option '%s'\n", arg); return SLANG_FAIL; } } - // any arguments left over were positional arguments - argCount = (int)(writeCursor - (const char**)argv); - argCursor = argv; - argEnd = argCursor + argCount; - + // first positional argument is source shader path - if( argCursor != argEnd ) + if(positionalArgs.Count()) { - gOptions.sourcePath = *argCursor++; + gOptions.sourcePath = positionalArgs[0]; + positionalArgs.RemoveAt(0); } // any remaining arguments represent an error - if(argCursor != argEnd) + if(positionalArgs.Count() != 0) { - fprintf(stderr, "unexpected arguments\n"); + stdError.print("unexpected arguments\n"); return SLANG_FAIL; } - *argc = 0; return SLANG_OK; } diff --git a/tools/render-test/options.h b/tools/render-test/options.h index 76fdf95af..09721def3 100644 --- a/tools/render-test/options.h +++ b/tools/render-test/options.h @@ -1,9 +1,10 @@ -// options.h +// options.h #pragma once #include <stdint.h> #include "../../slang-com-helper.h" +#include "../../source/core/slang-writer.h" #include "render.h" @@ -52,6 +53,6 @@ struct Options extern Options gOptions; -SlangResult parseOptions(int* argc, char** argv); +SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper stdError); } // renderer_test diff --git a/tools/render-test/render-test-shared-library.vcxproj b/tools/render-test/render-test-shared-library.vcxproj new file mode 100644 index 000000000..359a35b80 --- /dev/null +++ b/tools/render-test/render-test-shared-library.vcxproj @@ -0,0 +1,210 @@ +<?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>{61F7EB00-7281-4BF3-9470-7C2EA92620C3}</ProjectGuid> + <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> + <Keyword>Win32Proj</Keyword> + <RootNamespace>render-test-shared-library</RootNamespace> + <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion> + </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\render-test-shared-library\</IntDir> + <TargetName>render-test-shared-library</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\render-test-shared-library\</IntDir> + <TargetName>render-test-shared-library</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\render-test-shared-library\</IntDir> + <TargetName>render-test-shared-library</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\render-test-shared-library\</IntDir> + <TargetName>render-test-shared-library</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\render-test-shared-library.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\render-test-shared-library.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\render-test-shared-library.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\render-test-shared-library.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="options.h" /> + <ClInclude Include="png-serialize-util.h" /> + <ClInclude Include="shader-input-layout.h" /> + <ClInclude Include="shader-renderer-util.h" /> + <ClInclude Include="slang-support.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="main.cpp" /> + <ClCompile Include="options.cpp" /> + <ClCompile Include="png-serialize-util.cpp" /> + <ClCompile Include="shader-input-layout.cpp" /> + <ClCompile Include="shader-renderer-util.cpp" /> + <ClCompile Include="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/render-test/render-test-shared-library.vcxproj.filters b/tools/render-test/render-test-shared-library.vcxproj.filters new file mode 100644 index 000000000..ff3d52a7e --- /dev/null +++ b/tools/render-test/render-test-shared-library.vcxproj.filters @@ -0,0 +1,48 @@ +<?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="options.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="png-serialize-util.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="shader-input-layout.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="shader-renderer-util.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="slang-support.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="main.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="options.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="png-serialize-util.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="shader-input-layout.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="shader-renderer-util.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="slang-support.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp index f6c0366bb..0d0f8a3a5 100644 --- a/tools/render-test/shader-renderer-util.cpp +++ b/tools/render-test/shader-renderer-util.cpp @@ -185,7 +185,7 @@ static RefPtr<SamplerState> _createSamplerState( { if (baseIndex + i != entry.glslBinding[i]) { - assert("Bindings must be contiguous"); + assert(!"Bindings must be contiguous"); break; } } diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index 26e856295..1dc7323a5 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -14,7 +14,6 @@ namespace renderer_test { RefPtr<ShaderProgram> ShaderCompiler::compileProgram( ShaderCompileRequest const& request) { - SlangSession* slangSession = spCreateSession(NULL); SlangCompileRequest* slangRequest = spCreateCompileRequest(slangSession); spSetCodeGenTarget(slangRequest, target); @@ -173,8 +172,7 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram( // owns the memory allocation for the generated text, and will // free it when we destroy the compilation result. spDestroyCompileRequest(slangRequest); - spDestroySession(slangSession); - + return shaderProgram; } diff --git a/tools/render-test/slang-support.h b/tools/render-test/slang-support.h index 03de062d1..a9b8c8871 100644 --- a/tools/render-test/slang-support.h +++ b/tools/render-test/slang-support.h @@ -16,8 +16,9 @@ struct ShaderCompiler SlangSourceLanguage sourceLanguage; SlangPassThrough passThrough; char const* profile; - - RefPtr<ShaderProgram> compileProgram( + SlangSession* slangSession; + + RefPtr<ShaderProgram> compileProgram( ShaderCompileRequest const& request); }; |
