Files
wgpu/tests/out/hlsl/interpolate.hlsl
T
Dzmitry Malyshau 81f4ff032f HLSL: rewrite handling of interface matching rules (#1276)
* [hlsl-out] flatten the entry point inputs

Previously, the logic was re-ordering the inputs according to the binding.
This breaks if one of the inputs is a struct. With this change, the struct
fields are also flattened into the fake entry point struct. We also
construct the original arguments at the beginning of the function.

* hlsl-out: completely separate the flattened IO structs from the original IR structs

Previously, we had heuristics to detect if a particular struct needs the fields
to be re-ordered. We'd re-order interface structs without layout, and the detection
was very fragile and easily wrong.
The new logic is spawning separate struct types if we need any re-ordering to happen.
It's solid, there are no heuristics.
2021-08-22 22:40:31 -04:00

58 lines
2.1 KiB
HLSL

struct FragmentInput {
float4 position : SV_Position;
nointerpolation uint flat : LOC0;
noperspective float linear1 : LOC1;
noperspective centroid float2 linear_centroid : LOC2;
noperspective sample float3 linear_sample : LOC3;
linear float4 perspective : LOC4;
linear centroid float perspective_centroid : LOC5;
linear sample float perspective_sample : LOC6;
};
struct VertexOutput_main {
uint flat : LOC0;
float linear1 : LOC1;
float2 linear_centroid : LOC2;
float3 linear_sample : LOC3;
float4 perspective : LOC4;
float perspective_centroid : LOC5;
float perspective_sample : LOC6;
float4 position : SV_Position;
};
struct FragmentInput_main {
uint flat : LOC0;
float linear2 : LOC1;
float2 linear_centroid : LOC2;
float3 linear_sample : LOC3;
float4 perspective : LOC4;
float perspective_centroid : LOC5;
float perspective_sample : LOC6;
float4 position : SV_Position;
};
VertexOutput_main main()
{
FragmentInput out1 = (FragmentInput)0;
out1.position = float4(2.0, 4.0, 5.0, 6.0);
out1.flat = 8u;
out1.linear1 = 27.0;
out1.linear_centroid = float2(64.0, 125.0);
out1.linear_sample = float3(216.0, 343.0, 512.0);
out1.perspective = float4(729.0, 1000.0, 1331.0, 1728.0);
out1.perspective_centroid = 2197.0;
out1.perspective_sample = 2744.0;
FragmentInput _expr30 = out1;
const FragmentInput fragmentinput = _expr30;
const VertexOutput_main fragmentinput1 = { fragmentinput.flat, fragmentinput.linear1, fragmentinput.linear_centroid, fragmentinput.linear_sample, fragmentinput.perspective, fragmentinput.perspective_centroid, fragmentinput.perspective_sample, fragmentinput.position };
return fragmentinput1;
}
void main1(FragmentInput_main fragmentinput_main)
{
FragmentInput val = { fragmentinput_main.position, fragmentinput_main.flat, fragmentinput_main.linear2, fragmentinput_main.linear_centroid, fragmentinput_main.linear_sample, fragmentinput_main.perspective, fragmentinput_main.perspective_centroid, fragmentinput_main.perspective_sample };
return;
}