summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRhys Perry <pendingchaos02@gmail.com>2020-10-15 14:21:52 +0100
committerMarge Bot <eric+marge@anholt.net>2020-10-15 18:21:44 +0000
commitf91b2fe384a38d74df014c6421156a9f8b0bb78e (patch)
tree456c7248d8332f0e617aa1f09225f64c8c15003a
parentf8e971f51142195533e201ea45e33afaaaca1eac (diff)
nir/opt_load_store_vectorize: add some tests for discard/demote behaviour
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7163>
-rw-r--r--src/compiler/nir/tests/load_store_vectorizer_tests.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/compiler/nir/tests/load_store_vectorizer_tests.cpp b/src/compiler/nir/tests/load_store_vectorizer_tests.cpp
index 0f49d30e01a..134b95fa915 100644
--- a/src/compiler/nir/tests/load_store_vectorizer_tests.cpp
+++ b/src/compiler/nir/tests/load_store_vectorizer_tests.cpp
@@ -868,6 +868,62 @@ TEST_F(nir_load_store_vectorize_test, ssbo_load_adjacent_memory_barrier_shared)
ASSERT_EQ(count_intrinsics(nir_intrinsic_load_ssbo), 1);
}
+TEST_F(nir_load_store_vectorize_test, ssbo_store_adjacent_discard)
+{
+ create_store(nir_var_mem_ssbo, 0, 0, 0x1);
+ nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard)->instr);
+ create_store(nir_var_mem_ssbo, 0, 4, 0x2);
+
+ nir_validate_shader(b->shader, NULL);
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_store_ssbo), 2);
+
+ EXPECT_TRUE(run_vectorizer(nir_var_mem_ssbo));
+
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_store_ssbo), 2);
+}
+
+TEST_F(nir_load_store_vectorize_test, ssbo_store_adjacent_demote)
+{
+ create_store(nir_var_mem_ssbo, 0, 0, 0x1);
+ nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_demote)->instr);
+ create_store(nir_var_mem_ssbo, 0, 4, 0x2);
+
+ nir_validate_shader(b->shader, NULL);
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_store_ssbo), 2);
+
+ EXPECT_TRUE(run_vectorizer(nir_var_mem_ssbo));
+
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_store_ssbo), 2);
+}
+
+TEST_F(nir_load_store_vectorize_test, ssbo_load_adjacent_discard)
+{
+ create_load(nir_var_mem_ssbo, 0, 0, 0x1);
+ nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard)->instr);
+ create_load(nir_var_mem_ssbo, 0, 4, 0x2);
+
+ nir_validate_shader(b->shader, NULL);
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_load_ssbo), 2);
+
+ EXPECT_TRUE(run_vectorizer(nir_var_mem_ssbo));
+
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_load_ssbo), 2);
+}
+
+TEST_F(nir_load_store_vectorize_test, ssbo_load_adjacent_demote)
+{
+ create_load(nir_var_mem_ssbo, 0, 0, 0x1);
+ nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_demote)->instr);
+ create_load(nir_var_mem_ssbo, 0, 4, 0x2);
+
+ nir_validate_shader(b->shader, NULL);
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_load_ssbo), 2);
+
+ EXPECT_TRUE(run_vectorizer(nir_var_mem_ssbo));
+
+ ASSERT_EQ(count_intrinsics(nir_intrinsic_load_ssbo), 1);
+}
+
TEST_F(nir_load_store_vectorize_test, ssbo_load_adjacent_8_8_16)
{
create_load(nir_var_mem_ssbo, 0, 0, 0x1, 8);