-#define NOUVEAU_ERR(fmt, args...) \
- fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args);
-#define NOUVEAU_MSG(fmt, args...) \
- fprintf(stderr, "nouveau: "fmt, ##args);
-
-#define nouveau_bo_tile_layout(nvbo) \
- ((nvbo)->tile_flags & NOUVEAU_BO_TILE_LAYOUT_MASK)
-
-/* Constant buffer assignment */
-#define NV50_CB_PMISC 0
-#define NV50_CB_PVP 1
-#define NV50_CB_PFP 2
-#define NV50_CB_PGP 3
-#define NV50_CB_AUX 4
-
-#define NV50_NEW_BLEND (1 << 0)
-#define NV50_NEW_ZSA (1 << 1)
-#define NV50_NEW_BLEND_COLOUR (1 << 2)
-#define NV50_NEW_STIPPLE (1 << 3)
-#define NV50_NEW_SCISSOR (1 << 4)
-#define NV50_NEW_VIEWPORT (1 << 5)
-#define NV50_NEW_RASTERIZER (1 << 6)
-#define NV50_NEW_FRAMEBUFFER (1 << 7)
-#define NV50_NEW_VERTPROG (1 << 8)
-#define NV50_NEW_VERTPROG_CB (1 << 9)
-#define NV50_NEW_FRAGPROG (1 << 10)
-#define NV50_NEW_FRAGPROG_CB (1 << 11)
-#define NV50_NEW_GEOMPROG (1 << 12)
-#define NV50_NEW_GEOMPROG_CB (1 << 13)
-#define NV50_NEW_ARRAYS (1 << 14)
-#define NV50_NEW_SAMPLER (1 << 15)
-#define NV50_NEW_TEXTURE (1 << 16)
-#define NV50_NEW_STENCIL_REF (1 << 17)
-#define NV50_NEW_CLIP (1 << 18)
-
-struct nv50_blend_stateobj {
- struct pipe_blend_state pipe;
- struct nouveau_stateobj *so;
-};
-
-struct nv50_zsa_stateobj {
- struct pipe_depth_stencil_alpha_state pipe;
- struct nouveau_stateobj *so;
-};
-
-struct nv50_rasterizer_stateobj {
- struct pipe_rasterizer_state pipe;
- struct nouveau_stateobj *so;
-};
-
-struct nv50_sampler_stateobj {
- boolean normalized;
- unsigned tsc[8];
-};
-
-struct nv50_sampler_view {
- struct pipe_sampler_view pipe;
- uint32_t tic[8];
-};
-
-struct nv50_vtxelt_stateobj {
- struct pipe_vertex_element pipe[16];
- unsigned num_elements;
- uint32_t hw[16];
+struct nv50_context {
+ struct nouveau_context base;
+
+ struct nv50_screen *screen;
+
+ struct nouveau_bufctx *bufctx_3d;
+ struct nouveau_bufctx *bufctx;
+
+ uint32_t dirty;
+
+ struct {
+ uint32_t instance_elts; /* bitmask of per-instance elements */
+ uint32_t instance_base;
+ uint32_t interpolant_ctrl;
+ uint32_t semantic_color;
+ uint32_t semantic_psize;
+ int32_t index_bias;
+ boolean uniform_buffer_bound[3];
+ boolean prim_restart;
+ boolean point_sprite;
+ boolean rt_serialize;
+ boolean flushed;
+ boolean rasterizer_discard;
+ uint8_t tls_required;
+ boolean new_tls_space;
+ uint8_t num_vtxbufs;
+ uint8_t num_vtxelts;
+ uint8_t num_textures[3];
+ uint8_t num_samplers[3];
+ uint8_t prim_size;
+ uint16_t scissor;
+ } state;
+
+ struct nv50_blend_stateobj *blend;
+ struct nv50_rasterizer_stateobj *rast;
+ struct nv50_zsa_stateobj *zsa;
+ struct nv50_vertex_stateobj *vertex;
+
+ struct nv50_program *vertprog;
+ struct nv50_program *gmtyprog;
+ struct nv50_program *fragprog;
+
+ struct nv50_constbuf constbuf[3][NV50_MAX_PIPE_CONSTBUFS];
+ uint16_t constbuf_dirty[3];
+ uint16_t constbuf_valid[3];
+
+ struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
+ unsigned num_vtxbufs;
+ struct pipe_index_buffer idxbuf;
+ uint32_t vbo_fifo; /* bitmask of vertex elements to be pushed to FIFO */
+ uint32_t vbo_user; /* bitmask of vertex buffers pointing to user memory */
+ uint32_t vbo_constant; /* bitmask of user buffers with stride 0 */
+ uint32_t vb_elt_first; /* from pipe_draw_info, for vertex upload */
+ uint32_t vb_elt_limit; /* max - min element (count - 1) */
+ uint32_t instance_off; /* base vertex for instanced arrays */
+ uint32_t instance_max; /* max instance for current draw call */
+
+ struct pipe_sampler_view *textures[3][PIPE_MAX_SAMPLERS];
+ unsigned num_textures[3];
+ struct nv50_tsc_entry *samplers[3][PIPE_MAX_SAMPLERS];
+ unsigned num_samplers[3];
+
+ uint8_t num_so_targets;
+ uint8_t so_targets_dirty;
+ struct pipe_stream_output_target *so_target[4];
+
+ struct pipe_framebuffer_state framebuffer;
+ struct pipe_blend_color blend_colour;
+ struct pipe_stencil_ref stencil_ref;
+ struct pipe_poly_stipple stipple;
+ struct pipe_scissor_state scissor;
+ struct pipe_viewport_state viewport;
+ struct pipe_clip_state clip;
+
+ unsigned sample_mask;
+
+ boolean vbo_push_hint;
+
+ struct pipe_query *cond_query;
+ uint cond_mode;
+
+ struct nv50_blitctx *blit;
+
+#ifdef NV50_WITH_DRAW_MODULE
+ struct draw_context *draw;
+#endif