Merge pull request #2646 from johnstiles-google/parseconst
Fix mat4x2(scalar) constructor.
This commit is contained in:
commit
e71278cc92
@ -242,6 +242,36 @@ Shader version: 130
|
|||||||
0:54 'un34' ( uniform 4X4 matrix of float)
|
0:54 'un34' ( uniform 4X4 matrix of float)
|
||||||
0:54 'um43' ( uniform 4X4 matrix of float)
|
0:54 'um43' ( uniform 4X4 matrix of float)
|
||||||
0:54 'v' ( smooth in 4-component vector of float)
|
0:54 'v' ( smooth in 4-component vector of float)
|
||||||
|
0:56 Sequence
|
||||||
|
0:56 move second child to first child ( temp 4X2 matrix of float)
|
||||||
|
0:56 'm42' ( temp 4X2 matrix of float)
|
||||||
|
0:56 Constant:
|
||||||
|
0:56 42.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 42.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:57 Test condition and select ( temp void)
|
||||||
|
0:57 Condition
|
||||||
|
0:57 Compare Equal ( temp bool)
|
||||||
|
0:57 'm42' ( temp 4X2 matrix of float)
|
||||||
|
0:57 Constant:
|
||||||
|
0:57 42.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 42.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 true case
|
||||||
|
0:58 Sequence
|
||||||
|
0:58 add second child into first child ( temp 4-component vector of float)
|
||||||
|
0:58 'gl_FragColor' ( fragColor 4-component vector of float FragColor)
|
||||||
|
0:58 'v' ( smooth in 4-component vector of float)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 'colorTransform' ( uniform 3X3 matrix of float)
|
0:? 'colorTransform' ( uniform 3X3 matrix of float)
|
||||||
0:? 'Color' ( smooth in 3-component vector of float)
|
0:? 'Color' ( smooth in 3-component vector of float)
|
||||||
@ -495,6 +525,36 @@ Shader version: 130
|
|||||||
0:54 'un34' ( uniform 4X4 matrix of float)
|
0:54 'un34' ( uniform 4X4 matrix of float)
|
||||||
0:54 'um43' ( uniform 4X4 matrix of float)
|
0:54 'um43' ( uniform 4X4 matrix of float)
|
||||||
0:54 'v' ( smooth in 4-component vector of float)
|
0:54 'v' ( smooth in 4-component vector of float)
|
||||||
|
0:56 Sequence
|
||||||
|
0:56 move second child to first child ( temp 4X2 matrix of float)
|
||||||
|
0:56 'm42' ( temp 4X2 matrix of float)
|
||||||
|
0:56 Constant:
|
||||||
|
0:56 42.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 42.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:56 0.000000
|
||||||
|
0:57 Test condition and select ( temp void)
|
||||||
|
0:57 Condition
|
||||||
|
0:57 Compare Equal ( temp bool)
|
||||||
|
0:57 'm42' ( temp 4X2 matrix of float)
|
||||||
|
0:57 Constant:
|
||||||
|
0:57 42.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 42.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 0.000000
|
||||||
|
0:57 true case
|
||||||
|
0:58 Sequence
|
||||||
|
0:58 add second child into first child ( temp 4-component vector of float)
|
||||||
|
0:58 'gl_FragColor' ( fragColor 4-component vector of float FragColor)
|
||||||
|
0:58 'v' ( smooth in 4-component vector of float)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 'colorTransform' ( uniform 3X3 matrix of float)
|
0:? 'colorTransform' ( uniform 3X3 matrix of float)
|
||||||
0:? 'Color' ( smooth in 3-component vector of float)
|
0:? 'Color' ( smooth in 3-component vector of float)
|
||||||
|
115
Test/matrix.frag
115
Test/matrix.frag
@ -1,55 +1,60 @@
|
|||||||
#version 130
|
#version 130
|
||||||
|
|
||||||
//#define TEST_POST_110
|
//#define TEST_POST_110
|
||||||
|
|
||||||
uniform mat3 colorTransform;
|
uniform mat3 colorTransform;
|
||||||
varying vec3 Color;
|
varying vec3 Color;
|
||||||
uniform mat4 m, n;
|
uniform mat4 m, n;
|
||||||
|
|
||||||
#ifdef TEST_POST_110
|
#ifdef TEST_POST_110
|
||||||
uniform mat4x3 um43;
|
uniform mat4x3 um43;
|
||||||
uniform mat3x4 un34;
|
uniform mat3x4 un34;
|
||||||
#else
|
#else
|
||||||
uniform mat4 um43;
|
uniform mat4 um43;
|
||||||
uniform mat4 un34;
|
uniform mat4 un34;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
varying vec4 v;
|
varying vec4 v;
|
||||||
|
|
||||||
#ifdef TEST_POST_110
|
#ifdef TEST_POST_110
|
||||||
varying vec3 u;
|
varying vec3 u;
|
||||||
#else
|
#else
|
||||||
varying vec4 u;
|
varying vec4 u;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_FragColor = vec4(un34[1]);
|
gl_FragColor = vec4(un34[1]);
|
||||||
gl_FragColor += vec4(Color * colorTransform, 1.0);
|
gl_FragColor += vec4(Color * colorTransform, 1.0);
|
||||||
|
|
||||||
if (m != n)
|
if (m != n)
|
||||||
gl_FragColor += v;
|
gl_FragColor += v;
|
||||||
else {
|
else {
|
||||||
gl_FragColor += m * v;
|
gl_FragColor += m * v;
|
||||||
gl_FragColor += v * (m - n);
|
gl_FragColor += v * (m - n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_POST_110
|
#ifdef TEST_POST_110
|
||||||
mat3x4 m34 = outerProduct(v, u);
|
mat3x4 m34 = outerProduct(v, u);
|
||||||
m34 += mat4(v.x);
|
m34 += mat4(v.x);
|
||||||
m34 += mat4(u, u.x, u, u.x, u, u.x, u.x);
|
m34 += mat4(u, u.x, u, u.x, u, u.x, u.x);
|
||||||
#else
|
#else
|
||||||
mat4 m34 = mat4(v.x*u.x, v.x*u.y, v.x*u.z, v.x*u.w,
|
mat4 m34 = mat4(v.x*u.x, v.x*u.y, v.x*u.z, v.x*u.w,
|
||||||
v.y*u.x, v.y*u.y, v.y*u.z, v.y*u.w,
|
v.y*u.x, v.y*u.y, v.y*u.z, v.y*u.w,
|
||||||
v.z*u.x, v.z*u.y, v.z*u.z, v.z*u.w,
|
v.z*u.x, v.z*u.y, v.z*u.z, v.z*u.w,
|
||||||
v.w*u.x, v.w*u.y, v.w*u.z, v.w*u.w);
|
v.w*u.x, v.w*u.y, v.w*u.z, v.w*u.w);
|
||||||
m34 += mat4(v.x);
|
m34 += mat4(v.x);
|
||||||
m34 += mat4(u, u.x, u, u.x, u, u.x, u.x);
|
m34 += mat4(u, u.x, u, u.x, u, u.x, u.x);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m34 == un34)
|
if (m34 == un34)
|
||||||
gl_FragColor += m34 * u;
|
gl_FragColor += m34 * u;
|
||||||
else
|
else
|
||||||
gl_FragColor += (un34 * um43) * v;
|
gl_FragColor += (un34 * um43) * v;
|
||||||
}
|
|
||||||
|
mat4x2 m42 = mat4x2(42);
|
||||||
|
if (m42 == mat4x2(42, 0, 0, 42, 0, 0, 0, 0)) {
|
||||||
|
gl_FragColor += v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -166,31 +166,30 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// matrix from vector or scalar
|
// matrix from vector or scalar
|
||||||
int count = 0;
|
|
||||||
const int startIndex = index;
|
|
||||||
int nodeComps = node->getType().computeNumComponents();
|
int nodeComps = node->getType().computeNumComponents();
|
||||||
for (int i = startIndex; i < endIndex; i++) {
|
if (nodeComps == 1) {
|
||||||
if (i >= instanceSize)
|
for (int c = 0; c < matrixCols; ++c) {
|
||||||
return;
|
for (int r = 0; r < matrixRows; ++r) {
|
||||||
if (nodeComps == 1) {
|
if (r == c)
|
||||||
// If there is a single scalar parameter to a matrix
|
leftUnionArray[index] = rightUnionArray[0];
|
||||||
// constructor, it is used to initialize all the
|
else
|
||||||
// components on the matrix's diagonal, with the
|
leftUnionArray[index].setDConst(0.0);
|
||||||
// remaining components initialized to 0.0.
|
index++;
|
||||||
if (i == startIndex || (i - startIndex) % (matrixRows + 1) == 0 )
|
}
|
||||||
leftUnionArray[i] = rightUnionArray[count];
|
}
|
||||||
else
|
} else {
|
||||||
leftUnionArray[i].setDConst(0.0);
|
int count = 0;
|
||||||
} else {
|
for (int i = index; i < endIndex; i++) {
|
||||||
|
if (i >= instanceSize)
|
||||||
|
return;
|
||||||
|
|
||||||
// construct the matrix in column-major order, from
|
// construct the matrix in column-major order, from
|
||||||
// the components provided, in order
|
// the components provided, in order
|
||||||
leftUnionArray[i] = rightUnionArray[count];
|
leftUnionArray[i] = rightUnionArray[count];
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (nodeComps > 1)
|
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user