2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright 2009 Marek Olšák <maraeo@gmail.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
24 #include "draw/draw_context.h"
26 #include "util/u_math.h"
27 #include "util/u_memory.h"
28 #include "util/u_pack_color.h"
30 #include "tgsi/tgsi_parse.h"
32 #include "pipe/p_config.h"
34 #include "r300_context.h"
36 #include "r300_screen.h"
37 #include "r300_state_inlines.h"
41 #include "radeon_winsys.h"
43 /* r300_state: Functions used to intialize state context by translating
44 * Gallium state objects into semi-native r300 state objects. */
46 #define UPDATE_STATE(cso, atom) \
47 if (cso != atom.state) { \
52 static boolean
blend_discard_if_src_alpha_0(unsigned srcRGB
, unsigned srcA
,
53 unsigned dstRGB
, unsigned dstA
)
55 /* If the blend equation is ADD or REVERSE_SUBTRACT,
56 * SRC_ALPHA == 0, and the following state is set, the colorbuffer
57 * will not be changed.
58 * Notice that the dst factors are the src factors inverted. */
59 return (srcRGB
== PIPE_BLENDFACTOR_SRC_ALPHA
||
60 srcRGB
== PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
||
61 srcRGB
== PIPE_BLENDFACTOR_ZERO
) &&
62 (srcA
== PIPE_BLENDFACTOR_SRC_COLOR
||
63 srcA
== PIPE_BLENDFACTOR_SRC_ALPHA
||
64 srcA
== PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
||
65 srcA
== PIPE_BLENDFACTOR_ZERO
) &&
66 (dstRGB
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
67 dstRGB
== PIPE_BLENDFACTOR_ONE
) &&
68 (dstA
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
69 dstA
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
70 dstA
== PIPE_BLENDFACTOR_ONE
);
73 static boolean
blend_discard_if_src_alpha_1(unsigned srcRGB
, unsigned srcA
,
74 unsigned dstRGB
, unsigned dstA
)
76 /* If the blend equation is ADD or REVERSE_SUBTRACT,
77 * SRC_ALPHA == 1, and the following state is set, the colorbuffer
78 * will not be changed.
79 * Notice that the dst factors are the src factors inverted. */
80 return (srcRGB
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
81 srcRGB
== PIPE_BLENDFACTOR_ZERO
) &&
82 (srcA
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
83 srcA
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
84 srcA
== PIPE_BLENDFACTOR_ZERO
) &&
85 (dstRGB
== PIPE_BLENDFACTOR_SRC_ALPHA
||
86 dstRGB
== PIPE_BLENDFACTOR_ONE
) &&
87 (dstA
== PIPE_BLENDFACTOR_SRC_COLOR
||
88 dstA
== PIPE_BLENDFACTOR_SRC_ALPHA
||
89 dstA
== PIPE_BLENDFACTOR_ONE
);
92 static boolean
blend_discard_if_src_color_0(unsigned srcRGB
, unsigned srcA
,
93 unsigned dstRGB
, unsigned dstA
)
95 /* If the blend equation is ADD or REVERSE_SUBTRACT,
96 * SRC_COLOR == (0,0,0), and the following state is set, the colorbuffer
97 * will not be changed.
98 * Notice that the dst factors are the src factors inverted. */
99 return (srcRGB
== PIPE_BLENDFACTOR_SRC_COLOR
||
100 srcRGB
== PIPE_BLENDFACTOR_ZERO
) &&
101 (srcA
== PIPE_BLENDFACTOR_ZERO
) &&
102 (dstRGB
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
103 dstRGB
== PIPE_BLENDFACTOR_ONE
) &&
104 (dstA
== PIPE_BLENDFACTOR_ONE
);
107 static boolean
blend_discard_if_src_color_1(unsigned srcRGB
, unsigned srcA
,
108 unsigned dstRGB
, unsigned dstA
)
110 /* If the blend equation is ADD or REVERSE_SUBTRACT,
111 * SRC_COLOR == (1,1,1), and the following state is set, the colorbuffer
112 * will not be changed.
113 * Notice that the dst factors are the src factors inverted. */
114 return (srcRGB
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
115 srcRGB
== PIPE_BLENDFACTOR_ZERO
) &&
116 (srcA
== PIPE_BLENDFACTOR_ZERO
) &&
117 (dstRGB
== PIPE_BLENDFACTOR_SRC_COLOR
||
118 dstRGB
== PIPE_BLENDFACTOR_ONE
) &&
119 (dstA
== PIPE_BLENDFACTOR_ONE
);
122 static boolean
blend_discard_if_src_alpha_color_0(unsigned srcRGB
, unsigned srcA
,
123 unsigned dstRGB
, unsigned dstA
)
125 /* If the blend equation is ADD or REVERSE_SUBTRACT,
126 * SRC_ALPHA_COLOR == (0,0,0,0), and the following state is set,
127 * the colorbuffer will not be changed.
128 * Notice that the dst factors are the src factors inverted. */
129 return (srcRGB
== PIPE_BLENDFACTOR_SRC_COLOR
||
130 srcRGB
== PIPE_BLENDFACTOR_SRC_ALPHA
||
131 srcRGB
== PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
||
132 srcRGB
== PIPE_BLENDFACTOR_ZERO
) &&
133 (srcA
== PIPE_BLENDFACTOR_SRC_COLOR
||
134 srcA
== PIPE_BLENDFACTOR_SRC_ALPHA
||
135 srcA
== PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
||
136 srcA
== PIPE_BLENDFACTOR_ZERO
) &&
137 (dstRGB
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
138 dstRGB
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
139 dstRGB
== PIPE_BLENDFACTOR_ONE
) &&
140 (dstA
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
141 dstA
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
142 dstA
== PIPE_BLENDFACTOR_ONE
);
145 static boolean
blend_discard_if_src_alpha_color_1(unsigned srcRGB
, unsigned srcA
,
146 unsigned dstRGB
, unsigned dstA
)
148 /* If the blend equation is ADD or REVERSE_SUBTRACT,
149 * SRC_ALPHA_COLOR == (1,1,1,1), and the following state is set,
150 * the colorbuffer will not be changed.
151 * Notice that the dst factors are the src factors inverted. */
152 return (srcRGB
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
153 srcRGB
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
154 srcRGB
== PIPE_BLENDFACTOR_ZERO
) &&
155 (srcA
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
156 srcA
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
157 srcA
== PIPE_BLENDFACTOR_ZERO
) &&
158 (dstRGB
== PIPE_BLENDFACTOR_SRC_COLOR
||
159 dstRGB
== PIPE_BLENDFACTOR_SRC_ALPHA
||
160 dstRGB
== PIPE_BLENDFACTOR_ONE
) &&
161 (dstA
== PIPE_BLENDFACTOR_SRC_COLOR
||
162 dstA
== PIPE_BLENDFACTOR_SRC_ALPHA
||
163 dstA
== PIPE_BLENDFACTOR_ONE
);
166 static unsigned bgra_cmask(unsigned mask
)
168 /* Gallium uses RGBA color ordering while R300 expects BGRA. */
170 return ((mask
& PIPE_MASK_R
) << 2) |
171 ((mask
& PIPE_MASK_B
) >> 2) |
172 (mask
& (PIPE_MASK_G
| PIPE_MASK_A
));
175 /* Create a new blend state based on the CSO blend state.
177 * This encompasses alpha blending, logic/raster ops, and blend dithering. */
178 static void* r300_create_blend_state(struct pipe_context
* pipe
,
179 const struct pipe_blend_state
* state
)
181 struct r300_screen
* r300screen
= r300_screen(pipe
->screen
);
182 struct r300_blend_state
* blend
= CALLOC_STRUCT(r300_blend_state
);
184 if (state
->rt
[0].blend_enable
)
186 unsigned eqRGB
= state
->rt
[0].rgb_func
;
187 unsigned srcRGB
= state
->rt
[0].rgb_src_factor
;
188 unsigned dstRGB
= state
->rt
[0].rgb_dst_factor
;
190 unsigned eqA
= state
->rt
[0].alpha_func
;
191 unsigned srcA
= state
->rt
[0].alpha_src_factor
;
192 unsigned dstA
= state
->rt
[0].alpha_dst_factor
;
194 /* despite the name, ALPHA_BLEND_ENABLE has nothing to do with alpha,
195 * this is just the crappy D3D naming */
196 blend
->blend_control
= R300_ALPHA_BLEND_ENABLE
|
197 r300_translate_blend_function(eqRGB
) |
198 ( r300_translate_blend_factor(srcRGB
) << R300_SRC_BLEND_SHIFT
) |
199 ( r300_translate_blend_factor(dstRGB
) << R300_DST_BLEND_SHIFT
);
201 /* Optimization: some operations do not require the destination color.
203 * When SRC_ALPHA_SATURATE is used, colorbuffer reads must be enabled,
204 * otherwise blending gives incorrect results. It seems to be
206 if (eqRGB
== PIPE_BLEND_MIN
|| eqA
== PIPE_BLEND_MIN
||
207 eqRGB
== PIPE_BLEND_MAX
|| eqA
== PIPE_BLEND_MAX
||
208 dstRGB
!= PIPE_BLENDFACTOR_ZERO
||
209 dstA
!= PIPE_BLENDFACTOR_ZERO
||
210 srcRGB
== PIPE_BLENDFACTOR_DST_COLOR
||
211 srcRGB
== PIPE_BLENDFACTOR_DST_ALPHA
||
212 srcRGB
== PIPE_BLENDFACTOR_INV_DST_COLOR
||
213 srcRGB
== PIPE_BLENDFACTOR_INV_DST_ALPHA
||
214 srcA
== PIPE_BLENDFACTOR_DST_COLOR
||
215 srcA
== PIPE_BLENDFACTOR_DST_ALPHA
||
216 srcA
== PIPE_BLENDFACTOR_INV_DST_COLOR
||
217 srcA
== PIPE_BLENDFACTOR_INV_DST_ALPHA
||
218 srcRGB
== PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
) {
219 /* Enable reading from the colorbuffer. */
220 blend
->blend_control
|= R300_READ_ENABLE
;
222 if (r300_screen(r300_context(pipe
)->context
.screen
)->caps
->is_r500
) {
223 /* Optimization: Depending on incoming pixels, we can
224 * conditionally disable the reading in hardware... */
225 if (eqRGB
!= PIPE_BLEND_MIN
&& eqA
!= PIPE_BLEND_MIN
&&
226 eqRGB
!= PIPE_BLEND_MAX
&& eqA
!= PIPE_BLEND_MAX
) {
227 /* Disable reading if SRC_ALPHA == 0. */
228 if ((dstRGB
== PIPE_BLENDFACTOR_SRC_ALPHA
||
229 dstRGB
== PIPE_BLENDFACTOR_ZERO
) &&
230 (dstA
== PIPE_BLENDFACTOR_SRC_COLOR
||
231 dstA
== PIPE_BLENDFACTOR_SRC_ALPHA
||
232 dstA
== PIPE_BLENDFACTOR_ZERO
)) {
233 blend
->blend_control
|= R500_SRC_ALPHA_0_NO_READ
;
236 /* Disable reading if SRC_ALPHA == 1. */
237 if ((dstRGB
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
238 dstRGB
== PIPE_BLENDFACTOR_ZERO
) &&
239 (dstA
== PIPE_BLENDFACTOR_INV_SRC_COLOR
||
240 dstA
== PIPE_BLENDFACTOR_INV_SRC_ALPHA
||
241 dstA
== PIPE_BLENDFACTOR_ZERO
)) {
242 blend
->blend_control
|= R500_SRC_ALPHA_1_NO_READ
;
248 /* Optimization: discard pixels which don't change the colorbuffer.
250 * The code below is non-trivial and some math is involved.
252 * Discarding pixels must be disabled when FP16 AA is enabled.
253 * This is a hardware bug. Also, this implementation wouldn't work
254 * with FP blending enabled and equation clamping disabled.
256 * Equations other than ADD are rarely used and therefore won't be
258 if ((eqRGB
== PIPE_BLEND_ADD
|| eqRGB
== PIPE_BLEND_REVERSE_SUBTRACT
) &&
259 (eqA
== PIPE_BLEND_ADD
|| eqA
== PIPE_BLEND_REVERSE_SUBTRACT
)) {
261 * REVERSE_SUBTRACT: Y-X
264 * If X = src*srcFactor = 0 and Y = dst*dstFactor = 1,
265 * then CB will not be changed.
267 * Given the srcFactor and dstFactor variables, we can derive
268 * what src and dst should be equal to and discard appropriate
271 if (blend_discard_if_src_alpha_0(srcRGB
, srcA
, dstRGB
, dstA
)) {
272 blend
->blend_control
|= R300_DISCARD_SRC_PIXELS_SRC_ALPHA_0
;
273 } else if (blend_discard_if_src_alpha_1(srcRGB
, srcA
,
275 blend
->blend_control
|= R300_DISCARD_SRC_PIXELS_SRC_ALPHA_1
;
276 } else if (blend_discard_if_src_color_0(srcRGB
, srcA
,
278 blend
->blend_control
|= R300_DISCARD_SRC_PIXELS_SRC_COLOR_0
;
279 } else if (blend_discard_if_src_color_1(srcRGB
, srcA
,
281 blend
->blend_control
|= R300_DISCARD_SRC_PIXELS_SRC_COLOR_1
;
282 } else if (blend_discard_if_src_alpha_color_0(srcRGB
, srcA
,
284 blend
->blend_control
|=
285 R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_0
;
286 } else if (blend_discard_if_src_alpha_color_1(srcRGB
, srcA
,
288 blend
->blend_control
|=
289 R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_1
;
294 if (srcA
!= srcRGB
|| dstA
!= dstRGB
|| eqA
!= eqRGB
) {
295 blend
->blend_control
|= R300_SEPARATE_ALPHA_ENABLE
;
296 blend
->alpha_blend_control
=
297 r300_translate_blend_function(eqA
) |
298 (r300_translate_blend_factor(srcA
) << R300_SRC_BLEND_SHIFT
) |
299 (r300_translate_blend_factor(dstA
) << R300_DST_BLEND_SHIFT
);
303 /* PIPE_LOGICOP_* don't need to be translated, fortunately. */
304 if (state
->logicop_enable
) {
305 blend
->rop
= R300_RB3D_ROPCNTL_ROP_ENABLE
|
306 (state
->logicop_func
) << R300_RB3D_ROPCNTL_ROP_SHIFT
;
309 /* Color channel masks for all MRTs. */
310 blend
->color_channel_mask
= bgra_cmask(state
->rt
[0].colormask
);
311 if (r300screen
->caps
->is_r500
&& state
->independent_blend_enable
) {
312 if (state
->rt
[1].blend_enable
) {
313 blend
->color_channel_mask
|= bgra_cmask(state
->rt
[1].colormask
) << 4;
315 if (state
->rt
[2].blend_enable
) {
316 blend
->color_channel_mask
|= bgra_cmask(state
->rt
[2].colormask
) << 8;
318 if (state
->rt
[3].blend_enable
) {
319 blend
->color_channel_mask
|= bgra_cmask(state
->rt
[3].colormask
) << 12;
324 blend
->dither
= R300_RB3D_DITHER_CTL_DITHER_MODE_LUT
|
325 R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_LUT
;
331 /* Bind blend state. */
332 static void r300_bind_blend_state(struct pipe_context
* pipe
,
335 struct r300_context
* r300
= r300_context(pipe
);
337 UPDATE_STATE(state
, r300
->blend_state
);
340 /* Free blend state. */
341 static void r300_delete_blend_state(struct pipe_context
* pipe
,
347 /* Convert float to 10bit integer */
348 static unsigned float_to_fixed10(float f
)
350 return CLAMP((unsigned)(f
* 1023.9f
), 0, 1023);
354 * Setup both R300 and R500 registers, figure out later which one to write. */
355 static void r300_set_blend_color(struct pipe_context
* pipe
,
356 const struct pipe_blend_color
* color
)
358 struct r300_context
* r300
= r300_context(pipe
);
359 struct r300_screen
* r300screen
= r300_screen(pipe
->screen
);
360 struct r300_blend_color_state
* state
=
361 (struct r300_blend_color_state
*)r300
->blend_color_state
.state
;
364 util_pack_color(color
->color
, PIPE_FORMAT_B8G8R8A8_UNORM
, &uc
);
365 state
->blend_color
= uc
.ui
;
367 /* XXX if FP16 blending is enabled, we should use the FP16 format */
368 state
->blend_color_red_alpha
=
369 float_to_fixed10(color
->color
[0]) |
370 (float_to_fixed10(color
->color
[3]) << 16);
371 state
->blend_color_green_blue
=
372 float_to_fixed10(color
->color
[2]) |
373 (float_to_fixed10(color
->color
[1]) << 16);
375 r300
->blend_color_state
.size
= r300screen
->caps
->is_r500
? 3 : 2;
376 r300
->blend_color_state
.dirty
= TRUE
;
379 static void r300_set_clip_state(struct pipe_context
* pipe
,
380 const struct pipe_clip_state
* state
)
382 struct r300_context
* r300
= r300_context(pipe
);
386 if (r300_screen(pipe
->screen
)->caps
->has_tcl
) {
387 memcpy(r300
->clip_state
.state
, state
, sizeof(struct pipe_clip_state
));
388 r300
->clip_state
.size
= 29;
390 draw_flush(r300
->draw
);
391 draw_set_clip_state(r300
->draw
, state
);
392 r300
->clip_state
.size
= 2;
395 r300
->clip_state
.dirty
= TRUE
;
398 /* Create a new depth, stencil, and alpha state based on the CSO dsa state.
400 * This contains the depth buffer, stencil buffer, alpha test, and such.
401 * On the Radeon, depth and stencil buffer setup are intertwined, which is
402 * the reason for some of the strange-looking assignments across registers. */
404 r300_create_dsa_state(struct pipe_context
* pipe
,
405 const struct pipe_depth_stencil_alpha_state
* state
)
407 struct r300_capabilities
*caps
=
408 r300_screen(r300_context(pipe
)->context
.screen
)->caps
;
409 struct r300_dsa_state
* dsa
= CALLOC_STRUCT(r300_dsa_state
);
411 /* Depth test setup. */
412 if (state
->depth
.enabled
) {
413 dsa
->z_buffer_control
|= R300_Z_ENABLE
;
415 if (state
->depth
.writemask
) {
416 dsa
->z_buffer_control
|= R300_Z_WRITE_ENABLE
;
419 dsa
->z_stencil_control
|=
420 (r300_translate_depth_stencil_function(state
->depth
.func
) <<
424 /* Stencil buffer setup. */
425 if (state
->stencil
[0].enabled
) {
426 dsa
->z_buffer_control
|= R300_STENCIL_ENABLE
;
427 dsa
->z_stencil_control
|=
428 (r300_translate_depth_stencil_function(state
->stencil
[0].func
) <<
429 R300_S_FRONT_FUNC_SHIFT
) |
430 (r300_translate_stencil_op(state
->stencil
[0].fail_op
) <<
431 R300_S_FRONT_SFAIL_OP_SHIFT
) |
432 (r300_translate_stencil_op(state
->stencil
[0].zpass_op
) <<
433 R300_S_FRONT_ZPASS_OP_SHIFT
) |
434 (r300_translate_stencil_op(state
->stencil
[0].zfail_op
) <<
435 R300_S_FRONT_ZFAIL_OP_SHIFT
);
437 dsa
->stencil_ref_mask
=
438 (state
->stencil
[0].valuemask
<< R300_STENCILMASK_SHIFT
) |
439 (state
->stencil
[0].writemask
<< R300_STENCILWRITEMASK_SHIFT
);
441 if (state
->stencil
[1].enabled
) {
442 dsa
->z_buffer_control
|= R300_STENCIL_FRONT_BACK
;
443 dsa
->z_stencil_control
|=
444 (r300_translate_depth_stencil_function(state
->stencil
[1].func
) <<
445 R300_S_BACK_FUNC_SHIFT
) |
446 (r300_translate_stencil_op(state
->stencil
[1].fail_op
) <<
447 R300_S_BACK_SFAIL_OP_SHIFT
) |
448 (r300_translate_stencil_op(state
->stencil
[1].zpass_op
) <<
449 R300_S_BACK_ZPASS_OP_SHIFT
) |
450 (r300_translate_stencil_op(state
->stencil
[1].zfail_op
) <<
451 R300_S_BACK_ZFAIL_OP_SHIFT
);
455 dsa
->z_buffer_control
|= R500_STENCIL_REFMASK_FRONT_BACK
;
456 dsa
->stencil_ref_bf
=
457 (state
->stencil
[1].valuemask
<<
458 R300_STENCILMASK_SHIFT
) |
459 (state
->stencil
[1].writemask
<<
460 R300_STENCILWRITEMASK_SHIFT
);
465 /* Alpha test setup. */
466 if (state
->alpha
.enabled
) {
467 dsa
->alpha_function
=
468 r300_translate_alpha_function(state
->alpha
.func
) |
469 R300_FG_ALPHA_FUNC_ENABLE
;
471 /* We could use 10bit alpha ref but who needs that? */
472 dsa
->alpha_function
|= float_to_ubyte(state
->alpha
.ref_value
);
475 dsa
->alpha_function
|= R500_FG_ALPHA_FUNC_8BIT
;
481 /* Bind DSA state. */
482 static void r300_bind_dsa_state(struct pipe_context
* pipe
,
485 struct r300_context
* r300
= r300_context(pipe
);
487 UPDATE_STATE(state
, r300
->dsa_state
);
490 /* Free DSA state. */
491 static void r300_delete_dsa_state(struct pipe_context
* pipe
,
497 static void r300_set_stencil_ref(struct pipe_context
* pipe
,
498 const struct pipe_stencil_ref
* sr
)
500 struct r300_context
* r300
= r300_context(pipe
);
501 r300
->stencil_ref
= *sr
;
502 r300
->dsa_state
.dirty
= TRUE
;
505 /* This switcheroo is needed just because of goddamned MACRO_SWITCH. */
506 static void r300_fb_update_tiling_flags(struct r300_context
*r300
,
507 const struct pipe_framebuffer_state
*old_state
,
508 const struct pipe_framebuffer_state
*new_state
)
510 struct r300_texture
*tex
;
511 unsigned i
, j
, level
;
513 /* Reset tiling flags for old surfaces to default values. */
514 for (i
= 0; i
< old_state
->nr_cbufs
; i
++) {
515 for (j
= 0; j
< new_state
->nr_cbufs
; j
++) {
516 if (old_state
->cbufs
[i
]->texture
== new_state
->cbufs
[j
]->texture
) {
520 /* If not binding the surface again... */
521 if (j
!= new_state
->nr_cbufs
) {
525 tex
= (struct r300_texture
*)old_state
->cbufs
[i
]->texture
;
528 r300
->winsys
->buffer_set_tiling(r300
->winsys
, tex
->buffer
,
531 tex
->macrotile
!= 0);
534 if (old_state
->zsbuf
&&
535 (!new_state
->zsbuf
||
536 old_state
->zsbuf
->texture
!= new_state
->zsbuf
->texture
)) {
537 tex
= (struct r300_texture
*)old_state
->zsbuf
->texture
;
540 r300
->winsys
->buffer_set_tiling(r300
->winsys
, tex
->buffer
,
543 tex
->macrotile
!= 0);
547 /* Set tiling flags for new surfaces. */
548 for (i
= 0; i
< new_state
->nr_cbufs
; i
++) {
549 tex
= (struct r300_texture
*)new_state
->cbufs
[i
]->texture
;
550 level
= new_state
->cbufs
[i
]->level
;
552 r300
->winsys
->buffer_set_tiling(r300
->winsys
, tex
->buffer
,
555 tex
->mip_macrotile
[level
] != 0);
557 if (new_state
->zsbuf
) {
558 tex
= (struct r300_texture
*)new_state
->zsbuf
->texture
;
559 level
= new_state
->zsbuf
->level
;
561 r300
->winsys
->buffer_set_tiling(r300
->winsys
, tex
->buffer
,
564 tex
->mip_macrotile
[level
] != 0);
569 r300_set_framebuffer_state(struct pipe_context
* pipe
,
570 const struct pipe_framebuffer_state
* state
)
572 struct r300_context
* r300
= r300_context(pipe
);
573 struct r300_screen
* r300screen
= r300_screen(pipe
->screen
);
574 unsigned max_width
, max_height
;
575 uint32_t zbuffer_bpp
= 0;
578 if (state
->nr_cbufs
> 4) {
579 debug_printf("r300: Implementation error: Too many MRTs in %s, "
580 "refusing to bind framebuffer state!\n", __FUNCTION__
);
584 if (r300screen
->caps
->is_r500
) {
585 max_width
= max_height
= 4096;
586 } else if (r300screen
->caps
->is_r400
) {
587 max_width
= max_height
= 4021;
589 max_width
= max_height
= 2560;
592 if (state
->width
> max_width
|| state
->height
> max_height
) {
593 debug_printf("r300: Implementation error: Render targets are too "
594 "big in %s, refusing to bind framebuffer state!\n", __FUNCTION__
);
600 draw_flush(r300
->draw
);
603 memcpy(r300
->fb_state
.state
, state
, sizeof(struct pipe_framebuffer_state
));
605 r300
->fb_state
.size
= (10 * state
->nr_cbufs
) + (2 * (4 - state
->nr_cbufs
)) +
606 (state
->zsbuf
? 10 : 0) + 8;
608 r300_fb_update_tiling_flags(r300
, r300
->fb_state
.state
, state
);
611 r300
->blend_state
.dirty
= TRUE
;
612 r300
->dsa_state
.dirty
= TRUE
;
613 r300
->fb_state
.dirty
= TRUE
;
614 r300
->scissor_state
.dirty
= TRUE
;
616 /* Polygon offset depends on the zbuffer bit depth. */
617 if (state
->zsbuf
&& r300
->polygon_offset_enabled
) {
618 switch (util_format_get_blocksize(state
->zsbuf
->texture
->format
)) {
627 if (r300
->zbuffer_bpp
!= zbuffer_bpp
) {
628 r300
->zbuffer_bpp
= zbuffer_bpp
;
629 r300
->rs_state
.dirty
= TRUE
;
634 /* Create fragment shader state. */
635 static void* r300_create_fs_state(struct pipe_context
* pipe
,
636 const struct pipe_shader_state
* shader
)
638 struct r300_fragment_shader
* fs
= NULL
;
640 fs
= (struct r300_fragment_shader
*)CALLOC_STRUCT(r300_fragment_shader
);
642 /* Copy state directly into shader. */
644 fs
->state
.tokens
= tgsi_dup_tokens(shader
->tokens
);
646 tgsi_scan_shader(shader
->tokens
, &fs
->info
);
647 r300_shader_read_fs_inputs(&fs
->info
, &fs
->inputs
);
652 /* Bind fragment shader state. */
653 static void r300_bind_fs_state(struct pipe_context
* pipe
, void* shader
)
655 struct r300_context
* r300
= r300_context(pipe
);
656 struct r300_fragment_shader
* fs
= (struct r300_fragment_shader
*)shader
;
664 r300_pick_fragment_shader(r300
);
666 r300
->rs_block_state
.dirty
= TRUE
; /* Will be updated before the emission. */
668 if (r300
->vs_state
.state
&& r300_vertex_shader_setup_wpos(r300
)) {
669 r300
->vap_output_state
.dirty
= TRUE
;
672 r300
->dirty_state
|= R300_NEW_FRAGMENT_SHADER
| R300_NEW_FRAGMENT_SHADER_CONSTANTS
;
675 /* Delete fragment shader state. */
676 static void r300_delete_fs_state(struct pipe_context
* pipe
, void* shader
)
678 struct r300_fragment_shader
* fs
= (struct r300_fragment_shader
*)shader
;
679 struct r300_fragment_shader_code
*tmp
, *ptr
= fs
->first
;
684 rc_constants_destroy(&tmp
->code
.constants
);
687 FREE((void*)fs
->state
.tokens
);
691 static void r300_set_polygon_stipple(struct pipe_context
* pipe
,
692 const struct pipe_poly_stipple
* state
)
694 /* XXX no idea how to set this up, but not terribly important */
697 /* Create a new rasterizer state based on the CSO rasterizer state.
699 * This is a very large chunk of state, and covers most of the graphics
700 * backend (GB), geometry assembly (GA), and setup unit (SU) blocks.
702 * In a not entirely unironic sidenote, this state has nearly nothing to do
703 * with the actual block on the Radeon called the rasterizer (RS). */
704 static void* r300_create_rs_state(struct pipe_context
* pipe
,
705 const struct pipe_rasterizer_state
* state
)
707 struct r300_screen
* r300screen
= r300_screen(pipe
->screen
);
708 struct r300_rs_state
* rs
= CALLOC_STRUCT(r300_rs_state
);
710 /* Copy rasterizer state for Draw. */
713 #ifdef PIPE_ARCH_LITTLE_ENDIAN
714 rs
->vap_control_status
= R300_VC_NO_SWAP
;
716 rs
->vap_control_status
= R300_VC_32BIT_SWAP
;
719 /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL.
720 * Else, enable HW TCL and force Draw's TCL off. */
721 if (!r300screen
->caps
->has_tcl
) {
722 rs
->vap_control_status
|= R300_VAP_TCL_BYPASS
;
725 rs
->point_size
= pack_float_16_6x(state
->point_size
) |
726 (pack_float_16_6x(state
->point_size
) << R300_POINTSIZE_X_SHIFT
);
728 rs
->line_control
= pack_float_16_6x(state
->line_width
) |
729 R300_GA_LINE_CNTL_END_TYPE_COMP
;
731 /* Enable polygon mode */
732 if (state
->fill_cw
!= PIPE_POLYGON_MODE_FILL
||
733 state
->fill_ccw
!= PIPE_POLYGON_MODE_FILL
) {
734 rs
->polygon_mode
= R300_GA_POLY_MODE_DUAL
;
737 /* Radeons don't think in "CW/CCW", they think in "front/back". */
738 if (state
->front_winding
== PIPE_WINDING_CW
) {
739 rs
->cull_mode
= R300_FRONT_FACE_CW
;
742 if (state
->offset_cw
) {
743 rs
->polygon_offset_enable
|= R300_FRONT_ENABLE
;
745 if (state
->offset_ccw
) {
746 rs
->polygon_offset_enable
|= R300_BACK_ENABLE
;
750 if (rs
->polygon_mode
) {
752 r300_translate_polygon_mode_front(state
->fill_cw
);
754 r300_translate_polygon_mode_back(state
->fill_ccw
);
757 rs
->cull_mode
= R300_FRONT_FACE_CCW
;
760 if (state
->offset_ccw
) {
761 rs
->polygon_offset_enable
|= R300_FRONT_ENABLE
;
763 if (state
->offset_cw
) {
764 rs
->polygon_offset_enable
|= R300_BACK_ENABLE
;
768 if (rs
->polygon_mode
) {
770 r300_translate_polygon_mode_front(state
->fill_ccw
);
772 r300_translate_polygon_mode_back(state
->fill_cw
);
775 if (state
->front_winding
& state
->cull_mode
) {
776 rs
->cull_mode
|= R300_CULL_FRONT
;
778 if (~(state
->front_winding
) & state
->cull_mode
) {
779 rs
->cull_mode
|= R300_CULL_BACK
;
782 if (rs
->polygon_offset_enable
) {
783 rs
->depth_offset
= state
->offset_units
;
784 rs
->depth_scale
= state
->offset_scale
;
787 if (state
->line_stipple_enable
) {
788 rs
->line_stipple_config
=
789 R300_GA_LINE_STIPPLE_CONFIG_LINE_RESET_LINE
|
790 (fui((float)state
->line_stipple_factor
) &
791 R300_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_MASK
);
792 /* XXX this might need to be scaled up */
793 rs
->line_stipple_value
= state
->line_stipple_pattern
;
796 if (state
->flatshade
) {
797 rs
->color_control
= R300_SHADE_MODEL_FLAT
;
799 rs
->color_control
= R300_SHADE_MODEL_SMOOTH
;
805 /* Bind rasterizer state. */
806 static void r300_bind_rs_state(struct pipe_context
* pipe
, void* state
)
808 struct r300_context
* r300
= r300_context(pipe
);
809 struct r300_rs_state
* rs
= (struct r300_rs_state
*)state
;
812 draw_flush(r300
->draw
);
813 draw_set_rasterizer_state(r300
->draw
, &rs
->rs
, state
);
817 r300
->polygon_offset_enabled
= rs
->rs
.offset_cw
|| rs
->rs
.offset_ccw
;
819 r300
->polygon_offset_enabled
= FALSE
;
822 UPDATE_STATE(state
, r300
->rs_state
);
823 r300
->rs_state
.size
= 17 + (r300
->polygon_offset_enabled
? 5 : 0);
825 /* XXX Why is this still needed, dammit!? */
826 r300
->scissor_state
.dirty
= TRUE
;
827 r300
->viewport_state
.dirty
= TRUE
;
829 /* XXX Clean these up when we move to atom emits */
830 if (r300
->fs
&& r300
->fs
->inputs
.wpos
!= ATTR_UNUSED
) {
831 r300
->dirty_state
|= R300_NEW_FRAGMENT_SHADER_CONSTANTS
;
835 /* Free rasterizer state. */
836 static void r300_delete_rs_state(struct pipe_context
* pipe
, void* state
)
842 r300_create_sampler_state(struct pipe_context
* pipe
,
843 const struct pipe_sampler_state
* state
)
845 struct r300_context
* r300
= r300_context(pipe
);
846 struct r300_sampler_state
* sampler
= CALLOC_STRUCT(r300_sampler_state
);
850 sampler
->state
= *state
;
853 (r300_translate_wrap(state
->wrap_s
) << R300_TX_WRAP_S_SHIFT
) |
854 (r300_translate_wrap(state
->wrap_t
) << R300_TX_WRAP_T_SHIFT
) |
855 (r300_translate_wrap(state
->wrap_r
) << R300_TX_WRAP_R_SHIFT
);
857 sampler
->filter0
|= r300_translate_tex_filters(state
->min_img_filter
,
858 state
->mag_img_filter
,
859 state
->min_mip_filter
,
860 state
->max_anisotropy
> 0);
862 /* Unfortunately, r300-r500 don't support floating-point mipmap lods. */
863 /* We must pass these to the merge function to clamp them properly. */
864 sampler
->min_lod
= MAX2((unsigned)state
->min_lod
, 0);
865 sampler
->max_lod
= MAX2((unsigned)ceilf(state
->max_lod
), 0);
867 lod_bias
= CLAMP((int)(state
->lod_bias
* 32), -(1 << 9), (1 << 9) - 1);
869 sampler
->filter1
|= lod_bias
<< R300_LOD_BIAS_SHIFT
;
871 sampler
->filter1
|= r300_anisotropy(state
->max_anisotropy
);
873 util_pack_color(state
->border_color
, PIPE_FORMAT_B8G8R8A8_UNORM
, &uc
);
874 sampler
->border_color
= uc
.ui
;
876 /* R500-specific fixups and optimizations */
877 if (r300_screen(r300
->context
.screen
)->caps
->is_r500
) {
878 sampler
->filter1
|= R500_BORDER_FIX
;
881 return (void*)sampler
;
884 static void r300_bind_sampler_states(struct pipe_context
* pipe
,
888 struct r300_context
* r300
= r300_context(pipe
);
889 struct r300_textures_state
* state
=
890 (struct r300_textures_state
*)r300
->textures_state
.state
;
896 memcpy(state
->sampler_states
, states
, sizeof(void*) * count
);
897 state
->sampler_count
= count
;
899 r300
->textures_state
.dirty
= TRUE
;
901 /* Pick a fragment shader based on the texture compare state. */
902 if (r300
->fs
&& count
) {
903 if (r300_pick_fragment_shader(r300
)) {
904 r300
->dirty_state
|= R300_NEW_FRAGMENT_SHADER
|
905 R300_NEW_FRAGMENT_SHADER_CONSTANTS
;
910 static void r300_lacks_vertex_textures(struct pipe_context
* pipe
,
916 static void r300_delete_sampler_state(struct pipe_context
* pipe
, void* state
)
921 static void r300_set_sampler_textures(struct pipe_context
* pipe
,
923 struct pipe_texture
** texture
)
925 struct r300_context
* r300
= r300_context(pipe
);
926 struct r300_textures_state
* state
=
927 (struct r300_textures_state
*)r300
->textures_state
.state
;
929 boolean is_r500
= r300_screen(r300
->context
.screen
)->caps
->is_r500
;
930 boolean dirty_tex
= FALSE
;
937 for (i
= 0; i
< count
; i
++) {
938 if (state
->textures
[i
] != (struct r300_texture
*)texture
[i
]) {
939 pipe_texture_reference((struct pipe_texture
**)&state
->textures
[i
],
943 /* R300-specific - set the texrect factor in the fragment shader */
944 if (!is_r500
&& state
->textures
[i
]->is_npot
) {
945 /* XXX It would be nice to re-emit just 1 constant,
946 * XXX not all of them */
947 r300
->dirty_state
|= R300_NEW_FRAGMENT_SHADER_CONSTANTS
;
952 for (i
= count
; i
< 8; i
++) {
953 if (state
->textures
[i
]) {
954 pipe_texture_reference((struct pipe_texture
**)&state
->textures
[i
],
959 state
->texture_count
= count
;
961 r300
->textures_state
.dirty
= TRUE
;
964 r300
->texture_cache_inval
.dirty
= TRUE
;
968 static void r300_set_scissor_state(struct pipe_context
* pipe
,
969 const struct pipe_scissor_state
* state
)
971 struct r300_context
* r300
= r300_context(pipe
);
973 memcpy(r300
->scissor_state
.state
, state
,
974 sizeof(struct pipe_scissor_state
));
976 r300
->scissor_state
.dirty
= TRUE
;
979 static void r300_set_viewport_state(struct pipe_context
* pipe
,
980 const struct pipe_viewport_state
* state
)
982 struct r300_context
* r300
= r300_context(pipe
);
983 struct r300_viewport_state
* viewport
=
984 (struct r300_viewport_state
*)r300
->viewport_state
.state
;
986 r300
->viewport
= *state
;
988 /* Do the transform in HW. */
989 viewport
->vte_control
= R300_VTX_W0_FMT
;
991 if (state
->scale
[0] != 1.0f
) {
992 viewport
->xscale
= state
->scale
[0];
993 viewport
->vte_control
|= R300_VPORT_X_SCALE_ENA
;
995 if (state
->scale
[1] != 1.0f
) {
996 viewport
->yscale
= state
->scale
[1];
997 viewport
->vte_control
|= R300_VPORT_Y_SCALE_ENA
;
999 if (state
->scale
[2] != 1.0f
) {
1000 viewport
->zscale
= state
->scale
[2];
1001 viewport
->vte_control
|= R300_VPORT_Z_SCALE_ENA
;
1003 if (state
->translate
[0] != 0.0f
) {
1004 viewport
->xoffset
= state
->translate
[0];
1005 viewport
->vte_control
|= R300_VPORT_X_OFFSET_ENA
;
1007 if (state
->translate
[1] != 0.0f
) {
1008 viewport
->yoffset
= state
->translate
[1];
1009 viewport
->vte_control
|= R300_VPORT_Y_OFFSET_ENA
;
1011 if (state
->translate
[2] != 0.0f
) {
1012 viewport
->zoffset
= state
->translate
[2];
1013 viewport
->vte_control
|= R300_VPORT_Z_OFFSET_ENA
;
1016 r300
->viewport_state
.dirty
= TRUE
;
1017 if (r300
->fs
&& r300
->fs
->inputs
.wpos
!= ATTR_UNUSED
) {
1018 r300
->dirty_state
|= R300_NEW_FRAGMENT_SHADER_CONSTANTS
;
1022 static void r300_set_vertex_buffers(struct pipe_context
* pipe
,
1024 const struct pipe_vertex_buffer
* buffers
)
1026 struct r300_context
* r300
= r300_context(pipe
);
1027 unsigned i
, max_index
= ~0;
1029 memcpy(r300
->vertex_buffer
, buffers
,
1030 sizeof(struct pipe_vertex_buffer
) * count
);
1032 for (i
= 0; i
< count
; i
++) {
1033 max_index
= MIN2(buffers
[i
].max_index
, max_index
);
1036 r300
->vertex_buffer_count
= count
;
1037 r300
->vertex_buffer_max_index
= max_index
;
1040 draw_flush(r300
->draw
);
1041 draw_set_vertex_buffers(r300
->draw
, count
, buffers
);
1043 r300
->vertex_stream_state
.dirty
= TRUE
;
1047 static boolean
r300_validate_aos(struct r300_context
*r300
)
1049 struct pipe_vertex_buffer
*vbuf
= r300
->vertex_buffer
;
1050 struct pipe_vertex_element
*velem
= r300
->vertex_element
;
1053 /* Check if formats and strides are aligned to the size of DWORD. */
1054 for (i
= 0; i
< r300
->vertex_element_count
; i
++) {
1055 if (vbuf
[velem
[i
].vertex_buffer_index
].stride
% 4 != 0 ||
1056 util_format_get_blocksize(velem
[i
].src_format
) % 4 != 0) {
1063 static void r300_set_vertex_elements(struct pipe_context
* pipe
,
1065 const struct pipe_vertex_element
* elements
)
1067 struct r300_context
* r300
= r300_context(pipe
);
1069 memcpy(r300
->vertex_element
,
1071 sizeof(struct pipe_vertex_element
) * count
);
1072 r300
->vertex_element_count
= count
;
1075 draw_flush(r300
->draw
);
1076 draw_set_vertex_elements(r300
->draw
, count
, elements
);
1079 if (!r300_validate_aos(r300
)) {
1080 /* XXX We should fallback using draw. */
1086 static void* r300_create_vs_state(struct pipe_context
* pipe
,
1087 const struct pipe_shader_state
* shader
)
1089 struct r300_context
* r300
= r300_context(pipe
);
1091 if (r300_screen(pipe
->screen
)->caps
->has_tcl
) {
1092 struct r300_vertex_shader
* vs
= CALLOC_STRUCT(r300_vertex_shader
);
1093 /* Copy state directly into shader. */
1094 vs
->state
= *shader
;
1095 vs
->state
.tokens
= tgsi_dup_tokens(shader
->tokens
);
1097 tgsi_scan_shader(shader
->tokens
, &vs
->info
);
1101 return draw_create_vertex_shader(r300
->draw
, shader
);
1105 static void r300_bind_vs_state(struct pipe_context
* pipe
, void* shader
)
1107 struct r300_context
* r300
= r300_context(pipe
);
1109 if (r300_screen(pipe
->screen
)->caps
->has_tcl
) {
1110 struct r300_vertex_shader
* vs
= (struct r300_vertex_shader
*)shader
;
1113 r300
->vs_state
.state
= NULL
;
1115 } else if (!vs
->translated
) {
1116 r300_translate_vertex_shader(r300
, vs
);
1119 UPDATE_STATE(shader
, r300
->vs_state
);
1120 r300
->vs_state
.size
= vs
->code
.length
+ 9;
1122 r300
->rs_block_state
.dirty
= TRUE
; /* Will be updated before the emission. */
1123 r300
->vap_output_state
.dirty
= TRUE
;
1124 r300
->vertex_stream_state
.dirty
= TRUE
; /* XXX needed for TCL bypass */
1125 r300
->pvs_flush
.dirty
= TRUE
;
1128 r300_vertex_shader_setup_wpos(r300
);
1131 r300
->dirty_state
|= R300_NEW_VERTEX_SHADER_CONSTANTS
;
1133 draw_flush(r300
->draw
);
1134 draw_bind_vertex_shader(r300
->draw
,
1135 (struct draw_vertex_shader
*)shader
);
1139 static void r300_delete_vs_state(struct pipe_context
* pipe
, void* shader
)
1141 struct r300_context
* r300
= r300_context(pipe
);
1143 if (r300_screen(pipe
->screen
)->caps
->has_tcl
) {
1144 struct r300_vertex_shader
* vs
= (struct r300_vertex_shader
*)shader
;
1146 rc_constants_destroy(&vs
->code
.constants
);
1147 FREE((void*)vs
->state
.tokens
);
1150 draw_delete_vertex_shader(r300
->draw
,
1151 (struct draw_vertex_shader
*)shader
);
1155 static void r300_set_constant_buffer(struct pipe_context
*pipe
,
1156 uint shader
, uint index
,
1157 struct pipe_buffer
*buf
)
1159 struct r300_context
* r300
= r300_context(pipe
);
1160 struct r300_screen
*r300screen
= r300_screen(pipe
->screen
);
1164 if (buf
== NULL
|| buf
->size
== 0 ||
1165 (mapped
= pipe_buffer_map(pipe
->screen
, buf
, PIPE_BUFFER_USAGE_CPU_READ
)) == NULL
)
1167 r300
->shader_constants
[shader
].count
= 0;
1171 assert((buf
->size
% 4 * sizeof(float)) == 0);
1173 /* Check the size of the constant buffer. */
1175 case PIPE_SHADER_VERTEX
:
1178 case PIPE_SHADER_FRAGMENT
:
1179 if (r300screen
->caps
->is_r500
) {
1181 /* XXX Implement emission of r400's extended constant buffer. */
1182 /*} else if (r300screen->caps->is_r400) {
1192 /* XXX Subtract immediates and RC_STATE_* variables. */
1193 if (buf
->size
> (sizeof(float) * 4 * max_size
)) {
1194 debug_printf("r300: Max size of the constant buffer is "
1195 "%i*4 floats.\n", max_size
);
1199 memcpy(r300
->shader_constants
[shader
].constants
, mapped
, buf
->size
);
1200 r300
->shader_constants
[shader
].count
= buf
->size
/ (4 * sizeof(float));
1201 pipe_buffer_unmap(pipe
->screen
, buf
);
1203 if (shader
== PIPE_SHADER_VERTEX
) {
1204 r300
->dirty_state
|= R300_NEW_VERTEX_SHADER_CONSTANTS
;
1205 r300
->pvs_flush
.dirty
= TRUE
;
1207 else if (shader
== PIPE_SHADER_FRAGMENT
)
1208 r300
->dirty_state
|= R300_NEW_FRAGMENT_SHADER_CONSTANTS
;
1211 void r300_init_state_functions(struct r300_context
* r300
)
1213 r300
->context
.create_blend_state
= r300_create_blend_state
;
1214 r300
->context
.bind_blend_state
= r300_bind_blend_state
;
1215 r300
->context
.delete_blend_state
= r300_delete_blend_state
;
1217 r300
->context
.set_blend_color
= r300_set_blend_color
;
1219 r300
->context
.set_clip_state
= r300_set_clip_state
;
1221 r300
->context
.set_constant_buffer
= r300_set_constant_buffer
;
1223 r300
->context
.create_depth_stencil_alpha_state
= r300_create_dsa_state
;
1224 r300
->context
.bind_depth_stencil_alpha_state
= r300_bind_dsa_state
;
1225 r300
->context
.delete_depth_stencil_alpha_state
= r300_delete_dsa_state
;
1227 r300
->context
.set_stencil_ref
= r300_set_stencil_ref
;
1229 r300
->context
.set_framebuffer_state
= r300_set_framebuffer_state
;
1231 r300
->context
.create_fs_state
= r300_create_fs_state
;
1232 r300
->context
.bind_fs_state
= r300_bind_fs_state
;
1233 r300
->context
.delete_fs_state
= r300_delete_fs_state
;
1235 r300
->context
.set_polygon_stipple
= r300_set_polygon_stipple
;
1237 r300
->context
.create_rasterizer_state
= r300_create_rs_state
;
1238 r300
->context
.bind_rasterizer_state
= r300_bind_rs_state
;
1239 r300
->context
.delete_rasterizer_state
= r300_delete_rs_state
;
1241 r300
->context
.create_sampler_state
= r300_create_sampler_state
;
1242 r300
->context
.bind_fragment_sampler_states
= r300_bind_sampler_states
;
1243 r300
->context
.bind_vertex_sampler_states
= r300_lacks_vertex_textures
;
1244 r300
->context
.delete_sampler_state
= r300_delete_sampler_state
;
1246 r300
->context
.set_fragment_sampler_textures
= r300_set_sampler_textures
;
1248 r300
->context
.set_scissor_state
= r300_set_scissor_state
;
1250 r300
->context
.set_viewport_state
= r300_set_viewport_state
;
1252 r300
->context
.set_vertex_buffers
= r300_set_vertex_buffers
;
1253 r300
->context
.set_vertex_elements
= r300_set_vertex_elements
;
1255 r300
->context
.create_vs_state
= r300_create_vs_state
;
1256 r300
->context
.bind_vs_state
= r300_bind_vs_state
;
1257 r300
->context
.delete_vs_state
= r300_delete_vs_state
;