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:
@@ -963,6 +963,15 @@ struct iris_compiled_shader *iris_create_shader_variant(const struct iris_screen
|
|||||||
uint32_t key_size,
|
uint32_t key_size,
|
||||||
const void *key);
|
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,
|
void iris_upload_shader(struct iris_screen *screen,
|
||||||
struct iris_uncompiled_shader *,
|
struct iris_uncompiled_shader *,
|
||||||
struct iris_compiled_shader *,
|
struct iris_compiled_shader *,
|
||||||
@@ -971,14 +980,7 @@ void iris_upload_shader(struct iris_screen *screen,
|
|||||||
enum iris_program_cache_id,
|
enum iris_program_cache_id,
|
||||||
uint32_t key_size,
|
uint32_t key_size,
|
||||||
const void *key,
|
const void *key,
|
||||||
const void *assembly,
|
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);
|
|
||||||
void iris_delete_shader_variant(struct iris_compiled_shader *shader);
|
void iris_delete_shader_variant(struct iris_compiled_shader *shader);
|
||||||
|
|
||||||
void iris_destroy_shader_state(struct pipe_context *ctx, void *state);
|
void iris_destroy_shader_state(struct pipe_context *ctx, void *state);
|
||||||
|
@@ -239,14 +239,16 @@ iris_disk_cache_retrieve(struct iris_screen *screen,
|
|||||||
if (num_system_values || kernel_input_size)
|
if (num_system_values || kernel_input_size)
|
||||||
num_cbufs++;
|
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));
|
assert(stage < ARRAY_SIZE(cache_id_for_stage));
|
||||||
enum iris_program_cache_id cache_id = cache_id_for_stage[stage];
|
enum iris_program_cache_id cache_id = cache_id_for_stage[stage];
|
||||||
|
|
||||||
/* Upload our newly read shader to the in-memory program cache. */
|
/* Upload our newly read shader to the in-memory program cache. */
|
||||||
iris_upload_shader(screen, ish, shader, NULL, uploader,
|
iris_upload_shader(screen, ish, shader, NULL, uploader,
|
||||||
cache_id, key_size, prog_key, assembly,
|
cache_id, key_size, prog_key, assembly);
|
||||||
prog_data, so_decls, system_values,
|
|
||||||
num_system_values, kernel_input_size, num_cbufs, &bt);
|
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
|
@@ -69,6 +69,32 @@ get_new_program_id(struct iris_screen *screen)
|
|||||||
return p_atomic_inc_return(&screen->program_id);
|
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
|
static struct brw_vs_prog_key
|
||||||
iris_to_brw_vs_key(const struct intel_device_info *devinfo,
|
iris_to_brw_vs_key(const struct intel_device_info *devinfo,
|
||||||
const struct iris_vs_prog_key *key)
|
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,
|
screen->vtbl.create_so_decl_list(&ish->stream_output,
|
||||||
&vue_prog_data->vue_map);
|
&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,
|
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_VS,
|
||||||
sizeof(*key), key, program, prog_data, so_decls,
|
sizeof(*key), key, program);
|
||||||
system_values, num_system_values, 0, num_cbufs, &bt);
|
|
||||||
|
|
||||||
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
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_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_upload_shader(screen, ish, shader, passthrough_ht, uploader,
|
||||||
IRIS_CACHE_TCS, sizeof(*key), key, program, prog_data,
|
IRIS_CACHE_TCS, sizeof(*key), key, program);
|
||||||
NULL, system_values, num_system_values, 0, num_cbufs,
|
|
||||||
&bt);
|
|
||||||
|
|
||||||
if (ish)
|
if (ish)
|
||||||
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
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,
|
screen->vtbl.create_so_decl_list(&ish->stream_output,
|
||||||
&vue_prog_data->vue_map);
|
&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,
|
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_TES,
|
||||||
sizeof(*key), key, program, prog_data, so_decls,
|
sizeof(*key), key, program);
|
||||||
system_values, num_system_values, 0, num_cbufs, &bt);
|
|
||||||
|
|
||||||
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
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,
|
screen->vtbl.create_so_decl_list(&ish->stream_output,
|
||||||
&vue_prog_data->vue_map);
|
&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,
|
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_GS,
|
||||||
sizeof(*key), key, program, prog_data, so_decls,
|
sizeof(*key), key, program);
|
||||||
system_values, num_system_values, 0, num_cbufs, &bt);
|
|
||||||
|
|
||||||
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
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_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,
|
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_FS,
|
||||||
sizeof(*key), key, program, prog_data, NULL,
|
sizeof(*key), key, program);
|
||||||
system_values, num_system_values, 0, num_cbufs, &bt);
|
|
||||||
|
|
||||||
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
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_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,
|
iris_upload_shader(screen, ish, shader, NULL, uploader, IRIS_CACHE_CS,
|
||||||
sizeof(*key), key, program, prog_data, NULL,
|
sizeof(*key), key, program);
|
||||||
system_values, num_system_values, ish->kernel_input_size,
|
|
||||||
num_cbufs, &bt);
|
|
||||||
|
|
||||||
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
iris_disk_cache_store(screen->disk_cache, ish, shader, key, sizeof(*key));
|
||||||
|
|
||||||
|
@@ -155,26 +155,19 @@ iris_upload_shader(struct iris_screen *screen,
|
|||||||
enum iris_program_cache_id cache_id,
|
enum iris_program_cache_id cache_id,
|
||||||
uint32_t key_size,
|
uint32_t key_size,
|
||||||
const void *key,
|
const void *key,
|
||||||
const void *assembly,
|
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 struct intel_device_info *devinfo = &screen->devinfo;
|
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->assembly.offset, &shader->assembly.res,
|
||||||
&shader->map);
|
&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;
|
struct iris_resource *res = (void *) shader->assembly.res;
|
||||||
uint64_t shader_data_addr = res->bo->gtt_offset +
|
uint64_t shader_data_addr = res->bo->gtt_offset +
|
||||||
shader->assembly.offset +
|
shader->assembly.offset +
|
||||||
prog_data->const_data_offset;
|
shader->prog_data->const_data_offset;
|
||||||
|
|
||||||
struct brw_shader_reloc_value reloc_values[] = {
|
struct brw_shader_reloc_value reloc_values[] = {
|
||||||
{
|
{
|
||||||
@@ -186,23 +179,9 @@ iris_upload_shader(struct iris_screen *screen,
|
|||||||
.value = shader_data_addr >> 32,
|
.value = shader_data_addr >> 32,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
brw_write_shader_relocs(&screen->devinfo, shader->map, prog_data,
|
brw_write_shader_relocs(&screen->devinfo, shader->map,
|
||||||
reloc_values, ARRAY_SIZE(reloc_values));
|
shader->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);
|
|
||||||
|
|
||||||
/* Store the 3DSTATE shader packets and other derived state. */
|
/* Store the 3DSTATE shader packets and other derived state. */
|
||||||
screen->vtbl.store_derived_program_state(devinfo, cache_id, shader);
|
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,
|
iris_create_shader_variant(screen, ice->shaders.cache, IRIS_CACHE_BLORP,
|
||||||
key_size, key);
|
key_size, key);
|
||||||
|
|
||||||
|
iris_finalize_program(shader, prog_data, NULL, NULL, 0, 0, 0, &bt);
|
||||||
|
|
||||||
iris_upload_shader(screen, NULL, shader, ice->shaders.cache,
|
iris_upload_shader(screen, NULL, shader, ice->shaders.cache,
|
||||||
ice->shaders.uploader_driver,
|
ice->shaders.uploader_driver,
|
||||||
IRIS_CACHE_BLORP, key_size, key, kernel,
|
IRIS_CACHE_BLORP, key_size, key, kernel);
|
||||||
prog_data, NULL, NULL, 0, 0, 0, &bt);
|
|
||||||
|
|
||||||
struct iris_bo *bo = iris_resource_bo(shader->assembly.res);
|
struct iris_bo *bo = iris_resource_bo(shader->assembly.res);
|
||||||
*kernel_out =
|
*kernel_out =
|
||||||
|
Reference in New Issue
Block a user