2
我正在處理動態立方體貼圖渲染。特別是,爲了渲染立方體貼圖,我使用了DirectX SDK示例「CubeMapGS」中的着色器。着色器似乎是正確的,如你所見:着色器鏈接錯誤/不匹配
SamplerState ss;
Texture2D tex;
cbuffer Constants
{
float4x4 worldMat;
float4x4 viewMats[6];
float4x4 projMat;
};
struct VS_CUBEMAP_IN
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
struct GS_CUBEMAP_IN
{
float4 Pos : SV_POSITION; // World position
float2 Tex : TEXCOORD0; // Texture coord
};
struct PS_CUBEMAP_IN
{
float4 Pos : SV_POSITION; // Projection coord
float2 Tex : TEXCOORD0; // Texture coord
uint RTIndex : SV_RenderTargetArrayIndex;
};
GS_CUBEMAP_IN VShader(VS_CUBEMAP_IN input)
{
GS_CUBEMAP_IN output = (GS_CUBEMAP_IN) 0.0f;
// Compute world position
output.Pos = mul(input.Pos, worldMat);
// Propagate tex coord
output.Tex = input.Tex;
return output;
}
[maxvertexcount(18)]
void GShader(triangle GS_CUBEMAP_IN input[3], inout TriangleStream<PS_CUBEMAP_IN> CubeMapStream)
{
for (int f = 0; f < 6; ++f)
{
// Compute screen coordinates
PS_CUBEMAP_IN output;
output.RTIndex = f;
for (int v = 0; v < 3; v++)
{
output.Pos = mul(input[v].Pos, viewMats[f]);
output.Pos = mul(output.Pos, projMat);
output.Tex = input[v].Tex;
CubeMapStream.Append(output);
}
CubeMapStream.RestartStrip();
}
}
float4 PShader(PS_CUBEMAP_IN input) : SV_Target {
return tex.Sample(ss, input.Tex);
}
但是,它不起作用。事實上,我收到以下的DirectX錯誤消息:
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'SV_POSITION' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'SV_POSITION' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
錯誤消息,似乎預示着某種輸入參數和不同的Shader功能的輸出值之間的不匹配的,但我真的不能認識到這一點不匹配。
有關此錯誤的任何想法或解釋?