<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Nov 20, 2016, at 10:32 AM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">The former calculations were for min/max y. The width/height don't take<br class="">
translate into account.<br class="">
<br class="">
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>><br class="">
---<br class="">
<br class="">
v2 -> v3:<br class="">
- reduce viewport width when clamping the x/y offsets to 0<br class="">
- subtract vp->y from height, not vp->x<br class="">
<br class="">
Let's hope I don't need to write a v4 of this trivial patch.<br class="">
<br class="">
src/gallium/drivers/swr/swr_state.cpp | 18 ++++++++++++------<br class="">
1 file changed, 12 insertions(+), 6 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp<br class="">
index 520faea..0302439 100644<br class="">
--- a/src/gallium/drivers/swr/swr_state.cpp<br class="">
+++ b/src/gallium/drivers/swr/swr_state.cpp<br class="">
@@ -1018,9 +1018,9 @@ swr_update_derived(struct pipe_context *pipe,<br class="">
      SWR_VIEWPORT_MATRICES *vpm = &ctx->derived.vpm;<br class="">
<br class="">
      vp->x = state->translate[0] - state->scale[0];<br class="">
-      vp->width = state->translate[0] + state->scale[0];<br class="">
+      vp->width = 2 * state->scale[0];<br class="">
      vp->y = state->translate[1] - fabs(state->scale[1]);<br class="">
-      vp->height = state->translate[1] + fabs(state->scale[1]);<br class="">
+      vp->height = 2 * fabs(state->scale[1]);<br class="">
      util_viewport_zmin_zmax(state, rasterizer->clip_halfz,<br class="">
                              &vp->minZ, &vp->maxZ);<br class="">
<br class="">
@@ -1033,10 +1033,16 @@ swr_update_derived(struct pipe_context *pipe,<br class="">
<br class="">
      /* Now that the matrix is calculated, clip the view coords to screen<br class="">
       * size.  OpenGL allows for -ve x,y in the viewport. */<br class="">
-      vp->x = std::max(vp->x, 0.0f);<br class="">
-      vp->y = std::max(vp->y, 0.0f);<br class="">
-      vp->width = std::min(vp->width, (float)fb->width);<br class="">
-      vp->height = std::min(vp->height, (float)fb->height);<br class="">
+      if (vp->x < 0.0f) {<br class="">
+         vp->width += vp->x;<br class="">
+         vp->x = 0.0f;<br class="">
+      }<br class="">
+      if (vp->y < 0.0f) {<br class="">
+         vp->height += vp->y;<br class="">
+         vp->y = 0.0f;<br class="">
+      }<br class="">
+      vp->width = std::min(vp->width, (float)fb->width - vp->x);<br class="">
+      vp->height = std::min(vp->height, (float)fb->height - vp->y);<br class="">
<br class="">
      SwrSetViewports(ctx->swrContext, 1, vp, vpm);<br class="">
   }<br class="">
-- <br class="">
2.7.3<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>