summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-06-02 05:50:58 +0200
committerMarek Olšák <[email protected]>2010-06-02 06:01:22 +0200
commit37f3454eb3afa1297126a8d77a563d734c292a37 (patch)
treeecef6b95adaf132fef15fd23caa7daed86a018f7 /src
parentae3063066cb209efd07413f125bb86108906b033 (diff)
r300g: let the driver determine the GEM domain for buffer_create
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/r300_defines.h5
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.c2
-rw-r--r--src/gallium/drivers/r300/r300_texture.c4
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h3
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_buffer.h2
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_buffer.c31
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_r300.c9
7 files changed, 26 insertions, 30 deletions
diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h
index 4b1c3707268..83c9ec7e399 100644
--- a/src/gallium/drivers/r300/r300_defines.h
+++ b/src/gallium/drivers/r300/r300_defines.h
@@ -45,4 +45,9 @@ enum r300_buffer_tiling {
R300_BUFFER_SQUARETILED
};
+enum r300_buffer_domain { /* bitfield */
+ R300_DOMAIN_GTT = 1,
+ R300_DOMAIN_VRAM = 2
+};
+
#endif
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 3e2b5afe6f4..de89f51f3eb 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -125,7 +125,7 @@ r300_winsys_buffer_create(struct r300_screen *r300screen,
struct r300_winsys_screen *rws = r300screen->rws;
struct r300_winsys_buffer *buf;
- buf = rws->buffer_create(rws, alignment, usage, size);
+ buf = rws->buffer_create(rws, alignment, usage, R300_DOMAIN_GTT, size);
return buf;
}
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index a4b5d34ce1f..8572334f912 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -959,9 +959,9 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen,
base->width0, base->height0, base->depth0, base->last_level,
util_format_short_name(base->format));
- tex->buffer = rws->buffer_create(rws, 2048,
- base->bind,
+ tex->buffer = rws->buffer_create(rws, 2048, base->bind, R300_DOMAIN_VRAM,
tex->size);
+
rws->buffer_set_tiling(rws, tex->buffer,
tex->pitch[0] * util_format_get_blocksize(tex->b.b.format),
tex->microtile,
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index f7cbbde410a..d59a45a00a9 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -74,8 +74,9 @@ struct r300_winsys_screen {
struct r300_winsys_buffer *(*buffer_create)(struct r300_winsys_screen *ws,
unsigned alignment,
unsigned usage,
+ enum r300_buffer_domain domain,
unsigned size);
-
+
/**
* Map the entire data store of a buffer object into the client's address.
* flags is bitmask of R300_WINSYS_BUFFER_USAGE_CPU_READ/WRITE flags.
diff --git a/src/gallium/winsys/radeon/drm/radeon_buffer.h b/src/gallium/winsys/radeon/drm/radeon_buffer.h
index b9ecf9ded07..da13e4d36a4 100644
--- a/src/gallium/winsys/radeon/drm/radeon_buffer.h
+++ b/src/gallium/winsys/radeon/drm/radeon_buffer.h
@@ -43,6 +43,8 @@
#include "radeon_winsys.h"
+#define RADEON_USAGE_DOMAIN_GTT (1 << 29)
+#define RADEON_USAGE_DOMAIN_VRAM (1 << 30)
#define RADEON_MAX_BOS 24
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
index a05205da886..efe82026b43 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
@@ -145,31 +145,6 @@ const struct pb_vtbl radeon_drm_buffer_vtbl = {
radeon_drm_buffer_get_base_buffer,
};
-
-static uint32_t radeon_domain_from_usage(unsigned usage)
-{
- uint32_t domain = 0;
-
- if (usage & PIPE_BIND_RENDER_TARGET) {
- domain |= RADEON_GEM_DOMAIN_VRAM;
- }
- if (usage & PIPE_BIND_DEPTH_STENCIL) {
- domain |= RADEON_GEM_DOMAIN_VRAM;
- }
- if (usage & PIPE_BIND_SAMPLER_VIEW) {
- domain |= RADEON_GEM_DOMAIN_VRAM;
- }
- /* also need BIND_BLIT_SOURCE/DESTINATION ? */
- if (usage & PIPE_BIND_VERTEX_BUFFER) {
- domain |= RADEON_GEM_DOMAIN_GTT;
- }
- if (usage & PIPE_BIND_INDEX_BUFFER) {
- domain |= RADEON_GEM_DOMAIN_GTT;
- }
-
- return domain;
-}
-
struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
uint32_t handle)
{
@@ -225,7 +200,11 @@ radeon_drm_bufmgr_create_buffer(struct pb_manager *_mgr,
buf->mgr = mgr;
make_empty_list(buf);
- domain = radeon_domain_from_usage(desc->usage);
+
+ domain =
+ (desc->usage & RADEON_USAGE_DOMAIN_GTT ? RADEON_GEM_DOMAIN_GTT : 0) |
+ (desc->usage & RADEON_USAGE_DOMAIN_VRAM ? RADEON_GEM_DOMAIN_VRAM : 0);
+
buf->bo = radeon_bo_open(rws->bom, 0, size,
desc->alignment, domain, 0);
if (buf->bo == NULL)
diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c
index ecee1ee73db..4cf21ff72bf 100644
--- a/src/gallium/winsys/radeon/drm/radeon_r300.c
+++ b/src/gallium/winsys/radeon/drm/radeon_r300.c
@@ -31,6 +31,7 @@ static struct r300_winsys_buffer *
radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
unsigned alignment,
unsigned usage,
+ enum r300_buffer_domain domain,
unsigned size)
{
struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
@@ -38,6 +39,14 @@ radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
struct pb_manager *provider;
struct pb_buffer *buffer;
+ /* XXX this is hackish, but it's the only way to pass these flags
+ * to the real create function. */
+ usage &= ~(RADEON_USAGE_DOMAIN_GTT | RADEON_USAGE_DOMAIN_VRAM);
+ if (domain & R300_DOMAIN_GTT)
+ usage |= RADEON_USAGE_DOMAIN_GTT;
+ if (domain & R300_DOMAIN_VRAM)
+ usage |= RADEON_USAGE_DOMAIN_VRAM;
+
memset(&desc, 0, sizeof(desc));
desc.alignment = alignment;
desc.usage = usage;