Module: Mesa
Branch: main
Commit: 57dcaac31d46c552f57deacc2b3095504eaab1db
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=57dcaac31d46c552f57deacc2b3095504eaab1db

Author: Dave Airlie <[email protected]>
Date:   Tue Dec 21 15:46:35 2021 +1000

mesa/st: move st_ReadBuffer functionality into mesa

Reviewed-by: Kristian H. Kristensen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>

---

 src/mesa/main/buffers.c            | 18 +++++++++++++++++-
 src/mesa/state_tracker/st_cb_fbo.c | 30 ------------------------------
 src/mesa/state_tracker/st_cb_fbo.h |  1 -
 3 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d3afd180121..82da74e46c1 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -37,11 +37,15 @@
 #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);
+      }
    }
 }
 
diff --git a/src/mesa/state_tracker/st_cb_fbo.c 
b/src/mesa/state_tracker/st_cb_fbo.c
index 936417bfc95..107d83d1124 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -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.
  */
diff --git a/src/mesa/state_tracker/st_cb_fbo.h 
b/src/mesa/state_tracker/st_cb_fbo.h
index da1a1dacbd6..675d9cb59a2 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -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,

Reply via email to