From: Marek Olšák Date: Thu, 24 Jan 2013 20:14:30 +0000 (+0100) Subject: st/mesa: get rid of GET_CURRENT_CONTEXT in st_choose_format X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b92057a9837dfd87687d045609d1658089188998;p=mesa.git st/mesa: get rid of GET_CURRENT_CONTEXT in st_choose_format Reviewed-by: Brian Paul --- diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 26d1923b541..ba4f17a3da3 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -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); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index d042ebabfd8..72bc960b01d 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 80a440d18eb..ab5ff27b3f5 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, FALSE); 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 fd6d01b3af6..fba0eebeca4 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -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) { diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index 50588d8d496..aee624d2492 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, 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); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 584eaa9817a..ed37098483e 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, FALSE);