gallium: add condition parameter to render_condition
[mesa.git] / src / gallium / drivers / softpipe / sp_surface.c
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #include "util/u_format.h"
29 #include "util/u_surface.h"
30 #include "sp_context.h"
31 #include "sp_surface.h"
32
33 static void sp_blit(struct pipe_context *pipe,
34 const struct pipe_blit_info *info)
35 {
36 struct softpipe_context *sp = softpipe_context(pipe);
37
38 if (info->src.resource->nr_samples > 1 &&
39 info->dst.resource->nr_samples <= 1 &&
40 !util_format_is_depth_or_stencil(info->src.resource->format) &&
41 !util_format_is_pure_integer(info->src.resource->format)) {
42 debug_printf("softpipe: color resolve unimplemented\n");
43 return;
44 }
45
46 if (util_try_blit_via_copy_region(pipe, info)) {
47 return; /* done */
48 }
49
50 if (!util_blitter_is_blit_supported(sp->blitter, info)) {
51 debug_printf("softpipe: blit unsupported %s -> %s\n",
52 util_format_short_name(info->src.resource->format),
53 util_format_short_name(info->dst.resource->format));
54 return;
55 }
56
57 /* XXX turn off occlusion and streamout queries */
58
59 util_blitter_save_vertex_buffer_slot(sp->blitter, sp->vertex_buffer);
60 util_blitter_save_vertex_elements(sp->blitter, sp->velems);
61 util_blitter_save_vertex_shader(sp->blitter, sp->vs);
62 util_blitter_save_geometry_shader(sp->blitter, sp->gs);
63 util_blitter_save_so_targets(sp->blitter, sp->num_so_targets,
64 (struct pipe_stream_output_target**)sp->so_targets);
65 util_blitter_save_rasterizer(sp->blitter, sp->rasterizer);
66 util_blitter_save_viewport(sp->blitter, &sp->viewport);
67 util_blitter_save_scissor(sp->blitter, &sp->scissor);
68 util_blitter_save_fragment_shader(sp->blitter, sp->fs);
69 util_blitter_save_blend(sp->blitter, sp->blend);
70 util_blitter_save_depth_stencil_alpha(sp->blitter, sp->depth_stencil);
71 util_blitter_save_stencil_ref(sp->blitter, &sp->stencil_ref);
72 /*util_blitter_save_sample_mask(sp->blitter, sp->sample_mask);*/
73 util_blitter_save_framebuffer(sp->blitter, &sp->framebuffer);
74 util_blitter_save_fragment_sampler_states(sp->blitter,
75 sp->num_samplers[PIPE_SHADER_FRAGMENT],
76 (void**)sp->samplers[PIPE_SHADER_FRAGMENT]);
77 util_blitter_save_fragment_sampler_views(sp->blitter,
78 sp->num_sampler_views[PIPE_SHADER_FRAGMENT],
79 sp->sampler_views[PIPE_SHADER_FRAGMENT]);
80 util_blitter_save_render_condition(sp->blitter, sp->render_cond_query,
81 sp->render_cond_cond, sp->render_cond_mode);
82 util_blitter_blit(sp->blitter, info);
83 }
84
85 void
86 sp_init_surface_functions(struct softpipe_context *sp)
87 {
88 sp->pipe.resource_copy_region = util_resource_copy_region;
89 sp->pipe.clear_render_target = util_clear_render_target;
90 sp->pipe.clear_depth_stencil = util_clear_depth_stencil;
91 sp->pipe.blit = sp_blit;
92 }