Store integer and boolean uniforms in 4-element vectors.

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@1897 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent cd714ef2
......@@ -260,7 +260,6 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLfloat *target = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++)
......@@ -281,18 +280,16 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0.0f)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[1] = GL_FALSE;
boolParams[2] = GL_FALSE;
boolParams[3] = GL_FALSE;
boolParams += 4;
v += 1;
}
}
else
......@@ -321,7 +318,6 @@ bool ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat *
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);
GLfloat *target = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++)
......@@ -342,19 +338,16 @@ bool ProgramBinary::setUniform2fv(GLint location, GLsizei count, const GLfloat *
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);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 2;
for (int i = 0; i < count * 2; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0.0f)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[1] = (v[1] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[2] = GL_FALSE;
boolParams[3] = GL_FALSE;
boolParams += 4;
v += 2;
}
}
else
......@@ -383,7 +376,6 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLfloat *target = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; i++)
......@@ -404,18 +396,16 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 3;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 3; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0.0f)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[1] = (v[1] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[2] = (v[2] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[3] = GL_FALSE;
boolParams += 4;
v += 3;
}
}
else
......@@ -444,9 +434,17 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLfloat *target = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4;
memcpy(targetUniform->data + mUniformIndex[location].element * sizeof(GLfloat) * 4,
v, 4 * sizeof(GLfloat) * count);
for (int i = 0; i < count; i++)
{
target[0] = v[0];
target[1] = v[1];
target[2] = v[2];
target[3] = v[3];
target += 4;
v += 4;
}
}
else if (targetUniform->type == GL_BOOL_VEC4)
{
......@@ -458,16 +456,14 @@ bool ProgramBinary::setUniform4fv(GLint location, GLsizei count, const GLfloat *
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 4; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0.0f)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[1] = (v[1] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[2] = (v[2] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams[3] = (v[3] == 0.0f) ? GL_FALSE : GL_TRUE;
boolParams += 4;
v += 4;
}
}
else
......@@ -530,8 +526,8 @@ bool ProgramBinary::setUniformMatrix2fv(GLint location, GLsizei count, const GLf
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);
GLfloat *target = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 8;
for (int i = 0; i < count; i++)
{
transposeMatrix<GLfloat,4,2,2,2>(target, value);
......@@ -563,8 +559,8 @@ bool ProgramBinary::setUniformMatrix3fv(GLint location, GLsizei count, const GLf
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);
GLfloat *target = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 12;
for (int i = 0; i < count; i++)
{
transposeMatrix<GLfloat,4,3,3,3>(target, value);
......@@ -597,8 +593,8 @@ bool ProgramBinary::setUniformMatrix4fv(GLint location, GLsizei count, const GLf
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);
GLfloat *target = (GLfloat*)(targetUniform->data + mUniformIndex[location].element * sizeof(GLfloat) * 16);
for (int i = 0; i < count; i++)
{
transposeMatrix<GLfloat,4,4,4,4>(target, value);
......@@ -629,9 +625,17 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *target = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
memcpy(targetUniform->data + mUniformIndex[location].element * sizeof(GLint),
v, sizeof(GLint) * count);
for (int i = 0; i < count; i++)
{
target[0] = v[0];
target[1] = 0;
target[2] = 0;
target[3] = 0;
target += 4;
v += 1;
}
}
else if (targetUniform->type == GL_BOOL)
{
......@@ -641,18 +645,16 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
boolParams[1] = GL_FALSE;
boolParams[2] = GL_FALSE;
boolParams[3] = GL_FALSE;
boolParams += 4;
v += 1;
}
}
else
......@@ -681,9 +683,17 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *target = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
memcpy(targetUniform->data + mUniformIndex[location].element * sizeof(GLint) * 2,
v, 2 * sizeof(GLint) * count);
for (int i = 0; i < count; i++)
{
target[0] = v[0];
target[1] = v[1];
target[2] = 0;
target[3] = 0;
target += 4;
v += 2;
}
}
else if (targetUniform->type == GL_BOOL_VEC2)
{
......@@ -693,18 +703,16 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 2;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 2; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
boolParams[1] = (v[1] == 0) ? GL_FALSE : GL_TRUE;
boolParams[2] = GL_FALSE;
boolParams[3] = GL_FALSE;
boolParams += 4;
v += 2;
}
}
else
......@@ -733,9 +741,17 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *target = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
memcpy(targetUniform->data + mUniformIndex[location].element * sizeof(GLint) * 3,
v, 3 * sizeof(GLint) * count);
for (int i = 0; i < count; i++)
{
target[0] = v[0];
target[1] = v[1];
target[2] = v[2];
target[3] = 0;
target += 4;
v += 3;
}
}
else if (targetUniform->type == GL_BOOL_VEC3)
{
......@@ -745,18 +761,16 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 3;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 3; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
boolParams[1] = (v[1] == 0) ? GL_FALSE : GL_TRUE;
boolParams[2] = (v[2] == 0) ? GL_FALSE : GL_TRUE;
boolParams[3] = GL_FALSE;
boolParams += 4;
v += 3;
}
}
else
......@@ -785,9 +799,17 @@ 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
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *target = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
memcpy(targetUniform->data + mUniformIndex[location].element * sizeof(GLint) * 4,
v, 4 * sizeof(GLint) * count);
for (int i = 0; i < count; i++)
{
target[0] = v[0];
target[1] = v[1];
target[2] = v[2];
target[3] = v[3];
target += 4;
v += 4;
}
}
else if (targetUniform->type == GL_BOOL_VEC4)
{
......@@ -799,16 +821,14 @@ bool ProgramBinary::setUniform4iv(GLint location, GLsizei count, const GLint *v)
count = std::min(elementCount - (int)mUniformIndex[location].element, count);
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (int i = 0; i < count * 4; ++i)
for (int i = 0; i < count; i++)
{
if (v[i] == 0)
{
boolParams[i] = GL_FALSE;
}
else
{
boolParams[i] = GL_TRUE;
}
boolParams[0] = (v[0] == 0) ? GL_FALSE : GL_TRUE;
boolParams[1] = (v[1] == 0) ? GL_FALSE : GL_TRUE;
boolParams[2] = (v[2] == 0) ? GL_FALSE : GL_TRUE;
boolParams[3] = (v[3] == 0) ? GL_FALSE : GL_TRUE;
boolParams += 4;
v += 4;
}
}
else
......@@ -851,30 +871,29 @@ bool ProgramBinary::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *para
break;
default:
{
unsigned int count = UniformExternalComponentCount(targetUniform->type);
unsigned int internalCount = UniformInternalComponentCount(targetUniform->type);
unsigned int size = UniformComponentCount(targetUniform->type);
switch (UniformComponentType(targetUniform->type))
{
case GL_BOOL:
{
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * internalCount;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (unsigned int i = 0; i < count; ++i)
for (unsigned int i = 0; i < size; i++)
{
params[i] = (boolParams[i] == GL_FALSE) ? 0.0f : 1.0f;
}
}
break;
case GL_FLOAT:
memcpy(params, targetUniform->data + mUniformIndex[location].element * internalCount * sizeof(GLfloat),
count * sizeof(GLfloat));
memcpy(params, targetUniform->data + mUniformIndex[location].element * 4 * sizeof(GLfloat),
size * sizeof(GLfloat));
break;
case GL_INT:
{
GLint *intParams = (GLint*)targetUniform->data + mUniformIndex[location].element * internalCount;
GLint *intParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (unsigned int i = 0; i < count; ++i)
for (unsigned int i = 0; i < size; i++)
{
params[i] = (float)intParams[i];
}
......@@ -910,32 +929,25 @@ bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params
switch (targetUniform->type)
{
case GL_FLOAT_MAT2:
{
transposeMatrix<GLint,2,2,4,2>(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 8);
}
transposeMatrix<GLint,2,2,4,2>(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 8);
break;
case GL_FLOAT_MAT3:
{
transposeMatrix<GLint,3,3,4,3>(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 12);
}
transposeMatrix<GLint,3,3,4,3>(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 12);
break;
case GL_FLOAT_MAT4:
{
transposeMatrix<GLint,4,4,4,4>(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 16);
}
transposeMatrix<GLint,4,4,4,4>(params, (GLfloat*)targetUniform->data + mUniformIndex[location].element * 16);
break;
default:
{
unsigned int count = UniformExternalComponentCount(targetUniform->type);
unsigned int internalCount = UniformInternalComponentCount(targetUniform->type);
unsigned int size = VariableColumnCount(targetUniform->type);
switch (UniformComponentType(targetUniform->type))
{
case GL_BOOL:
{
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * internalCount;
GLint *boolParams = (GLint*)targetUniform->data + mUniformIndex[location].element * 4;
for (unsigned int i = 0; i < count; ++i)
for (unsigned int i = 0; i < size; i++)
{
params[i] = boolParams[i];
}
......@@ -943,17 +955,17 @@ bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params
break;
case GL_FLOAT:
{
GLfloat *floatParams = (GLfloat*)targetUniform->data + mUniformIndex[location].element * internalCount;
GLfloat *floatParams = (GLfloat*)targetUniform->data + mUniformIndex[location].element * 4;
for (unsigned int i = 0; i < count; ++i)
for (unsigned int i = 0; i < size; i++)
{
params[i] = (GLint)floatParams[i];
}
}
break;
case GL_INT:
memcpy(params, targetUniform->data + mUniformIndex[location].element * internalCount * sizeof(GLint),
count * sizeof(GLint));
memcpy(params, targetUniform->data + mUniformIndex[location].element * 4 * sizeof(GLint),
size * sizeof(GLint));
break;
default: UNREACHABLE();
}
......@@ -986,7 +998,7 @@ void ProgramBinary::applyUniforms()
targetUniform->type == GL_SAMPLER_CUBE)
{
int count = targetUniform->elementCount();
GLint *v = (GLint*)targetUniform->data;
GLint (*v)[4] = (GLint(*)[4])targetUniform->data;
if (targetUniform->psRegisterIndex >= 0)
{
......@@ -999,7 +1011,7 @@ void ProgramBinary::applyUniforms()
if (samplerIndex < MAX_TEXTURE_IMAGE_UNITS)
{
ASSERT(mSamplersPS[samplerIndex].active);
mSamplersPS[samplerIndex].logicalTextureUnit = v[i];
mSamplersPS[samplerIndex].logicalTextureUnit = v[i][0];
}
}
}
......@@ -1015,7 +1027,7 @@ void ProgramBinary::applyUniforms()
if (samplerIndex < IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS)
{
ASSERT(mSamplersVS[samplerIndex].active);
mSamplersVS[samplerIndex].logicalTextureUnit = v[i];
mSamplersVS[samplerIndex].logicalTextureUnit = v[i][0];
}
}
}
......
......@@ -1633,7 +1633,6 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray
if (targetUniform->dirty)
{
int count = targetUniform->elementCount();
GLfloat *f = (GLfloat*)targetUniform->data;
GLint *i = (GLint*)targetUniform->data;
......@@ -1641,22 +1640,28 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray
{
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
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;
break;
case GL_BOOL:
case GL_BOOL_VEC2:
case GL_BOOL_VEC3:
case GL_BOOL_VEC4:
applyUniformnbv(targetUniform, i);
break;
case GL_FLOAT:
case GL_FLOAT_VEC2:
case GL_FLOAT_VEC3:
case GL_FLOAT_VEC4:
case GL_FLOAT_MAT2:
case GL_FLOAT_MAT3:
case GL_FLOAT_MAT4: applyUniformnfv(targetUniform, f); break;
case GL_INT: applyUniform1iv(targetUniform, count, i); break;
case GL_INT_VEC2: applyUniform2iv(targetUniform, count, i); break;
case GL_INT_VEC3: applyUniform3iv(targetUniform, count, i); break;
case GL_INT_VEC4: applyUniform4iv(targetUniform, count, i); break;
case GL_FLOAT_MAT4:
applyUniformnfv(targetUniform, f);
break;
case GL_INT:
case GL_INT_VEC2:
case GL_INT_VEC3:
case GL_INT_VEC4:
applyUniformniv(targetUniform, i);
break;
default:
UNREACHABLE();
}
......@@ -1674,32 +1679,6 @@ void Renderer9::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray
}
}
void Renderer9::applyUniformnbv(gl::Uniform *targetUniform, GLsizei count, int width, const GLint *v)
{
float vector[D3D9_MAX_FLOAT_CONSTANTS * 4];
if (targetUniform->psRegisterIndex >= 0 || targetUniform->vsRegisterIndex >= 0)
{
ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS);
for (int i = 0; i < count; i++)
{
for (int j = 0; j < 4; j++)
{
if (j < width)
{
vector[i * 4 + j] = (v[i * width + j] == GL_FALSE) ? 0.0f : 1.0f;
}
else
{
vector[i * 4 + j] = 0.0f;
}
}
}
}
applyUniformnfv(targetUniform, vector);
}
void Renderer9::applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v)
{
if (targetUniform->psRegisterIndex >= 0)
......@@ -1713,62 +1692,36 @@ void Renderer9::applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v)
}
}
void Renderer9::applyUniform1iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v)
{
ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS);
gl::Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS];
for (int i = 0; i < count; i++)
{
vector[i] = gl::Vector4((float)v[i], 0, 0, 0);
}
applyUniformnfv(targetUniform, (const GLfloat*)vector);
}
void Renderer9::applyUniform2iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v)
{
ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS);
gl::Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS];
for (int i = 0; i < count; i++)
{
vector[i] = gl::Vector4((float)v[0], (float)v[1], 0, 0);
v += 2;
}
applyUniformnfv(targetUniform, (const GLfloat*)vector);
}
void Renderer9::applyUniform3iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v)
void Renderer9::applyUniformniv(gl::Uniform *targetUniform, const GLint *v)
{
ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS);
gl::Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS];
ASSERT(targetUniform->registerCount <= D3D9_MAX_FLOAT_CONSTANTS);
GLfloat vector[D3D9_MAX_FLOAT_CONSTANTS][4];
for (int i = 0; i < count; i++)
for (unsigned int i = 0; i < targetUniform->registerCount; i++)
{
vector[i] = gl::Vector4((float)v[0], (float)v[1], (float)v[2], 0);
v += 3;
vector[i][0] = (GLfloat)v[4 * i + 0];
vector[i][1] = (GLfloat)v[4 * i + 1];
vector[i][2] = (GLfloat)v[4 * i + 2];
vector[i][3] = (GLfloat)v[4 * i + 3];
}
applyUniformnfv(targetUniform, (const GLfloat*)vector);
applyUniformnfv(targetUniform, (GLfloat*)vector);
}
void Renderer9::applyUniform4iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v)
void Renderer9::applyUniformnbv(gl::Uniform *targetUniform, const GLint *v)
{
ASSERT(count <= D3D9_MAX_FLOAT_CONSTANTS);
gl::Vector4 vector[D3D9_MAX_FLOAT_CONSTANTS];
ASSERT(targetUniform->registerCount <= D3D9_MAX_FLOAT_CONSTANTS);
GLfloat vector[D3D9_MAX_FLOAT_CONSTANTS][4];
for (int i = 0; i < count; i++)
for (unsigned int i = 0; i < targetUniform->registerCount; i++)
{
vector[i] = gl::Vector4((float)v[0], (float)v[1], (float)v[2], (float)v[3]);
v += 4;
vector[i][0] = (v[4 * i + 0] == GL_FALSE) ? 0.0f : 1.0f;
vector[i][1] = (v[4 * i + 1] == GL_FALSE) ? 0.0f : 1.0f;
vector[i][2] = (v[4 * i + 2] == GL_FALSE) ? 0.0f : 1.0f;
vector[i][3] = (v[4 * i + 3] == GL_FALSE) ? 0.0f : 1.0f;
}
applyUniformnfv(targetUniform, (const GLfloat*)vector);
applyUniformnfv(targetUniform, (GLfloat*)vector);
}
void Renderer9::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
......
......@@ -210,11 +210,8 @@ class Renderer9 : public Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer9);
void applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v);
void applyUniform1iv(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 applyUniform4iv(gl::Uniform *targetUniform, GLsizei count, const GLint *v);
void applyUniformnbv(gl::Uniform *targetUniform, GLsizei count, int width, const GLint *v);
void applyUniformniv(gl::Uniform *targetUniform, const GLint *v);
void applyUniformnbv(gl::Uniform *targetUniform, const GLint *v);
void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -19,8 +19,7 @@
namespace gl
{
// This is how much data the application expects for a uniform
int UniformExternalComponentCount(GLenum type)
int UniformComponentCount(GLenum type)
{
switch (type)
{
......@@ -54,42 +53,6 @@ int UniformExternalComponentCount(GLenum type)
return 0;
}
// This is how much data we actually store for a uniform
int UniformInternalComponentCount(GLenum type)
{
switch (type)
{
case GL_BOOL:
case GL_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
return 1;
case GL_BOOL_VEC2:
case GL_INT_VEC2:
return 2;
case GL_INT_VEC3:
case GL_BOOL_VEC3:
return 3;
case GL_FLOAT:
case GL_FLOAT_VEC2:
case GL_FLOAT_VEC3:
case GL_BOOL_VEC4:
case GL_FLOAT_VEC4:
case GL_INT_VEC4:
return 4;
case GL_FLOAT_MAT2:
return 8;
case GL_FLOAT_MAT3:
return 12;
case GL_FLOAT_MAT4:
return 16;
default:
UNREACHABLE();
}
return 0;
}
GLenum UniformComponentType(GLenum type)
{
switch(type)
......@@ -136,12 +99,13 @@ size_t UniformComponentSize(GLenum type)
size_t UniformInternalSize(GLenum type)
{
return UniformComponentSize(UniformComponentType(type)) * UniformInternalComponentCount(type);
// Expanded to 4-element vectors
return UniformComponentSize(UniformComponentType(type)) * VariableRowCount(type) * 4;
}
size_t UniformExternalSize(GLenum type)
{
return UniformComponentSize(UniformComponentType(type)) * UniformExternalComponentCount(type);
return UniformComponentSize(UniformComponentType(type)) * UniformComponentCount(type);
}
int VariableRowCount(GLenum type)
......@@ -187,6 +151,8 @@ int VariableColumnCount(GLenum type)
case GL_BOOL:
case GL_FLOAT:
case GL_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
return 1;
case GL_BOOL_VEC2:
case GL_FLOAT_VEC2:
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -20,8 +20,7 @@ namespace gl
struct Color;
int UniformExternalComponentCount(GLenum type);
int UniformInternalComponentCount(GLenum type);
int UniformComponentCount(GLenum type);
GLenum UniformComponentType(GLenum type);
size_t UniformInternalSize(GLenum type);
size_t UniformExternalSize(GLenum type);
......
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