3

I am doing some hardware tessellation and managed to get the basic subdivision effect, so tried to move on to Phong tessellation (which is for rounding edges). Now when I want to add extra outputs in the Patch Constant Function and write them, but one of those throws an error.

struct ConstantOutputType
{
    float edges[3] : SV_TessFactor;
    float inside : SV_InsideTessFactor;

    float3 f3B0 : POSITION0;
    float3 f3B1 : POSITION1;
    float3 f3B2 : POSITION2;

    float3 f3N0 : NORMAL0;
    float3 f3N1 : NORMAL1;
    float3 f3N2 : NORMAL2;
};

ConstantOutputType PatchConstantFunction(InputPatch<HullInputType, 3> inputPatch, uint patchId : SV_PrimitiveID)
{    
    ConstantOutputType output = (ConstantOutputType)0;


    // Set the tessellation factors for the three edges of the triangle.
    output.edges[0] = inputPatch[0].dep;
    output.edges[1] = inputPatch[1].dep;
    output.edges[2] = inputPatch[2].dep;

    // Set the tessellation factor for tessallating inside the triangle.
    output.inside = (inputPatch[0].dep + inputPatch[1].dep + inputPatch[2].dep)/3.0f;


    output.f3B0 = inputPatch[0].pos.xyz;
    output.f3B1 = inputPatch[1].pos.xyz;
    output.f3B2 = inputPatch[2].pos.xyz;

    //output.f3N0 = inputPatch[0].nor.xyz;  <=====This throws the error (setting the normal)
    output.f3N1 = inputPatch[1].nor.xyz;
    output.f3N2 = inputPatch[2].nor.xyz;

    return output;
} 

The error thrown is: error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Components of input declaration for register 1 overlap with previous declaration for same register. Opcode #47 (count is 1-based). error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Can't continue validation - aborting. Which I can't seem to figure out what it means (given that it is my very first attempt at hull shader).

If I comment that out, it works, if I set an arbitary value for that, it also works (for example: output.f3N0 = float3(0,1,0) ). I also tried changing the semantics for the variables, but did not help. I would be very glad if someone could give me some insight on this.

UPDATE: Hull input follows, as requested:

struct HullInputType
{
    float3 pos              : POSITION;
    float2 tex              : TEXCOORD0;
    float3 nor              : TEXCOORD1;
    float  dep              : TEXCOORD2;
};
4

1 回答 1

3

好的,看来船体着色器输入结构中的 (float dep : TEXCOORD2;) 是问题所在。可能是因为着色器单元处理 float4 寄存器,所以两个 float3 变量无法连接,但 float2 和 float 连接到了一个 float4 寄存器。两个float2是一样的,但是float2和float3不能连接,不会重叠。所以我想我会用 float3 变量中的 (float2 tex) 发送深度 (float dep) 信息。

这很有趣,尽管它适用于某人。而且在我的域到像素着色器中,它不会以这种方式重叠寄存器。

更新:它不起作用,错误消失了,我可以编译着色器,但是如果我尝试通过从输入结构分配给它来使用该变量,那么整个图形渲染就会停止工作(即使是未细分的调用)。这发生在硬件设备上,在 WARP 上它以某种方式工作。

UPDATE2:现在我修复了它,只发送float4s,但我一点也不喜欢。很奇怪,我不必在我的顶点和像素着色器中这样做,也许这是一个小故障?或者可能是 GPU 硬件不兼容(Nvidia GT525M)。

于 2013-08-19T21:29:53.023 回答