1 #ifndef __NV50_CONTEXT_H__
2 #define __NV50_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"
12 #include "nouveau/nouveau_stateobj.h"
14 #define NOUVEAU_PUSH_CONTEXT(ctx) \
15 struct nv50_screen *ctx = nv50->screen
16 #include "nouveau/nouveau_push.h"
18 #include "nv50_screen.h"
19 #include "nv50_program.h"
21 #define NOUVEAU_ERR(fmt, args...) \
22 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
23 #define NOUVEAU_MSG(fmt, args...) \
24 fprintf(stderr, "nouveau: "fmt, ##args);
26 /* Constant buffer assignment */
27 #define NV50_CB_PMISC 0
33 #define NV50_CB_PUPLOAD 6
35 #define NV50_NEW_BLEND (1 << 0)
36 #define NV50_NEW_ZSA (1 << 1)
37 #define NV50_NEW_BLEND_COLOUR (1 << 2)
38 #define NV50_NEW_STIPPLE (1 << 3)
39 #define NV50_NEW_SCISSOR (1 << 4)
40 #define NV50_NEW_VIEWPORT (1 << 5)
41 #define NV50_NEW_RASTERIZER (1 << 6)
42 #define NV50_NEW_FRAMEBUFFER (1 << 7)
43 #define NV50_NEW_VERTPROG (1 << 8)
44 #define NV50_NEW_VERTPROG_CB (1 << 9)
45 #define NV50_NEW_FRAGPROG (1 << 10)
46 #define NV50_NEW_FRAGPROG_CB (1 << 11)
47 #define NV50_NEW_ARRAYS (1 << 12)
48 #define NV50_NEW_SAMPLER (1 << 13)
49 #define NV50_NEW_TEXTURE (1 << 14)
51 struct nv50_blend_stateobj
{
52 struct pipe_blend_state pipe
;
53 struct nouveau_stateobj
*so
;
56 struct nv50_zsa_stateobj
{
57 struct pipe_depth_stencil_alpha_state pipe
;
58 struct nouveau_stateobj
*so
;
61 struct nv50_rasterizer_stateobj
{
62 struct pipe_rasterizer_state pipe
;
63 struct nouveau_stateobj
*so
;
67 struct pipe_texture base
;
68 struct pipe_buffer
*buffer
;
71 static INLINE
struct nv50_miptree
*
72 nv50_miptree(struct pipe_texture
*pt
)
74 return (struct nv50_miptree
*)pt
;
78 struct pipe_surface base
;
79 struct pipe_buffer
*untiled
;
82 static INLINE
struct nv50_surface
*
83 nv50_surface(struct pipe_surface
*pt
)
85 return (struct nv50_surface
*)pt
;
91 struct nouveau_stateobj
*fb
;
92 struct nouveau_stateobj
*blend
;
93 struct nouveau_stateobj
*blend_colour
;
94 struct nouveau_stateobj
*zsa
;
95 struct nouveau_stateobj
*rast
;
96 struct nouveau_stateobj
*stipple
;
97 struct nouveau_stateobj
*scissor
;
98 unsigned scissor_enabled
;
99 struct nouveau_stateobj
*viewport
;
100 unsigned viewport_bypass
;
101 struct nouveau_stateobj
*tsc_upload
;
102 struct nouveau_stateobj
*tic_upload
;
103 struct nouveau_stateobj
*vertprog
;
104 struct nouveau_stateobj
*fragprog
;
105 struct nouveau_stateobj
*vtxfmt
;
106 struct nouveau_stateobj
*vtxbuf
;
109 struct nv50_context
{
110 struct pipe_context pipe
;
112 struct nv50_screen
*screen
;
115 struct draw_context
*draw
;
117 struct nv50_state state
;
120 struct nv50_blend_stateobj
*blend
;
121 struct nv50_zsa_stateobj
*zsa
;
122 struct nv50_rasterizer_stateobj
*rasterizer
;
123 struct pipe_blend_color blend_colour
;
124 struct pipe_poly_stipple stipple
;
125 struct pipe_scissor_state scissor
;
126 struct pipe_viewport_state viewport
;
127 struct pipe_framebuffer_state framebuffer
;
128 struct nv50_program
*vertprog
;
129 struct nv50_program
*fragprog
;
130 struct pipe_buffer
*constbuf
[PIPE_SHADER_TYPES
];
131 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
133 struct pipe_vertex_element vtxelt
[PIPE_MAX_ATTRIBS
];
135 unsigned *sampler
[PIPE_MAX_SAMPLERS
];
137 struct nv50_miptree
*miptree
[PIPE_MAX_SAMPLERS
];
141 static INLINE
struct nv50_context
*
142 nv50_context(struct pipe_context
*pipe
)
144 return (struct nv50_context
*)pipe
;
147 extern void nv50_init_surface_functions(struct nv50_context
*nv50
);
148 extern void nv50_init_state_functions(struct nv50_context
*nv50
);
149 extern void nv50_init_query_functions(struct nv50_context
*nv50
);
151 extern void nv50_screen_init_miptree_functions(struct pipe_screen
*pscreen
);
154 extern struct draw_stage
*nv50_draw_render_stage(struct nv50_context
*nv50
);
157 extern boolean
nv50_draw_arrays(struct pipe_context
*, unsigned mode
,
158 unsigned start
, unsigned count
);
159 extern boolean
nv50_draw_elements(struct pipe_context
*pipe
,
160 struct pipe_buffer
*indexBuffer
,
162 unsigned mode
, unsigned start
,
164 extern void nv50_vbo_validate(struct nv50_context
*nv50
);
167 extern void nv50_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
168 unsigned clearValue
);
171 extern void nv50_vertprog_validate(struct nv50_context
*nv50
);
172 extern void nv50_fragprog_validate(struct nv50_context
*nv50
);
173 extern void nv50_program_destroy(struct nv50_context
*nv50
, struct nv50_program
*p
);
175 /* nv50_state_validate.c */
176 extern boolean
nv50_state_validate(struct nv50_context
*nv50
);
179 extern void nv50_tex_validate(struct nv50_context
*);