2017-10-12 12 views
0

Hier ist ein einfacher Hull-Shader-Code, den ich gemacht habe, um zu versuchen, Tessellation zu verstehen. Ich kann einfach nichts falsch mit diesem Code finden, aber die Kompilierfunktion gibt immer false zurück. Hier ist mein Code:Kann nicht kompilieren HLSL Hull Shader-Code

Meine Eingangs- und Ausgangsstrukturen:

[domain("tri")] // indicates a triangle patch (3 verts) 
[partitioning("fractional_odd")] // fractional avoids popping 
// vertex ordering for the output triangles 
[outputtopology("triangle_cw")] 
[outputcontrolpoints(3)] 
// name of the patch constant hull shader 
[patchconstantfunc("ConstantsHS")] 
//[maxtessfactor(7.0)] 


cbuffer TessellationBuffer 
{ 
    float tessellationAmount; 
    float3 padding; 
}; 

struct VS_CONTROL_POINT_OUTPUT 
{ 
    float3 vWorldPos : POSITION; 
    float2 vTexCoord : TEXCOORD0; 
    float3 vNormal : NORMAL0; 
}; 

struct HS_CONTROL_POINT_OUTPUT 
{ 
    float3 vWorldPos : POSITION; 
    float2 vTexCoord : TEXCOORD0; 
    float3 vNormal : NORMAL0; 
}; 

struct HS_CONSTANT_DATA_OUTPUT 
{ 
    float Edges[3] : SV_TessFactor; 
    float Inside : SV_InsideTessFactor; 
}; 

Meine Funktionen:

HS_CONTROL_POINT_OUTPUT HS(InputPatch<VS_CONTROL_POINT_OUTPUT, 3> inputPatch, uint uCPID : SV_OutputControlPointID, uint patchId : SV_PrimitiveID) 
{ 
    HS_CONTROL_POINT_OUTPUT Output; 
    Output.vWorldPos = inputPatch[uCPID].vWorldPos; 
    Output.vTexCoord = inputPatch[uCPID].vTexCoord; 
    Output.vNormal = inputPatch[uCPID].vNormal; 

    return Output; 
}; 

HS_CONSTANT_DATA_OUTPUT ConstantsHS(InputPatch<VS_CONTROL_POINT_OUTPUT, 3> inputPatch, uint PatchID : SV_PrimitiveID ) 
{ 
    HS_CONSTANT_DATA_OUTPUT Output; 

    Output.Edges[0] = tessellationAmount; 
    Output.Edges[1] = tessellationAmount; 
    Output.Edges[2] = tessellationAmount; 
    Output.Inside = tessellationAmount; 
    return Output; 
}; 

Vielen Dank für jede Hilfe.

Antwort

1

Die Attribute haben wie unten auf den Einstiegspunkt gesetzt werden, dann ist dein Rumpf Shader gültig ist:

[domain("tri")] // indicates a triangle patch (3 verts) 
[partitioning("fractional_odd")] // fractional avoids popping 
// vertex ordering for the output triangles 
[outputtopology("triangle_cw")] 
[outputcontrolpoints(3)] 
// name of the patch constant hull shader 
[patchconstantfunc("ConstantsHS")] 
//[maxtessfactor(7.0)] 
HS_CONTROL_POINT_OUTPUT HS(InputPatch<VS_CONTROL_POINT_OUTPUT, 3> inputPatch, uint uCPID : SV_OutputControlPointID, uint patchId : SV_PrimitiveID) 

Auf einer Seite zur Kenntnis, das Kommandozeilen-Tool FXC.exe würde eine Fehlermeldung hat Druck, der hätte setzen Sie in die richtige Richtung: error X3000: syntax error: unexpected token 'cbuffer'

und ich bin nicht sicher, welche Funktion Sie sich beziehen, D3DCompile zurückkehren ein HRESULT, kein boolean, und es ist auch Ausgangs einen Klecks für Sie mit den Fehlermeldungen im Fehlerfall.

+0

Es funktioniert, danke! Ich kannte diesen Befehl nicht. Meine Funktion ist nur ein Aufruf von D3DCompile und druckt den Fehlerpuffer nicht. – mondlicht