mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
svga: fix FBO / viewport bugs
When drawing to a FBO, the viewport wasn't always set correctly. It was fine in the usual case of the viewport dims matching the surface dims but broken otherwise. In particular, this was happening because the viewport scale is negative for FBO rendering. The piglit fbo-viewport test exercises this. Reviewed-by: José Fonseca <jfonseca@vmware.com>
This commit is contained in:
parent
4a8d47c264
commit
1459c18f45
1 changed files with 24 additions and 7 deletions
|
|
@ -175,6 +175,7 @@ emit_viewport( struct svga_context *svga,
|
|||
float range_max = 1.0;
|
||||
float flip = -1.0;
|
||||
boolean degenerate = FALSE;
|
||||
boolean invertY = FALSE;
|
||||
enum pipe_error ret;
|
||||
|
||||
float fb_width = svga->curr.framebuffer.width;
|
||||
|
|
@ -218,11 +219,12 @@ emit_viewport( struct svga_context *svga,
|
|||
fx = viewport->scale[0] * 1.0 + viewport->translate[0];
|
||||
}
|
||||
|
||||
if (fh < 0) {
|
||||
prescale.scale[1] *= -1.0;
|
||||
prescale.translate[1] += -fh;
|
||||
if (fh < 0.0) {
|
||||
prescale.translate[1] = fh - 1 + fy * 2;
|
||||
fh = -fh;
|
||||
fy = flip * viewport->scale[1] * 1.0 + viewport->translate[1];
|
||||
fy -= fh;
|
||||
prescale.scale[1] = -1.0;
|
||||
invertY = TRUE;
|
||||
}
|
||||
|
||||
if (fx < 0) {
|
||||
|
|
@ -233,7 +235,12 @@ emit_viewport( struct svga_context *svga,
|
|||
}
|
||||
|
||||
if (fy < 0) {
|
||||
prescale.translate[1] += fy;
|
||||
if (invertY) {
|
||||
prescale.translate[1] -= fy;
|
||||
}
|
||||
else {
|
||||
prescale.translate[1] += fy;
|
||||
}
|
||||
prescale.scale[1] *= fh / (fh + fy);
|
||||
fh += fy;
|
||||
fy = 0;
|
||||
|
|
@ -249,8 +256,15 @@ emit_viewport( struct svga_context *svga,
|
|||
|
||||
if (fy + fh > fb_height) {
|
||||
prescale.scale[1] *= fh / (fb_height - fy);
|
||||
prescale.translate[1] -= fy * (fh / (fb_height - fy));
|
||||
prescale.translate[1] += fy;
|
||||
if (invertY) {
|
||||
float in = fb_height - fy; /* number of vp pixels inside view */
|
||||
float out = fy + fh - fb_height; /* number of vp pixels out of view */
|
||||
prescale.translate[1] += fy * out / in;
|
||||
}
|
||||
else {
|
||||
prescale.translate[1] -= fy * (fh / (fb_height - fy));
|
||||
prescale.translate[1] += fy;
|
||||
}
|
||||
fh = fb_height - fy;
|
||||
}
|
||||
|
||||
|
|
@ -307,6 +321,9 @@ emit_viewport( struct svga_context *svga,
|
|||
break;
|
||||
}
|
||||
|
||||
if (invertY)
|
||||
adjust_y = -adjust_y;
|
||||
|
||||
prescale.translate[0] += adjust_x;
|
||||
prescale.translate[1] += adjust_y;
|
||||
prescale.translate[2] = 0.5; /* D3D clip space */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue