mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 22:41:07 +01:00
* [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.
60 lines
2.0 KiB
HLSL
60 lines
2.0 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;
|
|
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_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 = { float4(1.0.xxxx), float(tmp) };
|
|
const VertexOutput_vertex vertexoutput1 = { vertexoutput.varying, vertexoutput.position };
|
|
return vertexoutput1;
|
|
}
|
|
|
|
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 = { 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;
|
|
}
|