mesa/i965: Refactor brw_is_front_buffer_{drawing,reading} to common code
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 17 Sep 2015 14:26:45 +0000 (10:26 -0400)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 6 Oct 2015 18:36:37 +0000 (11:36 -0700)
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 <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/intel_buffers.c
src/mesa/drivers/dri/i965/intel_buffers.h
src/mesa/main/framebuffer.c
src/mesa/main/framebuffer.h

index 87c84c6236b4547af28210dff559f668db0371ed..6b2bbd217039ba11a9c18b5391314dcfbdb80003 100644 (file)
@@ -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;
    }
 
index c0517e6c0fb70457d11381a29d5fc7439dcc0f97..39a26b0520116bc1bcf0b1ebc897bf950672beec 100644 (file)
@@ -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)
index c98e19382c36daef4ac9f0083bc606a0d1f6943b..fd522cc4f4d47ba35ffc042aedfcdb4e80e47d37 100644 (file)
 #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
index 016039a628d6a5e43fa21f1aa6fdaa5225cc8e7a..0e0d9c31f2b36807513773df90acbe0a520f3d5e 100644 (file)
@@ -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 */
index 5b6b3f64581febe03e7e9e9b0320ec598abf5a69..d18166d528ea6622919092c606009d499f068cf2 100644 (file)
@@ -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);
+}
index 08e43222045eb15772324154c3a8dbc26548e42a..bfc8a0836e7c15061775cc8e1be0ea4cc109862b 100644 (file)
@@ -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 */