Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bring back pre-GLSL1.20 matrix downcasts

  • Loading branch information...
commit 4f90f7f1aab989261c7611bf33dcbe6910a8652a 1 parent 84ee486
@aras-p authored
View
11 hlslang/GLSLCodeGen/glslOutput.cpp
@@ -1443,17 +1443,14 @@ bool TGlslOutputTraverser::traverseAggregate( bool preVisit, TIntermAggregate *n
case EOpConstructMat4x4: writeFuncCall( "mat4", node, goit); return false;
- /*
- case EOpConstructMat2FromMat:
- current->addLibFunction(EOpConstructMat2FromMat);
+ case EOpConstructMat2x2FromMat:
+ current->addLibFunction(EOpConstructMat2x2FromMat);
writeFuncCall( "xll_constructMat2", node, goit);
return false;
-
- case EOpConstructMat3FromMat:
- current->addLibFunction(EOpConstructMat3FromMat);
+ case EOpConstructMat3x3FromMat:
+ current->addLibFunction(EOpConstructMat3x3FromMat);
writeFuncCall( "xll_constructMat3", node, goit);
return false;
- */
case EOpConstructStruct: writeFuncCall( node->getTypePointer()->getTypeName(), node, goit); return false;
case EOpConstructArray: writeFuncCall( buildArrayConstructorString(*node->getTypePointer()), node, goit); return false;
View
29 hlslang/GLSLCodeGen/hlslSupportLib.cpp
@@ -441,22 +441,21 @@ void initializeHLSLSupportLibrary()
"#endif\n")
);
- /*
- hlslSupportLib->insert( CodeMap::value_type( EOpConstructMat2FromMat,
- "mat2 xll_constructMat2( mat3 m) {\n"
- " return mat2( vec2( m[0]), vec2( m[1]));\n"
- "}\n\n"
- "mat2 xll_constructMat2( mat4 m) {\n"
- " return mat2( vec2( m[0]), vec2( m[1]));\n"
- "}\n")
- );
- hlslSupportLib->insert( CodeMap::value_type( EOpConstructMat3FromMat,
- "mat3 xll_constructMat3( mat4 m) {\n"
- " return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));\n"
- "}\n")
- );
- */
+ // Used in pre-GLSL 1.20
+ hlslSupportLib->insert( CodeMap::value_type( EOpConstructMat2x2FromMat,
+ "mat2 xll_constructMat2( mat3 m) {\n"
+ " return mat2( vec2( m[0]), vec2( m[1]));\n"
+ "}\n\n"
+ "mat2 xll_constructMat2( mat4 m) {\n"
+ " return mat2( vec2( m[0]), vec2( m[1]));\n"
+ "}\n")
+ );
+ hlslSupportLib->insert( CodeMap::value_type( EOpConstructMat3x3FromMat,
+ "mat3 xll_constructMat3( mat4 m) {\n"
+ " return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));\n"
+ "}\n")
+ );
hlslSupportLib->insert( CodeMap::value_type( EOpDeterminant,
"float xll_determinant( mat2 m) {\n"
View
7 hlslang/Include/intermediate.h
@@ -15,6 +15,7 @@
#include "../Include/Common.h"
#include "../Include/Types.h"
+#include "../../include/hlsl2glsl.h"
//
// Operators used by the high-level (parse tree) representation.
@@ -529,7 +530,7 @@ class TIntermOperator : public TIntermTyped
TOperator getOp() const { return op; }
bool modifiesState() const;
bool isConstructor() const;
- virtual bool promote(TInfoSink&)
+ virtual bool promote(TInfoSink&, ETargetVersion targetVersion)
{
return true;
}
@@ -564,7 +565,7 @@ class TIntermBinary : public TIntermOperator
{
return this;
}
- virtual bool promote(TInfoSink&);
+ virtual bool promote(TInfoSink&, ETargetVersion targetVersion);
protected:
TIntermTyped* left;
@@ -588,7 +589,7 @@ class TIntermUnary : public TIntermOperator
void setOperand(TIntermTyped* o) { operand = o; }
TIntermTyped* getOperand() { return operand; }
- virtual bool promote(TInfoSink&);
+ virtual bool promote(TInfoSink&, ETargetVersion targetVersion);
private:
TIntermTyped* operand;
View
86 hlslang/MachineIndependent/Intermediate.cpp
@@ -39,7 +39,7 @@ TIntermSymbol* ir_add_symbol_internal(int id, const TString& name, const TTypeIn
// Connect two nodes with a new parent that does a binary operation on the nodes.
-TIntermTyped* ir_add_binary_math(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TInfoSink& infoSink)
+TIntermTyped* ir_add_binary_math(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion)
{
if (!left || !right)
return 0;
@@ -215,7 +215,7 @@ TIntermTyped* ir_add_binary_math(TOperator op, TIntermTyped* left, TIntermTyped*
node->setLeft(left);
node->setRight(right);
- if (! node->promote(infoSink))
+ if (! node->promote(infoSink, targetVersion))
return 0;
//
@@ -237,7 +237,7 @@ TIntermTyped* ir_add_binary_math(TOperator op, TIntermTyped* left, TIntermTyped*
// Connect two nodes through an assignment.
-TIntermTyped* ir_add_assign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TInfoSink& infoSink)
+TIntermTyped* ir_add_assign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion)
{
//
// Like adding binary math, except the conversion can only go
@@ -254,7 +254,7 @@ TIntermTyped* ir_add_assign(TOperator op, TIntermTyped* left, TIntermTyped* righ
node->setLeft(left);
node->setRight(child);
- if (! node->promote(infoSink))
+ if (! node->promote(infoSink, targetVersion))
return 0;
return node;
@@ -281,7 +281,7 @@ TIntermTyped* ir_add_index(TOperator op, TIntermTyped* base, TIntermTyped* index
// Add one node as the parent of another that it operates on.
-TIntermTyped* ir_add_unary_math(TOperator op, TIntermNode* childNode, TSourceLoc line, TInfoSink& infoSink)
+TIntermTyped* ir_add_unary_math(TOperator op, TIntermNode* childNode, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion)
{
TIntermUnary* node;
TIntermTyped* child = childNode->getAsTyped();
@@ -357,7 +357,7 @@ TIntermTyped* ir_add_unary_math(TOperator op, TIntermNode* childNode, TSourceLoc
node->setLine(line);
node->setOperand(child);
- if (! node->promote(infoSink))
+ if (! node->promote(infoSink, targetVersion))
return 0;
@@ -552,7 +552,7 @@ TIntermTyped* ir_add_conversion(TOperator op, const TType& type, TIntermTyped* n
}
}
-TIntermDeclaration* ir_add_declaration(TIntermSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink)
+TIntermDeclaration* ir_add_declaration(TIntermSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion)
{
TIntermDeclaration* decl = new TIntermDeclaration(symbol->getType());
decl->setLine(line);
@@ -560,31 +560,31 @@ TIntermDeclaration* ir_add_declaration(TIntermSymbol* symbol, TIntermTyped* init
if (!initializer)
decl->getDeclaration() = symbol;
else
- decl->getDeclaration() = ir_add_assign(EOpAssign, symbol, initializer, line, infoSink);
+ decl->getDeclaration() = ir_add_assign(EOpAssign, symbol, initializer, line, infoSink, targetVersion);
return decl;
}
-TIntermDeclaration* ir_add_declaration(TSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink)
+TIntermDeclaration* ir_add_declaration(TSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion)
{
TVariable* var = static_cast<TVariable*>(symbol);
TIntermSymbol* sym = ir_add_symbol(var, line);
- return ir_add_declaration(sym, initializer, line, infoSink);
+ return ir_add_declaration(sym, initializer, line, infoSink, targetVersion);
}
-TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink)
+TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink, ETargetVersion targetVersion)
{
TVariable* var = static_cast<TVariable*>(symbol);
TIntermSymbol* sym = ir_add_symbol(var, var->getType().getLine());
- return ir_grow_declaration(declaration, sym, initializer, infoSink);
+ return ir_grow_declaration(declaration, sym, initializer, infoSink, targetVersion);
}
-TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TIntermSymbol *symbol, TIntermTyped *initializer, TInfoSink& infoSink)
+TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TIntermSymbol *symbol, TIntermTyped *initializer, TInfoSink& infoSink, ETargetVersion targetVersion)
{
- TIntermTyped* added_decl = ir_add_declaration (symbol, initializer, symbol->getLine(), infoSink);
+ TIntermTyped* added_decl = ir_add_declaration (symbol, initializer, symbol->getLine(), infoSink, targetVersion);
if (declaration->getAsDeclaration()) {
TIntermAggregate* aggregate = ir_make_aggregate(declaration, declaration->getLine());
@@ -951,7 +951,7 @@ bool TIntermOperator::isConstructor() const
//
// Returns false in nothing makes sense.
//
-bool TIntermUnary::promote(TInfoSink&)
+bool TIntermUnary::promote(TInfoSink&, ETargetVersion targetVersion)
{
switch (op)
{
@@ -988,8 +988,22 @@ bool TIntermUnary::promote(TInfoSink&)
return true;
}
-static TOperator getMatrixConstructOp(const TIntermTyped& intermediate)
+static TOperator getMatrixConstructOp(const TIntermTyped& intermediate, ETargetVersion targetVersion)
{
+ // before GLSL 1.20, only square matrices
+ if (targetVersion < ETargetGLSL_120)
+ {
+ const int c = intermediate.getColsCount();
+ const int r = intermediate.getRowsCount();
+ if (c == 2 && r == 2)
+ return EOpConstructMat2x2FromMat;
+ if (c == 3 && r == 3)
+ return EOpConstructMat3x3FromMat;
+ if (c == 4 && r == 4)
+ return EOpConstructMat4x4;
+ return EOpNull; //@TODO: error?
+ }
+
switch (intermediate.getColsCount())
{
case 2:
@@ -1018,37 +1032,9 @@ static TOperator getMatrixConstructOp(const TIntermTyped& intermediate)
return EOpNull;
}
-static TOperator getDownConvertOp(const TIntermTyped& intermediate)
+static TOperator getDownConvertOp(const TIntermTyped& intermediate, ETargetVersion targetVersion)
{
- return getMatrixConstructOp(intermediate);
- /* implement EOpConstructMat?x?FromMat if support for glsl <1.20 is needed,
- switch (intermediate.getColsCount())
- {
- case 2:
- switch (intermediate.getRowsCount())
- {
- case 2: return EOpConstructMat2x2FromMat;
- case 3: return EOpConstructMat2x3FromMat;
- case 4: return EOpConstructMat2x4FromMat;
- } break;
- case 3:
- switch (intermediate.getRowsCount())
- {
- case 2: return EOpConstructMat3x2FromMat;
- case 3: return EOpConstructMat3x3FromMat;
- case 4: return EOpConstructMat3x4FromMat;
- } break;
- case 4:
- switch (intermediate.getRowsCount())
- {
- case 2: return EOpConstructMat4x2FromMat;
- case 3: return EOpConstructMat4x3FromMat;
- case 4: return EOpConstructMat4x4; //should never need to down convert to mat4
- } break;
- }
- assert(false);
- return EOpNull;
- */
+ return getMatrixConstructOp(intermediate, targetVersion);
}
@@ -1058,7 +1044,7 @@ static TOperator getDownConvertOp(const TIntermTyped& intermediate)
//
// Returns false if operator can't work on operands.
//
-bool TIntermBinary::promote(TInfoSink& infoSink)
+bool TIntermBinary::promote(TInfoSink& infoSink, ETargetVersion targetVersion)
{
TBasicType type = left->getBasicType();
@@ -1212,7 +1198,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
TOperator convert = EOpNull;
if (left->getTypePointer()->isMatrix())
{
- convert = getDownConvertOp(*right);
+ convert = getDownConvertOp(*right, targetVersion);
}
else if (left->getTypePointer()->isVector())
{
@@ -1243,7 +1229,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
TOperator convert = EOpNull;
if (right->getTypePointer()->isMatrix())
{
- convert = getDownConvertOp(*left);
+ convert = getDownConvertOp(*left, targetVersion);
}
else if (right->getTypePointer()->isVector())
{
@@ -1370,7 +1356,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
if (left->isMatrix() )
{
- convert = getMatrixConstructOp(*left);
+ convert = getMatrixConstructOp(*left, targetVersion);
}
else if (left->isVector() )
{
View
74 hlslang/MachineIndependent/ParseHelper.cpp
@@ -118,7 +118,7 @@ namespace {
TIntermTyped* TParseContext::add_binary(TOperator op, TIntermTyped* a, TIntermTyped* b, TSourceLoc line, const char* name, bool boolResult)
{
- TIntermTyped* res = ir_add_binary_math(op, a, b, line, infoSink);
+ TIntermTyped* res = ir_add_binary_math(op, a, b, line, infoSink, targetVersion);
if (res == NULL)
{
binaryOpError(line, name, a->getCompleteString(), b->getCompleteString());
@@ -1425,7 +1425,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
TIntermTyped* constructor = ir_set_aggregate_op(aggregate, op, line);
constructor->setType(*type);
if (!TransposeMatrixConstructorArgs (type, params))
- constructor = ir_add_unary_math (EOpTranspose, constructor, line, infoSink);
+ constructor = ir_add_unary_math (EOpTranspose, constructor, line, infoSink, targetVersion);
return constructor;
}
@@ -1607,13 +1607,13 @@ TIntermTyped* TParseContext::addAssign(TOperator op, TIntermTyped* left, TInterm
TIntermTyped *tNode;
- if ( (tNode = ir_add_assign(op,left,right,loc, infoSink)) == 0)
+ if ( (tNode = ir_add_assign(op,left,right,loc, infoSink, targetVersion)) == 0)
{
//need to convert
TOperator cop = getConstructorOp( left->getType());
TType type = left->getType();
tNode = constructBuiltIn( &type, cop, right, loc, false);
- tNode = ir_add_assign(op, left, tNode, loc, infoSink);
+ tNode = ir_add_assign(op, left, tNode, loc, infoSink, targetVersion);
}
return tNode;
@@ -1676,7 +1676,7 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
recover();
return 0;
}
- newNode = ir_add_unary_math(basicOp, node, node->getLine(), infoSink);
+ newNode = ir_add_unary_math(basicOp, node, node->getLine(), infoSink, targetVersion);
if (newNode == 0)
{
error(line, "can't convert", "constructor", "");
@@ -1702,31 +1702,45 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
if (newNode->getColsCount() < type->getColsCount() ||
newNode->getRowsCount() < type->getRowsCount())
return 0;
-
- switch (type->getColsCount())
- {
- case 2:
- switch (type->getRowsCount())
- {
- case 2: op = EOpConstructMat2x2; break;
- case 3: op = EOpConstructMat2x3; break;
- case 4: op = EOpConstructMat2x4; break;
- } break;
- case 3:
- switch (type->getRowsCount())
- {
- case 2: op = EOpConstructMat3x2; break;
- case 3: op = EOpConstructMat3x3; break;
- case 4: op = EOpConstructMat3x4; break;
- } break;
- case 4:
- switch (type->getRowsCount())
- {
- case 2: op = EOpConstructMat4x2; break;
- case 3: op = EOpConstructMat4x3; break;
- case 4: assert(false); break;
- } break;
- }
+
+ if (targetVersion < ETargetGLSL_120)
+ {
+ const int c = type->getColsCount();
+ const int r = type->getRowsCount();
+ if (c == 2 && r == 2)
+ op = EOpConstructMat2x2FromMat;
+ else if (c == 3 && r == 3)
+ op = EOpConstructMat3x3FromMat;
+ //@TODO: errors on others?
+ }
+ else
+ {
+
+ switch (type->getColsCount())
+ {
+ case 2:
+ switch (type->getRowsCount())
+ {
+ case 2: op = EOpConstructMat2x2; break;
+ case 3: op = EOpConstructMat2x3; break;
+ case 4: op = EOpConstructMat2x4; break;
+ } break;
+ case 3:
+ switch (type->getRowsCount())
+ {
+ case 2: op = EOpConstructMat3x2; break;
+ case 3: op = EOpConstructMat3x3; break;
+ case 4: op = EOpConstructMat3x4; break;
+ } break;
+ case 4:
+ switch (type->getRowsCount())
+ {
+ case 2: op = EOpConstructMat4x2; break;
+ case 3: op = EOpConstructMat4x3; break;
+ case 4: assert(false); break;
+ } break;
+ }
+ }
}
// will insert a new node for the constructor, as needed.
View
40 hlslang/MachineIndependent/hlslang.y
@@ -389,7 +389,7 @@ postfix_expression
| postfix_expression INC_OP {
if (parseContext.lValueErrorCheck($2.line, "++", $1))
parseContext.recover();
- $$ = ir_add_unary_math(EOpPostIncrement, $1, $2.line, parseContext.infoSink);
+ $$ = ir_add_unary_math(EOpPostIncrement, $1, $2.line, parseContext.infoSink, parseContext.targetVersion);
if ($$ == 0) {
parseContext.unaryOpError($2.line, "++", $1->getCompleteString());
parseContext.recover();
@@ -399,7 +399,7 @@ postfix_expression
| postfix_expression DEC_OP {
if (parseContext.lValueErrorCheck($2.line, "--", $1))
parseContext.recover();
- $$ = ir_add_unary_math(EOpPostDecrement, $1, $2.line, parseContext.infoSink);
+ $$ = ir_add_unary_math(EOpPostDecrement, $1, $2.line, parseContext.infoSink, parseContext.targetVersion);
if ($$ == 0) {
parseContext.unaryOpError($2.line, "--", $1->getCompleteString());
parseContext.recover();
@@ -492,7 +492,7 @@ function_call
//
// Treat it like a built-in unary operator.
//
- $$ = ir_add_unary_math(op, $1.intermNode, gNullSourceLoc, parseContext.infoSink);
+ $$ = ir_add_unary_math(op, $1.intermNode, gNullSourceLoc, parseContext.infoSink, parseContext.targetVersion);
if ($$ == 0) {
parseContext.error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
"built in unary operator function. Type: %s",
@@ -712,7 +712,7 @@ unary_expression
| INC_OP unary_expression {
if (parseContext.lValueErrorCheck($1.line, "++", $2))
parseContext.recover();
- $$ = ir_add_unary_math(EOpPreIncrement, $2, $1.line, parseContext.infoSink);
+ $$ = ir_add_unary_math(EOpPreIncrement, $2, $1.line, parseContext.infoSink, parseContext.targetVersion);
if ($$ == 0) {
parseContext.unaryOpError($1.line, "++", $2->getCompleteString());
parseContext.recover();
@@ -722,7 +722,7 @@ unary_expression
| DEC_OP unary_expression {
if (parseContext.lValueErrorCheck($1.line, "--", $2))
parseContext.recover();
- $$ = ir_add_unary_math(EOpPreDecrement, $2, $1.line, parseContext.infoSink);
+ $$ = ir_add_unary_math(EOpPreDecrement, $2, $1.line, parseContext.infoSink, parseContext.targetVersion);
if ($$ == 0) {
parseContext.unaryOpError($1.line, "--", $2->getCompleteString());
parseContext.recover();
@@ -731,7 +731,7 @@ unary_expression
}
| unary_operator unary_expression {
if ($1.op != EOpNull) {
- $$ = ir_add_unary_math($1.op, $2, $1.line, parseContext.infoSink);
+ $$ = ir_add_unary_math($1.op, $2, $1.line, parseContext.infoSink, parseContext.targetVersion);
if ($$ == 0) {
const char* errorOp = "";
switch($1.op) {
@@ -1275,7 +1275,7 @@ init_declarator_list
if (!sym)
$$ = $1;
else
- $$ = ir_grow_declaration($1, sym, NULL, parseContext.infoSink);
+ $$ = ir_grow_declaration($1, sym, NULL, parseContext.infoSink, parseContext.targetVersion);
}
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET type_info {
TPublicType type = ir_get_decl_type_noarray($1);
@@ -1297,7 +1297,7 @@ init_declarator_list
$$ = $1;
else {
variable->getType().setArray(true);
- $$ = ir_grow_declaration($1, variable, NULL, parseContext.infoSink);
+ $$ = ir_grow_declaration($1, variable, NULL, parseContext.infoSink, parseContext.targetVersion);
}
}
}
@@ -1325,7 +1325,7 @@ init_declarator_list
if (!variable)
$$ = $1;
else {
- $$ = ir_grow_declaration($1, variable, NULL, parseContext.infoSink);
+ $$ = ir_grow_declaration($1, variable, NULL, parseContext.infoSink, parseContext.targetVersion);
}
}
}
@@ -1348,7 +1348,7 @@ init_declarator_list
if (!variable)
$$ = $1;
else {
- $$ = ir_grow_declaration($1, variable, $8, parseContext.infoSink);
+ $$ = ir_grow_declaration($1, variable, $8, parseContext.infoSink, parseContext.targetVersion);
}
} else {
parseContext.recover();
@@ -1381,7 +1381,7 @@ init_declarator_list
if (!variable)
$$ = $1;
else {
- $$ = ir_grow_declaration($1, variable, $9, parseContext.infoSink);
+ $$ = ir_grow_declaration($1, variable, $9, parseContext.infoSink, parseContext.targetVersion);
}
} else {
parseContext.recover();
@@ -1402,7 +1402,7 @@ init_declarator_list
if (!variable)
$$ = $1;
else
- $$ = ir_grow_declaration($1, variable, $6, parseContext.infoSink);
+ $$ = ir_grow_declaration($1, variable, $6, parseContext.infoSink, parseContext.targetVersion);
} else {
parseContext.recover();
$$ = 0;
@@ -1439,7 +1439,7 @@ single_declaration
TSymbol* symbol = parseContext.symbolTable.find(*$2.string);
if (!error && symbol) {
- $$ = ir_add_declaration(symbol, NULL, $2.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, NULL, $2.line, parseContext.infoSink, parseContext.targetVersion);
} else {
$$ = 0;
}
@@ -1462,7 +1462,7 @@ single_declaration
TSymbol* symbol = parseContext.symbolTable.find(*$2.string);
if (symbol) {
- $$ = ir_add_declaration(symbol, NULL, $2.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, NULL, $2.line, parseContext.infoSink, parseContext.targetVersion);
} else {
$$ = 0;
}
@@ -1487,7 +1487,7 @@ single_declaration
parseContext.recover();
if (variable) {
- $$ = ir_add_declaration(variable, NULL, $2.line, parseContext.infoSink);
+ $$ = ir_add_declaration(variable, NULL, $2.line, parseContext.infoSink, parseContext.targetVersion);
} else {
$$ = 0;
}
@@ -1510,7 +1510,7 @@ single_declaration
TIntermSymbol* symbol;
if (!parseContext.executeInitializer($2.line, *$2.string, $5, $1, $7, symbol, variable)) {
if (variable)
- $$ = ir_add_declaration(symbol, $7, $6.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, $7, $6.line, parseContext.infoSink, parseContext.targetVersion);
else
$$ = 0;
} else {
@@ -1540,7 +1540,7 @@ single_declaration
TIntermSymbol* symbol;
if (!parseContext.executeInitializer($2.line, *$2.string, $6, $1, $8, symbol, variable)) {
if (variable)
- $$ = ir_add_declaration(symbol, $8, $7.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, $8, $7.line, parseContext.infoSink, parseContext.targetVersion);
else
$$ = 0;
} else {
@@ -1557,7 +1557,7 @@ single_declaration
TIntermSymbol* symbol;
if (!parseContext.executeInitializer($2.line, *$2.string, $3, $1, $5, symbol)) {
if (symbol)
- $$ = ir_add_declaration(symbol, $5, $4.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, $5, $4.line, parseContext.infoSink, parseContext.targetVersion);
else
$$ = 0;
} else {
@@ -1576,7 +1576,7 @@ single_declaration
TSymbol* symbol = parseContext.symbolTable.find(*$2.string);
if (symbol) {
- $$ = ir_add_declaration(symbol, NULL, $2.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, NULL, $2.line, parseContext.infoSink, parseContext.targetVersion);
} else {
$$ = 0;
}
@@ -2145,7 +2145,7 @@ condition
parseContext.recover();
if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, symbol)) {
- $$ = ir_add_declaration(symbol, $4, $2.line, parseContext.infoSink);
+ $$ = ir_add_declaration(symbol, $4, $2.line, parseContext.infoSink, parseContext.targetVersion);
} else {
parseContext.recover();
$$ = 0;
View
4 hlslang/MachineIndependent/intermOut.cpp
@@ -265,8 +265,8 @@ bool OutputAggregate(bool, /* preVisit */ TIntermAggregate* node, TIntermTravers
case EOpConstructMat4x3: out.debug << "Construct mat4x3"; break;
case EOpConstructMat4x4: out.debug << "Construct mat4x4"; break;
case EOpConstructStruct: out.debug << "Construct struc"; break;
- //case EOpConstructMat2FromMat: out.debug << "Construct mat2 from mat"; break;
- //case EOpConstructMat3FromMat: out.debug << "Construct mat3 from mat"; break;
+ case EOpConstructMat2x2FromMat: out.debug << "Construct mat2 from mat"; break;
+ case EOpConstructMat3x3FromMat: out.debug << "Construct mat3 from mat"; break;
case EOpMatrixIndex: out.debug << "Matrix index"; break;
case EOpMatrixIndexDynamic: out.debug << "Matrix index dynamic"; break;
View
14 hlslang/MachineIndependent/localintermediate.h
@@ -27,8 +27,8 @@ TIntermConstant* ir_add_constant(const TType&, TSourceLoc);
TIntermTyped* ir_add_index(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
TIntermTyped* ir_add_comma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
-TIntermTyped* ir_add_unary_math(TOperator op, TIntermNode* child, TSourceLoc, TInfoSink& infoSink);
-TIntermTyped* ir_add_binary_math(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TInfoSink& infoSink);
+TIntermTyped* ir_add_unary_math(TOperator op, TIntermNode* child, TSourceLoc, TInfoSink& infoSink, ETargetVersion targetVersion);
+TIntermTyped* ir_add_binary_math(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TInfoSink& infoSink, ETargetVersion targetVersion);
TIntermNode* ir_add_selection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc, TInfoSink& infoSink);
TIntermTyped* ir_add_selection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc, TInfoSink& infoSink);
TIntermBranch* ir_add_branch(TOperator, TSourceLoc);
@@ -36,9 +36,9 @@ TIntermBranch* ir_add_branch(TOperator, TIntermTyped*, TSourceLoc);
TIntermNode* ir_add_loop(TLoopType type, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, TSourceLoc line);
TIntermTyped* ir_add_swizzle(TVectorFields&, TSourceLoc);
TIntermTyped* ir_add_vector_swizzle(TVectorFields& fields, TIntermTyped* arg, TSourceLoc lineDot, TSourceLoc lineIndex);
-TIntermTyped* ir_add_assign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TInfoSink& infoSink);
-TIntermDeclaration* ir_add_declaration(TIntermSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink);
-TIntermDeclaration* ir_add_declaration(TSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink);
+TIntermTyped* ir_add_assign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TInfoSink& infoSink, ETargetVersion targetVersion);
+TIntermDeclaration* ir_add_declaration(TIntermSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion);
+TIntermDeclaration* ir_add_declaration(TSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink, ETargetVersion targetVersion);
TIntermTyped* ir_add_conversion(TOperator, const TType&, TIntermTyped*, TInfoSink& infoSink);
@@ -46,8 +46,8 @@ TIntermTyped* ir_promote_constant(TBasicType, TIntermConstant*, TInfoSink& infoS
TIntermAggregate* ir_grow_aggregate(TIntermNode* left, TIntermNode* right, TSourceLoc, TOperator expectedOp = EOpNull);
TIntermAggregate* ir_make_aggregate(TIntermNode* node, TSourceLoc);
TIntermAggregate* ir_set_aggregate_op(TIntermNode*, TOperator, TSourceLoc);
-TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TIntermSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink);
-TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink);
+TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TIntermSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink, ETargetVersion targetVersion);
+TIntermAggregate* ir_grow_declaration(TIntermTyped* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink, ETargetVersion targetVersion);
void ir_output_tree(TIntermNode* root, TInfoSink& infoSink);
View
6 tests/vertex/loops-for-out.txt
@@ -1,4 +1,6 @@
-
+mat3 xll_constructMat3( mat4 m) {
+ return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
+}
#line 14
struct v2f {
vec4 pos;
@@ -23,7 +25,7 @@ v2f xlat_main( in appdata v );
#line 19
vec3 ShadeMyVertexLights( in vec4 vertex, in vec3 normal ) {
vec3 viewpos = (UNITY_MATRIX_MV * vertex).xyz;
- vec3 viewN = (mat3( UNITY_MATRIX_IT_MV) * normal);
+ vec3 viewN = (xll_constructMat3( UNITY_MATRIX_IT_MV) * normal);
#line 23
vec3 lightColor = vec3( 0.0, 0.0, 0.0);
int i = 0;
View
6 tests/vertex/loops-for-outES.txt
@@ -1,4 +1,6 @@
-
+mat3 xll_constructMat3( mat4 m) {
+ return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
+}
#line 14
struct v2f {
mediump vec4 pos;
@@ -23,7 +25,7 @@ v2f xlat_main( in appdata v );
#line 19
highp vec3 ShadeMyVertexLights( in highp vec4 vertex, in highp vec3 normal ) {
highp vec3 viewpos = (UNITY_MATRIX_MV * vertex).xyz;
- highp vec3 viewN = (mat3( UNITY_MATRIX_IT_MV) * normal);
+ highp vec3 viewN = (xll_constructMat3( UNITY_MATRIX_IT_MV) * normal);
#line 23
highp vec3 lightColor = vec3( 0.0, 0.0, 0.0);
highp int i = 0;
View
7 tests/vertex/z-mia-lightmap-out.txt
@@ -12,6 +12,9 @@ mat4 xll_transpose(mat4 m) {
m[0][2], m[1][2], m[2][2], m[3][2],
m[0][3], m[1][3], m[2][3], m[3][3]);
}
+mat3 xll_constructMat3( mat4 m) {
+ return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
+}
vec2 xll_matrixindex (mat2 m, int i) { vec2 v; v.x=m[0][i]; v.y=m[1][i]; return v; }
vec3 xll_matrixindex (mat3 m, int i) { vec3 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; return v; }
vec4 xll_matrixindex (mat4 m, int i) { vec4 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; v.w=m[3][i]; return v; }
@@ -183,7 +186,7 @@ v2f_surf xlat_main( in appdata_full v ) {
#line 432
o.worldPos = (_Object2World * v.vertex).xyz;
vec3 viewDir = (-ObjSpaceViewDir( v.vertex));
- vec3 worldRefl = (mat3( _Object2World) * viewDir);
+ vec3 worldRefl = (xll_constructMat3( _Object2World) * viewDir);
vec3 binormal = (cross( normalize(v.normal), normalize(v.tangent.xyz)) * v.tangent.w);
#line 436
mat3 rotation = xll_transpose(mat3( v.tangent.xyz, binormal, v.normal));
@@ -196,7 +199,7 @@ v2f_surf xlat_main( in appdata_full v ) {
o.lmap.z = (length(((_Object2World * v.vertex).xyz - unity_ShadowFadeCenterAndType.xyz)) * unity_ShadowFadeCenterAndType.w);
o.lmap.w = ((-(glstate_matrix_modelview0 * v.vertex).z) * (1.0 - unity_ShadowFadeCenterAndType.w));
#line 444
- vec3 worldN = (mat3( _Object2World) * (v.normal * unity_Scale.w));
+ vec3 worldN = (xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w));
vec3 lightDir = (rotation * ObjSpaceLightDir( v.vertex));
o.lightDir = lightDir;
vec3 viewDirForLight = (rotation * ObjSpaceViewDir( v.vertex));
View
7 tests/vertex/z-mia-lightmap-outES.txt
@@ -12,6 +12,9 @@ mat4 xll_transpose(mat4 m) {
m[0][2], m[1][2], m[2][2], m[3][2],
m[0][3], m[1][3], m[2][3], m[3][3]);
}
+mat3 xll_constructMat3( mat4 m) {
+ return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
+}
vec2 xll_matrixindex (mat2 m, int i) { vec2 v; v.x=m[0][i]; v.y=m[1][i]; return v; }
vec3 xll_matrixindex (mat3 m, int i) { vec3 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; return v; }
vec4 xll_matrixindex (mat4 m, int i) { vec4 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; v.w=m[3][i]; return v; }
@@ -183,7 +186,7 @@ v2f_surf xlat_main( in appdata_full v ) {
#line 432
o.worldPos = (_Object2World * v.vertex).xyz;
highp vec3 viewDir = (-ObjSpaceViewDir( v.vertex));
- highp vec3 worldRefl = (mat3( _Object2World) * viewDir);
+ highp vec3 worldRefl = (xll_constructMat3( _Object2World) * viewDir);
highp vec3 binormal = (cross( normalize(v.normal), normalize(v.tangent.xyz)) * v.tangent.w);
#line 436
highp mat3 rotation = xll_transpose(mat3( v.tangent.xyz, binormal, v.normal));
@@ -196,7 +199,7 @@ v2f_surf xlat_main( in appdata_full v ) {
o.lmap.z = (length(((_Object2World * v.vertex).xyz - unity_ShadowFadeCenterAndType.xyz)) * unity_ShadowFadeCenterAndType.w);
o.lmap.w = ((-(glstate_matrix_modelview0 * v.vertex).z) * (1.0 - unity_ShadowFadeCenterAndType.w));
#line 444
- highp vec3 worldN = (mat3( _Object2World) * (v.normal * unity_Scale.w));
+ highp vec3 worldN = (xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w));
highp vec3 lightDir = (rotation * ObjSpaceLightDir( v.vertex));
o.lightDir = lightDir;
highp vec3 viewDirForLight = (rotation * ObjSpaceViewDir( v.vertex));
View
7 tests/vertex/z-mia-rt-out.txt
@@ -12,6 +12,9 @@ mat4 xll_transpose(mat4 m) {
m[0][2], m[1][2], m[2][2], m[3][2],
m[0][3], m[1][3], m[2][3], m[3][3]);
}
+mat3 xll_constructMat3( mat4 m) {
+ return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
+}
vec2 xll_matrixindex (mat2 m, int i) { vec2 v; v.x=m[0][i]; v.y=m[1][i]; return v; }
vec3 xll_matrixindex (mat3 m, int i) { vec3 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; return v; }
vec4 xll_matrixindex (mat4 m, int i) { vec4 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; v.w=m[3][i]; return v; }
@@ -183,14 +186,14 @@ v2f_surf xlat_main( in appdata_full v ) {
o.worldPos = (_Object2World * v.vertex).xyz;
vec3 viewDir = (-ObjSpaceViewDir( v.vertex));
#line 424
- vec3 worldRefl = (mat3( _Object2World) * viewDir);
+ vec3 worldRefl = (xll_constructMat3( _Object2World) * viewDir);
vec3 binormal = (cross( normalize(v.normal), normalize(v.tangent.xyz)) * v.tangent.w);
mat3 rotation = xll_transpose(mat3( v.tangent.xyz, binormal, v.normal));
o.TtoW0 = (vec4( (rotation * xll_matrixindex (_Object2World, 0).xyz), worldRefl.x) * unity_Scale.w);
#line 428
o.TtoW1 = (vec4( (rotation * xll_matrixindex (_Object2World, 1).xyz), worldRefl.y) * unity_Scale.w);
o.TtoW2 = (vec4( (rotation * xll_matrixindex (_Object2World, 2).xyz), worldRefl.z) * unity_Scale.w);
- vec3 worldN = (mat3( _Object2World) * (v.normal * unity_Scale.w));
+ vec3 worldN = (xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w));
vec3 lightDir = (rotation * ObjSpaceLightDir( v.vertex));
#line 432
o.lightDir = lightDir;
View
7 tests/vertex/z-mia-rt-outES.txt
@@ -12,6 +12,9 @@ mat4 xll_transpose(mat4 m) {
m[0][2], m[1][2], m[2][2], m[3][2],
m[0][3], m[1][3], m[2][3], m[3][3]);
}
+mat3 xll_constructMat3( mat4 m) {
+ return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
+}
vec2 xll_matrixindex (mat2 m, int i) { vec2 v; v.x=m[0][i]; v.y=m[1][i]; return v; }
vec3 xll_matrixindex (mat3 m, int i) { vec3 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; return v; }
vec4 xll_matrixindex (mat4 m, int i) { vec4 v; v.x=m[0][i]; v.y=m[1][i]; v.z=m[2][i]; v.w=m[3][i]; return v; }
@@ -183,14 +186,14 @@ v2f_surf xlat_main( in appdata_full v ) {
o.worldPos = (_Object2World * v.vertex).xyz;
highp vec3 viewDir = (-ObjSpaceViewDir( v.vertex));
#line 424
- highp vec3 worldRefl = (mat3( _Object2World) * viewDir);
+ highp vec3 worldRefl = (xll_constructMat3( _Object2World) * viewDir);
highp vec3 binormal = (cross( normalize(v.normal), normalize(v.tangent.xyz)) * v.tangent.w);
highp mat3 rotation = xll_transpose(mat3( v.tangent.xyz, binormal, v.normal));
o.TtoW0 = (vec4( (rotation * xll_matrixindex (_Object2World, 0).xyz), worldRefl.x) * unity_Scale.w);
#line 428
o.TtoW1 = (vec4( (rotation * xll_matrixindex (_Object2World, 1).xyz), worldRefl.y) * unity_Scale.w);
o.TtoW2 = (vec4( (rotation * xll_matrixindex (_Object2World, 2).xyz), worldRefl.z) * unity_Scale.w);
- highp vec3 worldN = (mat3( _Object2World) * (v.normal * unity_Scale.w));
+ highp vec3 worldN = (xll_constructMat3( _Object2World) * (v.normal * unity_Scale.w));
highp vec3 lightDir = (rotation * ObjSpaceLightDir( v.vertex));
#line 432
o.lightDir = lightDir;

0 comments on commit 4f90f7f

Please sign in to comment.
Something went wrong with that request. Please try again.