radeon: Drop broken front_buffer_reading/drawing optimization
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 18 Sep 2015 16:00:28 +0000 (12:00 -0400)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 26 Apr 2018 13:38:51 +0000 (09:38 -0400)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/drivers/dri/radeon/radeon_common.c
src/mesa/drivers/dri/radeon/radeon_common_context.c
src/mesa/drivers/dri/radeon/radeon_common_context.h

index 155d3a392c76f1afa2c15be48c7116c9ee920f4f..61cbf599f8167acce3684df6257d4ef65991f95a 100644 (file)
@@ -323,22 +323,17 @@ void radeonDrawBuffer( struct gl_context *ctx, GLenum mode )
                fprintf(stderr, "%s %s\n", __func__,
                        _mesa_enum_to_string( mode ));
 
-       if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+       if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) {
                radeonContextPtr radeon = RADEON_CONTEXT(ctx);
 
-               const GLboolean was_front_buffer_rendering =
-                       radeon->is_front_buffer_rendering;
-
-               radeon->is_front_buffer_rendering = (mode == GL_FRONT_LEFT) ||
-                                            (mode == GL_FRONT);
-
-      /* If we weren't front-buffer rendering before but we are now, make sure
-       * that the front-buffer has actually been allocated.
-       */
-               if (!was_front_buffer_rendering && radeon->is_front_buffer_rendering) {
-                       radeon_update_renderbuffers(radeon->driContext,
-                               radeon->driContext->driDrawablePriv, GL_FALSE);
-      }
+               /* If we might be front-buffer rendering on this buffer for
+                * the first time, invalidate our DRI drawable so we'll ask
+                * for new buffers (including the fake front) before we start
+                * rendering again.
+                */
+               radeon_update_renderbuffers(radeon->driContext,
+                                           radeon->driContext->driDrawablePriv,
+                                           GL_FALSE);
        }
 
        radeon_draw_buffer(ctx, ctx->DrawBuffer);
@@ -346,16 +341,10 @@ void radeonDrawBuffer( struct gl_context *ctx, GLenum mode )
 
 void radeonReadBuffer( struct gl_context *ctx, GLenum mode )
 {
-       if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+       if (_mesa_is_front_buffer_reading(ctx->ReadBuffer)) {
                struct radeon_context *const rmesa = RADEON_CONTEXT(ctx);
-               const GLboolean was_front_buffer_reading = rmesa->is_front_buffer_reading;
-               rmesa->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
-                                       || (mode == GL_FRONT);
-
-               if (!was_front_buffer_reading && rmesa->is_front_buffer_reading) {
-                       radeon_update_renderbuffers(rmesa->driContext,
-                                                   rmesa->driContext->driReadablePriv, GL_FALSE);
-               }
+               radeon_update_renderbuffers(rmesa->driContext,
+                                           rmesa->driContext->driReadablePriv, GL_FALSE);
        }
        /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
        if (ctx->ReadBuffer == ctx->DrawBuffer) {
@@ -381,7 +370,7 @@ void radeon_viewport(struct gl_context *ctx)
        void (*old_viewport)(struct gl_context *ctx);
 
        if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
-               if (radeon->is_front_buffer_rendering) {
+               if (_mesa_is_front_buffer_drawing(ctx->DrawBuffer)) {
                        ctx->Driver.Flush(ctx);
                }
                radeon_update_renderbuffers(driContext, driContext->driDrawablePriv, GL_FALSE);
index 7e24f6d7f77982fd00f736a6e44a635256844913..47719baa57545caecd9ae98d47b9dd5c3ce24380 100644 (file)
@@ -352,7 +352,7 @@ void radeon_prepare_render(radeonContextPtr radeon)
      * that will happen next will probably dirty the front buffer.  So
      * mark it as dirty here.
      */
-    if (radeon->is_front_buffer_rendering)
+    if (_mesa_is_front_buffer_drawing(radeon->glCtx.DrawBuffer))
        radeon->front_buffer_dirty = GL_TRUE;
 }
 
@@ -389,10 +389,10 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
                struct radeon_renderbuffer *stencil_rb;
 
                i = 0;
-               if ((front_only || radeon->is_front_buffer_rendering ||
-                    radeon->is_front_buffer_reading ||
-                    !draw->color_rb[1])
-                   && draw->color_rb[0]) {
+                if ((front_only || _mesa_is_front_buffer_drawing(&draw->base) ||
+                     _mesa_is_front_buffer_reading(&draw->base) ||
+                     !draw->color_rb[1])
+                    && draw->color_rb[0]) {
                        attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
                        attachments[i++] = radeon_bits_per_pixel(draw->color_rb[0]);
                }
index 328b545fdbfceaec146273b01fc32718437f8117..bd7343f4082300ad920e4edce9c9daefd08e903d 100644 (file)
@@ -426,23 +426,6 @@ struct radeon_context {
     */
    GLboolean front_buffer_dirty;
 
-   /**
-    * Track whether front-buffer rendering is currently enabled
-    *
-    * A separate flag is used to track this in order to support MRT more
-    * easily.
-    */
-   GLboolean is_front_buffer_rendering;
-
-   /**
-    * Track whether front-buffer is the current read target.
-    *
-    * This is closely associated with is_front_buffer_rendering, but may
-    * be set separately.  The DRI2 fake front buffer must be referenced
-    * either way.
-    */
-   GLboolean is_front_buffer_reading;
-
    struct {
        struct radeon_query_object *current;
        struct radeon_state_atom queryobj;