mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-15 19:40:30 +01:00
kk: Bundle nir_to_msl options into a struct for easier option addition
Reviewed-by: Arcady Goldmints-Orlov <arcady@lunarg.com> Signed-off-by: Aitor Camacho <aitor@lunarg.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39301>
This commit is contained in:
parent
f35f50af72
commit
8147ea59fe
4 changed files with 21 additions and 8 deletions
|
|
@ -2064,7 +2064,7 @@ predeclare_ssa_values(struct nir_to_msl_ctx *ctx, nir_function_impl *impl)
|
|||
}
|
||||
|
||||
char *
|
||||
nir_to_msl(nir_shader *shader, void *mem_ctx, uint64_t disabled_workarounds)
|
||||
nir_to_msl(nir_shader *shader, struct nir_to_msl_options *options)
|
||||
{
|
||||
/* Need to rename the entrypoint here since hardcoded shaders used by vk_meta
|
||||
* don't go through the preprocess step since we are the ones creating them.
|
||||
|
|
@ -2073,8 +2073,8 @@ nir_to_msl(nir_shader *shader, void *mem_ctx, uint64_t disabled_workarounds)
|
|||
|
||||
struct nir_to_msl_ctx ctx = {
|
||||
.shader = shader,
|
||||
.text = _mesa_string_buffer_create(mem_ctx, 1024),
|
||||
.disabled_workarounds = disabled_workarounds,
|
||||
.text = _mesa_string_buffer_create(options->mem_ctx, 1024),
|
||||
.disabled_workarounds = options->disabled_workarounds,
|
||||
};
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
msl_gather_info(&ctx);
|
||||
|
|
@ -2109,7 +2109,7 @@ nir_to_msl(nir_shader *shader, void *mem_ctx, uint64_t disabled_workarounds)
|
|||
P(&ctx, "}\n");
|
||||
char *ret = ctx.text->buf;
|
||||
_mesa_hash_table_destroy(ctx.types, NULL);
|
||||
ralloc_steal(mem_ctx, ctx.text->buf);
|
||||
ralloc_steal(options->mem_ctx, ctx.text->buf);
|
||||
ralloc_free(ctx.text);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,13 @@
|
|||
|
||||
enum pipe_format;
|
||||
|
||||
struct nir_to_msl_options {
|
||||
void *mem_ctx;
|
||||
uint64_t disabled_workarounds;
|
||||
};
|
||||
|
||||
/* Assumes nir_shader_gather_info has been called beforehand. */
|
||||
char *nir_to_msl(nir_shader *shader, void *mem_ctx,
|
||||
uint64_t disabled_workarounds);
|
||||
char *nir_to_msl(nir_shader *shader, struct nir_to_msl_options *options);
|
||||
|
||||
/* Call this after all API-specific lowerings. It will bring the NIR out of SSA
|
||||
* at the end */
|
||||
|
|
|
|||
|
|
@ -177,7 +177,11 @@ main(int argc, char **argv)
|
|||
optimize(shader);
|
||||
nir_print_shader(shader, stdout);
|
||||
|
||||
char *msl_text = nir_to_msl(shader, shader, 0u);
|
||||
struct nir_to_msl_options translate_options = {
|
||||
.mem_ctx = shader,
|
||||
.disabled_workarounds = 0u,
|
||||
};
|
||||
char *msl_text = nir_to_msl(shader, &translate_options);
|
||||
|
||||
fputs(msl_text, stdout);
|
||||
|
||||
|
|
|
|||
|
|
@ -680,7 +680,12 @@ kk_compile_shader(struct kk_device *dev, struct vk_shader_compile_info *info,
|
|||
msl_lower_nir_late(nir);
|
||||
msl_optimize_nir(nir);
|
||||
modify_nir_info(nir);
|
||||
shader->msl_code = nir_to_msl(nir, NULL, dev->disabled_workarounds);
|
||||
|
||||
struct nir_to_msl_options translate_options = {
|
||||
.mem_ctx = NULL,
|
||||
.disabled_workarounds = dev->disabled_workarounds,
|
||||
};
|
||||
shader->msl_code = nir_to_msl(nir, &translate_options);
|
||||
const char *entrypoint_name = nir_shader_get_entrypoint(nir)->function->name;
|
||||
|
||||
/* We need to steal so it doesn't get destroyed with the nir. Needs to happen
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue