Skip to content
Snippets Groups Projects
  • LoopDawg's avatar
    HLSL: add geometry stage support for clip/cull distance · 5e5b12e9
    LoopDawg authored
    Changes:
    
    (1) Allow clip/cull builtins as both input and output in the same shader stage.  Previously,
    not enough data was tracked to handle this.
    
    (2) Handle the extra array dimension in GS inputs.  The synthesized external variable can
    now be created with the extra array dimension if needed, and the form conversion code is
    able to handle it as well.
    
    For example, both of these GS inputs would result in the same synthesized external type:
    
        triangle in float4 clip[3] : SV_ClipDistance
    
        triangle in float2 clip[3][2] : SV_ClipDistance
    
    In the second case, the inner array dimension packs with the 2-vector of floats into an array[4],
    which there is an array[3] of due to the triangle geometry.
    5e5b12e9
hlsl.clipdistance-4.geom 616 B
struct S {
    float4 pos     : SV_Position;
    float2 clip0   : SV_ClipDistance0;  // clip0 and clip1 form an array of float[4] externally.
    float2 clip1   : SV_ClipDistance1;
};

[maxvertexcount(3)]
void main(triangle in float4 pos[3] : SV_Position, 
          triangle in uint VertexID[3] : VertexID,
          inout LineStream<S> OutputStream,
          triangle in float2 clip0[3] : SV_ClipDistance0,  // test input arrayed semantic vars
          triangle in float2 clip1[3] : SV_ClipDistance1)
{
    S s;

    s.pos = pos[0];
    s.clip0 = clip0[0];
    s.clip1 = clip1[0];

    OutputStream.Append(s);
}