From 2b09e818dc25a6b8ce583f69b90ccf735fd278dd Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 14 Nov 2019 16:06:10 -0800 Subject: iris: Create an "iris_surface_state" wrapper struct Today, we only have a state reference to the GPU buffer containing our uploaded SURFACE_STATEs. However, we're going to want a CPU-side copy soon. Making a wrapper struct means we can talk about both together, and also put both in the field called "surface_state". --- src/gallium/drivers/iris/iris_resource.h | 16 ++++++++--- src/gallium/drivers/iris/iris_state.c | 47 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h index 39cbaba71e7..4eac653bd3a 100644 --- a/src/gallium/drivers/iris/iris_resource.h +++ b/src/gallium/drivers/iris/iris_resource.h @@ -179,6 +179,14 @@ struct iris_state_ref { uint32_t offset; }; +/** + * The SURFACE_STATE descriptors for a resource. + */ +struct iris_surface_state { + /** A reference to the GPU buffer holding our uploaded SURFACE_STATE */ + struct iris_state_ref ref; +}; + /** * Gallium CSO for sampler views (texture views). * @@ -200,7 +208,7 @@ struct iris_sampler_view { struct iris_resource *res; /** The resource (BO) holding our SURFACE_STATE. */ - struct iris_state_ref surface_state; + struct iris_surface_state surface_state; }; /** @@ -210,7 +218,7 @@ struct iris_image_view { struct pipe_image_view base; /** The resource (BO) holding our SURFACE_STATE. */ - struct iris_state_ref surface_state; + struct iris_surface_state surface_state; }; /** @@ -226,9 +234,9 @@ struct iris_surface { union isl_color_value clear_color; /** The resource (BO) holding our SURFACE_STATE. */ - struct iris_state_ref surface_state; + struct iris_surface_state surface_state; /** The resource (BO) holding our SURFACE_STATE for read. */ - struct iris_state_ref surface_state_read; + struct iris_surface_state surface_state_read; }; /** diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 37f1ae26c17..8336e33e744 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -2264,7 +2264,7 @@ iris_create_sampler_view(struct pipe_context *ctx, isv->res = (struct iris_resource *) tex; void *map = alloc_surface_states(ice->state.surface_uploader, - &isv->surface_state, + &isv->surface_state.ref, isv->res->aux.sampler_usages); if (!unlikely(map)) return NULL; @@ -2330,7 +2330,7 @@ iris_sampler_view_destroy(struct pipe_context *ctx, { struct iris_sampler_view *isv = (void *) state; pipe_resource_reference(&state->texture, NULL); - pipe_resource_reference(&isv->surface_state.res, NULL); + pipe_resource_reference(&isv->surface_state.ref.res, NULL); free(isv); } @@ -2427,19 +2427,19 @@ iris_create_surface(struct pipe_context *ctx, void *map = alloc_surface_states(ice->state.surface_uploader, - &surf->surface_state, + &surf->surface_state.ref, res->aux.possible_usages); if (!unlikely(map)) { - pipe_resource_reference(&surf->surface_state.res, NULL); + pipe_resource_reference(&surf->surface_state.ref.res, NULL); return NULL; } #if GEN_GEN == 8 void *map_read = alloc_surface_states(ice->state.surface_uploader, - &surf->surface_state_read, + &surf->surface_state_read.ref, res->aux.possible_usages); if (!unlikely(map_read)) { - pipe_resource_reference(&surf->surface_state_read.res, NULL); + pipe_resource_reference(&surf->surface_state_read.ref.res, NULL); return NULL; } #endif @@ -2611,7 +2611,7 @@ iris_set_shader_images(struct pipe_context *ctx, void *map = alloc_surface_states(ice->state.surface_uploader, - &iv->surface_state, 1 << ISL_AUX_USAGE_NONE); + &iv->surface_state.ref, 1 << ISL_AUX_USAGE_NONE); if (!unlikely(map)) return; @@ -2685,7 +2685,7 @@ iris_set_shader_images(struct pipe_context *ctx, } } else { pipe_resource_reference(&iv->base.resource, NULL); - pipe_resource_reference(&iv->surface_state.res, NULL); + pipe_resource_reference(&iv->surface_state.ref.res, NULL); fill_default_image_param(&image_params[start_slot + i]); } } @@ -2760,8 +2760,8 @@ iris_surface_destroy(struct pipe_context *ctx, struct pipe_surface *p_surf) { struct iris_surface *surf = (void *) p_surf; pipe_resource_reference(&p_surf->texture, NULL); - pipe_resource_reference(&surf->surface_state.res, NULL); - pipe_resource_reference(&surf->surface_state_read.res, NULL); + pipe_resource_reference(&surf->surface_state.ref.res, NULL); + pipe_resource_reference(&surf->surface_state_read.ref.res, NULL); free(surf); } @@ -4491,9 +4491,9 @@ use_surface(struct iris_context *ice, iris_use_pinned_bo(batch, iris_resource_bo(p_surf->texture), writeable); if (GEN_GEN == 8 && is_read_surface) { - iris_use_pinned_bo(batch, iris_resource_bo(surf->surface_state_read.res), false); + iris_use_pinned_bo(batch, iris_resource_bo(surf->surface_state_read.ref.res), false); } else { - iris_use_pinned_bo(batch, iris_resource_bo(surf->surface_state.res), false); + iris_use_pinned_bo(batch, iris_resource_bo(surf->surface_state.ref.res), false); } if (res->aux.bo) { @@ -4503,18 +4503,19 @@ use_surface(struct iris_context *ice, if (memcmp(&res->aux.clear_color, &surf->clear_color, sizeof(surf->clear_color)) != 0) { - update_clear_value(ice, batch, res, &surf->surface_state, + update_clear_value(ice, batch, res, &surf->surface_state.ref, res->aux.possible_usages, &surf->view); if (GEN_GEN == 8) { - update_clear_value(ice, batch, res, &surf->surface_state_read, + update_clear_value(ice, batch, res, &surf->surface_state_read.ref, res->aux.possible_usages, &surf->read_view); } surf->clear_color = res->aux.clear_color; } } - offset = (GEN_GEN == 8 && is_read_surface) ? surf->surface_state_read.offset - : surf->surface_state.offset; + offset = (GEN_GEN == 8 && is_read_surface) + ? surf->surface_state_read.ref.offset + : surf->surface_state.ref.offset; return offset + surf_state_offset_for_aux(res, res->aux.possible_usages, aux_usage); @@ -4530,7 +4531,7 @@ use_sampler_view(struct iris_context *ice, iris_resource_texture_aux_usage(ice, isv->res, isv->view.format, 0); iris_use_pinned_bo(batch, isv->res->bo, false); - iris_use_pinned_bo(batch, iris_resource_bo(isv->surface_state.res), false); + iris_use_pinned_bo(batch, iris_resource_bo(isv->surface_state.ref.res), false); if (isv->res->aux.bo) { iris_use_pinned_bo(batch, isv->res->aux.bo, false); @@ -4538,13 +4539,13 @@ use_sampler_view(struct iris_context *ice, iris_use_pinned_bo(batch, isv->res->aux.clear_color_bo, false); if (memcmp(&isv->res->aux.clear_color, &isv->clear_color, sizeof(isv->clear_color)) != 0) { - update_clear_value(ice, batch, isv->res, &isv->surface_state, + update_clear_value(ice, batch, isv->res, &isv->surface_state.ref, isv->res->aux.sampler_usages, &isv->view); isv->clear_color = isv->res->aux.clear_color; } } - return isv->surface_state.offset + + return isv->surface_state.ref.offset + surf_state_offset_for_aux(isv->res, isv->res->aux.sampler_usages, aux_usage); } @@ -4578,12 +4579,12 @@ use_image(struct iris_batch *batch, struct iris_context *ice, bool write = iv->base.shader_access & PIPE_IMAGE_ACCESS_WRITE; iris_use_pinned_bo(batch, res->bo, write); - iris_use_pinned_bo(batch, iris_resource_bo(iv->surface_state.res), false); + iris_use_pinned_bo(batch, iris_resource_bo(iv->surface_state.ref.res), false); if (res->aux.bo) iris_use_pinned_bo(batch, res->aux.bo, write); - return iv->surface_state.offset; + return iv->surface_state.ref.offset; } #define push_bt_entry(addr) \ @@ -6336,7 +6337,7 @@ iris_destroy_state(struct iris_context *ice) } for (int i = 0; i < PIPE_MAX_SHADER_IMAGES; i++) { pipe_resource_reference(&shs->image[i].base.resource, NULL); - pipe_resource_reference(&shs->image[i].surface_state.res, NULL); + pipe_resource_reference(&shs->image[i].surface_state.ref.res, NULL); } for (int i = 0; i < PIPE_MAX_SHADER_BUFFERS; i++) { pipe_resource_reference(&shs->ssbo[i].buffer, NULL); @@ -6467,7 +6468,7 @@ iris_rebind_buffer(struct iris_context *ice, if (res->bo == iris_resource_bo(isv->base.texture)) { void *map = alloc_surface_states(ice->state.surface_uploader, - &isv->surface_state, + &isv->surface_state.ref, isv->res->aux.sampler_usages); assert(map); fill_buffer_surface_state(&screen->isl_dev, isv->res, map, -- cgit v1.2.3