diff --git a/src/render/direct3d12/D3D12_PixelShader_Advanced.hlsl b/src/render/direct3d12/D3D12_PixelShader_Advanced.hlsl index ac25bb02be..1c869b85c2 100644 --- a/src/render/direct3d12/D3D12_PixelShader_Advanced.hlsl +++ b/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); diff --git a/src/render/direct3d12/D3D12_PixelShader_Colors.hlsl b/src/render/direct3d12/D3D12_PixelShader_Colors.hlsl index 4383011f0e..834d6298f1 100644 --- a/src/render/direct3d12/D3D12_PixelShader_Colors.hlsl +++ b/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 diff --git a/src/render/direct3d12/D3D12_PixelShader_Common.incl b/src/render/direct3d12/D3D12_PixelShader_Common.hlsli similarity index 99% rename from src/render/direct3d12/D3D12_PixelShader_Common.incl rename to src/render/direct3d12/D3D12_PixelShader_Common.hlsli index 1133c32d9d..ba32e0c833 100644 --- a/src/render/direct3d12/D3D12_PixelShader_Common.incl +++ b/src/render/direct3d12/D3D12_PixelShader_Common.hlsli @@ -1,3 +1,4 @@ +#include "D3D12_Shader_Common.hlsli" Texture2D texture0 : register(t0); Texture2D texture1 : register(t1); diff --git a/src/render/direct3d12/D3D12_PixelShader_Textures.hlsl b/src/render/direct3d12/D3D12_PixelShader_Textures.hlsl index 6625744f1a..f705742ead 100644 --- a/src/render/direct3d12/D3D12_PixelShader_Textures.hlsl +++ b/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 diff --git a/src/render/direct3d12/D3D12_Shader_Common.hlsli b/src/render/direct3d12/D3D12_Shader_Common.hlsli new file mode 100644 index 0000000000..4bf8074de5 --- /dev/null +++ b/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 )" diff --git a/src/render/direct3d12/D3D12_VertexShader.hlsl b/src/render/direct3d12/D3D12_VertexShader.hlsl index ad08992a08..c7d2433526 100644 --- a/src/render/direct3d12/D3D12_VertexShader.hlsl +++ b/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) { diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index ef7d7ce2b0..aa9a4fc9da 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/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;