1 #ifndef __NV20_CONTEXT_H__
2 #define __NV20_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 #include "nv20_state.h"
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);
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)
36 #include "nv20_screen.h"
39 struct pipe_context pipe
;
41 struct nouveau_winsys
*nvws
;
42 struct nv20_screen
*screen
;
45 struct draw_context
*draw
;
49 struct nv20_sampler_state
*tex_sampler
[PIPE_MAX_SAMPLERS
];
50 struct nv20_miptree
*tex_miptree
[PIPE_MAX_SAMPLERS
];
51 unsigned dirty_samplers
;
56 struct pipe_buffer
*rt
[4];
57 struct pipe_buffer
*zeta
;
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
;
68 //struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
69 float *constbuf
[PIPE_SHADER_TYPES
][32][4];
70 unsigned constbuf_nr
[PIPE_SHADER_TYPES
];
72 struct vertex_info vertex_info
;
75 struct pipe_buffer
*buffer
;
81 struct pipe_buffer
*buffer
;
87 struct nouveau_resource *exec_heap;
88 struct nouveau_resource *data_heap;
90 struct nv20_vertex_program *active;
92 struct nv20_vertex_program *current;
96 struct nv20_fragment_program
*active
;
98 struct nv20_fragment_program
*current
;
99 struct pipe_buffer
*constant_buf
;
102 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
103 struct pipe_vertex_element vtxelt
[PIPE_MAX_ATTRIBS
];
106 static INLINE
struct nv20_context
*
107 nv20_context(struct pipe_context
*pipe
)
109 return (struct nv20_context
*)pipe
;
112 extern void nv20_init_state_functions(struct nv20_context
*nv20
);
113 extern void nv20_init_surface_functions(struct nv20_context
*nv20
);
115 extern void nv20_screen_init_miptree_functions(struct pipe_screen
*pscreen
);
118 extern void nv20_clear(struct pipe_context
*pipe
, unsigned buffers
,
119 const float *rgba
, double depth
, unsigned stencil
);
122 extern struct draw_stage
*nv20_draw_render_stage(struct nv20_context
*nv20
);
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
*);
131 extern void nv20_fragtex_bind(struct nv20_context
*);
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
);
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
);
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
,
147 unsigned prim
, unsigned start
, unsigned count
);