Use write posting in the kickoff function too.
[mesa.git] / src / mesa / pipe / softpipe / sp_state_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 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
29 */
30 #include "sp_context.h"
31 #include "sp_state.h"
32 #include "sp_surface.h"
33 #include "sp_tile_cache.h"
34
35
36 /**
37 * XXX this might get moved someday
38 * Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.
39 * Here, we map the surfaces and update the tile cache to point to the new
40 * surfaces.
41 */
42 void
43 softpipe_set_framebuffer_state(struct pipe_context *pipe,
44 const struct pipe_framebuffer_state *fb)
45 {
46 struct softpipe_context *sp = softpipe_context(pipe);
47 struct pipe_surface *ps;
48 uint i;
49
50 for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
51 /* check if changing cbuf */
52 if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
53 /* flush old */
54 sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
55 /* unmap old */
56 ps = sp->framebuffer.cbufs[i];
57 if (ps && ps->region)
58 pipe->region_unmap(pipe, ps->region);
59 /* map new */
60 ps = fb->cbufs[i];
61 if (ps)
62 pipe->region_map(pipe, ps->region);
63 /* assign new */
64 sp->framebuffer.cbufs[i] = fb->cbufs[i];
65
66 /* update cache */
67 sp_tile_cache_set_surface(sp->cbuf_cache[i], ps);
68 }
69 }
70
71 sp->framebuffer.num_cbufs = fb->num_cbufs;
72
73 /* zbuf changing? */
74 if (sp->framebuffer.zbuf != fb->zbuf) {
75 /* flush old */
76 sp_flush_tile_cache(sp, sp->zbuf_cache);
77 /* unmap old */
78 ps = sp->framebuffer.zbuf;
79 if (ps && ps->region)
80 pipe->region_unmap(pipe, ps->region);
81 if (sp->framebuffer.sbuf == sp->framebuffer.zbuf) {
82 /* combined z/stencil */
83 sp->framebuffer.sbuf = NULL;
84 }
85 /* map new */
86 ps = fb->zbuf;
87 if (ps)
88 pipe->region_map(pipe, ps->region);
89 /* assign new */
90 sp->framebuffer.zbuf = fb->zbuf;
91
92 /* update cache */
93 sp_tile_cache_set_surface(sp->zbuf_cache, ps);
94 }
95
96 /* XXX combined depth/stencil here */
97
98 /* sbuf changing? */
99 if (sp->framebuffer.sbuf != fb->sbuf) {
100 /* flush old */
101 sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
102 /* unmap old */
103 ps = sp->framebuffer.sbuf;
104 if (ps && ps->region)
105 pipe->region_unmap(pipe, ps->region);
106 /* map new */
107 ps = fb->sbuf;
108 if (ps && fb->sbuf != fb->zbuf)
109 pipe->region_map(pipe, ps->region);
110 /* assign new */
111 sp->framebuffer.sbuf = fb->sbuf;
112
113 /* update cache */
114 if (fb->sbuf != fb->zbuf) {
115 /* separate stencil buf */
116 sp->sbuf_cache = sp->sbuf_cache_sep;
117 sp_tile_cache_set_surface(sp->sbuf_cache, ps);
118 }
119 else {
120 /* combined depth/stencil */
121 sp->sbuf_cache = sp->zbuf_cache;
122 sp_tile_cache_set_surface(sp->sbuf_cache, ps);
123 }
124 }
125
126 sp->dirty |= SP_NEW_FRAMEBUFFER;
127 }
128
129
130
131
132 void
133 softpipe_set_clear_color_state(struct pipe_context *pipe,
134 const struct pipe_clear_color_state *clear)
135 {
136 struct softpipe_context *softpipe = softpipe_context(pipe);
137
138 softpipe->clear_color = *clear; /* struct copy */
139 }