Files
wgpu/tests/out/hlsl/interface.hlsl
T
Jim Blandy d44e2ad207 Simplify interpolation defaulting.
Replace `Module::apply_common_default_interpolation` with a simpler function
that handles a single `Binding` at a time. In exchange for the simplicity, the
function must be called at each point function arguments, function results, and
struct members are prepared. (Any missed spots will be caught by the verifier.)

This approach no longer requires mutating types in the arena, a prerequisite for
properly handling type identity.

Applying defaults to struct members when the struct declaration is parsed does
have a disadvantage, compared to the old whole-module pass: at struct parse
time, we don't yet know which pipeline stages the struct will be used in. The
best we can do is apply defaults to anything with a `Location` binding. This
causes needless qualifiers to appear in some output. However, it seems that our
back end languages all tolerate such qualifiers.
2021-09-27 15:17:41 -04:00

75 lines
2.4 KiB
HLSL

struct NagaConstants {
int base_vertex;
int base_instance;
uint other;
};
ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1);
struct VertexOutput {
float4 position : SV_Position;
linear float varying : LOC1;
};
struct FragmentOutput {
float depth : SV_Depth;
uint sample_mask : SV_Coverage;
linear float color : SV_Target0;
};
groupshared uint output[1];
struct VertexOutput_vertex {
float varying : LOC1;
float4 position : SV_Position;
};
struct FragmentInput_fragment {
float varying : LOC1;
float4 position : SV_Position;
bool front_facing1 : SV_IsFrontFace;
uint sample_index1 : SV_SampleIndex;
uint sample_mask1 : SV_Coverage;
};
VertexOutput ConstructVertexOutput(float4 arg0, float arg1) {
VertexOutput ret;
ret.position = arg0;
ret.varying = arg1;
return ret;
}
VertexOutput_vertex vertex(uint vertex_index : SV_VertexID, uint instance_index : SV_InstanceID, uint color : LOC10)
{
uint tmp = (((_NagaConstants.base_vertex + vertex_index) + (_NagaConstants.base_instance + instance_index)) + color);
const VertexOutput vertexoutput = ConstructVertexOutput(float4(1.0.xxxx), float(tmp));
const VertexOutput_vertex vertexoutput1 = { vertexoutput.varying, vertexoutput.position };
return vertexoutput1;
}
FragmentOutput ConstructFragmentOutput(float arg0, uint arg1, float arg2) {
FragmentOutput ret;
ret.depth = arg0;
ret.sample_mask = arg1;
ret.color = arg2;
return ret;
}
FragmentOutput fragment(FragmentInput_fragment fragmentinput_fragment)
{
VertexOutput in1 = { fragmentinput_fragment.position, fragmentinput_fragment.varying };
bool front_facing = fragmentinput_fragment.front_facing1;
uint sample_index = fragmentinput_fragment.sample_index1;
uint sample_mask = fragmentinput_fragment.sample_mask1;
uint mask = (sample_mask & (1u << sample_index));
float color1 = (front_facing ? 1.0 : 0.0);
const FragmentOutput fragmentoutput = ConstructFragmentOutput(in1.varying, mask, color1);
return fragmentoutput;
}
[numthreads(1, 1, 1)]
void compute(uint3 global_id : SV_DispatchThreadID, uint3 local_id : SV_GroupThreadID, uint local_index : SV_GroupIndex, uint3 wg_id : SV_GroupID, uint3 num_wgs : SV_GroupID)
{
output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + uint3(_NagaConstants.base_vertex, _NagaConstants.base_instance, _NagaConstants.other).x);
return;
}