1 /**************************************************************************
3 * Copyright 2007 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 **************************************************************************/
28 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
32 #include "pipe/draw/draw_context.h"
33 #include "pipe/p_winsys.h"
34 #include "pipe/p_util.h"
36 #include "i915_context.h"
38 #include "i915_state.h"
39 #include "i915_state_inlines.h"
42 /* The i915 (and related graphics cores) do not support GL_CLAMP. The
43 * Intel drivers for "other operating systems" implement GL_CLAMP as
44 * GL_CLAMP_TO_EDGE, so the same is done here.
47 translate_wrap_mode(unsigned wrap
)
50 case PIPE_TEX_WRAP_REPEAT
:
51 return TEXCOORDMODE_WRAP
;
52 case PIPE_TEX_WRAP_CLAMP
:
53 return TEXCOORDMODE_CLAMP_EDGE
; /* not quite correct */
54 case PIPE_TEX_WRAP_CLAMP_TO_EDGE
:
55 return TEXCOORDMODE_CLAMP_EDGE
;
56 case PIPE_TEX_WRAP_CLAMP_TO_BORDER
:
57 return TEXCOORDMODE_CLAMP_BORDER
;
58 // case PIPE_TEX_WRAP_MIRRORED_REPEAT:
59 // return TEXCOORDMODE_MIRROR;
61 return TEXCOORDMODE_WRAP
;
65 static unsigned translate_img_filter( unsigned filter
)
68 case PIPE_TEX_FILTER_NEAREST
:
69 return FILTER_NEAREST
;
70 case PIPE_TEX_FILTER_LINEAR
:
74 return FILTER_NEAREST
;
78 static unsigned translate_mip_filter( unsigned filter
)
81 case PIPE_TEX_MIPFILTER_NONE
:
82 return MIPFILTER_NONE
;
83 case PIPE_TEX_MIPFILTER_NEAREST
:
84 return MIPFILTER_NEAREST
;
85 case PIPE_TEX_FILTER_LINEAR
:
86 return MIPFILTER_LINEAR
;
89 return MIPFILTER_NONE
;
94 /* None of this state is actually used for anything yet.
97 i915_create_blend_state(struct pipe_context
*pipe
,
98 const struct pipe_blend_state
*blend
)
100 struct i915_blend_state
*cso_data
= CALLOC_STRUCT( i915_blend_state
);
103 unsigned eqRGB
= blend
->rgb_func
;
104 unsigned srcRGB
= blend
->rgb_src_factor
;
105 unsigned dstRGB
= blend
->rgb_dst_factor
;
107 unsigned eqA
= blend
->alpha_func
;
108 unsigned srcA
= blend
->alpha_src_factor
;
109 unsigned dstA
= blend
->alpha_dst_factor
;
111 /* Special handling for MIN/MAX filter modes handled at
112 * state_tracker level.
115 if (srcA
!= srcRGB
||
119 cso_data
->iab
= (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD
|
123 IAB_MODIFY_SRC_FACTOR
|
124 IAB_MODIFY_DST_FACTOR
|
125 SRC_ABLND_FACT(i915_translate_blend_factor(srcA
)) |
126 DST_ABLND_FACT(i915_translate_blend_factor(dstA
)) |
127 (i915_translate_blend_func(eqA
) << IAB_FUNC_SHIFT
));
130 cso_data
->iab
= (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD
|
136 cso_data
->modes4
|= (_3DSTATE_MODES_4_CMD
|
137 ENABLE_LOGIC_OP_FUNC
|
138 LOGIC_OP_FUNC(i915_translate_logic_op(blend
->logicop_func
)));
140 if (blend
->logicop_enable
)
141 cso_data
->LIS5
|= S5_LOGICOP_ENABLE
;
144 cso_data
->LIS5
|= S5_COLOR_DITHER_ENABLE
;
146 if ((blend
->colormask
& PIPE_MASK_R
) == 0)
147 cso_data
->LIS5
|= S5_WRITEDISABLE_RED
;
149 if ((blend
->colormask
& PIPE_MASK_G
) == 0)
150 cso_data
->LIS5
|= S5_WRITEDISABLE_GREEN
;
152 if ((blend
->colormask
& PIPE_MASK_B
) == 0)
153 cso_data
->LIS5
|= S5_WRITEDISABLE_BLUE
;
155 if ((blend
->colormask
& PIPE_MASK_A
) == 0)
156 cso_data
->LIS5
|= S5_WRITEDISABLE_ALPHA
;
158 if (blend
->blend_enable
) {
159 unsigned funcRGB
= blend
->rgb_func
;
160 unsigned srcRGB
= blend
->rgb_src_factor
;
161 unsigned dstRGB
= blend
->rgb_dst_factor
;
163 cso_data
->LIS6
|= (S6_CBUF_BLEND_ENABLE
|
164 SRC_BLND_FACT(i915_translate_blend_factor(srcRGB
)) |
165 DST_BLND_FACT(i915_translate_blend_factor(dstRGB
)) |
166 (i915_translate_blend_func(funcRGB
) << S6_CBUF_BLEND_FUNC_SHIFT
));
172 static void i915_bind_blend_state(struct pipe_context
*pipe
,
175 struct i915_context
*i915
= i915_context(pipe
);
177 i915
->blend
= (struct i915_blend_state
*)blend
;
179 i915
->dirty
|= I915_NEW_BLEND
;
183 static void i915_delete_blend_state(struct pipe_context
*pipe
, void *blend
)
188 static void i915_set_blend_color( struct pipe_context
*pipe
,
189 const struct pipe_blend_color
*blend_color
)
191 struct i915_context
*i915
= i915_context(pipe
);
193 i915
->blend_color
= *blend_color
;
195 i915
->dirty
|= I915_NEW_BLEND
;
199 i915_create_sampler_state(struct pipe_context
*pipe
,
200 const struct pipe_sampler_state
*sampler
)
202 struct i915_sampler_state
*cso
= CALLOC_STRUCT( i915_sampler_state
);
203 const unsigned ws
= sampler
->wrap_s
;
204 const unsigned wt
= sampler
->wrap_t
;
205 const unsigned wr
= sampler
->wrap_r
;
206 unsigned minFilt
, magFilt
;
209 cso
->templ
= sampler
;
211 mipFilt
= translate_mip_filter(sampler
->min_mip_filter
);
212 if (sampler
->max_anisotropy
> 1.0) {
213 minFilt
= FILTER_ANISOTROPIC
;
214 magFilt
= FILTER_ANISOTROPIC
;
215 if (sampler
->max_anisotropy
> 2.0) {
216 cso
->state
[0] |= SS2_MAX_ANISO_4
;
220 minFilt
= translate_img_filter( sampler
->min_img_filter
);
221 magFilt
= translate_img_filter( sampler
->mag_img_filter
);
225 int b
= (int) (sampler
->lod_bias
* 16.0);
226 b
= CLAMP(b
, -256, 255);
227 cso
->state
[0] |= ((b
<< SS2_LOD_BIAS_SHIFT
) & SS2_LOD_BIAS_MASK
);
232 if (sampler
->compare_mode
== PIPE_TEX_COMPARE_R_TO_TEXTURE
)
234 cso
->state
[0] |= (SS2_SHADOW_ENABLE
|
235 i915_translate_compare_func(sampler
->compare_func
));
237 minFilt
= FILTER_4X4_FLAT
;
238 magFilt
= FILTER_4X4_FLAT
;
241 cso
->state
[0] |= ((minFilt
<< SS2_MIN_FILTER_SHIFT
) |
242 (mipFilt
<< SS2_MIP_FILTER_SHIFT
) |
243 (magFilt
<< SS2_MAG_FILTER_SHIFT
));
246 ((translate_wrap_mode(ws
) << SS3_TCX_ADDR_MODE_SHIFT
) |
247 (translate_wrap_mode(wt
) << SS3_TCY_ADDR_MODE_SHIFT
) |
248 (translate_wrap_mode(wr
) << SS3_TCZ_ADDR_MODE_SHIFT
));
250 if (sampler
->normalized_coords
)
251 cso
->state
[1] |= SS3_NORMALIZED_COORDS
;
254 ubyte r
= float_to_ubyte(sampler
->border_color
[0]);
255 ubyte g
= float_to_ubyte(sampler
->border_color
[1]);
256 ubyte b
= float_to_ubyte(sampler
->border_color
[2]);
257 ubyte a
= float_to_ubyte(sampler
->border_color
[3]);
258 cso
->state
[2] = I915PACKCOLOR8888(r
, g
, b
, a
);
263 static void i915_bind_sampler_state(struct pipe_context
*pipe
,
264 unsigned unit
, void *sampler
)
266 struct i915_context
*i915
= i915_context(pipe
);
268 assert(unit
< PIPE_MAX_SAMPLERS
);
269 i915
->sampler
[unit
] = (const struct i915_sampler_state
*)sampler
;
271 i915
->dirty
|= I915_NEW_SAMPLER
;
274 static void i915_delete_sampler_state(struct pipe_context
*pipe
,
281 /** XXX move someday? Or consolidate all these simple state setters
286 i915_create_depth_stencil_state(struct pipe_context
*pipe
,
287 const struct pipe_depth_stencil_state
*depth_stencil
)
289 struct i915_depth_stencil_state
*cso
= CALLOC_STRUCT( i915_depth_stencil_state
);
292 int testmask
= depth_stencil
->stencil
.value_mask
[0] & 0xff;
293 int writemask
= depth_stencil
->stencil
.write_mask
[0] & 0xff;
295 cso
->stencil_modes4
|= (_3DSTATE_MODES_4_CMD
|
296 ENABLE_STENCIL_TEST_MASK
|
297 STENCIL_TEST_MASK(testmask
) |
298 ENABLE_STENCIL_WRITE_MASK
|
299 STENCIL_WRITE_MASK(writemask
));
302 if (depth_stencil
->stencil
.front_enabled
) {
303 int test
= i915_translate_compare_func(depth_stencil
->stencil
.front_func
);
304 int fop
= i915_translate_stencil_op(depth_stencil
->stencil
.front_fail_op
);
305 int dfop
= i915_translate_stencil_op(depth_stencil
->stencil
.front_zfail_op
);
306 int dpop
= i915_translate_stencil_op(depth_stencil
->stencil
.front_zpass_op
);
307 int ref
= depth_stencil
->stencil
.ref_value
[0] & 0xff;
309 cso
->stencil_LIS5
|= (S5_STENCIL_TEST_ENABLE
|
310 S5_STENCIL_WRITE_ENABLE
|
311 (ref
<< S5_STENCIL_REF_SHIFT
) |
312 (test
<< S5_STENCIL_TEST_FUNC_SHIFT
) |
313 (fop
<< S5_STENCIL_FAIL_SHIFT
) |
314 (dfop
<< S5_STENCIL_PASS_Z_FAIL_SHIFT
) |
315 (dpop
<< S5_STENCIL_PASS_Z_PASS_SHIFT
));
318 if (depth_stencil
->stencil
.back_enabled
) {
319 int test
= i915_translate_compare_func(depth_stencil
->stencil
.back_func
);
320 int fop
= i915_translate_stencil_op(depth_stencil
->stencil
.back_fail_op
);
321 int dfop
= i915_translate_stencil_op(depth_stencil
->stencil
.back_zfail_op
);
322 int dpop
= i915_translate_stencil_op(depth_stencil
->stencil
.back_zpass_op
);
323 int ref
= depth_stencil
->stencil
.ref_value
[1] & 0xff;
324 int tmask
= depth_stencil
->stencil
.value_mask
[1] & 0xff;
325 int wmask
= depth_stencil
->stencil
.write_mask
[1] & 0xff;
327 cso
->bfo
[0] = (_3DSTATE_BACKFACE_STENCIL_OPS
|
328 BFO_ENABLE_STENCIL_FUNCS
|
329 BFO_ENABLE_STENCIL_TWO_SIDE
|
330 BFO_ENABLE_STENCIL_REF
|
331 BFO_STENCIL_TWO_SIDE
|
332 (ref
<< BFO_STENCIL_REF_SHIFT
) |
333 (test
<< BFO_STENCIL_TEST_SHIFT
) |
334 (fop
<< BFO_STENCIL_FAIL_SHIFT
) |
335 (dfop
<< BFO_STENCIL_PASS_Z_FAIL_SHIFT
) |
336 (dpop
<< BFO_STENCIL_PASS_Z_PASS_SHIFT
));
338 cso
->bfo
[1] = (_3DSTATE_BACKFACE_STENCIL_MASKS
|
339 BFM_ENABLE_STENCIL_TEST_MASK
|
340 BFM_ENABLE_STENCIL_WRITE_MASK
|
341 (tmask
<< BFM_STENCIL_TEST_MASK_SHIFT
) |
342 (wmask
<< BFM_STENCIL_WRITE_MASK_SHIFT
));
345 /* This actually disables two-side stencil: The bit set is a
346 * modify-enable bit to indicate we are changing the two-side
347 * setting. Then there is a symbolic zero to show that we are
348 * setting the flag to zero/off.
350 cso
->bfo
[0] = (_3DSTATE_BACKFACE_STENCIL_OPS
|
351 BFO_ENABLE_STENCIL_TWO_SIDE
|
356 if (depth_stencil
->depth
.enabled
) {
357 int func
= i915_translate_compare_func(depth_stencil
->depth
.func
);
359 cso
->depth_LIS6
|= (S6_DEPTH_TEST_ENABLE
|
360 (func
<< S6_DEPTH_TEST_FUNC_SHIFT
));
362 if (depth_stencil
->depth
.writemask
)
363 cso
->depth_LIS6
|= S6_DEPTH_WRITE_ENABLE
;
369 static void i915_bind_depth_stencil_state(struct pipe_context
*pipe
,
372 struct i915_context
*i915
= i915_context(pipe
);
374 i915
->depth_stencil
= (const struct i915_depth_stencil_state
*)depth_stencil
;
376 i915
->dirty
|= I915_NEW_DEPTH_STENCIL
;
379 static void i915_delete_depth_stencil_state(struct pipe_context
*pipe
,
387 i915_create_alpha_test_state(struct pipe_context
*pipe
,
388 const struct pipe_alpha_test_state
*alpha_test
)
390 struct i915_alpha_test_state
*cso
= CALLOC_STRUCT( i915_alpha_test_state
);
392 if (alpha_test
->enabled
) {
393 int test
= i915_translate_compare_func(alpha_test
->func
);
394 ubyte refByte
= float_to_ubyte(alpha_test
->ref
);
396 cso
->LIS6
|= (S6_ALPHA_TEST_ENABLE
|
397 (test
<< S6_ALPHA_TEST_FUNC_SHIFT
) |
398 (((unsigned) refByte
) << S6_ALPHA_REF_SHIFT
));
403 static void i915_bind_alpha_test_state(struct pipe_context
*pipe
,
406 struct i915_context
*i915
= i915_context(pipe
);
408 i915
->alpha_test
= (const struct i915_alpha_test_state
*)alpha
;
410 i915
->dirty
|= I915_NEW_ALPHA_TEST
;
413 static void i915_delete_alpha_test_state(struct pipe_context
*pipe
,
419 static void i915_set_scissor_state( struct pipe_context
*pipe
,
420 const struct pipe_scissor_state
*scissor
)
422 struct i915_context
*i915
= i915_context(pipe
);
424 memcpy( &i915
->scissor
, scissor
, sizeof(*scissor
) );
425 i915
->dirty
|= I915_NEW_SCISSOR
;
429 static void i915_set_polygon_stipple( struct pipe_context
*pipe
,
430 const struct pipe_poly_stipple
*stipple
)
434 static void i915_set_sampler_units(struct pipe_context
*pipe
,
435 uint numSamplers
, const uint
*units
)
437 struct i915_context
*i915
= i915_context(pipe
);
439 for (i
= 0; i
< numSamplers
; i
++)
440 i915
->sampler_units
[i
] = units
[i
];
443 static void * i915_create_fs_state(struct pipe_context
*pipe
,
444 const struct pipe_shader_state
*templ
)
449 static void i915_bind_fs_state(struct pipe_context
*pipe
, void *fs
)
451 struct i915_context
*i915
= i915_context(pipe
);
453 i915
->fs
= (struct pipe_shader_state
*)fs
;
455 i915
->dirty
|= I915_NEW_FS
;
458 static void i915_delete_fs_state(struct pipe_context
*pipe
, void *shader
)
464 i915_create_vs_state(struct pipe_context
*pipe
,
465 const struct pipe_shader_state
*templ
)
467 struct i915_context
*i915
= i915_context(pipe
);
469 /* just pass-through to draw module */
470 return draw_create_vertex_shader(i915
->draw
, templ
);
473 static void i915_bind_vs_state(struct pipe_context
*pipe
, void *vs
)
475 struct i915_context
*i915
= i915_context(pipe
);
477 /* just pass-through to draw module */
478 draw_bind_vertex_shader(i915
->draw
, vs
);
481 static void i915_delete_vs_state(struct pipe_context
*pipe
, void *shader
)
483 struct i915_context
*i915
= i915_context(pipe
);
485 /* just pass-through to draw module */
486 draw_delete_vertex_shader(i915
->draw
, shader
);
489 static void i915_set_constant_buffer(struct pipe_context
*pipe
,
490 uint shader
, uint index
,
491 const struct pipe_constant_buffer
*buf
)
493 struct i915_context
*i915
= i915_context(pipe
);
494 struct pipe_winsys
*ws
= pipe
->winsys
;
496 assert(shader
< PIPE_SHADER_TYPES
);
499 /* Make a copy of shader constants.
500 * During fragment program translation we may add additional
501 * constants to the array.
503 * We want to consider the situation where some user constants
504 * (ex: a material color) may change frequently but the shader program
505 * stays the same. In that case we should only be updating the first
506 * N constants, leaving any extras from shader translation alone.
511 (mapped
= ws
->buffer_map(ws
, buf
->buffer
, PIPE_BUFFER_FLAG_READ
))) {
512 memcpy(i915
->current
.constants
[shader
], mapped
, buf
->size
);
513 ws
->buffer_unmap(ws
, buf
->buffer
);
514 i915
->current
.num_user_constants
[shader
]
515 = buf
->size
/ (4 * sizeof(float));
518 i915
->current
.num_user_constants
[shader
] = 0;
522 i915
->dirty
|= I915_NEW_CONSTANTS
;
526 static void i915_set_texture_state(struct pipe_context
*pipe
,
528 struct pipe_texture
*texture
)
530 struct i915_context
*i915
= i915_context(pipe
);
532 i915
->texture
[unit
] = (struct i915_texture
*)texture
; /* ptr, not struct */
534 i915
->dirty
|= I915_NEW_TEXTURE
;
539 static void i915_set_framebuffer_state(struct pipe_context
*pipe
,
540 const struct pipe_framebuffer_state
*fb
)
542 struct i915_context
*i915
= i915_context(pipe
);
544 i915
->framebuffer
= *fb
; /* struct copy */
546 i915
->dirty
|= I915_NEW_FRAMEBUFFER
;
551 i915_set_feedback_state(struct pipe_context
*pipe
,
552 const struct pipe_feedback_state
*feedback
)
554 struct i915_context
*i915
= i915_context(pipe
);
555 i915
->feedback
= *feedback
;
556 draw_set_feedback_state(i915
->draw
, feedback
);
561 i915_set_feedback_buffer(struct pipe_context
*pipe
,
563 const struct pipe_feedback_buffer
*feedback
)
565 struct i915_context
*i915
= i915_context(pipe
);
567 assert(index
< PIPE_MAX_FEEDBACK_ATTRIBS
);
569 /* Need to be careful with referencing */
570 pipe
->winsys
->buffer_reference(pipe
->winsys
,
571 &i915
->feedback_buffer
[index
].buffer
,
573 i915
->feedback_buffer
[index
].size
= feedback
->size
;
574 i915
->feedback_buffer
[index
].start_offset
= feedback
->start_offset
;
579 static void i915_set_clear_color_state(struct pipe_context
*pipe
,
580 const struct pipe_clear_color_state
*clear
)
582 struct i915_context
*i915
= i915_context(pipe
);
584 i915
->clear_color
= *clear
; /* struct copy */
589 static void i915_set_clip_state( struct pipe_context
*pipe
,
590 const struct pipe_clip_state
*clip
)
592 struct i915_context
*i915
= i915_context(pipe
);
594 draw_set_clip_state(i915
->draw
, clip
);
596 i915
->dirty
|= I915_NEW_CLIP
;
601 /* Called when driver state tracker notices changes to the viewport
604 static void i915_set_viewport_state( struct pipe_context
*pipe
,
605 const struct pipe_viewport_state
*viewport
)
607 struct i915_context
*i915
= i915_context(pipe
);
609 i915
->viewport
= *viewport
; /* struct copy */
611 /* pass the viewport info to the draw module */
612 draw_set_viewport_state(i915
->draw
, &i915
->viewport
);
614 i915
->dirty
|= I915_NEW_VIEWPORT
;
619 i915_create_rasterizer_state(struct pipe_context
*pipe
,
620 const struct pipe_rasterizer_state
*rasterizer
)
622 struct i915_rasterizer_state
*cso
= CALLOC_STRUCT( i915_rasterizer_state
);
624 cso
->templ
= rasterizer
;
625 cso
->color_interp
= rasterizer
->flatshade
? INTERP_CONSTANT
: INTERP_LINEAR
;
626 cso
->light_twoside
= rasterizer
->light_twoside
;
627 cso
->ds
[0].u
= _3DSTATE_DEPTH_OFFSET_SCALE
;
628 cso
->ds
[1].f
= rasterizer
->offset_scale
;
629 if (rasterizer
->poly_stipple_enable
) {
630 cso
->st
|= ST1_ENABLE
;
633 if (rasterizer
->scissor
)
634 cso
->sc
[0] = _3DSTATE_SCISSOR_ENABLE_CMD
| ENABLE_SCISSOR_RECT
;
636 cso
->sc
[0] = _3DSTATE_SCISSOR_ENABLE_CMD
| DISABLE_SCISSOR_RECT
;
638 switch (rasterizer
->cull_mode
) {
639 case PIPE_WINDING_NONE
:
640 cso
->LIS4
|= S4_CULLMODE_NONE
;
642 case PIPE_WINDING_CW
:
643 cso
->LIS4
|= S4_CULLMODE_CW
;
645 case PIPE_WINDING_CCW
:
646 cso
->LIS4
|= S4_CULLMODE_CCW
;
648 case PIPE_WINDING_BOTH
:
649 cso
->LIS4
|= S4_CULLMODE_BOTH
;
654 int line_width
= CLAMP((int)(rasterizer
->line_width
* 2), 1, 0xf);
656 cso
->LIS4
|= line_width
<< S4_LINE_WIDTH_SHIFT
;
658 if (rasterizer
->line_smooth
)
659 cso
->LIS4
|= S4_LINE_ANTIALIAS_ENABLE
;
663 int point_size
= CLAMP((int) rasterizer
->point_size
, 1, 0xff);
665 cso
->LIS4
|= point_size
<< S4_POINT_WIDTH_SHIFT
;
668 if (rasterizer
->flatshade
) {
669 cso
->LIS4
|= (S4_FLATSHADE_ALPHA
|
671 S4_FLATSHADE_SPECULAR
);
674 cso
->LIS7
= fui( rasterizer
->offset_units
);
680 static void i915_bind_rasterizer_state( struct pipe_context
*pipe
,
683 struct i915_context
*i915
= i915_context(pipe
);
685 i915
->rasterizer
= (struct i915_rasterizer_state
*)setup
;
687 /* pass-through to draw module */
688 draw_set_rasterizer_state(i915
->draw
, i915
->rasterizer
->templ
);
690 i915
->dirty
|= I915_NEW_RASTERIZER
;
693 static void i915_delete_rasterizer_state(struct pipe_context
*pipe
,
699 static void i915_set_vertex_buffer( struct pipe_context
*pipe
,
701 const struct pipe_vertex_buffer
*buffer
)
703 struct i915_context
*i915
= i915_context(pipe
);
704 i915
->vertex_buffer
[index
] = *buffer
;
705 /* pass-through to draw module */
706 draw_set_vertex_buffer(i915
->draw
, index
, buffer
);
709 static void i915_set_vertex_element( struct pipe_context
*pipe
,
711 const struct pipe_vertex_element
*element
)
713 struct i915_context
*i915
= i915_context(pipe
);
714 /* pass-through to draw module */
715 draw_set_vertex_element(i915
->draw
, index
, element
);
721 i915_init_state_functions( struct i915_context
*i915
)
723 i915
->pipe
.create_alpha_test_state
= i915_create_alpha_test_state
;
724 i915
->pipe
.bind_alpha_test_state
= i915_bind_alpha_test_state
;
725 i915
->pipe
.delete_alpha_test_state
= i915_delete_alpha_test_state
;
727 i915
->pipe
.create_blend_state
= i915_create_blend_state
;
728 i915
->pipe
.bind_blend_state
= i915_bind_blend_state
;
729 i915
->pipe
.delete_blend_state
= i915_delete_blend_state
;
731 i915
->pipe
.create_sampler_state
= i915_create_sampler_state
;
732 i915
->pipe
.bind_sampler_state
= i915_bind_sampler_state
;
733 i915
->pipe
.delete_sampler_state
= i915_delete_sampler_state
;
735 i915
->pipe
.create_depth_stencil_state
= i915_create_depth_stencil_state
;
736 i915
->pipe
.bind_depth_stencil_state
= i915_bind_depth_stencil_state
;
737 i915
->pipe
.delete_depth_stencil_state
= i915_delete_depth_stencil_state
;
739 i915
->pipe
.create_rasterizer_state
= i915_create_rasterizer_state
;
740 i915
->pipe
.bind_rasterizer_state
= i915_bind_rasterizer_state
;
741 i915
->pipe
.delete_rasterizer_state
= i915_delete_rasterizer_state
;
742 i915
->pipe
.create_fs_state
= i915_create_fs_state
;
743 i915
->pipe
.bind_fs_state
= i915_bind_fs_state
;
744 i915
->pipe
.delete_fs_state
= i915_delete_fs_state
;
745 i915
->pipe
.create_vs_state
= i915_create_vs_state
;
746 i915
->pipe
.bind_vs_state
= i915_bind_vs_state
;
747 i915
->pipe
.delete_vs_state
= i915_delete_vs_state
;
749 i915
->pipe
.set_blend_color
= i915_set_blend_color
;
750 i915
->pipe
.set_clip_state
= i915_set_clip_state
;
751 i915
->pipe
.set_clear_color_state
= i915_set_clear_color_state
;
752 i915
->pipe
.set_constant_buffer
= i915_set_constant_buffer
;
753 i915
->pipe
.set_framebuffer_state
= i915_set_framebuffer_state
;
754 i915
->pipe
.set_feedback_state
= i915_set_feedback_state
;
755 i915
->pipe
.set_feedback_buffer
= i915_set_feedback_buffer
;
757 i915
->pipe
.set_polygon_stipple
= i915_set_polygon_stipple
;
758 i915
->pipe
.set_sampler_units
= i915_set_sampler_units
;
759 i915
->pipe
.set_scissor_state
= i915_set_scissor_state
;
760 i915
->pipe
.set_texture_state
= i915_set_texture_state
;
761 i915
->pipe
.set_viewport_state
= i915_set_viewport_state
;
762 i915
->pipe
.set_vertex_buffer
= i915_set_vertex_buffer
;
763 i915
->pipe
.set_vertex_element
= i915_set_vertex_element
;