SPV: For GLSL only, bitcast OpArrayLength result back to int.
This makes the rest of the AST consuming the result match GLSL semantics and hence get complete type matching.
This commit is contained in:
parent
e045c23a34
commit
8c869679f2
2 changed files with 25 additions and 22 deletions
|
|
@ -1825,6 +1825,12 @@ bool TGlslangToSpvTraverser::visitUnary(glslang::TVisit /* visit */, glslang::TI
|
|||
unsigned int member = node->getOperand()->getAsBinaryNode()->getRight()->getAsConstantUnion()->getConstArray()[0].getUConst();
|
||||
spv::Id length = builder.createArrayLength(builder.accessChainGetLValue(), member);
|
||||
|
||||
// GLSL semantics say the result of .length() is an int, while SPIR-V says
|
||||
// signedness must be 0. So, convert from SPIR-V unsigned back to GLSL's
|
||||
// AST expectation of a signed result.
|
||||
if (glslangIntermediate->getSource() == glslang::EShSourceGlsl)
|
||||
length = builder.createUnaryOp(spv::OpBitcast, builder.makeIntType(32), length);
|
||||
|
||||
builder.clearAccessChain();
|
||||
builder.setAccessChainRValue(length);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue