winsys/radeon: consolidate the add_reloc function
authorMarek Olšák <maraeo@gmail.com>
Thu, 4 Aug 2011 00:36:57 +0000 (02:36 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 16 Aug 2011 07:15:10 +0000 (09:15 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/radeon/drm/radeon_drm_cs.c
src/gallium/winsys/radeon/drm/radeon_winsys.h

index 83e964b7f69727e4bc254e9921350a77422b9b9a..54b66cc9e356bde9cadc62650da3ff670bb257de 100644 (file)
@@ -135,7 +135,7 @@ static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r6
        assert(bo != NULL);
 
        reloc_index =
-               ctx->radeon->ws->trans_add_reloc(ctx->cs, bo->cs_buf, rbo->domains, rbo->domains);
+               ctx->radeon->ws->cs_add_reloc(ctx->cs, bo->cs_buf, rbo->domains, rbo->domains);
 
        if (reloc_index >= ctx->creloc)
                ctx->creloc = reloc_index+1;
index 09befb39b114ac2645439df0eda16bd724b9a34e..6da0ae6774364ec4aae43ea3501d6405b04929a8 100644 (file)
@@ -285,24 +285,23 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc,
     return csc->crelocs++;
 }
 
-static void radeon_drm_cs_add_reloc(struct radeon_winsys_cs *rcs,
-                                    struct radeon_winsys_cs_handle *buf,
-                                    enum radeon_bo_domain rd,
-                                    enum radeon_bo_domain wd)
+static unsigned radeon_drm_cs_add_reloc(struct radeon_winsys_cs *rcs,
+                                        struct radeon_winsys_cs_handle *buf,
+                                        enum radeon_bo_domain rd,
+                                        enum radeon_bo_domain wd)
 {
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
     struct radeon_bo *bo = (struct radeon_bo*)buf;
     enum radeon_bo_domain added_domains;
 
-    radeon_add_reloc(cs->csc, bo, rd, wd, &added_domains);
-
-    if (!added_domains)
-        return;
+    unsigned index = radeon_add_reloc(cs->csc, bo, rd, wd, &added_domains);
 
     if (added_domains & RADEON_DOMAIN_GTT)
         cs->csc->used_gart += bo->size;
     if (added_domains & RADEON_DOMAIN_VRAM)
         cs->csc->used_vram += bo->size;
+
+    return index;
 }
 
 static boolean radeon_drm_cs_validate(struct radeon_winsys_cs *rcs)
@@ -470,25 +469,6 @@ static boolean radeon_bo_is_referenced(struct radeon_winsys_cs *rcs,
     return radeon_bo_is_referenced_by_cs(cs, bo);
 }
 
-static unsigned trans_add_reloc(struct radeon_winsys_cs *rcs,
-                               struct radeon_winsys_cs_handle *buf,
-                               enum radeon_bo_domain rd,
-                                enum radeon_bo_domain wd)
-{
-       struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
-        struct radeon_bo *bo = (struct radeon_bo*)buf;
-        enum radeon_bo_domain added_domains;
-
-        unsigned index = radeon_add_reloc(cs->csc, bo, rd, wd, &added_domains);
-
-        if (added_domains & RADEON_DOMAIN_GTT)
-            cs->csc->used_gart += bo->size;
-        if (added_domains & RADEON_DOMAIN_VRAM)
-            cs->csc->used_vram += bo->size;
-
-       return index;
-}
-
 void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws)
 {
     ws->base.cs_create = radeon_drm_cs_create;
@@ -499,6 +479,4 @@ void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws)
     ws->base.cs_flush = radeon_drm_cs_flush;
     ws->base.cs_set_flush = radeon_drm_cs_set_flush;
     ws->base.cs_is_buffer_referenced = radeon_bo_is_referenced;
-
-    ws->base.trans_add_reloc = trans_add_reloc;
 }
index 073b6aad79a450b9a5669a74008956b8e08ec9e0..6360d6a840138acdb967ca10a63c929bf87203e0 100644 (file)
@@ -259,11 +259,12 @@ struct radeon_winsys {
      * \param buf A winsys buffer to validate.
      * \param rd  A read domain containing a bitmask of the RADEON_DOMAIN_* flags.
      * \param wd  A write domain containing a bitmask of the RADEON_DOMAIN_* flags.
+     * \return Relocation index.
      */
-    void (*cs_add_reloc)(struct radeon_winsys_cs *cs,
-                         struct radeon_winsys_cs_handle *buf,
-                         enum radeon_bo_domain rd,
-                         enum radeon_bo_domain wd);
+    unsigned (*cs_add_reloc)(struct radeon_winsys_cs *cs,
+                             struct radeon_winsys_cs_handle *buf,
+                             enum radeon_bo_domain rd,
+                             enum radeon_bo_domain wd);
 
     /**
      * Return TRUE if there is enough memory in VRAM and GTT for the relocs
@@ -329,10 +330,6 @@ struct radeon_winsys {
 
     /* Transitional functions for r600g when moving to winsys/radeon */
     unsigned (*trans_get_buffer_handle)(struct pb_buffer *buf);
-    unsigned (*trans_add_reloc)(struct radeon_winsys_cs *cs,
-                               struct radeon_winsys_cs_handle *buf,
-                               enum radeon_bo_domain rd,
-                                enum radeon_bo_domain wd);
 };
 
 #endif