r300_state.c revision 1db736f74a911f74228d6843f4d981eeafb8669d
1/*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23#include "util/u_math.h"
24#include "util/u_pack_color.h"
25
26#include "util/u_debug.h"
27#include "pipe/internal/p_winsys_screen.h"
28
29#include "r300_context.h"
30#include "r300_reg.h"
31#include "r300_state_inlines.h"
32#include "r300_state_shader.h"
33
34/* r300_state: Functions used to intialize state context by translating
35 * Gallium state objects into semi-native r300 state objects. */
36
37/* Create a new blend state based on the CSO blend state.
38 *
39 * This encompasses alpha blending, logic/raster ops, and blend dithering. */
40static void* r300_create_blend_state(struct pipe_context* pipe,
41                                     const struct pipe_blend_state* state)
42{
43    struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state);
44
45    if (state->blend_enable) {
46        /* XXX for now, always do separate alpha...
47         * is it faster to do it with one reg? */
48        blend->blend_control = R300_ALPHA_BLEND_ENABLE |
49                R300_SEPARATE_ALPHA_ENABLE |
50                R300_READ_ENABLE |
51                r300_translate_blend_function(state->rgb_func) |
52                (r300_translate_blend_factor(state->rgb_src_factor) <<
53                    R300_SRC_BLEND_SHIFT) |
54                (r300_translate_blend_factor(state->rgb_dst_factor) <<
55                    R300_DST_BLEND_SHIFT);
56        blend->alpha_blend_control =
57                r300_translate_blend_function(state->alpha_func) |
58                (r300_translate_blend_factor(state->alpha_src_factor) <<
59                    R300_SRC_BLEND_SHIFT) |
60                (r300_translate_blend_factor(state->alpha_dst_factor) <<
61                    R300_DST_BLEND_SHIFT);
62    }
63
64    /* PIPE_LOGICOP_* don't need to be translated, fortunately. */
65    /* XXX are logicops still allowed if blending's disabled?
66     * Does Gallium take care of it for us? */
67    if (state->logicop_enable) {
68        blend->rop = R300_RB3D_ROPCNTL_ROP_ENABLE |
69                (state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT;
70    }
71
72    if (state->dither) {
73        blend->dither = R300_RB3D_DITHER_CTL_DITHER_MODE_LUT |
74                R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_LUT;
75    }
76
77    return (void*)blend;
78}
79
80/* Bind blend state. */
81static void r300_bind_blend_state(struct pipe_context* pipe,
82                                  void* state)
83{
84    struct r300_context* r300 = r300_context(pipe);
85
86    r300->blend_state = (struct r300_blend_state*)state;
87    r300->dirty_state |= R300_NEW_BLEND;
88}
89
90/* Free blend state. */
91static void r300_delete_blend_state(struct pipe_context* pipe,
92                                    void* state)
93{
94    FREE(state);
95}
96
97/* Set blend color.
98 * Setup both R300 and R500 registers, figure out later which one to write. */
99static void r300_set_blend_color(struct pipe_context* pipe,
100                                 const struct pipe_blend_color* color)
101{
102    struct r300_context* r300 = r300_context(pipe);
103    ubyte ur, ug, ub, ua;
104
105    ur = float_to_ubyte(color->color[0]);
106    ug = float_to_ubyte(color->color[1]);
107    ub = float_to_ubyte(color->color[2]);
108    ua = float_to_ubyte(color->color[3]);
109
110    util_pack_color(color->color, PIPE_FORMAT_A8R8G8B8_UNORM,
111            &r300->blend_color_state->blend_color);
112
113    /* XXX this is wrong */
114    r300->blend_color_state->blend_color_red_alpha = ur | (ua << 16);
115    r300->blend_color_state->blend_color_green_blue = ub | (ug << 16);
116
117    r300->dirty_state |= R300_NEW_BLEND_COLOR;
118}
119
120static void r300_set_clip_state(struct pipe_context* pipe,
121                                const struct pipe_clip_state* state)
122{
123    struct r300_context* r300 = r300_context(pipe);
124    /* XXX Draw */
125    draw_flush(r300->draw);
126    draw_set_clip_state(r300->draw, state);
127}
128
129static void
130    r300_set_constant_buffer(struct pipe_context* pipe,
131                             uint shader, uint index,
132                             const struct pipe_constant_buffer* buffer)
133{
134    struct r300_context* r300 = r300_context(pipe);
135
136    /* This entire chunk of code seems ever-so-slightly baked.
137     * It's as if I've got pipe_buffer* matryoshkas... */
138    if (buffer && buffer->buffer && buffer->buffer->size) {
139        void* map = pipe->winsys->buffer_map(pipe->winsys, buffer->buffer,
140                                             PIPE_BUFFER_USAGE_CPU_READ);
141        memcpy(r300->shader_constants[shader].constants,
142            map, buffer->buffer->size);
143        pipe->winsys->buffer_unmap(pipe->winsys, buffer->buffer);
144
145        r300->shader_constants[shader].user_count =
146            buffer->buffer->size / (sizeof(float) * 4);
147    } else {
148        r300->shader_constants[shader].user_count = 0;
149    }
150
151    r300->dirty_state |= R300_NEW_CONSTANTS;
152}
153
154/* Create a new depth, stencil, and alpha state based on the CSO dsa state.
155 *
156 * This contains the depth buffer, stencil buffer, alpha test, and such.
157 * On the Radeon, depth and stencil buffer setup are intertwined, which is
158 * the reason for some of the strange-looking assignments across registers. */
159static void*
160        r300_create_dsa_state(struct pipe_context* pipe,
161                              const struct pipe_depth_stencil_alpha_state* state)
162{
163    struct r300_dsa_state* dsa = CALLOC_STRUCT(r300_dsa_state);
164
165    /* Depth test setup. */
166    if (state->depth.enabled) {
167        dsa->z_buffer_control |= R300_Z_ENABLE;
168
169        if (state->depth.writemask) {
170            dsa->z_buffer_control |= R300_Z_WRITE_ENABLE;
171        }
172
173        dsa->z_stencil_control |=
174            (r300_translate_depth_stencil_function(state->depth.func) <<
175                R300_Z_FUNC_SHIFT);
176    }
177
178    /* Stencil buffer setup. */
179    if (state->stencil[0].enabled) {
180        dsa->z_buffer_control |= R300_STENCIL_ENABLE;
181        dsa->z_stencil_control |=
182            (r300_translate_depth_stencil_function(state->stencil[0].func) <<
183                R300_S_FRONT_FUNC_SHIFT) |
184            (r300_translate_stencil_op(state->stencil[0].fail_op) <<
185                R300_S_FRONT_SFAIL_OP_SHIFT) |
186            (r300_translate_stencil_op(state->stencil[0].zpass_op) <<
187                R300_S_FRONT_ZPASS_OP_SHIFT) |
188            (r300_translate_stencil_op(state->stencil[0].zfail_op) <<
189                R300_S_FRONT_ZFAIL_OP_SHIFT);
190
191        dsa->stencil_ref_mask = (state->stencil[0].ref_value) |
192                (state->stencil[0].valuemask << R300_STENCILMASK_SHIFT) |
193                (state->stencil[0].writemask << R300_STENCILWRITEMASK_SHIFT);
194
195        if (state->stencil[1].enabled) {
196            dsa->z_buffer_control |= R300_STENCIL_FRONT_BACK;
197            dsa->z_stencil_control |=
198            (r300_translate_depth_stencil_function(state->stencil[1].func) <<
199                R300_S_BACK_FUNC_SHIFT) |
200            (r300_translate_stencil_op(state->stencil[1].fail_op) <<
201                R300_S_BACK_SFAIL_OP_SHIFT) |
202            (r300_translate_stencil_op(state->stencil[1].zpass_op) <<
203                R300_S_BACK_ZPASS_OP_SHIFT) |
204            (r300_translate_stencil_op(state->stencil[1].zfail_op) <<
205                R300_S_BACK_ZFAIL_OP_SHIFT);
206
207            dsa->stencil_ref_bf = (state->stencil[1].ref_value) |
208                (state->stencil[1].valuemask << R300_STENCILMASK_SHIFT) |
209                (state->stencil[1].writemask << R300_STENCILWRITEMASK_SHIFT);
210        }
211    }
212
213    /* Alpha test setup. */
214    if (state->alpha.enabled) {
215        dsa->alpha_function =
216            r300_translate_alpha_function(state->alpha.func) |
217            R300_FG_ALPHA_FUNC_ENABLE;
218        dsa->alpha_reference = CLAMP(state->alpha.ref_value * 1023.0f,
219                                     0, 1023);
220    } else {
221        dsa->z_buffer_top = R300_ZTOP_ENABLE;
222    }
223
224    return (void*)dsa;
225}
226
227/* Bind DSA state. */
228static void r300_bind_dsa_state(struct pipe_context* pipe,
229                                void* state)
230{
231    struct r300_context* r300 = r300_context(pipe);
232
233    r300->dsa_state = (struct r300_dsa_state*)state;
234    r300->dirty_state |= R300_NEW_DSA;
235}
236
237/* Free DSA state. */
238static void r300_delete_dsa_state(struct pipe_context* pipe,
239                                  void* state)
240{
241    FREE(state);
242}
243
244static void r300_set_edgeflags(struct pipe_context* pipe,
245                               const unsigned* bitfield)
246{
247    /* XXX you know it's bad when i915 has this blank too */
248}
249
250static void
251    r300_set_framebuffer_state(struct pipe_context* pipe,
252                               const struct pipe_framebuffer_state* state)
253{
254    struct r300_context* r300 = r300_context(pipe);
255
256    draw_flush(r300->draw);
257
258    r300->framebuffer_state = *state;
259
260    r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
261}
262
263/* Create fragment shader state. */
264static void* r300_create_fs_state(struct pipe_context* pipe,
265                                  const struct pipe_shader_state* shader)
266{
267    struct r300_context* r300 = r300_context(pipe);
268    struct r3xx_fragment_shader* fs = NULL;
269
270    if (r300_screen(r300->context.screen)->caps->is_r500) {
271        fs =
272            (struct r3xx_fragment_shader*)CALLOC_STRUCT(r500_fragment_shader);
273    } else {
274        fs =
275            (struct r3xx_fragment_shader*)CALLOC_STRUCT(r300_fragment_shader);
276    }
277
278    /* Copy state directly into shader. */
279    fs->state = *shader;
280
281    tgsi_scan_shader(shader->tokens, &fs->info);
282
283    return (void*)fs;
284}
285
286/* Bind fragment shader state. */
287static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
288{
289    struct r300_context* r300 = r300_context(pipe);
290    struct r3xx_fragment_shader* fs = (struct r3xx_fragment_shader*)shader;
291
292    if (fs == NULL) {
293        r300->fs = NULL;
294        return;
295    } else if (!fs->translated) {
296        r300_translate_fragment_shader(r300, fs);
297    }
298
299    fs->translated = TRUE;
300    r300->fs = fs;
301
302    r300->dirty_state |= R300_NEW_FRAGMENT_SHADER;
303}
304
305/* Delete fragment shader state. */
306static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
307{
308    FREE(shader);
309}
310
311static void r300_set_polygon_stipple(struct pipe_context* pipe,
312                                     const struct pipe_poly_stipple* state)
313{
314    /* XXX */
315}
316
317/* Create a new rasterizer state based on the CSO rasterizer state.
318 *
319 * This is a very large chunk of state, and covers most of the graphics
320 * backend (GB), geometry assembly (GA), and setup unit (SU) blocks.
321 *
322 * In a not entirely unironic sidenote, this state has nearly nothing to do
323 * with the actual block on the Radeon called the rasterizer (RS). */
324static void* r300_create_rs_state(struct pipe_context* pipe,
325                                  const struct pipe_rasterizer_state* state)
326{
327    struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state);
328
329    /* XXX this is part of HW TCL */
330    /* XXX endian control */
331    rs->vap_control_status = R300_VAP_TCL_BYPASS;
332
333    rs->point_size = pack_float_16_6x(state->point_size) |
334        (pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT);
335
336    rs->point_minmax =
337        ((int)(state->point_size_min * 6.0) <<
338         R300_GA_POINT_MINMAX_MIN_SHIFT) |
339        ((int)(state->point_size_max * 6.0) <<
340         R300_GA_POINT_MINMAX_MAX_SHIFT);
341
342    rs->line_control = pack_float_16_6x(state->line_width) |
343        R300_GA_LINE_CNTL_END_TYPE_COMP;
344
345    /* Radeons don't think in "CW/CCW", they think in "front/back". */
346    if (state->front_winding == PIPE_WINDING_CW) {
347        rs->cull_mode = R300_FRONT_FACE_CW;
348
349        if (state->offset_cw) {
350            rs->polygon_offset_enable |= R300_FRONT_ENABLE;
351        }
352        if (state->offset_ccw) {
353            rs->polygon_offset_enable |= R300_BACK_ENABLE;
354        }
355    } else {
356        rs->cull_mode = R300_FRONT_FACE_CCW;
357
358        if (state->offset_ccw) {
359            rs->polygon_offset_enable |= R300_FRONT_ENABLE;
360        }
361        if (state->offset_cw) {
362            rs->polygon_offset_enable |= R300_BACK_ENABLE;
363        }
364    }
365    if (state->front_winding & state->cull_mode) {
366        rs->cull_mode |= R300_CULL_FRONT;
367    }
368    if (~(state->front_winding) & state->cull_mode) {
369        rs->cull_mode |= R300_CULL_BACK;
370    }
371
372    if (rs->polygon_offset_enable) {
373        rs->depth_offset_front = rs->depth_offset_back =
374            fui(state->offset_units);
375        rs->depth_scale_front = rs->depth_scale_back =
376            fui(state->offset_scale);
377    }
378
379    if (state->line_stipple_enable) {
380        rs->line_stipple_config =
381            R300_GA_LINE_STIPPLE_CONFIG_LINE_RESET_LINE |
382            (fui((float)state->line_stipple_factor) &
383                R300_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_MASK);
384        /* XXX this might need to be scaled up */
385        rs->line_stipple_value = state->line_stipple_pattern;
386    }
387
388    if (state->flatshade) {
389        rs->color_control = R300_SHADE_MODEL_FLAT;
390    } else {
391        rs->color_control = R300_SHADE_MODEL_SMOOTH;
392    }
393
394    rs->rs = *state;
395
396    return (void*)rs;
397}
398
399/* Bind rasterizer state. */
400static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
401{
402    struct r300_context* r300 = r300_context(pipe);
403    struct r300_rs_state* rs = (struct r300_rs_state*)state;
404
405    draw_set_rasterizer_state(r300->draw, &rs->rs);
406
407    r300->rs_state = rs;
408    r300->dirty_state |= R300_NEW_RASTERIZER;
409}
410
411/* Free rasterizer state. */
412static void r300_delete_rs_state(struct pipe_context* pipe, void* state)
413{
414    FREE(state);
415}
416
417static void*
418        r300_create_sampler_state(struct pipe_context* pipe,
419                                  const struct pipe_sampler_state* state)
420{
421    struct r300_context* r300 = r300_context(pipe);
422    struct r300_sampler_state* sampler = CALLOC_STRUCT(r300_sampler_state);
423    int lod_bias;
424
425    sampler->filter0 |=
426        (r300_translate_wrap(state->wrap_s) << R300_TX_WRAP_S_SHIFT) |
427        (r300_translate_wrap(state->wrap_t) << R300_TX_WRAP_T_SHIFT) |
428        (r300_translate_wrap(state->wrap_r) << R300_TX_WRAP_R_SHIFT);
429
430    sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
431                                                   state->mag_img_filter,
432                                                   state->min_mip_filter);
433
434    lod_bias = CLAMP((int)(state->lod_bias * 32), -(1 << 9), (1 << 9) - 1);
435
436    sampler->filter1 |= lod_bias << R300_LOD_BIAS_SHIFT;
437
438    sampler->filter1 |= r300_anisotropy(state->max_anisotropy);
439
440    util_pack_color(state->border_color, PIPE_FORMAT_A8R8G8B8_UNORM,
441                    &sampler->border_color);
442
443    /* R500-specific fixups and optimizations */
444    if (r300_screen(r300->context.screen)->caps->is_r500) {
445        sampler->filter1 |= R500_BORDER_FIX;
446    }
447
448    return (void*)sampler;
449}
450
451static void r300_bind_sampler_states(struct pipe_context* pipe,
452                                     unsigned count,
453                                     void** states)
454{
455    struct r300_context* r300 = r300_context(pipe);
456    int i;
457
458    if (count > 8) {
459        return;
460    }
461
462    for (i = 0; i < count; i++) {
463        if (r300->sampler_states[i] != states[i]) {
464            r300->sampler_states[i] = (struct r300_sampler_state*)states[i];
465            r300->dirty_state |= (R300_NEW_SAMPLER << i);
466        }
467    }
468
469    r300->sampler_count = count;
470}
471
472static void r300_delete_sampler_state(struct pipe_context* pipe, void* state)
473{
474    FREE(state);
475}
476
477static void r300_set_sampler_textures(struct pipe_context* pipe,
478                                      unsigned count,
479                                      struct pipe_texture** texture)
480{
481    struct r300_context* r300 = r300_context(pipe);
482    int i;
483
484    /* XXX magic num */
485    if (count > 8) {
486        return;
487    }
488
489    for (i = 0; i < count; i++) {
490        if (r300->textures[i] != (struct r300_texture*)texture[i]) {
491            pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
492                texture[i]);
493            r300->dirty_state |= (R300_NEW_TEXTURE << i);
494        }
495    }
496
497    for (i = count; i < 8; i++) {
498        if (r300->textures[i]) {
499            pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
500                NULL);
501            r300->dirty_state |= (R300_NEW_TEXTURE << i);
502        }
503    }
504
505    r300->texture_count = count;
506}
507
508static void r300_set_scissor_state(struct pipe_context* pipe,
509                                   const struct pipe_scissor_state* state)
510{
511    struct r300_context* r300 = r300_context(pipe);
512    draw_flush(r300->draw);
513
514    if (r300_screen(r300->context.screen)->caps->is_r500) {
515        r300->scissor_state->scissor_top_left =
516            (state->minx << R300_SCISSORS_X_SHIFT) |
517            (state->miny << R300_SCISSORS_Y_SHIFT);
518        r300->scissor_state->scissor_bottom_right =
519            (state->maxx << R300_SCISSORS_X_SHIFT) |
520            (state->maxy << R300_SCISSORS_Y_SHIFT);
521    } else {
522        /* Offset of 1440 in non-R500 chipsets. */
523        r300->scissor_state->scissor_top_left =
524            ((state->minx + 1440) << R300_SCISSORS_X_SHIFT) |
525            ((state->miny + 1440) << R300_SCISSORS_Y_SHIFT);
526        r300->scissor_state->scissor_bottom_right =
527            ((state->maxx + 1440) << R300_SCISSORS_X_SHIFT) |
528            ((state->maxy + 1440) << R300_SCISSORS_Y_SHIFT);
529    }
530
531    r300->dirty_state |= R300_NEW_SCISSOR;
532}
533
534static void r300_set_viewport_state(struct pipe_context* pipe,
535                                    const struct pipe_viewport_state* state)
536{
537    struct r300_context* r300 = r300_context(pipe);
538
539    r300->viewport_state->xscale = state->scale[0];
540    r300->viewport_state->yscale = state->scale[1];
541    r300->viewport_state->zscale = state->scale[2];
542
543    r300->viewport_state->xoffset = state->translate[0];
544    r300->viewport_state->yoffset = state->translate[1];
545    r300->viewport_state->zoffset = state->translate[2];
546
547    r300->viewport_state->vte_control = 0;
548    if (r300_screen(r300->context.screen)->caps->has_tcl) {
549        /* Do the transform in HW. */
550        r300->viewport_state->vte_control |=
551            R300_VPORT_X_SCALE_ENA | R300_VPORT_X_OFFSET_ENA |
552            R300_VPORT_Y_SCALE_ENA | R300_VPORT_Y_OFFSET_ENA |
553            R300_VPORT_Z_SCALE_ENA | R300_VPORT_Z_OFFSET_ENA;
554    } else {
555        /* Have Draw do the actual transform. */
556        draw_set_viewport_state(r300->draw, state);
557    }
558}
559
560static void r300_set_vertex_buffers(struct pipe_context* pipe,
561                                    unsigned count,
562                                    const struct pipe_vertex_buffer* buffers)
563{
564    struct r300_context* r300 = r300_context(pipe);
565
566    memcpy(r300->vertex_buffers, buffers,
567        sizeof(struct pipe_vertex_buffer) * count);
568
569    r300->vertex_buffer_count = count;
570
571    draw_flush(r300->draw);
572    draw_set_vertex_buffers(r300->draw, count, buffers);
573}
574
575static void r300_set_vertex_elements(struct pipe_context* pipe,
576                                    unsigned count,
577                                    const struct pipe_vertex_element* elements)
578{
579    struct r300_context* r300 = r300_context(pipe);
580    /* XXX Draw */
581    draw_flush(r300->draw);
582    draw_set_vertex_elements(r300->draw, count, elements);
583}
584
585static void* r300_create_vs_state(struct pipe_context* pipe,
586                                  const struct pipe_shader_state* state)
587{
588    struct r300_context* context = r300_context(pipe);
589    /* XXX handing this off to Draw for now */
590    return draw_create_vertex_shader(context->draw, state);
591}
592
593static void r300_bind_vs_state(struct pipe_context* pipe, void* state) {
594    struct r300_context* context = r300_context(pipe);
595    /* XXX handing this off to Draw for now */
596    draw_bind_vertex_shader(context->draw, (struct draw_vertex_shader*)state);
597}
598
599static void r300_delete_vs_state(struct pipe_context* pipe, void* state)
600{
601    struct r300_context* context = r300_context(pipe);
602    /* XXX handing this off to Draw for now */
603    draw_delete_vertex_shader(context->draw, (struct draw_vertex_shader*)state);
604}
605
606void r300_init_state_functions(struct r300_context* r300)
607{
608    r300->context.create_blend_state = r300_create_blend_state;
609    r300->context.bind_blend_state = r300_bind_blend_state;
610    r300->context.delete_blend_state = r300_delete_blend_state;
611
612    r300->context.set_blend_color = r300_set_blend_color;
613
614    r300->context.set_clip_state = r300_set_clip_state;
615
616    r300->context.set_constant_buffer = r300_set_constant_buffer;
617
618    r300->context.create_depth_stencil_alpha_state = r300_create_dsa_state;
619    r300->context.bind_depth_stencil_alpha_state = r300_bind_dsa_state;
620    r300->context.delete_depth_stencil_alpha_state = r300_delete_dsa_state;
621
622    r300->context.set_edgeflags = r300_set_edgeflags;
623
624    r300->context.set_framebuffer_state = r300_set_framebuffer_state;
625
626    r300->context.create_fs_state = r300_create_fs_state;
627    r300->context.bind_fs_state = r300_bind_fs_state;
628    r300->context.delete_fs_state = r300_delete_fs_state;
629
630    r300->context.set_polygon_stipple = r300_set_polygon_stipple;
631
632    r300->context.create_rasterizer_state = r300_create_rs_state;
633    r300->context.bind_rasterizer_state = r300_bind_rs_state;
634    r300->context.delete_rasterizer_state = r300_delete_rs_state;
635
636    r300->context.create_sampler_state = r300_create_sampler_state;
637    r300->context.bind_sampler_states = r300_bind_sampler_states;
638    r300->context.delete_sampler_state = r300_delete_sampler_state;
639
640    r300->context.set_sampler_textures = r300_set_sampler_textures;
641
642    r300->context.set_scissor_state = r300_set_scissor_state;
643
644    r300->context.set_viewport_state = r300_set_viewport_state;
645
646    r300->context.set_vertex_buffers = r300_set_vertex_buffers;
647    r300->context.set_vertex_elements = r300_set_vertex_elements;
648
649    r300->context.create_vs_state = r300_create_vs_state;
650    r300->context.bind_vs_state = r300_bind_vs_state;
651    r300->context.delete_vs_state = r300_delete_vs_state;
652}
653