r600g,radeonsi: set resource domains in one place (v2)
authorMarek Olšák <marek.olsak@amd.com>
Tue, 4 Feb 2014 17:35:40 +0000 (18:35 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 6 Feb 2014 16:29:59 +0000 (17:29 +0100)
v2: This doesn't change the behavior. It only moves the tiling check
    to r600_init_resource and removes the usage parameter.

Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeonsi/si_descriptors.c

index d1410260cc50c0ae6839087ee78d85e33291f656..208c073a7a87b41199b95cab534b532244bcc83d 100644 (file)
@@ -2179,8 +2179,8 @@ static void r600_invalidate_buffer(struct pipe_context *ctx, struct pipe_resourc
        pb_reference(&rbuffer->buf, NULL);
 
        /* Create a new one in the same pipe_resource. */
-       r600_init_resource(&rctx->screen->b, rbuffer, rbuffer->b.b.width0, alignment,
-                          TRUE, rbuffer->b.b.usage);
+       r600_init_resource(&rctx->screen->b, rbuffer, rbuffer->b.b.width0,
+                          alignment, TRUE);
 
        /* We changed the buffer, now we need to bind it where the old one was bound. */
        /* Vertex buffers. */
index 20772289e246c3a7cb81650970630cf837fb2c3b..59578e1ad5374b62e479ce8e8cdc633a997d7b47 100644 (file)
@@ -103,42 +103,41 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
 bool r600_init_resource(struct r600_common_screen *rscreen,
                        struct r600_resource *res,
                        unsigned size, unsigned alignment,
-                       bool use_reusable_pool, unsigned usage)
+                       bool use_reusable_pool)
 {
-       uint32_t initial_domain, domains;
+       struct r600_texture *rtex = (struct r600_texture*)res;
 
-       switch(usage) {
+       switch (res->b.b.usage) {
        case PIPE_USAGE_STAGING:
        case PIPE_USAGE_DYNAMIC:
        case PIPE_USAGE_STREAM:
-               /* These resources participate in transfers, i.e. are used
-                * for uploads and downloads from regular resources.
-                * We generate them internally for some transfers.
-                */
-               initial_domain = RADEON_DOMAIN_GTT;
-               domains = RADEON_DOMAIN_GTT;
+               /* Transfers are likely to occur more often with these resources. */
+               res->domains = RADEON_DOMAIN_GTT;
                break;
        case PIPE_USAGE_DEFAULT:
        case PIPE_USAGE_STATIC:
        case PIPE_USAGE_IMMUTABLE:
        default:
-               /* Don't list GTT here, because the memory manager would put some
-                * resources to GTT no matter what the initial domain is.
-                * Not listing GTT in the domains improves performance a lot. */
-               initial_domain = RADEON_DOMAIN_VRAM;
-               domains = RADEON_DOMAIN_VRAM;
+               /* Not listing GTT here improves performance in some apps. */
+               res->domains = RADEON_DOMAIN_VRAM;
                break;
        }
 
+       /* Tiled textures are unmappable. Always put them in VRAM. */
+       if (res->b.b.target != PIPE_BUFFER &&
+           rtex->surface.level[0].mode >= RADEON_SURF_MODE_1D) {
+               res->domains = RADEON_DOMAIN_VRAM;
+       }
+
+       /* Allocate the resource. */
        res->buf = rscreen->ws->buffer_create(rscreen->ws, size, alignment,
                                               use_reusable_pool,
-                                              initial_domain);
+                                              res->domains);
        if (!res->buf) {
                return false;
        }
 
        res->cs_buf = rscreen->ws->buffer_get_cs_handle(res->buf);
-       res->domains = domains;
        util_range_set_empty(&res->valid_buffer_range);
 
        if (rscreen->debug_flags & DBG_VM && res->b.b.target == PIPE_BUFFER) {
@@ -327,7 +326,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
        rbuffer->b.vtbl = &r600_buffer_vtbl;
        util_range_init(&rbuffer->valid_buffer_range);
 
-       if (!r600_init_resource(rscreen, rbuffer, templ->width0, alignment, TRUE, templ->usage)) {
+       if (!r600_init_resource(rscreen, rbuffer, templ->width0, alignment, TRUE)) {
                FREE(rbuffer);
                return NULL;
        }
index 9fdfdfd21fd060629fc3a15f64b4f054decddc48..7193a0f156e3e6728dbc2dd4975a13d4f7ef8f2d 100644 (file)
@@ -321,7 +321,7 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
 bool r600_init_resource(struct r600_common_screen *rscreen,
                        struct r600_resource *res,
                        unsigned size, unsigned alignment,
-                       bool use_reusable_pool, unsigned usage);
+                       bool use_reusable_pool);
 struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
                                         const struct pipe_resource *templ,
                                         unsigned alignment);
index eb1e191d0f9915af2020b508121e24c4770adc82..84c3daa7728f14bec226aef1a827b9fa564cec2d 100644 (file)
@@ -616,11 +616,8 @@ r600_texture_create_object(struct pipe_screen *screen,
 
        /* Now create the backing buffer. */
        if (!buf) {
-               unsigned base_align = rtex->surface.bo_alignment;
-               unsigned usage = rtex->surface.level[0].mode >= RADEON_SURF_MODE_1D ?
-                                        PIPE_USAGE_STATIC : base->usage;
-
-               if (!r600_init_resource(rscreen, resource, rtex->size, base_align, FALSE, usage)) {
+               if (!r600_init_resource(rscreen, resource, rtex->size,
+                                       rtex->surface.bo_alignment, FALSE)) {
                        FREE(rtex);
                        return NULL;
                }
index 9078c6c7f3e386f047234b76663707a1e5153f0c..f717371bb2a51866b24292a538c8168d2fbc24cf 100644 (file)
@@ -706,8 +706,8 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource
        pb_reference(&rbuffer->buf, NULL);
 
        /* Create a new one in the same pipe_resource. */
-       r600_init_resource(&sctx->screen->b, rbuffer, rbuffer->b.b.width0, alignment,
-                          TRUE, rbuffer->b.b.usage);
+       r600_init_resource(&sctx->screen->b, rbuffer, rbuffer->b.b.width0,
+                          alignment, TRUE);
 
        /* We changed the buffer, now we need to bind it where the old one
         * was bound. This consists of 2 things: