Skip to content
Snippets Groups Projects
  • LoopDawg's avatar
    HLSL: handle clip and cull distance input builtin type conversion · e2cda3c2
    LoopDawg authored
    HLSL allows a range of types for clip and cull distances.  There are
    three dimensions, including arrayness, vectorness, and semantic ID.
    SPIR-V requires clip and cull distance be a single array of floats in
    all cases.
    
    This code provides input side conversion between the SPIR-V form and
    the HLSL form.  (Output conversion was added in PR #947 and #997).
    
    This PR extends HlslParseContext::assignClipCullDistance to cope with
    the input side conversion.  Not as much changed as appears: there was
    also a lot of renaming to reflect the fact that the code now handles
    either direction.
    
    Currently, non-{frag,vert} stages are not handled, and are explicitly
    rejected.
    
    Fixes #1026.
    e2cda3c2
hlsl.clipdistance-6.frag 330 B
struct VS_OUTPUT        {
    float4 Position             : SV_Position;
    float4 clip0                : SV_ClipDistance0;  // multiple semantic IDs, two vec4s (no extra packing)
    float4 clip1                : SV_ClipDistance1;  // ...
};

float4 main(VS_OUTPUT v) : SV_Target0
{
    return v.Position + v.clip0 + v.clip1;
}