From e45bf01940fa6692d4f1d9385c2d6466da06a9bb Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Sun, 19 May 2019 00:22:17 -0700 Subject: spirv: Change spirv_to_nir() to return a nir_shader spirv_to_nir() returned the nir_function corresponding to the entrypoint, as a way to identify it. There's now a bool is_entrypoint in nir_function and also a helper function to get the entry_point from a nir_shader. The return type reflects better what the function name suggests. It also helps drivers avoid the mistake of reusing internal shader references after running NIR_PASS on it. When using NIR_TEST_CLONE or NIR_TEST_SERIALIZE, those would be invalidated right in the first pass executed. Reviewed-by: Bas Nieuwenhuizen --- src/mesa/main/glspirv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index 8d1ac9b5072..bb5a3f7452b 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -186,8 +186,6 @@ _mesa_spirv_to_nir(struct gl_context *ctx, gl_shader_stage stage, const nir_shader_compiler_options *options) { - nir_shader *nir = NULL; - struct gl_linked_shader *linked_shader = prog->_LinkedShaders[stage]; assert (linked_shader); @@ -217,7 +215,7 @@ _mesa_spirv_to_nir(struct gl_context *ctx, .caps = ctx->Const.SpirVCapabilities }; - nir_function *entry_point = + nir_shader *nir = spirv_to_nir((const uint32_t *) &spirv_module->Binary[0], spirv_module->Length / 4, spec_entries, spirv_data->NumSpecializationConstants, @@ -226,8 +224,7 @@ _mesa_spirv_to_nir(struct gl_context *ctx, options); free(spec_entries); - assert (entry_point); - nir = entry_point->shader; + assert(nir); assert(nir->info.stage == stage); nir->options = options; -- cgit v1.2.3