/** * Called via ctx->Driver.Bitmap() */ static void st_Bitmap(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { struct st_context *st = st_context(ctx); struct pipe_resource *pt; assert(width > 0); assert(height > 0); st_invalidate_readpix_cache(st); if (!st->bitmap.cache) { init_bitmap_state(st); } /* We only need to validate any non-ST_NEW_CONSTANTS state. The VS we use * for bitmap drawing uses no constants and the FS constants are * explicitly uploaded in the draw_bitmap_quad() function. */ if ((st->dirty | ctx->NewDriverState) & ~ST_NEW_CONSTANTS & ST_PIPELINE_RENDER_STATE_MASK || st->gfx_shaders_may_be_dirty) { st_validate_state(st, ST_PIPELINE_RENDER); } if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap)) return; pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); if (pt) { struct pipe_sampler_view *sv = st_create_texture_sampler_view(st->pipe, pt); assert(pt->target == PIPE_TEXTURE_2D || pt->target == PIPE_TEXTURE_RECT); if (sv) { draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], width, height, sv, ctx->Current.RasterColor); pipe_sampler_view_reference(&sv, NULL); } /* release/free the texture */ pipe_resource_reference(&pt, NULL); } }
/** * Called via ctx->Driver.Bitmap() */ static void st_Bitmap(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { struct st_context *st = st_context(ctx); struct pipe_resource *pt; if (width == 0 || height == 0) return; st_validate_state(st); if (!st->bitmap.vs) { /* create pass-through vertex shader now */ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_COLOR, st->needs_texcoord_semantic ? TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC }; const uint semantic_indexes[] = { 0, 0, 0 }; st->bitmap.vs = util_make_vertex_passthrough_shader(st->pipe, 3, semantic_names, semantic_indexes, FALSE); } if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap)) return; pt = make_bitmap_texture(ctx, width, height, unpack, bitmap); if (pt) { struct pipe_sampler_view *sv = st_create_texture_sampler_view(st->pipe, pt); assert(pt->target == PIPE_TEXTURE_2D || pt->target == PIPE_TEXTURE_RECT); if (sv) { draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2], width, height, sv, st->ctx->Current.RasterColor); pipe_sampler_view_reference(&sv, NULL); } /* release/free the texture */ pipe_resource_reference(&pt, NULL); } }