1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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 **************************************************************************/
30 * Copy/blit pixel rect between surfaces
36 #include "pipe/p_context.h"
37 #include "util/u_debug.h"
38 #include "pipe/p_defines.h"
39 #include "util/u_inlines.h"
40 #include "pipe/p_shader_tokens.h"
41 #include "pipe/p_state.h"
43 #include "util/u_blit.h"
44 #include "util/u_draw_quad.h"
45 #include "util/u_format.h"
46 #include "util/u_math.h"
47 #include "util/u_memory.h"
48 #include "util/u_sampler.h"
49 #include "util/u_simple_shaders.h"
51 #include "cso_cache/cso_context.h"
56 struct pipe_context *pipe;
57 struct cso_context *cso;
59 struct pipe_blend_state blend;
60 struct pipe_depth_stencil_alpha_state depthstencil_keep;
61 struct pipe_depth_stencil_alpha_state depthstencil_write;
62 struct pipe_rasterizer_state rasterizer;
63 struct pipe_sampler_state sampler;
64 struct pipe_viewport_state viewport;
65 struct pipe_vertex_element velem[2];
66 enum pipe_texture_target internal_target;
69 void *fs[TGSI_WRITEMASK_XYZW + 1];
72 struct pipe_resource *vbuf; /**< quad vertices */
75 float vertices[4][2][4]; /**< vertex/texcoords for quad */
80 * Create state object for blit.
81 * Intended to be created once and re-used for many blit() calls.
84 util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
86 struct blit_state *ctx;
89 ctx = CALLOC_STRUCT(blit_state);
96 /* disabled blending/masking */
97 memset(&ctx->blend, 0, sizeof(ctx->blend));
98 ctx->blend.rt[0].colormask = PIPE_MASK_RGBA;
100 /* no-op depth/stencil/alpha */
101 memset(&ctx->depthstencil_keep, 0, sizeof(ctx->depthstencil_keep));
102 memset(&ctx->depthstencil_write, 0, sizeof(ctx->depthstencil_write));
103 ctx->depthstencil_write.depth.enabled = 1;
104 ctx->depthstencil_write.depth.writemask = 1;
105 ctx->depthstencil_write.depth.func = PIPE_FUNC_ALWAYS;
108 memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer));
109 ctx->rasterizer.cull_face = PIPE_FACE_NONE;
110 ctx->rasterizer.gl_rasterization_rules = 1;
111 ctx->rasterizer.depth_clip = 1;
114 memset(&ctx->sampler, 0, sizeof(ctx->sampler));
115 ctx->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
116 ctx->sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
117 ctx->sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
118 ctx->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
119 ctx->sampler.min_img_filter = 0; /* set later */
120 ctx->sampler.mag_img_filter = 0; /* set later */
122 /* vertex elements state */
123 memset(&ctx->velem[0], 0, sizeof(ctx->velem[0]) * 2);
124 for (i = 0; i < 2; i++) {
125 ctx->velem[i].src_offset = i * 4 * sizeof(float);
126 ctx->velem[i].instance_divisor = 0;
127 ctx->velem[i].vertex_buffer_index = 0;
128 ctx->velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
133 /* init vertex data that doesn't change */
134 for (i = 0; i < 4; i++) {
135 ctx->vertices[i][0][3] = 1.0f; /* w */
136 ctx->vertices[i][1][2] = 0.0f; /* r */
137 ctx->vertices[i][1][3] = 1.0f; /* q */
140 if(pipe->screen->get_param(pipe->screen, PIPE_CAP_NPOT_TEXTURES))
141 ctx->internal_target = PIPE_TEXTURE_2D;
143 ctx->internal_target = PIPE_TEXTURE_RECT;
150 * Destroy a blit context
153 util_destroy_blit(struct blit_state *ctx)
155 struct pipe_context *pipe = ctx->pipe;
159 pipe->delete_vs_state(pipe, ctx->vs);
161 for (i = 0; i < Elements(ctx->fs); i++)
163 pipe->delete_fs_state(pipe, ctx->fs[i]);
166 pipe->delete_fs_state(pipe, ctx->fs_depth);
168 pipe_resource_reference(&ctx->vbuf, NULL);
175 * Helper function to set the fragment shaders.
178 set_fragment_shader(struct blit_state *ctx, uint writemask)
180 if (!ctx->fs[writemask])
182 util_make_fragment_tex_shader_writemask(ctx->pipe, TGSI_TEXTURE_2D,
183 TGSI_INTERPOLATE_LINEAR,
186 cso_set_fragment_shader_handle(ctx->cso, ctx->fs[writemask]);
191 * Helper function to set the depthwrite shader.
194 set_depth_fragment_shader(struct blit_state *ctx)
198 util_make_fragment_tex_shader_writedepth(ctx->pipe, TGSI_TEXTURE_2D,
199 TGSI_INTERPOLATE_LINEAR);
201 cso_set_fragment_shader_handle(ctx->cso, ctx->fs_depth);
206 * Helper function to set the vertex shader.
209 set_vertex_shader(struct blit_state *ctx)
211 /* vertex shader - still required to provide the linkage between
212 * fragment shader input semantics and vertex_element/buffers.
215 const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
216 TGSI_SEMANTIC_GENERIC };
217 const uint semantic_indexes[] = { 0, 0 };
218 ctx->vs = util_make_vertex_passthrough_shader(ctx->pipe, 2,
223 cso_set_vertex_shader_handle(ctx->cso, ctx->vs);
228 * Get offset of next free slot in vertex buffer for quad vertices.
231 get_next_slot( struct blit_state *ctx )
233 const unsigned max_slots = 4096 / sizeof ctx->vertices;
235 if (ctx->vbuf_slot >= max_slots)
236 util_blit_flush( ctx );
239 ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
240 PIPE_BIND_VERTEX_BUFFER,
242 max_slots * sizeof ctx->vertices);
245 return ctx->vbuf_slot++ * sizeof ctx->vertices;
252 * Setup vertex data for the textured quad we'll draw.
256 setup_vertex_data_tex(struct blit_state *ctx,
257 float x0, float y0, float x1, float y1,
258 float s0, float t0, float s1, float t1,
263 ctx->vertices[0][0][0] = x0;
264 ctx->vertices[0][0][1] = y0;
265 ctx->vertices[0][0][2] = z;
266 ctx->vertices[0][1][0] = s0; /*s*/
267 ctx->vertices[0][1][1] = t0; /*t*/
269 ctx->vertices[1][0][0] = x1;
270 ctx->vertices[1][0][1] = y0;
271 ctx->vertices[1][0][2] = z;
272 ctx->vertices[1][1][0] = s1; /*s*/
273 ctx->vertices[1][1][1] = t0; /*t*/
275 ctx->vertices[2][0][0] = x1;
276 ctx->vertices[2][0][1] = y1;
277 ctx->vertices[2][0][2] = z;
278 ctx->vertices[2][1][0] = s1;
279 ctx->vertices[2][1][1] = t1;
281 ctx->vertices[3][0][0] = x0;
282 ctx->vertices[3][0][1] = y1;
283 ctx->vertices[3][0][2] = z;
284 ctx->vertices[3][1][0] = s0;
285 ctx->vertices[3][1][1] = t1;
287 offset = get_next_slot( ctx );
290 pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
291 offset, sizeof(ctx->vertices), ctx->vertices);
299 * \return TRUE if two regions overlap, FALSE otherwise
302 regions_overlap(int srcX0, int srcY0,
303 int srcX1, int srcY1,
304 int dstX0, int dstY0,
305 int dstX1, int dstY1)
307 if (MAX2(srcX0, srcX1) < MIN2(dstX0, dstX1))
308 return FALSE; /* src completely left of dst */
310 if (MAX2(dstX0, dstX1) < MIN2(srcX0, srcX1))
311 return FALSE; /* dst completely left of src */
313 if (MAX2(srcY0, srcY1) < MIN2(dstY0, dstY1))
314 return FALSE; /* src completely above dst */
316 if (MAX2(dstY0, dstY1) < MIN2(srcY0, srcY1))
317 return FALSE; /* dst completely above src */
319 return TRUE; /* some overlap */
324 * Copy pixel block from src surface to dst surface.
325 * Overlapping regions are acceptable.
326 * Flipping and stretching are supported.
327 * \param filter one of PIPE_TEX_MIPFILTER_NEAREST/LINEAR
328 * \param writemask controls which channels in the dest surface are sourced
329 * from the src surface. Disabled channels are sourced
331 * XXX need some control over blitting stencil.
334 util_blit_pixels_writemask(struct blit_state *ctx,
335 struct pipe_resource *src_tex,
337 int srcX0, int srcY0,
338 int srcX1, int srcY1,
340 struct pipe_surface *dst,
341 int dstX0, int dstY0,
342 int dstX1, int dstY1,
343 float z, uint filter,
346 struct pipe_context *pipe = ctx->pipe;
347 struct pipe_screen *screen = pipe->screen;
348 enum pipe_format src_format, dst_format;
349 struct pipe_sampler_view *sampler_view = NULL;
350 struct pipe_sampler_view sv_templ;
351 struct pipe_surface *dst_surface;
352 struct pipe_framebuffer_state fb;
353 const int srcW = abs(srcX1 - srcX0);
354 const int srcH = abs(srcY1 - srcY0);
356 boolean overlap, dst_is_depth;
357 float s0, t0, s1, t1;
360 assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
361 filter == PIPE_TEX_MIPFILTER_LINEAR);
363 assert(src_level <= src_tex->last_level);
365 /* do the regions overlap? */
366 overlap = src_tex == dst->texture &&
367 dst->u.tex.level == src_level &&
368 dst->u.tex.first_layer == srcZ0 &&
369 regions_overlap(srcX0, srcY0, srcX1, srcY1,
370 dstX0, dstY0, dstX1, dstY1);
372 src_format = util_format_linear(src_tex->format);
373 dst_format = util_format_linear(dst->format);
376 * Check for simple case: no format conversion, no flipping, no stretching,
378 * Filter mode should not matter since there's no stretching.
380 if (dst_format == src_format &&
385 (dstX1 - dstX0) == (srcX1 - srcX0) &&
386 (dstY1 - dstY0) == (srcY1 - srcY0) &&
388 struct pipe_box src_box;
392 src_box.width = srcW;
393 src_box.height = srcH;
395 pipe->resource_copy_region(pipe,
396 dst->texture, dst->u.tex.level,
397 dstX0, dstY0, dst->u.tex.first_layer,/* dest */
403 if (dst_format == dst->format) {
406 struct pipe_surface templ = *dst;
407 templ.format = dst_format;
408 dst_surface = pipe->create_surface(pipe, dst->texture, &templ);
411 /* Create a temporary texture when src and dest alias or when src
412 * is anything other than a 2d texture.
413 * XXX should just use appropriate shader to access 1d / 3d slice / cube face,
414 * much like the u_blitter code does (should be pretty trivial).
416 * This can still be improved upon.
418 if ((src_tex == dst_surface->texture &&
419 dst_surface->u.tex.level == src_level &&
420 dst_surface->u.tex.first_layer == srcZ0) ||
421 (src_tex->target != PIPE_TEXTURE_2D &&
422 src_tex->target != PIPE_TEXTURE_2D &&
423 src_tex->target != PIPE_TEXTURE_RECT))
425 struct pipe_resource texTemp;
426 struct pipe_resource *tex;
427 struct pipe_sampler_view sv_templ;
428 struct pipe_box src_box;
429 const int srcLeft = MIN2(srcX0, srcX1);
430 const int srcTop = MIN2(srcY0, srcY1);
432 if (srcLeft != srcX0) {
433 /* left-right flip */
439 if (srcTop != srcY0) {
446 /* create temp texture */
447 memset(&texTemp, 0, sizeof(texTemp));
448 texTemp.target = ctx->internal_target;
449 texTemp.format = src_format;
450 texTemp.last_level = 0;
451 texTemp.width0 = srcW;
452 texTemp.height0 = srcH;
454 texTemp.array_size = 1;
455 texTemp.bind = PIPE_BIND_SAMPLER_VIEW;
457 tex = screen->resource_create(screen, &texTemp);
464 src_box.width = srcW;
465 src_box.height = srcH;
467 /* load temp texture */
468 pipe->resource_copy_region(pipe,
469 tex, 0, 0, 0, 0, /* dest */
470 src_tex, src_level, &src_box);
472 normalized = tex->target != PIPE_TEXTURE_RECT;
486 u_sampler_view_default_template(&sv_templ, tex, tex->format);
487 sampler_view = pipe->create_sampler_view(pipe, tex, &sv_templ);
490 pipe_resource_reference(&tex, NULL);
493 pipe_resource_reference(&tex, NULL);
496 u_sampler_view_default_template(&sv_templ, src_tex, src_format);
497 sampler_view = pipe->create_sampler_view(pipe, src_tex, &sv_templ);
507 normalized = sampler_view->texture->target != PIPE_TEXTURE_RECT;
510 s0 /= (float)(u_minify(sampler_view->texture->width0, src_level));
511 s1 /= (float)(u_minify(sampler_view->texture->width0, src_level));
512 t0 /= (float)(u_minify(sampler_view->texture->height0, src_level));
513 t1 /= (float)(u_minify(sampler_view->texture->height0, src_level));
517 dst_is_depth = util_format_is_depth_or_stencil(dst_format);
519 assert(screen->is_format_supported(screen, sampler_view->format, ctx->internal_target,
520 sampler_view->texture->nr_samples,
521 PIPE_BIND_SAMPLER_VIEW));
522 assert(screen->is_format_supported(screen, dst_format, ctx->internal_target,
523 dst_surface->texture->nr_samples,
524 dst_is_depth ? PIPE_BIND_DEPTH_STENCIL :
525 PIPE_BIND_RENDER_TARGET));
526 /* save state (restored below) */
527 cso_save_blend(ctx->cso);
528 cso_save_depth_stencil_alpha(ctx->cso);
529 cso_save_rasterizer(ctx->cso);
530 cso_save_samplers(ctx->cso);
531 cso_save_fragment_sampler_views(ctx->cso);
532 cso_save_stream_outputs(ctx->cso);
533 cso_save_viewport(ctx->cso);
534 cso_save_framebuffer(ctx->cso);
535 cso_save_fragment_shader(ctx->cso);
536 cso_save_vertex_shader(ctx->cso);
537 cso_save_geometry_shader(ctx->cso);
538 cso_save_vertex_elements(ctx->cso);
539 cso_save_vertex_buffers(ctx->cso);
541 /* set misc state we care about */
542 cso_set_blend(ctx->cso, &ctx->blend);
543 cso_set_depth_stencil_alpha(ctx->cso,
544 dst_is_depth ? &ctx->depthstencil_write :
545 &ctx->depthstencil_keep);
546 cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
547 cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
548 cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
551 ctx->sampler.normalized_coords = normalized;
552 ctx->sampler.min_img_filter = filter;
553 ctx->sampler.mag_img_filter = filter;
554 ctx->sampler.min_lod = src_level;
555 ctx->sampler.max_lod = src_level;
556 cso_single_sampler(ctx->cso, 0, &ctx->sampler);
557 cso_single_sampler_done(ctx->cso);
560 ctx->viewport.scale[0] = 0.5f * dst_surface->width;
561 ctx->viewport.scale[1] = 0.5f * dst_surface->height;
562 ctx->viewport.scale[2] = 0.5f;
563 ctx->viewport.scale[3] = 1.0f;
564 ctx->viewport.translate[0] = 0.5f * dst_surface->width;
565 ctx->viewport.translate[1] = 0.5f * dst_surface->height;
566 ctx->viewport.translate[2] = 0.5f;
567 ctx->viewport.translate[3] = 0.0f;
568 cso_set_viewport(ctx->cso, &ctx->viewport);
571 cso_set_fragment_sampler_views(ctx->cso, 1, &sampler_view);
575 set_depth_fragment_shader(ctx);
577 set_fragment_shader(ctx, writemask);
579 set_vertex_shader(ctx);
580 cso_set_geometry_shader_handle(ctx->cso, NULL);
583 memset(&fb, 0, sizeof(fb));
584 fb.width = dst_surface->width;
585 fb.height = dst_surface->height;
587 fb.zsbuf = dst_surface;
590 fb.cbufs[0] = dst_surface;
592 cso_set_framebuffer(ctx->cso, &fb);
595 offset = setup_vertex_data_tex(ctx,
596 (float) dstX0 / dst_surface->width * 2.0f - 1.0f,
597 (float) dstY0 / dst_surface->height * 2.0f - 1.0f,
598 (float) dstX1 / dst_surface->width * 2.0f - 1.0f,
599 (float) dstY1 / dst_surface->height * 2.0f - 1.0f,
605 util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf, offset,
606 PIPE_PRIM_TRIANGLE_FAN,
608 2); /* attribs/vert */
611 /* restore state we changed */
612 cso_restore_blend(ctx->cso);
613 cso_restore_depth_stencil_alpha(ctx->cso);
614 cso_restore_rasterizer(ctx->cso);
615 cso_restore_samplers(ctx->cso);
616 cso_restore_fragment_sampler_views(ctx->cso);
617 cso_restore_viewport(ctx->cso);
618 cso_restore_framebuffer(ctx->cso);
619 cso_restore_fragment_shader(ctx->cso);
620 cso_restore_vertex_shader(ctx->cso);
621 cso_restore_geometry_shader(ctx->cso);
622 cso_restore_vertex_elements(ctx->cso);
623 cso_restore_vertex_buffers(ctx->cso);
624 cso_restore_stream_outputs(ctx->cso);
626 pipe_sampler_view_reference(&sampler_view, NULL);
627 if (dst_surface != dst)
628 pipe_surface_reference(&dst_surface, NULL);
633 util_blit_pixels(struct blit_state *ctx,
634 struct pipe_resource *src_tex,
636 int srcX0, int srcY0,
637 int srcX1, int srcY1,
639 struct pipe_surface *dst,
640 int dstX0, int dstY0,
641 int dstX1, int dstY1,
642 float z, uint filter )
644 util_blit_pixels_writemask( ctx, src_tex,
653 TGSI_WRITEMASK_XYZW );
657 /* Release vertex buffer at end of frame to avoid synchronous
660 void util_blit_flush( struct blit_state *ctx )
662 pipe_resource_reference(&ctx->vbuf, NULL);
669 * Copy pixel block from src texture to dst surface.
670 * The sampler view's first_level field indicates the source
671 * mipmap level to use.
672 * XXX need some control over blitting Z and/or stencil.
675 util_blit_pixels_tex(struct blit_state *ctx,
676 struct pipe_sampler_view *src_sampler_view,
677 int srcX0, int srcY0,
678 int srcX1, int srcY1,
679 struct pipe_surface *dst,
680 int dstX0, int dstY0,
681 int dstX1, int dstY1,
682 float z, uint filter)
684 boolean normalized = src_sampler_view->texture->target != PIPE_TEXTURE_RECT;
685 struct pipe_framebuffer_state fb;
686 float s0, t0, s1, t1;
688 struct pipe_resource *tex = src_sampler_view->texture;
690 assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
691 filter == PIPE_TEX_MIPFILTER_LINEAR);
694 assert(tex->width0 != 0);
695 assert(tex->height0 != 0);
704 /* normalize according to the mipmap level's size */
705 int level = src_sampler_view->u.tex.first_level;
706 float w = (float) u_minify(tex->width0, level);
707 float h = (float) u_minify(tex->height0, level);
714 assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
716 dst->texture->nr_samples,
717 PIPE_BIND_RENDER_TARGET));
719 /* save state (restored below) */
720 cso_save_blend(ctx->cso);
721 cso_save_depth_stencil_alpha(ctx->cso);
722 cso_save_rasterizer(ctx->cso);
723 cso_save_samplers(ctx->cso);
724 cso_save_fragment_sampler_views(ctx->cso);
725 cso_save_stream_outputs(ctx->cso);
726 cso_save_viewport(ctx->cso);
727 cso_save_framebuffer(ctx->cso);
728 cso_save_fragment_shader(ctx->cso);
729 cso_save_vertex_shader(ctx->cso);
730 cso_save_geometry_shader(ctx->cso);
731 cso_save_vertex_elements(ctx->cso);
732 cso_save_vertex_buffers(ctx->cso);
734 /* set misc state we care about */
735 cso_set_blend(ctx->cso, &ctx->blend);
736 cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil_keep);
737 cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
738 cso_set_vertex_elements(ctx->cso, 2, ctx->velem);
739 cso_set_stream_outputs(ctx->cso, 0, NULL, 0);
742 ctx->sampler.normalized_coords = normalized;
743 ctx->sampler.min_img_filter = filter;
744 ctx->sampler.mag_img_filter = filter;
745 cso_single_sampler(ctx->cso, 0, &ctx->sampler);
746 cso_single_sampler_done(ctx->cso);
749 ctx->viewport.scale[0] = 0.5f * dst->width;
750 ctx->viewport.scale[1] = 0.5f * dst->height;
751 ctx->viewport.scale[2] = 0.5f;
752 ctx->viewport.scale[3] = 1.0f;
753 ctx->viewport.translate[0] = 0.5f * dst->width;
754 ctx->viewport.translate[1] = 0.5f * dst->height;
755 ctx->viewport.translate[2] = 0.5f;
756 ctx->viewport.translate[3] = 0.0f;
757 cso_set_viewport(ctx->cso, &ctx->viewport);
760 cso_set_fragment_sampler_views(ctx->cso, 1, &src_sampler_view);
763 set_fragment_shader(ctx, TGSI_WRITEMASK_XYZW);
764 set_vertex_shader(ctx);
765 cso_set_geometry_shader_handle(ctx->cso, NULL);
768 memset(&fb, 0, sizeof(fb));
769 fb.width = dst->width;
770 fb.height = dst->height;
773 cso_set_framebuffer(ctx->cso, &fb);
776 offset = setup_vertex_data_tex(ctx,
777 (float) dstX0 / dst->width * 2.0f - 1.0f,
778 (float) dstY0 / dst->height * 2.0f - 1.0f,
779 (float) dstX1 / dst->width * 2.0f - 1.0f,
780 (float) dstY1 / dst->height * 2.0f - 1.0f,
784 util_draw_vertex_buffer(ctx->pipe, ctx->cso,
786 PIPE_PRIM_TRIANGLE_FAN,
788 2); /* attribs/vert */
790 /* restore state we changed */
791 cso_restore_blend(ctx->cso);
792 cso_restore_depth_stencil_alpha(ctx->cso);
793 cso_restore_rasterizer(ctx->cso);
794 cso_restore_samplers(ctx->cso);
795 cso_restore_fragment_sampler_views(ctx->cso);
796 cso_restore_viewport(ctx->cso);
797 cso_restore_framebuffer(ctx->cso);
798 cso_restore_fragment_shader(ctx->cso);
799 cso_restore_vertex_shader(ctx->cso);
800 cso_restore_geometry_shader(ctx->cso);
801 cso_restore_vertex_elements(ctx->cso);
802 cso_restore_vertex_buffers(ctx->cso);
803 cso_restore_stream_outputs(ctx->cso);