r300: Add sampler state skeleton.
[mesa.git] / src / gallium / drivers / r300 / r300_context.h
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 #ifndef R300_CONTEXT_H
24 #define R300_CONTEXT_H
25
26 #include "draw/draw_context.h"
27 #include "pipe/p_context.h"
28 #include "util/u_memory.h"
29
30 #include "r300_screen.h"
31 #include "r300_winsys.h"
32
33 struct r300_blend_state {
34 uint32_t blend_control; /* R300_RB3D_CBLEND: 0x4e04 */
35 uint32_t alpha_blend_control; /* R300_RB3D_ABLEND: 0x4e08 */
36 uint32_t rop; /* R300_RB3D_ROPCNTL: 0x4e18 */
37 uint32_t dither; /* R300_RB3D_DITHER_CTL: 0x4e50 */
38 };
39
40 struct r300_blend_color_state {
41 /* RV515 and earlier */
42 uint32_t blend_color; /* R300_RB3D_BLEND_COLOR: 0x4e10 */
43 /* R520 and newer */
44 uint32_t blend_color_red_alpha; /* R500_RB3D_CONSTANT_COLOR_AR: 0x4ef8 */
45 uint32_t blend_color_green_blue; /* R500_RB3D_CONSTANT_COLOR_GB: 0x4efc */
46 };
47
48 struct r300_dsa_state {
49 uint32_t alpha_function; /* R300_FG_ALPHA_FUNC: 0x4bd4 */
50 uint32_t alpha_reference; /* R500_FG_ALPHA_VALUE: 0x4be0 */
51 uint32_t z_buffer_control; /* R300_ZB_CNTL: 0x4f00 */
52 uint32_t z_stencil_control; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */
53 uint32_t stencil_ref_mask; /* R300_ZB_STENCILREFMASK: 0x4f08 */
54 uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */
55 uint32_t stencil_ref_bf; /* R500_ZB_STENCILREFMASK_BF: 0x4fd4 */
56 };
57
58 struct r300_rs_state {
59 uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */
60 uint32_t depth_scale_front; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */
61 uint32_t depth_offset_front; /* R300_SU_POLY_OFFSET_FRONT_OFFSET: 0x42a8 */
62 uint32_t depth_scale_back; /* R300_SU_POLY_OFFSET_BACK_SCALE: 0x42ac */
63 uint32_t depth_offset_back; /* R300_SU_POLY_OFFSET_BACK_OFFSET: 0x42b0 */
64 uint32_t polygon_offset_enable; /* R300_SU_POLY_OFFSET_ENABLE: 0x42b4 */
65 uint32_t cull_mode; /* R300_SU_CULL_MODE: 0x42b8 */
66 };
67
68 struct r300_sampler_state {
69 };
70
71 struct r300_scissor_state {
72 uint32_t scissor_top_left; /* R300_SC_SCISSORS_TL: 0x43e0 */
73 uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
74 };
75
76 #define R300_NEW_BLEND 0x0001
77 #define R300_NEW_BLEND_COLOR 0x0002
78 #define R300_NEW_DSA 0x0004
79 #define R300_NEW_RS 0x0008
80 #define R300_NEW_SAMPLER 0x0010
81 #define R300_NEW_SCISSOR 0x1000
82 #define R300_NEW_KITCHEN_SINK 0x1fff
83
84 struct r300_context {
85 /* Parent class */
86 struct pipe_context context;
87
88 /* The interface to the windowing system, etc. */
89 struct r300_winsys* winsys;
90 /* Draw module. Used mostly for SW TCL. */
91 struct draw_context* draw;
92
93 /* Various CSO state objects. */
94 /* Blend state. */
95 struct r300_blend_state* blend_state;
96 /* Blend color state. */
97 struct r300_blend_color_state* blend_color_state;
98 /* Depth, stencil, and alpha state. */
99 struct r300_dsa_state* dsa_state;
100 /* Rasterizer state. */
101 struct r300_rs_state* rs_state;
102 /* Sampler states. */
103 struct r300_sampler_state* sampler_states[8];
104 int sampler_count;
105 /* Scissor state. */
106 struct r300_scissor_state* scissor_state;
107 /* Bitmask of dirty state objects. */
108 uint32_t dirty_state;
109 /* Flag indicating whether or not the HW is dirty. */
110 uint32_t dirty_hw;
111 };
112
113 /* Convenience cast wrapper. */
114 static struct r300_context* r300_context(struct pipe_context* context) {
115 return (struct r300_context*)context;
116 }
117
118 /* Context initialization. */
119 void r300_init_state_functions(struct r300_context* r300);
120 void r300_init_surface_functions(struct r300_context* r300);
121
122 struct pipe_context* r300_create_context(struct pipe_screen* screen,
123 struct pipe_winsys* winsys,
124 struct r300_winsys* r300_winsys);
125
126 #endif /* R300_CONTEXT_H */