nir: add a flag for functions that are used in cmat calls.
With coopmat2 a bunch of functions need a lot of lowering passes to happen before they can be lowered, so mark them as to be lowered later. Drivers needing these should call the nir_remove_non_cmat_call_entrypoints where they remove entrypoints now, and call the original nir_remove_non_entrypoints after lowering coopmat2. Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38389>
This commit is contained in:
@@ -626,6 +626,7 @@ nir_function_create(nir_shader *shader, const char *name)
|
||||
func->params = NULL;
|
||||
func->impl = NULL;
|
||||
func->is_entrypoint = false;
|
||||
func->cmat_call = false;
|
||||
func->is_preamble = false;
|
||||
func->dont_inline = false;
|
||||
func->should_inline = false;
|
||||
@@ -3767,6 +3768,15 @@ nir_remove_non_entrypoints(nir_shader *nir)
|
||||
assert(exec_list_length(&nir->functions) == 1);
|
||||
}
|
||||
|
||||
void
|
||||
nir_remove_non_cmat_call_entrypoints(nir_shader *nir)
|
||||
{
|
||||
nir_foreach_function_safe(func, nir) {
|
||||
if (!func->is_entrypoint && !func->cmat_call)
|
||||
exec_node_remove(&func->node);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nir_remove_non_exported(nir_shader *nir)
|
||||
{
|
||||
|
||||
@@ -3811,6 +3811,8 @@ typedef struct nir_function {
|
||||
uint32_t driver_attributes;
|
||||
|
||||
bool is_entrypoint;
|
||||
/* called by a cmat call */
|
||||
bool cmat_call;
|
||||
/* from SPIR-V linkage, only for libraries */
|
||||
bool is_exported;
|
||||
bool is_preamble;
|
||||
@@ -4013,6 +4015,7 @@ nir_shader_get_function_for_name(const nir_shader *shader, const char *name)
|
||||
* functions from a shader and library respectively.
|
||||
*/
|
||||
void nir_remove_non_entrypoints(nir_shader *shader);
|
||||
void nir_remove_non_cmat_call_entrypoints(nir_shader *nir);
|
||||
void nir_remove_non_exported(nir_shader *shader);
|
||||
void nir_remove_entrypoints(nir_shader *shader);
|
||||
void nir_fixup_is_exported(nir_shader *shader);
|
||||
|
||||
@@ -758,6 +758,7 @@ nir_function_clone(nir_shader *ns, const nir_function *fxn)
|
||||
}
|
||||
}
|
||||
nfxn->is_entrypoint = fxn->is_entrypoint;
|
||||
nfxn->cmat_call = fxn->cmat_call;
|
||||
nfxn->is_preamble = fxn->is_preamble;
|
||||
nfxn->should_inline = fxn->should_inline;
|
||||
nfxn->dont_inline = fxn->dont_inline;
|
||||
|
||||
@@ -2026,6 +2026,8 @@ write_function(write_ctx *ctx, const nir_function *fxn)
|
||||
flags |= 0x80;
|
||||
if (fxn->workgroup_size[0] || fxn->workgroup_size[1] || fxn->workgroup_size[2])
|
||||
flags |= 0x100;
|
||||
if (fxn->cmat_call)
|
||||
flags |= 0x200;
|
||||
blob_write_uint32(ctx->blob, flags);
|
||||
if (fxn->name && !ctx->strip)
|
||||
blob_write_string(ctx->blob, fxn->name);
|
||||
@@ -2128,6 +2130,7 @@ read_function(read_ctx *ctx)
|
||||
fxn->dont_inline = flags & 0x20;
|
||||
fxn->is_subroutine = flags & 0x40;
|
||||
fxn->is_tmp_globals_wrapper = flags & 0x80;
|
||||
fxn->cmat_call = flags & 0x200;
|
||||
return fxn;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user