Eliminated D3DConstantTable.
TRAC #22326
Signed-off-by: Daniel Koch
Signed-off-by: Shannon Woods
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1634 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index f33d5f1..b141a7a 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -1639,7 +1639,7 @@
ptr += vertexShaderSize;
mPixelExecutable = mRenderer->loadExecutable(reinterpret_cast<const DWORD*>(pixelShaderFunction),
- pixelShaderSize, GL_FRAGMENT_SHADER, NULL);
+ pixelShaderSize, GL_FRAGMENT_SHADER);
if (!mPixelExecutable)
{
infoLog.append("Could not create pixel shader.");
@@ -1647,7 +1647,7 @@
}
mVertexExecutable = mRenderer->loadExecutable(reinterpret_cast<const DWORD*>(vertexShaderFunction),
- vertexShaderSize, GL_VERTEX_SHADER, NULL);
+ vertexShaderSize, GL_VERTEX_SHADER);
if (!mVertexExecutable)
{
infoLog.append("Could not create vertex shader.");
@@ -1922,160 +1922,6 @@
return true;
}
-// Adds the description of a constant found in the binary shader to the list of uniforms
-// Returns true if succesful (uniform not already defined)
-bool ProgramBinary::defineUniform(InfoLog &infoLog, GLenum shader, const rx::D3DConstant *constant, const std::string &name,
- rx::D3DConstantTable *vsConstantTable, rx::D3DConstantTable *psConstantTable)
-{
- if (constant->registerSet == rx::D3DConstant::RS_SAMPLER)
- {
- for (unsigned int i = 0; i < constant->registerCount; i++)
- {
- const rx::D3DConstant *psConstant = psConstantTable->getConstantByName(constant->name.c_str());
- const rx::D3DConstant *vsConstant = vsConstantTable->getConstantByName(constant->name.c_str());
-
- if (psConstant)
- {
- unsigned int samplerIndex = psConstant->registerIndex + i;
-
- if (samplerIndex < MAX_TEXTURE_IMAGE_UNITS)
- {
- mSamplersPS[samplerIndex].active = true;
- mSamplersPS[samplerIndex].textureType = (constant->type == rx::D3DConstant::PT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D;
- mSamplersPS[samplerIndex].logicalTextureUnit = 0;
- mUsedPixelSamplerRange = std::max(samplerIndex + 1, mUsedPixelSamplerRange);
- }
- else
- {
- infoLog.append("Pixel shader sampler count exceeds MAX_TEXTURE_IMAGE_UNITS (%d).", MAX_TEXTURE_IMAGE_UNITS);
- return false;
- }
- }
-
- if (vsConstant)
- {
- unsigned int samplerIndex = vsConstant->registerIndex + i;
-
- if (samplerIndex < getContext()->getMaximumVertexTextureImageUnits())
- {
- mSamplersVS[samplerIndex].active = true;
- mSamplersVS[samplerIndex].textureType = (constant->type == rx::D3DConstant::PT_SAMPLERCUBE) ? TEXTURE_CUBE : TEXTURE_2D;
- mSamplersVS[samplerIndex].logicalTextureUnit = 0;
- mUsedVertexSamplerRange = std::max(samplerIndex + 1, mUsedVertexSamplerRange);
- }
- else
- {
- infoLog.append("Vertex shader sampler count exceeds MAX_VERTEX_TEXTURE_IMAGE_UNITS (%d).", getContext()->getMaximumVertexTextureImageUnits());
- return false;
- }
- }
- }
- }
-
- switch(constant->typeClass)
- {
- case rx::D3DConstant::CLASS_STRUCT:
- {
- for (unsigned int arrayIndex = 0; arrayIndex < constant->elements; arrayIndex++)
- {
- for (unsigned int field = 0; field < constant->structMembers[arrayIndex].size(); field++)
- {
- const rx::D3DConstant *fieldConstant = constant->structMembers[arrayIndex][field];
-
- std::string structIndex = (constant->elements > 1) ? ("[" + str(arrayIndex) + "]") : "";
-
- if (!defineUniform(infoLog, shader, fieldConstant, name + constant->name + structIndex + ".", vsConstantTable, psConstantTable))
- {
- return false;
- }
- }
- }
-
- return true;
- }
- case rx::D3DConstant::CLASS_SCALAR:
- case rx::D3DConstant::CLASS_VECTOR:
- case rx::D3DConstant::CLASS_MATRIX_COLUMNS:
- case rx::D3DConstant::CLASS_OBJECT:
- return defineUniform(shader, constant, name + constant->name);
- default:
- UNREACHABLE();
- return false;
- }
-}
-
-bool ProgramBinary::defineUniform(GLenum shader, const rx::D3DConstant *constant, const std::string &_name)
-{
- if (_name == "dx_DepthRange")
- {
- if (shader == GL_VERTEX_SHADER) mDxDepthRangeRegisterVS = constant->registerIndex;
- if (shader == GL_FRAGMENT_SHADER) mDxDepthRangeRegisterPS = constant->registerIndex;
- return true;
- }
-
- if (_name == "dx_DepthFront")
- {
- mDxDepthFrontRegister = constant->registerIndex;
- return true;
- }
-
- if (_name == "dx_Coord")
- {
- mDxCoordRegister = constant->registerIndex;
- return true;
- }
-
- if (_name == "dx_HalfPixelSize")
- {
- mDxHalfPixelSizeRegister = constant->registerIndex;
- return true;
- }
-
- Uniform *uniform = createUniform(constant, _name);
-
- 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 = constant->registerCount;
- }
- else if (shader == GL_VERTEX_SHADER)
- {
- uniform->vs.registerIndex = constant->registerIndex;
- uniform->vs.registerCount = constant->registerCount;
- }
- 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(_name, i, uniformIndex));
- }
-
- return true;
-}
-
bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog)
{
if (constant.name == "dx_DepthRange")
@@ -2197,81 +2043,6 @@
return true;
}
-Uniform *ProgramBinary::createUniform(const rx::D3DConstant *constant, const std::string &_name)
-{
- if (constant->rows == 1) // Vectors and scalars
- {
- switch (constant->type)
- {
- case rx::D3DConstant::PT_SAMPLER2D:
- switch (constant->columns)
- {
- case 1: return new Uniform(GL_SAMPLER_2D, _name, constant->elements);
- default: UNREACHABLE();
- }
- break;
- case rx::D3DConstant::PT_SAMPLERCUBE:
- switch (constant->columns)
- {
- case 1: return new Uniform(GL_SAMPLER_CUBE, _name, constant->elements);
- default: UNREACHABLE();
- }
- break;
- case rx::D3DConstant::PT_BOOL:
- switch (constant->columns)
- {
- case 1: return new Uniform(GL_BOOL, _name, constant->elements);
- case 2: return new Uniform(GL_BOOL_VEC2, _name, constant->elements);
- case 3: return new Uniform(GL_BOOL_VEC3, _name, constant->elements);
- case 4: return new Uniform(GL_BOOL_VEC4, _name, constant->elements);
- default: UNREACHABLE();
- }
- break;
- case rx::D3DConstant::PT_INT:
- switch (constant->columns)
- {
- case 1: return new Uniform(GL_INT, _name, constant->elements);
- case 2: return new Uniform(GL_INT_VEC2, _name, constant->elements);
- case 3: return new Uniform(GL_INT_VEC3, _name, constant->elements);
- case 4: return new Uniform(GL_INT_VEC4, _name, constant->elements);
- default: UNREACHABLE();
- }
- break;
- case rx::D3DConstant::PT_FLOAT:
- switch (constant->columns)
- {
- case 1: return new Uniform(GL_FLOAT, _name, constant->elements);
- case 2: return new Uniform(GL_FLOAT_VEC2, _name, constant->elements);
- case 3: return new Uniform(GL_FLOAT_VEC3, _name, constant->elements);
- case 4: return new Uniform(GL_FLOAT_VEC4, _name, constant->elements);
- default: UNREACHABLE();
- }
- break;
- default:
- UNREACHABLE();
- }
- }
- else if (constant->rows == constant->columns) // Square matrices
- {
- switch (constant->type)
- {
- case rx::D3DConstant::PT_FLOAT:
- switch (constant->rows)
- {
- case 2: return new Uniform(GL_FLOAT_MAT2, _name, constant->elements);
- case 3: return new Uniform(GL_FLOAT_MAT3, _name, constant->elements);
- case 4: return new Uniform(GL_FLOAT_MAT4, _name, constant->elements);
- default: UNREACHABLE();
- }
- break;
- default: UNREACHABLE();
- }
- }
- else UNREACHABLE();
-
- return 0;
-}
-
// This method needs to match OutputHLSL::decorate
std::string ProgramBinary::decorateAttribute(const std::string &name)
{