Mesa (main): mesa/st: move renderbuffer format choosing wrapper into mesa.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 24 21:35:12 UTC 2022


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Jan 24 16:17:26 2022 +1000

mesa/st: move renderbuffer format choosing wrapper into mesa.

This moves this and cleans up the results.

Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>

---

 src/mesa/main/renderbuffer.c       | 43 +++++++++++++++++++++++++++-----------
 src/mesa/state_tracker/st_format.c | 20 ------------------
 src/mesa/state_tracker/st_format.h |  6 +-----
 3 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index 13bb27bf210..fa03e014f04 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -38,6 +38,27 @@
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_format.h"
 
+/**
+ * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
+ */
+static enum pipe_format
+choose_renderbuffer_format(struct gl_context *ctx,
+                           GLenum internalFormat, unsigned sample_count,
+                           unsigned storage_sample_count)
+{
+   unsigned bindings;
+   if (_mesa_is_depth_or_stencil_format(internalFormat))
+      bindings = PIPE_BIND_DEPTH_STENCIL;
+   else
+      bindings = PIPE_BIND_RENDER_TARGET;
+   return st_choose_format(st_context(ctx), internalFormat, GL_NONE, GL_NONE,
+                           PIPE_TEXTURE_2D, sample_count,
+                           storage_sample_count, bindings,
+                           false, false);
+}
+
+
+
 /**
  * Delete a gl_framebuffer.
  * This is the default function for renderbuffer->Delete().
@@ -68,7 +89,6 @@ renderbuffer_alloc_sw_storage(struct gl_context *ctx,
                               GLenum internalFormat,
                               GLuint width, GLuint height)
 {
-   struct st_context *st = st_context(ctx);
    enum pipe_format format;
    size_t size;
 
@@ -77,14 +97,14 @@ renderbuffer_alloc_sw_storage(struct gl_context *ctx,
 
    if (internalFormat == GL_RGBA16_SNORM) {
       /* Special case for software accum buffers.  Otherwise, if the
-       * call to st_choose_renderbuffer_format() fails (because the
+       * call to choose_renderbuffer_format() fails (because the
        * driver doesn't support signed 16-bit/channel colors) we'd
        * just return without allocating the software accum buffer.
        */
       format = PIPE_FORMAT_R16G16B16A16_SNORM;
    }
    else {
-      format = st_choose_renderbuffer_format(st, internalFormat, 0, 0);
+      format = choose_renderbuffer_format(ctx, internalFormat, 0, 0);
 
       /* Not setting gl_renderbuffer::Format here will cause
        * FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called.
@@ -178,8 +198,8 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
             for (unsigned samples = start;
                  samples <= ctx->Const.MaxDepthStencilFramebufferSamples;
                  samples++) {
-               format = st_choose_renderbuffer_format(st, internalFormat,
-                                                      samples, samples);
+               format = choose_renderbuffer_format(ctx, internalFormat,
+                                                   samples, samples);
 
                if (format != PIPE_FORMAT_NONE) {
                   rb->NumSamples = samples;
@@ -195,9 +215,9 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
                for (unsigned samples = MAX2(start, storage_samples);
                     samples <= ctx->Const.MaxColorFramebufferSamples;
                     samples++) {
-                  format = st_choose_renderbuffer_format(st, internalFormat,
-                                                         samples,
-                                                         storage_samples);
+                  format = choose_renderbuffer_format(ctx, internalFormat,
+                                                      samples,
+                                                      storage_samples);
 
                   if (format != PIPE_FORMAT_NONE) {
                      rb->NumSamples = samples;
@@ -211,8 +231,8 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
       } else {
          for (unsigned samples = start; samples <= ctx->Const.MaxSamples;
               samples++) {
-            format = st_choose_renderbuffer_format(st, internalFormat,
-                                                   samples, samples);
+            format = choose_renderbuffer_format(ctx, internalFormat,
+                                                samples, samples);
 
             if (format != PIPE_FORMAT_NONE) {
                rb->NumSamples = samples;
@@ -222,7 +242,7 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
          }
       }
    } else {
-      format = st_choose_renderbuffer_format(st, internalFormat, 0, 0);
+      format = choose_renderbuffer_format(ctx, internalFormat, 0, 0);
    }
 
    /* Not setting gl_renderbuffer::Format here will cause
@@ -543,7 +563,6 @@ void
 _mesa_update_renderbuffer_surface(struct gl_context *ctx,
                                   struct gl_renderbuffer *rb)
 {
-   struct st_context *st = st_context(ctx);
    struct pipe_context *pipe = ctx->pipe;
    struct pipe_resource *resource = rb->texture;
    const struct gl_texture_object *stTexObj = NULL;
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 105d84016cf..94b387df3b8 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1206,26 +1206,6 @@ success:
 }
 
 
-/**
- * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
- */
-enum pipe_format
-st_choose_renderbuffer_format(struct st_context *st,
-                              GLenum internalFormat, unsigned sample_count,
-                              unsigned storage_sample_count)
-{
-   unsigned bindings;
-   if (_mesa_is_depth_or_stencil_format(internalFormat))
-      bindings = PIPE_BIND_DEPTH_STENCIL;
-   else
-      bindings = PIPE_BIND_RENDER_TARGET;
-   return st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
-                           PIPE_TEXTURE_2D, sample_count,
-                           storage_sample_count, bindings,
-                           false, false);
-}
-
-
 /**
  * Given an OpenGL user-requested format and type, and swapBytes state,
  * return the format which exactly matches those parameters, so that
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index e7228520b37..33f43e742dd 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -40,6 +40,7 @@ extern "C" {
 #endif
 
 struct gl_context;
+struct st_context;
 struct pipe_screen;
 
 
@@ -57,11 +58,6 @@ st_choose_format(struct st_context *st, GLenum internalFormat,
                  unsigned storage_sample_count,
                  unsigned bindings, bool swap_bytes, bool allow_dxt);
 
-extern enum pipe_format
-st_choose_renderbuffer_format(struct st_context *st,
-                              GLenum internalFormat, unsigned sample_count,
-                              unsigned storage_sample_count);
-
 extern enum pipe_format
 st_choose_matching_format_noverify(struct st_context *st,
                                    GLenum format, GLenum type, GLboolean swapBytes);



More information about the mesa-commit mailing list