From b6b76cbb20b3d9467011231069e23972b98afa49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 2 Jun 2010 06:45:00 +0200 Subject: [PATCH] r300g: store the GEM domain in buffer and texture structs --- src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_screen_buffer.c | 25 ++++++------------- src/gallium/drivers/r300/r300_screen_buffer.h | 2 ++ src/gallium/drivers/r300/r300_texture.c | 9 ++++--- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index e047307e10b..48ec52d26cf 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -272,6 +272,8 @@ struct r300_texture { /* Parent class */ struct u_resource b; + enum r300_buffer_domain domain; + /* Offsets into the buffer. */ unsigned offset[R300_MAX_TEXTURE_LEVELS]; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index de89f51f3eb..44179f19ed4 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -116,19 +116,6 @@ int r300_upload_user_buffers(struct r300_context *r300) return ret; } -static struct r300_winsys_buffer * -r300_winsys_buffer_create(struct r300_screen *r300screen, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct r300_winsys_screen *rws = r300screen->rws; - struct r300_winsys_buffer *buf; - - buf = rws->buffer_create(rws, alignment, usage, R300_DOMAIN_GTT, size); - return buf; -} - static void r300_winsys_buffer_destroy(struct r300_screen *r300screen, struct r300_buffer *rbuf) { @@ -180,9 +167,9 @@ r300_buffer_transfer_map( struct pipe_context *pipe, rws->buffer_reference(rws, &rbuf->buf, NULL); rbuf->num_ranges = 0; - rbuf->buf = r300_winsys_buffer_create(r300screen, - 16, - rbuf->b.b.bind, /* XXX */ + rbuf->buf = r300screen->rws->buffer_create(r300screen->rws, 16, + rbuf->b.b.bind, + rbuf->domain, rbuf->b.b.width0); break; } @@ -278,9 +265,12 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen, if (rbuf->b.b.bind & R300_BIND_OQBO) alignment = 4096; - rbuf->buf = r300_winsys_buffer_create(r300screen, + rbuf->domain = R300_DOMAIN_GTT; + + rbuf->buf = r300screen->rws->buffer_create(r300screen->rws, alignment, rbuf->b.b.bind, + rbuf->domain, rbuf->b.b.width0); if (!rbuf->buf) @@ -315,6 +305,7 @@ struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen, rbuf->b.b.width0 = bytes; rbuf->b.b.height0 = 1; rbuf->b.b.depth0 = 1; + rbuf->domain = R300_DOMAIN_GTT; rbuf->user_buffer = ptr; return &rbuf->b.b; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h index b4776fa344e..87b42b94122 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.h +++ b/src/gallium/drivers/r300/r300_screen_buffer.h @@ -52,6 +52,8 @@ struct r300_buffer struct r300_winsys_buffer *buf; + enum r300_buffer_domain domain; + void *user_buffer; struct r300_buffer_range ranges[R300_BUFFER_MAX_RANGES]; unsigned num_ranges; diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 33aa2508866..4e5dc5568f8 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -918,7 +918,6 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen, struct r300_texture* tex = CALLOC_STRUCT(r300_texture); struct r300_screen* rscreen = r300_screen(screen); struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys; - enum r300_buffer_domain domain; if (!tex) { return NULL; @@ -960,10 +959,11 @@ 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)); - domain = base->flags & R300_RESOURCE_FLAG_TRANSFER ? R300_DOMAIN_GTT : - R300_DOMAIN_VRAM; + tex->domain = base->flags & R300_RESOURCE_FLAG_TRANSFER ? R300_DOMAIN_GTT : + R300_DOMAIN_VRAM; - tex->buffer = rws->buffer_create(rws, 2048, base->bind, domain, tex->size); + tex->buffer = rws->buffer_create(rws, 2048, base->bind, tex->domain, + tex->size); rws->buffer_set_tiling(rws, tex->buffer, tex->pitch[0] * util_format_get_blocksize(tex->b.b.format), @@ -1051,6 +1051,7 @@ r300_texture_from_handle(struct pipe_screen* screen, tex->b.vtbl = &r300_texture_vtbl; pipe_reference_init(&tex->b.b.reference, 1); tex->b.b.screen = screen; + tex->domain = R300_DOMAIN_VRAM; tex->stride_override = stride; -- 2.30.2