From a9df8f7b64b903e0039e5b8893e0e0a55d57885e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 5 Jul 2021 15:46:54 +1000 Subject: [PATCH] crocus: use threaded context base classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit should be a pretty non-functional change Reviewed-by: Zoltán Böszörményi Part-of: --- src/gallium/drivers/crocus/crocus_blit.c | 14 ++-- src/gallium/drivers/crocus/crocus_blt.c | 14 ++-- src/gallium/drivers/crocus/crocus_clear.c | 8 +-- src/gallium/drivers/crocus/crocus_query.c | 2 + src/gallium/drivers/crocus/crocus_resolve.c | 30 ++++---- src/gallium/drivers/crocus/crocus_resource.c | 76 ++++++++++---------- src/gallium/drivers/crocus/crocus_resource.h | 7 +- src/gallium/drivers/crocus/crocus_state.c | 48 ++++++------- 8 files changed, 103 insertions(+), 96 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_blit.c b/src/gallium/drivers/crocus/crocus_blit.c index 5cec1ff2287..7620efc932b 100644 --- a/src/gallium/drivers/crocus/crocus_blit.c +++ b/src/gallium/drivers/crocus/crocus_blit.c @@ -583,10 +583,10 @@ use_blorp: struct blorp_surf src_surf, dst_surf; crocus_blorp_surf_for_resource(&screen->vtbl, &screen->isl_dev, &src_surf, - &src_res->base, src_aux_usage, + &src_res->base.b, src_aux_usage, info->src.level, false); crocus_blorp_surf_for_resource(&screen->vtbl, &screen->isl_dev, &dst_surf, - &dst_res->base, dst_aux_usage, + &dst_res->base.b, dst_aux_usage, info->dst.level, true); crocus_resource_prepare_render(ice, dst_res, info->dst.level, @@ -598,8 +598,8 @@ use_blorp: if (crocus_batch_references(batch, src_res->bo)) tex_cache_flush_hack(batch, src_fmt.fmt, src_res->surf.format); - if (dst_res->base.target == PIPE_BUFFER) { - util_range_add(&dst_res->base, &dst_res->valid_buffer_range, + if (dst_res->base.b.target == PIPE_BUFFER) { + util_range_add(&dst_res->base.b, &dst_res->valid_buffer_range, dst_x0, dst_x1); } @@ -703,7 +703,7 @@ crocus_copy_region(struct blorp_context *blorp, tex_cache_flush_hack(batch, ISL_FORMAT_UNSUPPORTED, src_res->surf.format); if (dst->target == PIPE_BUFFER) - util_range_add(&dst_res->base, &dst_res->valid_buffer_range, dstx, dstx + src_box->width); + util_range_add(&dst_res->base.b, &dst_res->valid_buffer_range, dstx, dstx + src_box->width); if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { struct blorp_address src_addr = { @@ -825,8 +825,8 @@ crocus_resource_copy_region(struct pipe_context *ctx, crocus_get_depth_stencil_resources(devinfo, p_src, &junk, &s_src_res); crocus_get_depth_stencil_resources(devinfo, p_dst, &junk, &s_dst_res); - crocus_copy_region(&ice->blorp, batch, &s_dst_res->base, dst_level, dstx, - dsty, dstz, &s_src_res->base, src_level, src_box); + crocus_copy_region(&ice->blorp, batch, &s_dst_res->base.b, dst_level, dstx, + dsty, dstz, &s_src_res->base.b, src_level, src_box); } crocus_flush_and_dirty_for_history(ice, batch, dst, diff --git a/src/gallium/drivers/crocus/crocus_blt.c b/src/gallium/drivers/crocus/crocus_blt.c index 96bb005983e..b6b8368d0fd 100644 --- a/src/gallium/drivers/crocus/crocus_blt.c +++ b/src/gallium/drivers/crocus/crocus_blt.c @@ -191,9 +191,9 @@ static bool crocus_emit_blt(struct crocus_batch *batch, crocus_resource_get_image_offset(src, src_level, src_box->z, &src_image_x, &src_image_y); - if (util_format_is_compressed(src->base.format)) { - int bw = util_format_get_blockwidth(src->base.format); - int bh = util_format_get_blockheight(src->base.format); + if (util_format_is_compressed(src->base.b.format)) { + int bw = util_format_get_blockwidth(src->base.b.format); + int bh = util_format_get_blockheight(src->base.b.format); assert(src_x % bw == 0); assert(src_y % bh == 0); src_x /= (int)bw; @@ -204,9 +204,9 @@ static bool crocus_emit_blt(struct crocus_batch *batch, crocus_resource_get_image_offset(dst, dst_level, dst_z, &dst_image_x, &dst_image_y); - if (util_format_is_compressed(dst->base.format)) { - int bw = util_format_get_blockwidth(dst->base.format); - int bh = util_format_get_blockheight(dst->base.format); + if (util_format_is_compressed(dst->base.b.format)) { + int bw = util_format_get_blockwidth(dst->base.b.format); + int bh = util_format_get_blockheight(dst->base.b.format); assert(dst_x % bw == 0); assert(dst_y % bh == 0); dst_x /= (int)bw; @@ -312,7 +312,7 @@ static bool crocus_copy_region_blt(struct crocus_batch *batch, unsigned src_level, const struct pipe_box *src_box) { - if (dst->base.target == PIPE_BUFFER || src->base.target == PIPE_BUFFER) + if (dst->base.b.target == PIPE_BUFFER || src->base.b.target == PIPE_BUFFER) return false; return crocus_emit_blt(batch, src, diff --git a/src/gallium/drivers/crocus/crocus_clear.c b/src/gallium/drivers/crocus/crocus_clear.c index 8ea21d9d227..261f19ac9db 100644 --- a/src/gallium/drivers/crocus/crocus_clear.c +++ b/src/gallium/drivers/crocus/crocus_clear.c @@ -347,7 +347,7 @@ clear_color(struct crocus_context *ice, } if (p_res->target == PIPE_BUFFER) - util_range_add(&res->base, &res->valid_buffer_range, box->x, box->x + box->width); + util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width); crocus_batch_maybe_flush(batch, 1500); @@ -430,7 +430,7 @@ can_fast_clear_depth(struct crocus_context *ice, if (!crocus_resource_level_has_hiz(res, level)) return false; - if (res->base.format == PIPE_FORMAT_Z16_UNORM) { + if (res->base.b.format == PIPE_FORMAT_Z16_UNORM) { /* From the Sandy Bridge PRM, volume 2 part 1, page 314: * * "[DevSNB+]: Several cases exist where Depth Buffer Clear cannot be @@ -592,7 +592,7 @@ clear_depth_stencil(struct crocus_context *ice, crocus_resource_prepare_render(ice, z_res, level, box->z, box->depth, aux_usage); crocus_blorp_surf_for_resource(&screen->vtbl, &batch->screen->isl_dev, - &z_surf, &z_res->base, aux_usage, + &z_surf, &z_res->base.b, aux_usage, level, true); } @@ -604,7 +604,7 @@ clear_depth_stencil(struct crocus_context *ice, crocus_resource_prepare_access(ice, stencil_res, level, 1, box->z, box->depth, stencil_res->aux.usage, false); crocus_blorp_surf_for_resource(&screen->vtbl, &batch->screen->isl_dev, - &stencil_surf, &stencil_res->base, + &stencil_surf, &stencil_res->base.b, stencil_res->aux.usage, level, true); } diff --git a/src/gallium/drivers/crocus/crocus_query.c b/src/gallium/drivers/crocus/crocus_query.c index 47114cc6e60..df3f3103647 100644 --- a/src/gallium/drivers/crocus/crocus_query.c +++ b/src/gallium/drivers/crocus/crocus_query.c @@ -74,6 +74,8 @@ #endif struct crocus_query { + struct threaded_query b; + enum pipe_query_type type; int index; diff --git a/src/gallium/drivers/crocus/crocus_resolve.c b/src/gallium/drivers/crocus/crocus_resolve.c index c0415d9a6df..3629785cd3a 100644 --- a/src/gallium/drivers/crocus/crocus_resolve.c +++ b/src/gallium/drivers/crocus/crocus_resolve.c @@ -98,7 +98,7 @@ resolve_sampler_views(struct crocus_context *ice, const int i = u_bit_scan(&views); struct crocus_sampler_view *isv = shs->textures[i]; - if (isv->res->base.target != PIPE_BUFFER) { + if (isv->res->base.b.target != PIPE_BUFFER) { if (consider_framebuffer) { disable_rb_aux_buffer(ice, draw_aux_buffer_disabled, isv->res, isv->view.base_level, isv->view.levels, @@ -140,7 +140,7 @@ resolve_image_views(struct crocus_context *ice, struct pipe_image_view *pview = &shs->image[i].base; struct crocus_resource *res = (void *) pview->resource; - if (res->base.target != PIPE_BUFFER) { + if (res->base.b.target != PIPE_BUFFER) { if (consider_framebuffer) { disable_rb_aux_buffer(ice, draw_aux_buffer_disabled, res, pview->u.tex.level, 1, @@ -533,7 +533,7 @@ crocus_resolve_color(struct crocus_context *ice, struct blorp_surf surf; crocus_blorp_surf_for_resource(&screen->vtbl, &batch->screen->isl_dev, &surf, - &res->base, res->aux.usage, level, true); + &res->base.b, res->aux.usage, level, true); crocus_batch_maybe_flush(batch, 1500); @@ -580,7 +580,7 @@ crocus_mcs_partial_resolve(struct crocus_context *ice, struct blorp_surf surf; crocus_blorp_surf_for_resource(&screen->vtbl, &batch->screen->isl_dev, &surf, - &res->base, res->aux.usage, 0, true); + &res->base.b, res->aux.usage, 0, true); struct blorp_batch blorp_batch; blorp_batch_init(&ice->blorp, &blorp_batch, batch, 0); @@ -683,7 +683,7 @@ crocus_hiz_exec(struct crocus_context *ice, struct blorp_surf surf; crocus_blorp_surf_for_resource(&screen->vtbl, &batch->screen->isl_dev, &surf, - &res->base, res->aux.usage, level, true); + &res->base.b, res->aux.usage, level, true); struct blorp_batch blorp_batch; enum blorp_batch_flags flags = 0; @@ -751,7 +751,7 @@ crocus_resource_check_level_layer(UNUSED const struct crocus_resource *res, UNUSED uint32_t level, UNUSED uint32_t layer) { assert(level < res->surf.levels); - assert(layer < util_num_layers(&res->base, level)); + assert(layer < util_num_layers(&res->base.b, level)); } static inline uint32_t @@ -774,7 +774,7 @@ static inline uint32_t miptree_layer_range_length(const struct crocus_resource *res, uint32_t level, uint32_t start_layer, uint32_t num_layers) { - assert(level <= res->base.last_level); + assert(level <= res->base.b.last_level); const uint32_t total_num_layers = crocus_get_num_logical_layers(res, level); assert(start_layer < total_num_layers); @@ -881,7 +881,7 @@ crocus_resource_finish_write(struct crocus_context *ice, uint32_t start_layer, uint32_t num_layers, enum isl_aux_usage aux_usage) { - if (res->base.format == PIPE_FORMAT_S8_UINT) + if (res->base.b.format == PIPE_FORMAT_S8_UINT) res->shadow_needs_update = true; if (!crocus_resource_level_has_aux(res, level)) @@ -1048,18 +1048,18 @@ crocus_update_stencil_shadow(struct crocus_context *ice, return; struct pipe_box box; - for (unsigned level = 0; level <= res->base.last_level; level++) { + for (unsigned level = 0; level <= res->base.b.last_level; level++) { u_box_2d(0, 0, - u_minify(res->base.width0, level), - u_minify(res->base.height0, level), &box); - const unsigned depth = res->base.target == PIPE_TEXTURE_3D ? - u_minify(res->base.depth0, level) : res->base.array_size; + u_minify(res->base.b.width0, level), + u_minify(res->base.b.height0, level), &box); + const unsigned depth = res->base.b.target == PIPE_TEXTURE_3D ? + u_minify(res->base.b.depth0, level) : res->base.b.array_size; for (unsigned layer = 0; layer < depth; layer++) { box.z = layer; ice->ctx.resource_copy_region(&ice->ctx, - &res->shadow->base, level, 0, 0, layer, - &res->base, level, &box); + &res->shadow->base.b, level, 0, 0, layer, + &res->base.b, level, &box); } } res->shadow_needs_update = false; diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c index 8854573ef9c..e3034268c7e 100644 --- a/src/gallium/drivers/crocus/crocus_resource.c +++ b/src/gallium/drivers/crocus/crocus_resource.c @@ -343,10 +343,10 @@ crocus_alloc_resource(struct pipe_screen *pscreen, if (!res) return NULL; - res->base = *templ; - res->base.screen = pscreen; + res->base.b = *templ; + res->base.b.screen = pscreen; res->orig_screen = crocus_pscreen_ref(pscreen); - pipe_reference_init(&res->base.reference, 1); + pipe_reference_init(&res->base.b.reference, 1); if (templ->target == PIPE_BUFFER) util_range_init(&res->valid_buffer_range); @@ -608,7 +608,7 @@ crocus_resource_finish_aux_import(struct pipe_screen *pscreen, assert(crocus_resource_unfinished_aux_import(res)); assert(!res->mod_info->supports_clear_color); - struct crocus_resource *aux_res = (void *) res->base.next; + struct crocus_resource *aux_res = (void *) res->base.b.next; assert(aux_res->aux.surf.row_pitch_B && aux_res->aux.offset && aux_res->aux.bo); @@ -621,8 +621,8 @@ crocus_resource_finish_aux_import(struct pipe_screen *pscreen, assert(res->bo->size >= (res->aux.offset + res->aux.surf.size_B)); assert(aux_res->aux.surf.row_pitch_B == res->aux.surf.row_pitch_B); - crocus_resource_destroy(&screen->base, res->base.next); - res->base.next = NULL; + crocus_resource_destroy(&screen->base, res->base.b.next); + res->base.b.next = NULL; } static struct pipe_resource * @@ -645,11 +645,11 @@ crocus_resource_create_for_buffer(struct pipe_screen *pscreen, res->bo = crocus_bo_alloc(screen->bufmgr, name, templ->width0); if (!res->bo) { - crocus_resource_destroy(pscreen, &res->base); + crocus_resource_destroy(pscreen, &res->base.b); return NULL; } - return &res->base; + return &res->base.b; } static struct pipe_resource * @@ -721,25 +721,25 @@ crocus_resource_create_with_modifiers(struct pipe_screen *pscreen, struct pipe_resource templ_shadow = (struct pipe_resource) { .usage = 0, .bind = PIPE_BIND_SAMPLER_VIEW, - .width0 = res->base.width0, - .height0 = res->base.height0, - .depth0 = res->base.depth0, - .last_level = res->base.last_level, - .nr_samples = res->base.nr_samples, - .nr_storage_samples = res->base.nr_storage_samples, - .array_size = res->base.array_size, + .width0 = res->base.b.width0, + .height0 = res->base.b.height0, + .depth0 = res->base.b.depth0, + .last_level = res->base.b.last_level, + .nr_samples = res->base.b.nr_samples, + .nr_storage_samples = res->base.b.nr_storage_samples, + .array_size = res->base.b.array_size, .format = PIPE_FORMAT_R8_UINT, - .target = res->base.target, + .target = res->base.b.target, }; res->shadow = (struct crocus_resource *)screen->base.resource_create(&screen->base, &templ_shadow); assert(res->shadow); } - return &res->base; + return &res->base.b; fail: fprintf(stderr, "XXX: resource creation failed\n"); - crocus_resource_destroy(pscreen, &res->base); + crocus_resource_destroy(pscreen, &res->base.b); return NULL; } @@ -789,9 +789,9 @@ crocus_resource_from_user_memory(struct pipe_screen *pscreen, return NULL; } - util_range_add(&res->base, &res->valid_buffer_range, 0, templ->width0); + util_range_add(&res->base.b, &res->valid_buffer_range, 0, templ->width0); - return &res->base; + return &res->base.b; } static struct pipe_resource * @@ -869,10 +869,10 @@ crocus_resource_from_handle(struct pipe_screen *pscreen, res->bo = NULL; } - return &res->base; + return &res->base.b; fail: - crocus_resource_destroy(pscreen, &res->base); + crocus_resource_destroy(pscreen, &res->base.b); return NULL; } @@ -899,7 +899,7 @@ crocus_resource_from_memobj(struct pipe_screen *pscreen, res->offset = offset; res->external_format = memobj->format; - return &res->base; + return &res->base.b; } static void @@ -1174,7 +1174,7 @@ static void crocus_map_copy_region(struct crocus_transfer *map) { struct pipe_screen *pscreen = &map->batch->screen->base; - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; struct pipe_box *box = &xfer->box; struct crocus_resource *res = (void *) xfer->resource; @@ -1311,7 +1311,7 @@ s8_offset(uint32_t stride, uint32_t x, uint32_t y, bool swizzled) static void crocus_unmap_s8(struct crocus_transfer *map) { - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; const struct pipe_box *box = &xfer->box; struct crocus_resource *res = (struct crocus_resource *) xfer->resource; struct isl_surf *surf = &res->surf; @@ -1344,7 +1344,7 @@ crocus_unmap_s8(struct crocus_transfer *map) static void crocus_map_s8(struct crocus_transfer *map) { - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; const struct pipe_box *box = &xfer->box; struct crocus_resource *res = (struct crocus_resource *) xfer->resource; struct isl_surf *surf = &res->surf; @@ -1417,7 +1417,7 @@ tile_extents(const struct isl_surf *surf, static void crocus_unmap_tiled_memcpy(struct crocus_transfer *map) { - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; const struct pipe_box *box = &xfer->box; struct crocus_resource *res = (struct crocus_resource *) xfer->resource; struct isl_surf *surf = &res->surf; @@ -1445,7 +1445,7 @@ crocus_unmap_tiled_memcpy(struct crocus_transfer *map) static void crocus_map_tiled_memcpy(struct crocus_transfer *map) { - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; const struct pipe_box *box = &xfer->box; struct crocus_resource *res = (struct crocus_resource *) xfer->resource; struct isl_surf *surf = &res->surf; @@ -1493,13 +1493,13 @@ crocus_map_tiled_memcpy(struct crocus_transfer *map) static void crocus_map_direct(struct crocus_transfer *map) { - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; struct pipe_box *box = &xfer->box; struct crocus_resource *res = (struct crocus_resource *) xfer->resource; void *ptr = crocus_bo_map(map->dbg, res->bo, xfer->usage & MAP_FLAGS); - if (res->base.target == PIPE_BUFFER) { + if (res->base.b.target == PIPE_BUFFER) { xfer->stride = 0; xfer->layer_stride = 0; @@ -1529,7 +1529,7 @@ can_promote_to_async(const struct crocus_resource *res, * initialized with useful data, then we can safely promote this write * to be unsynchronized. This helps the common pattern of appending data. */ - return res->base.target == PIPE_BUFFER && (usage & PIPE_MAP_WRITE) && + return res->base.b.target == PIPE_BUFFER && (usage & PIPE_MAP_WRITE) && !(usage & TC_TRANSFER_MAP_NO_INFER_UNSYNCHRONIZED) && !util_ranges_intersect(&res->valid_buffer_range, box->x, box->x + box->width); @@ -1579,7 +1579,7 @@ crocus_transfer_map(struct pipe_context *ctx, return NULL; struct crocus_transfer *map = slab_alloc(&ice->transfer_pool); - struct pipe_transfer *xfer = &map->base; + struct pipe_transfer *xfer = &map->base.b; if (!map) return NULL; @@ -1599,7 +1599,7 @@ crocus_transfer_map(struct pipe_context *ctx, box->x + box->width); if (usage & PIPE_MAP_WRITE) - util_range_add(&res->base, &res->valid_buffer_range, box->x, box->x + box->width); + util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width); /* Avoid using GPU copies for persistent/coherent buffers, as the idea * there is to access them simultaneously on the CPU & GPU. This also @@ -1678,14 +1678,14 @@ crocus_transfer_flush_region(struct pipe_context *ctx, uint32_t history_flush = 0; - if (res->base.target == PIPE_BUFFER) { + if (res->base.b.target == PIPE_BUFFER) { if (map->staging) history_flush |= PIPE_CONTROL_RENDER_TARGET_FLUSH; if (map->dest_had_defined_contents) history_flush |= crocus_flush_bits_for_history(res); - util_range_add(&res->base, &res->valid_buffer_range, box->x, box->x + box->width); + util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width); } if (history_flush & ~PIPE_CONTROL_CS_STALL) { @@ -1730,6 +1730,10 @@ crocus_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *xfer) map->unmap(map); pipe_resource_reference(&xfer->resource, NULL); + /* transfer_unmap is always called from the driver thread, so we have to + * use transfer_pool, not transfer_pool_unsync. Freeing an object into a + * different pool is allowed, however. + */ slab_free(&ice->transfer_pool, map); } @@ -1782,7 +1786,7 @@ crocus_flush_and_dirty_for_history(struct crocus_context *ice, uint32_t extra_flags, const char *reason) { - if (res->base.target != PIPE_BUFFER) + if (res->base.b.target != PIPE_BUFFER) return; uint32_t flush = crocus_flush_bits_for_history(res) | extra_flags; diff --git a/src/gallium/drivers/crocus/crocus_resource.h b/src/gallium/drivers/crocus/crocus_resource.h index b16a7184de0..6a165820207 100644 --- a/src/gallium/drivers/crocus/crocus_resource.h +++ b/src/gallium/drivers/crocus/crocus_resource.h @@ -26,6 +26,7 @@ #include "pipe/p_state.h" #include "util/u_inlines.h" #include "util/u_range.h" +#include "util/u_threaded_context.h" #include "intel/isl/isl.h" #include "intel/dev/intel_device_info.h" #include "crocus_bufmgr.h" @@ -83,7 +84,7 @@ crocus_combine_swizzle(enum pipe_swizzle outswz[4], * They contain the storage (BO) and layout information (ISL surface). */ struct crocus_resource { - struct pipe_resource base; + struct threaded_resource base; enum pipe_format internal_format; /** @@ -259,7 +260,7 @@ struct crocus_surface { * Transfer object - information about a buffer mapping. */ struct crocus_transfer { - struct pipe_transfer base; + struct threaded_transfer base; struct pipe_debug_callback *dbg; void *buffer; void *ptr; @@ -497,7 +498,7 @@ void crocus_resource_prepare_texture(struct crocus_context *ice, static inline bool crocus_resource_unfinished_aux_import(struct crocus_resource *res) { - return res->base.next != NULL && res->mod_info && + return res->base.b.next != NULL && res->mod_info && res->mod_info->aux_usage != ISL_AUX_USAGE_NONE; } diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c index e623ae62d4b..78b667d7e1a 100644 --- a/src/gallium/drivers/crocus/crocus_state.c +++ b/src/gallium/drivers/crocus/crocus_state.c @@ -2689,11 +2689,11 @@ crocus_create_sampler_view(struct pipe_context *ctx, crocus_get_depth_stencil_resources(devinfo, tex, &zres, &sres); - tex = util_format_has_depth(desc) ? &zres->base : &sres->base; + tex = util_format_has_depth(desc) ? &zres->base.b : &sres->base.b; if (tex->format == PIPE_FORMAT_S8_UINT) if (devinfo->ver == 7 && sres->shadow) - tex = &sres->shadow->base; + tex = &sres->shadow->base.b; } isv->res = (struct crocus_resource *) tex; @@ -2907,8 +2907,8 @@ crocus_create_surface(struct pipe_context *ctx, uint32_t temp_offset, temp_x, temp_y; isl_surf_get_image_offset_B_tile_sa(&res->surf, tmpl->u.tex.level, - res->base.target == PIPE_TEXTURE_3D ? 0 : tmpl->u.tex.first_layer, - res->base.target == PIPE_TEXTURE_3D ? tmpl->u.tex.first_layer : 0, + res->base.b.target == PIPE_TEXTURE_3D ? 0 : tmpl->u.tex.first_layer, + res->base.b.target == PIPE_TEXTURE_3D ? tmpl->u.tex.first_layer : 0, &temp_offset, &temp_x, &temp_y); if (!devinfo->has_surface_tile_offset && (temp_x || temp_y)) { @@ -2917,11 +2917,11 @@ crocus_create_surface(struct pipe_context *ctx, */ /* move to temp */ struct pipe_resource wa_templ = (struct pipe_resource) { - .width0 = u_minify(res->base.width0, tmpl->u.tex.level), - .height0 = u_minify(res->base.height0, tmpl->u.tex.level), + .width0 = u_minify(res->base.b.width0, tmpl->u.tex.level), + .height0 = u_minify(res->base.b.height0, tmpl->u.tex.level), .depth0 = 1, .array_size = 1, - .format = res->base.format, + .format = res->base.b.format, .target = PIPE_TEXTURE_2D, .bind = (usage & ISL_SURF_USAGE_DEPTH_BIT ? PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET) | PIPE_BIND_SAMPLER_VIEW, }; @@ -3084,7 +3084,7 @@ crocus_set_shader_images(struct pipe_context *ctx, fmt.fmt = isl_lower_storage_image_format(devinfo, fmt.fmt); } - if (res->base.target != PIPE_BUFFER) { + if (res->base.b.target != PIPE_BUFFER) { struct isl_view view = { .format = fmt.fmt, .base_level = img->u.tex.level, @@ -3108,7 +3108,7 @@ crocus_set_shader_images(struct pipe_context *ctx, }; iv->view = view; - util_range_add(&res->base, &res->valid_buffer_range, img->u.buf.offset, + util_range_add(&res->base.b, &res->valid_buffer_range, img->u.buf.offset, img->u.buf.offset + img->u.buf.size); fill_buffer_image_param(&image_params[start_slot + i], img->format, img->u.buf.size); @@ -3602,7 +3602,7 @@ crocus_set_shader_buffers(struct pipe_context *ctx, if (buffers && buffers[i].buffer) { struct crocus_resource *res = (void *) buffers[i].buffer; struct pipe_shader_buffer *ssbo = &shs->ssbo[start_slot + i]; - pipe_resource_reference(&ssbo->buffer, &res->base); + pipe_resource_reference(&ssbo->buffer, &res->base.b); ssbo->buffer_offset = buffers[i].buffer_offset; ssbo->buffer_size = MIN2(buffers[i].buffer_size, res->bo->size - ssbo->buffer_offset); @@ -3612,7 +3612,7 @@ crocus_set_shader_buffers(struct pipe_context *ctx, res->bind_history |= PIPE_BIND_SHADER_BUFFER; res->bind_stages |= 1 << stage; - util_range_add(&res->base, &res->valid_buffer_range, ssbo->buffer_offset, + util_range_add(&res->base.b, &res->valid_buffer_range, ssbo->buffer_offset, ssbo->buffer_offset + ssbo->buffer_size); } else { pipe_resource_reference(&shs->ssbo[start_slot + i].buffer, NULL); @@ -3948,7 +3948,7 @@ crocus_get_so_offset(struct pipe_stream_output_target *so) struct pipe_box box; uint32_t result; u_box_1d(tgt->offset_offset, 4, &box); - void *val = so->context->buffer_map(so->context, &tgt->offset_res->base, + void *val = so->context->buffer_map(so->context, &tgt->offset_res->base.b, 0, PIPE_MAP_DIRECTLY, &box, &transfer); assert(val); @@ -4005,7 +4005,7 @@ crocus_create_stream_output_target(struct pipe_context *ctx, cso->base.buffer_size = buffer_size; cso->base.context = ctx; - util_range_add(&res->base, &res->valid_buffer_range, buffer_offset, + util_range_add(&res->base.b, &res->valid_buffer_range, buffer_offset, buffer_offset + buffer_size); #if GFX_VER >= 7 struct crocus_context *ice = (struct crocus_context *) ctx; @@ -4953,7 +4953,7 @@ emit_surface_state(struct crocus_batch *batch, struct isl_surf surf = *in_surf; if (adjust_surf) { - if (res->base.target == PIPE_TEXTURE_3D && view->array_len == 1) { + if (res->base.b.target == PIPE_TEXTURE_3D && view->array_len == 1) { isl_surf_get_image_surf(isl_dev, in_surf, view->base_level, 0, view->base_array_layer, @@ -4961,7 +4961,7 @@ emit_surface_state(struct crocus_batch *batch, &tile_x_sa, &tile_y_sa); view->base_array_layer = 0; view->base_level = 0; - } else if (res->base.target == PIPE_TEXTURE_CUBE && devinfo->ver == 4) { + } else if (res->base.b.target == PIPE_TEXTURE_CUBE && devinfo->ver == 4) { isl_surf_get_image_surf(isl_dev, in_surf, view->base_level, view->base_array_layer, 0, @@ -4969,7 +4969,7 @@ emit_surface_state(struct crocus_batch *batch, &tile_x_sa, &tile_y_sa); view->base_array_layer = 0; view->base_level = 0; - } else if (res->base.target == PIPE_TEXTURE_1D_ARRAY) + } else if (res->base.b.target == PIPE_TEXTURE_1D_ARRAY) surf.dim = ISL_SURF_DIM_2D; } @@ -5044,7 +5044,7 @@ emit_surface(struct crocus_batch *batch, struct crocus_resource *res = (struct crocus_resource *)surf->base.texture; struct isl_view *view = &surf->view; uint32_t offset = 0; - enum pipe_texture_target target = res->base.target; + enum pipe_texture_target target = res->base.b.target; bool adjust_surf = false; if (devinfo->ver == 4 && target == PIPE_TEXTURE_CUBE) @@ -5204,7 +5204,7 @@ emit_image_view(struct crocus_context *ice, isl_dev->ss.align, &offset); bool write = iv->base.shader_access & PIPE_IMAGE_ACCESS_WRITE; uint32_t reloc = RELOC_32BIT | (write ? RELOC_WRITE : 0); - if (res->base.target == PIPE_BUFFER) { + if (res->base.b.target == PIPE_BUFFER) { const struct isl_format_layout *fmtl = isl_format_get_layout(iv->view.format); const unsigned cpp = iv->view.format == ISL_FORMAT_RAW ? 1 : fmtl->bpb / 8; unsigned final_size = @@ -5315,7 +5315,7 @@ emit_sol_surface(struct crocus_batch *batch, isl_dev->ss.align, &offset); isl_buffer_fill_state(isl_dev, surf_state, .address = crocus_state_reloc(batch, offset + isl_dev->ss.addr_offset, - crocus_resource_bo(&buf->base), + crocus_resource_bo(&buf->base.b), offset_dwords * 4, RELOC_32BIT|RELOC_WRITE), .size_B = num_elements * 4, .stride_B = stride_dwords * 4, @@ -6546,7 +6546,7 @@ crocus_upload_dirty_render_state(struct crocus_context *ice, sob.SurfaceSize = MAX2(tgt->base.buffer_size / 4, 1) - 1; sob.StreamOutputBufferOffsetAddress = - rw_bo(crocus_resource_bo(&tgt->offset_res->base), tgt->offset_offset); + rw_bo(crocus_resource_bo(&tgt->offset_res->base.b), tgt->offset_offset); if (tgt->zero_offset) { sob.StreamOffset = 0; tgt->zero_offset = false; @@ -7926,7 +7926,7 @@ crocus_upload_render_state(struct crocus_context *ice, mi_builder_init(&b, &batch->screen->devinfo, batch); struct crocus_address addr = - ro_bo(crocus_resource_bo(&so->offset_res->base), so->offset_offset); + ro_bo(crocus_resource_bo(&so->offset_res->base.b), so->offset_offset); struct mi_value offset = mi_iadd_imm(&b, mi_mem32(addr), -so->base.buffer_offset); @@ -8253,7 +8253,7 @@ crocus_rebind_buffer(struct crocus_context *ice, { struct pipe_context *ctx = &ice->ctx; - assert(res->base.target == PIPE_BUFFER); + assert(res->base.b.target == PIPE_BUFFER); /* Buffers can't be framebuffer attachments, nor display related, * and we don't have upstream Clover support. @@ -8272,7 +8272,7 @@ crocus_rebind_buffer(struct crocus_context *ice, const int i = u_bit_scan64(&bound_vbs); struct pipe_vertex_buffer *buffer = &ice->state.vertex_buffers[i]; - if (!buffer->is_user_buffer && &res->base == buffer->buffer.resource) + if (!buffer->is_user_buffer && &res->base.b == buffer->buffer.resource) ice->state.dirty |= CROCUS_DIRTY_VERTEX_BUFFERS; } } @@ -8329,7 +8329,7 @@ crocus_rebind_buffer(struct crocus_context *ice, if (res->bo == crocus_resource_bo(ssbo->buffer)) { struct pipe_shader_buffer buf = { - .buffer = &res->base, + .buffer = &res->base.b, .buffer_offset = ssbo->buffer_offset, .buffer_size = ssbo->buffer_size, };