Merge branch 'gallium-polygon-stipple'
[mesa.git] / src / gallium / drivers / nvc0 / nvc0_context.h
index 0f340beb35ada26f42e8118825cef89e7d6e9348..bf891649a57106882d28243162b6b443eeb498cc 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __NVC0_CONTEXT_H__
 #define __NVC0_CONTEXT_H__
 
-#include <stdio.h>
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
 
 #include "draw/draw_vertex.h"
 
+#include "nv50/nv50_debug.h"
 #include "nvc0_winsys.h"
 #include "nvc0_stateobj.h"
 #include "nvc0_screen.h"
 #include "nvc0_program.h"
 #include "nvc0_resource.h"
 
+#include "nv50/nv50_transfer.h"
+
+#include "nouveau/nouveau_context.h"
+
 #include "nvc0_3ddefs.xml.h"
 #include "nvc0_3d.xml.h"
 #include "nvc0_2d.xml.h"
 #include "nvc0_m2mf.xml.h"
 
-#define NOUVEAU_ERR(fmt, args...) \
-   fprintf(stderr, "%s:%d -  "fmt, __FUNCTION__, __LINE__, ##args);
-
-#ifdef NOUVEAU_DEBUG
-# define NOUVEAU_DBG(args...) printf(args);
-#else
-# define NOUVEAU_DBG(args...)
-#endif
-
 #define NVC0_NEW_BLEND        (1 << 0)
 #define NVC0_NEW_RASTERIZER   (1 << 1)
 #define NVC0_NEW_ZSA          (1 << 2)
@@ -54,6 +49,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
 #define NVC0_BUFCTX_COUNT    4
 
 struct nvc0_context {
-   struct pipe_context pipe;
+   struct nouveau_context base;
 
    struct nvc0_screen *screen;
 
    struct util_dynarray residents[NVC0_BUFCTX_COUNT];
+   unsigned residents_size;
 
    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;
+      boolean early_z;
       uint8_t num_vtxbufs;
       uint8_t num_vtxelts;
       uint8_t num_textures[5];
       uint8_t num_samplers[5];
+      uint8_t tls_required; /* bitmask of shader types using l[] */
       uint16_t scissor;
       uint32_t uniform_buffer_bound[5];
    } state;
@@ -100,13 +100,14 @@ 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];
-   struct nvc0_tsc_entry *samplers[5][PIPE_MAX_SAMPLERS];
+   struct nv50_tsc_entry *samplers[5][PIPE_MAX_SAMPLERS];
    unsigned num_samplers[5];
 
    struct pipe_framebuffer_state framebuffer;
@@ -119,43 +120,39 @@ struct nvc0_context {
 
    unsigned sample_mask;
 
-   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;
 };
 
+#define NVC0_USING_EDGEFLAG(ctx) \
+   ((ctx)->vertprog->vp.edgeflag < PIPE_MAX_ATTRIBS)
+
 static INLINE struct nvc0_context *
 nvc0_context(struct pipe_context *pipe)
 {
    return (struct nvc0_context *)pipe;
 }
 
-struct nvc0_surface {
-   struct pipe_surface base;
-   uint32_t offset;
-   uint32_t width;
-   uint16_t height;
-   uint16_t depth;
-};
-
-static INLINE struct nvc0_surface *
-nvc0_surface(struct pipe_surface *ps)
-{
-   return (struct nvc0_surface *)ps;
-}
-
 /* nvc0_context.c */
 struct pipe_context *nvc0_create(struct pipe_screen *, void *);
 
+void nvc0_default_flush_notify(struct nouveau_channel *);
+
 void nvc0_bufctx_emit_relocs(struct nvc0_context *);
 void nvc0_bufctx_add_resident(struct nvc0_context *, int ctx,
-                              struct nvc0_resource *, uint32_t flags);
+                              struct nv04_resource *, uint32_t flags);
 void nvc0_bufctx_del_resident(struct nvc0_context *, int ctx,
-                              struct nvc0_resource *);
+                              struct nv04_resource *);
 static INLINE void
 nvc0_bufctx_reset(struct nvc0_context *nvc0, int ctx)
 {
+   nvc0->residents_size -= nvc0->residents[ctx].size;
    util_dynarray_resize(&nvc0->residents[ctx], 0);
 }
 
@@ -176,6 +173,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 *);
 
@@ -198,11 +197,16 @@ nvc0_create_sampler_view(struct pipe_context *,
 
 /* nvc0_transfer.c */
 void
-nvc0_m2mf_push_linear(struct nvc0_context *nvc0,
-                     struct nouveau_bo *dst, unsigned domain, int offset,
+nvc0_m2mf_transfer_rect(struct pipe_screen *pscreen,
+                        const struct nv50_m2mf_rect *dst,
+                        const struct nv50_m2mf_rect *src,
+                        uint32_t nblocksx, uint32_t nblocksy);
+void
+nvc0_m2mf_push_linear(struct nouveau_context *nv,
+                     struct nouveau_bo *dst, unsigned offset, unsigned domain,
                      unsigned size, void *data);
 void
-nvc0_m2mf_copy_linear(struct nvc0_context *nvc0,
+nvc0_m2mf_copy_linear(struct nouveau_context *nv,
                      struct nouveau_bo *dst, unsigned dstoff, unsigned dstdom,
                      struct nouveau_bo *src, unsigned srcoff, unsigned srcdom,
                      unsigned size);