[Mesa-dev] [PATCH 2/4] radeon: Make use of _mesa_get_viewport_xform v2.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Thu Apr 2 09:21:34 PDT 2015


From: Mathias Froehlich <Mathias.Froehlich at web.de>

Hi Michael,

You mean like this?
I did initially preserve the original ordering present in the
radeon implementation because I thought it is easier to review then.
If it's the other way round, here you are ...
Ok, to commit?

Thanks

Mathias


Instead of _WindowMap just use the translation and scale
of the viewport transform directly. Thereby avoid dividing by
_DepthMaxF again.

v2:
Change order of assignments.

Reviewed-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
---
 src/mesa/drivers/dri/r200/r200_state.c     | 17 +++++++++--------
 src/mesa/drivers/dri/radeon/radeon_state.c | 17 +++++++++--------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index 8327187..e4f07b3 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/framebuffer.h"
 #include "main/fbobject.h"
 #include "main/stencil.h"
+#include "main/viewport.h"
 
 #include "swrast/swrast.h"
 #include "vbo/vbo.h"
@@ -1544,9 +1545,8 @@ void r200UpdateWindow( struct gl_context *ctx )
    __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLfloat xoffset = 0;
    GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0;
-   const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m;
    const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0);
-   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   double scale[3], translate[3];
    GLfloat y_scale, y_bias;
 
    if (render_to_fbo) {
@@ -1557,12 +1557,13 @@ void r200UpdateWindow( struct gl_context *ctx )
       y_bias = yoffset;
    }
 
-   float_ui32_type sx = { v[MAT_SX] };
-   float_ui32_type tx = { v[MAT_TX] + xoffset };
-   float_ui32_type sy = { v[MAT_SY] * y_scale };
-   float_ui32_type ty = { (v[MAT_TY] * y_scale) + y_bias };
-   float_ui32_type sz = { v[MAT_SZ] * depthScale };
-   float_ui32_type tz = { v[MAT_TZ] * depthScale };
+   _mesa_get_viewport_xform(ctx, 0, scale, translate);
+   float_ui32_type sx = { scale[0] };
+   float_ui32_type sy = { scale[1] * y_scale };
+   float_ui32_type sz = { scale[2] };
+   float_ui32_type tx = { translate[0] + xoffset };
+   float_ui32_type ty = { (translate[1] * y_scale) + y_bias };
+   float_ui32_type tz = { translate[2] };
 
    R200_STATECHANGE( rmesa, vpt );
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index e83a34d..66a50a9 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -44,6 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/state.h"
 #include "main/core.h"
 #include "main/stencil.h"
+#include "main/viewport.h"
 
 #include "vbo/vbo.h"
 #include "tnl/tnl.h"
@@ -1352,9 +1353,8 @@ void radeonUpdateWindow( struct gl_context *ctx )
    __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    GLfloat xoffset = 0.0;
    GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0;
-   const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m;
    const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0);
-   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+   double scale[3], translate[3];
    GLfloat y_scale, y_bias;
 
    if (render_to_fbo) {
@@ -1365,12 +1365,13 @@ void radeonUpdateWindow( struct gl_context *ctx )
       y_bias = yoffset;
    }
 
-   float_ui32_type sx = { v[MAT_SX] };
-   float_ui32_type tx = { v[MAT_TX] + xoffset + SUBPIXEL_X };
-   float_ui32_type sy = { v[MAT_SY] * y_scale };
-   float_ui32_type ty = { (v[MAT_TY] * y_scale) + y_bias + SUBPIXEL_Y };
-   float_ui32_type sz = { v[MAT_SZ] * depthScale };
-   float_ui32_type tz = { v[MAT_TZ] * depthScale };
+   _mesa_get_viewport_xform(ctx, 0, scale, translate);
+   float_ui32_type sx = { scale[0] };
+   float_ui32_type sy = { scale[1] * y_scale };
+   float_ui32_type sz = { scale[2] };
+   float_ui32_type tx = { translate[0] + xoffset + SUBPIXEL_X };
+   float_ui32_type ty = { (translate[1] * y_scale) + y_bias + SUBPIXEL_Y };
+   float_ui32_type tz = { translate[2] };
 
    RADEON_STATECHANGE( rmesa, vpt );
 
-- 
2.1.0



More information about the mesa-dev mailing list