spirv/nir: parse function control and store in nir.
This just lets the nir access the inline/dont inline attributes Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24687>
This commit is contained in:
@@ -485,6 +485,8 @@ nir_function_create(nir_shader *shader, const char *name)
|
||||
func->impl = NULL;
|
||||
func->is_entrypoint = false;
|
||||
func->is_preamble = false;
|
||||
func->dont_inline = false;
|
||||
func->should_inline = false;
|
||||
|
||||
return func;
|
||||
}
|
||||
|
@@ -3322,6 +3322,9 @@ typedef struct nir_function {
|
||||
|
||||
bool is_entrypoint;
|
||||
bool is_preamble;
|
||||
/* from SPIR-V function control */
|
||||
bool should_inline;
|
||||
bool dont_inline; /* from SPIR-V */
|
||||
} nir_function;
|
||||
|
||||
typedef enum {
|
||||
|
@@ -665,6 +665,8 @@ nir_function_clone(nir_shader *ns, const nir_function *fxn)
|
||||
}
|
||||
nfxn->is_entrypoint = fxn->is_entrypoint;
|
||||
nfxn->is_preamble = fxn->is_preamble;
|
||||
nfxn->should_inline = fxn->should_inline;
|
||||
nfxn->dont_inline = fxn->dont_inline;
|
||||
|
||||
/* At first glance, it looks like we should clone the function_impl here.
|
||||
* However, call instructions need to be able to reference at least the
|
||||
|
@@ -2148,8 +2148,9 @@ print_function(nir_function *function, print_state *state)
|
||||
{
|
||||
FILE *fp = state->fp;
|
||||
|
||||
fprintf(fp, "decl_function %s (%d params)", function->name,
|
||||
function->num_params);
|
||||
fprintf(fp, "decl_function %s (%d params) %s", function->name,
|
||||
function->num_params, function->dont_inline ? "(noinline)" :
|
||||
function->should_inline ? "(inline)" : "");
|
||||
|
||||
fprintf(fp, "\n");
|
||||
|
||||
|
@@ -1887,6 +1887,10 @@ write_function(write_ctx *ctx, const nir_function *fxn)
|
||||
flags |= 0x4;
|
||||
if (fxn->impl)
|
||||
flags |= 0x8;
|
||||
if (fxn->should_inline)
|
||||
flags |= 0x10;
|
||||
if (fxn->dont_inline)
|
||||
flags |= 0x20;
|
||||
blob_write_uint32(ctx->blob, flags);
|
||||
if (fxn->name)
|
||||
blob_write_string(ctx->blob, fxn->name);
|
||||
@@ -1931,6 +1935,8 @@ read_function(read_ctx *ctx)
|
||||
fxn->is_preamble = flags & 0x2;
|
||||
if (flags & 0x8)
|
||||
fxn->impl = NIR_SERIALIZE_FUNC_HAS_IMPL;
|
||||
fxn->should_inline = flags & 0x10;
|
||||
fxn->dont_inline = flags & 0x20;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -201,6 +201,9 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
|
||||
if (func_type->return_type->base_type != vtn_base_type_void)
|
||||
num_params++;
|
||||
|
||||
func->should_inline = b->func->control & SpvFunctionControlInlineMask;
|
||||
func->dont_inline = b->func->control & SpvFunctionControlDontInlineMask;
|
||||
|
||||
func->num_params = num_params;
|
||||
func->params = ralloc_array(b->shader, nir_parameter, num_params);
|
||||
|
||||
|
Reference in New Issue
Block a user