[Mesa-dev] [PATCH v2] swr: calculate viewport width/height based on the scale
Ilia Mirkin
imirkin at alum.mit.edu
Sat Nov 19 16:17:44 UTC 2016
The former calculations were for min/max y. The width/height don't take
translate into account.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
v1 -> v2: also fix clamping logic to respect viewport offset
src/gallium/drivers/swr/swr_state.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
index 520faea..c889a68 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -1018,9 +1018,9 @@ swr_update_derived(struct pipe_context *pipe,
SWR_VIEWPORT_MATRICES *vpm = &ctx->derived.vpm;
vp->x = state->translate[0] - state->scale[0];
- vp->width = state->translate[0] + state->scale[0];
+ vp->width = 2 * state->scale[0];
vp->y = state->translate[1] - fabs(state->scale[1]);
- vp->height = state->translate[1] + fabs(state->scale[1]);
+ vp->height = 2 * fabs(state->scale[1]);
util_viewport_zmin_zmax(state, rasterizer->clip_halfz,
&vp->minZ, &vp->maxZ);
@@ -1035,8 +1035,8 @@ swr_update_derived(struct pipe_context *pipe,
* size. OpenGL allows for -ve x,y in the viewport. */
vp->x = std::max(vp->x, 0.0f);
vp->y = std::max(vp->y, 0.0f);
- vp->width = std::min(vp->width, (float)fb->width);
- vp->height = std::min(vp->height, (float)fb->height);
+ vp->width = std::min(vp->width, (float)fb->width - vp->x);
+ vp->height = std::min(vp->height, (float)fb->height - vp->x);
SwrSetViewports(ctx->swrContext, 1, vp, vpm);
}
--
2.7.3
More information about the mesa-dev
mailing list