From: Kenneth Graunke Date: Mon, 1 Feb 2021 12:51:11 +0000 (-0800) Subject: iris: Defer uploading of surface states X-Git-Tag: upstream/21.2.3~6972 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5659460af4dd5b5ca78487fff54210057db1f43a;p=platform%2Fupstream%2Fmesa.git iris: Defer uploading of surface states With u_threaded_context, create_surface and create_sampler_view will be called from a different thread than the driver thread. They aren't allowed to access the context, which means that they can't use the uploaders there to upload our SURFACE_STATE entries. Thanks to backing-storage replacement and iris_rebind_buffer, we already reworked things to maintain CPU-side copies of the SURFACE_STATE entries and added the ability to upload or re-upload them later. So we can skip the upload at object creation time, and add a simple resource-is-NULL check at binding table upload time to ensure that they get uploaded by the time we need them. (They might get uploaded earlier due to rebinds or clear color updates, but this is the last moment to do so.) Reviewed-by: Zoltán Böszörményi Reviewed-by: Ian Romanick Reviewed-by: Nanley Chery Part-of: --- diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index ec92720..fd621d9 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -2430,7 +2430,6 @@ iris_create_sampler_view(struct pipe_context *ctx, struct pipe_resource *tex, const struct pipe_sampler_view *tmpl) { - struct iris_context *ice = (struct iris_context *) ctx; struct iris_screen *screen = (struct iris_screen *)ctx->screen; const struct gen_device_info *devinfo = &screen->devinfo; struct iris_sampler_view *isv = calloc(1, sizeof(struct iris_sampler_view)); @@ -2513,8 +2512,6 @@ iris_create_sampler_view(struct pipe_context *ctx, ISL_SURF_USAGE_TEXTURE_BIT); } - upload_surface_states(ice->state.surface_uploader, &isv->surface_state); - return &isv->base; } @@ -2540,7 +2537,6 @@ iris_create_surface(struct pipe_context *ctx, struct pipe_resource *tex, const struct pipe_surface *tmpl) { - struct iris_context *ice = (struct iris_context *) ctx; struct iris_screen *screen = (struct iris_screen *)ctx->screen; const struct gen_device_info *devinfo = &screen->devinfo; @@ -2657,13 +2653,6 @@ iris_create_surface(struct pipe_context *ctx, #endif } - upload_surface_states(ice->state.surface_uploader, &surf->surface_state); - -#if GEN_GEN == 8 - upload_surface_states(ice->state.surface_uploader, - &surf->surface_state_read); -#endif - return psurf; } @@ -2745,8 +2734,6 @@ iris_create_surface(struct pipe_context *ctx, isl_surf_fill_state_s(&screen->isl_dev, surf->surface_state.cpu, &f); - upload_surface_states(ice->state.surface_uploader, &surf->surface_state); - return psurf; } @@ -4819,6 +4806,16 @@ use_surface(struct iris_context *ice, struct iris_resource *res = (void *) p_surf->texture; uint32_t offset = 0; + if (GEN_GEN == 8 && is_read_surface && !surf->surface_state_read.ref.res) { + upload_surface_states(ice->state.surface_uploader, + &surf->surface_state_read); + } + + if (!surf->surface_state.ref.res) { + upload_surface_states(ice->state.surface_uploader, + &surf->surface_state); + } + if (res->aux.bo) { iris_use_pinned_bo(batch, res->aux.bo, writeable, access); if (res->aux.clear_color_bo) @@ -4862,6 +4859,9 @@ use_sampler_view(struct iris_context *ice, enum isl_aux_usage aux_usage = iris_resource_texture_aux_usage(ice, isv->res, isv->view.format); + if (!isv->surface_state.ref.res) + upload_surface_states(ice->state.surface_uploader, &isv->surface_state); + if (isv->res->aux.bo) { iris_use_pinned_bo(batch, isv->res->aux.bo, false, IRIS_DOMAIN_OTHER_READ);