From 0b6f735ad2ee5e565a0ffe9f9091146b59057faf Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 1 Aug 2018 12:04:26 +0100 Subject: [PATCH] Tidy up vertex-fragment structures in HLSL shaders * Fix a few mismatches and delete wireframeV2F which is not needed in any other shaders but the mesh rendering path. Others just need SV_Position. --- renderdoc/data/hlsl/debugdisplay.hlsl | 34 +++++++-------------------- renderdoc/data/hlsl/mesh.hlsl | 14 +++++------ renderdoc/data/hlsl/multisample.hlsl | 32 ++++++++++--------------- 3 files changed, 27 insertions(+), 53 deletions(-) diff --git a/renderdoc/data/hlsl/debugdisplay.hlsl b/renderdoc/data/hlsl/debugdisplay.hlsl index 84b9db79a..ab29892a6 100644 --- a/renderdoc/data/hlsl/debugdisplay.hlsl +++ b/renderdoc/data/hlsl/debugdisplay.hlsl @@ -195,36 +195,18 @@ struct MultipleOutput float4 col7 : SV_Target7; }; -struct wireframeV2F +float4 RENDERDOC_FullscreenVS(uint id : SV_VertexID) : SV_Position { - float4 pos : SV_Position; - float3 norm : Normal; - float4 secondary : Secondary; -}; - -wireframeV2F RENDERDOC_FullscreenVS(uint id : SV_VertexID) -{ - wireframeV2F OUT = (wireframeV2F)0; - float4 pos[] = { float4( -1.0f, 1.0f, 0.0f, 1.0f), float4( 3.0f, 1.0f, 0.0f, 1.0f), float4( -1.0f, -3.0f, 0.0f, 1.0f) }; - - float2 uv[] = { - float2(0.0f, 0.0f), - float2(2.0f, 0.0f), - float2(0.0f, 2.0f) - }; - OUT.pos = pos[id]; - OUT.secondary = float4(uv[id].xy, 0, 1); - - return OUT; + return pos[id]; } -MultipleOutput RENDERDOC_WireframePS(wireframeV2F IN) +MultipleOutput RENDERDOC_WireframePS() { MultipleOutput OUT = (MultipleOutput)0; @@ -246,7 +228,7 @@ cbuffer overlayconsts : register(b0) float4 overlaycol; }; -MultipleOutput RENDERDOC_FixedColPS(float4 IN : SV_Position) +MultipleOutput RENDERDOC_FixedColPS() { MultipleOutput OUT = (MultipleOutput)0; @@ -263,11 +245,11 @@ MultipleOutput RENDERDOC_FixedColPS(float4 IN : SV_Position) return OUT; } -float4 RENDERDOC_OutlinePS(float4 IN : SV_Position) : SV_Target0 +float4 RENDERDOC_OutlinePS(float4 pos : SV_Position) : SV_Target0 { float4 ret = Channels; - float2 rectPos = IN.xy - float2(RangeMinimum, InverseRangeSize); + float2 rectPos = pos.xy - float2(RangeMinimum, InverseRangeSize); float2 rectSize = TextureResolutionPS.xy; float2 ab = fmod(rectPos.xy, 32.0.xx); @@ -302,9 +284,9 @@ float4 RENDERDOC_OutlinePS(float4 IN : SV_Position) : SV_Target0 return ret; } -float4 RENDERDOC_CheckerboardPS(float4 IN : SV_Position) : SV_Target0 +float4 RENDERDOC_CheckerboardPS(float4 pos : SV_Position) : SV_Target0 { - float2 ab = fmod(IN.xy, 128.0.xx); + float2 ab = fmod(pos.xy, 128.0.xx); if( (ab.x < 64 && ab.y < 64) || diff --git a/renderdoc/data/hlsl/mesh.hlsl b/renderdoc/data/hlsl/mesh.hlsl index 36a590a78..e676487b0 100644 --- a/renderdoc/data/hlsl/mesh.hlsl +++ b/renderdoc/data/hlsl/mesh.hlsl @@ -22,7 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ -struct wireframeV2F +struct meshV2F { float4 pos : SV_Position; float3 norm : Normal; @@ -35,9 +35,9 @@ struct meshA2V float4 secondary : sec; }; -wireframeV2F RENDERDOC_MeshVS(meshA2V IN, uint vid : SV_VertexID) +meshV2F RENDERDOC_MeshVS(meshA2V IN, uint vid : SV_VertexID) { - wireframeV2F OUT = (wireframeV2F)0; + meshV2F OUT = (meshV2F)0; float2 psprite[4] = { @@ -67,7 +67,7 @@ cbuffer viewportCBuf : register(b0) }; [maxvertexcount(3)] -void RENDERDOC_TriangleSizeGS(triangle wireframeV2F input[3], inout TriangleStream TriStream) +void RENDERDOC_TriangleSizeGS(triangle meshV2F input[3], inout TriangleStream TriStream) { triSizeV2F output; @@ -114,9 +114,9 @@ float4 RENDERDOC_TriangleSizePS(triSizeV2F IN) : SV_Target0 } [maxvertexcount(3)] -void RENDERDOC_MeshGS(triangle wireframeV2F input[3], inout TriangleStream TriStream) +void RENDERDOC_MeshGS(triangle meshV2F input[3], inout TriangleStream TriStream) { - wireframeV2F output; + meshV2F output; float4 faceEdgeA = mul(input[1].pos, InvProj) - mul(input[0].pos, InvProj); float4 faceEdgeB = mul(input[2].pos, InvProj) - mul(input[0].pos, InvProj); @@ -137,7 +137,7 @@ cbuffer MeshColourPush : register(b2) float4 MeshColour; } -float4 RENDERDOC_MeshPS(wireframeV2F IN) : SV_Target0 +float4 RENDERDOC_MeshPS(meshV2F IN) : SV_Target0 { uint type = OutputDisplayFormat; diff --git a/renderdoc/data/hlsl/multisample.hlsl b/renderdoc/data/hlsl/multisample.hlsl index a669d25ea..ba2eea3a3 100644 --- a/renderdoc/data/hlsl/multisample.hlsl +++ b/renderdoc/data/hlsl/multisample.hlsl @@ -27,14 +27,6 @@ // (or serialising it back in, for that matter), we copy each sample to a slice in a // 2DArray texture, and vice-versa. These shaders do that copy as appropriate. -struct wireframeV2F -{ - float4 pos : SV_Position; - float3 norm : Normal; - float3 color : COLOR; - float2 tex : TEXCOORD0; -}; - cbuffer msarraycopyconsts : register(b0) { uint sampleCount; @@ -49,9 +41,9 @@ Texture2DMSArray sourceMS8 : register(t3); Texture2DMSArray sourceMS16 : register(t4); Texture2DMSArray sourceMS32 : register(t5); -uint4 RENDERDOC_CopyMSToArray(wireframeV2F IN) : SV_Target0 +uint4 RENDERDOC_CopyMSToArray(float4 pos : SV_Position) : SV_Target0 { - uint3 srcCoord = uint3(IN.pos.x, IN.pos.y, currentSlice); + uint3 srcCoord = uint3(pos.x, pos.y, currentSlice); if(sampleCount == 2) { @@ -83,9 +75,9 @@ Texture2DMSArray sourceFloatMS8 : register(t3); Texture2DMSArray sourceFloatMS16 : register(t4); Texture2DMSArray sourceFloatMS32 : register(t5); -float4 RENDERDOC_FloatCopyMSToArray(wireframeV2F IN) : SV_Target0 +float4 RENDERDOC_FloatCopyMSToArray(float4 pos : SV_Position) : SV_Target0 { - uint3 srcCoord = uint3(IN.pos.x, IN.pos.y, currentSlice); + uint3 srcCoord = uint3(pos.x, pos.y, currentSlice); if(sampleCount == 2) { @@ -123,9 +115,9 @@ Texture2DMSArray sourceStencilMS8 : register(t13); Texture2DMSArray sourceStencilMS16 : register(t14); Texture2DMSArray sourceStencilMS32 : register(t15); -float RENDERDOC_DepthCopyMSToArray(wireframeV2F IN) : SV_Depth +float RENDERDOC_DepthCopyMSToArray(float4 pos : SV_Position) : SV_Depth { - uint3 srcCoord = uint3(IN.pos.x, IN.pos.y, currentSlice); + uint3 srcCoord = uint3(pos.x, pos.y, currentSlice); if(currentStencil < 256) { @@ -182,18 +174,18 @@ float RENDERDOC_DepthCopyMSToArray(wireframeV2F IN) : SV_Depth Texture2DArray sourceArray : register(t0); -uint4 RENDERDOC_CopyArrayToMS(wireframeV2F IN, uint curSample : SV_SampleIndex) : SV_Target0 +uint4 RENDERDOC_CopyArrayToMS(float4 pos : SV_Position, uint curSample : SV_SampleIndex) : SV_Target0 { - uint4 srcCoord = uint4(IN.pos.x, IN.pos.y, currentSlice*sampleCount + curSample, 0); + uint4 srcCoord = uint4(pos.x, pos.y, currentSlice*sampleCount + curSample, 0); return sourceArray.Load(srcCoord); } Texture2DArray sourceFloatArray : register(t0); -float4 RENDERDOC_FloatCopyArrayToMS(wireframeV2F IN, uint curSample : SV_SampleIndex) : SV_Target0 +float4 RENDERDOC_FloatCopyArrayToMS(float4 pos : SV_Position, uint curSample : SV_SampleIndex) : SV_Target0 { - uint4 srcCoord = uint4(IN.pos.x, IN.pos.y, currentSlice*sampleCount + curSample, 0); + uint4 srcCoord = uint4(pos.x, pos.y, currentSlice*sampleCount + curSample, 0); return sourceFloatArray.Load(srcCoord); } @@ -201,9 +193,9 @@ float4 RENDERDOC_FloatCopyArrayToMS(wireframeV2F IN, uint curSample : SV_SampleI Texture2DArray sourceDepthArray : register(t0); Texture2DArray sourceStencilArray : register(t1); -float RENDERDOC_DepthCopyArrayToMS(wireframeV2F IN, uint curSample : SV_SampleIndex) : SV_Depth +float RENDERDOC_DepthCopyArrayToMS(float4 pos : SV_Position, uint curSample : SV_SampleIndex) : SV_Depth { - uint4 srcCoord = uint4(IN.pos.x, IN.pos.y, currentSlice*sampleCount + curSample, 0); + uint4 srcCoord = uint4(pos.x, pos.y, currentSlice*sampleCount + curSample, 0); if(currentStencil < 1000) {