gallium: notify drivers about possible changes in user buffer contents
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_context.h
index 0ea18d74ee3538ef4e55d5a773df9e4e48db023b..a082ad4575c399949befe2518c2e471d6a20fa48 100644 (file)
@@ -54,6 +54,8 @@
 #define NVC0_NEW_CONSTBUF     (1 << 18)
 #define NVC0_NEW_TEXTURES     (1 << 19)
 #define NVC0_NEW_SAMPLERS     (1 << 20)
+#define NVC0_NEW_TFB          (1 << 21)
+#define NVC0_NEW_TFB_BUFFERS  (1 << 22)
 
 #define NVC0_BUFCTX_CONSTANT 0
 #define NVC0_BUFCTX_FRAME    1
@@ -71,7 +73,7 @@ struct nvc0_context {
    uint32_t dirty;
 
    struct {
-      uint32_t instance_bits;
+      uint32_t instance_elts; /* bitmask of per-instance elements */
       uint32_t instance_base;
       int32_t index_bias;
       boolean prim_restart;
@@ -100,7 +102,10 @@ struct nvc0_context {
    struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
    unsigned num_vtxbufs;
    struct pipe_index_buffer idxbuf;
-   uint32_t vbo_fifo;
+   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 */
+   unsigned vbo_min_index; /* from pipe_draw_info, for vertex upload */
+   unsigned vbo_max_index;
 
    struct pipe_sampler_view *textures[5][PIPE_MAX_SAMPLERS];
    unsigned num_textures[5];
@@ -120,6 +125,11 @@ struct nvc0_context {
    boolean vbo_dirty;
    boolean vbo_push_hint;
 
+   struct nvc0_transform_feedback_state *tfb;
+   struct pipe_resource *tfbbuf[4];
+   unsigned num_tfbbufs;
+   unsigned tfb_offset[4];
+
    struct draw_context *draw;
 };
 
@@ -130,7 +140,11 @@ nvc0_context(struct pipe_context *pipe)
 }
 
 struct nvc0_surface {
-   struct pipe_surface pipe;
+   struct pipe_surface base;
+   uint32_t offset;
+   uint32_t width;
+   uint16_t height;
+   uint16_t depth;
 };
 
 static INLINE struct nvc0_surface *
@@ -139,31 +153,19 @@ nvc0_surface(struct pipe_surface *ps)
    return (struct nvc0_surface *)ps;
 }
 
-static INLINE void
-nvc0_make_bo_resident(struct nvc0_context *nvc0, struct nouveau_bo *bo,
-                      unsigned flags)
-{
-   nouveau_reloc_emit(nvc0->screen->base.channel,
-                      NULL, 0, NULL, bo, 0, 0, flags, 0, 0);
-}
-
-static INLINE void
-nvc0_make_buffer_resident(struct nvc0_context *nvc0,
-                          struct nvc0_resource *res, unsigned flags)
-{
-   nvc0_resource_validate(res, flags);
-   nvc0_make_bo_resident(nvc0, res->bo, flags);
-}
-
 /* nvc0_context.c */
 struct pipe_context *nvc0_create(struct pipe_screen *, void *);
 
 void nvc0_bufctx_emit_relocs(struct nvc0_context *);
-void nvc0_bufctx_reset(struct nvc0_context *, int ctx);
 void nvc0_bufctx_add_resident(struct nvc0_context *, int ctx,
                               struct nvc0_resource *, uint32_t flags);
 void nvc0_bufctx_del_resident(struct nvc0_context *, int ctx,
                               struct nvc0_resource *);
+static INLINE void
+nvc0_bufctx_reset(struct nvc0_context *nvc0, int ctx)
+{
+   util_dynarray_resize(&nvc0->residents[ctx], 0);
+}
 
 /* nvc0_draw.c */
 extern struct draw_stage *nvc0_draw_render_stage(struct nvc0_context *);
@@ -172,6 +174,9 @@ extern struct draw_stage *nvc0_draw_render_stage(struct nvc0_context *);
 boolean nvc0_program_translate(struct nvc0_program *);
 void nvc0_program_destroy(struct nvc0_context *, struct nvc0_program *);
 
+/* nvc0_query.c */
+void nvc0_init_query_functions(struct nvc0_context *);
+
 /* nvc0_shader_state.c */
 void nvc0_vertprog_validate(struct nvc0_context *);
 void nvc0_tctlprog_validate(struct nvc0_context *);
@@ -179,6 +184,8 @@ void nvc0_tevlprog_validate(struct nvc0_context *);
 void nvc0_gmtyprog_validate(struct nvc0_context *);
 void nvc0_fragprog_validate(struct nvc0_context *);
 
+void nvc0_tfb_validate(struct nvc0_context *);
+
 /* nvc0_state.c */
 extern void nvc0_init_state_functions(struct nvc0_context *);