这是 DirectX9 效果编译器中的错误吗? "Invalid input semantics - POSITIONT0"

Is this a bug in DirectX9 Effect Compiler? "Invalid input semantics - POSITIONT0"

本文关键字:Invalid input semantics POSITIONT0 错误 DirectX9 编译器 这是      更新时间:2023-10-16

我试图编译一个非常简单的效果着色器针对DirectX9和着色器模型2。我试图直接传递顶点位置的屏幕坐标,而不是乘以世界,视图和投影矩阵,所以我在VertexShaderInput结构中使用POSITIONT语义而不是position0语义。然而,当我尝试使用

编译着色器时
fxc.exe /Od /Zi /T fx_2_0 /Fo simple.fxo simple.fx

我得到以下错误:"错误X4502:无效输入语义- POSITIONT0"

由于某种原因,它似乎自动在语义的末尾添加了一个0。这似乎是我的错误,因为POSITIONT在这里被清楚地描述为一个有效的输入语义:https://msdn.microsoft.com/en-us/library/windows/desktop/bb509647 (v = vs.85) . aspx # PS

,它是唯一一个不允许在语义的末尾附加额外整数的。

编辑:我刚刚发现,如果我把POSITIONT改为POSITIONT1,它工作得很好。这似乎与上面的文档所描述的相反。

simple.fx:

目录
struct VertexShaderInput
{
  float4 Position : POSITIONT;
  float4 Color : COLOR0;
};
struct VertexShaderOutput
{
  float4 Position : POSITION0;
  float4 Color : COLOR0;
};
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{ 
  VertexShaderOutput output;
  output.Position = input.Position;
  output.Color = input.Color;
  return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
  return input.Color;
}
technique Ambient
{
  pass Pass1
  {
    VertexShader = compile vs_2_0 VertexShaderFunction();
    PixelShader = compile ps_2_0 PixelShaderFunction();
  }
}

对于传统的Direct3D9,有一个特殊的D3DDECLUSAGE_POSITIONT,这意味着只是跳过顶点处理。因此,你只能在PIXEL SHADER输入中使用POSITIONT。它根本不能在VERTEX SHADER中使用。

将着色器改为POSITIONPOSITION0