Link uniforms.

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@1627 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c5c9e3c5
......@@ -1828,13 +1828,33 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
success = false;
}
if (constantTableVS && constantTablePS)
if (constantTableVS && constantTablePS) // D3D9_REPLACE
{
if (!linkUniforms(infoLog, constantTableVS, constantTablePS))
{
success = false;
}
}
else
{
for (sh::ActiveUniforms::const_iterator uniform = vertexShader->getUniforms().begin(); uniform != vertexShader->getUniforms().end(); uniform++)
{
if (!defineUniform(GL_VERTEX_SHADER, *uniform))
{
success = false;
break;
}
}
for (sh::ActiveUniforms::const_iterator uniform = fragmentShader->getUniforms().begin(); uniform != fragmentShader->getUniforms().end(); uniform++)
{
if (!defineUniform(GL_FRAGMENT_SHADER, *uniform))
{
success = false;
break;
}
}
}
Context *context = getContext();
context->markDxUniformsDirty();
......@@ -2090,6 +2110,54 @@ bool ProgramBinary::defineUniform(GLenum shader, const rx::D3DConstant *constant
return true;
}
bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant)
{
ASSERT(constant.arraySize <= 1); // FIXME: UNIMPLEMENTED
Uniform *uniform = new Uniform(constant.type, constant.name, 1 /*constant.arraySize*/);
if (!uniform)
{
return false;
}
// Check if already defined
GLint location = getUniformLocation(uniform->name);
GLenum type = uniform->type;
if (location >= 0)
{
delete uniform;
uniform = mUniforms[mUniformIndex[location].index];
}
if (shader == GL_FRAGMENT_SHADER)
{
uniform->ps.registerIndex = constant.registerIndex;
uniform->ps.registerCount = 1 /*constant.arraySize*/;
}
else if (shader == GL_VERTEX_SHADER)
{
uniform->vs.registerIndex = constant.registerIndex;
uniform->vs.registerCount = 1 /*constant.arraySize*/;
}
else UNREACHABLE();
if (location >= 0)
{
return uniform->type == type;
}
mUniforms.push_back(uniform);
unsigned int uniformIndex = mUniforms.size() - 1;
for (unsigned int i = 0; i < uniform->arraySize; i++)
{
mUniformIndex.push_back(UniformLocation(constant.name, i, uniformIndex));
}
return true;
}
Uniform *ProgramBinary::createUniform(const rx::D3DConstant *constant, const std::string &_name)
{
if (constant->rows == 1) // Vectors and scalars
......
......@@ -121,6 +121,7 @@ class ProgramBinary : public RefCountObject
bool defineUniform(InfoLog &infoLog, GLenum shader, const rx::D3DConstant *constant, const std::string &name,
rx::D3DConstantTable *vsConstantTable, rx::D3DConstantTable *psConstantTable);
bool defineUniform(GLenum shader, const rx::D3DConstant *constant, const std::string &name);
bool defineUniform(GLenum shader, const sh::Uniform &constant);
Uniform *createUniform(const rx::D3DConstant *constant, const std::string &name);
rx::Renderer *const mRenderer;
......
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