diff options
author | Jason Ekstrand <[email protected]> | 2017-05-08 09:20:21 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-05-09 15:07:47 -0700 |
commit | b86dba8a0eee6be283a96481c0c2b1fb1e882824 (patch) | |
tree | 5a8bfc6bff9ef65ab733327305026f2731f3096e /src/compiler/spirv | |
parent | d4fa0a0fa63c538b0c67ec3c46a45c1e4dcf91fc (diff) |
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 <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 48 | ||||
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 14 |
2 files changed, 31 insertions, 31 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index c120ad6d19d..0a5eb0eb6b0 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1017,9 +1017,9 @@ handle_workgroup_size_decoration_cb(struct vtn_builder *b, assert(val->const_type == glsl_vector_type(GLSL_TYPE_UINT, 3)); - b->shader->info->cs.local_size[0] = val->constant->values[0].u32[0]; - b->shader->info->cs.local_size[1] = val->constant->values[0].u32[1]; - b->shader->info->cs.local_size[2] = val->constant->values[0].u32[2]; + b->shader->info.cs.local_size[0] = val->constant->values[0].u32[0]; + b->shader->info.cs.local_size[1] = val->constant->values[0].u32[1]; + b->shader->info.cs.local_size[2] = val->constant->values[0].u32[2]; } static void @@ -2808,36 +2808,36 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, case SpvExecutionModeEarlyFragmentTests: assert(b->shader->stage == MESA_SHADER_FRAGMENT); - b->shader->info->fs.early_fragment_tests = true; + b->shader->info.fs.early_fragment_tests = true; break; case SpvExecutionModeInvocations: assert(b->shader->stage == MESA_SHADER_GEOMETRY); - b->shader->info->gs.invocations = MAX2(1, mode->literals[0]); + b->shader->info.gs.invocations = MAX2(1, mode->literals[0]); break; case SpvExecutionModeDepthReplacing: assert(b->shader->stage == MESA_SHADER_FRAGMENT); - b->shader->info->fs.depth_layout = FRAG_DEPTH_LAYOUT_ANY; + b->shader->info.fs.depth_layout = FRAG_DEPTH_LAYOUT_ANY; break; case SpvExecutionModeDepthGreater: assert(b->shader->stage == MESA_SHADER_FRAGMENT); - b->shader->info->fs.depth_layout = FRAG_DEPTH_LAYOUT_GREATER; + b->shader->info.fs.depth_layout = FRAG_DEPTH_LAYOUT_GREATER; break; case SpvExecutionModeDepthLess: assert(b->shader->stage == MESA_SHADER_FRAGMENT); - b->shader->info->fs.depth_layout = FRAG_DEPTH_LAYOUT_LESS; + b->shader->info.fs.depth_layout = FRAG_DEPTH_LAYOUT_LESS; break; case SpvExecutionModeDepthUnchanged: assert(b->shader->stage == MESA_SHADER_FRAGMENT); - b->shader->info->fs.depth_layout = FRAG_DEPTH_LAYOUT_UNCHANGED; + b->shader->info.fs.depth_layout = FRAG_DEPTH_LAYOUT_UNCHANGED; break; case SpvExecutionModeLocalSize: assert(b->shader->stage == MESA_SHADER_COMPUTE); - b->shader->info->cs.local_size[0] = mode->literals[0]; - b->shader->info->cs.local_size[1] = mode->literals[1]; - b->shader->info->cs.local_size[2] = mode->literals[2]; + b->shader->info.cs.local_size[0] = mode->literals[0]; + b->shader->info.cs.local_size[1] = mode->literals[1]; + b->shader->info.cs.local_size[2] = mode->literals[2]; break; case SpvExecutionModeLocalSizeHint: break; /* Nothing to do with this */ @@ -2845,10 +2845,10 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, case SpvExecutionModeOutputVertices: if (b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL) { - b->shader->info->tess.tcs_vertices_out = mode->literals[0]; + b->shader->info.tess.tcs_vertices_out = mode->literals[0]; } else { assert(b->shader->stage == MESA_SHADER_GEOMETRY); - b->shader->info->gs.vertices_out = mode->literals[0]; + b->shader->info.gs.vertices_out = mode->literals[0]; } break; @@ -2861,11 +2861,11 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, case SpvExecutionModeIsolines: if (b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL) { - b->shader->info->tess.primitive_mode = + b->shader->info.tess.primitive_mode = gl_primitive_from_spv_execution_mode(mode->exec_mode); } else { assert(b->shader->stage == MESA_SHADER_GEOMETRY); - b->shader->info->gs.vertices_in = + b->shader->info.gs.vertices_in = vertices_in_from_spv_execution_mode(mode->exec_mode); } break; @@ -2874,24 +2874,24 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, case SpvExecutionModeOutputLineStrip: case SpvExecutionModeOutputTriangleStrip: assert(b->shader->stage == MESA_SHADER_GEOMETRY); - b->shader->info->gs.output_primitive = + b->shader->info.gs.output_primitive = gl_primitive_from_spv_execution_mode(mode->exec_mode); break; case SpvExecutionModeSpacingEqual: assert(b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL); - b->shader->info->tess.spacing = TESS_SPACING_EQUAL; + b->shader->info.tess.spacing = TESS_SPACING_EQUAL; break; case SpvExecutionModeSpacingFractionalEven: assert(b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL); - b->shader->info->tess.spacing = TESS_SPACING_FRACTIONAL_EVEN; + b->shader->info.tess.spacing = TESS_SPACING_FRACTIONAL_EVEN; break; case SpvExecutionModeSpacingFractionalOdd: assert(b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL); - b->shader->info->tess.spacing = TESS_SPACING_FRACTIONAL_ODD; + b->shader->info.tess.spacing = TESS_SPACING_FRACTIONAL_ODD; break; case SpvExecutionModeVertexOrderCw: assert(b->shader->stage == MESA_SHADER_TESS_CTRL || @@ -2900,18 +2900,18 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, * but be the opposite of OpenGL. Currently NIR follows GL semantics, * so we set it backwards here. */ - b->shader->info->tess.ccw = true; + b->shader->info.tess.ccw = true; break; case SpvExecutionModeVertexOrderCcw: assert(b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL); /* Backwards; see above */ - b->shader->info->tess.ccw = false; + b->shader->info.tess.ccw = false; break; case SpvExecutionModePointMode: assert(b->shader->stage == MESA_SHADER_TESS_CTRL || b->shader->stage == MESA_SHADER_TESS_EVAL); - b->shader->info->tess.point_mode = true; + b->shader->info.tess.point_mode = true; break; case SpvExecutionModePixelCenterInteger: @@ -3287,7 +3287,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count, b->shader = nir_shader_create(NULL, stage, options, NULL); /* Set shader info defaults */ - b->shader->info->gs.invocations = 1; + b->shader->info.gs.invocations = 1; /* Parse execution modes */ vtn_foreach_execution_mode(b, b->entry_point, diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 365e562386f..0f0cc1cd5c4 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1094,9 +1094,9 @@ apply_var_decoration(struct vtn_builder *b, nir_variable *nir_var, nir_var->data.read_only = true; nir_constant *c = rzalloc(nir_var, nir_constant); - c->values[0].u32[0] = b->shader->info->cs.local_size[0]; - c->values[0].u32[1] = b->shader->info->cs.local_size[1]; - c->values[0].u32[2] = b->shader->info->cs.local_size[2]; + c->values[0].u32[0] = b->shader->info.cs.local_size[0]; + c->values[0].u32[1] = b->shader->info.cs.local_size[1]; + c->values[0].u32[2] = b->shader->info.cs.local_size[2]; nir_var->constant_initializer = c; break; } @@ -1335,18 +1335,18 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, case SpvStorageClassUniformConstant: if (without_array->block) { var->mode = vtn_variable_mode_ubo; - b->shader->info->num_ubos++; + b->shader->info.num_ubos++; } else if (without_array->buffer_block) { var->mode = vtn_variable_mode_ssbo; - b->shader->info->num_ssbos++; + b->shader->info.num_ssbos++; } else if (glsl_type_is_image(without_array->type)) { var->mode = vtn_variable_mode_image; nir_mode = nir_var_uniform; - b->shader->info->num_images++; + b->shader->info.num_images++; } else if (glsl_type_is_sampler(without_array->type)) { var->mode = vtn_variable_mode_sampler; nir_mode = nir_var_uniform; - b->shader->info->num_textures++; + b->shader->info.num_textures++; } else { assert(!"Invalid uniform variable type"); } |