Merge remote branch 'origin/mesa_7_6_branch'
[mesa.git] / src / gallium / drivers / nv10 / nv10_context.h
1 #ifndef __NV10_CONTEXT_H__
2 #define __NV10_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 #define NOUVEAU_PUSH_CONTEXT(ctx) \
19 struct nv10_screen *ctx = nv10->screen
20 #include "nouveau/nouveau_push.h"
21
22 #include "nv10_state.h"
23
24 #define NOUVEAU_ERR(fmt, args...) \
25 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
26 #define NOUVEAU_MSG(fmt, args...) \
27 fprintf(stderr, "nouveau: "fmt, ##args);
28
29 #define NV10_NEW_VERTPROG (1 << 0)
30 #define NV10_NEW_FRAGPROG (1 << 1)
31 #define NV10_NEW_VTXARRAYS (1 << 2)
32 #define NV10_NEW_BLEND (1 << 3)
33 #define NV10_NEW_BLENDCOL (1 << 4)
34 #define NV10_NEW_RAST (1 << 5)
35 #define NV10_NEW_DSA (1 << 6)
36 #define NV10_NEW_VIEWPORT (1 << 7)
37 #define NV10_NEW_SCISSOR (1 << 8)
38 #define NV10_NEW_FRAMEBUFFER (1 << 9)
39
40 #include "nv10_screen.h"
41
42 struct nv10_context {
43 struct pipe_context pipe;
44
45 struct nouveau_winsys *nvws;
46 struct nv10_screen *screen;
47 unsigned pctx_id;
48
49 struct draw_context *draw;
50
51 uint32_t dirty;
52
53 struct nv10_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
54 struct nv10_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
55 unsigned dirty_samplers;
56 unsigned fp_samplers;
57 unsigned vp_samplers;
58
59 uint32_t rt_enable;
60 struct pipe_buffer *rt[4];
61 struct pipe_buffer *zeta;
62 uint32_t lma_offset;
63
64 struct nv10_blend_state *blend;
65 struct pipe_blend_color *blend_color;
66 struct nv10_rasterizer_state *rast;
67 struct nv10_depth_stencil_alpha_state *dsa;
68 struct pipe_viewport_state *viewport;
69 struct pipe_scissor_state *scissor;
70 struct pipe_framebuffer_state *framebuffer;
71
72 //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
73 float *constbuf[PIPE_SHADER_TYPES][32][4];
74 unsigned constbuf_nr[PIPE_SHADER_TYPES];
75
76 struct vertex_info vertex_info;
77
78 struct {
79 struct pipe_buffer *buffer;
80 uint32_t format;
81 } tex[2];
82
83 unsigned vb_enable;
84 struct {
85 struct pipe_buffer *buffer;
86 unsigned delta;
87 } vb[16];
88
89 /* struct {
90
91 struct nouveau_resource *exec_heap;
92 struct nouveau_resource *data_heap;
93
94 struct nv10_vertex_program *active;
95
96 struct nv10_vertex_program *current;
97 } vertprog;
98 */
99 struct {
100 struct nv10_fragment_program *active;
101
102 struct nv10_fragment_program *current;
103 struct pipe_buffer *constant_buf;
104 } fragprog;
105
106 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
107 struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
108 };
109
110 static INLINE struct nv10_context *
111 nv10_context(struct pipe_context *pipe)
112 {
113 return (struct nv10_context *)pipe;
114 }
115
116 extern void nv10_init_state_functions(struct nv10_context *nv10);
117 extern void nv10_init_surface_functions(struct nv10_context *nv10);
118
119 extern void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen);
120
121 /* nv10_clear.c */
122 extern void nv10_clear(struct pipe_context *pipe, unsigned buffers,
123 const float *rgba, double depth, unsigned stencil);
124
125
126 /* nv10_draw.c */
127 extern struct draw_stage *nv10_draw_render_stage(struct nv10_context *nv10);
128
129 /* nv10_fragprog.c */
130 extern void nv10_fragprog_bind(struct nv10_context *,
131 struct nv10_fragment_program *);
132 extern void nv10_fragprog_destroy(struct nv10_context *,
133 struct nv10_fragment_program *);
134
135 /* nv10_fragtex.c */
136 extern void nv10_fragtex_bind(struct nv10_context *);
137
138 /* nv10_prim_vbuf.c */
139 struct draw_stage *nv10_draw_vbuf_stage( struct nv10_context *nv10 );
140 extern void nv10_vtxbuf_bind(struct nv10_context* nv10);
141
142 /* nv10_state.c and friends */
143 extern void nv10_emit_hw_state(struct nv10_context *nv10);
144 extern void nv10_state_tex_update(struct nv10_context *nv10);
145
146 /* nv10_vbo.c */
147 extern boolean nv10_draw_arrays(struct pipe_context *, unsigned mode,
148 unsigned start, unsigned count);
149 extern boolean nv10_draw_elements( struct pipe_context *pipe,
150 struct pipe_buffer *indexBuffer,
151 unsigned indexSize,
152 unsigned prim, unsigned start, unsigned count);
153
154
155 #endif