1 #ifndef __NV10_CONTEXT_H__
2 #define __NV10_CONTEXT_H__
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
7 #include "pipe/p_compiler.h"
9 #include "util/u_memory.h"
10 #include "util/u_math.h"
12 #include "draw/draw_vertex.h"
14 #include "nouveau/nouveau_winsys.h"
15 #include "nouveau/nouveau_gldefs.h"
16 #include "nouveau/nouveau_context.h"
18 #define NOUVEAU_PUSH_CONTEXT(ctx) \
19 struct nv10_screen *ctx = nv10->screen
20 #include "nouveau/nouveau_push.h"
22 #include "nv10_state.h"
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);
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)
40 #include "nv10_screen.h"
43 struct pipe_context pipe
;
45 struct nouveau_winsys
*nvws
;
46 struct nv10_screen
*screen
;
49 struct draw_context
*draw
;
53 struct nv10_sampler_state
*tex_sampler
[PIPE_MAX_SAMPLERS
];
54 struct nv10_miptree
*tex_miptree
[PIPE_MAX_SAMPLERS
];
55 unsigned dirty_samplers
;
60 struct pipe_buffer
*rt
[4];
61 struct pipe_buffer
*zeta
;
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
;
72 //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
73 float *constbuf
[PIPE_SHADER_TYPES
][32][4];
74 unsigned constbuf_nr
[PIPE_SHADER_TYPES
];
76 struct vertex_info vertex_info
;
79 struct pipe_buffer
*buffer
;
85 struct pipe_buffer
*buffer
;
91 struct nouveau_resource *exec_heap;
92 struct nouveau_resource *data_heap;
94 struct nv10_vertex_program *active;
96 struct nv10_vertex_program *current;
100 struct nv10_fragment_program
*active
;
102 struct nv10_fragment_program
*current
;
103 struct pipe_buffer
*constant_buf
;
106 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
107 struct pipe_vertex_element vtxelt
[PIPE_MAX_ATTRIBS
];
110 static INLINE
struct nv10_context
*
111 nv10_context(struct pipe_context
*pipe
)
113 return (struct nv10_context
*)pipe
;
116 extern void nv10_init_state_functions(struct nv10_context
*nv10
);
117 extern void nv10_init_surface_functions(struct nv10_context
*nv10
);
119 extern void nv10_screen_init_miptree_functions(struct pipe_screen
*pscreen
);
122 extern void nv10_clear(struct pipe_context
*pipe
, unsigned buffers
,
123 const float *rgba
, double depth
, unsigned stencil
);
127 extern struct draw_stage
*nv10_draw_render_stage(struct nv10_context
*nv10
);
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
*);
136 extern void nv10_fragtex_bind(struct nv10_context
*);
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
);
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
);
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
,
152 unsigned prim
, unsigned start
, unsigned count
);