Skip to content

Commit

Permalink
Merge pull request KhronosGroup#1698 from KhronosGroup/fix-1691
Browse files Browse the repository at this point in the history
HLSL: Rewrite how block IO is emitted.
  • Loading branch information
HansKristian-Work authored Jun 29, 2021
2 parents 9338996 + d6b29ab commit 853e84e
Show file tree
Hide file tree
Showing 12 changed files with 273 additions and 235 deletions.
18 changes: 12 additions & 6 deletions reference/opt/shaders-hlsl/frag/io-block.frag
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
static float4 FragColor;

struct VertexOut
{
float4 a : TEXCOORD1;
float4 b : TEXCOORD2;
float4 a;
float4 b;
};

static float4 FragColor;
static VertexOut _12;

struct SPIRV_Cross_Input
{
float4 VertexOut_a : TEXCOORD1;
float4 VertexOut_b : TEXCOORD2;
};

struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
Expand All @@ -18,9 +23,10 @@ void frag_main()
FragColor = _12.a + _12.b;
}

SPIRV_Cross_Output main(in VertexOut stage_input_12)
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
_12 = stage_input_12;
_12.a = stage_input.VertexOut_a;
_12.b = stage_input.VertexOut_b;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
Expand Down
20 changes: 11 additions & 9 deletions reference/opt/shaders-hlsl/vert/locations.vert
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ struct Foo
float3 c;
};

struct VertexOut
{
float3 color;
float3 foo;
};

static const Foo _71 = { 1.0f.xxx, 1.0f.xxx, 1.0f.xxx };

static float4 gl_Position;
Expand All @@ -16,13 +22,6 @@ static float vLocation1;
static float vLocation2[2];
static Foo vLocation4;
static float vLocation9;

struct VertexOut
{
float3 color : TEXCOORD7;
float3 foo : TEXCOORD8;
};

static VertexOut vout;

struct SPIRV_Cross_Input
Expand All @@ -38,6 +37,8 @@ struct SPIRV_Cross_Output
float vLocation1 : TEXCOORD1;
float vLocation2[2] : TEXCOORD2;
Foo vLocation4 : TEXCOORD4;
float3 VertexOut_color : TEXCOORD7;
float3 VertexOut_foo : TEXCOORD8;
float vLocation9 : TEXCOORD9;
float4 gl_Position : SV_Position;
};
Expand All @@ -55,19 +56,20 @@ void vert_main()
vout.foo = 4.0f.xxx;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input, out VertexOut stage_outputvout)
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
Input2 = stage_input.Input2;
Input4 = stage_input.Input4;
Input0 = stage_input.Input0;
vert_main();
stage_outputvout = vout;
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.vLocation0 = vLocation0;
stage_output.vLocation1 = vLocation1;
stage_output.vLocation2 = vLocation2;
stage_output.vLocation4 = vLocation4;
stage_output.vLocation9 = vLocation9;
stage_output.VertexOut_color = vout.color;
stage_output.VertexOut_foo = vout.foo;
return stage_output;
}
28 changes: 17 additions & 11 deletions reference/opt/shaders-hlsl/vert/qualifiers.vert
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
struct Block
{
float vFlat;
float vCentroid;
float vSample;
float vNoperspective;
};

static float4 gl_Position;
static float vFlat;
static float vCentroid;
static float vSample;
static float vNoperspective;

struct Block
{
nointerpolation float vFlat : TEXCOORD4;
centroid float vCentroid : TEXCOORD5;
sample float vSample : TEXCOORD6;
noperspective float vNoperspective : TEXCOORD7;
};

static Block vout;

struct SPIRV_Cross_Output
Expand All @@ -20,6 +19,10 @@ struct SPIRV_Cross_Output
centroid float vCentroid : TEXCOORD1;
sample float vSample : TEXCOORD2;
noperspective float vNoperspective : TEXCOORD3;
nointerpolation float Block_vFlat : TEXCOORD4;
centroid float Block_vCentroid : TEXCOORD5;
sample float Block_vSample : TEXCOORD6;
noperspective float Block_vNoperspective : TEXCOORD7;
float4 gl_Position : SV_Position;
};

Expand All @@ -36,15 +39,18 @@ void vert_main()
vout.vNoperspective = 3.0f;
}

SPIRV_Cross_Output main(out Block stage_outputvout)
SPIRV_Cross_Output main()
{
vert_main();
stage_outputvout = vout;
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.vFlat = vFlat;
stage_output.vCentroid = vCentroid;
stage_output.vSample = vSample;
stage_output.vNoperspective = vNoperspective;
stage_output.Block_vFlat = vout.vFlat;
stage_output.Block_vCentroid = vout.vCentroid;
stage_output.Block_vSample = vout.vSample;
stage_output.Block_vNoperspective = vout.vNoperspective;
return stage_output;
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
struct Vert
{
float a;
float b;
};

struct Foo
{
float c;
float d;
};

static const Vert _11 = { 0.0f, 0.0f };
static const Foo _13 = { 0.0f, 0.0f };

static Foo foo = _13;

struct Vert
{
float a : TEXCOORD0;
float b : TEXCOORD1;
};

static Vert _3 = { 0.0f, 0.0f };
static Foo foo = _13;

struct SPIRV_Cross_Output
{
float Vert_a : TEXCOORD0;
float Vert_b : TEXCOORD1;
Foo foo : TEXCOORD2;
};

void vert_main()
{
}

SPIRV_Cross_Output main(out Vert stage_output_3)
SPIRV_Cross_Output main()
{
vert_main();
stage_output_3 = _3;
SPIRV_Cross_Output stage_output;
stage_output.Vert_a = _3.a;
stage_output.Vert_b = _3.b;
stage_output.foo = foo;
return stage_output;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ struct Struct_vec4
float4 m0;
};

struct VertexOut
{
Struct_vec4 m0;
Struct_vec4 m1;
};

cbuffer UBO : register(b0)
{
Struct_vec4 ubo_binding_0_m0 : packoffset(c0);
Expand All @@ -11,19 +17,14 @@ cbuffer UBO : register(b0)


static float4 gl_Position;
static VertexOut output_location_0;
static Struct_vec4 output_location_2;
static Struct_vec4 output_location_3;

struct VertexOut
{
Struct_vec4 m0 : TEXCOORD0;
Struct_vec4 m1 : TEXCOORD1;
};

static VertexOut output_location_0;

struct SPIRV_Cross_Output
{
Struct_vec4 VertexOut_m0 : TEXCOORD0;
Struct_vec4 VertexOut_m1 : TEXCOORD1;
Struct_vec4 output_location_2 : TEXCOORD2;
Struct_vec4 output_location_3 : TEXCOORD3;
float4 gl_Position : SV_Position;
Expand All @@ -42,12 +43,13 @@ void vert_main()
output_location_3 = b;
}

SPIRV_Cross_Output main(out VertexOut stage_outputoutput_location_0)
SPIRV_Cross_Output main()
{
vert_main();
stage_outputoutput_location_0 = output_location_0;
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.VertexOut_m0 = output_location_0.m0;
stage_output.VertexOut_m1 = output_location_0.m1;
stage_output.output_location_2 = output_location_2;
stage_output.output_location_3 = output_location_3;
return stage_output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ struct Bar

struct V
{
float a : TEXCOORD0;
float b[2] : TEXCOORD1;
Bar c[2] : TEXCOORD3;
Bar d : TEXCOORD9;
float a;
float b[2];
Bar c[2];
Bar d;
};

static V _14;

struct SPIRV_Cross_Output
{
float V_a : TEXCOORD0;
float V_b[2] : TEXCOORD1;
Bar V_c[2] : TEXCOORD3;
Bar V_d : TEXCOORD9;
};

void vert_main()
{
_14.a = 1.0f;
Expand All @@ -30,8 +38,13 @@ void vert_main()
_14.d.w = 12.0f;
}

void main(out V stage_output_14)
SPIRV_Cross_Output main()
{
vert_main();
stage_output_14 = _14;
SPIRV_Cross_Output stage_output;
stage_output.V_a = _14.a;
stage_output.V_b = _14.b;
stage_output.V_c = _14.c;
stage_output.V_d = _14.d;
return stage_output;
}
18 changes: 12 additions & 6 deletions reference/shaders-hlsl/frag/io-block.frag
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
static float4 FragColor;

struct VertexOut
{
float4 a : TEXCOORD1;
float4 b : TEXCOORD2;
float4 a;
float4 b;
};

static float4 FragColor;
static VertexOut _12;

struct SPIRV_Cross_Input
{
float4 VertexOut_a : TEXCOORD1;
float4 VertexOut_b : TEXCOORD2;
};

struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
Expand All @@ -18,9 +23,10 @@ void frag_main()
FragColor = _12.a + _12.b;
}

SPIRV_Cross_Output main(in VertexOut stage_input_12)
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
_12 = stage_input_12;
_12.a = stage_input.VertexOut_a;
_12.b = stage_input.VertexOut_b;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
Expand Down
20 changes: 11 additions & 9 deletions reference/shaders-hlsl/vert/locations.vert
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ struct Foo
float3 c;
};

struct VertexOut
{
float3 color;
float3 foo;
};

static float4 gl_Position;
static float4 Input2;
static float4 Input4;
Expand All @@ -14,13 +20,6 @@ static float vLocation1;
static float vLocation2[2];
static Foo vLocation4;
static float vLocation9;

struct VertexOut
{
float3 color : TEXCOORD7;
float3 foo : TEXCOORD8;
};

static VertexOut vout;

struct SPIRV_Cross_Input
Expand All @@ -36,6 +35,8 @@ struct SPIRV_Cross_Output
float vLocation1 : TEXCOORD1;
float vLocation2[2] : TEXCOORD2;
Foo vLocation4 : TEXCOORD4;
float3 VertexOut_color : TEXCOORD7;
float3 VertexOut_foo : TEXCOORD8;
float vLocation9 : TEXCOORD9;
float4 gl_Position : SV_Position;
};
Expand All @@ -57,19 +58,20 @@ void vert_main()
vout.foo = 4.0f.xxx;
}

SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input, out VertexOut stage_outputvout)
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
Input2 = stage_input.Input2;
Input4 = stage_input.Input4;
Input0 = stage_input.Input0;
vert_main();
stage_outputvout = vout;
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.vLocation0 = vLocation0;
stage_output.vLocation1 = vLocation1;
stage_output.vLocation2 = vLocation2;
stage_output.vLocation4 = vLocation4;
stage_output.vLocation9 = vLocation9;
stage_output.VertexOut_color = vout.color;
stage_output.VertexOut_foo = vout.foo;
return stage_output;
}
Loading

0 comments on commit 853e84e

Please sign in to comment.