diff options
| author | David Siher <32305650+dsiher@users.noreply.github.com> | 2022-01-27 11:53:58 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-27 08:53:58 -0800 |
| commit | 22f0c04d2b5f8245ccaee6caee8e5adebea4aea0 (patch) | |
| tree | 4ab4b2089823f0b6b915bfed479d39468d7b83ad | |
| parent | 10470f8796de5b4fe48a83d50cda75a4188c06e3 (diff) | |
Update heterogeneous-hello-world to use gfx changes + delete shader.cpp (#2085)
* Update heterogeneous-hello-world to use gfx changes + delete shader.cpp
* Remove "experimental feature" tag from premake
* Add placeholder executeComputation_0() to shader.cpp
* Add shader.cpp to heterogeneous-hello-world files in premake
* Added project "heterogeneous-first-gen" to address first time build issues
* Re-add "experimental feature" tag, clean up generated file structure
Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
5 files changed, 199 insertions, 21 deletions
diff --git a/build/visual-studio/heterogeneous-hello-world/heterogeneous-first-gen.vcxproj b/build/visual-studio/heterogeneous-hello-world/heterogeneous-first-gen.vcxproj new file mode 100644 index 000000000..a2181ad08 --- /dev/null +++ b/build/visual-studio/heterogeneous-hello-world/heterogeneous-first-gen.vcxproj @@ -0,0 +1,168 @@ +<?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|ARM"> + <Configuration>Debug</Configuration> + <Platform>ARM</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|ARM"> + <Configuration>Debug aarch64</Configuration> + <Platform>ARM</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|ARM"> + <Configuration>Release</Configuration> + <Platform>ARM</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|ARM"> + <Configuration>Release aarch64</Configuration> + <Platform>ARM</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{3E8C6F8B-AAC3-B722-B3CD-1B461F84DE1B}</ProjectGuid> + <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> + <Keyword>Win32Proj</Keyword> + <RootNamespace>heterogeneous-first-gen</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Utility</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Utility</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM'" Label="Configuration"> + <ConfigurationType>Utility</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Utility</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Utility</ConfigurationType> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM'" Label="Configuration"> + <ConfigurationType>Utility</ConfigurationType> + <PlatformToolset>v142</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)'=='Debug aarch64|ARM'"> + <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|ARM'"> + <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'"> + <OutDir>..\..\..\bin\windows-x86\debug\</OutDir> + <IntDir>obj\x86\Debug\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <OutDir>..\..\..\bin\windows-x64\debug\</OutDir> + <IntDir>obj\x64\Debug\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM'"> + <OutDir>..\..\..\bin\windows-aarch64\debug\</OutDir> + <IntDir>obj\aarch64\Debug\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <OutDir>..\..\..\bin\windows-x86\release\</OutDir> + <IntDir>obj\x86\Release\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <OutDir>..\..\..\bin\windows-x64\release\</OutDir> + <IntDir>obj\x64\Release\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM'"> + <OutDir>..\..\..\bin\windows-aarch64\release\</OutDir> + <IntDir>obj\aarch64\Release\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <PreBuildEvent> + <Command>"../../../bin/windows-x86/debug/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <PreBuildEvent> + <Command>"../../../bin/windows-x64/debug/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM'"> + <PreBuildEvent> + <Command>"../../../bin/windows-aarch64/debug/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <PreBuildEvent> + <Command>"../../../bin/windows-x86/release/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <PreBuildEvent> + <Command>"../../../bin/windows-x64/release/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM'"> + <PreBuildEvent> + <Command>"../../../bin/windows-aarch64/release/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> + </PreBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ProjectReference Include="..\slangc\slangc.vcxproj"> + <Project>{D56CBCEB-1EB5-4CA8-AEC4-48EA35ED61C7}</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/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj b/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj index a7489c0b3..70c173112 100644 --- a/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj +++ b/build/visual-studio/heterogeneous-hello-world/heterogeneous-hello-world.vcxproj @@ -175,7 +175,7 @@ </Link> <PreBuildEvent> <Command>"../../../bin/windows-x86/debug/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> - <Message>Generating shader.cpp from shader.slang</Message> + <Message>Generating shader.cpp in ../../../examples/heterogeneous-hello-world/</Message> </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> @@ -194,7 +194,7 @@ </Link> <PreBuildEvent> <Command>"../../../bin/windows-x64/debug/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> - <Message>Generating shader.cpp from shader.slang</Message> + <Message>Generating shader.cpp in ../../../examples/heterogeneous-hello-world/</Message> </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug aarch64|ARM'"> @@ -213,7 +213,7 @@ </Link> <PreBuildEvent> <Command>"../../../bin/windows-aarch64/debug/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> - <Message>Generating shader.cpp from shader.slang</Message> + <Message>Generating shader.cpp in ../../../examples/heterogeneous-hello-world/</Message> </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> @@ -236,7 +236,7 @@ </Link> <PreBuildEvent> <Command>"../../../bin/windows-x86/release/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> - <Message>Generating shader.cpp from shader.slang</Message> + <Message>Generating shader.cpp in ../../../examples/heterogeneous-hello-world/</Message> </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> @@ -259,7 +259,7 @@ </Link> <PreBuildEvent> <Command>"../../../bin/windows-x64/release/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> - <Message>Generating shader.cpp from shader.slang</Message> + <Message>Generating shader.cpp in ../../../examples/heterogeneous-hello-world/</Message> </PreBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release aarch64|ARM'"> @@ -282,7 +282,7 @@ </Link> <PreBuildEvent> <Command>"../../../bin/windows-aarch64/release/slangc" "../../../examples/heterogeneous-hello-world/shader.slang" -o "../../../examples/heterogeneous-hello-world/shader.cpp" -heterogeneous -target cpp -target hlsl</Command> - <Message>Generating shader.cpp from shader.slang</Message> + <Message>Generating shader.cpp in ../../../examples/heterogeneous-hello-world/</Message> </PreBuildEvent> </ItemDefinitionGroup> <ItemGroup> @@ -314,6 +314,9 @@ <ProjectReference Include="..\core\core.vcxproj"> <Project>{F9BE7957-8399-899E-0C49-E714FDDD4B65}</Project> </ProjectReference> + <ProjectReference Include="heterogeneous-first-gen.vcxproj"> + <Project>{3E8C6F8B-AAC3-B722-B3CD-1B461F84DE1B}</Project> + </ProjectReference> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/examples/heterogeneous-hello-world/main.cpp b/examples/heterogeneous-hello-world/main.cpp index 05d1e4787..0d8d2ca73 100644 --- a/examples/heterogeneous-hello-world/main.cpp +++ b/examples/heterogeneous-hello-world/main.cpp @@ -132,7 +132,6 @@ gfx::IShaderProgram* loadShaderProgram(gfx::IDevice *device, String entryPoint, // We can create a `gfx::IShaderProgram` object from `composedProgram` // so it may be used by the graphics layer. gfx::IShaderProgram::Desc programDesc = {}; - programDesc.pipelineType = gfx::PipelineType::Compute; programDesc.slangProgram = composedProgram.get(); gProgram = device->createProgram(programDesc); @@ -158,7 +157,7 @@ gfx::IBufferResource* createStructuredBuffer( ResourceState::CopyDestination, ResourceState::CopySource); bufferDesc.defaultState = ResourceState::UnorderedAccess; - bufferDesc.cpuAccessFlags = AccessFlag::Write | AccessFlag::Read; + bufferDesc.memoryType = MemoryType::DeviceLocal; SlangResult result = device->createBufferResource(bufferDesc, (void *)initialData, @@ -237,7 +236,7 @@ void dispatchComputation( encoder->endEncoding(); commandBuffer->close(); gQueue->executeCommandBuffer(commandBuffer); - gQueue->wait(); + gQueue->waitOnHost(); } bool printOutputValues( diff --git a/examples/heterogeneous-hello-world/shader.cpp b/examples/heterogeneous-hello-world/shader.cpp deleted file mode 100644 index b1fff29f6..000000000 --- a/examples/heterogeneous-hello-world/shader.cpp +++ /dev/null @@ -1 +0,0 @@ -// This is a placeholder. The contents will be generated during build.
\ No newline at end of file diff --git a/premake5.lua b/premake5.lua index 69f18a5b4..e83d61728 100644 --- a/premake5.lua +++ b/premake5.lua @@ -151,14 +151,14 @@ newoption { default = "true", allowed = { { "true", "True"}, { "false", "False" } } } - -newoption { + + newoption { trigger = "enable-experimental-projects", description = "(Optional) If true include experimental projects in build.", value = "bool", default = "false", allowed = { { "true", "True"}, { "false", "False" } } - } + } buildLocation = _OPTIONS["build-location"] executeBinary = (_OPTIONS["execute-binary"] == "true") @@ -679,21 +679,30 @@ newoption { example "cpu-hello-world" kind "ConsoleApp" - -if enableExperimental then - -- TODO: Currently this project doesn't build on linux CI. - -- Need to fix so that we don't check in shader.cpp, which changes - -- everytime when it is generated on a different machine (contains absolute path) + + if enableExperimental then + project "heterogeneous-first-gen" + kind "Utility" + links "slangc" + location("build/" .. slangUtil.getBuildLocationName(targetInfo) .. "/heterogeneous-hello-world") + prebuildcommands { + "\"%{wks.location:lower()}/bin/" .. targetName .. "/%{cfg.buildcfg:lower()}/slangc\" \"%{wks.location:lower()}/examples/heterogeneous-hello-world/shader.slang\" -o \"%{wks.location:lower()}/examples/heterogeneous-hello-world/shader.cpp\" -heterogeneous -target cpp -target hlsl" + } + example "heterogeneous-hello-world" kind "ConsoleApp" -- Additionally add slangc for compiling shader.cpp - links { "example-base", "slang", "gfx", "gfx-util", "slangc", "platform", "core" } + links { "example-base", "slang", "gfx", "gfx-util", "slangc", "platform", "core", "heterogeneous-first-gen" } -- Generate shader.cpp from shader.slang - prebuildmessage ("Generating shader.cpp from shader.slang") + prebuildmessage "Generating shader.cpp in %{wks.location:lower()}/examples/heterogeneous-hello-world/" prebuildcommands { "\"%{wks.location:lower()}/bin/" .. targetName .. "/%{cfg.buildcfg:lower()}/slangc\" \"%{wks.location:lower()}/examples/heterogeneous-hello-world/shader.slang\" -o \"%{wks.location:lower()}/examples/heterogeneous-hello-world/shader.cpp\" -heterogeneous -target cpp -target hlsl" } -end + files { + "examples/heterogeneous-hello-world/shader.cpp" + } + end + -- Most of the other projects have more interesting configuration going -- on, so let's walk through them in order of increasing complexity. -- |
