R300_BUFFER_SQUARETILED
};
+enum r300_buffer_domain { /* bitfield */
+ R300_DOMAIN_GTT = 1,
+ R300_DOMAIN_VRAM = 2
+};
+
#endif
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;
}
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,
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.
#include "radeon_winsys.h"
+#define RADEON_USAGE_DOMAIN_GTT (1 << 29)
+#define RADEON_USAGE_DOMAIN_VRAM (1 << 30)
#define RADEON_MAX_BOS 24
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)
{
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)
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);
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;