Explorar o código

d3d12: Move root sigs to D3D12_Shader_Common.hlsli, fix mismatch

Jade Macho hai 1 ano
pai
achega
c74f273848

+ 2 - 13
src/render/direct3d12/D3D12_PixelShader_Advanced.hlsl

@@ -1,18 +1,7 @@
 
-#include "D3D12_PixelShader_Common.incl"
+#include "D3D12_PixelShader_Common.hlsli"
 
-#define ADVANCEDRS \
-    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
-    "            DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
-    "            DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
-    "            DENY_HULL_SHADER_ROOT_ACCESS )," \
-    "RootConstants(num32BitConstants=24, b1),"\
-    "DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
-
-[RootSignature(ADVANCEDRS)]
+[RootSignature(AdvancedRS)]
 float4 main(PixelShaderInput input) : SV_TARGET
 {
     return AdvancedPixelShader(input);

+ 1 - 8
src/render/direct3d12/D3D12_PixelShader_Colors.hlsl

@@ -1,12 +1,5 @@
 
-#include "D3D12_PixelShader_Common.incl"
-
-#define ColorRS \
-    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
-    "DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
-    "DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
-    "DENY_HULL_SHADER_ROOT_ACCESS )," \
-    "RootConstants(num32BitConstants=24, b1)"
+#include "D3D12_PixelShader_Common.hlsli"
 
 [RootSignature(ColorRS)]
 float4 main(PixelShaderInput input) : SV_TARGET0

+ 1 - 0
src/render/direct3d12/D3D12_PixelShader_Common.incl → src/render/direct3d12/D3D12_PixelShader_Common.hlsli

@@ -1,3 +1,4 @@
+#include "D3D12_Shader_Common.hlsli"
 
 Texture2D texture0 : register(t0);
 Texture2D texture1 : register(t1);

+ 1 - 10
src/render/direct3d12/D3D12_PixelShader_Textures.hlsl

@@ -1,14 +1,5 @@
 
-#include "D3D12_PixelShader_Common.incl"
-
-#define TextureRS \
-    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
-    "            DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
-    "            DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
-    "            DENY_HULL_SHADER_ROOT_ACCESS )," \
-    "RootConstants(num32BitConstants=24, b1),"\
-    "DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
+#include "D3D12_PixelShader_Common.hlsli"
 
 [RootSignature(TextureRS)]
 float4 main(PixelShaderInput input) : SV_TARGET

+ 37 - 0
src/render/direct3d12/D3D12_Shader_Common.hlsli

@@ -0,0 +1,37 @@
+#pragma pack_matrix( row_major )
+
+cbuffer VertexShaderConstants : register(b0)
+{
+    matrix model;
+    matrix projectionAndView;
+};
+
+#define ColorRS \
+    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
+    "DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
+    "DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
+    "DENY_HULL_SHADER_ROOT_ACCESS )," \
+    "RootConstants(num32BitConstants=32, b0)," \
+    "RootConstants(num32BitConstants=24, b1)"\
+
+#define TextureRS \
+    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
+    "            DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
+    "            DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
+    "            DENY_HULL_SHADER_ROOT_ACCESS )," \
+    "RootConstants(num32BitConstants=32, b0),"\
+    "RootConstants(num32BitConstants=24, b1),"\
+    "DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
+    "DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
+
+#define AdvancedRS \
+    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
+    "            DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
+    "            DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
+    "            DENY_HULL_SHADER_ROOT_ACCESS )," \
+    "RootConstants(num32BitConstants=32, b0),"\
+    "RootConstants(num32BitConstants=24, b1),"\
+    "DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
+    "DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
+    "DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
+    "DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"

+ 1 - 37
src/render/direct3d12/D3D12_VertexShader.hlsl

@@ -1,10 +1,4 @@
-#pragma pack_matrix( row_major )
-
-cbuffer VertexShaderConstants : register(b0)
-{
-    matrix model;
-    matrix projectionAndView;
-};
+#include "D3D12_Shader_Common.hlsli"
 
 struct VertexShaderInput
 {
@@ -20,36 +14,6 @@ struct VertexShaderOutput
     float4 color : COLOR0;
 };
 
-#define ColorRS \
-    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
-    "DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
-    "DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
-    "DENY_HULL_SHADER_ROOT_ACCESS )," \
-    "RootConstants(num32BitConstants=32, b0)," \
-    "RootConstants(num32BitConstants=20, b1)"\
-
-#define TextureRS \
-    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
-    "            DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
-    "            DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
-    "            DENY_HULL_SHADER_ROOT_ACCESS )," \
-    "RootConstants(num32BitConstants=32, b0),"\
-    "RootConstants(num32BitConstants=20, b1),"\
-    "DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
-
-#define AdvancedRS \
-    "RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
-    "            DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
-    "            DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
-    "            DENY_HULL_SHADER_ROOT_ACCESS )," \
-    "RootConstants(num32BitConstants=32, b0),"\
-    "RootConstants(num32BitConstants=20, b1),"\
-    "DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
-    "DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
-
 [RootSignature(ColorRS)]
 VertexShaderOutput mainColor(VertexShaderInput input)
 {

+ 1 - 1
src/render/direct3d12/SDL_render_d3d12.c

@@ -90,7 +90,7 @@ typedef struct
     Float4X4 projectionAndView;
 } VertexShaderConstants;
 
-/* These should mirror the definitions in D3D12_PixelShader_Common.incl */
+/* These should mirror the definitions in D3D12_PixelShader_Common.hlsli */
 //static const float TONEMAP_NONE = 0;
 //static const float TONEMAP_LINEAR = 1;
 static const float TONEMAP_CHROME = 2;