summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-10-13 11:41:23 +1100
committerTimothy Arceri <[email protected]>2016-10-26 14:29:36 +1100
commite1af20f18a86f52a9640faf2d4ff8a71b0a4fa9b (patch)
tree32b4e9dbc9c03aa7733e1e32721d92c3c54571e0 /src/compiler/nir
parent094fe3a9591ce200162d955635eee577c13f9324 (diff)
nir/i965/anv/radv/gallium: make shader info a pointer
When restoring something from shader cache we won't have and don't want to create a nir_shader this change detaches the two. There are other advantages such as being able to reuse the shader info populated by GLSL IR. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.c6
-rw-r--r--src/compiler/nir/nir.h5
-rw-r--r--src/compiler/nir/nir_builder.h2
-rw-r--r--src/compiler/nir/nir_clone.c8
-rw-r--r--src/compiler/nir/nir_gather_info.c30
-rw-r--r--src/compiler/nir/nir_lower_bitmap.c2
-rw-r--r--src/compiler/nir/nir_lower_clip.c2
-rw-r--r--src/compiler/nir/nir_lower_gs_intrinsics.c3
-rw-r--r--src/compiler/nir/nir_lower_system_values.c12
-rw-r--r--src/compiler/nir/nir_print.c8
-rw-r--r--src/compiler/nir/nir_sweep.c6
11 files changed, 45 insertions, 39 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 098e1b2759e..09aad57e87f 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -32,7 +32,8 @@
nir_shader *
nir_shader_create(void *mem_ctx,
gl_shader_stage stage,
- const nir_shader_compiler_options *options)
+ const nir_shader_compiler_options *options,
+ shader_info *si)
{
nir_shader *shader = ralloc(mem_ctx, nir_shader);
@@ -42,7 +43,8 @@ nir_shader_create(void *mem_ctx,
exec_list_make_empty(&shader->shared);
shader->options = options;
- memset(&shader->info, 0, sizeof(shader->info));
+
+ shader->info = si ? si : rzalloc(shader, shader_info);
exec_list_make_empty(&shader->functions);
exec_list_make_empty(&shader->registers);
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 04b0301367a..54302f82a9a 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1805,7 +1805,7 @@ typedef struct nir_shader {
const struct nir_shader_compiler_options *options;
/** Various bits of compile-time information about a given shader */
- struct shader_info info;
+ struct shader_info *info;
/** list of global variables in the shader (nir_variable) */
struct exec_list globals;
@@ -1848,7 +1848,8 @@ nir_shader_get_entrypoint(nir_shader *shader)
nir_shader *nir_shader_create(void *mem_ctx,
gl_shader_stage stage,
- const nir_shader_compiler_options *options);
+ const nir_shader_compiler_options *options,
+ shader_info *si);
/** creates a register, including assigning it an index and adding it to the list */
nir_register *nir_global_reg_create(nir_shader *shader);
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 040f03ef9d3..0ee7d1a6f39 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -52,7 +52,7 @@ nir_builder_init_simple_shader(nir_builder *build, void *mem_ctx,
gl_shader_stage stage,
const nir_shader_compiler_options *options)
{
- build->shader = nir_shader_create(mem_ctx, stage, options);
+ build->shader = nir_shader_create(mem_ctx, stage, options, NULL);
nir_function *func = nir_function_create(build->shader, "main");
build->exact = false;
build->impl = nir_function_impl_create(func);
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index 0e397b03821..f23fabc7015 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -682,7 +682,7 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
clone_state state;
init_clone_state(&state, true);
- nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options);
+ nir_shader *ns = nir_shader_create(mem_ctx, s->stage, s->options, NULL);
state.ns = ns;
clone_var_list(&state, &ns->uniforms, &s->uniforms);
@@ -711,9 +711,9 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
ns->reg_alloc = s->reg_alloc;
ns->info = s->info;
- ns->info.name = ralloc_strdup(ns, ns->info.name);
- if (ns->info.label)
- ns->info.label = ralloc_strdup(ns, ns->info.label);
+ ns->info->name = ralloc_strdup(ns, ns->info->name);
+ if (ns->info->label)
+ ns->info->label = ralloc_strdup(ns, ns->info->label);
ns->num_inputs = s->num_inputs;
ns->num_uniforms = s->num_uniforms;
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index 2d6efd55a68..380140ad5ce 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -30,7 +30,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
case nir_intrinsic_discard:
case nir_intrinsic_discard_if:
assert(shader->stage == MESA_SHADER_FRAGMENT);
- shader->info.fs.uses_discard = true;
+ shader->info->fs.uses_discard = true;
break;
case nir_intrinsic_load_front_face:
@@ -47,14 +47,14 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
case nir_intrinsic_load_local_invocation_index:
case nir_intrinsic_load_work_group_id:
case nir_intrinsic_load_num_work_groups:
- shader->info.system_values_read |=
+ shader->info->system_values_read |=
(1 << nir_system_value_from_intrinsic(instr->intrinsic));
break;
case nir_intrinsic_end_primitive:
case nir_intrinsic_end_primitive_with_counter:
assert(shader->stage == MESA_SHADER_GEOMETRY);
- shader->info.gs.uses_end_primitive = 1;
+ shader->info->gs.uses_end_primitive = 1;
break;
default:
@@ -66,7 +66,7 @@ static void
gather_tex_info(nir_tex_instr *instr, nir_shader *shader)
{
if (instr->op == nir_texop_tg4)
- shader->info.uses_texture_gather = true;
+ shader->info->uses_texture_gather = true;
}
static void
@@ -127,26 +127,26 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
shader->stage == MESA_SHADER_COMPUTE);
bool uses_sample_qualifier = false;
- shader->info.inputs_read = 0;
+ shader->info->inputs_read = 0;
foreach_list_typed(nir_variable, var, node, &shader->inputs) {
- shader->info.inputs_read |= get_io_mask(var, shader->stage);
+ shader->info->inputs_read |= get_io_mask(var, shader->stage);
uses_sample_qualifier |= var->data.sample;
}
if (shader->stage == MESA_SHADER_FRAGMENT)
- shader->info.fs.uses_sample_qualifier = uses_sample_qualifier;
+ shader->info->fs.uses_sample_qualifier = uses_sample_qualifier;
/* TODO: Some day we may need to add stream support to NIR */
- shader->info.outputs_written = 0;
+ shader->info->outputs_written = 0;
foreach_list_typed(nir_variable, var, node, &shader->outputs)
- shader->info.outputs_written |= get_io_mask(var, shader->stage);
+ shader->info->outputs_written |= get_io_mask(var, shader->stage);
- shader->info.system_values_read = 0;
+ shader->info->system_values_read = 0;
foreach_list_typed(nir_variable, var, node, &shader->system_values)
- shader->info.system_values_read |= get_io_mask(var, shader->stage);
+ shader->info->system_values_read |= get_io_mask(var, shader->stage);
- shader->info.num_textures = 0;
- shader->info.num_images = 0;
+ shader->info->num_textures = 0;
+ shader->info->num_images = 0;
nir_foreach_variable(var, &shader->uniforms) {
const struct glsl_type *type = var->type;
unsigned count = 1;
@@ -156,9 +156,9 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
}
if (glsl_type_is_image(type)) {
- shader->info.num_images += count;
+ shader->info->num_images += count;
} else if (glsl_type_is_sampler(type)) {
- shader->info.num_textures += count;
+ shader->info->num_textures += count;
}
}
diff --git a/src/compiler/nir/nir_lower_bitmap.c b/src/compiler/nir/nir_lower_bitmap.c
index 216bedf5740..fefe53cbd81 100644
--- a/src/compiler/nir/nir_lower_bitmap.c
+++ b/src/compiler/nir/nir_lower_bitmap.c
@@ -108,7 +108,7 @@ lower_bitmap(nir_shader *shader, nir_builder *b,
discard->src[0] = nir_src_for_ssa(cond);
nir_builder_instr_insert(b, &discard->instr);
- shader->info.fs.uses_discard = true;
+ shader->info->fs.uses_discard = true;
}
static void
diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index b74e6cca39f..62540ac11d9 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -287,7 +287,7 @@ lower_clip_fs(nir_function_impl *impl, unsigned ucp_enables,
discard->src[0] = nir_src_for_ssa(cond);
nir_builder_instr_insert(&b, &discard->instr);
- b.shader->info.fs.uses_discard = true;
+ b.shader->info->fs.uses_discard = true;
}
}
}
diff --git a/src/compiler/nir/nir_lower_gs_intrinsics.c b/src/compiler/nir/nir_lower_gs_intrinsics.c
index 9bbaf836843..a955e8b5dc7 100644
--- a/src/compiler/nir/nir_lower_gs_intrinsics.c
+++ b/src/compiler/nir/nir_lower_gs_intrinsics.c
@@ -76,7 +76,8 @@ rewrite_emit_vertex(nir_intrinsic_instr *intrin, struct state *state)
b->cursor = nir_before_instr(&intrin->instr);
nir_ssa_def *count = nir_load_var(b, state->vertex_count_var);
- nir_ssa_def *max_vertices = nir_imm_int(b, b->shader->info.gs.vertices_out);
+ nir_ssa_def *max_vertices =
+ nir_imm_int(b, b->shader->info->gs.vertices_out);
/* Create: if (vertex_count < max_vertices) and insert it.
*
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index 9747ac473d3..6ad5ad6940d 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -58,9 +58,9 @@ convert_block(nir_block *block, nir_builder *b)
*/
nir_const_value local_size;
- local_size.u32[0] = b->shader->info.cs.local_size[0];
- local_size.u32[1] = b->shader->info.cs.local_size[1];
- local_size.u32[2] = b->shader->info.cs.local_size[2];
+ local_size.u32[0] = b->shader->info->cs.local_size[0];
+ local_size.u32[1] = b->shader->info->cs.local_size[1];
+ local_size.u32[2] = b->shader->info->cs.local_size[2];
nir_ssa_def *group_id = nir_load_work_group_id(b);
nir_ssa_def *local_id = nir_load_local_invocation_id(b);
@@ -87,8 +87,10 @@ convert_block(nir_block *block, nir_builder *b)
*/
nir_ssa_def *local_id = nir_load_local_invocation_id(b);
- nir_ssa_def *size_x = nir_imm_int(b, b->shader->info.cs.local_size[0]);
- nir_ssa_def *size_y = nir_imm_int(b, b->shader->info.cs.local_size[1]);
+ nir_ssa_def *size_x =
+ nir_imm_int(b, b->shader->info->cs.local_size[0]);
+ nir_ssa_def *size_y =
+ nir_imm_int(b, b->shader->info->cs.local_size[1]);
sysval = nir_imul(b, nir_channel(b, local_id, 2),
nir_imul(b, size_x, size_y));
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 35f64684d29..242bffba472 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -1143,11 +1143,11 @@ nir_print_shader_annotated(nir_shader *shader, FILE *fp,
fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->stage));
- if (shader->info.name)
- fprintf(fp, "name: %s\n", shader->info.name);
+ if (shader->info->name)
+ fprintf(fp, "name: %s\n", shader->info->name);
- if (shader->info.label)
- fprintf(fp, "label: %s\n", shader->info.label);
+ if (shader->info->label)
+ fprintf(fp, "label: %s\n", shader->info->label);
fprintf(fp, "inputs: %u\n", shader->num_inputs);
fprintf(fp, "outputs: %u\n", shader->num_outputs);
diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c
index 0f1debce3ad..faf696d6dec 100644
--- a/src/compiler/nir/nir_sweep.c
+++ b/src/compiler/nir/nir_sweep.c
@@ -153,9 +153,9 @@ nir_sweep(nir_shader *nir)
/* First, move ownership of all the memory to a temporary context; assume dead. */
ralloc_adopt(rubbish, nir);
- ralloc_steal(nir, (char *)nir->info.name);
- if (nir->info.label)
- ralloc_steal(nir, (char *)nir->info.label);
+ ralloc_steal(nir, (char *)nir->info->name);
+ if (nir->info->label)
+ ralloc_steal(nir, (char *)nir->info->label);
/* Variables and registers are not dead. Steal them back. */
steal_list(nir, nir_variable, &nir->uniforms);