HLSL: handle multiple clip/cull semantic IDs
HLSL allows several variables to be declared. There are packing rules involved:
e.g, a float3 and a float1 can be packed into a single array[4], while for a
float3 and another float3, the second one will skip the third array entry to
avoid straddling
This is implements that ability. Because there can be multiple variables involved,
and the final output array will often be a different type altogether (to fuse
the values into a single destination), a new variable is synthesized, unlike the prior
clip/cull support which used the declared variable. The new variable name is
taken from one of the declared ones, so the old tests are unchanged.
Several new tests are added to test various packing scenarios.
Only two semantic IDs are supported: 0, and 1, per HLSL rules. This is
encapsulated in
static const int maxClipCullRegs = 2;
and the algorithm (probably :) ) generalizes to larger values, although there
are a few issues around how HLSL would pack (e.g, would 4 scalars be packed into
a single HLSL float4 out reg? Probably, and this algorithm assumes so).
This commit is contained in:
parent
cd52fd5a42
commit
307b6507b3
17 changed files with 2257 additions and 430 deletions
19
Test/hlsl.clipdistance-9.vert
Normal file
19
Test/hlsl.clipdistance-9.vert
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
struct VS_OUTPUT {
|
||||
float4 Position : SV_Position;
|
||||
};
|
||||
|
||||
// Test packing 0 and 1 semantics into single array[4] output, from out fn params.
|
||||
VS_OUTPUT main(out float3 clip0 : SV_ClipDistance0, out float clip1 : SV_ClipDistance1)
|
||||
{
|
||||
VS_OUTPUT Output;
|
||||
Output.Position = 0;
|
||||
|
||||
clip0.x = 0;
|
||||
clip0.y = 1;
|
||||
clip0.z = 2;
|
||||
|
||||
// Position 3 is packed from clip1's float
|
||||
clip1 = 3;
|
||||
|
||||
return Output;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue