radeong: Clean up domain usages.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 25 Jan 2010 19:01:16 +0000 (11:01 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 25 Jan 2010 19:30:39 +0000 (11:30 -0800)
Split from Marek's immd-mode patch.

src/gallium/winsys/drm/radeon/core/radeon_buffer.c

index 25e1cdcdb6daf2271905e51c0b7f7e8012f358b7..421fda2b4505359bfbe9f3911d5c90e7edccb487 100644 (file)
@@ -51,6 +51,23 @@ static const char *radeon_get_name(struct pipe_winsys *ws)
     return "Radeon/GEM+KMS";
 }
 
+static uint32_t radeon_domain_from_usage(unsigned usage)
+{
+    uint32_t domain = 0;
+
+    if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+        domain |= RADEON_GEM_DOMAIN_VRAM;
+    }
+    if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+        domain |= RADEON_GEM_DOMAIN_GTT;
+    }
+    if (usage & PIPE_BUFFER_USAGE_INDEX) {
+        domain |= RADEON_GEM_DOMAIN_GTT;
+    }
+
+    return domain;
+}
+
 static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
                                                 unsigned alignment,
                                                 unsigned usage,
@@ -79,17 +96,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
         return &radeon_buffer->base;
     }
 
-    domain = 0;
-
-    if (usage & PIPE_BUFFER_USAGE_PIXEL) {
-        domain |= RADEON_GEM_DOMAIN_VRAM;
-    }
-    if (usage & PIPE_BUFFER_USAGE_VERTEX) {
-        domain |= RADEON_GEM_DOMAIN_GTT;
-    }
-    if (usage & PIPE_BUFFER_USAGE_INDEX) {
-        domain |= RADEON_GEM_DOMAIN_GTT;
-    }
+    domain = radeon_domain_from_usage(usage);
 
     radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size,
             alignment, domain, 0);