iris: Split iris_upload_shader in two

Now the part that uploads the shader and the part that finishes the
creation of the shader are separated.  Each now has a more reasonable
number of parameters.

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11229>
This commit is contained in:
Ian Romanick 2021-06-28 11:51:10 -07:00 committed by Marge Bot
parent 42c34e1ac8
commit dff0d9911d
4 changed files with 76 additions and 55 deletions

View File

@ -963,6 +963,15 @@ struct iris_compiled_shader *iris_create_shader_variant(const struct iris_screen
uint32_t key_size,
const void *key);
void iris_finalize_program(struct iris_compiled_shader *shader,
struct brw_stage_prog_data *prog_data,
uint32_t *streamout,
enum brw_param_builtin *system_values,
unsigned num_system_values,
unsigned kernel_input_size,
unsigned num_cbufs,
const struct iris_binding_table *bt);
void iris_upload_shader(struct iris_screen *screen,
struct iris_uncompiled_shader *,
struct iris_compiled_shader *,
@ -971,14 +980,7 @@ void iris_upload_shader(struct iris_screen *screen,
enum iris_program_cache_id,
uint32_t key_size,
const void *key,
const void *assembly,
struct brw_stage_prog_data *,
uint32_t *streamout,
enum brw_param_builtin *sysv,
unsigned num_system_values,
unsigned kernel_input_size,
unsigned num_cbufs,
const struct iris_binding_table *bt);
const void *assembly);
void iris_delete_shader_variant(struct iris_compiled_shader *shader);
void iris_destroy_shader_state(struct pipe_context *ctx, void *state);

View File

@ -239,14 +239,16 @@ iris_disk_cache_retrieve(struct iris_screen *screen,
if (num_system_values || kernel_input_size)
num_cbufs++;
iris_finalize_program(shader, prog_data, so_decls, system_values,
num_system_values, kernel_input_size, num_cbufs,
&bt);
assert(stage < ARRAY_SIZE(cache_id_for_stage));
enum iris_program_cache_id cache_id = cache_id_for_stage[stage];
/* Upload our newly read shader to the in-memory program cache. */
iris_upload_shader(screen, ish, shader, NULL, uploader,
cache_id, key_size, prog_key, assembly,
prog_data, so_decls, system_values,
num_system_values, kernel_input_size, num_cbufs, &bt);
cache_id, key_size, prog_key, assembly);
free(buffer);

View File

@ -69,6 +69,32 @@ get_new_program_id(struct iris_screen *screen)
return p_atomic_inc_return(&screen->program_id);
}
void
iris_finalize_program(struct iris_compiled_shader *shader,
struct brw_stage_prog_data *prog_data,
uint32_t *streamout,
enum brw_param_builtin *system_values,
unsigned num_system_values,
unsigned kernel_input_size,
unsigned num_cbufs,
const struct iris_binding_table *bt)
{
shader->prog_data = prog_data;
shader->streamout = streamout;
shader->system_values = system_values;
shader->num_system_values = num_system_values;
shader->kernel_input_size = kernel_input_size;
shader->num_cbufs = num_cbufs;
shader->bt = *bt;
ralloc_steal(shader, shader->prog_data);
ralloc_steal(shader->prog_data, (void *)prog_data->relocs);
ralloc_steal(shader->prog_data, prog_data->param);
ralloc_steal(shader->prog_data, prog_data->pull_param);
ralloc_steal(shader, shader->streamout);
ralloc_steal(shader, shader->system_values);
}
static struct brw_vs_prog_key
iris_to_brw_vs_key(const struct intel_device_info *devinfo,
const struct iris_vs_prog_key *key)
@ -1296,9 +1322,11 @@ iris_compile_vs(struct iris_screen *screen,
screen->vtbl.create_so_decl_list(&ish->stream_output,
&vue_prog_data->vue_map);
iris_finalize_program(shader, prog_data, so_decls, system_values,
num_system_values, 0, num_cbufs, &bt);
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_VS,
sizeof(*key), key, program, prog_data, so_decls,
system_values, num_system_values, 0, num_cbufs, &bt);
sizeof(*key), key, program);
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
@ -1491,10 +1519,11 @@ iris_compile_tcs(struct iris_screen *screen,
iris_debug_recompile(screen, dbg, ish, &brw_key.base);
iris_finalize_program(shader, prog_data, NULL, system_values,
num_system_values, 0, num_cbufs, &bt);
iris_upload_shader(screen, ish, shader, passthrough_ht, uploader,
IRIS_CACHE_TCS, sizeof(*key), key, program, prog_data,
NULL, system_values, num_system_values, 0, num_cbufs,
&bt);
IRIS_CACHE_TCS, sizeof(*key), key, program);
if (ish)
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
@ -1651,9 +1680,11 @@ iris_compile_tes(struct iris_screen *screen,
screen->vtbl.create_so_decl_list(&ish->stream_output,
&vue_prog_data->vue_map);
iris_finalize_program(shader, prog_data, so_decls, system_values,
num_system_values, 0, num_cbufs, &bt);
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_TES,
sizeof(*key), key, program, prog_data, so_decls,
system_values, num_system_values, 0, num_cbufs, &bt);
sizeof(*key), key, program);
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
@ -1782,9 +1813,11 @@ iris_compile_gs(struct iris_screen *screen,
screen->vtbl.create_so_decl_list(&ish->stream_output,
&vue_prog_data->vue_map);
iris_finalize_program(shader, prog_data, so_decls, system_values,
num_system_values, 0, num_cbufs, &bt);
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_GS,
sizeof(*key), key, program, prog_data, so_decls,
system_values, num_system_values, 0, num_cbufs, &bt);
sizeof(*key), key, program);
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
@ -1916,9 +1949,11 @@ iris_compile_fs(struct iris_screen *screen,
iris_debug_recompile(screen, dbg, ish, &brw_key.base);
iris_finalize_program(shader, prog_data, NULL, system_values,
num_system_values, 0, num_cbufs, &bt);
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_FS,
sizeof(*key), key, program, prog_data, NULL,
system_values, num_system_values, 0, num_cbufs, &bt);
sizeof(*key), key, program);
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
@ -2186,10 +2221,12 @@ iris_compile_cs(struct iris_screen *screen,
iris_debug_recompile(screen, dbg, ish, &brw_key.base);
iris_finalize_program(shader, prog_data, NULL, system_values,
num_system_values, ish->kernel_input_size, num_cbufs,
&bt);
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_CS,
sizeof(*key), key, program, prog_data, NULL,
system_values, num_system_values, ish->kernel_input_size,
num_cbufs, &bt);
sizeof(*key), key, program);
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));

View File

@ -155,26 +155,19 @@ iris_upload_shader(struct iris_screen *screen,
enum iris_program_cache_id cache_id,
uint32_t key_size,
const void *key,
const void *assembly,
struct brw_stage_prog_data *prog_data,
uint32_t *streamout,
enum brw_param_builtin *system_values,
unsigned num_system_values,
unsigned kernel_input_size,
unsigned num_cbufs,
const struct iris_binding_table *bt)
const void *assembly)
{
const struct intel_device_info *devinfo = &screen->devinfo;
u_upload_alloc(uploader, 0, prog_data->program_size, 64,
u_upload_alloc(uploader, 0, shader->prog_data->program_size, 64,
&shader->assembly.offset, &shader->assembly.res,
&shader->map);
memcpy(shader->map, assembly, prog_data->program_size);
memcpy(shader->map, assembly, shader->prog_data->program_size);
struct iris_resource *res = (void *) shader->assembly.res;
uint64_t shader_data_addr = res->bo->gtt_offset +
shader->assembly.offset +
prog_data->const_data_offset;
shader->prog_data->const_data_offset;
struct brw_shader_reloc_value reloc_values[] = {
{
@ -186,23 +179,9 @@ iris_upload_shader(struct iris_screen *screen,
.value = shader_data_addr >> 32,
},
};
brw_write_shader_relocs(&screen->devinfo, shader->map, prog_data,
reloc_values, ARRAY_SIZE(reloc_values));
shader->prog_data = prog_data;
shader->streamout = streamout;
shader->system_values = system_values;
shader->num_system_values = num_system_values;
shader->kernel_input_size = kernel_input_size;
shader->num_cbufs = num_cbufs;
shader->bt = *bt;
ralloc_steal(shader, shader->prog_data);
ralloc_steal(shader->prog_data, (void *)prog_data->relocs);
ralloc_steal(shader->prog_data, prog_data->param);
ralloc_steal(shader->prog_data, prog_data->pull_param);
ralloc_steal(shader, shader->streamout);
ralloc_steal(shader, shader->system_values);
brw_write_shader_relocs(&screen->devinfo, shader->map,
shader->prog_data, reloc_values,
ARRAY_SIZE(reloc_values));
/* Store the 3DSTATE shader packets and other derived state. */
screen->vtbl.store_derived_program_state(devinfo, cache_id, shader);
@ -262,10 +241,11 @@ iris_blorp_upload_shader(struct blorp_batch *blorp_batch, uint32_t stage,
iris_create_shader_variant(screen, ice->shaders.cache, IRIS_CACHE_BLORP,
key_size, key);
iris_finalize_program(shader, prog_data, NULL, NULL, 0, 0, 0, &bt);
iris_upload_shader(screen, NULL, shader, ice->shaders.cache,
ice->shaders.uploader_driver,
IRIS_CACHE_BLORP, key_size, key, kernel,
prog_data, NULL, NULL, 0, 0, 0, &bt);
IRIS_CACHE_BLORP, key_size, key, kernel);
struct iris_bo *bo = iris_resource_bo(shader->assembly.res);
*kernel_out =