summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/emit.cpp58
-rw-r--r--tests/cross-compile/glsl-generic-in.slang28
-rw-r--r--tests/cross-compile/glsl-generic-in.slang.glsl61
3 files changed, 117 insertions, 30 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 914aea7fd..c3e1b2d08 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -6640,36 +6640,6 @@ String emitEntryPoint(
// un-specialized IR.
dumpIRIfEnabled(compileRequest, irModule);
-
-
- // For GLSL only, we will need to perform "legalization" of
- // the entry point and any entry-point parameters.
- //
- // TODO: We should consider moving this legalization work
- // as late as possible, so that it doesn't affect how other
- // optimization passes need to work.
- //
- switch (target)
- {
- case CodeGenTarget::GLSL:
- {
- legalizeEntryPointForGLSL(
- session,
- irModule,
- irEntryPoint,
- &compileRequest->mSink,
- &sharedContext.extensionUsageTracker);
- }
- break;
-
- default:
- break;
- }
-#if 0
- dumpIRIfEnabled(compileRequest, irModule, "GLSL LEGALIZED");
-#endif
- validateIRModuleIfEnabled(compileRequest, irModule);
-
// Desguar any union types, since these will be illegal on
// various targets.
//
@@ -6765,6 +6735,34 @@ String emitEntryPoint(
#endif
validateIRModuleIfEnabled(compileRequest, irModule);
+ // For GLSL only, we will need to perform "legalization" of
+ // the entry point and any entry-point parameters.
+ //
+ // TODO: We should consider moving this legalization work
+ // as late as possible, so that it doesn't affect how other
+ // optimization passes need to work.
+ //
+ switch (target)
+ {
+ case CodeGenTarget::GLSL:
+ {
+ legalizeEntryPointForGLSL(
+ session,
+ irModule,
+ irEntryPoint,
+ &compileRequest->mSink,
+ &sharedContext.extensionUsageTracker);
+ }
+ break;
+
+ default:
+ break;
+ }
+#if 0
+ dumpIRIfEnabled(compileRequest, irModule, "GLSL LEGALIZED");
+#endif
+ validateIRModuleIfEnabled(compileRequest, irModule);
+
// The resource-based specialization pass above
// may create specialized versions of functions, but
// it does not try to completely eliminate the original
diff --git a/tests/cross-compile/glsl-generic-in.slang b/tests/cross-compile/glsl-generic-in.slang
new file mode 100644
index 000000000..e9b9a5a91
--- /dev/null
+++ b/tests/cross-compile/glsl-generic-in.slang
@@ -0,0 +1,28 @@
+//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -profile vs_5_0
+interface IField
+{
+ float get();
+};
+struct GIn<TField>
+{
+ float3 p0;
+ TField field;
+};
+struct F : IField
+{
+ float4 v0;
+ float2 v1;
+ float get() { return v0.x + v1.x; }
+};
+
+struct VOut
+{
+ float4 projPos : SV_POSITION;
+};
+
+VOut main(GIn<F> vIn)
+{
+ VOut vout;
+ vout.projPos = float4(vIn.p0, vIn.field.get());
+ return vout;
+} \ No newline at end of file
diff --git a/tests/cross-compile/glsl-generic-in.slang.glsl b/tests/cross-compile/glsl-generic-in.slang.glsl
new file mode 100644
index 000000000..66d7546ff
--- /dev/null
+++ b/tests/cross-compile/glsl-generic-in.slang.glsl
@@ -0,0 +1,61 @@
+//TEST_IGNORE_FILE
+#version 450
+layout(row_major) uniform;
+layout(row_major) buffer;
+
+#line 11 0
+struct F_0
+{
+ vec4 v0_0;
+ vec2 v1_0;
+};
+
+
+#line 15
+float F_get_0(F_0 this_0)
+{
+
+#line 15
+ return this_0.v0_0.x + this_0.v1_0.x;
+}
+
+
+#line 6
+layout(location = 0)
+in vec3 _S1;
+
+layout(location = 1)
+in vec4 _S2;
+
+layout(location = 2)
+in vec2 _S3;
+
+struct GIn_0
+{
+ vec3 p0_0;
+ F_0 field_0;
+};
+
+struct VOut_0
+{
+ vec4 projPos_0;
+};
+
+
+#line 23
+void main()
+{
+ GIn_0 _S4 = GIn_0(_S1, F_0(_S2, _S3));
+
+#line 25
+ VOut_0 vout_0;
+ vec3 _S5 = _S4.p0_0;
+
+#line 26
+ float _S6 = F_get_0(_S4.field_0);
+
+#line 26
+ vout_0.projPos_0 = vec4(_S5, _S6);
+ gl_Position = vout_0.projPos_0;
+ return;
+} \ No newline at end of file