summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-05-21 14:44:09 -0400
committerGitHub <noreply@github.com>2019-05-21 14:44:09 -0400
commitc2b4c5838431e12abb6f233c459d3d6a717aad18 (patch)
treeed11811faa1c47b71a2acb482e01990baab8f43e
parent7ffe6f03976c98ba0233483d0182fc0ad600fd7a (diff)
Hotfix/improve glsl semantic conversion (#965)
* Specify glsl semantic format - such that conversions are possible from hlsl sematics. * Comment improvements. Give appropriate type in glsl for sv_tessfactor. Note that sv_tessfactor is not functional though. * Work in progress for comparison of types. * * Fix type comparison issues around the hash. * Fix tests whos output changed with use of isTypeEqual
-rw-r--r--source/slang/emit.cpp1
-rw-r--r--source/slang/ir-glsl-legalize.cpp27
-rw-r--r--source/slang/ir.cpp196
-rw-r--r--source/slang/ir.h11
-rw-r--r--source/slang/type-system-shared.h4
-rw-r--r--tests/compute/half-texture.slang.expected290
-rw-r--r--tests/cross-compile/func-resource-param-array.slang.glsl20
7 files changed, 379 insertions, 170 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 675d459e9..0d5e51747 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -7280,6 +7280,7 @@ String emitEntryPoint(
#endif
validateIRModuleIfEnabled(compileRequest, irModule);
+
// For GLSL only, we will need to perform "legalization" of
// the entry point and any entry-point parameters.
//
diff --git a/source/slang/ir-glsl-legalize.cpp b/source/slang/ir-glsl-legalize.cpp
index db23161f4..6a50d32cd 100644
--- a/source/slang/ir-glsl-legalize.cpp
+++ b/source/slang/ir-glsl-legalize.cpp
@@ -231,6 +231,8 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// HLSL semantic types can be found here
// https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-semantics
+ /// NOTE! While there might be an "official" type for most of these in HLSL, in practice the user is allowed to declare almost anything
+ /// that the HLSL compiler can implicitly convert to/from the correct type
auto builder = context->getBuilder();
IRType* requiredType = nullptr;
@@ -267,6 +269,8 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
{
name = "gl_Position";
}
+
+ requiredType = builder->getVectorType(builder->getBasicType(BaseType::Float), builder->getIntValue(builder->getIntType(), 4));
}
else if(semanticName == "sv_target")
{
@@ -286,6 +290,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_ClipDistance.xhtml
name = "gl_ClipDistance";
+ requiredType = builder->getBasicType(BaseType::Float);
}
else if(semanticName == "sv_culldistance")
{
@@ -296,6 +301,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// TODO: type conversion is required here.
name = "gl_CullDistance";
+ requiredType = builder->getBasicType(BaseType::Float);
}
else if(semanticName == "sv_coverage")
{
@@ -315,6 +321,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// Float in hlsl & glsl
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FragDepth.xhtml
name = "gl_FragDepth";
+ requiredType = builder->getBasicType(BaseType::Float);
}
else if(semanticName == "sv_depthgreaterequal")
{
@@ -322,6 +329,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// Type is 'unknown' in hlsl
name = "gl_FragDepth";
+ requiredType = builder->getBasicType(BaseType::Float);
}
else if(semanticName == "sv_depthlessequal")
{
@@ -329,6 +337,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// 'unknown' in hlsl, float in glsl
name = "gl_FragDepth";
+ requiredType = builder->getBasicType(BaseType::Float);
}
else if(semanticName == "sv_dispatchthreadid")
{
@@ -340,7 +349,6 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
}
else if(semanticName == "sv_domainlocation")
{
- // TODO: Not 100% confident that say float2 will convert into float3 glsl?
// float2|3 in hlsl, vec3 in glsl
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_TessCoord.xhtml
@@ -360,6 +368,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
{
// uint in hlsl & in glsl
name = "gl_LocalInvocationIndex";
+ requiredType = builder->getBasicType(BaseType::UInt);
}
else if(semanticName == "sv_groupthreadid")
{
@@ -389,6 +398,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
// bool in hlsl & glsl
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FrontFacing.xhtml
name = "gl_FrontFacing";
+ requiredType = builder->getBasicType(BaseType::Bool);
}
else if(semanticName == "sv_outputcontrolpointid")
{
@@ -403,6 +413,7 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
{
// float in hlsl & glsl
name = "gl_PointSize";
+ requiredType = builder->getBasicType(BaseType::Float);
}
else if(semanticName == "sv_primitiveid")
{
@@ -456,11 +467,21 @@ GLSLSystemValueInfo* getGLSLSystemValueInfo(
}
else if (semanticName == "sv_tessfactor")
{
- // TODO(JS): Need to ensure the adjustType can handle such a scenario.
+ // TODO(JS): Adjust type does *not* handle the conversion correctly. More specifically a float array hlsl
+ // parameter goes through code to make SOA in createGLSLGlobalVaryingsImpl.
+ //
+ // Can be input and output.
+ //
+ // https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/sv-tessfactor
+ // "Tessellation factors must be declared as an array; they cannot be packed into a single vector."
+ //
// float[2|3|4] in hlsl, float[4] on glsl (ie both are arrays but might be different size)
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_TessLevelOuter.xhtml
name = "gl_TessLevelOuter";
+
+ // float[4] on glsl
+ requiredType = builder->getArrayType(builder->getBasicType(BaseType::Float), builder->getIntValue(builder->getIntType(), 4));
}
else if (semanticName == "sv_vertexid")
{
@@ -637,7 +658,7 @@ ScalarizedVal createSimpleGLSLGlobalVarying(
// the actual type of the GLSL global.
auto toType = inType;
- if( fromType != toType )
+ if( !isTypeEqual(fromType, toType ))
{
RefPtr<ScalarizedTypeAdapterValImpl> typeAdapter = new ScalarizedTypeAdapterValImpl;
typeAdapter->actualType = systemValueInfo->requiredType;
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 5015fda9d..00a70a2b4 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -1308,20 +1308,19 @@ namespace Slang
}
}
- /// True if constants are equal
- bool IRConstant::equal(IRConstant& rhs)
+ bool IRConstant::isValueEqual(IRConstant& rhs)
{
// If they are literally the same thing..
if (this == &rhs)
{
return true;
}
- // Check the type and they are the same op
- if (op != rhs.op ||
- getFullType() != rhs.getFullType())
+ // Check the type and they are the same op & same type
+ if (op != rhs.op)
{
return false;
}
+
switch (op)
{
case kIROp_BoolLit:
@@ -1347,6 +1346,13 @@ namespace Slang
return false;
}
+ /// True if constants are equal
+ bool IRConstant::equal(IRConstant& rhs)
+ {
+ // TODO(JS): Only equal if pointer types are identical (to match how getHashCode works below)
+ return isValueEqual(rhs) && getFullType() == rhs.getFullType();
+ }
+
int IRConstant::getHashCode()
{
auto code = Slang::GetHashCode(op);
@@ -3820,9 +3826,183 @@ namespace Slang
writer->flush();
}
- //
- //
- //
+ // Pre-declare
+ static bool _isTypeOperandEqual(IRInst* a, IRInst* b);
+
+ static bool _areTypeOperandsEqual(IRInst* a, IRInst* b)
+ {
+ // Must have same number of operands
+ const auto operandCountA = Index(a->getOperandCount());
+ if (operandCountA != Index(b->getOperandCount()))
+ {
+ return false;
+ }
+
+ // All the operands must be equal
+ for (Index i = 0; i < operandCountA; ++i)
+ {
+ IRInst* operandA = a->getOperand(i);
+ IRInst* operandB = b->getOperand(i);
+
+ if (!_isTypeOperandEqual(operandA, operandB))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ static bool _hasNominalEquality(IROp op)
+ {
+ // True if the type should be handled 'nominally' for equality
+ switch (op)
+ {
+ case kIROp_StructType:
+ case kIROp_InterfaceType:
+ case kIROp_Generic:
+ case kIROp_Param:
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static bool _isNominallyEqual(IRInst* a, IRInst* b)
+ {
+ // Two instruction are nominally equal if their instruction pointer is equal
+ return a == b;
+ }
+
+ // True if a type operand is equal. Operands are 'IRInst' - but it's only a restricted set
+ // if equality of nominal types is by names alone.
+ static bool _isTypeOperandEqual(IRInst* a, IRInst* b)
+ {
+ if (a == b)
+ {
+ return true;
+ }
+
+ if (a == nullptr || b == nullptr)
+ {
+ return false;
+ }
+
+ IROp opA = IROp(a->op & kIROpMeta_PseudoOpMask);
+ IROp opB = IROp(b->op & kIROpMeta_PseudoOpMask);
+
+ if (opA != opB)
+ {
+ return false;
+ }
+
+ // If it's a constant...
+ if (IRConstant::isaImpl(opA))
+ {
+ // TODO: This is contrived in that we want two types that are the same, but are different
+ // pointers to match here.
+ // If we make GetHashCode for IRType* compatible with isTypeEqual, then we should probably use that.
+ return static_cast<IRConstant*>(a)->isValueEqual(*static_cast<IRConstant*>(b)) &&
+ isTypeEqual(a->getFullType(), b->getFullType());
+ }
+
+ // If it's a type
+ if (IRType::isaImpl(opA))
+ {
+ return isTypeEqual(static_cast<IRType*>(a), static_cast<IRType*>(b));
+ }
+
+ if (_hasNominalEquality(opA))
+ {
+ return _isNominallyEqual(a, b);
+ }
+
+ SLANG_ASSERT(!"Unhandled comparison");
+
+ // We can't equate any other type..
+ return false;
+ }
+
+
+ bool isTypeEqual(IRType* a, IRType* b)
+ {
+ if (a == b)
+ {
+ return true;
+ }
+
+ if (a == nullptr || b == nullptr)
+ {
+ return false;
+ }
+
+ const IROp opA = IROp(a->op & kIROpMeta_PseudoOpMask);
+ const IROp opB = IROp(b->op & kIROpMeta_PseudoOpMask);
+ if (opA != opB)
+ {
+ return false;
+ }
+
+ if (IRBasicType::isaImpl(opA))
+ {
+ // If it's a basic type, then their op being the same means we are done
+ return true;
+ }
+
+ // We don't care about the parent or positioning
+ // We also don't care about 'type' - because these instructions are defining the type.
+ //
+ // We may want to care about decorations.
+ //
+
+ if (_hasNominalEquality(opA))
+ {
+ return _isNominallyEqual(a, b);
+ }
+
+ // IRTextureType contains IRParam
+ // If it's a resource type - handle the resource flavor
+ if (IRResourceTypeBase::isaImpl(opA))
+ {
+ auto resourceA = static_cast<const IRResourceTypeBase*>(a);
+ auto resourceB = static_cast<const IRResourceTypeBase*>(b);
+
+ if (resourceA->getFlavor() != resourceB->getFlavor())
+ {
+ return false;
+ }
+ }
+
+ if (!_areTypeOperandsEqual(a, b))
+ {
+ return false;
+ }
+
+ // TODO(JS): There is a question here about what to do about decorations.
+ // For now we ignore decorations. Are two types potentially different if there decorations different?
+ // If decorations play a part in difference in types - the order of decorations presumably is not important.
+
+ return true;
+ }
+
+ void findAllInstsBreadthFirst(IRInst* inst, List<IRInst*>& outInsts)
+ {
+ Index index = outInsts.getCount();
+
+ outInsts.add(inst);
+
+ while (index < outInsts.getCount())
+ {
+ IRInst* cur = outInsts[index++];
+
+ IRInstListBase childrenList = cur->getDecorationsAndChildren();
+ for (IRInst* child : childrenList)
+ {
+ outInsts.add(child);
+ }
+ }
+ }
IRDecoration* IRInst::getFirstDecoration()
{
diff --git a/source/slang/ir.h b/source/slang/ir.h
index 61cae5847..47c672a99 100644
--- a/source/slang/ir.h
+++ b/source/slang/ir.h
@@ -504,6 +504,13 @@ struct IRBoolType : IRBasicType
SIMPLE_IR_TYPE(StringType, Type)
+
+// True if types are equal
+// Note compares nominal types by name alone
+bool isTypeEqual(IRType* a, IRType* b);
+
+void findAllInstsBreadthFirst(IRInst* inst, List<IRInst*>& outInsts);
+
// Constant Instructions
typedef int64_t IRIntegerValue;
@@ -540,6 +547,10 @@ struct IRConstant : IRInst
/// True if constants are equal
bool equal(IRConstant& rhs);
+ /// True if the value is equal.
+ /// Does *NOT* compare if the type is equal.
+ bool isValueEqual(IRConstant& rhs);
+
/// Get the hash
int getHashCode();
diff --git a/source/slang/type-system-shared.h b/source/slang/type-system-shared.h
index 183cacb4b..95840e701 100644
--- a/source/slang/type-system-shared.h
+++ b/source/slang/type-system-shared.h
@@ -32,6 +32,7 @@ FOREACH_BASE_TYPE(DEFINE_BASE_TYPE)
struct TextureFlavor
{
+ typedef TextureFlavor ThisType;
enum
{
// Mask for the overall "shape" of the texture
@@ -78,6 +79,9 @@ FOREACH_BASE_TYPE(DEFINE_BASE_TYPE)
bool isMultisample() const { return (flavor & MultisampleFlag) != 0; }
// bool isShadow() const { return (flavor & ShadowFlag) != 0; }
+ SLANG_FORCE_INLINE bool operator==(const ThisType& rhs) const { return flavor == rhs.flavor; }
+ SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
+
SlangResourceShape getShape() const { return flavor & 0xFF; }
SlangResourceAccess getAccess() const { return (flavor >> 8) & 0xFF; }
diff --git a/tests/compute/half-texture.slang.expected b/tests/compute/half-texture.slang.expected
index 8d1a6bef4..eb1ee705f 100644
--- a/tests/compute/half-texture.slang.expected
+++ b/tests/compute/half-texture.slang.expected
@@ -4,7 +4,7 @@ standard error = {
standard output = {
// Module Version 10000
// Generated by (magic number): 80007
-// Id's are bound by 129
+// Id's are bound by 125
Capability Shader
Capability Float16
@@ -20,30 +20,30 @@ standard output = {
Name 4 "main"
Name 9 "pos_0"
Name 13 "gl_GlobalInvocationID"
- Name 22 "pos2_0"
- Name 36 "h_0"
- Name 40 "halfTexture_0"
- Name 51 "h2_0"
- Name 54 "halfTexture2_0"
- Name 65 "h4_0"
- Name 68 "halfTexture4_0"
- Name 108 "index_0"
- Name 117 "_S1"
- MemberName 117(_S1) 0 "_data"
- Name 119 "outputBuffer_0"
+ Name 18 "pos2_0"
+ Name 32 "h_0"
+ Name 36 "halfTexture_0"
+ Name 47 "h2_0"
+ Name 50 "halfTexture2_0"
+ Name 61 "h4_0"
+ Name 64 "halfTexture4_0"
+ Name 104 "index_0"
+ Name 113 "_S1"
+ MemberName 113(_S1) 0 "_data"
+ Name 115 "outputBuffer_0"
Decorate 13(gl_GlobalInvocationID) BuiltIn GlobalInvocationId
- Decorate 40(halfTexture_0) DescriptorSet 0
- Decorate 40(halfTexture_0) Binding 1
- Decorate 54(halfTexture2_0) DescriptorSet 0
- Decorate 54(halfTexture2_0) Binding 2
- Decorate 68(halfTexture4_0) DescriptorSet 0
- Decorate 68(halfTexture4_0) Binding 3
- Decorate 116 ArrayStride 4
- MemberDecorate 117(_S1) 0 Offset 0
- Decorate 117(_S1) BufferBlock
- Decorate 119(outputBuffer_0) DescriptorSet 0
- Decorate 119(outputBuffer_0) Binding 0
- Decorate 128 BuiltIn WorkgroupSize
+ Decorate 36(halfTexture_0) DescriptorSet 0
+ Decorate 36(halfTexture_0) Binding 1
+ Decorate 50(halfTexture2_0) DescriptorSet 0
+ Decorate 50(halfTexture2_0) Binding 2
+ Decorate 64(halfTexture4_0) DescriptorSet 0
+ Decorate 64(halfTexture4_0) Binding 3
+ Decorate 112 ArrayStride 4
+ MemberDecorate 113(_S1) 0 Offset 0
+ Decorate 113(_S1) BufferBlock
+ Decorate 115(outputBuffer_0) DescriptorSet 0
+ Decorate 115(outputBuffer_0) Binding 0
+ Decorate 124 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
@@ -53,133 +53,129 @@ standard output = {
11: TypeVector 10(int) 3
12: TypePointer Input 11(ivec3)
13(gl_GlobalInvocationID): 12(ptr) Variable Input
- 19: TypeVector 10(int) 2
- 23: 6(int) Constant 3
- 24: 10(int) Constant 1
- 25: TypePointer Function 6(int)
- 29: 10(int) Constant 0
- 34: TypeFloat 16
- 35: TypePointer Function 34(float16_t)
- 37: TypeFloat 32
- 38: TypeImage 37(float) 2D nonsampled format:R16f
- 39: TypePointer UniformConstant 38
-40(halfTexture_0): 39(ptr) Variable UniformConstant
- 45: TypeVector 37(float) 4
- 49: TypeVector 34(float16_t) 2
- 50: TypePointer Function 49(f16vec2)
- 52: TypeImage 37(float) 2D nonsampled format:Rg16f
- 53: TypePointer UniformConstant 52
-54(halfTexture2_0): 53(ptr) Variable UniformConstant
- 60: TypeVector 37(float) 2
- 63: TypeVector 34(float16_t) 4
- 64: TypePointer Function 63(f16vec4)
- 66: TypeImage 37(float) 2D nonsampled format:Rgba16f
- 67: TypePointer UniformConstant 66
-68(halfTexture4_0): 67(ptr) Variable UniformConstant
- 84:34(float16_t) Constant 0
- 113: 6(int) Constant 4
- 116: TypeRuntimeArray 6(int)
- 117(_S1): TypeStruct 116
- 118: TypePointer Uniform 117(_S1)
-119(outputBuffer_0): 118(ptr) Variable Uniform
- 120: 6(int) Constant 0
- 124: TypePointer Uniform 6(int)
- 127: 10(int) Constant 4
- 128: 11(ivec3) ConstantComposite 127 127 24
+ 14: TypeVector 10(int) 2
+ 19: 6(int) Constant 3
+ 20: 10(int) Constant 1
+ 21: TypePointer Function 6(int)
+ 25: 10(int) Constant 0
+ 30: TypeFloat 16
+ 31: TypePointer Function 30(float16_t)
+ 33: TypeFloat 32
+ 34: TypeImage 33(float) 2D nonsampled format:R16f
+ 35: TypePointer UniformConstant 34
+36(halfTexture_0): 35(ptr) Variable UniformConstant
+ 41: TypeVector 33(float) 4
+ 45: TypeVector 30(float16_t) 2
+ 46: TypePointer Function 45(f16vec2)
+ 48: TypeImage 33(float) 2D nonsampled format:Rg16f
+ 49: TypePointer UniformConstant 48
+50(halfTexture2_0): 49(ptr) Variable UniformConstant
+ 56: TypeVector 33(float) 2
+ 59: TypeVector 30(float16_t) 4
+ 60: TypePointer Function 59(f16vec4)
+ 62: TypeImage 33(float) 2D nonsampled format:Rgba16f
+ 63: TypePointer UniformConstant 62
+64(halfTexture4_0): 63(ptr) Variable UniformConstant
+ 80:30(float16_t) Constant 0
+ 109: 6(int) Constant 4
+ 112: TypeRuntimeArray 6(int)
+ 113(_S1): TypeStruct 112
+ 114: TypePointer Uniform 113(_S1)
+115(outputBuffer_0): 114(ptr) Variable Uniform
+ 116: 6(int) Constant 0
+ 120: TypePointer Uniform 6(int)
+ 123: 10(int) Constant 4
+ 124: 11(ivec3) ConstantComposite 123 123 20
4(main): 2 Function None 3
5: Label
9(pos_0): 8(ptr) Variable Function
- 22(pos2_0): 8(ptr) Variable Function
- 36(h_0): 35(ptr) Variable Function
- 51(h2_0): 50(ptr) Variable Function
- 65(h4_0): 64(ptr) Variable Function
- 108(index_0): 25(ptr) Variable Function
- 14: 11(ivec3) Load 13(gl_GlobalInvocationID)
- 15: 10(int) CompositeExtract 14 0
- 16: 10(int) CompositeExtract 14 1
- 17: 10(int) CompositeExtract 14 2
- 18: 11(ivec3) CompositeConstruct 15 16 17
- 20: 19(ivec2) VectorShuffle 18 18 0 1
- 21: 7(ivec2) Bitcast 20
- Store 9(pos_0) 21
- 26: 25(ptr) AccessChain 9(pos_0) 24
+ 18(pos2_0): 8(ptr) Variable Function
+ 32(h_0): 31(ptr) Variable Function
+ 47(h2_0): 46(ptr) Variable Function
+ 61(h4_0): 60(ptr) Variable Function
+ 104(index_0): 21(ptr) Variable Function
+ 15: 11(ivec3) Load 13(gl_GlobalInvocationID)
+ 16: 14(ivec2) VectorShuffle 15 15 0 1
+ 17: 7(ivec2) Bitcast 16
+ Store 9(pos_0) 17
+ 22: 21(ptr) AccessChain 9(pos_0) 20
+ 23: 6(int) Load 22
+ 24: 6(int) ISub 19 23
+ 26: 21(ptr) AccessChain 9(pos_0) 25
27: 6(int) Load 26
- 28: 6(int) ISub 23 27
- 30: 25(ptr) AccessChain 9(pos_0) 29
- 31: 6(int) Load 30
- 32: 6(int) ISub 23 31
- 33: 7(ivec2) CompositeConstruct 28 32
- Store 22(pos2_0) 33
- 41: 38 Load 40(halfTexture_0)
- 42: 7(ivec2) Load 22(pos2_0)
- 43: 19(ivec2) Bitcast 42
- 44: 7(ivec2) Bitcast 43
- 46: 45(fvec4) ImageRead 41 44
- 47: 37(float) CompositeExtract 46 0
- 48:34(float16_t) FConvert 47
- Store 36(h_0) 48
- 55: 52 Load 54(halfTexture2_0)
- 56: 7(ivec2) Load 22(pos2_0)
- 57: 19(ivec2) Bitcast 56
- 58: 7(ivec2) Bitcast 57
- 59: 45(fvec4) ImageRead 55 58
- 61: 60(fvec2) VectorShuffle 59 59 0 1
- 62: 49(f16vec2) FConvert 61
- Store 51(h2_0) 62
- 69: 66 Load 68(halfTexture4_0)
- 70: 7(ivec2) Load 22(pos2_0)
- 71: 19(ivec2) Bitcast 70
- 72: 7(ivec2) Bitcast 71
- 73: 45(fvec4) ImageRead 69 72
- 74: 63(f16vec4) FConvert 73
- Store 65(h4_0) 74
- 75: 38 Load 40(halfTexture_0)
- 76: 7(ivec2) Load 9(pos_0)
- 77: 19(ivec2) Bitcast 76
- 78: 7(ivec2) Bitcast 77
- 79: 35(ptr) AccessChain 51(h2_0) 29
- 80:34(float16_t) Load 79
- 81: 35(ptr) AccessChain 51(h2_0) 24
- 82:34(float16_t) Load 81
- 83:34(float16_t) FAdd 80 82
- 85: 63(f16vec4) CompositeConstruct 83 84 84 84
- 86: 45(fvec4) FConvert 85
- ImageWrite 75 78 86
- 87: 52 Load 54(halfTexture2_0)
- 88: 7(ivec2) Load 9(pos_0)
- 89: 19(ivec2) Bitcast 88
- 90: 7(ivec2) Bitcast 89
- 91: 63(f16vec4) Load 65(h4_0)
- 92: 49(f16vec2) VectorShuffle 91 91 0 1
- 93:34(float16_t) CompositeExtract 92 0
- 94:34(float16_t) CompositeExtract 92 1
- 95: 63(f16vec4) CompositeConstruct 93 94 84 84
- 96: 45(fvec4) FConvert 95
- ImageWrite 87 90 96
- 97: 66 Load 68(halfTexture4_0)
- 98: 7(ivec2) Load 9(pos_0)
- 99: 19(ivec2) Bitcast 98
- 100: 7(ivec2) Bitcast 99
- 101: 49(f16vec2) Load 51(h2_0)
- 102:34(float16_t) Load 36(h_0)
- 103:34(float16_t) Load 36(h_0)
- 104:34(float16_t) CompositeExtract 101 0
- 105:34(float16_t) CompositeExtract 101 1
- 106: 63(f16vec4) CompositeConstruct 104 105 102 103
- 107: 45(fvec4) FConvert 106
- ImageWrite 97 100 107
- 109: 25(ptr) AccessChain 9(pos_0) 29
- 110: 6(int) Load 109
- 111: 25(ptr) AccessChain 9(pos_0) 24
- 112: 6(int) Load 111
- 114: 6(int) IMul 112 113
- 115: 6(int) IAdd 110 114
- Store 108(index_0) 115
- 121: 6(int) Load 108(index_0)
- 122: 10(int) Bitcast 121
- 123: 6(int) Load 108(index_0)
- 125: 124(ptr) AccessChain 119(outputBuffer_0) 120 122
- Store 125 123
+ 28: 6(int) ISub 19 27
+ 29: 7(ivec2) CompositeConstruct 24 28
+ Store 18(pos2_0) 29
+ 37: 34 Load 36(halfTexture_0)
+ 38: 7(ivec2) Load 18(pos2_0)
+ 39: 14(ivec2) Bitcast 38
+ 40: 7(ivec2) Bitcast 39
+ 42: 41(fvec4) ImageRead 37 40
+ 43: 33(float) CompositeExtract 42 0
+ 44:30(float16_t) FConvert 43
+ Store 32(h_0) 44
+ 51: 48 Load 50(halfTexture2_0)
+ 52: 7(ivec2) Load 18(pos2_0)
+ 53: 14(ivec2) Bitcast 52
+ 54: 7(ivec2) Bitcast 53
+ 55: 41(fvec4) ImageRead 51 54
+ 57: 56(fvec2) VectorShuffle 55 55 0 1
+ 58: 45(f16vec2) FConvert 57
+ Store 47(h2_0) 58
+ 65: 62 Load 64(halfTexture4_0)
+ 66: 7(ivec2) Load 18(pos2_0)
+ 67: 14(ivec2) Bitcast 66
+ 68: 7(ivec2) Bitcast 67
+ 69: 41(fvec4) ImageRead 65 68
+ 70: 59(f16vec4) FConvert 69
+ Store 61(h4_0) 70
+ 71: 34 Load 36(halfTexture_0)
+ 72: 7(ivec2) Load 9(pos_0)
+ 73: 14(ivec2) Bitcast 72
+ 74: 7(ivec2) Bitcast 73
+ 75: 31(ptr) AccessChain 47(h2_0) 25
+ 76:30(float16_t) Load 75
+ 77: 31(ptr) AccessChain 47(h2_0) 20
+ 78:30(float16_t) Load 77
+ 79:30(float16_t) FAdd 76 78
+ 81: 59(f16vec4) CompositeConstruct 79 80 80 80
+ 82: 41(fvec4) FConvert 81
+ ImageWrite 71 74 82
+ 83: 48 Load 50(halfTexture2_0)
+ 84: 7(ivec2) Load 9(pos_0)
+ 85: 14(ivec2) Bitcast 84
+ 86: 7(ivec2) Bitcast 85
+ 87: 59(f16vec4) Load 61(h4_0)
+ 88: 45(f16vec2) VectorShuffle 87 87 0 1
+ 89:30(float16_t) CompositeExtract 88 0
+ 90:30(float16_t) CompositeExtract 88 1
+ 91: 59(f16vec4) CompositeConstruct 89 90 80 80
+ 92: 41(fvec4) FConvert 91
+ ImageWrite 83 86 92
+ 93: 62 Load 64(halfTexture4_0)
+ 94: 7(ivec2) Load 9(pos_0)
+ 95: 14(ivec2) Bitcast 94
+ 96: 7(ivec2) Bitcast 95
+ 97: 45(f16vec2) Load 47(h2_0)
+ 98:30(float16_t) Load 32(h_0)
+ 99:30(float16_t) Load 32(h_0)
+ 100:30(float16_t) CompositeExtract 97 0
+ 101:30(float16_t) CompositeExtract 97 1
+ 102: 59(f16vec4) CompositeConstruct 100 101 98 99
+ 103: 41(fvec4) FConvert 102
+ ImageWrite 93 96 103
+ 105: 21(ptr) AccessChain 9(pos_0) 25
+ 106: 6(int) Load 105
+ 107: 21(ptr) AccessChain 9(pos_0) 20
+ 108: 6(int) Load 107
+ 110: 6(int) IMul 108 109
+ 111: 6(int) IAdd 106 110
+ Store 104(index_0) 111
+ 117: 6(int) Load 104(index_0)
+ 118: 10(int) Bitcast 117
+ 119: 6(int) Load 104(index_0)
+ 121: 120(ptr) AccessChain 115(outputBuffer_0) 116 118
+ Store 121 119
Return
FunctionEnd
}
diff --git a/tests/cross-compile/func-resource-param-array.slang.glsl b/tests/cross-compile/func-resource-param-array.slang.glsl
index d7f9c17bc..e9d1b5a97 100644
--- a/tests/cross-compile/func-resource-param-array.slang.glsl
+++ b/tests/cross-compile/func-resource-param-array.slang.glsl
@@ -26,14 +26,12 @@
#define g_c_i _S10
#define g_c_j _S11
-#define tid _S12
+#define tmp_f_a_ii _S12
+#define tmp_f_a_jj _S13
-#define tmp_f_a_ii _S13
-#define tmp_f_a_jj _S14
-
-#define tmp_f_b _S15
-#define tmp_g_b _S16
-#define tmp_g_c _S17
+#define tmp_f_b _S14
+#define tmp_g_b _S15
+#define tmp_g_c _S16
layout(std430, binding = 0) buffer a_block {
int _data[];
@@ -71,11 +69,9 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main()
{
- uvec3 tid = uvec3(gl_GlobalInvocationID);
-
- uint ii = tid.x;
- uint jj = tid.y;
- uint kk = tid.z;
+ uint ii = gl_GlobalInvocationID.x;
+ uint jj = gl_GlobalInvocationID.y;
+ uint kk = gl_GlobalInvocationID.z;
int tmp_f_a_ii = f_a(ii);