Fixed skipping over internal uniforms in getActiveUniform.

TRAC #14390 Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@483 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 52813558
...@@ -1658,6 +1658,9 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1658,6 +1658,9 @@ bool Context::applyRenderTarget(bool ignoreViewport)
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
renderTarget->GetDesc(&desc); renderTarget->GetDesc(&desc);
float zNear = clamp01(mState.zNear);
float zFar = clamp01(mState.zFar);
if (ignoreViewport) if (ignoreViewport)
{ {
viewport.X = 0; viewport.X = 0;
...@@ -1673,8 +1676,8 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1673,8 +1676,8 @@ bool Context::applyRenderTarget(bool ignoreViewport)
viewport.Y = std::max(mState.viewportY, 0); viewport.Y = std::max(mState.viewportY, 0);
viewport.Width = std::min(mState.viewportWidth, (int)desc.Width - (int)viewport.X); viewport.Width = std::min(mState.viewportWidth, (int)desc.Width - (int)viewport.X);
viewport.Height = std::min(mState.viewportHeight, (int)desc.Height - (int)viewport.Y); viewport.Height = std::min(mState.viewportHeight, (int)desc.Height - (int)viewport.Y);
viewport.MinZ = clamp01(mState.zNear); viewport.MinZ = zNear;
viewport.MaxZ = clamp01(mState.zFar); viewport.MaxZ = zFar;
} }
if (viewport.Width <= 0 || viewport.Height <= 0) if (viewport.Width <= 0 || viewport.Height <= 0)
...@@ -1720,17 +1723,17 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1720,17 +1723,17 @@ bool Context::applyRenderTarget(bool ignoreViewport)
programObject->setUniform4fv(window, 1, (GLfloat*)&whxy); programObject->setUniform4fv(window, 1, (GLfloat*)&whxy);
GLint depth = programObject->getDxDepthLocation(); GLint depth = programObject->getDxDepthLocation();
GLfloat dz[2] = {(mState.zFar - mState.zNear) / 2.0f, (mState.zNear + mState.zFar) / 2.0f}; GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f};
programObject->setUniform2fv(depth, 1, (GLfloat*)&dz); programObject->setUniform2fv(depth, 1, (GLfloat*)&dz);
GLint near = programObject->getDepthRangeNearLocation(); GLint near = programObject->getDepthRangeNearLocation();
programObject->setUniform1fv(near, 1, &mState.zNear); programObject->setUniform1fv(near, 1, &zNear);
GLint far = programObject->getDepthRangeFarLocation(); GLint far = programObject->getDepthRangeFarLocation();
programObject->setUniform1fv(far, 1, &mState.zFar); programObject->setUniform1fv(far, 1, &zFar);
GLint diff = programObject->getDepthRangeDiffLocation(); GLint diff = programObject->getDepthRangeDiffLocation();
GLfloat zDiff = mState.zFar - mState.zNear; GLfloat zDiff = zFar - zNear;
programObject->setUniform1fv(diff, 1, &zDiff); programObject->setUniform1fv(diff, 1, &zDiff);
} }
......
...@@ -1374,7 +1374,7 @@ bool Program::linkVaryings() ...@@ -1374,7 +1374,7 @@ bool Program::linkVaryings()
{ {
mPixelHLSL += " float4 gl_FragCoord : " + varyingSemantic + str(registers) + ";\n"; mPixelHLSL += " float4 gl_FragCoord : " + varyingSemantic + str(registers) + ";\n";
if (sm3) { if (sm3) {
mPixelHLSL += " float4 dx_VPos : VPOS;\n"; mPixelHLSL += " float2 dx_VPos : VPOS;\n";
} }
} }
...@@ -2641,18 +2641,26 @@ GLint Program::getActiveAttributeMaxLength() ...@@ -2641,18 +2641,26 @@ GLint Program::getActiveAttributeMaxLength()
void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
{ {
unsigned int uniform = 0; // Skip over internal uniforms
for (unsigned int i = 0; i < index; i++) unsigned int activeUniform = 0;
unsigned int uniform;
for (uniform = 0; uniform < mUniforms.size(); uniform++)
{ {
do while (mUniforms[uniform]->name.substr(0, 3) == "dx_")
{ {
uniform++; uniform++;
}
ASSERT(uniform < mUniforms.size()); // index must be smaller than getActiveUniformCount() if (activeUniform == index)
{
break;
} }
while (mUniforms[uniform]->name.substr(0, 3) == "dx_");
activeUniform++;
} }
ASSERT(uniform < mUniforms.size()); // index must be smaller than getActiveUniformCount()
if (bufsize > 0) if (bufsize > 0)
{ {
std::string string = undecorate(mUniforms[uniform]->name); std::string string = undecorate(mUniforms[uniform]->name);
......
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