Store boolean uniforms as 32-bit integers.

TRAC #22428 Signed-off-by: Geoff Lang Signed-off-by: Jamie Madill Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1896 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a14ecf36
...@@ -281,7 +281,7 @@ bool ProgramBinary::setUniform1fv(GLint location, GLsizei count, const GLfloat* ...@@ -281,7 +281,7 @@ bool ProgramBinary::setUniform1fv(GLint location, GLsizei count, const GLfloat*
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element;
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
...@@ -343,7 +343,7 @@ bool ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat * ...@@ -343,7 +343,7 @@ bool ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat *
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * 2; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 2;
for (int i = 0; i < count * 2; ++i) for (int i = 0; i < count * 2; ++i)
{ {
...@@ -404,7 +404,7 @@ bool ProgramBinary::setUniform3fv(GLint location, GLsizei count, const GLfloat * ...@@ -404,7 +404,7 @@ bool ProgramBinary::setUniform3fv(GLint location, GLsizei count, const GLfloat *
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * 3; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 3;
for (int i = 0; i < count * 3; ++i) for (int i = 0; i < count * 3; ++i)
{ {
...@@ -456,7 +456,7 @@ bool ProgramBinary::setUniform4fv(GLint location, GLsizei count, const GLfloat * ...@@ -456,7 +456,7 @@ bool ProgramBinary::setUniform4fv(GLint location, GLsizei count, const GLfloat *
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * 4; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 4; ++i) for (int i = 0; i < count * 4; ++i)
{ {
...@@ -641,7 +641,7 @@ bool ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v) ...@@ -641,7 +641,7 @@ bool ProgramBinary::setUniform1iv(GLint location, GLsizei count, const GLint *v)
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element;
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
...@@ -693,7 +693,7 @@ bool ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v) ...@@ -693,7 +693,7 @@ bool ProgramBinary::setUniform2iv(GLint location, GLsizei count, const GLint *v)
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * 2; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 2;
for (int i = 0; i < count * 2; ++i) for (int i = 0; i < count * 2; ++i)
{ {
...@@ -745,7 +745,7 @@ bool ProgramBinary::setUniform3iv(GLint location, GLsizei count, const GLint *v) ...@@ -745,7 +745,7 @@ bool ProgramBinary::setUniform3iv(GLint location, GLsizei count, const GLint *v)
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * 3; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 3;
for (int i = 0; i < count * 3; ++i) for (int i = 0; i < count * 3; ++i)
{ {
...@@ -797,7 +797,7 @@ bool ProgramBinary::setUniform4iv(GLint location, GLsizei count, const GLint *v) ...@@ -797,7 +797,7 @@ bool ProgramBinary::setUniform4iv(GLint location, GLsizei count, const GLint *v)
return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION return false; // attempting to write an array to a non-array uniform is an INVALID_OPERATION
count = std::min(elementCount - (int)mUniformIndex[location].element, count); count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * 4; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 4; ++i) for (int i = 0; i < count * 4; ++i)
{ {
...@@ -858,7 +858,7 @@ bool ProgramBinary::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *para ...@@ -858,7 +858,7 @@ bool ProgramBinary::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *para
{ {
case GL_BOOL: case GL_BOOL:
{ {
GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element * internalCount; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * internalCount;
for (unsigned int i = 0; i < count; ++i) for (unsigned int i = 0; i < count; ++i)
{ {
...@@ -933,11 +933,11 @@ bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params ...@@ -933,11 +933,11 @@ bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params
{ {
case GL_BOOL: case GL_BOOL:
{ {
GLboolean *boolParams = targetUniform->data + mUniformIndex[location].element * internalCount; GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * internalCount;
for (unsigned int i = 0; i < count; ++i) for (unsigned int i = 0; i < count; ++i)
{ {
params[i] = (GLint)boolParams[i]; params[i] = boolParams[i];
} }
} }
break; break;
......
...@@ -1304,6 +1304,10 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra ...@@ -1304,6 +1304,10 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
case GL_INT_VEC2: case GL_INT_VEC2:
case GL_INT_VEC3: case GL_INT_VEC3:
case GL_INT_VEC4: case GL_INT_VEC4:
case GL_BOOL:
case GL_BOOL_VEC2:
case GL_BOOL_VEC3:
case GL_BOOL_VEC4:
if (uniform->vsRegisterIndex >= 0 && mapVS) if (uniform->vsRegisterIndex >= 0 && mapVS)
{ {
int (*c)[4] = (int(*)[4])mapVS; int (*c)[4] = (int(*)[4])mapVS;
...@@ -1333,39 +1337,6 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra ...@@ -1333,39 +1337,6 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
} }
} }
break; break;
case GL_BOOL:
case GL_BOOL_VEC2:
case GL_BOOL_VEC3:
case GL_BOOL_VEC4:
if (uniform->vsRegisterIndex >= 0 && mapVS)
{
int (*c)[4] = (int(*)[4])mapVS;
GLboolean *b = (GLboolean*)uniform->data;
int count = gl::VariableColumnCount(uniform->type);
for (unsigned int i = 0; i < uniform->registerCount; i++)
{
if (count >= 1) c[uniform->vsRegisterIndex + i][0] = b[i * count + 0];
if (count >= 2) c[uniform->vsRegisterIndex + i][1] = b[i * count + 1];
if (count >= 3) c[uniform->vsRegisterIndex + i][2] = b[i * count + 2];
if (count >= 4) c[uniform->vsRegisterIndex + i][3] = b[i * count + 3];
}
}
if (uniform->psRegisterIndex >= 0 && mapPS)
{
int (*c)[4] = (int(*)[4])mapPS;
GLboolean *b = (GLboolean*)uniform->data;
int count = gl::VariableColumnCount(uniform->type);
for (unsigned int i = 0; i < uniform->registerCount; i++)
{
if (count >= 1) c[uniform->psRegisterIndex + i][0] = b[i * count + 0];
if (count >= 2) c[uniform->psRegisterIndex + i][1] = b[i * count + 1];
if (count >= 3) c[uniform->psRegisterIndex + i][2] = b[i * count + 2];
if (count >= 4) c[uniform->psRegisterIndex + i][3] = b[i * count + 3];
}
}
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -1636,17 +1636,16 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray ...@@ -1636,17 +1636,16 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray
int count = targetUniform->elementCount(); int count = targetUniform->elementCount();
GLfloat *f = (GLfloat*)targetUniform->data; GLfloat *f = (GLfloat*)targetUniform->data;
GLint *i = (GLint*)targetUniform->data; GLint *i = (GLint*)targetUniform->data;
GLboolean *b = (GLboolean*)targetUniform->data;
switch (targetUniform->type) switch (targetUniform->type)
{ {
case GL_SAMPLER_2D: case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE: case GL_SAMPLER_CUBE:
break; break;
case GL_BOOL: applyUniformnbv(targetUniform, count, 1, b); break; case GL_BOOL: applyUniformnbv(targetUniform, count, 1, i); break;
case GL_BOOL_VEC2: applyUniformnbv(targetUniform, count, 2, b); break; case GL_BOOL_VEC2: applyUniformnbv(targetUniform, count, 2, i); break;
case GL_BOOL_VEC3: applyUniformnbv(targetUniform, count, 3, b); break; case GL_BOOL_VEC3: applyUniformnbv(targetUniform, count, 3, i); break;
case GL_BOOL_VEC4: applyUniformnbv(targetUniform, count, 4, b); break; case GL_BOOL_VEC4: applyUniformnbv(targetUniform, count, 4, i); break;
case GL_FLOAT: case GL_FLOAT:
case GL_FLOAT_VEC2: case GL_FLOAT_VEC2:
case GL_FLOAT_VEC3: case GL_FLOAT_VEC3:
...@@ -1675,7 +1674,7 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray ...@@ -1675,7 +1674,7 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray
} }
} }
void Renderer9::applyUniformnbv(gl::Uniform *targetUniform, GLsizei count, int width, const GLboolean *v) void Renderer9::applyUniformnbv(gl::Uniform *targetUniform, GLsizei count, int width, const GLint *v)
{ {
float vector[D3D9_MAX_FLOAT_CONSTANTS * 4]; float vector[D3D9_MAX_FLOAT_CONSTANTS * 4];
......
...@@ -214,7 +214,7 @@ class Renderer9 : public Renderer ...@@ -214,7 +214,7 @@ class Renderer9 : public Renderer
void applyUniform2iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v); void applyUniform2iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v);
void applyUniform3iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v); void applyUniform3iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v);
void applyUniform4iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v); void applyUniform4iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v);
void applyUniformnbv(gl::Uniform *targetUniform, GLsizei count, int width, const GLboolean *v); void applyUniformnbv(gl::Uniform *targetUniform, GLsizei count, int width, const GLint *v);
void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment