summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorLaura Ekstrand <[email protected]>2015-01-30 14:03:53 -0800
committerLaura Ekstrand <[email protected]>2015-02-02 13:21:20 -0800
commite187c2f5432466c7b49dba266026fb9b01f5f667 (patch)
tree6232bca416174ed9c15bdbc69b8c6e650cad76c8 /src/mesa/swrast
parentad2c64abbd7326be35fa1f94c7e056e868ee6185 (diff)
DD: Refactor BlitFramebuffer.
In preparation for glBlitNamedFramebuffer, the DD table function BlitFramebuffer needs to accept two arbitrary framebuffer objects rather than assuming ctx->ReadBuffer and ctx->DrawBuffer. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_blit.c41
-rw-r--r--src/mesa/swrast/s_copypix.c13
-rw-r--r--src/mesa/swrast/swrast.h8
3 files changed, 35 insertions, 27 deletions
diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index e3b45f14682..48936d32917 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -107,14 +107,14 @@ RESAMPLE(resample_row_16, GLuint, 4)
*/
static void
blit_nearest(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield buffer)
{
struct gl_renderbuffer *readRb, *drawRb = NULL;
struct gl_renderbuffer_attachment *readAtt = NULL, *drawAtt = NULL;
- struct gl_framebuffer *readFb = ctx->ReadBuffer;
- struct gl_framebuffer *drawFb = ctx->DrawBuffer;
GLuint numDrawBuffers = 0;
GLuint i;
@@ -508,11 +508,11 @@ resample_linear_row_float(GLint srcWidth, GLint dstWidth,
*/
static void
blit_linear(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1)
{
- struct gl_framebuffer *drawFb = ctx->DrawBuffer;
- struct gl_framebuffer *readFb = ctx->ReadBuffer;
struct gl_renderbuffer *readRb = readFb->_ColorReadBuffer;
struct gl_renderbuffer_attachment *readAtt =
&readFb->Attachment[readFb->_ColorReadBufferIndex];
@@ -733,6 +733,8 @@ fail_no_memory:
*/
void
_swrast_BlitFramebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
@@ -756,7 +758,7 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
if (!_mesa_check_conditional_render(ctx))
return; /* Do not blit */
- if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
+ if (!_mesa_clip_blit(ctx, readFb, drawFb, &srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1)) {
return;
}
@@ -775,14 +777,15 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
dstY0 < dstY1) {
for (i = 0; i < 3; i++) {
if (mask & buffers[i]) {
- if (swrast_fast_copy_pixels(ctx,
- srcX0, srcY0,
- srcX1 - srcX0, srcY1 - srcY0,
- dstX0, dstY0,
- buffer_enums[i])) {
- mask &= ~buffers[i];
- }
- }
+ if (swrast_fast_copy_pixels(ctx,
+ readFb, drawFb,
+ srcX0, srcY0,
+ srcX1 - srcX0, srcY1 - srcY0,
+ dstX0, dstY0,
+ buffer_enums[i])) {
+ mask &= ~buffers[i];
+ }
+ }
}
if (!mask)
@@ -791,17 +794,17 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
if (filter == GL_NEAREST) {
for (i = 0; i < 3; i++) {
- if (mask & buffers[i]) {
- blit_nearest(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, buffers[i]);
- }
+ if (mask & buffers[i]) {
+ blit_nearest(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1, buffers[i]);
+ }
}
}
else {
ASSERT(filter == GL_LINEAR);
if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */
- blit_linear(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1);
+ blit_linear(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1);
}
}
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index d001734766c..eeea20e8671 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -442,11 +442,11 @@ end:
*/
GLboolean
swrast_fast_copy_pixels(struct gl_context *ctx,
- GLint srcX, GLint srcY, GLsizei width, GLsizei height,
- GLint dstX, GLint dstY, GLenum type)
+ struct gl_framebuffer *srcFb,
+ struct gl_framebuffer *dstFb,
+ GLint srcX, GLint srcY, GLsizei width, GLsizei height,
+ GLint dstX, GLint dstY, GLenum type)
{
- struct gl_framebuffer *srcFb = ctx->ReadBuffer;
- struct gl_framebuffer *dstFb = ctx->DrawBuffer;
struct gl_renderbuffer *srcRb, *dstRb;
GLint row;
GLuint pixelBytes, widthInBytes;
@@ -637,8 +637,9 @@ _swrast_CopyPixels( struct gl_context *ctx,
ctx->Pixel.ZoomX != 1.0F ||
ctx->Pixel.ZoomY != 1.0F ||
ctx->_ImageTransferState) &&
- swrast_fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty,
- type)) {
+ swrast_fast_copy_pixels(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
+ srcx, srcy, width, height, destx, desty,
+ type)) {
/* all done */
return;
}
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index ac3dbe3041e..8847bced0cf 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -140,8 +140,10 @@ _swrast_CopyPixels( struct gl_context *ctx,
extern GLboolean
swrast_fast_copy_pixels(struct gl_context *ctx,
- GLint srcX, GLint srcY, GLsizei width, GLsizei height,
- GLint dstX, GLint dstY, GLenum type);
+ struct gl_framebuffer *srcFb,
+ struct gl_framebuffer *dstFb,
+ GLint srcX, GLint srcY, GLsizei width, GLsizei height,
+ GLint dstX, GLint dstY, GLenum type);
extern void
_swrast_DrawPixels( struct gl_context *ctx,
@@ -153,6 +155,8 @@ _swrast_DrawPixels( struct gl_context *ctx,
extern void
_swrast_BlitFramebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);