OSDN Git Service

Use the projection matrix to scale z.
authorNicolas Capens <capn@google.com>
Thu, 2 Jul 2015 20:55:29 +0000 (16:55 -0400)
committerNicolas Capens <capn@google.com>
Fri, 3 Jul 2015 15:10:11 +0000 (15:10 +0000)
Bug 22123818

Change-Id: I2c72e221d9d9410c32875188a5edea6ce7310f20
Reviewed-on: https://swiftshader-review.googlesource.com/3625
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/libGL/Context.cpp
src/OpenGL/libGLES_CM/Context.cpp
src/Shader/VertexRoutine.cpp

index 69217d9..8a2b5cf 100644 (file)
@@ -2479,7 +2479,13 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
     if(!mState.currentProgram)\r
     {\r
         //return;// error(GL_INVALID_OPERATION);\r
-        device->setProjectionMatrix(projection.current());\r
+\r
+               const sw::Matrix Z(1, 0, 0, 0,\r
+                              0, 1, 0, 0,\r
+                              0, 0, 0.5, 0.5,\r
+                              0, 0, 0, 1);   // Map depth range from [-1, 1] to [0, 1]\r
+\r
+        device->setProjectionMatrix(Z * projection.current());\r
         device->setViewMatrix(modelView.current());\r
                device->setTextureMatrix(0, texture[0].current());\r
                device->setTextureMatrix(1, texture[1].current());\r
@@ -3509,7 +3515,12 @@ void Context::end()
         return error(GL_INVALID_OPERATION);\r
     }\r
 \r
-       device->setProjectionMatrix(projection.current());\r
+       const sw::Matrix Z(1, 0, 0, 0,\r
+                          0, 1, 0, 0,\r
+                          0, 0, 0.5, 0.5,\r
+                          0, 0, 0, 1);   // Map depth range from [-1, 1] to [0, 1]\r
+\r
+       device->setProjectionMatrix(Z * projection.current());\r
     device->setViewMatrix(modelView.current());\r
     device->setTextureMatrix(0, texture[0].current());\r
        device->setTextureMatrix(1, texture[1].current());\r
index 68be546..774455d 100644 (file)
@@ -1805,7 +1805,12 @@ void Context::applyState(GLenum drawMode)
        device->setAmbientMaterialSource(sw::MATERIAL_MATERIAL);\r
        device->setEmissiveMaterialSource(sw::MATERIAL_MATERIAL);\r
 \r
-    device->setProjectionMatrix(projectionStack.current());\r
+       const sw::Matrix Z(1, 0, 0, 0,\r
+                          0, 1, 0, 0,\r
+                          0, 0, 0.5, 0.5,\r
+                          0, 0, 0, 1);   // Map depth range from [-1, 1] to [0, 1]\r
+\r
+    device->setProjectionMatrix(Z * projectionStack.current());\r
     device->setModelMatrix(modelViewStack.current());\r
     device->setTextureMatrix(0, textureStack0.current());\r
        device->setTextureMatrix(1, textureStack1.current());\r
index c14b633..e6c6fb9 100644 (file)
@@ -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;
                }
 
-               if(symmetricNormalizedDepth)
+               if(symmetricNormalizedDepth && !state.fixedFunction)
                {
                        r.o[pos].z = (r.o[pos].z + r.o[pos].w) * Float4(0.5f);
                }