summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2016-04-08 16:30:23 -0400
committerJason Ekstrand <[email protected]>2016-05-05 16:19:41 -0700
commitd40fbbc27ecd9a7c1d8ed0ebcb43b4dfcd2d3df7 (patch)
treeb3785de3d8fc5f4f7afa0a100f651a356e4afe65 /src
parent8a7fe634d254acd7f4d0896449340f528feef826 (diff)
nir/lower_tex: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_lower_tex.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index d75e455136b..a0804754098 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -38,12 +38,6 @@
#include "nir.h"
#include "nir_builder.h"
-typedef struct {
- nir_builder b;
- const nir_lower_tex_options *options;
- bool progress;
-} lower_tex_state;
-
static void
project_src(nir_builder *b, nir_tex_instr *tex)
{
@@ -315,11 +309,10 @@ linearize_srgb_result(nir_builder *b, nir_tex_instr *tex)
}
static bool
-nir_lower_tex_block(nir_block *block, void *void_state)
+nir_lower_tex_block(nir_block *block, nir_builder *b,
+ const nir_lower_tex_options *options)
{
- lower_tex_state *state = void_state;
- const nir_lower_tex_options *options = state->options;
- nir_builder *b = &state->b;
+ bool progress = false;
nir_foreach_instr_safe(instr, block) {
if (instr->type != nir_instr_type_tex)
@@ -343,59 +336,63 @@ nir_lower_tex_block(nir_block *block, void *void_state)
*/
if (lower_txp || sat_mask) {
project_src(b, tex);
- state->progress = true;
+ progress = true;
}
if ((tex->sampler_dim == GLSL_SAMPLER_DIM_RECT) && options->lower_rect) {
lower_rect(b, tex);
- state->progress = true;
+ progress = true;
}
if (sat_mask) {
saturate_src(b, tex, sat_mask);
- state->progress = true;
+ progress = true;
}
if (((1 << tex->texture_index) & options->swizzle_result) &&
!nir_tex_instr_is_query(tex) &&
!(tex->is_shadow && tex->is_new_style_shadow)) {
swizzle_result(b, tex, options->swizzles[tex->texture_index]);
- state->progress = true;
+ progress = true;
}
/* should be after swizzle so we know which channels are rgb: */
if (((1 << tex->texture_index) & options->lower_srgb) &&
!nir_tex_instr_is_query(tex) && !tex->is_shadow) {
linearize_srgb_result(b, tex);
- state->progress = true;
+ progress = true;
}
}
- return true;
+ return progress;
}
-static void
-nir_lower_tex_impl(nir_function_impl *impl, lower_tex_state *state)
+static bool
+nir_lower_tex_impl(nir_function_impl *impl,
+ const nir_lower_tex_options *options)
{
- nir_builder_init(&state->b, impl);
+ bool progress = false;
+ nir_builder builder;
+ nir_builder_init(&builder, impl);
- nir_foreach_block_call(impl, nir_lower_tex_block, state);
+ nir_foreach_block(block, impl) {
+ progress |= nir_lower_tex_block(block, &builder, options);
+ }
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
+ return progress;
}
bool
nir_lower_tex(nir_shader *shader, const nir_lower_tex_options *options)
{
- lower_tex_state state;
- state.options = options;
- state.progress = false;
+ bool progress = false;
nir_foreach_function(function, shader) {
if (function->impl)
- nir_lower_tex_impl(function->impl, &state);
+ progress |= nir_lower_tex_impl(function->impl, options);
}
- return state.progress;
+ return progress;
}