Commit 5ce0ea65 by Nicolas Capens

Use the projection matrix to scale z.

Bug 22123818 Change-Id: I2c72e221d9d9410c32875188a5edea6ce7310f20 Reviewed-on: https://swiftshader-review.googlesource.com/3625Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 5491cb48
...@@ -2479,7 +2479,13 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count) ...@@ -2479,7 +2479,13 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
if(!mState.currentProgram) if(!mState.currentProgram)
{ {
//return;// error(GL_INVALID_OPERATION); //return;// error(GL_INVALID_OPERATION);
device->setProjectionMatrix(projection.current());
const sw::Matrix Z(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0.5, 0.5,
0, 0, 0, 1); // Map depth range from [-1, 1] to [0, 1]
device->setProjectionMatrix(Z * projection.current());
device->setViewMatrix(modelView.current()); device->setViewMatrix(modelView.current());
device->setTextureMatrix(0, texture[0].current()); device->setTextureMatrix(0, texture[0].current());
device->setTextureMatrix(1, texture[1].current()); device->setTextureMatrix(1, texture[1].current());
...@@ -3509,7 +3515,12 @@ void Context::end() ...@@ -3509,7 +3515,12 @@ void Context::end()
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
device->setProjectionMatrix(projection.current()); const sw::Matrix Z(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0.5, 0.5,
0, 0, 0, 1); // Map depth range from [-1, 1] to [0, 1]
device->setProjectionMatrix(Z * projection.current());
device->setViewMatrix(modelView.current()); device->setViewMatrix(modelView.current());
device->setTextureMatrix(0, texture[0].current()); device->setTextureMatrix(0, texture[0].current());
device->setTextureMatrix(1, texture[1].current()); device->setTextureMatrix(1, texture[1].current());
......
...@@ -1805,7 +1805,12 @@ void Context::applyState(GLenum drawMode) ...@@ -1805,7 +1805,12 @@ void Context::applyState(GLenum drawMode)
device->setAmbientMaterialSource(sw::MATERIAL_MATERIAL); device->setAmbientMaterialSource(sw::MATERIAL_MATERIAL);
device->setEmissiveMaterialSource(sw::MATERIAL_MATERIAL); device->setEmissiveMaterialSource(sw::MATERIAL_MATERIAL);
device->setProjectionMatrix(projectionStack.current()); const sw::Matrix Z(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0.5, 0.5,
0, 0, 0, 1); // Map depth range from [-1, 1] to [0, 1]
device->setProjectionMatrix(Z * projectionStack.current());
device->setModelMatrix(modelViewStack.current()); device->setModelMatrix(modelViewStack.current());
device->setTextureMatrix(0, textureStack0.current()); device->setTextureMatrix(0, textureStack0.current());
device->setTextureMatrix(1, textureStack1.current()); device->setTextureMatrix(1, textureStack1.current());
......
...@@ -488,7 +488,7 @@ namespace sw ...@@ -488,7 +488,7 @@ namespace sw
r.o[pos].y = r.o[pos].y + *Pointer<Float4>(r.data + OFFSET(DrawData,halfPixelY)) * r.o[pos].w; r.o[pos].y = r.o[pos].y + *Pointer<Float4>(r.data + OFFSET(DrawData,halfPixelY)) * r.o[pos].w;
} }
if(symmetricNormalizedDepth) if(symmetricNormalizedDepth && !state.fixedFunction)
{ {
r.o[pos].z = (r.o[pos].z + r.o[pos].w) * Float4(0.5f); r.o[pos].z = (r.o[pos].z + r.o[pos].w) * Float4(0.5f);
} }
......
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