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
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index d5038de..7a069ab 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -281,7 +281,7 @@
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);
- GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element;
+ GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element;
for (int i = 0; i < count; ++i)
{
@@ -343,7 +343,7 @@
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)
{
@@ -404,7 +404,7 @@
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);
- 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)
{
@@ -456,7 +456,7 @@
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);
- 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)
{
@@ -641,7 +641,7 @@
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);
- GLboolean *boolParams = (GLboolean*)targetUniform->data + mUniformIndex[location].element;
+ GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element;
for (int i = 0; i < count; ++i)
{
@@ -693,7 +693,7 @@
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);
- 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)
{
@@ -745,7 +745,7 @@
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);
- 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)
{
@@ -797,7 +797,7 @@
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);
- 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)
{
@@ -858,7 +858,7 @@
{
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)
{
@@ -933,11 +933,11 @@
{
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)
{
- params[i] = (GLint)boolParams[i];
+ params[i] = boolParams[i];
}
}
break;
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 4833d07..4e4c018 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -1304,6 +1304,10 @@
case GL_INT_VEC2:
case GL_INT_VEC3:
case GL_INT_VEC4:
+ 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;
@@ -1333,39 +1337,6 @@
}
}
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:
UNREACHABLE();
}
diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp
index 9640c0a..c9eb918 100644
--- a/src/libGLESv2/renderer/Renderer9.cpp
+++ b/src/libGLESv2/renderer/Renderer9.cpp
@@ -1636,17 +1636,16 @@
int count = targetUniform->elementCount();
GLfloat *f = (GLfloat*)targetUniform->data;
GLint *i = (GLint*)targetUniform->data;
- GLboolean *b = (GLboolean*)targetUniform->data;
switch (targetUniform->type)
{
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
break;
- case GL_BOOL: applyUniformnbv(targetUniform, count, 1, b); break;
- case GL_BOOL_VEC2: applyUniformnbv(targetUniform, count, 2, b); break;
- case GL_BOOL_VEC3: applyUniformnbv(targetUniform, count, 3, b); break;
- case GL_BOOL_VEC4: applyUniformnbv(targetUniform, count, 4, b); break;
+ case GL_BOOL: applyUniformnbv(targetUniform, count, 1, i); break;
+ case GL_BOOL_VEC2: applyUniformnbv(targetUniform, count, 2, i); break;
+ case GL_BOOL_VEC3: applyUniformnbv(targetUniform, count, 3, i); break;
+ case GL_BOOL_VEC4: applyUniformnbv(targetUniform, count, 4, i); break;
case GL_FLOAT:
case GL_FLOAT_VEC2:
case GL_FLOAT_VEC3:
@@ -1675,7 +1674,7 @@
}
}
-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];
diff --git a/src/libGLESv2/renderer/Renderer9.h b/src/libGLESv2/renderer/Renderer9.h
index 539e144..765b1b1 100644
--- a/src/libGLESv2/renderer/Renderer9.h
+++ b/src/libGLESv2/renderer/Renderer9.h
@@ -214,7 +214,7 @@
void applyUniform2iv(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 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);