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

main
Jade Macho 2024-03-01 18:21:27 +01:00 committed by Sam Lantinga
parent e2a8209263
commit c74f273848
7 changed files with 44 additions and 69 deletions

View File

@ -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);

View File

@ -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

View File

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

View File

@ -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

View File

@ -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 )"

View File

@ -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)
{

View File

@ -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;