diff options
author | Marek Olšák <[email protected]> | 2010-06-02 05:50:58 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2010-06-02 06:01:22 +0200 |
commit | 37f3454eb3afa1297126a8d77a563d734c292a37 (patch) | |
tree | ecef6b95adaf132fef15fd23caa7daed86a018f7 /src/gallium/winsys/radeon/drm | |
parent | ae3063066cb209efd07413f125bb86108906b033 (diff) |
r300g: let the driver determine the GEM domain for buffer_create
Diffstat (limited to 'src/gallium/winsys/radeon/drm')
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_buffer.h | 2 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_buffer.c | 31 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_r300.c | 9 |
3 files changed, 16 insertions, 26 deletions
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; |