Non-functional: Fix some comments English and brace formatting in recent merges.
This commit is contained in:
@@ -1891,8 +1891,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
addMemberDecoration(spvType, member, TranslateLayoutDecoration(glslangType, subQualifier.layoutMatrix));
|
||||
addMemberDecoration(spvType, member, TranslatePrecisionDecoration(glslangType));
|
||||
// Add interpolation decorations only to top-level members of Input and Output storage classes
|
||||
if (type.getQualifier().storage == glslang::EvqVaryingIn || type.getQualifier().storage == glslang::EvqVaryingOut)
|
||||
{
|
||||
if (type.getQualifier().storage == glslang::EvqVaryingIn || type.getQualifier().storage == glslang::EvqVaryingOut) {
|
||||
addMemberDecoration(spvType, member, TranslateInterpolationDecoration(subQualifier));
|
||||
}
|
||||
addMemberDecoration(spvType, member, TranslateInvariantDecoration(subQualifier));
|
||||
@@ -1909,14 +1908,11 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
// probably move to the linker stage of the front end proper, and just have the
|
||||
// answer sitting already distributed throughout the individual member locations.
|
||||
int location = -1; // will only decorate if present or inherited
|
||||
if (subQualifier.hasLocation()) // no inheritance, or override of inheritance
|
||||
{
|
||||
if (subQualifier.hasLocation()) { // no inheritance, or override of inheritance
|
||||
// struct members should not have explicit locations
|
||||
assert(type.getBasicType() != glslang::EbtStruct);
|
||||
location = subQualifier.layoutLocation;
|
||||
}
|
||||
else if (type.getBasicType() != glslang::EbtBlock)
|
||||
{
|
||||
} else if (type.getBasicType() != glslang::EbtBlock) {
|
||||
// If it is a not a Block, (...) Its members are assigned consecutive locations (...)
|
||||
// The members, and their nested types, must not themselves have Location decorations.
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
//
|
||||
// Visit the nodes in the glslang intermediate tree representation to
|
||||
// propagate 'noContraction' qualifier.
|
||||
// propagate the 'noContraction' qualifier.
|
||||
//
|
||||
|
||||
#include "propagateNoContraction.h"
|
||||
@@ -48,16 +48,16 @@
|
||||
#include "localintermediate.h"
|
||||
namespace {
|
||||
|
||||
// Use string to hold the accesschain information, as in most cases the
|
||||
// Use a string to hold the access chain information, as in most cases the
|
||||
// access chain is short and may contain only one element, which is the symbol
|
||||
// ID.
|
||||
// Example: struct {float a; float b;} s;
|
||||
// Object s.a will be represented with: <symbol ID of s>/0
|
||||
// Object s.b will be represented with: <symbol ID of s>/1
|
||||
// Object s will be representend with: <symbol ID of s>
|
||||
// Object s will be represented with: <symbol ID of s>
|
||||
// For members of vector, matrix and arrays, they will be represented with the
|
||||
// same symbol ID of their container symbol objects. This is because their
|
||||
// precise'ness is always the same as their container symbol objects.
|
||||
// preciseness is always the same as their container symbol objects.
|
||||
typedef std::string ObjectAccessChain;
|
||||
|
||||
// The delimiter used in the ObjectAccessChain string to separate symbol ID and
|
||||
@@ -127,7 +127,7 @@ bool isAssignOperation(glslang::TOperator op)
|
||||
}
|
||||
|
||||
// A helper function to get the unsigned int from a given constant union node.
|
||||
// Note the node should only holds a uint scalar.
|
||||
// Note the node should only hold a uint scalar.
|
||||
unsigned getStructIndexFromConstantUnion(glslang::TIntermTyped* node)
|
||||
{
|
||||
assert(node->getAsConstantUnion() && node->getAsConstantUnion()->isScalar());
|
||||
@@ -144,7 +144,7 @@ ObjectAccessChain generateSymbolLabel(glslang::TIntermSymbol* node)
|
||||
}
|
||||
|
||||
// Returns true if the operation is an arithmetic operation and valid for
|
||||
// 'NoContraction' decoration.
|
||||
// the 'NoContraction' decoration.
|
||||
bool isArithmeticOperation(glslang::TOperator op)
|
||||
{
|
||||
switch (op) {
|
||||
@@ -184,7 +184,7 @@ bool isArithmeticOperation(glslang::TOperator op)
|
||||
}
|
||||
}
|
||||
|
||||
// A helper class to help managing populating_initial_no_contraction_ flag.
|
||||
// A helper class to help manage the populating_initial_no_contraction_ flag.
|
||||
template <typename T> class StateSettingGuard {
|
||||
public:
|
||||
StateSettingGuard(T* state_ptr, T new_state_value)
|
||||
@@ -260,7 +260,7 @@ protected:
|
||||
// visited.
|
||||
AccessChainMapping& accesschain_mapping_;
|
||||
// The pointer to the Function Definition node, so we can get the
|
||||
// precise'ness of the return expression from it when we traverse the
|
||||
// preciseness of the return expression from it when we traverse the
|
||||
// return branch node.
|
||||
glslang::TIntermAggregate* current_function_definition_node_;
|
||||
};
|
||||
@@ -288,14 +288,14 @@ void TSymbolDefinitionCollectingTraverser::visitSymbol(glslang::TIntermSymbol* n
|
||||
bool TSymbolDefinitionCollectingTraverser::visitAggregate(glslang::TVisit,
|
||||
glslang::TIntermAggregate* node)
|
||||
{
|
||||
// This aggreagate node might be a function definition node, in which case we need to
|
||||
// cache this node, so we can get the precise'ness information of the return value
|
||||
// This aggregate node might be a function definition node, in which case we need to
|
||||
// cache this node, so we can get the preciseness information of the return value
|
||||
// of this function later.
|
||||
StateSettingGuard<glslang::TIntermAggregate*> current_function_definition_node_setting_guard(
|
||||
¤t_function_definition_node_);
|
||||
if (node->getOp() == glslang::EOpFunction) {
|
||||
// This is function definition node, we need to cache this node so that we can
|
||||
// get the precise'ness of the return value later.
|
||||
// get the preciseness of the return value later.
|
||||
current_function_definition_node_setting_guard.setState(node);
|
||||
}
|
||||
// Traverse the items in the sequence.
|
||||
@@ -313,7 +313,7 @@ bool TSymbolDefinitionCollectingTraverser::visitBranch(glslang::TVisit,
|
||||
if (node->getFlowOp() == glslang::EOpReturn && node->getExpression() &&
|
||||
current_function_definition_node_ &&
|
||||
current_function_definition_node_->getType().getQualifier().noContraction) {
|
||||
// This node is a return node with expression, and its function has
|
||||
// This node is a return node with an expression, and its function has a
|
||||
// precise return value. We need to find the involved objects in its
|
||||
// expression and add them to the set of initial precise objects.
|
||||
precise_return_nodes_.insert(node);
|
||||
@@ -322,7 +322,7 @@ bool TSymbolDefinitionCollectingTraverser::visitBranch(glslang::TVisit,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Visits an unary node. This might be an implicit assignment like i++, i--. etc.
|
||||
// Visits a unary node. This might be an implicit assignment like i++, i--. etc.
|
||||
bool TSymbolDefinitionCollectingTraverser::visitUnary(glslang::TVisit /* visit */,
|
||||
glslang::TIntermUnary* node)
|
||||
{
|
||||
@@ -345,7 +345,7 @@ bool TSymbolDefinitionCollectingTraverser::visitUnary(glslang::TVisit /* visit *
|
||||
// Add a mapping from the symbol ID to this assignment operation node.
|
||||
symbol_definition_mapping_.insert(std::make_pair(id_symbol, node));
|
||||
}
|
||||
// Unary node is not a dereference node, so we clear the accesschain which
|
||||
// A unary node is not a dereference node, so we clear the access chain which
|
||||
// is under construction.
|
||||
current_object_.clear();
|
||||
return false;
|
||||
@@ -380,7 +380,7 @@ bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit /* visit
|
||||
symbol_definition_mapping_.insert(std::make_pair(id_symbol, node));
|
||||
|
||||
// Traverses the right node, there may be other 'assignment'
|
||||
// operatrions in the right.
|
||||
// operations in the right.
|
||||
current_object_.clear();
|
||||
node->getRight()->traverse(this);
|
||||
|
||||
@@ -395,7 +395,7 @@ bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit /* visit
|
||||
}
|
||||
accesschain_mapping_[node] = current_object_;
|
||||
|
||||
// For dereference node, there is no need to traverse the right child
|
||||
// For a dereference node, there is no need to traverse the right child
|
||||
// node as the right node should always be an integer type object.
|
||||
|
||||
} else {
|
||||
@@ -464,11 +464,11 @@ public:
|
||||
: TIntermTraverser(true, false, false), accesschain_mapping_(accesschain_mapping),
|
||||
precise_object_(nullptr) {}
|
||||
|
||||
// Checks the precise'ness of a given assignment node with a precise object
|
||||
// Checks the preciseness of a given assignment node with a precise object
|
||||
// represented as access chain. The precise object shares the same symbol
|
||||
// with the assignee of the given assignment node. Return a tuple of two:
|
||||
//
|
||||
// 1) The precise'ness of the assignee node of this assignment node. True
|
||||
// 1) The preciseness of the assignee node of this assignment node. True
|
||||
// if the assignee contains 'precise' objects or is 'precise', false if
|
||||
// the assignee is not 'precise' according to the access chain of the given
|
||||
// precise object.
|
||||
@@ -487,7 +487,7 @@ public:
|
||||
ObjectAccessChain assignee_object;
|
||||
if (glslang::TIntermBinary* BN = node->getAsBinaryNode()) {
|
||||
// This is a binary assignment node, we need to check the
|
||||
// precise'ness of the left node.
|
||||
// preciseness of the left node.
|
||||
assert(accesschain_mapping_.count(BN->getLeft()));
|
||||
// The left node (assignee node) is an object node, traverse the
|
||||
// node to let the 'precise' of nesting objects being transfered to
|
||||
@@ -498,14 +498,14 @@ public:
|
||||
if (isPreciseObjectNode(BN->getLeft())) {
|
||||
return make_tuple(true, ObjectAccessChain());
|
||||
}
|
||||
// If the precise'ness of the left node (assignee node) can not
|
||||
// If the preciseness of the left node (assignee node) can not
|
||||
// be determined by now, we need to compare the access chain string
|
||||
// of the assignee object with the given precise object.
|
||||
assignee_object = accesschain_mapping_.at(BN->getLeft());
|
||||
|
||||
} else if (glslang::TIntermUnary* UN = node->getAsUnaryNode()) {
|
||||
// This is a unary assignment node, we need to check the
|
||||
// precise'ness of the operand node. For unary assignment node, the
|
||||
// preciseness of the operand node. For unary assignment node, the
|
||||
// operand node should always be an object node.
|
||||
assert(accesschain_mapping_.count(UN->getOperand()));
|
||||
// Traverse the operand node to let the 'precise' being propagated
|
||||
@@ -516,7 +516,7 @@ public:
|
||||
if (isPreciseObjectNode(UN->getOperand())) {
|
||||
return make_tuple(true, ObjectAccessChain());
|
||||
}
|
||||
// If the precise'ness of the operand node (assignee node) can not
|
||||
// If the preciseness of the operand node (assignee node) can not
|
||||
// be determined by now, we need to compare the access chain string
|
||||
// of the assignee object with the given precise object.
|
||||
assignee_object = accesschain_mapping_.at(UN->getOperand());
|
||||
@@ -541,7 +541,7 @@ public:
|
||||
return make_tuple(true, getSubAccessChainAfterPrefix(precise_object, assignee_object));
|
||||
} else {
|
||||
// The access chain strings do not match, the assignee object can
|
||||
// not be labelled as 'precise' according to the given precise
|
||||
// not be labeled as 'precise' according to the given precise
|
||||
// object.
|
||||
return make_tuple(false, ObjectAccessChain());
|
||||
}
|
||||
@@ -603,7 +603,7 @@ void TNoContractionAssigneeCheckingTraverser::visitSymbol(glslang::TIntermSymbol
|
||||
// A traverser that only traverses the right side of binary assignment nodes
|
||||
// and the operand node of unary assignment nodes.
|
||||
//
|
||||
// 1) Marks arithmetic operations 'NoContraction'.
|
||||
// 1) Marks arithmetic operations as 'NoContraction'.
|
||||
//
|
||||
// 2) Find the object which should be marked as 'precise' in the right and
|
||||
// update the 'precise' object work list.
|
||||
@@ -659,7 +659,7 @@ protected:
|
||||
// access chain is not empty, we need to refer to the
|
||||
// assignee_remained_access_chain_ to find the nested
|
||||
// 'precise' object. And we don't need to visit other nodes in this
|
||||
// aggreagate node.
|
||||
// aggregate node.
|
||||
|
||||
// Gets the struct dereference index that leads to 'precise' object.
|
||||
ObjectAccessChain precise_accesschain_index_str =
|
||||
@@ -718,7 +718,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Visits an unary node. An unary node can not be an object node. If the operation
|
||||
// Visits a unary node. A unary node can not be an object node. If the operation
|
||||
// is an arithmetic operation, need to mark this node as 'noContraction'.
|
||||
bool visitUnary(glslang::TVisit /* visit */, glslang::TIntermUnary* node) override
|
||||
{
|
||||
@@ -730,7 +730,7 @@ protected:
|
||||
}
|
||||
|
||||
// Visits a symbol node. A symbol node is always an object node. So we
|
||||
// should always be able to find its in our colected mapping from object
|
||||
// should always be able to find its in our collected mapping from object
|
||||
// nodes to access chains. As an object node, a symbol node can be either
|
||||
// 'precise' or containing 'precise' objects according to unused
|
||||
// access chain information we have when we visit this node.
|
||||
@@ -833,7 +833,7 @@ void PropagateNoContraction(const glslang::TIntermediate& intermediate)
|
||||
// Visits all the assignment nodes of that symbol ID and
|
||||
// 1) Check if the assignee node is 'precise' or contains 'precise'
|
||||
// objects.
|
||||
// 2) Propagate the 'precise' to the top layer object ndoes
|
||||
// 2) Propagate the 'precise' to the top layer object nodes
|
||||
// in the right side of the assignment operation, update the 'precise'
|
||||
// work list with new access chains representing the new 'precise'
|
||||
// objects, and mark arithmetic operations as 'noContraction'.
|
||||
|
||||
Reference in New Issue
Block a user