سؤال

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;
};
هل كانت مفيدة؟

المحلول

Okay, It seems that the (float dep : TEXCOORD2;) in the hull shader input struct was the problem. Probably because the shader unit deals with float4 registers, the two float3 variables could not have been joined, but the float2 and the float was joined to a float4 register. It is the same with two float2's, but a float2 and a float3 can not be joined, and will not overlap. So I guess I'll be sending the depth (float dep) information with the (float2 tex) in a float3 variable.

It is interesting, though that it works for someone. And that in my domain-to pixel shader does not overlap registers in such a way.

UPDATE: It does not work, the error went away, I can compile the shader, but if I try to use that variable by assigning to it from the input struct then the whole graphics rendering just stops to work (even the untessellated calls). This happens on a HARDWARE device, on WARP it works somehow.

UPDATE2: Now I fixed it, by sending just float4s, but I do not like that one bit. It is very strange that I do not have to do that in my vertex and pixel shaders, maybe it is a glitch? Or could be a GPU hardware uncompatibility (Nvidia GT525M).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top