1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
33 #include "main/imports.h"
34 #include "main/image.h"
35 #include "main/bufferobj.h"
36 #include "main/macros.h"
38 #include "program/program.h"
39 #include "program/prog_print.h"
41 #include "st_context.h"
43 #include "st_atom_constbuf.h"
45 #include "st_program.h"
46 #include "st_cb_bitmap.h"
47 #include "st_texture.h"
49 #include "pipe/p_context.h"
50 #include "pipe/p_defines.h"
51 #include "pipe/p_shader_tokens.h"
52 #include "util/u_inlines.h"
53 #include "util/u_simple_shaders.h"
54 #include "program/prog_instruction.h"
55 #include "cso_cache/cso_context.h"
59 * glBitmaps are drawn as textured quads. The user's bitmap pattern
60 * is stored in a texture image. An alpha8 texture format is used.
61 * The fragment shader samples a bit (texel) from the texture, then
62 * discards the fragment if the bit is off.
64 * Note that we actually store the inverse image of the bitmap to
65 * simplify the fragment program. An "on" bit gets stored as texel=0x0
66 * and an "off" bit is stored as texel=0xff. Then we kill the
67 * fragment if the negated texel value is less than zero.
72 * The bitmap cache attempts to accumulate multiple glBitmap calls in a
73 * buffer which is then rendered en mass upon a flush, state change, etc.
74 * A wide, short buffer is used to target the common case of a series
75 * of glBitmap calls being used to draw text.
77 static GLboolean UseBitmapCache
= GL_TRUE
;
80 #define BITMAP_CACHE_WIDTH 512
81 #define BITMAP_CACHE_HEIGHT 32
85 /** Window pos to render the cached image */
87 /** Bounds of region used in window coords */
88 GLint xmin
, ymin
, xmax
, ymax
;
92 /** Bitmap's Z position */
95 struct pipe_resource
*texture
;
96 struct pipe_transfer
*trans
;
100 /** An I8 texture image: */
105 /** Epsilon for Z comparisons */
106 #define Z_EPSILON 1e-06
110 * Copy user-provide bitmap bits into texture buffer, expanding
112 * "On" bits will set texels to 0x0.
113 * "Off" bits will not modify texels.
114 * Note that the image is actually going to be upside down in
115 * the texture. We deal with that with texcoords.
118 unpack_bitmap(struct st_context
*st
,
119 GLint px
, GLint py
, GLsizei width
, GLsizei height
,
120 const struct gl_pixelstore_attrib
*unpack
,
121 const GLubyte
*bitmap
,
122 ubyte
*destBuffer
, uint destStride
)
124 destBuffer
+= py
* destStride
+ px
;
126 _mesa_expand_bitmap(width
, height
, unpack
, bitmap
,
127 destBuffer
, destStride
, 0x0);
132 * Create a texture which represents a bitmap image.
134 static struct pipe_resource
*
135 make_bitmap_texture(struct gl_context
*ctx
, GLsizei width
, GLsizei height
,
136 const struct gl_pixelstore_attrib
*unpack
,
137 const GLubyte
*bitmap
)
139 struct st_context
*st
= st_context(ctx
);
140 struct pipe_context
*pipe
= st
->pipe
;
141 struct pipe_transfer
*transfer
;
143 struct pipe_resource
*pt
;
146 bitmap
= _mesa_map_pbo_source(ctx
, unpack
, bitmap
);
152 * Create texture to hold bitmap pattern.
154 pt
= st_texture_create(st
, st
->internal_target
, st
->bitmap
.tex_format
,
155 0, width
, height
, 1, 1, 0,
156 PIPE_BIND_SAMPLER_VIEW
);
158 _mesa_unmap_pbo_source(ctx
, unpack
);
162 dest
= pipe_transfer_map(st
->pipe
, pt
, 0, 0,
164 0, 0, width
, height
, &transfer
);
166 /* Put image into texture transfer */
167 memset(dest
, 0xff, height
* transfer
->stride
);
168 unpack_bitmap(st
, 0, 0, width
, height
, unpack
, bitmap
,
169 dest
, transfer
->stride
);
171 _mesa_unmap_pbo_source(ctx
, unpack
);
173 /* Release transfer */
174 pipe_transfer_unmap(pipe
, transfer
);
180 * Setup pipeline state prior to rendering the bitmap textured quad.
183 setup_render_state(struct gl_context
*ctx
,
184 struct pipe_sampler_view
*sv
,
185 const GLfloat
*color
)
187 struct st_context
*st
= st_context(ctx
);
188 struct cso_context
*cso
= st
->cso_context
;
189 struct st_fp_variant
*fpv
;
190 struct st_fp_variant_key key
;
192 memset(&key
, 0, sizeof(key
));
193 key
.st
= st
->has_shareable_shaders
? NULL
: st
;
194 key
.bitmap
= GL_TRUE
;
195 key
.clamp_color
= st
->clamp_frag_color_in_shader
&&
196 st
->ctx
->Color
._ClampFragmentColor
;
198 fpv
= st_get_fp_variant(st
, st
->fp
, &key
);
200 /* As an optimization, Mesa's fragment programs will sometimes get the
201 * primary color from a statevar/constant rather than a varying variable.
202 * when that's the case, we need to ensure that we use the 'color'
203 * parameter and not the current attribute color (which may have changed
204 * through glRasterPos and state validation.
205 * So, we force the proper color here. Not elegant, but it works.
208 GLfloat colorSave
[4];
209 COPY_4V(colorSave
, ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
210 COPY_4V(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
], color
);
211 st_upload_constants(st
, st
->fp
->Base
.Base
.Parameters
,
212 PIPE_SHADER_FRAGMENT
);
213 COPY_4V(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
], colorSave
);
216 cso_save_rasterizer(cso
);
217 cso_save_fragment_samplers(cso
);
218 cso_save_fragment_sampler_views(cso
);
219 cso_save_viewport(cso
);
220 cso_save_fragment_shader(cso
);
221 cso_save_stream_outputs(cso
);
222 cso_save_vertex_shader(cso
);
223 cso_save_tessctrl_shader(cso
);
224 cso_save_tesseval_shader(cso
);
225 cso_save_geometry_shader(cso
);
226 cso_save_vertex_elements(cso
);
227 cso_save_aux_vertex_buffer_slot(cso
);
229 /* rasterizer state: just scissor */
230 st
->bitmap
.rasterizer
.scissor
= ctx
->Scissor
.EnableFlags
& 1;
231 cso_set_rasterizer(cso
, &st
->bitmap
.rasterizer
);
233 /* fragment shader state: TEX lookup program */
234 cso_set_fragment_shader_handle(cso
, fpv
->driver_shader
);
236 /* vertex shader state: position + texcoord pass-through */
237 cso_set_vertex_shader_handle(cso
, st
->bitmap
.vs
);
239 /* disable other shaders */
240 cso_set_tessctrl_shader_handle(cso
, NULL
);
241 cso_set_tesseval_shader_handle(cso
, NULL
);
242 cso_set_geometry_shader_handle(cso
, NULL
);
244 /* user samplers, plus our bitmap sampler */
246 struct pipe_sampler_state
*samplers
[PIPE_MAX_SAMPLERS
];
247 uint num
= MAX2(fpv
->bitmap_sampler
+ 1,
248 st
->state
.num_samplers
[PIPE_SHADER_FRAGMENT
]);
250 for (i
= 0; i
< st
->state
.num_samplers
[PIPE_SHADER_FRAGMENT
]; i
++) {
251 samplers
[i
] = &st
->state
.samplers
[PIPE_SHADER_FRAGMENT
][i
];
253 samplers
[fpv
->bitmap_sampler
] = &st
->bitmap
.sampler
;
254 cso_set_samplers(cso
, PIPE_SHADER_FRAGMENT
, num
,
255 (const struct pipe_sampler_state
**) samplers
);
258 /* user textures, plus the bitmap texture */
260 struct pipe_sampler_view
*sampler_views
[PIPE_MAX_SAMPLERS
];
261 uint num
= MAX2(fpv
->bitmap_sampler
+ 1,
262 st
->state
.num_sampler_views
[PIPE_SHADER_FRAGMENT
]);
263 memcpy(sampler_views
, st
->state
.sampler_views
[PIPE_SHADER_FRAGMENT
],
264 sizeof(sampler_views
));
265 sampler_views
[fpv
->bitmap_sampler
] = sv
;
266 cso_set_sampler_views(cso
, PIPE_SHADER_FRAGMENT
, num
, sampler_views
);
269 /* viewport state: viewport matching window dims */
271 const GLboolean invert
= st
->state
.fb_orientation
== Y_0_TOP
;
272 const GLfloat width
= (GLfloat
)st
->state
.framebuffer
.width
;
273 const GLfloat height
= (GLfloat
)st
->state
.framebuffer
.height
;
274 struct pipe_viewport_state vp
;
275 vp
.scale
[0] = 0.5f
* width
;
276 vp
.scale
[1] = height
* (invert
? -0.5f
: 0.5f
);
278 vp
.translate
[0] = 0.5f
* width
;
279 vp
.translate
[1] = 0.5f
* height
;
280 vp
.translate
[2] = 0.5f
;
281 cso_set_viewport(cso
, &vp
);
284 cso_set_vertex_elements(cso
, 3, st
->util_velems
);
286 cso_set_stream_outputs(st
->cso_context
, 0, NULL
, NULL
);
291 * Restore pipeline state after rendering the bitmap textured quad.
294 restore_render_state(struct gl_context
*ctx
)
296 struct st_context
*st
= st_context(ctx
);
297 struct cso_context
*cso
= st
->cso_context
;
299 cso_restore_rasterizer(cso
);
300 cso_restore_fragment_samplers(cso
);
301 cso_restore_fragment_sampler_views(cso
);
302 cso_restore_viewport(cso
);
303 cso_restore_fragment_shader(cso
);
304 cso_restore_vertex_shader(cso
);
305 cso_restore_tessctrl_shader(cso
);
306 cso_restore_tesseval_shader(cso
);
307 cso_restore_geometry_shader(cso
);
308 cso_restore_vertex_elements(cso
);
309 cso_restore_aux_vertex_buffer_slot(cso
);
310 cso_restore_stream_outputs(cso
);
315 * Render a glBitmap by drawing a textured quad
318 draw_bitmap_quad(struct gl_context
*ctx
, GLint x
, GLint y
, GLfloat z
,
319 GLsizei width
, GLsizei height
,
320 struct pipe_sampler_view
*sv
,
321 const GLfloat
*color
)
323 struct st_context
*st
= st_context(ctx
);
324 struct pipe_context
*pipe
= st
->pipe
;
325 const float fb_width
= (float) st
->state
.framebuffer
.width
;
326 const float fb_height
= (float) st
->state
.framebuffer
.height
;
327 const float x0
= (float) x
;
328 const float x1
= (float) (x
+ width
);
329 const float y0
= (float) y
;
330 const float y1
= (float) (y
+ height
);
331 float sLeft
= 0.0f
, sRight
= 1.0f
;
332 float tTop
= 0.0f
, tBot
= 1.0f
- tTop
;
333 const float clip_x0
= x0
/ fb_width
* 2.0f
- 1.0f
;
334 const float clip_y0
= y0
/ fb_height
* 2.0f
- 1.0f
;
335 const float clip_x1
= x1
/ fb_width
* 2.0f
- 1.0f
;
336 const float clip_y1
= y1
/ fb_height
* 2.0f
- 1.0f
;
340 /* XXX if the bitmap is larger than the max texture size, break
343 GLuint maxSize
= 1 << (pipe
->screen
->get_param(pipe
->screen
,
344 PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
345 assert(width
<= (GLsizei
) maxSize
);
346 assert(height
<= (GLsizei
) maxSize
);
349 setup_render_state(ctx
, sv
, color
);
351 /* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */
354 if (sv
->texture
->target
== PIPE_TEXTURE_RECT
) {
355 /* use non-normalized texcoords */
356 sRight
= (float) width
;
357 tBot
= (float) height
;
360 if (!st_draw_quad(st
, clip_x0
, clip_y0
, clip_x1
, clip_y1
, z
,
361 sLeft
, tBot
, sRight
, tTop
, color
, 0)) {
362 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBitmap");
365 restore_render_state(ctx
);
367 /* We uploaded modified constants, need to invalidate them. */
368 st
->dirty
.mesa
|= _NEW_PROGRAM_CONSTANTS
;
373 reset_cache(struct st_context
*st
)
375 struct bitmap_cache
*cache
= st
->bitmap
.cache
;
377 /*memset(cache->buffer, 0xff, sizeof(cache->buffer));*/
378 cache
->empty
= GL_TRUE
;
380 cache
->xmin
= 1000000;
381 cache
->xmax
= -1000000;
382 cache
->ymin
= 1000000;
383 cache
->ymax
= -1000000;
385 assert(!cache
->texture
);
387 /* allocate a new texture */
388 cache
->texture
= st_texture_create(st
, st
->internal_target
,
389 st
->bitmap
.tex_format
, 0,
390 BITMAP_CACHE_WIDTH
, BITMAP_CACHE_HEIGHT
,
392 PIPE_BIND_SAMPLER_VIEW
);
396 /** Print bitmap image to stdout (debug) */
398 print_cache(const struct bitmap_cache
*cache
)
402 for (i
= 0; i
< BITMAP_CACHE_HEIGHT
; i
++) {
403 k
= BITMAP_CACHE_WIDTH
* (BITMAP_CACHE_HEIGHT
- i
- 1);
404 for (j
= 0; j
< BITMAP_CACHE_WIDTH
; j
++) {
405 if (cache
->buffer
[k
])
417 * Create gallium pipe_transfer object for the bitmap cache.
420 create_cache_trans(struct st_context
*st
)
422 struct pipe_context
*pipe
= st
->pipe
;
423 struct bitmap_cache
*cache
= st
->bitmap
.cache
;
428 /* Map the texture transfer.
429 * Subsequent glBitmap calls will write into the texture image.
431 cache
->buffer
= pipe_transfer_map(pipe
, cache
->texture
, 0, 0,
432 PIPE_TRANSFER_WRITE
, 0, 0,
434 BITMAP_CACHE_HEIGHT
, &cache
->trans
);
436 /* init image to all 0xff */
437 memset(cache
->buffer
, 0xff, cache
->trans
->stride
* BITMAP_CACHE_HEIGHT
);
442 * If there's anything in the bitmap cache, draw/flush it now.
445 st_flush_bitmap_cache(struct st_context
*st
)
447 struct bitmap_cache
*cache
= st
->bitmap
.cache
;
449 if (cache
&& !cache
->empty
) {
450 struct pipe_context
*pipe
= st
->pipe
;
451 struct pipe_sampler_view
*sv
;
453 assert(cache
->xmin
<= cache
->xmax
);
456 printf("flush bitmap, size %d x %d at %d, %d\n",
457 cache
->xmax
- cache
->xmin
,
458 cache
->ymax
- cache
->ymin
,
459 cache
->xpos
, cache
->ypos
);
461 /* The texture transfer has been mapped until now.
462 * So unmap and release the texture transfer before drawing.
464 if (cache
->trans
&& cache
->buffer
) {
467 pipe_transfer_unmap(pipe
, cache
->trans
);
468 cache
->buffer
= NULL
;
472 sv
= st_create_texture_sampler_view(st
->pipe
, cache
->texture
);
474 draw_bitmap_quad(st
->ctx
,
478 BITMAP_CACHE_WIDTH
, BITMAP_CACHE_HEIGHT
,
482 pipe_sampler_view_reference(&sv
, NULL
);
485 /* release/free the texture */
486 pipe_resource_reference(&cache
->texture
, NULL
);
494 * Try to accumulate this glBitmap call in the bitmap cache.
495 * \return GL_TRUE for success, GL_FALSE if bitmap is too large, etc.
498 accum_bitmap(struct gl_context
*ctx
,
499 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
500 const struct gl_pixelstore_attrib
*unpack
,
501 const GLubyte
*bitmap
)
503 struct st_context
*st
= ctx
->st
;
504 struct bitmap_cache
*cache
= st
->bitmap
.cache
;
505 int px
= -999, py
= -999;
506 const GLfloat z
= st
->ctx
->Current
.RasterPos
[2];
508 if (width
> BITMAP_CACHE_WIDTH
||
509 height
> BITMAP_CACHE_HEIGHT
)
510 return GL_FALSE
; /* too big to cache */
513 px
= x
- cache
->xpos
; /* pos in buffer */
514 py
= y
- cache
->ypos
;
515 if (px
< 0 || px
+ width
> BITMAP_CACHE_WIDTH
||
516 py
< 0 || py
+ height
> BITMAP_CACHE_HEIGHT
||
517 !TEST_EQ_4V(st
->ctx
->Current
.RasterColor
, cache
->color
) ||
518 ((fabs(z
- cache
->zpos
) > Z_EPSILON
))) {
519 /* This bitmap would extend beyond cache bounds, or the bitmap
521 * so flush and continue.
523 st_flush_bitmap_cache(st
);
528 /* Initialize. Center bitmap vertically in the buffer. */
530 py
= (BITMAP_CACHE_HEIGHT
- height
) / 2;
532 cache
->ypos
= y
- py
;
534 cache
->empty
= GL_FALSE
;
535 COPY_4FV(cache
->color
, st
->ctx
->Current
.RasterColor
);
545 if (x
+ width
> cache
->xmax
)
546 cache
->xmax
= x
+ width
;
547 if (y
+ height
> cache
->ymax
)
548 cache
->ymax
= y
+ height
;
550 /* create the transfer if needed */
551 create_cache_trans(st
);
554 bitmap
= _mesa_map_pbo_source(ctx
, unpack
, bitmap
);
559 unpack_bitmap(st
, px
, py
, width
, height
, unpack
, bitmap
,
560 cache
->buffer
, BITMAP_CACHE_WIDTH
);
562 _mesa_unmap_pbo_source(ctx
, unpack
);
564 return GL_TRUE
; /* accumulated */
569 * One-time init for drawing bitmaps.
572 init_bitmap_state(struct st_context
*st
)
574 struct pipe_context
*pipe
= st
->pipe
;
575 struct pipe_screen
*screen
= pipe
->screen
;
577 /* This function should only be called once */
578 assert(st
->bitmap
.cache
== NULL
);
580 assert(st
->internal_target
== PIPE_TEXTURE_2D
||
581 st
->internal_target
== PIPE_TEXTURE_RECT
);
583 /* alloc bitmap cache object */
584 st
->bitmap
.cache
= ST_CALLOC_STRUCT(bitmap_cache
);
586 /* init sampler state once */
587 memset(&st
->bitmap
.sampler
, 0, sizeof(st
->bitmap
.sampler
));
588 st
->bitmap
.sampler
.wrap_s
= PIPE_TEX_WRAP_CLAMP
;
589 st
->bitmap
.sampler
.wrap_t
= PIPE_TEX_WRAP_CLAMP
;
590 st
->bitmap
.sampler
.wrap_r
= PIPE_TEX_WRAP_CLAMP
;
591 st
->bitmap
.sampler
.min_img_filter
= PIPE_TEX_FILTER_NEAREST
;
592 st
->bitmap
.sampler
.min_mip_filter
= PIPE_TEX_MIPFILTER_NONE
;
593 st
->bitmap
.sampler
.mag_img_filter
= PIPE_TEX_FILTER_NEAREST
;
594 st
->bitmap
.sampler
.normalized_coords
= st
->internal_target
== PIPE_TEXTURE_2D
;
596 /* init baseline rasterizer state once */
597 memset(&st
->bitmap
.rasterizer
, 0, sizeof(st
->bitmap
.rasterizer
));
598 st
->bitmap
.rasterizer
.half_pixel_center
= 1;
599 st
->bitmap
.rasterizer
.bottom_edge_rule
= 1;
600 st
->bitmap
.rasterizer
.depth_clip
= 1;
602 /* find a usable texture format */
603 if (screen
->is_format_supported(screen
, PIPE_FORMAT_I8_UNORM
,
604 st
->internal_target
, 0,
605 PIPE_BIND_SAMPLER_VIEW
)) {
606 st
->bitmap
.tex_format
= PIPE_FORMAT_I8_UNORM
;
608 else if (screen
->is_format_supported(screen
, PIPE_FORMAT_A8_UNORM
,
609 st
->internal_target
, 0,
610 PIPE_BIND_SAMPLER_VIEW
)) {
611 st
->bitmap
.tex_format
= PIPE_FORMAT_A8_UNORM
;
613 else if (screen
->is_format_supported(screen
, PIPE_FORMAT_L8_UNORM
,
614 st
->internal_target
, 0,
615 PIPE_BIND_SAMPLER_VIEW
)) {
616 st
->bitmap
.tex_format
= PIPE_FORMAT_L8_UNORM
;
619 /* XXX support more formats */
623 /* Create the vertex shader */
625 const uint semantic_names
[] = { TGSI_SEMANTIC_POSITION
,
627 st
->needs_texcoord_semantic
? TGSI_SEMANTIC_TEXCOORD
:
628 TGSI_SEMANTIC_GENERIC
};
629 const uint semantic_indexes
[] = { 0, 0, 0 };
630 st
->bitmap
.vs
= util_make_vertex_passthrough_shader(st
->pipe
, 3,
641 * Called via ctx->Driver.Bitmap()
644 st_Bitmap(struct gl_context
*ctx
, GLint x
, GLint y
,
645 GLsizei width
, GLsizei height
,
646 const struct gl_pixelstore_attrib
*unpack
, const GLubyte
*bitmap
)
648 struct st_context
*st
= st_context(ctx
);
649 struct pipe_resource
*pt
;
654 if (!st
->bitmap
.cache
) {
655 init_bitmap_state(st
);
658 /* We only need to validate state of the st dirty flags are set or
659 * any non-_NEW_PROGRAM_CONSTANTS mesa flags are set. The VS we use
660 * for bitmap drawing uses no constants and the FS constants are
661 * explicitly uploaded in the draw_bitmap_quad() function.
663 if ((st
->dirty
.mesa
& ~_NEW_PROGRAM_CONSTANTS
) || st
->dirty
.st
) {
664 st_validate_state(st
, ST_PIPELINE_RENDER
);
667 if (UseBitmapCache
&& accum_bitmap(ctx
, x
, y
, width
, height
, unpack
, bitmap
))
670 pt
= make_bitmap_texture(ctx
, width
, height
, unpack
, bitmap
);
672 struct pipe_sampler_view
*sv
=
673 st_create_texture_sampler_view(st
->pipe
, pt
);
675 assert(pt
->target
== PIPE_TEXTURE_2D
|| pt
->target
== PIPE_TEXTURE_RECT
);
678 draw_bitmap_quad(ctx
, x
, y
, ctx
->Current
.RasterPos
[2],
680 st
->ctx
->Current
.RasterColor
);
682 pipe_sampler_view_reference(&sv
, NULL
);
685 /* release/free the texture */
686 pipe_resource_reference(&pt
, NULL
);
691 /** Per-context init */
693 st_init_bitmap_functions(struct dd_function_table
*functions
)
695 functions
->Bitmap
= st_Bitmap
;
699 /** Per-context tear-down */
701 st_destroy_bitmap(struct st_context
*st
)
703 struct pipe_context
*pipe
= st
->pipe
;
704 struct bitmap_cache
*cache
= st
->bitmap
.cache
;
707 cso_delete_vertex_shader(st
->cso_context
, st
->bitmap
.vs
);
708 st
->bitmap
.vs
= NULL
;
712 if (cache
->trans
&& cache
->buffer
) {
713 pipe_transfer_unmap(pipe
, cache
->trans
);
715 pipe_resource_reference(&st
->bitmap
.cache
->texture
, NULL
);
716 free(st
->bitmap
.cache
);
717 st
->bitmap
.cache
= NULL
;