iris: Extract allocation bits from iris_upload_shader to iris_create_shader_variant
The added assertion in iris_create_shader_variant helped catch a bug in the next commit. v2: Drop (unnecessary) initialization of shader->assembly.res when moving to iris_create_shader_variant. Suggested by Ken. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11229>
This commit is contained in:
parent
d0fac4e4f8
commit
ca19be1a8d
|
@ -940,6 +940,13 @@ struct iris_compiled_shader *iris_find_cached_shader(struct iris_context *ice,
|
|||
enum iris_program_cache_id,
|
||||
uint32_t key_size,
|
||||
const void *key);
|
||||
|
||||
struct iris_compiled_shader *iris_create_shader_variant(const struct iris_screen *,
|
||||
void *mem_ctx,
|
||||
enum iris_program_cache_id cache_id,
|
||||
uint32_t key_size,
|
||||
const void *key);
|
||||
|
||||
struct iris_compiled_shader *iris_upload_shader(struct iris_screen *screen,
|
||||
struct iris_uncompiled_shader *,
|
||||
struct hash_table *driver_ht,
|
||||
|
|
|
@ -106,6 +106,43 @@ iris_delete_shader_variant(struct iris_compiled_shader *shader)
|
|||
ralloc_free(shader);
|
||||
}
|
||||
|
||||
struct iris_compiled_shader *
|
||||
iris_create_shader_variant(const struct iris_screen *screen,
|
||||
void *mem_ctx,
|
||||
enum iris_program_cache_id cache_id,
|
||||
uint32_t key_size,
|
||||
const void *key)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (cache_id == IRIS_CACHE_BLORP) {
|
||||
/* Blorp shader must have a mem_ctx. */
|
||||
assert(mem_ctx != NULL);
|
||||
} else if (cache_id == IRIS_CACHE_TCS) {
|
||||
/* Pass-through tessellation control shaders (generated by the driver)
|
||||
* will have a mem_ctx, and other tessellation control shaders will not.
|
||||
*/
|
||||
} else {
|
||||
/* Shaders that are neither blorp nor tessellation control must not have
|
||||
* a mem_ctx.
|
||||
*/
|
||||
assert(mem_ctx == NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct iris_compiled_shader *shader =
|
||||
rzalloc_size(mem_ctx, sizeof(struct iris_compiled_shader) +
|
||||
screen->vtbl.derived_program_state_size(cache_id));
|
||||
|
||||
pipe_reference_init(&shader->ref, 1);
|
||||
|
||||
if (cache_id != IRIS_CACHE_BLORP) {
|
||||
assert(key_size <= sizeof(union iris_any_prog_key));
|
||||
memcpy(&shader->key, key, key_size);
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
struct iris_compiled_shader *
|
||||
iris_upload_shader(struct iris_screen *screen,
|
||||
struct iris_uncompiled_shader *ish,
|
||||
|
@ -126,13 +163,10 @@ iris_upload_shader(struct iris_screen *screen,
|
|||
const struct intel_device_info *devinfo = &screen->devinfo;
|
||||
|
||||
void *mem_ctx = ish ? NULL : (void *) driver_shaders;
|
||||
|
||||
struct iris_compiled_shader *shader =
|
||||
rzalloc_size(mem_ctx, sizeof(struct iris_compiled_shader) +
|
||||
screen->vtbl.derived_program_state_size(cache_id));
|
||||
iris_create_shader_variant(screen, mem_ctx, cache_id, key_size, key);
|
||||
|
||||
pipe_reference_init(&shader->ref, 1);
|
||||
|
||||
shader->assembly.res = NULL;
|
||||
u_upload_alloc(uploader, 0, prog_data->program_size, 64,
|
||||
&shader->assembly.offset, &shader->assembly.res,
|
||||
&shader->map);
|
||||
|
@ -175,9 +209,6 @@ iris_upload_shader(struct iris_screen *screen,
|
|||
screen->vtbl.store_derived_program_state(devinfo, cache_id, shader);
|
||||
|
||||
if (ish) {
|
||||
assert(key_size <= sizeof(union iris_any_prog_key));
|
||||
memcpy(&shader->key, key, key_size);
|
||||
|
||||
simple_mtx_lock(&ish->lock);
|
||||
|
||||
/* While unlikely, it's possible that another thread concurrently
|
||||
|
|
Loading…
Reference in New Issue