this paves the way for moving to pb bufmgrs now.
};
/* simple shader */
- bo = radeon_ws_bo(rscreen->rw, 128, 4096);
+ bo = radeon_ws_bo(rscreen->rw, 128, 4096, 0);
if (bo == NULL) {
return -ENOMEM;
}
- data = radeon_ws_bo_map(rscreen->rw, bo);
+ data = radeon_ws_bo_map(rscreen->rw, bo, 0, NULL);
if (!data) {
radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
return -ENOMEM;
};
/* simple shader */
- bo = radeon_ws_bo(rscreen->rw, 128, 4096);
+ bo = radeon_ws_bo(rscreen->rw, 128, 4096, 0);
if (bo == NULL) {
return;
}
- data = radeon_ws_bo_map(rscreen->rw, bo);
+ data = radeon_ws_bo_map(rscreen->rw, bo, 0, NULL);
if (!data) {
radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
return;
};
/* simple shader */
- bo = radeon_ws_bo(rscreen->rw, 128, 4096);
+ bo = radeon_ws_bo(rscreen->rw, 128, 4096, 0);
if (bo == NULL) {
return;
}
- data = radeon_ws_bo_map(rscreen->rw, bo);
+ data = radeon_ws_bo_map(rscreen->rw, bo, 0, NULL);
if (!data) {
radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
return;
struct r600_screen *rscreen = r600_screen(screen);
struct r600_resource *rbuffer;
struct radeon_ws_bo *bo;
- struct pb_desc desc;
/* XXX We probably want a different alignment for buffers and textures. */
unsigned alignment = 4096;
rbuffer->base.b.screen = screen;
rbuffer->base.vtbl = &r600_buffer_vtbl;
rbuffer->size = rbuffer->base.b.width0;
- if ((rscreen->use_mem_constant == FALSE) && (rbuffer->base.b.bind & PIPE_BIND_CONSTANT_BUFFER)) {
- desc.alignment = alignment;
- desc.usage = rbuffer->base.b.bind;
- rbuffer->pb = pb_malloc_buffer_create(rbuffer->base.b.width0,
- &desc);
- if (rbuffer->pb == NULL) {
- free(rbuffer);
- return NULL;
- }
- return &rbuffer->base.b;
- }
rbuffer->domain = r600_domain_from_usage(rbuffer->base.b.bind);
- bo = radeon_ws_bo(rscreen->rw, rbuffer->base.b.width0, alignment);
+ bo = radeon_ws_bo(rscreen->rw, rbuffer->base.b.width0, alignment, rbuffer->base.b.bind);
if (bo == NULL) {
FREE(rbuffer);
return NULL;
if (rbuffer == NULL) {
return NULL;
}
- data = radeon_ws_bo_map(rscreen->rw, rbuffer->bo);
+ data = radeon_ws_bo_map(rscreen->rw, rbuffer->bo, 0, NULL);
memcpy(data, ptr, bytes);
radeon_ws_bo_unmap(rscreen->rw, rbuffer->bo);
return &rbuffer->base.b;
struct r600_resource *rbuffer = (struct r600_resource*)buf;
struct r600_screen *rscreen = r600_screen(screen);
- if (rbuffer->pb) {
- pipe_reference_init(&rbuffer->pb->base.reference, 0);
- pb_destroy(rbuffer->pb);
- rbuffer->pb = NULL;
- }
if (rbuffer->bo) {
radeon_ws_bo_reference(rscreen->rw, &rbuffer->bo, NULL);
}
- memset(rbuffer, 0, sizeof(struct r600_resource));
FREE(rbuffer);
}
int write = 0;
uint8_t *data;
- if (rbuffer->pb) {
- return (uint8_t*)pb_map(rbuffer->pb, transfer->usage, NULL) + transfer->box.x;
- }
if (transfer->usage & PIPE_TRANSFER_DONTBLOCK) {
/* FIXME */
}
if (transfer->usage & PIPE_TRANSFER_WRITE) {
write = 1;
}
- data = radeon_ws_bo_map(rscreen->rw, rbuffer->bo);
+ data = radeon_ws_bo_map(rscreen->rw, rbuffer->bo, transfer->usage, r600_context(pipe));
if (!data)
return NULL;
struct r600_resource *rbuffer = (struct r600_resource*)transfer->resource;
struct r600_screen *rscreen = r600_screen(pipe->screen);
- if (rbuffer->pb) {
- pb_unmap(rbuffer->pb);
- } else {
- radeon_ws_bo_unmap(rscreen->rw, rbuffer->bo);
- }
+ radeon_ws_bo_unmap(rscreen->rw, rbuffer->bo);
}
static void r600_buffer_transfer_flush_region(struct pipe_context *pipe,
q->type = query_type;
q->buffer_size = 4096;
- q->buffer = radeon_ws_bo(rscreen->rw, q->buffer_size, 1);
+ q->buffer = radeon_ws_bo(rscreen->rw, q->buffer_size, 1, 0);
if (!q->buffer) {
FREE(q);
return NULL;
int i;
radeon_ws_bo_wait(rscreen->rw, rquery->buffer);
- results = radeon_ws_bo_map(rscreen->rw, rquery->buffer);
+ results = radeon_ws_bo_map(rscreen->rw, rquery->buffer, 0, r600_context(ctx));
for (i = 0; i < rquery->num_results; i += 4) {
start = (u64)results[i] | (u64)results[i + 1] << 32;
end = (u64)results[i + 2] | (u64)results[i + 3] << 32;
struct radeon_ws_bo *bo;
u32 domain;
u32 flink;
- struct pb_buffer *pb;
u32 size;
};
FREE(rscreen);
return NULL;
}
+ radeon_set_mem_constant(rw, rscreen->use_mem_constant);
rscreen->rw = rw;
rscreen->screen.winsys = (struct pipe_winsys*)rw;
rscreen->screen.destroy = r600_destroy_screen;
radeon_ws_bo_reference(rscreen->rw, &rpshader->bo, NULL);
rpshader->bo = NULL;
rpshader->bo = radeon_ws_bo(rscreen->rw, rshader->bc.ndw * 4,
- 4096);
+ 4096, 0);
if (rpshader->bo == NULL) {
return -ENOMEM;
}
- data = radeon_ws_bo_map(rscreen->rw, rpshader->bo);
+ data = radeon_ws_bo_map(rscreen->rw, rpshader->bo, 0, rctx);
memcpy(data, rshader->bc.bytecode, rshader->bc.ndw * 4);
radeon_ws_bo_unmap(rscreen->rw, rpshader->bo);
/* build state */
/* FIXME alignment 4096 enought ? too much ? */
resource->domain = r600_domain_from_usage(resource->base.b.bind);
resource->size = rtex->size;
- resource->bo = radeon_ws_bo(radeon, rtex->size, 4096);
+ resource->bo = radeon_ws_bo(radeon, rtex->size, 4096, 0);
if (resource->bo == NULL) {
FREE(rtex);
return NULL;
transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
- map = radeon_ws_bo_map(radeon, bo);
+ map = radeon_ws_bo_map(radeon, bo, 0, r600_context(ctx));
if (!map) {
return NULL;
}
/* allocate uncompressed texture */
if (rtexture->uncompressed == NULL) {
- rtexture->uncompressed = radeon_ws_bo(rscreen->rw, rtexture->size, 4096);
+ rtexture->uncompressed = radeon_ws_bo(rscreen->rw, rtexture->size, 4096, 0);
if (rtexture->uncompressed == NULL) {
return -ENOMEM;
}
#include <stdint.h>
+#include <pipe/p_compiler.h>
+
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
};
enum radeon_family radeon_get_family(struct radeon *rw);
+void radeon_set_mem_constant(struct radeon *radeon, boolean state);
/* lowlevel WS bo */
struct radeon_ws_bo;
struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon,
- unsigned size, unsigned alignment);
+ unsigned size, unsigned alignment, unsigned usage);
struct radeon_ws_bo *radeon_ws_bo_handle(struct radeon *radeon,
unsigned handle);
-void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo);
+void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo, unsigned usage, void *ctx);
void radeon_ws_bo_unmap(struct radeon *radeon, struct radeon_ws_bo *bo);
void radeon_ws_bo_reference(struct radeon *radeon, struct radeon_ws_bo **dst,
struct radeon_ws_bo *src);
return radeon->family;
}
+void radeon_set_mem_constant(struct radeon *radeon, boolean state)
+{
+ radeon->use_mem_constant = state;
+}
+
static int radeon_get_device(struct radeon *radeon)
{
struct drm_radeon_info info;
goto out_err;
bof_decref(handle);
handle = NULL;
- data = radeon_ws_bo_map(ctx->radeon, ctx->bo[i]);
+ data = radeon_ws_bo_map(ctx->radeon, ctx->bo[i], 0, NULL);
blob = bof_blob(ctx->bo[i]->bo->size, data);
radeon_ws_bo_unmap(ctx->radeon, ctx->bo[i]);
if (blob == NULL)
unsigned nstype;
struct radeon_stype_info *stype;
unsigned max_states;
+ boolean use_mem_constant; /* true for evergreen */
};
struct radeon_ws_bo {
struct pipe_reference reference;
struct radeon_bo *bo;
+ struct pb_buffer *pb;
};
extern struct radeon *radeon_new(int fd, unsigned device);
#include <malloc.h>
+#include <pipe/p_screen.h>
+#include <pipebuffer/pb_bufmgr.h>
#include "radeon_priv.h"
struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon,
- unsigned size, unsigned alignment)
+ unsigned size, unsigned alignment, unsigned usage)
{
struct radeon_ws_bo *ws_bo = calloc(1, sizeof(struct radeon_ws_bo));
+ struct pb_desc desc;
- ws_bo->bo = radeon_bo(radeon, 0, size, alignment, NULL);
- if (!ws_bo->bo) {
- free(ws_bo);
- return NULL;
+ if (radeon->use_mem_constant && (usage & PIPE_BIND_CONSTANT_BUFFER)) {
+ desc.alignment = alignment;
+ desc.usage = usage;
+ ws_bo->pb = pb_malloc_buffer_create(size, &desc);
+ if (ws_bo->pb == NULL) {
+ free(ws_bo);
+ return NULL;
+ }
+ } else {
+ ws_bo->bo = radeon_bo(radeon, 0, size, alignment, NULL);
+ if (!ws_bo->bo) {
+ free(ws_bo);
+ return NULL;
+ }
}
pipe_reference_init(&ws_bo->reference, 1);
return ws_bo;
}
-void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo)
+void *radeon_ws_bo_map(struct radeon *radeon, struct radeon_ws_bo *bo, unsigned usage, void *ctx)
{
+ if (bo->pb)
+ return pb_map(bo->pb, usage, ctx);
radeon_bo_map(radeon, bo->bo);
return bo->bo->data;
}
void radeon_ws_bo_unmap(struct radeon *radeon, struct radeon_ws_bo *bo)
{
- radeon_bo_unmap(radeon, bo->bo);
+ if (bo->pb)
+ pb_unmap(bo->pb);
+ else
+ radeon_bo_unmap(radeon, bo->bo);
}
static void radeon_ws_bo_destroy(struct radeon *radeon, struct radeon_ws_bo *bo)
{
- radeon_bo_reference(radeon, &bo->bo, NULL);
+ if (bo->pb)
+ pb_reference(&bo->pb, NULL);
+ else
+ radeon_bo_reference(radeon, &bo->bo, NULL);
free(bo);
}
struct radeon_ws_bo *src)
{
struct radeon_ws_bo *old = *dst;
+
if (pipe_reference(&(*dst)->reference, &src->reference)) {
radeon_ws_bo_destroy(radeon, old);
}
int radeon_ws_bo_wait(struct radeon *radeon, struct radeon_ws_bo *bo)
{
- return radeon_bo_wait(radeon, bo->bo);
+ if (bo->pb)
+ return 0;
+ else
+ return radeon_bo_wait(radeon, bo->bo);
}