From b86dba8a0eee6be283a96481c0c2b1fb1e882824 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 8 May 2017 09:20:21 -0700 Subject: nir: Embed the shader_info in the nir_shader again Commit e1af20f18a86f52a9640faf2d4ff8a71b0a4fa9b changed the shader_info from being embedded into being just a pointer. The idea was that sharing the shader_info between NIR and GLSL would be easier if it were a pointer pointing to the same shader_info struct. This, however, has caused a few problems: 1) There are many things which generate NIR without GLSL. This means we have to support both NIR shaders which come from GLSL and ones that don't and need to have an info elsewhere. 2) The solution to (1) raises all sorts of ownership issues which have to be resolved with ralloc_parent checks. 3) Ever since 00620782c92100d77c660f9783504c6d80fa1d58, we've been using nir_gather_info to fill out the final shader_info. Thanks to cloning and the above ownership issues, the nir_shader::info may not point back to the gl_shader anymore and so we have to do a copy of the shader_info from NIR back to GLSL anyway. All of these issues go away if we just embed the shader_info in the nir_shader. There's a little downside of having to copy it back after calling nir_gather_info but, as explained above, we have to do that anyway. Acked-by: Timothy Arceri Reviewed-by: Kenneth Graunke --- src/compiler/glsl/glsl_to_nir.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/compiler/glsl/glsl_to_nir.cpp') diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 307276555ee..6513484fa01 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -133,13 +133,13 @@ static void nir_remap_attributes(nir_shader *shader) { nir_foreach_variable(var, &shader->inputs) { - var->data.location += _mesa_bitcount_64(shader->info->double_inputs_read & + var->data.location += _mesa_bitcount_64(shader->info.double_inputs_read & BITFIELD64_MASK(var->data.location)); } /* Once the remap is done, reset double_inputs_read, so later it will have * which location/slots are doubles */ - shader->info->double_inputs_read = 0; + shader->info.double_inputs_read = 0; } nir_shader * @@ -166,10 +166,10 @@ glsl_to_nir(const struct gl_shader_program *shader_prog, if (shader->stage == MESA_SHADER_VERTEX) nir_remap_attributes(shader); - shader->info->name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name); + shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name); if (shader_prog->Label) - shader->info->label = ralloc_strdup(shader, shader_prog->Label); - shader->info->has_transform_feedback_varyings = + shader->info.label = ralloc_strdup(shader, shader_prog->Label); + shader->info.has_transform_feedback_varyings = shader_prog->TransformFeedback.NumVarying > 0; return shader; @@ -368,7 +368,7 @@ nir_visitor::visit(ir_variable *ir) if (glsl_type_is_dual_slot(glsl_without_array(var->type))) { for (uint i = 0; i < glsl_count_attribute_slots(var->type, true); i++) { uint64_t bitfield = BITFIELD64_BIT(var->data.location + i); - shader->info->double_inputs_read |= bitfield; + shader->info.double_inputs_read |= bitfield; } } break; -- cgit v1.2.3