From: Jason Ekstrand Date: Tue, 11 Aug 2020 00:05:56 +0000 (-0500) Subject: iris: Add support for serialized NIR X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d62735b470c0851a567bd2cc0759c18af987923;p=mesa.git iris: Add support for serialized NIR Reviewed-by: Kenneth Graunke Part-of: --- diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index a9e464bcb46..f38afc5726d 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -2376,12 +2376,31 @@ static void * iris_create_compute_state(struct pipe_context *ctx, const struct pipe_compute_state *state) { - assert(state->ir_type == PIPE_SHADER_IR_NIR); - struct iris_context *ice = (void *) ctx; struct iris_screen *screen = (void *) ctx->screen; + const nir_shader_compiler_options *options = + screen->compiler->glsl_compiler_options[MESA_SHADER_COMPUTE].NirOptions; + + nir_shader *nir; + switch (state->ir_type) { + case PIPE_SHADER_IR_NIR: + nir = (void *)state->prog; + break; + + case PIPE_SHADER_IR_NIR_SERIALIZED: { + struct blob_reader reader; + const struct pipe_binary_program_header *hdr = state->prog; + blob_reader_init(&reader, hdr->blob, hdr->num_bytes); + nir = nir_deserialize(NULL, options, &reader); + break; + } + + default: + unreachable("Unsupported IR"); + } + struct iris_uncompiled_shader *ish = - iris_create_uncompiled_shader(ctx, (void *) state->prog, NULL); + iris_create_uncompiled_shader(ctx, nir, NULL); // XXX: disallow more than 64KB of shared variables diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index ca75a1308dd..c30626c132c 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -422,7 +422,8 @@ iris_get_shader_param(struct pipe_screen *pscreen, case PIPE_SHADER_CAP_PREFERRED_IR: return PIPE_SHADER_IR_NIR; case PIPE_SHADER_CAP_SUPPORTED_IRS: - return 1 << PIPE_SHADER_IR_NIR; + return (1 << PIPE_SHADER_IR_NIR) | + (1 << PIPE_SHADER_IR_NIR_SERIALIZED); case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED: case PIPE_SHADER_CAP_TGSI_LDEXP_SUPPORTED: return 1;