diff options
| -rw-r--r-- | source/slang/emit.cpp | 5 | ||||
| -rw-r--r-- | source/slang/ir-glsl-legalize.cpp | 18 | ||||
| -rw-r--r-- | tests/cross-compile/glsl-generic-in.slang | 11 | ||||
| -rw-r--r-- | tests/cross-compile/glsl-generic-in.slang.glsl | 26 |
4 files changed, 42 insertions, 18 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index c3e1b2d08..536c72e11 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3572,6 +3572,9 @@ struct EmitVisitor UInt argCount = inst->getOperandCount(); for( UInt aa = 1; aa < argCount; ++aa ) { + auto operand = inst->getOperand(aa); + if (as<IRVoidType>(operand->getDataType())) + continue; if(aa != 1) emit(", "); emitIROperand(ctx, inst->getOperand(aa), mode, kEOp_General); } @@ -6087,6 +6090,8 @@ struct EmitVisitor { varType = outType->getValueType(); } + if (as<IRVoidType>(varType)) + return; // When a global shader parameter represents a "parameter group" // (either a constant buffer or a parameter block with non-resource diff --git a/source/slang/ir-glsl-legalize.cpp b/source/slang/ir-glsl-legalize.cpp index 9c4210be0..d2b696c5b 100644 --- a/source/slang/ir-glsl-legalize.cpp +++ b/source/slang/ir-glsl-legalize.cpp @@ -567,7 +567,11 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( UInt bindingIndex, GlobalVaryingDeclarator* declarator) { - if( as<IRBasicType>(type) ) + if (as<IRVoidType>(type)) + { + return ScalarizedVal(); + } + else if( as<IRBasicType>(type) ) { return createSimpleGLSLGlobalVarying( context, @@ -675,12 +679,14 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( stage, fieldBindingIndex, declarator); + if (fieldVal.flavor != ScalarizedVal::Flavor::none) + { + ScalarizedTupleValImpl::Element element; + element.val = fieldVal; + element.key = field->getKey(); - ScalarizedTupleValImpl::Element element; - element.val = fieldVal; - element.key = field->getKey(); - - tupleValImpl->elements.Add(element); + tupleValImpl->elements.Add(element); + } } return ScalarizedVal::tuple(tupleValImpl); diff --git a/tests/cross-compile/glsl-generic-in.slang b/tests/cross-compile/glsl-generic-in.slang index e9b9a5a91..90fe387ba 100644 --- a/tests/cross-compile/glsl-generic-in.slang +++ b/tests/cross-compile/glsl-generic-in.slang @@ -3,10 +3,11 @@ interface IField { float get(); }; -struct GIn<TField> +struct GIn<TField : IField, TEmptyField> { float3 p0; TField field; + TEmptyField e; }; struct F : IField { @@ -14,15 +15,19 @@ struct F : IField float2 v1; float get() { return v0.x + v1.x; } }; +struct E +{ + float get() {return 1.0;} +}; struct VOut { float4 projPos : SV_POSITION; }; -VOut main(GIn<F> vIn) +VOut main(GIn<F, E> vIn) { VOut vout; - vout.projPos = float4(vIn.p0, vIn.field.get()); + vout.projPos = float4(vIn.p0, vIn.field.get() + vIn.e.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 index 66d7546ff..7dbe7feca 100644 --- a/tests/cross-compile/glsl-generic-in.slang.glsl +++ b/tests/cross-compile/glsl-generic-in.slang.glsl @@ -1,9 +1,8 @@ -//TEST_IGNORE_FILE #version 450 layout(row_major) uniform; layout(row_major) buffer; -#line 11 0 +#line 12 0 struct F_0 { vec4 v0_0; @@ -11,15 +10,23 @@ struct F_0 }; -#line 15 +#line 16 float F_get_0(F_0 this_0) { -#line 15 +#line 16 return this_0.v0_0.x + this_0.v1_0.x; } +float E_get_0() +{ + +#line 20 + return 1.00000000000000000000; +} + + #line 6 layout(location = 0) in vec3 _S1; @@ -42,20 +49,21 @@ struct VOut_0 }; -#line 23 + void main() { GIn_0 _S4 = GIn_0(_S1, F_0(_S2, _S3)); -#line 25 +#line 30 VOut_0 vout_0; vec3 _S5 = _S4.p0_0; -#line 26 +#line 31 float _S6 = F_get_0(_S4.field_0); + float _S7 = E_get_0(); -#line 26 - vout_0.projPos_0 = vec4(_S5, _S6); +#line 31 + vout_0.projPos_0 = vec4(_S5, _S6 + _S7); gl_Position = vout_0.projPos_0; return; }
\ No newline at end of file |
