[Mesa-dev] [PATCH 5/9] st/mesa: get rid of GET_CURRENT_CONTEXT in st_choose_format

Marek Olšák maraeo at gmail.com
Sun Jan 27 12:52:53 PST 2013


---
 src/mesa/state_tracker/st_cb_drawpixels.c |    4 ++--
 src/mesa/state_tracker/st_cb_fbo.c        |    8 ++++----
 src/mesa/state_tracker/st_cb_texture.c    |    2 +-
 src/mesa/state_tracker/st_format.c        |   20 ++++++++++----------
 src/mesa/state_tracker/st_format.h        |    4 ++--
 src/mesa/state_tracker/st_texture.c       |    3 +--
 6 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index c944b81..f29c8d0 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1497,14 +1497,14 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
    else {
       /* srcFormat can't be used as a texture format */
       if (type == GL_DEPTH) {
-         texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
+         texFormat = st_choose_format(st, GL_DEPTH_COMPONENT,
                                       GL_NONE, GL_NONE, st->internal_target,
 				      sample_count, PIPE_BIND_DEPTH_STENCIL);
          assert(texFormat != PIPE_FORMAT_NONE);
       }
       else {
          /* default color format */
-         texFormat = st_choose_format(screen, GL_RGBA,
+         texFormat = st_choose_format(st, GL_RGBA,
                                       GL_NONE, GL_NONE, st->internal_target,
                                       sample_count, PIPE_BIND_SAMPLER_VIEW);
          assert(texFormat != PIPE_FORMAT_NONE);
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index d042eba..72bc960 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -63,7 +63,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx,
                                  GLenum internalFormat,
                                  GLuint width, GLuint height)
 {
-   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+   struct st_context *st = st_context(ctx);
    struct st_renderbuffer *strb = st_renderbuffer(rb);
    enum pipe_format format;
    size_t size;
@@ -80,7 +80,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx,
       format = PIPE_FORMAT_R16G16B16A16_SNORM;
    }
    else {
-      format = st_choose_renderbuffer_format(screen, internalFormat, 0);
+      format = st_choose_renderbuffer_format(st, internalFormat, 0);
 
       /* Not setting gl_renderbuffer::Format here will cause
        * FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called.
@@ -153,7 +153,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
       unsigned i;
 
       for (i = rb->NumSamples; i <= ctx->Const.MaxSamples; i++) {
-         format = st_choose_renderbuffer_format(screen, internalFormat, i);
+         format = st_choose_renderbuffer_format(st, internalFormat, i);
 
          if (format != PIPE_FORMAT_NONE) {
             rb->NumSamples = i;
@@ -161,7 +161,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
          }
       }
    } else {
-      format = st_choose_renderbuffer_format(screen, internalFormat, 0);
+      format = st_choose_renderbuffer_format(st, internalFormat, 0);
    }
 
    /* Not setting gl_renderbuffer::Format here will cause
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 3cea2df..95a6af2 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -596,7 +596,7 @@ decompress_with_blit(struct gl_context * ctx,
    pipe_target = gl_target_to_pipe(gl_target);
 
    /* Find the best match for the format+type combo. */
-   pipe_format = st_choose_format(pipe->screen, GL_RGBA8, format, type,
+   pipe_format = st_choose_format(st, GL_RGBA8, format, type,
                                   pipe_target, 0, bind);
    if (pipe_format == PIPE_FORMAT_NONE) {
       /* unable to get an rgba format!?! */
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 41142bf..4abfb3c 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1511,17 +1511,17 @@ find_exact_format(GLint internalFormat, GLenum format, GLenum type)
  * \param bindings  bitmask of PIPE_BIND_x flags.
  */
 enum pipe_format
-st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
+st_choose_format(struct st_context *st, GLenum internalFormat,
                  GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
                  unsigned bindings)
 {
-   GET_CURRENT_CONTEXT(ctx); /* XXX this should be a function parameter */
+   struct pipe_screen *screen = st->pipe->screen;
    int i, j;
    enum pipe_format pf;
 
    /* can't render to compressed formats at this time */
-   if (_mesa_is_compressed_format(ctx, internalFormat)
+   if (_mesa_is_compressed_format(st->ctx, internalFormat)
        && (bindings & ~PIPE_BIND_SAMPLER_VIEW)) {
       return PIPE_FORMAT_NONE;
    }
@@ -1556,7 +1556,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
  * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
  */
 enum pipe_format
-st_choose_renderbuffer_format(struct pipe_screen *screen,
+st_choose_renderbuffer_format(struct st_context *st,
                               GLenum internalFormat, unsigned sample_count)
 {
    uint usage;
@@ -1564,7 +1564,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
       usage = PIPE_BIND_DEPTH_STENCIL;
    else
       usage = PIPE_BIND_RENDER_TARGET;
-   return st_choose_format(screen, internalFormat, GL_NONE, GL_NONE, PIPE_TEXTURE_2D,
+   return st_choose_format(st, internalFormat, GL_NONE, GL_NONE, PIPE_TEXTURE_2D,
                            sample_count, usage);
 }
 
@@ -1573,7 +1573,7 @@ gl_format
 st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
 				  GLenum format, GLenum type, GLboolean renderable)
 {
-   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+   struct st_context *st = st_context(ctx);
    enum pipe_format pFormat;
    uint bindings;
 
@@ -1591,12 +1591,12 @@ st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
 	 bindings |= PIPE_BIND_RENDER_TARGET;
    }
 
-   pFormat = st_choose_format(screen, internalFormat, format, type,
+   pFormat = st_choose_format(st, internalFormat, format, type,
                               PIPE_TEXTURE_2D, 0, bindings);
 
    if (pFormat == PIPE_FORMAT_NONE) {
       /* try choosing format again, this time without render target bindings */
-      pFormat = st_choose_format(screen, internalFormat, format, type,
+      pFormat = st_choose_format(st, internalFormat, format, type,
                                  PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
    }
 
@@ -1644,7 +1644,7 @@ size_t
 st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
                          int samples[16])
 {
-   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+   struct st_context *st = st_context(ctx);
    enum pipe_format format;
    unsigned i, bind, num_sample_counts = 0;
 
@@ -1655,7 +1655,7 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
 
    /* Set sample counts in descending order. */
    for (i = 16; i > 1; i--) {
-      format = st_choose_format(screen, internalFormat, GL_NONE, GL_NONE,
+      format = st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
                                 PIPE_TEXTURE_2D, i, bind);
 
       if (format != PIPE_FORMAT_NONE) {
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index cb6e5bc..b4442bd 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -48,13 +48,13 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
 
 
 extern enum pipe_format
-st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
+st_choose_format(struct st_context *st, GLenum internalFormat,
                  GLenum format, GLenum type,
                  enum pipe_texture_target target, unsigned sample_count,
                  unsigned bindings);
 
 extern enum pipe_format
-st_choose_renderbuffer_format(struct pipe_screen *screen,
+st_choose_renderbuffer_format(struct st_context *st,
                               GLenum internalFormat, unsigned sample_count);
 
 
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index ee4d762..5741ed5 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -391,13 +391,12 @@ struct pipe_resource *
 st_create_color_map_texture(struct gl_context *ctx)
 {
    struct st_context *st = st_context(ctx);
-   struct pipe_context *pipe = st->pipe;
    struct pipe_resource *pt;
    enum pipe_format format;
    const uint texSize = 256; /* simple, and usually perfect */
 
    /* find an RGBA texture format */
-   format = st_choose_format(pipe->screen, GL_RGBA, GL_NONE, GL_NONE,
+   format = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE,
                              PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
 
    /* create texture for color map/table */
-- 
1.7.10.4



More information about the mesa-dev mailing list