diff options
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter_rectlist.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_resource.c | 102 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_resource.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_transfer.c | 6 |
4 files changed, 63 insertions, 51 deletions
diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index 4efdeb80e4f..3cb17e0f37a 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -141,7 +141,7 @@ ilo_blitter_set_rectlist(struct ilo_blitter *blitter, /* buffer is full */ if (blitter->buffer.offset + sizeof(vertices) > blitter->buffer.size) { - if (!ilo_buffer_alloc_bo(ilo_buffer(blitter->buffer.res))) + if (!ilo_buffer_rename_bo(ilo_buffer(blitter->buffer.res))) usage &= ~PIPE_TRANSFER_UNSYNCHRONIZED; blitter->buffer.offset = 0; diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 4f0e416ee37..20393ee3098 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -605,7 +605,7 @@ tex_layout_init_tiling(struct tex_layout *layout) /* no conflicting binding flags */ assert(valid_tilings); - /* prefer tiled than linear */ + /* prefer tiled over linear */ if (valid_tilings & tile_y) layout->tiling = INTEL_TILING_Y; else if (valid_tilings & tile_x) @@ -1108,42 +1108,38 @@ tex_alloc_slices(struct ilo_texture *tex) } static bool -tex_create_bo(struct ilo_texture *tex, - const struct winsys_handle *handle) +tex_import_handle(struct ilo_texture *tex, + const struct tex_layout *layout, + const struct winsys_handle *handle) { struct ilo_screen *is = ilo_screen(tex->base.screen); const char *name = resource_get_bo_name(&tex->base); - struct intel_bo *bo; - - if (handle) { - enum intel_tiling_mode tiling; - unsigned long pitch; - - bo = intel_winsys_import_handle(is->winsys, name, handle, - tex->bo_height, &tiling, &pitch); + enum intel_tiling_mode tiling; + unsigned long pitch; - if (bo) { - tex->tiling = tiling; - tex->bo_stride = pitch; - } - } - else { - const enum intel_domain_flag initial_domain = - resource_get_bo_initial_domain(&tex->base); + tex->bo = intel_winsys_import_handle(is->winsys, name, handle, + tex->bo_height, &tiling, &pitch); + if (!tex->bo) + return false; - bo = intel_winsys_alloc_bo(is->winsys, name, tex->tiling, - tex->bo_stride, tex->bo_height, initial_domain); - } + tex->tiling = tiling; + tex->bo_stride = pitch; - if (!bo) - return false; + return true; +} - if (tex->bo) - intel_bo_unreference(tex->bo); +static bool +tex_create_bo(struct ilo_texture *tex) +{ + struct ilo_screen *is = ilo_screen(tex->base.screen); + const char *name = resource_get_bo_name(&tex->base); + const enum intel_domain_flag initial_domain = + resource_get_bo_initial_domain(&tex->base); - tex->bo = bo; + tex->bo = intel_winsys_alloc_bo(is->winsys, name, tex->tiling, + tex->bo_stride, tex->bo_height, initial_domain); - return true; + return (tex->bo != NULL); } static bool @@ -1281,8 +1277,14 @@ tex_apply_layout(struct ilo_texture *tex, tex->array_spacing_full = layout->array_spacing_full; tex->interleaved = layout->interleaved; - if (!tex_create_bo(tex, handle)) - return false; + if (handle) { + if (!tex_import_handle(tex, layout, handle)) + return false; + } + else { + if (!tex_create_bo(tex)) + return false; + } /* allocate separate stencil resource */ if (layout->separate_stencil && !tex_create_separate_stencil(tex)) @@ -1390,19 +1392,11 @@ buf_create_bo(struct ilo_buffer *buf) const char *name = resource_get_bo_name(&buf->base); const enum intel_domain_flag initial_domain = resource_get_bo_initial_domain(&buf->base); - struct intel_bo *bo; - bo = intel_winsys_alloc_buffer(is->winsys, name, + buf->bo = intel_winsys_alloc_buffer(is->winsys, name, buf->bo_size, initial_domain); - if (!bo) - return false; - - if (buf->bo) - intel_bo_unreference(buf->bo); - buf->bo = bo; - - return true; + return (buf->bo != NULL); } static void @@ -1547,19 +1541,37 @@ ilo_init_resource_functions(struct ilo_screen *is) } bool -ilo_buffer_alloc_bo(struct ilo_buffer *buf) +ilo_buffer_rename_bo(struct ilo_buffer *buf) { - return buf_create_bo(buf); + struct intel_bo *old_bo = buf->bo; + + if (buf_create_bo(buf)) { + intel_bo_unreference(old_bo); + return true; + } + else { + buf->bo = old_bo; + return false; + } } bool -ilo_texture_alloc_bo(struct ilo_texture *tex) +ilo_texture_rename_bo(struct ilo_texture *tex) { - /* a shared bo cannot be reallocated */ + struct intel_bo *old_bo = tex->bo; + + /* an imported texture cannot be renamed */ if (tex->imported) return false; - return tex_create_bo(tex, NULL); + if (tex_create_bo(tex)) { + intel_bo_unreference(old_bo); + return true; + } + else { + tex->bo = old_bo; + return false; + } } /** diff --git a/src/gallium/drivers/ilo/ilo_resource.h b/src/gallium/drivers/ilo/ilo_resource.h index 81563da7a2b..5af9cc1b440 100644 --- a/src/gallium/drivers/ilo/ilo_resource.h +++ b/src/gallium/drivers/ilo/ilo_resource.h @@ -155,10 +155,10 @@ void ilo_init_resource_functions(struct ilo_screen *is); bool -ilo_buffer_alloc_bo(struct ilo_buffer *buf); +ilo_buffer_rename_bo(struct ilo_buffer *buf); bool -ilo_texture_alloc_bo(struct ilo_texture *tex); +ilo_texture_rename_bo(struct ilo_texture *tex); static inline struct ilo_texture_slice * ilo_texture_get_slice(const struct ilo_texture *tex, diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c index 4a38e29e076..f55bd261f75 100644 --- a/src/gallium/drivers/ilo/ilo_transfer.c +++ b/src/gallium/drivers/ilo/ilo_transfer.c @@ -136,8 +136,8 @@ choose_transfer_method(struct ilo_context *ilo, struct ilo_transfer *xfer) } else if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) { /* discard old bo and allocate a new one for mapping */ - if ((tex && ilo_texture_alloc_bo(tex)) || - (buf && ilo_buffer_alloc_bo(buf))) { + if ((tex && ilo_texture_rename_bo(tex)) || + (buf && ilo_buffer_rename_bo(buf))) { ilo_mark_states_with_resource_dirty(ilo, res); will_stall = false; } @@ -948,7 +948,7 @@ buf_pwrite(struct ilo_context *ilo, struct ilo_buffer *buf, if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) { /* old data not needed so discard the old bo to avoid stalling */ - if (ilo_buffer_alloc_bo(buf)) { + if (ilo_buffer_rename_bo(buf)) { ilo_mark_states_with_resource_dirty(ilo, &buf->base); will_stall = false; } |