Implemented support for DX11 uniform arrays.

TRAC #22239 Signed-off-by: Daniel Koch Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1629 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 873f28aa
......@@ -14,7 +14,7 @@ namespace gl
Uniform::Uniform(GLenum type, const std::string &_name, unsigned int arraySize)
: type(type), _name(_name), name(undecorate(_name)), arraySize(arraySize)
{
int bytes = gl::UniformInternalSize(type) * arraySize;
int bytes = gl::UniformInternalSize(type) * elementCount();
data = new unsigned char[bytes];
memset(data, 0, bytes);
dirty = true;
......@@ -25,12 +25,29 @@ Uniform::~Uniform()
delete[] data;
}
bool Uniform::isArray()
bool Uniform::isArray() const
{
size_t dot = _name.find_last_of('.');
if (dot == std::string::npos) dot = -1;
if (name != _name) // D3D9_REPLACE
{
size_t dot = _name.find_last_of('.');
if (dot == std::string::npos) dot = -1;
return _name.compare(dot + 1, dot + 4, "ar_") == 0;
}
else
{
return arraySize > 0;
}
}
return _name.compare(dot + 1, dot + 4, "ar_") == 0;
unsigned int Uniform::elementCount() const
{
return arraySize > 0 ? arraySize : 1;
}
unsigned int Uniform::registerCount() const
{
return VariableRowCount(type) * elementCount();
}
std::string Uniform::undecorate(const std::string &_name)
......
......@@ -25,7 +25,9 @@ struct Uniform
~Uniform();
bool isArray();
bool isArray() const;
unsigned int elementCount() const;
unsigned int registerCount() const;
static std::string Uniform::undecorate(const std::string &_name);
const GLenum type;
......@@ -45,7 +47,7 @@ struct Uniform
}
int registerIndex;
int registerCount;
unsigned int registerCount;
};
RegisterInfo ps;
......
......@@ -837,7 +837,7 @@ void Renderer11::applyUniforms(const gl::UniformArray *uniformArray)
case GL_FLOAT_MAT4:
if (uniform->vs.registerCount)
{
for (int i = 0; i < uniform->vs.registerCount; i++)
for (unsigned int i = 0; i < uniform->vs.registerCount; i++)
{
cVS[uniform->vs.registerIndex + i][0] = f[i][0];
cVS[uniform->vs.registerIndex + i][1] = f[i][1];
......@@ -847,7 +847,7 @@ void Renderer11::applyUniforms(const gl::UniformArray *uniformArray)
}
if (uniform->ps.registerCount)
{
for (int i = 0; i < uniform->ps.registerCount; i++)
for (unsigned int i = 0; i < uniform->ps.registerCount; i++)
{
cPS[uniform->ps.registerIndex + i][0] = f[i][0];
cPS[uniform->ps.registerIndex + i][1] = f[i][1];
......
......@@ -1471,7 +1471,7 @@ void Renderer9::applyUniforms(const gl::UniformArray *uniformArray)
if (targetUniform->dirty)
{
int arraySize = targetUniform->arraySize;
int count = targetUniform->elementCount();
GLfloat *f = (GLfloat*)targetUniform->data;
GLint *i = (GLint*)targetUniform->data;
GLboolean *b = (GLboolean*)targetUniform->data;
......@@ -1481,21 +1481,21 @@ void Renderer9::applyUniforms(const gl::UniformArray *uniformArray)
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
break;
case GL_BOOL: applyUniformnbv(targetUniform, arraySize, 1, b); break;
case GL_BOOL_VEC2: applyUniformnbv(targetUniform, arraySize, 2, b); break;
case GL_BOOL_VEC3: applyUniformnbv(targetUniform, arraySize, 3, b); break;
case GL_BOOL_VEC4: applyUniformnbv(targetUniform, arraySize, 4, b); 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_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, arraySize, i); break;
case GL_INT_VEC2: applyUniform2iv(targetUniform, arraySize, i); break;
case GL_INT_VEC3: applyUniform3iv(targetUniform, arraySize, i); break;
case GL_INT_VEC4: applyUniform4iv(targetUniform, arraySize, i); break;
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;
default:
UNREACHABLE();
}
......
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