Improved fix for buffer reference constants
This is an alternate fix for the issue described in commit be63facd, whose
solution didn't work if there were non-trivial operations involved in computing
a constant initializer which caused the 'constant unfolding' code to kick in
(addConstantReferenceConversion). Instead, this change does the 'unfolding'
later in createSpvConstantFromConstUnionArray. If a reference-type constant has
survived that long, then folding is already done, this must be a 'real' (inside
a function) use of the constant, and it should be safe to unfold and apply the
bitcast.
This commit is contained in:
parent
79d25ea0ce
commit
3fd1232665
6 changed files with 75 additions and 75 deletions
|
|
@ -725,19 +725,6 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|||
return newNode;
|
||||
}
|
||||
|
||||
// Convert a constant that is a reference type to a uint64_t constant plus a
|
||||
// constructor instruction. This is needed because SPIR-V doesn't support
|
||||
// OpConstant on pointer types.
|
||||
TIntermTyped* TIntermediate::addConstantReferenceConversion(TIntermTyped* node)
|
||||
{
|
||||
if (node->getType().getBasicType() == EbtReference && node->getAsConstantUnion()) {
|
||||
const TType &type = node->getType();
|
||||
node = addBuiltInFunctionCall(node->getLoc(), EOpConvPtrToUint64, true, node, TType(EbtUint64));
|
||||
node = addUnaryNode(EOpConstructReference, node, node->getLoc(), type);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
TIntermTyped* TIntermediate::addConversion(TBasicType convertTo, TIntermTyped* node) const
|
||||
{
|
||||
return createConversion(convertTo, node);
|
||||
|
|
@ -775,9 +762,6 @@ TIntermediate::addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* no
|
|||
return std::make_tuple(node0, node1);
|
||||
}
|
||||
|
||||
node0 = addConstantReferenceConversion(node0);
|
||||
node1 = addConstantReferenceConversion(node1);
|
||||
|
||||
auto promoteTo = std::make_tuple(EbtNumTypes, EbtNumTypes);
|
||||
|
||||
switch (op) {
|
||||
|
|
@ -897,8 +881,6 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
if (!isConversionAllowed(op, node))
|
||||
return nullptr;
|
||||
|
||||
node = addConstantReferenceConversion(node);
|
||||
|
||||
// Otherwise, if types are identical, no problem
|
||||
if (type == node->getType())
|
||||
return node;
|
||||
|
|
|
|||
|
|
@ -6527,11 +6527,7 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|||
// We either have a folded constant in getAsConstantUnion, or we have to use
|
||||
// the initializer's subtree in the AST to represent the computation of a
|
||||
// specialization constant.
|
||||
// A third case arises when a reference type is made non-constant due to
|
||||
// addConstantReferenceConversion, but reference types can't be const, so
|
||||
// this is an error.
|
||||
assert(initializer->getAsConstantUnion() || initializer->getType().getQualifier().isSpecConstant() ||
|
||||
initializer->getType().getBasicType() == EbtReference);
|
||||
assert(initializer->getAsConstantUnion() || initializer->getType().getQualifier().isSpecConstant());
|
||||
if (initializer->getAsConstantUnion())
|
||||
variable->setConstArray(initializer->getAsConstantUnion()->getConstArray());
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -501,7 +501,6 @@ public:
|
|||
TIntermTyped* addConversion(TBasicType convertTo, TIntermTyped* node) const;
|
||||
void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
|
||||
TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
|
||||
TIntermTyped* addConstantReferenceConversion(TIntermTyped* node);
|
||||
TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue