[Mesa-dev] [PATCH 12/18] mesa/i965: Refactor brw_is_front_buffer_{drawing, reading} to common code
Ian Romanick
idr at freedesktop.org
Wed Sep 30 13:58:00 PDT 2015
From: Ian Romanick <ian.d.romanick at intel.com>
There are multiple similar implementations of these functions, and a
later patch was going to add another.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/drivers/dri/i965/brw_context.c | 15 ++++++++-------
src/mesa/drivers/dri/i965/brw_draw.c | 3 ++-
src/mesa/drivers/dri/i965/intel_buffers.c | 24 ++----------------------
src/mesa/drivers/dri/i965/intel_buffers.h | 5 -----
src/mesa/main/framebuffer.c | 19 +++++++++++++++++++
src/mesa/main/framebuffer.h | 6 ++++++
6 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 4d49929..3f64fbb 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 6a75e06..9357a2d 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 c98e193..fd522cc 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 85f54b2..0e0d9c3 100644
--- a/src/mesa/drivers/dri/i965/intel_buffers.h
+++ b/src/mesa/drivers/dri/i965/intel_buffers.h
@@ -30,11 +30,6 @@
#include "drm.h"
#include "brw_context.h"
-struct intel_framebuffer;
-
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 37e2c29..a958e44 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -965,3 +965,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 08e4322..bfc8a08 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 */
--
2.1.0
More information about the mesa-dev
mailing list