[Mesa-dev] [PATCH 2/9] nir/lower_vec_to_movs: Add a state struct
Kenneth Graunke
kenneth at whitecape.org
Fri Sep 18 08:37:08 PDT 2015
From: Jason Ekstrand <jason at jlekstrand.net>
While we're here, we also fix up a couple of potential ralloc-parenting
bugs. In particular, we were calling nir_src_copy with the shader as the
mem context instead of the instruction.
v2 (Ken): Rebase.
Reviewed-by: Eduardo Lima Mitev <elima at igalia.com> [v1]
---
src/glsl/nir/nir_lower_vec_to_movs.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/glsl/nir/nir_lower_vec_to_movs.c b/src/glsl/nir/nir_lower_vec_to_movs.c
index 2cb0457..f5d30be 100644
--- a/src/glsl/nir/nir_lower_vec_to_movs.c
+++ b/src/glsl/nir/nir_lower_vec_to_movs.c
@@ -32,6 +32,10 @@
* moves with partial writes.
*/
+struct vec_to_movs_state {
+ nir_function_impl *impl;
+};
+
static bool
src_matches_dest_reg(nir_dest *dest, nir_src *src)
{
@@ -185,9 +189,10 @@ try_coalesce(nir_alu_instr *vec, unsigned start_idx, nir_shader *shader)
}
static bool
-lower_vec_to_movs_block(nir_block *block, void *void_impl)
+lower_vec_to_movs_block(nir_block *block, void *void_state)
{
- nir_function_impl *impl = void_impl;
+ struct vec_to_movs_state *state = void_state;
+ nir_function_impl *impl = state->impl;
nir_shader *shader = impl->overload->function->shader;
nir_foreach_instr_safe(block, instr) {
@@ -254,7 +259,9 @@ lower_vec_to_movs_block(nir_block *block, void *void_impl)
static void
nir_lower_vec_to_movs_impl(nir_function_impl *impl)
{
- nir_foreach_block(impl, lower_vec_to_movs_block, impl);
+ struct vec_to_movs_state state = { impl };
+
+ nir_foreach_block(impl, lower_vec_to_movs_block, &state);
}
void
--
2.5.1
More information about the mesa-dev
mailing list