gallium: add PIPE_CAP_MAX_SHADER_PATCH_VARYINGS
[mesa.git] / src / gallium / drivers / nouveau / nouveau_context.h
index b3fe05b1019f1f8df85a98c42d135e6352ba4b32..c2ba0159afecd21c18d9a68ebd703e26bf025b54 100644 (file)
@@ -2,7 +2,7 @@
 #define __NOUVEAU_CONTEXT_H__
 
 #include "pipe/p_context.h"
-#include <libdrm/nouveau.h>
+#include <nouveau.h>
 
 #define NOUVEAU_MAX_SCRATCH_BUFS 4
 
@@ -14,7 +14,6 @@ struct nouveau_context {
    struct nouveau_pushbuf *pushbuf;
 
    boolean vbo_dirty;
-   boolean cb_dirty;
 
    void (*copy_data)(struct nouveau_context *,
                      struct nouveau_bo *dst, unsigned, unsigned,
@@ -28,6 +27,11 @@ struct nouveau_context {
                    unsigned base, unsigned size,
                    unsigned offset, unsigned words, const uint32_t *);
 
+   /* @return: @ref reduced by nr of references found in context */
+   int (*invalidate_resource_storage)(struct nouveau_context *,
+                                      struct pipe_resource *,
+                                      int ref);
+
    struct {
       uint8_t *map;
       unsigned id;
@@ -36,10 +40,17 @@ struct nouveau_context {
       unsigned end;
       struct nouveau_bo *bo[NOUVEAU_MAX_SCRATCH_BUFS];
       struct nouveau_bo *current;
-      struct nouveau_bo **runout;
-      unsigned nr_runout;
+      struct runout {
+         unsigned nr;
+         struct nouveau_bo *bo[0];
+      } *runout;
       unsigned bo_size;
    } scratch;
+
+   struct {
+      uint32_t buf_cache_count;
+      uint32_t buf_cache_frame;
+   } stats;
 };
 
 static INLINE struct nouveau_context *
@@ -62,7 +73,7 @@ static INLINE void
 nouveau_scratch_done(struct nouveau_context *nv)
 {
    nv->scratch.wrap = nv->scratch.id;
-   if (unlikely(nv->scratch.nr_runout))
+   if (unlikely(nv->scratch.runout))
       nouveau_scratch_runout_release(nv);
 }
 
@@ -84,4 +95,17 @@ nouveau_context_destroy(struct nouveau_context *ctx)
 
    FREE(ctx);
 }
+
+static INLINE  void
+nouveau_context_update_frame_stats(struct nouveau_context *nv)
+{
+   nv->stats.buf_cache_frame <<= 1;
+   if (nv->stats.buf_cache_count) {
+      nv->stats.buf_cache_count = 0;
+      nv->stats.buf_cache_frame |= 1;
+      if ((nv->stats.buf_cache_frame & 0xf) == 0xf)
+         nv->screen->hint_buf_keep_sysmem_copy = TRUE;
+   }
+}
+
 #endif