mesa/st: move st_ReadBuffer functionality into mesa
authorDave Airlie <airlied@redhat.com>
Tue, 21 Dec 2021 05:46:35 +0000 (15:46 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 24 Jan 2022 21:03:42 +0000 (07:03 +1000)
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>

src/mesa/main/buffers.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_fbo.h

index d3afd18..82da74e 100644 (file)
 #include "fbobject.h"
 #include "hash.h"
 #include "mtypes.h"
+#include "state.h"
 #include "util/bitscan.h"
 #include "util/u_math.h"
 #include "api_exec_decl.h"
 
 #include "state_tracker/st_cb_fbo.h"
+#include "state_tracker/st_manager.h"
+#include "state_tracker/st_atom.h"
+#include "state_tracker/st_context.h"
 
 #define BAD_MASK ~0u
 
@@ -932,7 +936,19 @@ read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
 
    /* Call the device driver function only if fb is the bound read buffer */
    if (fb == ctx->ReadBuffer) {
-      st_ReadBuffer(ctx, buffer);
+      /* Check if we need to allocate a front color buffer.
+       * Front buffers are often allocated on demand (other color buffers are
+       * always allocated in advance).
+       */
+      if ((fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT ||
+           fb->_ColorReadBufferIndex == BUFFER_FRONT_RIGHT) &&
+          fb->Attachment[fb->_ColorReadBufferIndex].Type == GL_NONE) {
+         assert(_mesa_is_winsys_fbo(fb));
+         /* add the buffer */
+         st_manager_add_color_renderbuffer(st_context(ctx), fb, fb->_ColorReadBufferIndex);
+         _mesa_update_state(ctx);
+         st_validate_state(st_context(ctx), ST_PIPELINE_UPDATE_FRAMEBUFFER);
+      }
    }
 }
 
index 936417b..107d83d 100644 (file)
@@ -563,36 +563,6 @@ st_DrawBufferAllocate(struct gl_context *ctx)
    }
 }
 
-
-/**
- * Called via glReadBuffer.  As with st_DrawBufferAllocate, we use this
- * function to check if we need to allocate a renderbuffer on demand.
- */
-void
-st_ReadBuffer(struct gl_context *ctx, GLenum buffer)
-{
-   struct st_context *st = st_context(ctx);
-   struct gl_framebuffer *fb = ctx->ReadBuffer;
-
-   (void) buffer;
-
-   /* Check if we need to allocate a front color buffer.
-    * Front buffers are often allocated on demand (other color buffers are
-    * always allocated in advance).
-    */
-   if ((fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT ||
-        fb->_ColorReadBufferIndex == BUFFER_FRONT_RIGHT) &&
-       fb->Attachment[fb->_ColorReadBufferIndex].Type == GL_NONE) {
-      assert(_mesa_is_winsys_fbo(fb));
-      /* add the buffer */
-      st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex);
-      _mesa_update_state(ctx);
-      st_validate_state(st, ST_PIPELINE_UPDATE_FRAMEBUFFER);
-   }
-}
-
-
-
 /**
  * Called via ctx->Driver.MapRenderbuffer.
  */
index da1a1da..675d9cb 100644 (file)
@@ -79,7 +79,6 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
                               GLenum internalFormat,
                               GLuint width, GLuint height);
 void st_DrawBufferAllocate(struct gl_context *ctx);
-void st_ReadBuffer(struct gl_context *ctx, GLenum buffer);
 
 void st_MapRenderbuffer(struct gl_context *ctx,
                         struct gl_renderbuffer *rb,