diff options
| -rw-r--r-- | build/visual-studio/gfx/gfx.vcxproj | 2 | ||||
| -rw-r--r-- | build/visual-studio/gfx/gfx.vcxproj.filters | 6 | ||||
| -rw-r--r-- | build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj | 306 | ||||
| -rw-r--r-- | build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters | 24 | ||||
| -rw-r--r-- | premake5.lua | 9 | ||||
| -rw-r--r-- | slang.sln | 15 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-device.cpp | 19 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-pipeline-dump-layer.cpp | 152 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-pipeline-dump-layer.h | 11 | ||||
| -rw-r--r-- | tools/vk-pipeline-create/main.cpp | 287 |
10 files changed, 830 insertions, 1 deletions
diff --git a/build/visual-studio/gfx/gfx.vcxproj b/build/visual-studio/gfx/gfx.vcxproj index ac51b4fb2..f761631f0 100644 --- a/build/visual-studio/gfx/gfx.vcxproj +++ b/build/visual-studio/gfx/gfx.vcxproj @@ -435,6 +435,7 @@ IF EXIST "$(SolutionDir)tools\gfx\slang.slang"\ (xcopy /Q /E /Y /I "$(SolutionDi <ClInclude Include="..\..\..\tools\gfx\vulkan\vk-framebuffer.h" />
<ClInclude Include="..\..\..\tools\gfx\vulkan\vk-helper-functions.h" />
<ClInclude Include="..\..\..\tools\gfx\vulkan\vk-module.h" />
+ <ClInclude Include="..\..\..\tools\gfx\vulkan\vk-pipeline-dump-layer.h" />
<ClInclude Include="..\..\..\tools\gfx\vulkan\vk-pipeline-state.h" />
<ClInclude Include="..\..\..\tools\gfx\vulkan\vk-query.h" />
<ClInclude Include="..\..\..\tools\gfx\vulkan\vk-render-pass.h" />
@@ -543,6 +544,7 @@ IF EXIST "$(SolutionDir)tools\gfx\slang.slang"\ (xcopy /Q /E /Y /I "$(SolutionDi <ClCompile Include="..\..\..\tools\gfx\vulkan\vk-framebuffer.cpp" />
<ClCompile Include="..\..\..\tools\gfx\vulkan\vk-helper-functions.cpp" />
<ClCompile Include="..\..\..\tools\gfx\vulkan\vk-module.cpp" />
+ <ClCompile Include="..\..\..\tools\gfx\vulkan\vk-pipeline-dump-layer.cpp" />
<ClCompile Include="..\..\..\tools\gfx\vulkan\vk-pipeline-state.cpp" />
<ClCompile Include="..\..\..\tools\gfx\vulkan\vk-query.cpp" />
<ClCompile Include="..\..\..\tools\gfx\vulkan\vk-render-pass.cpp" />
diff --git a/build/visual-studio/gfx/gfx.vcxproj.filters b/build/visual-studio/gfx/gfx.vcxproj.filters index 97b3f6f19..ad0ef3c35 100644 --- a/build/visual-studio/gfx/gfx.vcxproj.filters +++ b/build/visual-studio/gfx/gfx.vcxproj.filters @@ -372,6 +372,9 @@ <ClInclude Include="..\..\..\tools\gfx\vulkan\vk-module.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\tools\gfx\vulkan\vk-pipeline-dump-layer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\..\..\tools\gfx\vulkan\vk-pipeline-state.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -692,6 +695,9 @@ <ClCompile Include="..\..\..\tools\gfx\vulkan\vk-module.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\tools\gfx\vulkan\vk-pipeline-dump-layer.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="..\..\..\tools\gfx\vulkan\vk-pipeline-state.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj new file mode 100644 index 000000000..e3634d91e --- /dev/null +++ b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj @@ -0,0 +1,306 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" 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="Debug|ARM64"> + <Configuration>Debug</Configuration> + <Platform>ARM64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug aarch64|Win32"> + <Configuration>Debug aarch64</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug aarch64|x64"> + <Configuration>Debug aarch64</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug aarch64|ARM64"> + <Configuration>Debug aarch64</Configuration> + <Platform>ARM64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|ARM64"> + <Configuration>Release</Configuration> + <Platform>ARM64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release aarch64|Win32"> + <Configuration>Release aarch64</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release aarch64|x64"> + <Configuration>Release aarch64</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release aarch64|ARM64"> + <Configuration>Release aarch64</Configuration> + <Platform>ARM64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{9ED23316-AE8B-4018-9407-271F4DDB8CBA}</ProjectGuid> + <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> + <Keyword>Win32Proj</Keyword> + <RootNamespace>vk-pipeline-create</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support> + </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)'=='Debug aarch64|ARM64'"> + <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> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'"> + <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\vk-pipeline-create\</IntDir> + <TargetName>vk-pipeline-create</TargetName> + <TargetExt>.exe</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>..\..\..\bin\windows-x64\debug\</OutDir> + <IntDir>..\..\..\intermediate\windows-x64\debug\vk-pipeline-create\</IntDir> + <TargetName>vk-pipeline-create</TargetName> + <TargetExt>.exe</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>..\..\..\bin\windows-aarch64\debug\</OutDir> + <IntDir>..\..\..\intermediate\windows-aarch64\debug\vk-pipeline-create\</IntDir> + <TargetName>vk-pipeline-create</TargetName> + <TargetExt>.exe</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\bin\windows-x86\release\</OutDir> + <IntDir>..\..\..\intermediate\windows-x86\release\vk-pipeline-create\</IntDir> + <TargetName>vk-pipeline-create</TargetName> + <TargetExt>.exe</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\bin\windows-x64\release\</OutDir> + <IntDir>..\..\..\intermediate\windows-x64\release\vk-pipeline-create\</IntDir> + <TargetName>vk-pipeline-create</TargetName> + <TargetExt>.exe</TargetExt> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\bin\windows-aarch64\release\</OutDir> + <IntDir>..\..\..\intermediate\windows-aarch64\release\vk-pipeline-create\</IntDir> + <TargetName>vk-pipeline-create</TargetName> + <TargetExt>.exe</TargetExt> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <MinimalRebuild>false</MinimalRebuild> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <LanguageStandard>stdcpp17</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <MinimalRebuild>false</MinimalRebuild> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <LanguageStandard>stdcpp17</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>_DEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <Optimization>Disabled</Optimization> + <MinimalRebuild>false</MinimalRebuild> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <LanguageStandard>stdcpp17</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <LanguageStandard>stdcpp17</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <LanguageStandard>stdcpp17</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM64'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>NDEBUG;WIN32_LEAN_AND_MEAN;VC_EXTRALEAN;NOMINMAX;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\..\..\external\vulkan\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <Optimization>Full</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <LanguageStandard>stdcpp17</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClInclude Include="..\..\..\examples\hello-world\vulkan-api.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\..\examples\hello-world\vulkan-api.cpp" /> + <ClCompile Include="..\..\..\tools\vk-pipeline-create\main.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\slang\slang.vcxproj"> + <Project>{DB00DA62-0533-4AFD-B59F-A67D5B3A0808}</Project> + </ProjectReference> + <ProjectReference Include="..\gfx\gfx.vcxproj"> + <Project>{222F7498-B40C-4F3F-A704-DDEB91A4484A}</Project> + </ProjectReference> + <ProjectReference Include="..\gfx-util\gfx-util.vcxproj"> + <Project>{F5ADB74E-02A7-44FB-AA3B-FC02F8AC7A4B}</Project> + </ProjectReference> + <ProjectReference Include="..\platform\platform.vcxproj"> + <Project>{3565FE5E-4FA3-11EB-AE93-0242AC130002}</Project> + </ProjectReference> + <ProjectReference Include="..\core\core.vcxproj"> + <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters new file mode 100644 index 000000000..1068a0300 --- /dev/null +++ b/build/visual-studio/vk-pipeline-create/vk-pipeline-create.vcxproj.filters @@ -0,0 +1,24 @@ +<?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="..\..\..\examples\hello-world\vulkan-api.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\..\examples\hello-world\vulkan-api.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\..\tools\vk-pipeline-create\main.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/premake5.lua b/premake5.lua index 98bb2b6a0..1af31bb4b 100644 --- a/premake5.lua +++ b/premake5.lua @@ -838,7 +838,7 @@ end example "hello-world" kind "ConsoleApp" includedirs {"external/vulkan/include"} --- + -- Note how we are calling our custom `example()` subroutine with -- the same syntax sugar that Premake usually advocates for their -- `project()` function. This allows us to treat `example` as @@ -1006,8 +1006,15 @@ tool "slangd" uuid "B2D63B45-92B0-40F7-B242-CCA4DFD64341" includedirs { "." } links { "compiler-core", "core", "slang" } + +tool "vk-pipeline-create" + uuid "9ED23316-AE8B-4018-9407-271F4DDB8CBA" + includedirs { ".", "external/vulkan/include"} + files { "examples/hello-world/vulkan-api.cpp", "examples/hello-world/vulkan-api.h" } + links { "slang", "gfx", "gfx-util", "platform", "core" } -- +-- -- `slang-generate` is a tool we use for source code generation on -- the compiler. It depends on the `core` library, so we need to -- declare that: @@ -33,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-process", "build\visua EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-server", "build\visual-studio\test-server\test-server.vcxproj", "{23149706-C12F-4329-B6AA-8266407C32D3}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vk-pipeline-create", "build\visual-studio\vk-pipeline-create\vk-pipeline-create.vcxproj", "{9ED23316-AE8B-4018-9407-271F4DDB8CBA}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compiler-core", "build\visual-studio\compiler-core\compiler-core.vcxproj", "{12C1E89D-F5D0-41D3-8E8D-FB3F358F8126}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "build\visual-studio\core\core.vcxproj", "{F9BE7957-8399-899E-0C49-E714FDDD4B65}"
@@ -261,6 +263,18 @@ Global {23149706-C12F-4329-B6AA-8266407C32D3}.Release|Win32.Build.0 = Release|Win32
{23149706-C12F-4329-B6AA-8266407C32D3}.Release|x64.ActiveCfg = Release|x64
{23149706-C12F-4329-B6AA-8266407C32D3}.Release|x64.Build.0 = Release|x64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Debug|aarch64.ActiveCfg = Debug aarch64|ARM64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Debug|aarch64.Build.0 = Debug aarch64|ARM64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Debug|Win32.Build.0 = Debug|Win32
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Debug|x64.ActiveCfg = Debug|x64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Debug|x64.Build.0 = Debug|x64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Release|aarch64.ActiveCfg = Release aarch64|ARM64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Release|aarch64.Build.0 = Release aarch64|ARM64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Release|Win32.ActiveCfg = Release|Win32
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Release|Win32.Build.0 = Release|Win32
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Release|x64.ActiveCfg = Release|x64
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA}.Release|x64.Build.0 = Release|x64
{12C1E89D-F5D0-41D3-8E8D-FB3F358F8126}.Debug|aarch64.ActiveCfg = Debug aarch64|ARM64
{12C1E89D-F5D0-41D3-8E8D-FB3F358F8126}.Debug|aarch64.Build.0 = Debug aarch64|ARM64
{12C1E89D-F5D0-41D3-8E8D-FB3F358F8126}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -590,6 +604,7 @@ Global {B2D63B45-92B0-40F7-B242-CCA4DFD64341} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13}
{BE412850-4BB9-429A-877C-BFBC4B34186C} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13}
{23149706-C12F-4329-B6AA-8266407C32D3} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13}
+ {9ED23316-AE8B-4018-9407-271F4DDB8CBA} = {FD47AE19-69FD-260F-F2F1-20E65EA61D13}
{2F0A3884-1B72-FE51-84DD-12687064153E} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231}
{0996B38F-F512-A7D2-1E90-A7E60A6C4366} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231}
{4B47A364-37C4-96A7-6041-97BB4C1D333B} = {EB5FC2C6-D72D-B6CC-C0C1-26F3AC2E9231}
diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp index f8bc9c3aa..fe3680eda 100644 --- a/tools/gfx/vulkan/vk-device.cpp +++ b/tools/gfx/vulkan/vk-device.cpp @@ -15,9 +15,12 @@ #include "vk-swap-chain.h" #include "vk-transient-heap.h" #include "vk-vertex-layout.h" +#include "vk-pipeline-dump-layer.h" #include "vk-helper-functions.h" +#include "source/core/slang-platform.h" + #ifdef GFX_NV_AFTERMATH # include "GFSDK_Aftermath.h" # include "GFSDK_Aftermath_Defines.h" @@ -32,8 +35,20 @@ using namespace Slang; namespace vk { +static bool shouldDumpPipeline() +{ + StringBuilder dumpPipelineSettings; + PlatformUtil::getEnvironmentVariable(toSlice("SLANG_GFX_DUMP_PIPELINE"), dumpPipelineSettings); + return dumpPipelineSettings.produceString() == "1"; +} + DeviceImpl::~DeviceImpl() { + if (shouldDumpPipeline()) + { + writePipelineDump(toSlice("gfx-vk-pipeline-dump.bin")); + } + // Check the device queue is valid else, we can't wait on it.. if (m_deviceQueue.isValid()) { @@ -782,6 +797,10 @@ Result DeviceImpl::initVulkanInstanceAndDevice( SLANG_RETURN_ON_FAIL(m_api.initDeviceProcs(m_device)); + if (shouldDumpPipeline()) + { + installPipelineDumpLayer(m_api); + } return SLANG_OK; } diff --git a/tools/gfx/vulkan/vk-pipeline-dump-layer.cpp b/tools/gfx/vulkan/vk-pipeline-dump-layer.cpp new file mode 100644 index 000000000..959eee15d --- /dev/null +++ b/tools/gfx/vulkan/vk-pipeline-dump-layer.cpp @@ -0,0 +1,152 @@ +#include "vk-pipeline-dump-layer.h" +#include "core/slang-basic.h" +#include "core/slang-stream.h" +namespace gfx { + using namespace Slang; + + struct PipelineDumpContext + { + Dictionary<VkPipelineLayout, Index> pipelineLayouts; + Dictionary<VkShaderModule, Index> shaderModules; + Dictionary<VkDescriptorSetLayout, Index> descriptorSets; + Dictionary<VkPipeline, Index> computePipelines; + + List<uint8_t> serializedBytes; + + VulkanApi api; + + template<typename T> + void writeRaw(T v) + { + auto startIndex = serializedBytes.getCount(); + serializedBytes.growToCount(startIndex + sizeof(T)); + memcpy(serializedBytes.getBuffer() + startIndex, &v, sizeof(T)); + } + + template<typename T> + void writeArray(uint32_t elementCount, const T* data) + { + writeRaw(elementCount); + + auto startIndex = serializedBytes.getCount(); + serializedBytes.growToCount(startIndex + sizeof(T) * elementCount); + memcpy(serializedBytes.getBuffer() + startIndex, data, sizeof(T) * elementCount); + } + + void writeStr(const char* str) + { + auto len = (uint32_t)strlen(str) + 1; + writeRaw(len); + + auto startIndex = serializedBytes.getCount(); + serializedBytes.growToCount(startIndex + len); + memcpy(serializedBytes.getBuffer() + startIndex, str, len - 1); + serializedBytes[startIndex + len - 1] = 0; + } + + void writePipelineLayout(VkPipelineLayout layout, const VkPipelineLayoutCreateInfo* createInfo) + { + auto startIndex = serializedBytes.getCount(); + writeRaw(createInfo->sType); + writeRaw(createInfo->flags); + writeRaw(createInfo->setLayoutCount); + for (uint32_t i = 0; i < createInfo->setLayoutCount; i++) + writeRaw(descriptorSets.getValue(createInfo->pSetLayouts[i])); + writeArray(createInfo->pushConstantRangeCount, createInfo->pPushConstantRanges); + pipelineLayouts[layout] = startIndex; + } + + void writeShaderModule(VkShaderModule module, const VkShaderModuleCreateInfo* createInfo) + { + auto startIndex = serializedBytes.getCount(); + writeRaw(createInfo->sType); + writeRaw(createInfo->flags); + writeArray((uint32_t)(createInfo->codeSize/sizeof(uint32_t)), createInfo->pCode); + shaderModules[module] = startIndex; + } + + void writeDescriptorSetLayout(VkDescriptorSetLayout layout, const VkDescriptorSetLayoutCreateInfo* createInfo) + { + auto startIndex = serializedBytes.getCount(); + writeRaw(createInfo->sType); + writeRaw(createInfo->flags); + writeArray(createInfo->bindingCount, createInfo->pBindings); + descriptorSets[layout] = startIndex; + } + + void writePipeline(VkPipeline pipeline, const VkComputePipelineCreateInfo* createInfo) + { + auto startIndex = serializedBytes.getCount(); + writeRaw(createInfo->sType); + writeRaw(createInfo->flags); + writeRaw(createInfo->stage.sType); + writeRaw(createInfo->stage.flags); + writeRaw(createInfo->stage.stage); + writeRaw(shaderModules.getValue(createInfo->stage.module)); + writeStr(createInfo->stage.pName); + writeRaw(pipelineLayouts.getValue(createInfo->layout)); + computePipelines[pipeline] = startIndex; + } + + void writeToFile(UnownedStringSlice path) + { + RefPtr<FileStream> fs = new FileStream(); + fs->init(path, FileMode::Create); + uint32_t pipelineCount = (uint32_t)computePipelines.getCount(); + fs->write(&pipelineCount, sizeof(uint32_t)); + for (auto& pair : computePipelines) + { + fs->write(KeyValueDetail::getValue(&pair), sizeof(Index)); + } + Index blobSize = serializedBytes.getCount(); + fs->write(&blobSize, sizeof(blobSize)); + fs->write(serializedBytes.getBuffer(), serializedBytes.getCount()); + fs->close(); + } + }; + + PipelineDumpContext dumpContext; + + VkResult SLANG_MCALL createPipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* callbacks, VkPipelineLayout* outLayout) + { + auto result = dumpContext.api.vkCreatePipelineLayout(device, createInfo, callbacks, outLayout); + dumpContext.writePipelineLayout(*outLayout, createInfo); + return result; + } + + VkResult SLANG_MCALL createComputePipelines(VkDevice device, VkPipelineCache cache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* createInfos, const VkAllocationCallbacks* callbacks, VkPipeline* outPipelines) + { + auto result = dumpContext.api.vkCreateComputePipelines(device, cache, createInfoCount, createInfos, callbacks, outPipelines); + for (uint32_t i = 0; i < createInfoCount; i++) + dumpContext.writePipeline(outPipelines[i], createInfos + i); + return result; + } + + VkResult SLANG_MCALL createShaderModule(VkDevice device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* callbacks, VkShaderModule* outShaderModule) + { + auto result = dumpContext.api.vkCreateShaderModule(device, createInfo, callbacks, outShaderModule); + dumpContext.writeShaderModule(*outShaderModule, createInfo); + return result; + } + + VkResult SLANG_MCALL createDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* callbacks, VkDescriptorSetLayout* outDescSetLayout) + { + auto result = dumpContext.api.vkCreateDescriptorSetLayout(device, createInfo, callbacks, outDescSetLayout); + dumpContext.writeDescriptorSetLayout(*outDescSetLayout, createInfo); + return result; + } + + void installPipelineDumpLayer(VulkanApi& api) + { + dumpContext.api = api; + api.vkCreatePipelineLayout = createPipelineLayout; + api.vkCreateComputePipelines = createComputePipelines; + api.vkCreateShaderModule = createShaderModule; + api.vkCreateDescriptorSetLayout = createDescriptorSetLayout; + } + + void writePipelineDump(UnownedStringSlice path) + { + dumpContext.writeToFile(path); + } +} // renderer_test diff --git a/tools/gfx/vulkan/vk-pipeline-dump-layer.h b/tools/gfx/vulkan/vk-pipeline-dump-layer.h new file mode 100644 index 000000000..c514f7f3e --- /dev/null +++ b/tools/gfx/vulkan/vk-pipeline-dump-layer.h @@ -0,0 +1,11 @@ +// vk-api.cpp +#include "vk-api.h" + +#include "core/slang-string.h" + +namespace gfx { + +void installPipelineDumpLayer(VulkanApi& api); +void writePipelineDump(Slang::UnownedStringSlice path); + +} // renderer_test diff --git a/tools/vk-pipeline-create/main.cpp b/tools/vk-pipeline-create/main.cpp new file mode 100644 index 000000000..893eecfd1 --- /dev/null +++ b/tools/vk-pipeline-create/main.cpp @@ -0,0 +1,287 @@ +// main.cpp + +// This tools reads a gfx pipeline dump file and replays the pipeline creation to trigger +// shader compilation in the driver. +// +#include <slang.h> +#include <slang-com-ptr.h> + +#include "examples/hello-world/vulkan-api.h" +#include "../../source/core/slang-string-util.h" +#include "../../source/core/slang-stream.h" +#include "slang-gfx.h" +#include <chrono> + +#if SLANG_WINDOWS_FAMILY +# include <windows.h> +#else +# include <dlfcn.h> +#endif + +using namespace Slang; + +struct PipelineCreationReplay +{ + // The Vulkan functions pointers result from loading the vulkan library. + VulkanAPI vkAPI; + + Dictionary<Index, VkPipelineLayout> pipelineLayouts; + Dictionary<Index, VkDescriptorSetLayout> descSetLayouts; + Dictionary<Index, VkShaderModule> shaderModules; + Dictionary<Index, VkPipeline> pipelines; + + VkPipelineLayout pipelineLayout = VK_NULL_HANDLE; + VkPipeline pipeline = VK_NULL_HANDLE; + + int initVulkanInstanceAndDevice(); + + List<uint8_t> fileBlob; + List<Index> pipelineOffsets; + + struct Reader + { + Index position; + List<uint8_t>& fileBlob; + Reader(List<uint8_t>& blob, Index pos) : fileBlob(blob), position(pos) {} + template<typename T> + void readRaw(T& val) + { + memcpy(&val, fileBlob.getBuffer() + position, sizeof(T)); + position += sizeof(T); + } + + Index readIndex() + { + Index index; + readRaw(index); + return index; + } + + uint32_t readUInt32() + { + uint32_t index; + readRaw(index); + return index; + } + + const char* readString() + { + uint32_t len = readUInt32(); + auto result = (const char*)fileBlob.getBuffer() + position; + position += len; + return result; + } + + const char* getPtr() { return (const char*)fileBlob.getBuffer() + position; } + }; + + VkShaderModule loadShaderModule(Index offset) + { + VkShaderModule shader = VK_NULL_HANDLE; + if (shaderModules.tryGetValue(offset, shader)) + return shader; + + Reader reader(fileBlob, offset); + VkShaderModuleCreateInfo createInfo = {}; + reader.readRaw(createInfo.sType); + reader.readRaw(createInfo.flags); + createInfo.codeSize = reader.readUInt32(); + createInfo.codeSize *= sizeof(uint32_t); + createInfo.pCode = (uint32_t*)reader.getPtr(); + vkAPI.vkCreateShaderModule(vkAPI.device, &createInfo, nullptr, &shader); + shaderModules[offset] = shader; + + return shader; + } + + VkDescriptorSetLayout loadDescriptorSetLayout(Index offset) + { + VkDescriptorSetLayout layout = VK_NULL_HANDLE; + if (descSetLayouts.tryGetValue(offset, layout)) + return layout; + Reader reader(fileBlob, offset); + VkDescriptorSetLayoutCreateInfo createInfo = {}; + reader.readRaw(createInfo.sType); + reader.readRaw(createInfo.flags); + reader.readRaw(createInfo.bindingCount); + List<VkDescriptorSetLayoutBinding> bindings; + bindings.setCount(createInfo.bindingCount); + memcpy(bindings.getBuffer(), reader.getPtr(), sizeof(VkDescriptorSetLayoutBinding) * bindings.getCount()); + createInfo.pBindings = bindings.getBuffer(); + + vkAPI.vkCreateDescriptorSetLayout(vkAPI.device, &createInfo, nullptr, &layout); + descSetLayouts[offset] = layout; + return layout; + } + + VkPipelineLayout loadPipelineLayout(Index offset) + { + VkPipelineLayout layout = VK_NULL_HANDLE; + if (pipelineLayouts.tryGetValue(offset, layout)) + return layout; + + Reader reader(fileBlob, offset); + VkPipelineLayoutCreateInfo createInfo = {}; + reader.readRaw(createInfo.sType); + reader.readRaw(createInfo.flags); + reader.readRaw(createInfo.setLayoutCount); + List<VkDescriptorSetLayout> setLayouts; + for (uint32_t i = 0; i < createInfo.setLayoutCount; i++) + { + setLayouts.add(loadDescriptorSetLayout(reader.readIndex())); + } + createInfo.pSetLayouts = setLayouts.getBuffer(); + reader.readRaw(createInfo.pushConstantRangeCount); + List<VkPushConstantRange> pushConstants; + pushConstants.setCount(createInfo.pushConstantRangeCount); + memcpy(pushConstants.getBuffer(), reader.getPtr(), sizeof(VkPushConstantRange) * createInfo.pushConstantRangeCount); + createInfo.pPushConstantRanges = pushConstants.getBuffer(); + + vkAPI.vkCreatePipelineLayout(vkAPI.device, &createInfo, nullptr, &layout); + pipelineLayouts[offset] = layout; + return layout; + } + + void loadPipeline(Index id, Index offset) + { + printf("Creating pipeline %d...", (int)id); + + Reader reader(fileBlob, offset); + VkComputePipelineCreateInfo createInfo = {}; + reader.readRaw(createInfo.sType); + reader.readRaw(createInfo.flags); + reader.readRaw(createInfo.stage.sType); + reader.readRaw(createInfo.stage.flags); + reader.readRaw(createInfo.stage.stage); + createInfo.stage.module = loadShaderModule(reader.readIndex()); + createInfo.stage.pName = reader.readString(); + createInfo.layout = loadPipelineLayout(reader.readIndex()); + + VkPipeline pipeline = VK_NULL_HANDLE; + + auto startTime = std::chrono::high_resolution_clock::now(); + + if (vkAPI.vkCreateComputePipelines(vkAPI.device, VK_NULL_HANDLE, 1, &createInfo, nullptr, &pipeline) == 0) + printf("done"); + else + printf("failed"); + + auto endTime = std::chrono::high_resolution_clock::now(); + auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime); + printf(" in %.2fs.\n", elapsed.count() / 1000.0); + + vkAPI.vkDestroyPipeline(vkAPI.device, pipeline, nullptr); + } + + int createComputePipelineFromShader(UnownedStringSlice path, Int pipelineIndex) + { + RefPtr<FileStream> f = new FileStream(); + f->init(path, FileMode::Open); + uint32_t pipelineCount; + size_t readBytes; + f->read(&pipelineCount, sizeof(uint32_t), readBytes); + for (uint32_t i = 0; i < pipelineCount; ++i) + { + Index offset; + f->read(&offset, sizeof(Index), readBytes); + pipelineOffsets.add(offset); + } + Index blobSize; + f->read(&blobSize, sizeof(Index), readBytes); + fileBlob.setCount(blobSize); + f->read(fileBlob.getBuffer(), sizeof(uint8_t) * blobSize, readBytes); + + if (pipelineIndex == -1) + { + for (Index i = 0; i < pipelineOffsets.getCount(); ++i) + { + loadPipeline(i, pipelineOffsets[i]); + } + } + else if (pipelineIndex < pipelineOffsets.getCount()) + { + loadPipeline(pipelineIndex, pipelineOffsets[pipelineIndex]); + } + + for (auto p: descSetLayouts) + vkAPI.vkDestroyDescriptorSetLayout(vkAPI.device, *KeyValueDetail::getValue(&p), nullptr); + for (auto p : pipelineLayouts) + vkAPI.vkDestroyPipelineLayout(vkAPI.device, *KeyValueDetail::getValue(&p), nullptr); + for (auto p : shaderModules) + vkAPI.vkDestroyShaderModule(vkAPI.device, *KeyValueDetail::getValue(&p), nullptr); + + return 0; + } + + int run(int argc, const char** argv); + + void initVulkanAPI(gfx::IDevice* device); +}; + +int main(int argc, const char** argv) +{ + PipelineCreationReplay app; + return app.run(argc, argv); +} + +int PipelineCreationReplay::run(int argc, const char** argv) +{ + gfx::IDevice::Desc deviceDesc = {}; + deviceDesc.deviceType = gfx::DeviceType::Vulkan; + ComPtr<gfx::IDevice> device; + gfx::gfxCreateDevice(&deviceDesc, device.writeRef()); + initVulkanAPI(device); + + if (argc < 2) + { + printf("Usage: vk-pipeline-create <path-to-pipeline-file> [pipeline-index]\n"); + return -1; + } + UnownedStringSlice path = UnownedStringSlice(argv[1]); + Int pipelineIndex = -1; + if (argc > 2) + { + StringUtil::parseInt(UnownedStringSlice(argv[2]), pipelineIndex); + } + + RETURN_ON_FAIL(createComputePipelineFromShader(path, pipelineIndex)); + + vkAPI.vkDestroyDevice = nullptr; + vkAPI.vkDestroyDebugReportCallbackEXT = nullptr; + vkAPI.vkDestroyInstance = nullptr; + return 0; +} + +void PipelineCreationReplay::initVulkanAPI(gfx::IDevice* device) +{ + gfx::IDevice::InteropHandles handle; + device->getNativeDeviceHandles(&handle); + vkAPI.device = (VkDevice)(handle.handles[2].handleValue); + vkAPI.instance = (VkInstance)(handle.handles[0].handleValue); +#if SLANG_WINDOWS_FAMILY + auto dynamicLibraryName = "vulkan-1.dll"; + HMODULE module = ::LoadLibraryA(dynamicLibraryName); + vkAPI.vulkanLibraryHandle = (void*)module; +#define VK_API_GET_GLOBAL_PROC(x) vkAPI.x = (PFN_##x)GetProcAddress(module, #x); +#else + auto dynamicLibraryName = "libvulkan.so.1"; + vkAPI.vulkanLibraryHandle = dlopen(dynamicLibraryName, RTLD_NOW); +#define VK_API_GET_GLOBAL_PROC(x) vkAPI.x = (PFN_##x)dlsym(vkAPI.vulkanLibraryHandle, #x); +#endif + + // Initialize all the global functions. + VK_API_ALL_GLOBAL_PROCS(VK_API_GET_GLOBAL_PROC); + + vkAPI.initInstanceProcs(); + vkAPI.initDeviceProcs(); +} + +int PipelineCreationReplay::initVulkanInstanceAndDevice() +{ + if (initializeVulkanDevice(vkAPI) != 0) + { + printf("Failed to load Vulkan.\n"); + return -1; + } + return 0; +} |
