mesa/st: keep surface_copy arguments positive
The src/dest x,y, and w,h arguments of the pipe->surface_copy function are unsigned and the drivers aren't expecting negative (or extremly-large unsigned) values as inputs. Trim the requests at the state-tracker level before passing down.
This commit is contained in:
@@ -910,6 +910,34 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||||||
|
|
||||||
st_validate_state(st);
|
st_validate_state(st);
|
||||||
|
|
||||||
|
if (srcx < 0) {
|
||||||
|
width -= -srcx;
|
||||||
|
dstx += -srcx;
|
||||||
|
srcx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srcy < 0) {
|
||||||
|
height -= -srcy;
|
||||||
|
dsty += -srcy;
|
||||||
|
srcy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstx < 0) {
|
||||||
|
width -= -dstx;
|
||||||
|
srcx += -dstx;
|
||||||
|
dstx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dsty < 0) {
|
||||||
|
height -= -dsty;
|
||||||
|
srcy += -dsty;
|
||||||
|
dsty = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width < 0 || height < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (type == GL_STENCIL) {
|
if (type == GL_STENCIL) {
|
||||||
/* can't use texturing to do stencil */
|
/* can't use texturing to do stencil */
|
||||||
copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty);
|
copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty);
|
||||||
@@ -951,15 +979,24 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||||
|
srcy = ctx->DrawBuffer->Height - srcy - height;
|
||||||
|
|
||||||
|
if (srcy < 0) {
|
||||||
|
height -= -srcy;
|
||||||
|
srcy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, texFormat, 0,
|
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, texFormat, 0,
|
||||||
width, height, 1,
|
width, height, 1,
|
||||||
PIPE_TEXTURE_USAGE_SAMPLER);
|
PIPE_TEXTURE_USAGE_SAMPLER);
|
||||||
if (!pt)
|
if (!pt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
|
||||||
srcy = ctx->DrawBuffer->Height - srcy - height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (srcFormat == texFormat) {
|
if (srcFormat == texFormat) {
|
||||||
/* copy source framebuffer surface into mipmap/texture */
|
/* copy source framebuffer surface into mipmap/texture */
|
||||||
|
@@ -1337,6 +1337,34 @@ st_copy_texsubimage(GLcontext *ctx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (srcX < 0) {
|
||||||
|
width -= -srcX;
|
||||||
|
destX += -srcX;
|
||||||
|
srcX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srcY < 0) {
|
||||||
|
height -= -srcY;
|
||||||
|
destY += -srcY;
|
||||||
|
srcY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destX < 0) {
|
||||||
|
width -= -destX;
|
||||||
|
srcX += -destX;
|
||||||
|
destX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destY < 0) {
|
||||||
|
height -= -destY;
|
||||||
|
srcY += -destY;
|
||||||
|
destY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width < 0 || height < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
assert(strb);
|
assert(strb);
|
||||||
assert(strb->surface);
|
assert(strb->surface);
|
||||||
assert(stImage->pt);
|
assert(stImage->pt);
|
||||||
|
Reference in New Issue
Block a user