This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
SharpBgfx.targets
68 lines (56 loc) · 4.9 KB
/
SharpBgfx.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<Project>
<PropertyGroup>
<!-- Instucts Visual Studio to always start MSBuild when building. -->
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<ShaderCPath Condition=" $(ShaderCPath) == '' ">$(MSBuildThisFileDirectory)tools\shaderc.exe</ShaderCPath>
<ShaderIncludeDir Condition=" $(ShaderIncludeDir) == '' ">$(MSBuildThisFileDirectory)include</ShaderIncludeDir>
<VertexShaderIncludePattern Condition=" $(VertexShaderIncludePattern) == '' ">vs_*.sc</VertexShaderIncludePattern>
<FragmentShaderIncludePattern Condition=" $(FragmentShaderIncludePattern) == '' ">fs_*.sc</FragmentShaderIncludePattern>
<ComputeShaderIncludePattern Condition=" $(ComputeShaderIncludePattern) == '' ">cs_*.sc</ComputeShaderIncludePattern>
<ShaderOutputDir Condition=" $(ShaderOutputDir) == '' ">bin\</ShaderOutputDir>
</PropertyGroup>
<ItemGroup>
<VertexShaders Include="$(VertexShaderIncludePattern)" />
<FragmentShaders Include="$(FragmentShaderIncludePattern)" />
<ComputeShaders Include="$(ComputeShaderIncludePattern)" />
</ItemGroup>
<!-- Build process hooks. -->
<PropertyGroup>
<CleanDependsOn>CleanShaders;$(CoreCompileDependsOn)</CleanDependsOn>
<CoreCompileDependsOn>$(CoreCompileDependsOn);CompileShaders</CoreCompileDependsOn>
</PropertyGroup>
<Target Name="CleanShaders" BeforeTargets="CoreClean">
<RemoveDir Condition=" Exists('$(IntermediateOutputPath)$(ShaderOutputDir)') "
Directories="$(IntermediateOutputPath)$(ShaderOutputDir)" />
<RemoveDir Condition=" Exists('$(TargetDir)$(ShaderOutputDir)') "
Directories="$(TargetDir)$(ShaderOutputDir)" />
</Target>
<Target Name="CompileShaders"
BeforeTargets="AfterBuild"
AfterTargets="CopyFilesToOutputDirectory"
DependsOnTargets="EnsureShaderIntermediateOutputDirectory;CompileVertexShaders;CompileFragmentShaders;CompileComputeShaders;CopyShaderBinariesToOutputDirectory" />
<Target Name="EnsureShaderIntermediateOutputDirectory">
<MakeDir Directories="$(IntermediateOutputPath)$(ShaderOutputDir)dx11\" />
<MakeDir Directories="$(IntermediateOutputPath)$(ShaderOutputDir)glsl\" />
</Target>
<Target Name="CompileVertexShaders" Inputs="@(VertexShaders)" Outputs="$(IntermediateOutputPath)$(ShaderOutputDir)dx11\%(VertexShaders.Filename).bin;$(IntermediateOutputPath)$(ShaderOutputDir)glsl\%(VertexShaders.Filename).bin">
<Exec Command="$(ShaderCPath) --platform windows --type vertex -p vs_4_0 -O 3 -f "@(VertexShaders)" -o "$(IntermediateOutputPath)$(ShaderOutputDir)dx11\%(VertexShaders.Filename).bin" -i "$(ShaderIncludeDir)"" />
<Exec Command="$(ShaderCPath) --platform linux --type vertex -p 120 -f "@(VertexShaders)" -o "$(IntermediateOutputPath)$(ShaderOutputDir)glsl\%(VertexShaders.Filename).bin" -i "$(ShaderIncludeDir)"" />
</Target>
<Target Name="CompileFragmentShaders" Inputs="@(FragmentShaders)" Outputs="$(IntermediateOutputPath)$(ShaderOutputDir)dx11\%(FragmentShaders.Filename).bin;$(IntermediateOutputPath)$(ShaderOutputDir)glsl\%(FragmentShaders.Filename).bin">
<Exec Command="$(ShaderCPath) --platform windows --type fragment -p ps_4_0 -O 3 -f "@(FragmentShaders)" -o "$(IntermediateOutputPath)$(ShaderOutputDir)dx11\%(FragmentShaders.Filename).bin" -i "$(ShaderIncludeDir)"" />
<Exec Command="$(ShaderCPath) --platform linux --type fragment -p 120 -f "@(FragmentShaders)" -o "$(IntermediateOutputPath)$(ShaderOutputDir)glsl\%(FragmentShaders.Filename).bin" -i "$(ShaderIncludeDir)"" />
</Target>
<Target Name="CompileComputeShaders" Inputs="@(ComputeShaders)" Outputs="$(IntermediateOutputPath)$(ShaderOutputDir)dx11\%(ComputeShaders.Filename).bin;$(IntermediateOutputPath)$(ShaderOutputDir)glsl\%(ComputeShaders.Filename).bin">
<Exec Command="$(ShaderCPath) --platform windows --type compute -p cs_5_0 -O 3 -f "@(ComputeShaders)" -o "$(IntermediateOutputPath)$(ShaderOutputDir)dx11\%(ComputeShaders.Filename).bin" -i "$(ShaderIncludeDir)"" />
<Exec Command="$(ShaderCPath) --platform linux --type compute -p 430 -f "@(ComputeShaders)" -o "$(IntermediateOutputPath)$(ShaderOutputDir)glsl\%(ComputeShaders.Filename).bin" -i "$(ShaderIncludeDir)"" />
</Target>
<Target Name="CopyShaderBinariesToOutputDirectory">
<ItemGroup>
<ShaderBinaries Include="$(IntermediateOutputPath)$(ShaderOutputDir)**\*.bin" />
</ItemGroup>
<Copy SourceFiles="@(ShaderBinaries)"
DestinationFolder="$(TargetDir)$(ShaderOutputDir)%(RecursiveDir)"
SkipUnchangedFiles="true" />
</Target>
</Project>