1 #ifndef __NV40_CONTEXT_H__
2 #define __NV40_CONTEXT_H__
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
8 #include "draw/draw_vertex.h"
10 #include "nouveau/nouveau_winsys.h"
11 #include "nouveau/nouveau_gldefs.h"
13 #define NOUVEAU_PUSH_CONTEXT(ctx) \
14 struct nv40_channel_context *ctx = nv40->hw
15 #include "nouveau/nouveau_push.h"
16 #include "nouveau/nouveau_stateobj.h"
18 #include "nv40_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 NV40_NEW_BLEND (1 << 0)
26 #define NV40_NEW_RAST (1 << 1)
27 #define NV40_NEW_ZSA (1 << 2)
28 #define NV40_NEW_SAMPLER (1 << 3)
29 #define NV40_NEW_FB (1 << 4)
30 #define NV40_NEW_STIPPLE (1 << 5)
31 #define NV40_NEW_SCISSOR (1 << 6)
32 #define NV40_NEW_VIEWPORT (1 << 7)
33 #define NV40_NEW_BCOL (1 << 8)
34 #define NV40_NEW_VERTPROG (1 << 9)
35 #define NV40_NEW_FRAGPROG (1 << 10)
36 #define NV40_NEW_ARRAYS (1 << 11)
38 struct nv40_channel_context
{
39 struct nouveau_winsys
*nvws
;
44 /* HW graphics objects */
45 struct nouveau_grobj
*curie
;
46 struct nouveau_notifier
*sync
;
48 /* Query object resources */
49 struct nouveau_notifier
*query
;
50 struct nouveau_resource
*query_heap
;
52 /* Vtxprog resources */
53 struct nouveau_resource
*vp_exec_heap
;
54 struct nouveau_resource
*vp_data_heap
;
58 struct pipe_context pipe
;
59 struct nouveau_winsys
*nvws
;
61 struct nv40_channel_context
*hw
;
62 struct draw_context
*draw
;
68 struct nv40_sampler_state
*tex_sampler
[PIPE_MAX_SAMPLERS
];
69 struct nv40_miptree
*tex_miptree
[PIPE_MAX_SAMPLERS
];
70 unsigned dirty_samplers
;
74 struct nouveau_stateobj
*so_framebuffer
;
75 struct nouveau_stateobj
*so_fragtex
[16];
76 struct nouveau_stateobj
*so_vtxbuf
;
77 struct nouveau_stateobj
*so_blend
;
78 struct nouveau_stateobj
*so_rast
;
79 struct nouveau_stateobj
*so_zsa
;
80 struct nouveau_stateobj
*so_bcol
;
81 struct nouveau_stateobj
*so_scissor
;
82 struct nouveau_stateobj
*so_viewport
;
83 struct nouveau_stateobj
*so_stipple
;
86 struct nv40_vertex_program
*active
;
88 struct nv40_vertex_program
*current
;
89 struct pipe_buffer
*constant_buf
;
93 struct nv40_fragment_program
*active
;
95 struct nv40_fragment_program
*current
;
96 struct pipe_buffer
*constant_buf
;
99 struct pipe_vertex_buffer vtxbuf
[PIPE_ATTRIB_MAX
];
100 struct pipe_vertex_element vtxelt
[PIPE_ATTRIB_MAX
];
103 static INLINE
struct nv40_context
*
104 nv40_context(struct pipe_context
*pipe
)
106 return (struct nv40_context
*)pipe
;
109 extern void nv40_init_state_functions(struct nv40_context
*nv40
);
110 extern void nv40_init_surface_functions(struct nv40_context
*nv40
);
111 extern void nv40_init_miptree_functions(struct nv40_context
*nv40
);
112 extern void nv40_init_query_functions(struct nv40_context
*nv40
);
115 extern struct draw_stage
*nv40_draw_render_stage(struct nv40_context
*nv40
);
117 /* nv40_vertprog.c */
118 extern void nv40_vertprog_translate(struct nv40_context
*,
119 struct nv40_vertex_program
*);
120 extern void nv40_vertprog_bind(struct nv40_context
*,
121 struct nv40_vertex_program
*);
122 extern void nv40_vertprog_destroy(struct nv40_context
*,
123 struct nv40_vertex_program
*);
125 /* nv40_fragprog.c */
126 extern void nv40_fragprog_translate(struct nv40_context
*,
127 struct nv40_fragment_program
*);
128 extern void nv40_fragprog_bind(struct nv40_context
*,
129 struct nv40_fragment_program
*);
130 extern void nv40_fragprog_destroy(struct nv40_context
*,
131 struct nv40_fragment_program
*);
134 extern void nv40_fragtex_bind(struct nv40_context
*);
136 /* nv40_state.c and friends */
137 extern void nv40_emit_hw_state(struct nv40_context
*nv40
);
138 extern void nv40_state_tex_update(struct nv40_context
*nv40
);
141 extern boolean
nv40_draw_arrays(struct pipe_context
*, unsigned mode
,
142 unsigned start
, unsigned count
);
143 extern boolean
nv40_draw_elements(struct pipe_context
*pipe
,
144 struct pipe_buffer
*indexBuffer
,
146 unsigned mode
, unsigned start
,
150 extern void nv40_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
151 unsigned clearValue
);