diff options
author | Matt Turner <mattst88@gmail.com> | 2017-03-02 11:28:14 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2017-03-23 14:34:44 -0700 |
commit | b0e72defc2a0687cec8bf731c6b897ff293a26da (patch) | |
tree | 40cac25c0ec0f9b03e0888dea59c86165afe0d05 /src/compiler/nir | |
parent | 01548f9f01644623ff7eb9778fc78f2eb90fc99a (diff) |
nir: Return progress from nir_lower_samplers().
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_samplers.c | 29 |
2 files changed, 19 insertions, 12 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 703d5d2dd1..8bf517c333 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2405,7 +2405,7 @@ bool nir_lower_load_const_to_scalar(nir_shader *shader); bool nir_lower_phis_to_scalar(nir_shader *shader); void nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask); -void nir_lower_samplers(nir_shader *shader, +bool nir_lower_samplers(nir_shader *shader, const struct gl_shader_program *shader_program); bool nir_lower_system_values(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c index 9debfb2eaf..0c4e91b000 100644 --- a/src/compiler/nir/nir_lower_samplers.c +++ b/src/compiler/nir/nir_lower_samplers.c @@ -86,12 +86,12 @@ calc_sampler_offsets(nir_deref *tail, nir_tex_instr *instr, } } -static void +static bool lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_program, gl_shader_stage stage, nir_builder *b) { if (instr->texture == NULL) - return; + return false; /* In GLSL, we only fill out the texture field. The sampler is inferred */ assert(instr->sampler == NULL); @@ -140,11 +140,8 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr instr->texture_array_size = array_elements; } - if (location > shader_program->data->NumUniformStorage - 1 || - !shader_program->data->UniformStorage[location].opaque[stage].active) { - assert(!"cannot return a sampler"); - return; - } + assert(location < shader_program->data->NumUniformStorage && + shader_program->data->UniformStorage[location].opaque[stage].active); instr->texture_index += shader_program->data->UniformStorage[location].opaque[stage].index; @@ -152,29 +149,39 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr instr->sampler_index = instr->texture_index; instr->texture = NULL; + + return true; } -static void +static bool lower_impl(nir_function_impl *impl, const struct gl_shader_program *shader_program, gl_shader_stage stage) { nir_builder b; nir_builder_init(&b, impl); + bool progress = false; nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { if (instr->type == nir_instr_type_tex) - lower_sampler(nir_instr_as_tex(instr), shader_program, stage, &b); + progress |= lower_sampler(nir_instr_as_tex(instr), + shader_program, stage, &b); } } + + return progress; } -void +bool nir_lower_samplers(nir_shader *shader, const struct gl_shader_program *shader_program) { + bool progress = false; + nir_foreach_function(function, shader) { if (function->impl) - lower_impl(function->impl, shader_program, shader->stage); + progress |= lower_impl(function->impl, shader_program, shader->stage); } + + return progress; } |