r600g: bump domain selection up one layer.
authorDave Airlie <airlied@redhat.com>
Fri, 13 May 2011 04:16:31 +0000 (14:16 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 18 May 2011 07:31:51 +0000 (17:31 +1000)
this is taken from a patch from Mathias Froehlich, just going to
stage it in a few pieces.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/winsys/r600/drm/r600_bo.c
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/r600/drm/radeon_bo.c

index e9c650d..2bfb8e4 100644 (file)
@@ -38,7 +38,8 @@ struct r600_bo *r600_bo(struct radeon *radeon,
 {
        struct r600_bo *bo;
        struct radeon_bo *rbo;
-
+       uint32_t initial_domain;
+         
        if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)) {
                bo = r600_bomgr_bo_create(radeon->bomgr, size, alignment, *radeon->cfence);
                if (bo) {
@@ -46,7 +47,24 @@ struct r600_bo *r600_bo(struct radeon *radeon,
                }
        }
 
-       rbo = radeon_bo(radeon, 0, size, alignment);
+       if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)) {
+               initial_domain = RADEON_GEM_DOMAIN_GTT;
+       } else {
+               switch(usage) {
+               case PIPE_USAGE_DYNAMIC:
+               case PIPE_USAGE_STREAM:
+               case PIPE_USAGE_STAGING:
+                       initial_domain = RADEON_GEM_DOMAIN_GTT;
+                       break;
+               case PIPE_USAGE_DEFAULT:
+               case PIPE_USAGE_STATIC:
+               case PIPE_USAGE_IMMUTABLE:
+               default:
+                       initial_domain = RADEON_GEM_DOMAIN_VRAM;
+                       break;
+               }
+       }
+       rbo = radeon_bo(radeon, 0, size, alignment, initial_domain);
        if (rbo == NULL) {
                return NULL;
        }
@@ -80,7 +98,7 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon,
        struct r600_bo *bo = calloc(1, sizeof(struct r600_bo));
        struct radeon_bo *rbo;
 
-       rbo = bo->bo = radeon_bo(radeon, handle, 0, 0);
+       rbo = bo->bo = radeon_bo(radeon, handle, 0, 0, 0);
        if (rbo == NULL) {
                free(bo);
                return NULL;
index 4f7e60c..78b8190 100644 (file)
@@ -132,7 +132,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 size, unsigned alignment, 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);
index cd817fc..45cf6f0 100644 (file)
@@ -71,7 +71,7 @@ static void radeon_bo_fixed_unmap(struct radeon *radeon, struct radeon_bo *bo)
 }
 
 struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
-                       unsigned size, unsigned alignment)
+                           unsigned size, unsigned alignment, unsigned initial_domain)
 {
        struct radeon_bo *bo;
        int r;
@@ -115,7 +115,7 @@ struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
 
                args.size = size;
                args.alignment = alignment;
-               args.initial_domain = RADEON_GEM_DOMAIN_CPU;
+               args.initial_domain = initial_domain;
                args.flags = 0;
                args.handle = 0;
                r = drmCommandWriteRead(radeon->fd, DRM_RADEON_GEM_CREATE,