diff options
author | Shintaro Sakahara <skhrshin@flokart.world> | 2022-02-16 15:53:24 +0300 |
---|---|---|
committer | Shintaro Sakahara <skhrshin@flokart.world> | 2022-02-16 15:53:24 +0300 |
commit | ed4ded040e693a3e37a0187de68929aef50fd988 (patch) | |
tree | dfea5c49d918fa6847974cc767d162a92f61cb4f /reference/opt | |
parent | 131278458ea8eebe6a6e9c476fbcf71278726e1a (diff) |
HLSL: Make --flatten-ubo work correctly
Diffstat (limited to 'reference/opt')
13 files changed, 478 insertions, 0 deletions
diff --git a/reference/opt/shaders-hlsl/flatten/array.flatten.vert b/reference/opt/shaders-hlsl/flatten/array.flatten.vert new file mode 100644 index 00000000..c709893c --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/array.flatten.vert @@ -0,0 +1,28 @@ +uniform float4 UBO[56]; + +static float4 gl_Position; +static float4 aVertex; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = (mul(aVertex, float4x4(UBO[40], UBO[41], UBO[42], UBO[43])) + UBO[55]) + ((UBO[50] + UBO[45]) + UBO[54].x.xxxx); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/basic.flatten.vert b/reference/opt/shaders-hlsl/flatten/basic.flatten.vert new file mode 100644 index 00000000..778acd48 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/basic.flatten.vert @@ -0,0 +1,35 @@ +uniform float4 UBO[4]; + +static float4 gl_Position; +static float4 aVertex; +static float3 vNormal; +static float3 aNormal; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; + float3 aNormal : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float3 vNormal : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, float4x4(UBO[0], UBO[1], UBO[2], UBO[3])); + vNormal = aNormal; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + aNormal = stage_input.aNormal; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vNormal = vNormal; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/copy.flatten.vert b/reference/opt/shaders-hlsl/flatten/copy.flatten.vert new file mode 100644 index 00000000..5d857ad6 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/copy.flatten.vert @@ -0,0 +1,50 @@ +struct Light +{ + float3 Position; + float Radius; + float4 Color; +}; + +uniform float4 UBO[12]; + +static float4 gl_Position; +static float4 aVertex; +static float4 vColor; +static float3 aNormal; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; + float3 aNormal : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 vColor : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, float4x4(UBO[0], UBO[1], UBO[2], UBO[3])); + vColor = 0.0f.xxxx; + for (int _96 = 0; _96 < 4; ) + { + Light _51 = {UBO[_96 * 2 + 4].xyz, UBO[_96 * 2 + 4].w, UBO[_96 * 2 + 5]}; + float3 _68 = aVertex.xyz - _51.Position; + vColor += ((UBO[_96 * 2 + 5] * clamp(1.0f - (length(_68) / _51.Radius), 0.0f, 1.0f)) * dot(aNormal, normalize(_68))); + _96++; + continue; + } +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + aNormal = stage_input.aNormal; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vColor = vColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/dynamic.flatten.vert b/reference/opt/shaders-hlsl/flatten/dynamic.flatten.vert new file mode 100644 index 00000000..98d5e1b3 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/dynamic.flatten.vert @@ -0,0 +1,49 @@ +struct Light +{ + float3 Position; + float Radius; + float4 Color; +}; + +uniform float4 UBO[12]; + +static float4 gl_Position; +static float4 aVertex; +static float4 vColor; +static float3 aNormal; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; + float3 aNormal : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 vColor : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, float4x4(UBO[0], UBO[1], UBO[2], UBO[3])); + vColor = 0.0f.xxxx; + for (int _82 = 0; _82 < 4; ) + { + float3 _54 = aVertex.xyz - UBO[_82 * 2 + 4].xyz; + vColor += ((UBO[_82 * 2 + 5] * clamp(1.0f - (length(_54) / UBO[_82 * 2 + 4].w), 0.0f, 1.0f)) * dot(aNormal, normalize(_54))); + _82++; + continue; + } +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + aNormal = stage_input.aNormal; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vColor = vColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/matrix-conversion.flatten.frag b/reference/opt/shaders-hlsl/flatten/matrix-conversion.flatten.frag new file mode 100644 index 00000000..59ec525f --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/matrix-conversion.flatten.frag @@ -0,0 +1,29 @@ +uniform float4 UBO[4]; + +static float3 FragColor; +static float3 vNormal; + +struct SPIRV_Cross_Input +{ + nointerpolation float3 vNormal : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float3 FragColor : SV_Target0; +}; + +void frag_main() +{ + float4x4 _19 = float4x4(UBO[0], UBO[1], UBO[2], UBO[3]); + FragColor = mul(vNormal, float3x3(_19[0].xyz, _19[1].xyz, _19[2].xyz)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vNormal = stage_input.vNormal; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/matrixindex.flatten.vert b/reference/opt/shaders-hlsl/flatten/matrixindex.flatten.vert new file mode 100644 index 00000000..b69a72dc --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/matrixindex.flatten.vert @@ -0,0 +1,41 @@ +uniform float4 UBO[14]; + +static float4 gl_Position; +static float4 oA; +static float4 oB; +static float4 oC; +static float4 oD; +static float4 oE; + +struct SPIRV_Cross_Output +{ + float4 oA : TEXCOORD0; + float4 oB : TEXCOORD1; + float4 oC : TEXCOORD2; + float4 oD : TEXCOORD3; + float4 oE : TEXCOORD4; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 0.0f.xxxx; + oA = UBO[1]; + oB = float4(UBO[4].y, UBO[5].y, UBO[6].y, UBO[7].y); + oC = UBO[9]; + oD = float4(UBO[10].x, UBO[11].x, UBO[12].x, UBO[13].x); + oE = float4(UBO[1].z, UBO[6].y, UBO[9].z, UBO[12].y); +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.oA = oA; + stage_output.oB = oB; + stage_output.oC = oC; + stage_output.oD = oD; + stage_output.oE = oE; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/multiindex.flatten.vert b/reference/opt/shaders-hlsl/flatten/multiindex.flatten.vert new file mode 100644 index 00000000..f21f05ec --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/multiindex.flatten.vert @@ -0,0 +1,28 @@ +uniform float4 UBO[15]; + +static float4 gl_Position; +static int2 aIndex; + +struct SPIRV_Cross_Input +{ + int2 aIndex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = UBO[aIndex.x * 5 + aIndex.y * 1 + 0]; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aIndex = stage_input.aIndex; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/push-constant.flatten.vert b/reference/opt/shaders-hlsl/flatten/push-constant.flatten.vert new file mode 100644 index 00000000..5bfb4dc0 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/push-constant.flatten.vert @@ -0,0 +1,35 @@ +uniform float4 PushMe[6]; + +static float4 gl_Position; +static float4 Pos; +static float2 vRot; +static float2 Rot; + +struct SPIRV_Cross_Input +{ + float2 Rot : TEXCOORD0; + float4 Pos : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float2 vRot : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(Pos, float4x4(PushMe[0], PushMe[1], PushMe[2], PushMe[3])); + vRot = mul(Rot, float2x2(PushMe[4].xy, PushMe[4].zw)) + PushMe[5].z.xx; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + Pos = stage_input.Pos; + Rot = stage_input.Rot; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vRot = vRot; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/rowmajor.flatten.vert b/reference/opt/shaders-hlsl/flatten/rowmajor.flatten.vert new file mode 100644 index 00000000..2560484e --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/rowmajor.flatten.vert @@ -0,0 +1,28 @@ +uniform float4 UBO[12]; + +static float4 gl_Position; +static float4 aVertex; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, float4x4(UBO[0], UBO[1], UBO[2], UBO[3])) + mul(aVertex, transpose(float4x4(UBO[4], UBO[5], UBO[6], UBO[7]))); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/struct.flatten.vert b/reference/opt/shaders-hlsl/flatten/struct.flatten.vert new file mode 100644 index 00000000..41ad8ce9 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/struct.flatten.vert @@ -0,0 +1,44 @@ +struct Light +{ + float3 Position; + float Radius; + float4 Color; +}; + +uniform float4 UBO[6]; + +static float4 gl_Position; +static float4 aVertex; +static float4 vColor; +static float3 aNormal; + +struct SPIRV_Cross_Input +{ + float4 aVertex : TEXCOORD0; + float3 aNormal : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 vColor : TEXCOORD0; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(aVertex, float4x4(UBO[0], UBO[1], UBO[2], UBO[3])); + vColor = 0.0f.xxxx; + float3 _39 = aVertex.xyz - UBO[4].xyz; + vColor += ((UBO[5] * clamp(1.0f - (length(_39) / UBO[4].w), 0.0f, 1.0f)) * dot(aNormal, normalize(_39))); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + aVertex = stage_input.aVertex; + aNormal = stage_input.aNormal; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vColor = vColor; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert b/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert new file mode 100644 index 00000000..bb702907 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert @@ -0,0 +1,43 @@ +struct Foo +{ + column_major float3x4 MVP0; + column_major float3x4 MVP1; +}; + +uniform float4 UBO[8]; + +static float4 v0; +static float4 v1; +static float3 V0; +static float3 V1; + +struct SPIRV_Cross_Input +{ + float4 v0 : TEXCOORD0; + float4 v1 : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float3 V0 : TEXCOORD0; + float3 V1 : TEXCOORD1; +}; + +void vert_main() +{ + Foo _19 = {transpose(float4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(float4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))}; + Foo _20 = _19; + V0 = mul(_20.MVP0, v0); + V1 = mul(_20.MVP1, v1); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + v0 = stage_input.v0; + v1 = stage_input.v1; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.V0 = V0; + stage_output.V1 = V1; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/swizzle.flatten.vert b/reference/opt/shaders-hlsl/flatten/swizzle.flatten.vert new file mode 100644 index 00000000..1091a17e --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/swizzle.flatten.vert @@ -0,0 +1,45 @@ +uniform float4 UBO[8]; + +static float4 gl_Position; +static float4 oA; +static float4 oB; +static float4 oC; +static float4 oD; +static float4 oE; +static float4 oF; + +struct SPIRV_Cross_Output +{ + float4 oA : TEXCOORD0; + float4 oB : TEXCOORD1; + float4 oC : TEXCOORD2; + float4 oD : TEXCOORD3; + float4 oE : TEXCOORD4; + float4 oF : TEXCOORD5; + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = 0.0f.xxxx; + oA = UBO[0]; + oB = float4(UBO[1].xy, UBO[1].zw); + oC = float4(UBO[2].x, UBO[3].xyz); + oD = float4(UBO[4].xyz, UBO[4].w); + oE = float4(UBO[5].x, UBO[5].y, UBO[5].z, UBO[5].w); + oF = float4(UBO[6].x, UBO[6].zw, UBO[7].x); +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.oA = oA; + stage_output.oB = oB; + stage_output.oC = oC; + stage_output.oD = oD; + stage_output.oE = oE; + stage_output.oF = oF; + return stage_output; +} diff --git a/reference/opt/shaders-hlsl/flatten/types.flatten.frag b/reference/opt/shaders-hlsl/flatten/types.flatten.frag new file mode 100644 index 00000000..feb0b360 --- /dev/null +++ b/reference/opt/shaders-hlsl/flatten/types.flatten.frag @@ -0,0 +1,23 @@ +uniform int4 UBO1[2]; +uniform uint4 UBO2[2]; +uniform float4 UBO0[2]; + +static float4 FragColor; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = ((((float4(UBO1[0]) + float4(UBO1[1])) + float4(UBO2[0])) + float4(UBO2[1])) + UBO0[0]) + UBO0[1]; +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} |