r600g: move more DRM queries into winsys/radeon
[mesa.git] / src / gallium / winsys / r600 / drm / r600_priv.h
index c310defe2b1e26db84409f74727855e8e07df167..036468e3a31f14fcf1e7a6b1e2162adf999b4fc0 100644 (file)
 #include "../../radeon/drm/radeon_winsys.h"
 #include "util/u_hash_table.h"
 #include "os/os_thread.h"
+#include "radeon_drm.h"
 
 #define PKT_COUNT_C                     0xC000FFFF
 #define PKT_COUNT_S(x)                  (((x) & 0x3FFF) << 16)
 
-struct r600_bomgr;
-struct r600_bo;
-
 struct radeon {
        struct radeon_winsys            *ws;
        struct radeon_info              info;
        unsigned                        family;
        enum chip_class                 chip_class;
        struct r600_tiling_info         tiling_info;
-       struct r600_bomgr               *bomgr;
-       unsigned                        fence;
-       unsigned                        *cfence;
-       struct r600_bo                  *fence_bo;
-       unsigned                        num_tile_pipes;
-       unsigned                        backend_map;
-       boolean                         backend_map_valid;
-
-        /* List of buffer handles and its mutex. */
-       struct util_hash_table          *bo_handles;
-       pipe_mutex bo_handles_mutex;
 };
 
 /* these flags are used in register flags and added into block flags */
@@ -75,52 +62,24 @@ struct r600_reg {
 #define BO_BOUND_TEXTURE 1
 struct radeon_bo {
        struct pipe_reference           reference;
+       struct pb_buffer                *buf;
+       struct radeon_winsys_cs_handle  *cs_buf;
        unsigned                        handle;
        unsigned                        size;
-       unsigned                        alignment;
        int                             map_count;
        void                            *data;
-       struct list_head                fencedlist;
-       unsigned                        fence;
-       struct r600_context             *ctx;
-       boolean                         shared;
-       struct r600_reloc               *reloc;
-       unsigned                        reloc_id;
+
        unsigned                        last_flush;
-       unsigned                        name;
        unsigned                        binding;
 };
 
 struct r600_bo {
        struct pipe_reference           reference; /* this must be the first member for the r600_bo_reference inline to work */
        /* DO NOT MOVE THIS ^ */
-       unsigned                        size;
        unsigned                        domains;
        struct radeon_bo                *bo;
-       unsigned                        fence;
-       /* manager data */
-       struct list_head                list;
-       unsigned                        manager_id;
-       unsigned                        alignment;
-       unsigned                        offset;
-       int64_t                         start;
-       int64_t                         end;
 };
 
-struct r600_bomgr {
-       struct radeon                   *radeon;
-       unsigned                        usecs;
-       pipe_mutex                      mutex;
-       struct list_head                delayed;
-       unsigned                        num_delayed;
-};
-
-/*
- * r600_drm.c
- */
-struct radeon *r600_new(int fd, unsigned device);
-void r600_delete(struct radeon *r600);
-
 /*
  * radeon_pciid.c
  */
@@ -130,7 +89,7 @@ unsigned radeon_family_from_device(unsigned device);
  * radeon_bo.c
  */
 struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
-                           unsigned size, unsigned alignment, unsigned initial_domain);
+                           unsigned size, unsigned alignment, unsigned bind, unsigned initial_domain);
 void radeon_bo_reference(struct radeon *radeon, struct radeon_bo **dst,
                         struct radeon_bo *src);
 int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);
@@ -148,7 +107,6 @@ int radeon_bo_fixed_map(struct radeon *radeon, struct radeon_bo *bo);
  * r600_hw_context.c
  */
 int r600_context_init_fence(struct r600_context *ctx);
-void r600_context_get_reloc(struct r600_context *ctx, struct r600_bo *rbo);
 void r600_context_bo_flush(struct r600_context *ctx, unsigned flush_flags,
                                unsigned flush_mask, struct r600_bo *rbo);
 struct r600_bo *r600_context_reg_bo(struct r600_context *ctx, unsigned offset);
@@ -166,17 +124,21 @@ void r600_context_reg(struct r600_context *ctx,
 void r600_init_cs(struct r600_context *ctx);
 int r600_resource_init(struct r600_context *ctx, struct r600_range *range, unsigned offset, unsigned nblocks, unsigned stride, struct r600_reg *reg, int nreg, unsigned offset_base);
 
-static INLINE void r600_context_bo_reloc(struct r600_context *ctx, u32 *pm4, struct r600_bo *rbo)
+static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r600_bo *rbo)
 {
        struct radeon_bo *bo = rbo->bo;
+       unsigned reloc_index;
 
        assert(bo != NULL);
 
-       if (!bo->reloc)
-               r600_context_get_reloc(ctx, rbo);
+       reloc_index =
+               ctx->radeon->ws->cs_add_reloc(ctx->cs, bo->cs_buf, rbo->domains, rbo->domains);
 
-       /* set PKT3 to point to proper reloc */
-       *pm4 = bo->reloc_id;
+       if (reloc_index >= ctx->creloc)
+               ctx->creloc = reloc_index+1;
+
+       radeon_bo_reference(ctx->radeon, &ctx->bo[reloc_index], bo);
+       return reloc_index * 4;
 }
 
 /*
@@ -184,23 +146,6 @@ static INLINE void r600_context_bo_reloc(struct r600_context *ctx, u32 *pm4, str
  */
 void r600_bo_destroy(struct radeon *radeon, struct r600_bo *bo);
 
-/*
- * r600_bomgr.c
- */
-struct r600_bomgr *r600_bomgr_create(struct radeon *radeon, unsigned usecs);
-void r600_bomgr_destroy(struct r600_bomgr *mgr);
-boolean r600_bomgr_bo_destroy(struct r600_bomgr *mgr, struct r600_bo *bo);
-void r600_bomgr_bo_init(struct r600_bomgr *mgr, struct r600_bo *bo);
-struct r600_bo *r600_bomgr_bo_create(struct r600_bomgr *mgr,
-                                       unsigned size,
-                                       unsigned alignment,
-                                       unsigned cfence);
-
-
-/*
- * helpers
- */
-
 
 /*
  * radeon_bo.c