From 76c7ad2e7d387feefe58dc2116b613fe11a8b273 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 14:00:50 -0600 Subject: [PATCH] st/mesa: clean-up: use st_context() everywhere --- .../state_tracker/st_atom_pixeltransfer.c | 15 ++-- src/mesa/state_tracker/st_cb_accum.c | 4 +- src/mesa/state_tracker/st_cb_bitmap.c | 22 ++--- src/mesa/state_tracker/st_cb_blit.c | 2 +- src/mesa/state_tracker/st_cb_clear.c | 13 ++- src/mesa/state_tracker/st_cb_condrender.c | 4 +- src/mesa/state_tracker/st_cb_drawpixels.c | 2 +- src/mesa/state_tracker/st_cb_eglimage.c | 4 +- src/mesa/state_tracker/st_cb_fbo.c | 19 ++-- src/mesa/state_tracker/st_cb_feedback.c | 4 +- src/mesa/state_tracker/st_cb_flush.c | 4 +- src/mesa/state_tracker/st_cb_queryobj.c | 10 +-- src/mesa/state_tracker/st_cb_rasterpos.c | 6 +- src/mesa/state_tracker/st_cb_readpixels.c | 11 +-- src/mesa/state_tracker/st_cb_texture.c | 90 ++++++++++--------- src/mesa/state_tracker/st_debug.c | 2 +- src/mesa/state_tracker/st_draw.c | 23 ++--- src/mesa/state_tracker/st_draw_feedback.c | 8 +- src/mesa/state_tracker/st_format.c | 5 +- src/mesa/state_tracker/st_gen_mipmap.c | 4 +- 20 files changed, 138 insertions(+), 114 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index e8e67f80305..29c4d092bf0 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -115,7 +115,8 @@ make_state_key(GLcontext *ctx, struct state_key *key) static struct pipe_resource * create_color_map_texture(GLcontext *ctx) { - struct pipe_context *pipe = ctx->st->pipe; + 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 */ @@ -125,7 +126,7 @@ create_color_map_texture(GLcontext *ctx) PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); /* create texture for color map/table */ - pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, + pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW); return pt; } @@ -137,7 +138,8 @@ create_color_map_texture(GLcontext *ctx) static void load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_transfer *transfer; const GLuint rSize = ctx->PixelMaps.RtoR.Size; const GLuint gSize = ctx->PixelMaps.GtoG.Size; @@ -185,7 +187,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) static struct gl_fragment_program * get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct prog_instruction inst[MAX_INST]; struct gl_program_parameter_list *params; struct gl_fragment_program *fp; @@ -256,8 +258,9 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key) /* create the colormap/texture now if not already done */ if (!st->pixel_xfer.pixelmap_texture) { st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx); - st->pixel_xfer.pixelmap_sampler_view = st_create_texture_sampler_view(ctx->st->pipe, - st->pixel_xfer.pixelmap_texture); + st->pixel_xfer.pixelmap_sampler_view = + st_create_texture_sampler_view(st->pipe, + st->pixel_xfer.pixelmap_texture); } /* with a little effort, we can do four pixel map look-ups with diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 2732969d956..0101837f999 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -223,7 +223,7 @@ accum_return(GLcontext *ctx, GLfloat value, struct st_renderbuffer *acc_strb, struct st_renderbuffer *color_strb) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; const GLubyte *colormask = ctx->Color.ColorMask[0]; enum pipe_transfer_usage usage; struct pipe_transfer *color_trans; @@ -287,7 +287,7 @@ accum_return(GLcontext *ctx, GLfloat value, static void st_Accum(GLcontext *ctx, GLenum op, GLfloat value) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_renderbuffer *acc_strb = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); struct st_renderbuffer *color_strb diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 12bba050a61..797c0ba7f55 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -114,6 +114,7 @@ struct bitmap_cache static struct st_fragment_program * make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex) { + struct st_context *st = st_context(ctx); struct st_fragment_program *stfp; struct gl_program *p; GLuint ic = 0; @@ -145,7 +146,7 @@ make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex) p->Instructions[ic].Opcode = OPCODE_KIL; p->Instructions[ic].SrcReg[0].File = PROGRAM_TEMPORARY; - if (ctx->st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM) + if (st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM) p->Instructions[ic].SrcReg[0].Swizzle = SWIZZLE_XXXX; p->Instructions[ic].SrcReg[0].Index = 0; @@ -187,7 +188,7 @@ find_free_bit(uint bitfield) static struct st_fragment_program * combined_bitmap_fragment_program(GLcontext *ctx) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_fragment_program *stfp = st->fp; if (!stfp->bitmap_program) { @@ -258,7 +259,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_transfer *transfer; ubyte *dest; struct pipe_resource *pt; @@ -272,7 +274,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /** * Create texture to hold bitmap pattern. */ - pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format, + pt = st_texture_create(st, PIPE_TEXTURE_2D, st->bitmap.tex_format, 0, width, height, 1, PIPE_BIND_SAMPLER_VIEW); if (!pt) { @@ -280,7 +282,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, return NULL; } - transfer = st_no_flush_get_tex_transfer(st_context(ctx), pt, 0, 0, 0, + transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, width, height); @@ -288,7 +290,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /* Put image into texture transfer */ memset(dest, 0xff, height * transfer->stride); - unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap, + unpack_bitmap(st, 0, 0, width, height, unpack, bitmap, dest, transfer->stride); _mesa_unmap_pbo_source(ctx, unpack); @@ -400,9 +402,9 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_sampler_view *sv, const GLfloat *color) { - struct st_context *st = ctx->st; - struct pipe_context *pipe = ctx->st->pipe; - struct cso_context *cso = ctx->st->cso_context; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; + struct cso_context *cso = st->cso_context; struct st_fragment_program *stfp; GLuint maxSize; GLuint offset; @@ -732,7 +734,7 @@ static void st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_resource *pt; if (width == 0 || height == 0) diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index d6fdfaccd63..1c8dc0c07fb 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -68,7 +68,7 @@ st_BlitFramebuffer(GLcontext *ctx, { const GLbitfield depthStencil = (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; const uint pFilter = ((filter == GL_NEAREST) ? PIPE_TEX_MIPFILTER_NEAREST diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 2f77aff7a6c..736180ddc6c 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -109,11 +109,10 @@ st_destroy_clear(struct st_context *st) * Coords are clip coords with y=0=bottom. */ static void -draw_quad(GLcontext *ctx, +draw_quad(struct st_context *st, float x0, float y0, float x1, float y1, GLfloat z, const GLfloat color[4]) { - struct st_context *st = ctx->st; struct pipe_context *pipe = st->pipe; /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as @@ -193,7 +192,7 @@ static void clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); const struct gl_framebuffer *fb = ctx->DrawBuffer; const GLfloat fb_width = (GLfloat) fb->Width; const GLfloat fb_height = (GLfloat) fb->Height; @@ -295,7 +294,7 @@ clear_with_quad(GLcontext *ctx, cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); /* draw quad matching scissor rect (XXX verify coord round-off) */ - draw_quad(ctx, x0, y0, x1, y1, + draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, ctx->Color.ClearColor); /* Restore pipe state */ @@ -448,7 +447,7 @@ st_Clear(GLcontext *ctx, GLbitfield mask) { static const GLbitfield BUFFER_BITS_DS = (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct gl_renderbuffer *depthRb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; struct gl_renderbuffer *stencilRb @@ -530,8 +529,8 @@ st_Clear(GLcontext *ctx, GLbitfield mask) mask & BUFFER_BIT_DEPTH, mask & BUFFER_BIT_STENCIL); } else if (clear_buffers) - ctx->st->pipe->clear(ctx->st->pipe, clear_buffers, ctx->Color.ClearColor, - ctx->Depth.Clear, ctx->Stencil.Clear); + st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor, + ctx->Depth.Clear, ctx->Stencil.Clear); if (mask & BUFFER_BIT_ACCUM) st_clear_accum_buffer(ctx, diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c index 8483b93bd85..b509d43b7c6 100644 --- a/src/mesa/state_tracker/st_cb_condrender.c +++ b/src/mesa/state_tracker/st_cb_condrender.c @@ -51,7 +51,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q, GLenum mode) { struct st_query_object *stq = st_query_object(q); - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; uint m; switch (mode) { @@ -82,7 +82,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q, static void st_EndConditionalRender(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; (void) q; pipe->render_condition(pipe, NULL, 0); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 2c18ded2abf..e059002f157 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -858,7 +858,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint dstx, GLint dsty) { struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer); - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; enum pipe_transfer_usage usage; struct pipe_transfer *ptDraw; ubyte *drawMap; diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index a924f872232..0fa1848e232 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -74,7 +74,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLeglImageOES image_handle) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(rb); struct pipe_surface *ps; unsigned usage; @@ -138,7 +138,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target, struct gl_texture_image *texImage, GLeglImageOES image_handle) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_surface *ps; unsigned usage; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index e59ece7e966..e5c956d561d 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -64,7 +64,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct st_renderbuffer *strb = st_renderbuffer(rb); enum pipe_format format; @@ -312,9 +313,9 @@ st_render_texture(GLcontext *ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = ctx->st->pipe->screen; + struct pipe_screen *screen = pipe->screen; struct st_renderbuffer *strb; struct gl_renderbuffer *rb; struct pipe_resource *pt = st_get_texobj_resource(att->Texture); @@ -403,12 +404,13 @@ static void st_finish_render_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att) { + struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer); if (!strb) return; - st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL ); + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); strb->rtt = NULL; @@ -455,7 +457,8 @@ st_validate_attachment(struct pipe_screen *screen, static void st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; const struct gl_renderbuffer *depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; const struct gl_renderbuffer *stencilRb = @@ -496,6 +499,7 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) static void st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) { + struct st_context *st = st_context(ctx); GLframebuffer *fb = ctx->DrawBuffer; GLuint i; @@ -505,7 +509,7 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) /* add the renderbuffers on demand */ for (i = 0; i < fb->_NumColorDrawBuffers; i++) { gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i]; - st_manager_add_color_renderbuffer(ctx->st, fb, idx); + st_manager_add_color_renderbuffer(st, fb, idx); } } @@ -516,12 +520,13 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers) static void st_ReadBuffer(GLcontext *ctx, GLenum buffer) { + struct st_context *st = st_context(ctx); GLframebuffer *fb = ctx->ReadBuffer; (void) buffer; /* add the renderbuffer on demand */ - st_manager_add_color_renderbuffer(ctx->st, fb, fb->_ColorReadBufferIndex); + st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex); } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 37b1fb55f4a..c85d3da84a2 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -80,7 +80,7 @@ static void feedback_vertex(GLcontext *ctx, const struct draw_context *draw, const struct vertex_header *v) { - const struct st_context *st = ctx->st; + const struct st_context *st = st_context(ctx); GLfloat win[4]; const GLfloat *color, *texcoord; GLuint slot; @@ -271,7 +271,7 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw) static void st_RenderMode(GLcontext *ctx, GLenum newMode ) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct draw_context *draw = st->draw; if (newMode == GL_RENDER) { diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 415e8f3d2a2..8c9959f9544 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -115,7 +115,7 @@ void st_finish( struct st_context *st ) */ static void st_glFlush(GLcontext *ctx) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); /* Don't call st_finish() here. It is not the state tracker's * responsibilty to inject sleeps in the hope of avoiding buffer @@ -135,7 +135,7 @@ static void st_glFlush(GLcontext *ctx) */ static void st_glFinish(GLcontext *ctx) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); st_finish(st); diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index c66729b1244..1896663932c 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -61,7 +61,7 @@ st_NewQueryObject(GLcontext *ctx, GLuint id) static void st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); if (stq->pq) { @@ -76,7 +76,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) static void st_BeginQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); switch (q->Target) { @@ -96,7 +96,7 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q) static void st_EndQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); pipe->end_query(pipe, stq->pq); @@ -106,7 +106,7 @@ st_EndQuery(GLcontext *ctx, struct gl_query_object *q) static void st_WaitQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); /* this function should only be called if we don't have a ready result */ @@ -128,7 +128,7 @@ st_WaitQuery(GLcontext *ctx, struct gl_query_object *q) static void st_CheckQuery(GLcontext *ctx, struct gl_query_object *q) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); assert(!q->Ready); /* we should not get called if Ready is TRUE */ q->Ready = pipe->get_query_result(pipe, stq->pq, FALSE, &q->Result); diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 752b411b5fc..843f3200278 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -133,7 +133,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) { struct rastpos_stage *rs = rastpos_stage(stage); GLcontext *ctx = rs->ctx; - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); const GLfloat height = (GLfloat) ctx->DrawBuffer->Height; const GLuint *outputMapping = st->vertex_result_to_slot; const GLfloat *pos; @@ -221,7 +221,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) static void st_RasterPos(GLcontext *ctx, const GLfloat v[4]) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct draw_context *draw = st->draw; struct rastpos_stage *rs; @@ -239,7 +239,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4]) draw_set_rasterize_stage(st->draw, st->rastpos_stage); /* make sure everything's up to date */ - st_validate_state(ctx->st); + st_validate_state(st); /* This will get set only if rastpos_point(), above, gets called */ ctx->Current.RasterPosValid = GL_FALSE; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 67c3b9adbb9..69950ac44bb 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -63,7 +63,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, GLvoid *pixels) { struct gl_framebuffer *fb = ctx->ReadBuffer; - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer); struct pipe_transfer *pt; ubyte *stmap; @@ -220,7 +220,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, /*printf("st_fast_readpixels combo %d\n", (GLint) combo);*/ { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct pipe_transfer *trans; const GLubyte *map; GLubyte *dst; @@ -322,7 +322,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *pack, GLvoid *dest) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; GLfloat temp[MAX_WIDTH][4]; const GLbitfield transferOps = ctx->_ImageTransferState; GLsizei i, j; @@ -337,7 +338,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* XXX convolution not done yet */ assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0); - st_validate_state(ctx->st); + st_validate_state(st); /* Do all needed clipping here, so that we can forget about it later */ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { @@ -349,7 +350,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (!dest) return; - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL) { diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 5b7d8c0aae1..613fff019d9 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -120,17 +120,18 @@ static void st_DeleteTextureObject(GLcontext *ctx, struct gl_texture_object *texObj) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(texObj); if (stObj->pt) pipe_resource_reference(&stObj->pt, NULL); if (stObj->sampler_view) { - if (stObj->sampler_view->context != ctx->st->pipe) { + if (stObj->sampler_view->context != st->pipe) { /* Take "ownership" of this texture sampler view by setting * its context pointer to this context. This avoids potential * crashes when the texture object is shared among contexts * and the original/owner context has already been destroyed. */ - stObj->sampler_view->context = ctx->st->pipe; + stObj->sampler_view->context = st->pipe; } pipe_sampler_view_reference(&stObj->sampler_view, NULL); } @@ -389,7 +390,8 @@ compress_with_blit(GLcontext * ctx, { const GLuint dstImageOffsets[1] = {0}; struct st_texture_image *stImage = st_texture_image(texImage); - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; gl_format mesa_format; struct pipe_resource templ; @@ -466,7 +468,7 @@ compress_with_blit(GLcontext * ctx, /* copy / compress image */ - util_blit_pixels_tex(ctx->st->blit, + util_blit_pixels_tex(st->blit, src_view, /* sampler view (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ @@ -501,7 +503,8 @@ st_TexImage(GLcontext * ctx, struct gl_texture_image *texImage, GLsizei imageSize, GLboolean compressed_src) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct st_texture_object *stObj = st_texture_object(texObj); struct st_texture_image *stImage = st_texture_image(texImage); GLint postConvWidth, postConvHeight; @@ -596,13 +599,13 @@ st_TexImage(GLcontext * ctx, } if (!stObj->pt) { - guess_and_alloc_texture(ctx->st, stObj, stImage); + guess_and_alloc_texture(st, stObj, stImage); if (!stObj->pt) { /* Probably out of memory. * Try flushing any pending rendering, then retry. */ - st_finish(ctx->st); - guess_and_alloc_texture(ctx->st, stObj, stImage); + st_finish(st); + guess_and_alloc_texture(st, stObj, stImage); if (!stObj->pt) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); return; @@ -667,7 +670,7 @@ st_TexImage(GLcontext * ctx, else transfer_usage = PIPE_TRANSFER_WRITE; - texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + texImage->Data = st_texture_image_map(st, stImage, 0, transfer_usage, 0, 0, stImage->base.Width, stImage->base.Height); @@ -748,9 +751,9 @@ st_TexImage(GLcontext * ctx, if (stImage->pt && i + 1 < depth) { /* unmap this slice */ - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); /* map next slice of 3D texture */ - texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1, + texImage->Data = st_texture_image_map(st, stImage, i + 1, transfer_usage, 0, 0, stImage->base.Width, stImage->base.Height); @@ -763,7 +766,7 @@ done: _mesa_unmap_teximage_pbo(ctx, unpack); if (stImage->pt && texImage->Data) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -840,7 +843,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); struct st_texture_object *stObj = st_texture_object(texObj); @@ -864,7 +868,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, } /* blit/render/decompress */ - util_blit_pixels_tex(ctx->st->blit, + util_blit_pixels_tex(st->blit, src_view, /* pipe_resource (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ @@ -936,6 +940,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage, GLboolean compressed_dst) { + struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); const GLuint dstImageStride = _mesa_image_image_stride(&ctx->Pack, texImage->Width, texImage->Height, @@ -962,10 +967,10 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, */ unsigned face = _mesa_tex_target_to_face(target); - st_teximage_flush_before_map(ctx->st, stImage->pt, face, level, + st_teximage_flush_before_map(st, stImage->pt, face, level, PIPE_TRANSFER_READ); - texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, stImage->base.Height); @@ -1000,9 +1005,9 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, if (stImage->pt && i + 1 < depth) { /* unmap this slice */ - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); /* map next slice of 3D texture */ - texImage->Data = st_texture_image_map(ctx->st, stImage, i + 1, + texImage->Data = st_texture_image_map(st, stImage, i + 1, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, stImage->base.Height); @@ -1014,7 +1019,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, /* Unmap */ if (stImage->pt) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -1052,7 +1057,8 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); GLuint dstRowStride; const GLuint srcImageStride = @@ -1100,9 +1106,9 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(ctx->st, stImage->pt, face, level, + st_teximage_flush_before_map(st, stImage->pt, face, level, transfer_usage); - texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset, + texImage->Data = st_texture_image_map(st, stImage, zoffset, transfer_usage, xoffset, yoffset, width, height); @@ -1130,9 +1136,9 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, if (stImage->pt && i + 1 < depth) { /* unmap this slice */ - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); /* map next slice of 3D texture */ - texImage->Data = st_texture_image_map(ctx->st, stImage, + texImage->Data = st_texture_image_map(st, stImage, zoffset + i + 1, transfer_usage, xoffset, yoffset, @@ -1145,7 +1151,7 @@ done: _mesa_unmap_teximage_pbo(ctx, packing); if (stImage->pt && texImage->Data) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -1216,6 +1222,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { + struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); int srcBlockStride; int dstBlockStride; @@ -1226,9 +1233,9 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, unsigned face = _mesa_tex_target_to_face(target); pformat = stImage->pt->format; - st_teximage_flush_before_map(ctx->st, stImage->pt, face, level, + st_teximage_flush_before_map(st, stImage->pt, face, level, PIPE_TRANSFER_WRITE); - texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_WRITE, xoffset, yoffset, width, height); @@ -1260,7 +1267,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, } if (stImage->pt) { - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); texImage->Data = NULL; } } @@ -1296,7 +1303,8 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, GLint srcX, GLint srcY, GLsizei width, GLsizei height) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_transfer *src_trans; GLvoid *texDest; enum pipe_transfer_usage transfer_usage; @@ -1324,10 +1332,10 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(ctx->st, stImage->pt, 0, 0, + st_teximage_flush_before_map(st, stImage->pt, 0, 0, transfer_usage); - texDest = st_texture_image_map(ctx->st, stImage, 0, transfer_usage, + texDest = st_texture_image_map(st, stImage, 0, transfer_usage, destX, destY, width, height); if (baseFormat == GL_DEPTH_COMPONENT || @@ -1402,7 +1410,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, free(tempSrc); } - st_texture_image_unmap(ctx->st, stImage); + st_texture_image_unmap(st, stImage); pipe->transfer_destroy(pipe, src_trans); } @@ -1498,7 +1506,8 @@ st_copy_texsubimage(GLcontext *ctx, const GLenum texBaseFormat = texImage->_BaseFormat; struct gl_framebuffer *fb = ctx->ReadBuffer; struct st_renderbuffer *strb; - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; enum pipe_format dest_format, src_format; GLboolean use_fallback = GL_TRUE; @@ -1508,11 +1517,11 @@ st_copy_texsubimage(GLcontext *ctx, GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); /* any rendering in progress must flushed before we grab the fb image */ - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); /* make sure finalize_textures has been called? */ - if (0) st_validate_state(ctx->st); + if (0) st_validate_state(st); /* determine if copying depth or color data */ if (texBaseFormat == GL_DEPTH_COMPONENT || @@ -1629,7 +1638,7 @@ st_copy_texsubimage(GLcontext *ctx, srcY0 = srcY; srcY1 = srcY0 + height; } - util_blit_pixels_writemask(ctx->st->blit, + util_blit_pixels_writemask(st->blit, strb->surface, st_get_renderbuffer_sampler_view(strb, pipe), srcX, srcY0, @@ -1796,6 +1805,7 @@ st_finalize_texture(GLcontext *ctx, struct gl_texture_object *tObj, GLboolean *needFlush) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(tObj); const GLuint nr_faces = (stObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; GLuint blockSize, face; @@ -1849,7 +1859,7 @@ st_finalize_texture(GLcontext *ctx, { pipe_resource_reference(&stObj->pt, NULL); pipe_sampler_view_reference(&stObj->sampler_view, NULL); - ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; + st->dirty.st |= ST_NEW_FRAMEBUFFER; } } @@ -1858,9 +1868,9 @@ st_finalize_texture(GLcontext *ctx, if (!stObj->pt) { const enum pipe_format fmt = st_mesa_format_to_pipe_format(firstImage->base.TexFormat); - GLuint bindings = default_bindings(ctx->st, fmt); + GLuint bindings = default_bindings(st, fmt); - stObj->pt = st_texture_create(ctx->st, + stObj->pt = st_texture_create(st, gl_target_to_pipe(stObj->base.Target), fmt, stObj->lastLevel, @@ -1886,7 +1896,7 @@ st_finalize_texture(GLcontext *ctx, /* Need to import images in main memory or held in other textures. */ if (stImage && stObj->pt != stImage->pt) { - copy_image_data_to_texture(ctx->st, stObj, level, stImage); + copy_image_data_to_texture(st, stObj, level, stImage); *needFlush = GL_TRUE; } } diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 5dbabfa5c2f..175bf9e6f97 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -75,7 +75,7 @@ void st_print_current(void) { GET_CURRENT_CONTEXT(ctx); - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); #if 0 int i; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index a3620359dbf..4137596bd40 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -347,7 +347,8 @@ setup_interleaved_attribs(GLcontext *ctx, struct pipe_vertex_buffer *vbuffer, struct pipe_vertex_element velements[]) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; GLuint attr; const GLubyte *offset0 = NULL; @@ -412,7 +413,8 @@ setup_non_interleaved_attribs(GLcontext *ctx, struct pipe_vertex_buffer vbuffer[], struct pipe_vertex_element velements[]) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; GLuint attr; for (attr = 0; attr < vpv->num_inputs; attr++) { @@ -543,7 +545,8 @@ st_draw_vbo(GLcontext *ctx, GLuint min_index, GLuint max_index) { - struct pipe_context *pipe = ctx->st->pipe; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; const struct st_vertex_program *vp; const struct st_vp_varient *vpv; struct pipe_vertex_buffer vbuffer[PIPE_MAX_SHADER_INPUTS]; @@ -566,16 +569,16 @@ st_draw_vbo(GLcontext *ctx, vertDataEdgeFlags = arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj && arrays[VERT_ATTRIB_EDGEFLAG]->BufferObj->Name; - if (vertDataEdgeFlags != ctx->st->vertdata_edgeflags) { - ctx->st->vertdata_edgeflags = vertDataEdgeFlags; - ctx->st->dirty.st |= ST_NEW_EDGEFLAGS_DATA; + if (vertDataEdgeFlags != st->vertdata_edgeflags) { + st->vertdata_edgeflags = vertDataEdgeFlags; + st->dirty.st |= ST_NEW_EDGEFLAGS_DATA; } - st_validate_state(ctx->st); + st_validate_state(st); /* must get these after state validation! */ - vp = ctx->st->vp; - vpv = ctx->st->vp_varient; + vp = st->vp; + vpv = st->vp_varient; #if 0 if (MESA_VERBOSE & VERBOSE_GLSL) { @@ -624,7 +627,7 @@ st_draw_vbo(GLcontext *ctx, #endif pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); - cso_set_vertex_elements(ctx->st->cso_context, num_velements, velements); + cso_set_vertex_elements(st->cso_context, num_velements, velements); if (num_vbuffers == 0 || num_velements == 0) return; diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 0889f1a522d..a1f70e86936 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -55,7 +55,7 @@ static void set_feedback_vertex_format(GLcontext *ctx) { #if 0 - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct vertex_info vinfo; GLuint i; @@ -99,7 +99,7 @@ st_feedback_draw_vbo(GLcontext *ctx, GLuint min_index, GLuint max_index) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; struct draw_context *draw = st->draw; const struct st_vertex_program *vp; @@ -115,13 +115,13 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(draw); - st_validate_state(ctx->st); + st_validate_state(st); if (!index_bounds_valid) vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index); /* must get these after state validation! */ - vp = ctx->st->vp; + vp = st->vp; vs = &st->vp_varient->tgsi; if (!st->vp_varient->draw_shader) { diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index fa6dd2d6363..c149c5cf0b8 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -650,6 +650,7 @@ gl_format st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type) { + struct pipe_screen *screen = st_context(ctx)->pipe->screen; enum pipe_format pFormat; uint bindings; @@ -665,12 +666,12 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, else bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, + pFormat = st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, bindings); if (pFormat == PIPE_FORMAT_NONE) { /* try choosing format again, this time without render target bindings */ - pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, + pFormat = st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 5b7a9620379..36782146c57 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -106,7 +106,7 @@ static void fallback_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st_context(ctx)->pipe; struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; const uint lastLevel = pt->last_level; @@ -211,7 +211,7 @@ void st_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; -- 2.30.2