Unverified Commit 4d2298bf by Cody Northrop Committed by GitHub

Support multiple swizzled out operands (#2175)

Swizzled out operands were added in bbbd9a2a. This was sufficient for most tests, but we ran into problems with umulExtended and imulExtended, which have two. This CL converts the tracking values to vectors so multiple operands can be supported. Test: KHR-GLES31.core.shader_bitfield_operation.* Test: ctest
parent 46572440
...@@ -2357,10 +2357,10 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt ...@@ -2357,10 +2357,10 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
spec_constant_op_mode_setter.turnOnSpecConstantOpMode(); spec_constant_op_mode_setter.turnOnSpecConstantOpMode();
spv::Id result = spv::NoResult; spv::Id result = spv::NoResult;
spv::Id invertedType = spv::NoType; // to use to override the natural type of the node spv::Id invertedType = spv::NoType; // to use to override the natural type of the node
spv::Builder::AccessChain complexLvalue; // for holding swizzling l-values too complex for SPIR-V, std::vector<spv::Builder::AccessChain> complexLvalues; // for holding swizzling l-values too complex for
// for at out parameter // SPIR-V, for an out parameter
spv::Id temporaryLvalue = spv::NoResult; // temporary to pass, as proxy for complexLValue std::vector<spv::Id> temporaryLvalues; // temporaries to pass, as proxies for complexLValues
auto resultType = [&invertedType, &node, this](){ return invertedType != spv::NoType ? auto resultType = [&invertedType, &node, this](){ return invertedType != spv::NoType ?
invertedType : invertedType :
...@@ -2976,10 +2976,10 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt ...@@ -2976,10 +2976,10 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
// reduce to a simple access chain. So, we need a temporary vector to // reduce to a simple access chain. So, we need a temporary vector to
// receive the result, and must later swizzle that into the original // receive the result, and must later swizzle that into the original
// l-value. // l-value.
complexLvalue = builder.getAccessChain(); complexLvalues.push_back(builder.getAccessChain());
temporaryLvalue = builder.createVariable(spv::StorageClassFunction, temporaryLvalues.push_back(builder.createVariable(spv::StorageClassFunction,
builder.accessChainGetInferredType(), "swizzleTemp"); builder.accessChainGetInferredType(), "swizzleTemp"));
operands.push_back(temporaryLvalue); operands.push_back(temporaryLvalues.back());
} else { } else {
operands.push_back(builder.accessChainGetLValue()); operands.push_back(builder.accessChainGetLValue());
} }
...@@ -3074,11 +3074,13 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt ...@@ -3074,11 +3074,13 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
result = createMiscOperation(node->getOp(), precision, resultType(), operands, node->getBasicType()); result = createMiscOperation(node->getOp(), precision, resultType(), operands, node->getBasicType());
break; break;
} }
if (invertedType != spv::NoResult) if (invertedType != spv::NoResult)
result = createInvertedSwizzle(precision, *glslangOperands[0]->getAsBinaryNode(), result); result = createInvertedSwizzle(precision, *glslangOperands[0]->getAsBinaryNode(), result);
else if (temporaryLvalue != spv::NoResult) {
builder.setAccessChain(complexLvalue); for (unsigned int i = 0; i < temporaryLvalues.size(); ++i) {
builder.accessChainStore(builder.createLoad(temporaryLvalue)); builder.setAccessChain(complexLvalues[i]);
builder.accessChainStore(builder.createLoad(temporaryLvalues[i]));
} }
} }
......
...@@ -97,6 +97,13 @@ void main() ...@@ -97,6 +97,13 @@ void main()
u += max(u, uui); u += max(u, uui);
u += clamp(u, uui, uui); u += clamp(u, uui, uui);
// multiple out operands
uvec4 msb;
uvec4 lsb;
umulExtended(uuv4.xyz, uuv4.xyz, msb.xyz, lsb.xyz);
u += msb.x + msb.y + msb.z;
u += lsb.x + lsb.y + lsb.z;
//// bool //// bool
b = isnan(uf); b = isnan(uf);
b = isinf(f); b = isinf(f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment