Merge branch 'mesa_7_7_branch'
[mesa.git] / src / gallium / drivers / nv20 / nv20_context.h
1 #ifndef __NV20_CONTEXT_H__
2 #define __NV20_CONTEXT_H__
3
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7 #include "pipe/p_compiler.h"
8
9 #include "util/u_memory.h"
10 #include "util/u_math.h"
11
12 #include "draw/draw_vertex.h"
13
14 #include "nouveau/nouveau_winsys.h"
15 #include "nouveau/nouveau_gldefs.h"
16 #include "nouveau/nouveau_context.h"
17
18 #include "nv20_state.h"
19
20 #define NOUVEAU_ERR(fmt, args...) \
21 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
22 #define NOUVEAU_MSG(fmt, args...) \
23 fprintf(stderr, "nouveau: "fmt, ##args);
24
25 #define NV20_NEW_VERTPROG (1 << 0)
26 #define NV20_NEW_FRAGPROG (1 << 1)
27 #define NV20_NEW_VTXARRAYS (1 << 2)
28 #define NV20_NEW_BLEND (1 << 3)
29 #define NV20_NEW_BLENDCOL (1 << 4)
30 #define NV20_NEW_RAST (1 << 5)
31 #define NV20_NEW_DSA (1 << 6)
32 #define NV20_NEW_VIEWPORT (1 << 7)
33 #define NV20_NEW_SCISSOR (1 << 8)
34 #define NV20_NEW_FRAMEBUFFER (1 << 9)
35
36 #include "nv20_screen.h"
37
38 struct nv20_context {
39 struct pipe_context pipe;
40
41 struct nouveau_winsys *nvws;
42 struct nv20_screen *screen;
43 unsigned pctx_id;
44
45 struct draw_context *draw;
46
47 uint32_t dirty;
48
49 struct nv20_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
50 struct nv20_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
51 unsigned dirty_samplers;
52 unsigned fp_samplers;
53 unsigned vp_samplers;
54
55 uint32_t rt_enable;
56 struct pipe_buffer *rt[4];
57 struct pipe_buffer *zeta;
58 uint32_t lma_offset;
59
60 struct nv20_blend_state *blend;
61 struct pipe_blend_color *blend_color;
62 struct nv20_rasterizer_state *rast;
63 struct nv20_depth_stencil_alpha_state *dsa;
64 struct pipe_viewport_state *viewport;
65 struct pipe_scissor_state *scissor;
66 struct pipe_framebuffer_state *framebuffer;
67
68 //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
69 float *constbuf[PIPE_SHADER_TYPES][32][4];
70 unsigned constbuf_nr[PIPE_SHADER_TYPES];
71
72 struct vertex_info vertex_info;
73
74 struct {
75 struct pipe_buffer *buffer;
76 uint32_t format;
77 } tex[2];
78
79 unsigned vb_enable;
80 struct {
81 struct pipe_buffer *buffer;
82 unsigned delta;
83 } vb[16];
84
85 /* struct {
86
87 struct nouveau_resource *exec_heap;
88 struct nouveau_resource *data_heap;
89
90 struct nv20_vertex_program *active;
91
92 struct nv20_vertex_program *current;
93 } vertprog;
94 */
95 struct {
96 struct nv20_fragment_program *active;
97
98 struct nv20_fragment_program *current;
99 struct pipe_buffer *constant_buf;
100 } fragprog;
101
102 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
103 struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
104 };
105
106 static INLINE struct nv20_context *
107 nv20_context(struct pipe_context *pipe)
108 {
109 return (struct nv20_context *)pipe;
110 }
111
112 extern void nv20_init_state_functions(struct nv20_context *nv20);
113 extern void nv20_init_surface_functions(struct nv20_context *nv20);
114
115 extern void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen);
116
117 /* nv20_clear.c */
118 extern void nv20_clear(struct pipe_context *pipe, unsigned buffers,
119 const float *rgba, double depth, unsigned stencil);
120
121 /* nv20_draw.c */
122 extern struct draw_stage *nv20_draw_render_stage(struct nv20_context *nv20);
123
124 /* nv20_fragprog.c */
125 extern void nv20_fragprog_bind(struct nv20_context *,
126 struct nv20_fragment_program *);
127 extern void nv20_fragprog_destroy(struct nv20_context *,
128 struct nv20_fragment_program *);
129
130 /* nv20_fragtex.c */
131 extern void nv20_fragtex_bind(struct nv20_context *);
132
133 /* nv20_prim_vbuf.c */
134 struct draw_stage *nv20_draw_vbuf_stage( struct nv20_context *nv20 );
135 extern void nv20_vtxbuf_bind(struct nv20_context* nv20);
136
137 /* nv20_state.c and friends */
138 extern void nv20_emit_hw_state(struct nv20_context *nv20);
139 extern void nv20_state_tex_update(struct nv20_context *nv20);
140
141 /* nv20_vbo.c */
142 extern void nv20_draw_arrays(struct pipe_context *, unsigned mode,
143 unsigned start, unsigned count);
144 extern void nv20_draw_elements( struct pipe_context *pipe,
145 struct pipe_buffer *indexBuffer,
146 unsigned indexSize,
147 unsigned prim, unsigned start, unsigned count);
148
149
150 #endif