util: use C99 declaration in the for-loop hash_table_foreach() macro
[mesa.git] / src / mesa / drivers / dri / i965 / brw_bufmgr.h
index a3745d6667ab8a68bd3595ef6ce3f2e8c99b75fc..32fc7a553c95277e236cdddebd8d17548644344b 100644 (file)
@@ -37,6 +37,8 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <time.h>
+
 #include "util/u_atomic.h"
 #include "util/list.h"
 
@@ -47,6 +49,42 @@ extern "C" {
 struct gen_device_info;
 struct brw_context;
 
+/**
+ * Memory zones.  When allocating a buffer, you can request that it is
+ * placed into a specific region of the virtual address space (PPGTT).
+ *
+ * Most buffers can go anywhere (BRW_MEMZONE_OTHER).  Some buffers are
+ * accessed via an offset from a base address.  STATE_BASE_ADDRESS has
+ * a maximum 4GB size for each region, so we need to restrict those
+ * buffers to be within 4GB of the base.  Each memory zone corresponds
+ * to a particular base address.
+ *
+ * Currently, i965 partitions the address space into two regions:
+ *
+ * - Low 4GB
+ * - Full 48-bit address space
+ *
+ * Eventually, we hope to carve out 4GB of VMA for each base address.
+ */
+enum brw_memory_zone {
+   BRW_MEMZONE_LOW_4G,
+   BRW_MEMZONE_OTHER,
+
+   /* Shaders - Instruction State Base Address */
+   BRW_MEMZONE_SHADER  = BRW_MEMZONE_LOW_4G,
+
+   /* Scratch - General State Base Address */
+   BRW_MEMZONE_SCRATCH = BRW_MEMZONE_LOW_4G,
+
+   /* Surface State Base Address */
+   BRW_MEMZONE_SURFACE = BRW_MEMZONE_LOW_4G,
+
+   /* Dynamic State Base Address */
+   BRW_MEMZONE_DYNAMIC = BRW_MEMZONE_LOW_4G,
+};
+
+#define BRW_MEMZONE_COUNT (BRW_MEMZONE_OTHER + 1)
+
 struct brw_bo {
    /**
     * Size in bytes of the buffer object.
@@ -56,13 +94,6 @@ struct brw_bo {
     */
    uint64_t size;
 
-   /**
-    * Alignment requirement for object
-    *
-    * Used for GTT mapping & pinning the object.
-    */
-   uint64_t align;
-
    /** Buffer manager context associated with this buffer object */
    struct brw_bufmgr *bufmgr;
 
@@ -120,9 +151,6 @@ struct brw_bo {
    int refcount;
    const char *name;
 
-#ifndef EXEC_OBJECT_CAPTURE
-#define EXEC_OBJECT_CAPTURE            (1<<7)
-#endif
    uint64_t kflags;
 
    /**
@@ -178,7 +206,7 @@ struct brw_bo {
  * using brw_bo_map() to be used by the CPU.
  */
 struct brw_bo *brw_bo_alloc(struct brw_bufmgr *bufmgr, const char *name,
-                            uint64_t size, uint64_t alignment);
+                            uint64_t size, enum brw_memory_zone memzone);
 
 /**
  * Allocate a tiled buffer object.
@@ -194,6 +222,7 @@ struct brw_bo *brw_bo_alloc(struct brw_bufmgr *bufmgr, const char *name,
 struct brw_bo *brw_bo_alloc_tiled(struct brw_bufmgr *bufmgr,
                                   const char *name,
                                   uint64_t size,
+                                  enum brw_memory_zone memzone,
                                   uint32_t tiling_mode,
                                   uint32_t pitch,
                                   unsigned flags);
@@ -216,6 +245,7 @@ struct brw_bo *brw_bo_alloc_tiled(struct brw_bufmgr *bufmgr,
 struct brw_bo *brw_bo_alloc_tiled_2d(struct brw_bufmgr *bufmgr,
                                      const char *name,
                                      int x, int y, int cpp,
+                                     enum brw_memory_zone memzone,
                                      uint32_t tiling_mode,
                                      uint32_t *pitch,
                                      unsigned flags);
@@ -255,7 +285,7 @@ MUST_CHECK void *brw_bo_map(struct brw_context *brw, struct brw_bo *bo, unsigned
  * Reduces the refcount on the userspace mapping of the buffer
  * object.
  */
-static inline int brw_bo_unmap(struct brw_bo *bo) { return 0; }
+static inline int brw_bo_unmap(UNUSED struct brw_bo *bo) { return 0; }
 
 /** Write data into an object. */
 int brw_bo_subdata(struct brw_bo *bo, uint64_t offset,
@@ -323,10 +353,6 @@ int brw_bo_wait(struct brw_bo *bo, int64_t timeout_ns);
 
 uint32_t brw_create_hw_context(struct brw_bufmgr *bufmgr);
 
-#define BRW_CONTEXT_LOW_PRIORITY ((I915_CONTEXT_MIN_USER_PRIORITY-1)/2)
-#define BRW_CONTEXT_MEDIUM_PRIORITY (I915_CONTEXT_DEFAULT_PRIORITY)
-#define BRW_CONTEXT_HIGH_PRIORITY ((I915_CONTEXT_MAX_USER_PRIORITY+1)/2)
-
 int brw_hw_context_set_priority(struct brw_bufmgr *bufmgr,
                                 uint32_t ctx_id,
                                 int priority);
@@ -346,6 +372,8 @@ uint32_t brw_bo_export_gem_handle(struct brw_bo *bo);
 int brw_reg_read(struct brw_bufmgr *bufmgr, uint32_t offset,
                  uint64_t *result);
 
+bool brw_using_softpin(struct brw_bufmgr *bufmgr);
+
 /** @{ */
 
 #if defined(__cplusplus)