nir: Add clone/hash/serialize support for non-uniform tex instructions.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 1 Jan 2020 13:42:58 +0000 (14:42 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 2 Jan 2020 10:41:33 +0000 (11:41 +0100)
These were missed when the fields got added. Added it everywhere where
texture_index got used and it made sense.

Found this in "The Surge 2", where the inliner does not copy the fields,
resulting in corruption and hangs.

Fixes: 3bd54576415 "nir: Add a lowering pass for non-uniform resource access"
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1203
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3246>

src/compiler/nir/nir_clone.c
src/compiler/nir/nir_instr_set.c
src/compiler/nir/nir_serialize.c

index 69807e2e7a54a12a22e0ba4873daddc8e309cfd1..d1938918d5e1d5e26cea7bba98d7e16aac4d275f 100644 (file)
@@ -422,6 +422,9 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
    ntex->texture_array_size = tex->texture_array_size;
    ntex->sampler_index = tex->sampler_index;
 
+   ntex->texture_non_uniform = tex->texture_non_uniform;
+   ntex->sampler_non_uniform = tex->sampler_non_uniform;
+
    return ntex;
 }
 
index fdab2a4fb1e4165832c2e9882f51f270ad0cd384..cb0f2befa86d1482436724214485a7448da9e92e 100644 (file)
@@ -276,6 +276,8 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)
    hash = HASH(hash, instr->texture_index);
    hash = HASH(hash, instr->texture_array_size);
    hash = HASH(hash, instr->sampler_index);
+   hash = HASH(hash, instr->texture_non_uniform);
+   hash = HASH(hash, instr->sampler_non_uniform);
 
    return hash;
 }
index b991b1d02e250b93303cb911416adf140142b788..990f778ef51c4f71ffd3e3636ac33d46ef1f1859 100644 (file)
@@ -1440,7 +1440,9 @@ union packed_tex_data {
       unsigned is_shadow:1;
       unsigned is_new_style_shadow:1;
       unsigned component:2;
-      unsigned unused:10; /* Mark unused for valgrind. */
+      unsigned texture_non_uniform:1;
+      unsigned sampler_non_uniform:1;
+      unsigned unused:8; /* Mark unused for valgrind. */
    } u;
 };
 
@@ -1475,6 +1477,8 @@ write_tex(write_ctx *ctx, const nir_tex_instr *tex)
       .u.is_shadow = tex->is_shadow,
       .u.is_new_style_shadow = tex->is_new_style_shadow,
       .u.component = tex->component,
+      .u.texture_non_uniform = tex->texture_non_uniform,
+      .u.sampler_non_uniform = tex->sampler_non_uniform,
    };
    blob_write_uint32(ctx->blob, packed.u32);
 
@@ -1509,6 +1513,8 @@ read_tex(read_ctx *ctx, union packed_instr header)
    tex->is_shadow = packed.u.is_shadow;
    tex->is_new_style_shadow = packed.u.is_new_style_shadow;
    tex->component = packed.u.component;
+   tex->texture_non_uniform = packed.u.texture_non_uniform;
+   tex->sampler_non_uniform = packed.u.sampler_non_uniform;
 
    for (unsigned i = 0; i < tex->num_srcs; i++) {
       union packed_src src = read_src(ctx, &tex->src[i].src, &tex->instr);