OSDN Git Service

st/mesa: get rid of GET_CURRENT_CONTEXT in st_choose_format
authorMarek Olšák <maraeo@gmail.com>
Thu, 24 Jan 2013 20:14:30 +0000 (21:14 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 6 Feb 2013 13:51:32 +0000 (14:51 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h
src/mesa/state_tracker/st_texture.c

index 26d1923..ba4f17a 100644 (file)
@@ -492,7 +492,7 @@ make_texture(struct st_context *st,
    /* Choose a pixel format for the temp texture which will hold the
     * image to draw.
     */
-   pipeFormat = st_choose_format(pipe->screen, intFormat, format, type,
+   pipeFormat = st_choose_format(st, intFormat, format, type,
                                  PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW,
                                  FALSE);
    assert(pipeFormat != PIPE_FORMAT_NONE);
@@ -1499,7 +1499,7 @@ 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,
                                       FALSE);
@@ -1507,7 +1507,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
       }
       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,
                                       FALSE);
index d042eba..72bc960 100644 (file)
@@ -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
index 80a440d..ab5ff27 100644 (file)
@@ -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, FALSE);
    if (pipe_format == PIPE_FORMAT_NONE) {
       /* unable to get an rgba format!?! */
index fd6d01b..fba0eeb 100644 (file)
@@ -1522,17 +1522,17 @@ find_exact_format(GLint internalFormat, GLenum format, GLenum type)
  *                   when we're getting called from gl[Copy]TexImage().
  */
 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, boolean allow_dxt)
 {
-   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;
    }
@@ -1568,7 +1568,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;
@@ -1576,7 +1576,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,
+   return st_choose_format(st, internalFormat, GL_NONE, GL_NONE,
                            PIPE_TEXTURE_2D, sample_count, usage, FALSE);
 }
 
@@ -1594,7 +1594,7 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
       internalFormat == GL_RGB || internalFormat == GL_RGBA ||
       internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 ||
       internalFormat == GL_BGRA;
-   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+   struct st_context *st = st_context(ctx);
    enum pipe_format pFormat;
    unsigned bindings;
 
@@ -1618,12 +1618,12 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
         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, ctx->Mesa_DXTn);
 
    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,
                                  ctx->Mesa_DXTn);
    }
@@ -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, FALSE);
 
       if (format != PIPE_FORMAT_NONE) {
index 50588d8..aee624d 100644 (file)
@@ -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, boolean allow_dxt);
 
 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);
 
 
index 584eaa9..ed37098 100644 (file)
@@ -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,
                              FALSE);