From: Kenneth Graunke Date: Fri, 7 Dec 2018 19:20:39 +0000 (-0800) Subject: iris: Make a alloc_surface_state helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b2fa90706e9d6edbf7b33691b6600cab14a24740;p=mesa.git iris: Make a alloc_surface_state helper This does the gtt_offset addition for us --- diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 059cbca08ea..e4c95f2e06c 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -1503,6 +1503,22 @@ fill_buffer_surface_state(struct isl_device *isl_dev, .mocs = MOCS_WB); } +/** + * Allocate a SURFACE_STATE structure. + */ +static void * +alloc_surface_states(struct u_upload_mgr *mgr, + struct iris_state_ref *ref) +{ + const unsigned surf_size = 4 * GENX(RENDER_SURFACE_STATE_length); + + void *map = upload_state(mgr, ref, surf_size, 64); + + ref->offset += iris_bo_offset_from_base_address(iris_resource_bo(ref->res)); + + return map; +} + static void fill_surface_state(struct isl_device *isl_dev, void *map, @@ -1542,14 +1558,11 @@ iris_create_sampler_view(struct pipe_context *ctx, pipe_reference_init(&isv->base.reference, 1); pipe_resource_reference(&isv->base.texture, tex); - void *map = upload_state(ice->state.surface_uploader, &isv->surface_state, - 4 * GENX(RENDER_SURFACE_STATE_length), 64); + void *map = alloc_surface_states(ice->state.surface_uploader, + &isv->surface_state); if (!unlikely(map)) return NULL; - struct iris_bo *state_bo = iris_resource_bo(isv->surface_state.res); - isv->surface_state.offset += iris_bo_offset_from_base_address(state_bo); - if (util_format_is_depth_or_stencil(tmpl->format)) { struct iris_resource *zres, *sres; const struct util_format_description *desc = @@ -1680,14 +1693,11 @@ iris_create_surface(struct pipe_context *ctx, return psurf; - void *map = upload_state(ice->state.surface_uploader, &surf->surface_state, - 4 * GENX(RENDER_SURFACE_STATE_length), 64); + void *map = alloc_surface_states(ice->state.surface_uploader, + &surf->surface_state); if (!unlikely(map)) return NULL; - struct iris_bo *state_bo = iris_resource_bo(surf->surface_state.res); - surf->surface_state.offset += iris_bo_offset_from_base_address(state_bo); - fill_surface_state(&screen->isl_dev, map, res, &surf->view); return psurf; @@ -1722,19 +1732,13 @@ iris_set_shader_images(struct pipe_context *ctx, // XXX: these are not retained forever, use a separate uploader? void *map = - upload_state(ice->state.surface_uploader, - &shs->image[start_slot + i].surface_state, - 4 * GENX(RENDER_SURFACE_STATE_length), 64); + alloc_surface_states(ice->state.surface_uploader, + &shs->image[start_slot + i].surface_state); if (!unlikely(map)) { pipe_resource_reference(&shs->image[start_slot + i].res, NULL); return; } - struct iris_bo *surf_state_bo = - iris_resource_bo(shs->image[start_slot + i].surface_state.res); - shs->image[start_slot + i].surface_state.offset += - iris_bo_offset_from_base_address(surf_state_bo); - isl_surf_usage_flags_t usage = ISL_SURF_USAGE_STORAGE_BIT; enum isl_format isl_format = iris_format_for_usage(devinfo, img->format, usage).fmt;