add a test for matrix, fix a variable name
This commit is contained in:
@@ -357,8 +357,32 @@ vertices = -1
|
|||||||
0:99 subtract (temp float)
|
0:99 subtract (temp float)
|
||||||
0:99 'a' (temp float)
|
0:99 'a' (temp float)
|
||||||
0:99 'b' (in float)
|
0:99 'b' (in float)
|
||||||
0:102 Function Definition: main( (global void)
|
0:102 Function Definition: matrix(mf23;mf32; (global 3X3 matrix of float)
|
||||||
0:102 Function Parameters:
|
0:102 Function Parameters:
|
||||||
|
0:102 'a' (in 2X3 matrix of float)
|
||||||
|
0:102 'b' (in 3X2 matrix of float)
|
||||||
|
0:103 Sequence
|
||||||
|
0:103 Sequence
|
||||||
|
0:103 move second child to first child (temp 2X3 matrix of float)
|
||||||
|
0:103 'c' (noContraction temp 2X3 matrix of float)
|
||||||
|
0:103 Constant:
|
||||||
|
0:103 1.000000
|
||||||
|
0:103 2.000000
|
||||||
|
0:103 3.000000
|
||||||
|
0:103 4.000000
|
||||||
|
0:103 5.000000
|
||||||
|
0:103 6.000000
|
||||||
|
0:105 move second child to first child (temp 3X3 matrix of float)
|
||||||
|
0:105 'result' (noContraction temp 3X3 matrix of float)
|
||||||
|
0:105 matrix-multiply (noContraction temp 3X3 matrix of float)
|
||||||
|
0:105 add (noContraction temp 2X3 matrix of float)
|
||||||
|
0:105 'a' (noContraction in 2X3 matrix of float)
|
||||||
|
0:105 'c' (noContraction temp 2X3 matrix of float)
|
||||||
|
0:105 'b' (noContraction in 3X2 matrix of float)
|
||||||
|
0:106 Branch: Return with expression
|
||||||
|
0:106 'result' (noContraction temp 3X3 matrix of float)
|
||||||
|
0:109 Function Definition: main( (global void)
|
||||||
|
0:109 Function Parameters:
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
|
|
||||||
|
|
||||||
@@ -722,7 +746,31 @@ vertices = -1
|
|||||||
0:99 subtract (temp float)
|
0:99 subtract (temp float)
|
||||||
0:99 'a' (temp float)
|
0:99 'a' (temp float)
|
||||||
0:99 'b' (in float)
|
0:99 'b' (in float)
|
||||||
0:102 Function Definition: main( (global void)
|
0:102 Function Definition: matrix(mf23;mf32; (global 3X3 matrix of float)
|
||||||
0:102 Function Parameters:
|
0:102 Function Parameters:
|
||||||
|
0:102 'a' (in 2X3 matrix of float)
|
||||||
|
0:102 'b' (in 3X2 matrix of float)
|
||||||
|
0:103 Sequence
|
||||||
|
0:103 Sequence
|
||||||
|
0:103 move second child to first child (temp 2X3 matrix of float)
|
||||||
|
0:103 'c' (noContraction temp 2X3 matrix of float)
|
||||||
|
0:103 Constant:
|
||||||
|
0:103 1.000000
|
||||||
|
0:103 2.000000
|
||||||
|
0:103 3.000000
|
||||||
|
0:103 4.000000
|
||||||
|
0:103 5.000000
|
||||||
|
0:103 6.000000
|
||||||
|
0:105 move second child to first child (temp 3X3 matrix of float)
|
||||||
|
0:105 'result' (noContraction temp 3X3 matrix of float)
|
||||||
|
0:105 matrix-multiply (noContraction temp 3X3 matrix of float)
|
||||||
|
0:105 add (noContraction temp 2X3 matrix of float)
|
||||||
|
0:105 'a' (noContraction in 2X3 matrix of float)
|
||||||
|
0:105 'c' (noContraction temp 2X3 matrix of float)
|
||||||
|
0:105 'b' (noContraction in 3X2 matrix of float)
|
||||||
|
0:106 Branch: Return with expression
|
||||||
|
0:106 'result' (noContraction temp 3X3 matrix of float)
|
||||||
|
0:109 Function Definition: main( (global void)
|
||||||
|
0:109 Function Parameters:
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
|
|
||||||
|
|||||||
@@ -99,4 +99,11 @@ float precise_func_parameter(float b, precise out float c) {
|
|||||||
return a - b; // Not noContraction
|
return a - b; // Not noContraction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mat3 matrix (mat2x3 a, mat3x2 b) {
|
||||||
|
mat2x3 c = mat2x3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
|
||||||
|
precise mat3 result;
|
||||||
|
result = (a + c) * b; // should be noContraction
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void main(){}
|
void main(){}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ using ObjectAccessChain = std::string;
|
|||||||
|
|
||||||
// The delimiter used in the ObjectAccessChain string to separate symbol ID and
|
// The delimiter used in the ObjectAccessChain string to separate symbol ID and
|
||||||
// different level of struct indices.
|
// different level of struct indices.
|
||||||
const char OBJECT_ACCESSCHAIN_DELIMITER = '/';
|
const char ObjectAccesschainDelimiter = '/';
|
||||||
|
|
||||||
// Mapping from Symbol IDs of symbol nodes, to their defining operation
|
// Mapping from Symbol IDs of symbol nodes, to their defining operation
|
||||||
// nodes.
|
// nodes.
|
||||||
@@ -169,6 +169,7 @@ bool isArithmeticOperation(glslang::TOperator op)
|
|||||||
case glslang::EOpVectorTimesMatrix:
|
case glslang::EOpVectorTimesMatrix:
|
||||||
case glslang::EOpMatrixTimesVector:
|
case glslang::EOpMatrixTimesVector:
|
||||||
case glslang::EOpMatrixTimesScalar:
|
case glslang::EOpMatrixTimesScalar:
|
||||||
|
case glslang::EOpMatrixTimesMatrix:
|
||||||
|
|
||||||
case glslang::EOpDot:
|
case glslang::EOpDot:
|
||||||
|
|
||||||
@@ -207,14 +208,14 @@ private:
|
|||||||
// A helper function to get the front element from a given ObjectAccessChain
|
// A helper function to get the front element from a given ObjectAccessChain
|
||||||
ObjectAccessChain getFrontElement(const ObjectAccessChain& chain)
|
ObjectAccessChain getFrontElement(const ObjectAccessChain& chain)
|
||||||
{
|
{
|
||||||
size_t pos_delimiter = chain.find(OBJECT_ACCESSCHAIN_DELIMITER);
|
size_t pos_delimiter = chain.find(ObjectAccesschainDelimiter);
|
||||||
return pos_delimiter == std::string::npos ? chain : chain.substr(0, pos_delimiter);
|
return pos_delimiter == std::string::npos ? chain : chain.substr(0, pos_delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper function to get the accesschain starting from the second element.
|
// A helper function to get the accesschain starting from the second element.
|
||||||
ObjectAccessChain subAccessChainFromSecondElement(const ObjectAccessChain& chain)
|
ObjectAccessChain subAccessChainFromSecondElement(const ObjectAccessChain& chain)
|
||||||
{
|
{
|
||||||
size_t pos_delimiter = chain.find(OBJECT_ACCESSCHAIN_DELIMITER);
|
size_t pos_delimiter = chain.find(ObjectAccesschainDelimiter);
|
||||||
return pos_delimiter == std::string::npos ? "" : chain.substr(pos_delimiter + 1);
|
return pos_delimiter == std::string::npos ? "" : chain.substr(pos_delimiter + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +225,7 @@ ObjectAccessChain getSubAccessChainAfterPrefix(const ObjectAccessChain& chain,
|
|||||||
{
|
{
|
||||||
size_t pos = chain.find(prefix);
|
size_t pos = chain.find(prefix);
|
||||||
if (pos != 0) return chain;
|
if (pos != 0) return chain;
|
||||||
return chain.substr(prefix.length() + sizeof(OBJECT_ACCESSCHAIN_DELIMITER));
|
return chain.substr(prefix.length() + sizeof(ObjectAccesschainDelimiter));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -415,7 +416,7 @@ bool TSymbolDefinitionCollectingTraverser::visitBinary(glslang::TVisit /* visit
|
|||||||
// object. We need to record the accesschain information of the current
|
// object. We need to record the accesschain information of the current
|
||||||
// node into its object id.
|
// node into its object id.
|
||||||
unsigned struct_dereference_index = getStructIndexFromConstantUnion(node->getRight());
|
unsigned struct_dereference_index = getStructIndexFromConstantUnion(node->getRight());
|
||||||
object_to_be_defined_.push_back(OBJECT_ACCESSCHAIN_DELIMITER);
|
object_to_be_defined_.push_back(ObjectAccesschainDelimiter);
|
||||||
object_to_be_defined_.append(std::to_string(struct_dereference_index));
|
object_to_be_defined_.append(std::to_string(struct_dereference_index));
|
||||||
accesschain_mapping_[node] = object_to_be_defined_;
|
accesschain_mapping_[node] = object_to_be_defined_;
|
||||||
|
|
||||||
@@ -728,7 +729,7 @@ protected:
|
|||||||
if (remained_accesschain_.empty()) {
|
if (remained_accesschain_.empty()) {
|
||||||
node->getWritableType().getQualifier().noContraction = true;
|
node->getWritableType().getQualifier().noContraction = true;
|
||||||
} else {
|
} else {
|
||||||
new_precise_accesschain += OBJECT_ACCESSCHAIN_DELIMITER + remained_accesschain_;
|
new_precise_accesschain += ObjectAccesschainDelimiter + remained_accesschain_;
|
||||||
}
|
}
|
||||||
// Cache the accesschain as added precise object, so we won't add the
|
// Cache the accesschain as added precise object, so we won't add the
|
||||||
// same object to the worklist again.
|
// same object to the worklist again.
|
||||||
@@ -777,7 +778,7 @@ protected:
|
|||||||
if (remained_accesschain_.empty()) {
|
if (remained_accesschain_.empty()) {
|
||||||
node->getWritableType().getQualifier().noContraction = true;
|
node->getWritableType().getQualifier().noContraction = true;
|
||||||
} else {
|
} else {
|
||||||
new_precise_accesschain += OBJECT_ACCESSCHAIN_DELIMITER + remained_accesschain_;
|
new_precise_accesschain += ObjectAccesschainDelimiter + remained_accesschain_;
|
||||||
}
|
}
|
||||||
// Add the new 'precise' accesschain to the worklist and make sure we
|
// Add the new 'precise' accesschain to the worklist and make sure we
|
||||||
// don't visit it again.
|
// don't visit it again.
|
||||||
|
|||||||
Reference in New Issue
Block a user