2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
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:
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
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. */
23 #ifndef R300_CONTEXT_H
24 #define R300_CONTEXT_H
26 #include "draw/draw_context.h"
27 #include "pipe/p_context.h"
28 #include "util/u_memory.h"
30 #include "r300_screen.h"
32 struct r300_blend_state {
33 uint32_t blend_control; /* R300_RB3D_BLENDCNTL: 0x4e04 */
34 uint32_t alpha_blend_control; /* R300_RB3D_ABLENDCNTL: 0x4e08 */
35 uint32_t rop; /* R300_RB3D_ROPCNTL: 0x4e18 */
36 uint32_t dither; /* R300_RB3D_DITHER_CTL: 0x4e50 */
39 struct r300_dsa_state {
40 uint32_t alpha_function; /* R300_FG_ALPHA_FUNC: 0x4bd4 */
41 uint32_t alpha_reference; /* R500_FG_ALPHA_VALUE: 0x4be0 */
42 uint32_t z_buffer_control; /* R300_ZB_CNTL: 0x4f00 */
43 uint32_t z_stencil_control; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */
44 uint32_t stencil_ref_mask; /* R300_ZB_STENCILREFMASK: 0x4f08 */
45 uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */
46 uint32_t stencil_ref_bf; /* R300_ZB_STENCILREFMASK_BF: 0x4fd4 */
49 struct r300_rs_state {
50 uint32_t polygon_offset_enable; /* R300_SU_POLY_OFFSET_ENABLE: 0x42b4 */
51 uint32_t cull_mode; /* R300_SU_CULL_MODE: 0x42b8 */
52 uint32_t depth_scale_front; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */
53 uint32_t depth_offset_front; /* R300_SU_POLY_OFFSET_FRONT_OFFSET: 0x42a8 */
54 uint32_t depth_scale_back; /* R300_SU_POLY_OFFSET_BACK_SCALE: 0x42ac */
55 uint32_t depth_offset_back; /* R300_SU_POLY_OFFSET_BACK_OFFSET: 0x42b0 */
58 struct r300_scissor_state {
59 uint32_t scissor_top_left; /* R300_SC_SCISSORS_TL: 0x43e0 */
60 uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
63 #define R300_NEW_BLEND 0x1
64 #define R300_NEW_DSA 0x2
65 #define R300_NEW_RS 0x4
66 #define R300_NEW_SCISSOR 0x8
70 struct pipe_context context;
72 /* The interface to the windowing system, etc. */
73 struct r300_winsys* winsys;
74 /* Draw module. Used mostly for SW TCL. */
75 struct draw_context* draw;
77 /* Various CSO state objects. */
79 struct r300_blend_state* blend_state;
80 /* Depth, stencil, and alpha state. */
81 struct r300_dsa_state* dsa_state;
82 /* Rasterizer state. */
83 struct r300_rs_state* rs_state;
85 struct r300_scissor_state* scissor_state;
87 /* Bitmask of dirty state objects. */
91 /* Convenience cast wrapper. */
92 static struct r300_context* r300_context(struct pipe_context* context) {
93 return (struct r300_context*)context;
96 /* Context initialization. */
97 void r300_init_state_functions(struct r300_context* r300);
98 void r300_init_surface_functions(struct r300_context* r300);
100 struct pipe_context* r300_create_context(struct pipe_screen* screen,
101 struct pipe_winsys* winsys,
102 struct r300_winsys* r300_winsys);
104 #endif /* R300_CONTEXT_H */