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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue