From: Ian Romanick Date: Thu, 17 Sep 2015 14:26:45 +0000 (-0400) Subject: mesa/i965: Refactor brw_is_front_buffer_{drawing,reading} to common code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea8b77e892cdf6aa4cdd8a9ff312c422b3509ae7;p=mesa.git mesa/i965: Refactor brw_is_front_buffer_{drawing,reading} to common code There are multiple similar implementations of these functions, and a later patch was going to add another. v2: Move removing intel_framebuffer to a different patch. Signed-off-by: Ian Romanick Reviewed-by: Iago Toral Quiroga --- diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 87c84c6236b..6b2bbd21703 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -41,6 +41,7 @@ #include "main/version.h" #include "main/vtxfmt.h" #include "main/texobj.h" +#include "main/framebuffer.h" #include "vbo/vbo_context.h" @@ -1298,7 +1299,7 @@ intel_prepare_render(struct brw_context *brw) * that will happen next will probably dirty the front buffer. So * mark it as dirty here. */ - if (brw_is_front_buffer_drawing(ctx->DrawBuffer)) + if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) brw->front_buffer_dirty = true; } @@ -1337,8 +1338,8 @@ intel_query_dri2_buffers(struct brw_context *brw, back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT); memset(attachments, 0, sizeof(attachments)); - if ((brw_is_front_buffer_drawing(fb) || - brw_is_front_buffer_reading(fb) || + if ((_mesa_is_front_buffer_drawing(fb) || + _mesa_is_front_buffer_reading(fb) || !back_rb) && front_rb) { /* If a fake front buffer is in use, then querying for * __DRI_BUFFER_FRONT_LEFT will cause the server to copy the image from @@ -1452,7 +1453,7 @@ intel_process_dri2_buffer(struct brw_context *brw, drawable->w, drawable->h, buffer->pitch); - if (brw_is_front_buffer_drawing(fb) && + if (_mesa_is_front_buffer_drawing(fb) && (buffer->attachment == __DRI_BUFFER_FRONT_LEFT || buffer->attachment == __DRI_BUFFER_FAKE_FRONT_LEFT) && rb->Base.Base.NumSamples > 1) { @@ -1510,7 +1511,7 @@ intel_update_image_buffer(struct brw_context *intel, buffer->width, buffer->height, buffer->pitch); - if (brw_is_front_buffer_drawing(fb) && + if (_mesa_is_front_buffer_drawing(fb) && buffer_type == __DRI_IMAGE_BUFFER_FRONT && rb->Base.Base.NumSamples > 1) { intel_renderbuffer_upsample(intel, rb); @@ -1538,8 +1539,8 @@ intel_update_image_buffers(struct brw_context *brw, __DRIdrawable *drawable) else return; - if (front_rb && (brw_is_front_buffer_drawing(fb) || - brw_is_front_buffer_reading(fb) || !back_rb)) { + if (front_rb && (_mesa_is_front_buffer_drawing(fb) || + _mesa_is_front_buffer_reading(fb) || !back_rb)) { buffer_mask |= __DRI_IMAGE_BUFFER_FRONT; } diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index c0517e6c0fb..39a26b05201 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -33,6 +33,7 @@ #include "main/enums.h" #include "main/macros.h" #include "main/transformfeedback.h" +#include "main/framebuffer.h" #include "tnl/tnl.h" #include "vbo/vbo_context.h" #include "swrast/swrast.h" @@ -364,7 +365,7 @@ brw_postdraw_set_buffers_need_resolve(struct brw_context *brw) struct intel_renderbuffer *stencil_irb = intel_get_renderbuffer(fb, BUFFER_STENCIL); struct gl_renderbuffer_attachment *depth_att = &fb->Attachment[BUFFER_DEPTH]; - if (brw_is_front_buffer_drawing(fb)) + if (_mesa_is_front_buffer_drawing(fb)) front_irb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT); if (front_irb) diff --git a/src/mesa/drivers/dri/i965/intel_buffers.c b/src/mesa/drivers/dri/i965/intel_buffers.c index c98e19382c3..fd522cc4f4d 100644 --- a/src/mesa/drivers/dri/i965/intel_buffers.c +++ b/src/mesa/drivers/dri/i965/intel_buffers.c @@ -32,30 +32,10 @@ #include "main/framebuffer.h" #include "main/renderbuffer.h" - -bool -brw_is_front_buffer_reading(struct gl_framebuffer *fb) -{ - if (!fb || _mesa_is_user_fbo(fb)) - return false; - - return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT; -} - -bool -brw_is_front_buffer_drawing(struct gl_framebuffer *fb) -{ - if (!fb || _mesa_is_user_fbo(fb)) - return false; - - return (fb->_NumColorDrawBuffers >= 1 && - fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT); -} - static void intelDrawBuffer(struct gl_context * ctx, GLenum mode) { - if (brw_is_front_buffer_drawing(ctx->DrawBuffer)) { + if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) { struct brw_context *const brw = brw_context(ctx); /* If we might be front-buffer rendering on this buffer for the first @@ -71,7 +51,7 @@ intelDrawBuffer(struct gl_context * ctx, GLenum mode) static void intelReadBuffer(struct gl_context * ctx, GLenum mode) { - if (brw_is_front_buffer_reading(ctx->ReadBuffer)) { + if (_mesa_is_front_buffer_reading(ctx->ReadBuffer)) { struct brw_context *const brw = brw_context(ctx); /* If we might be front-buffer reading on this buffer for the first diff --git a/src/mesa/drivers/dri/i965/intel_buffers.h b/src/mesa/drivers/dri/i965/intel_buffers.h index 016039a628d..0e0d9c31f2b 100644 --- a/src/mesa/drivers/dri/i965/intel_buffers.h +++ b/src/mesa/drivers/dri/i965/intel_buffers.h @@ -32,7 +32,4 @@ extern void intelInitBufferFuncs(struct dd_function_table *functions); -bool brw_is_front_buffer_reading(struct gl_framebuffer *fb); -bool brw_is_front_buffer_drawing(struct gl_framebuffer *fb); - #endif /* INTEL_BUFFERS_H */ diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 5b6b3f64581..d18166d528e 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -964,3 +964,22 @@ _mesa_print_framebuffer(const struct gl_framebuffer *fb) } } } + +bool +_mesa_is_front_buffer_reading(const struct gl_framebuffer *fb) +{ + if (!fb || _mesa_is_user_fbo(fb)) + return false; + + return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT; +} + +bool +_mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb) +{ + if (!fb || _mesa_is_user_fbo(fb)) + return false; + + return (fb->_NumColorDrawBuffers >= 1 && + fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT); +} diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h index 08e43222045..bfc8a0836e7 100644 --- a/src/mesa/main/framebuffer.h +++ b/src/mesa/main/framebuffer.h @@ -139,4 +139,10 @@ _mesa_get_read_renderbuffer_for_format(const struct gl_context *ctx, extern void _mesa_print_framebuffer(const struct gl_framebuffer *fb); +extern bool +_mesa_is_front_buffer_reading(const struct gl_framebuffer *fb); + +extern bool +_mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb); + #endif /* FRAMEBUFFER_H */