[Mesa-dev] [PATCH 13/18] i965: Validate math instruction sources.

Matt Turner mattst88 at gmail.com
Tue Nov 22 19:59:47 UTC 2016


---
 src/mesa/drivers/dri/i965/brw_eu_emit.c        |  9 ---------
 src/mesa/drivers/dri/i965/test_eu_validate.cpp | 23 +++++++++++++++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 3146271..f3aa2bc 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -2005,8 +2005,6 @@ void gen6_math(struct brw_codegen *p,
 
    assert(dest.file == BRW_GENERAL_REGISTER_FILE ||
           (devinfo->gen >= 7 && dest.file == BRW_MESSAGE_REGISTER_FILE));
-   assert(src0.file == BRW_GENERAL_REGISTER_FILE ||
-          (devinfo->gen >= 8 && src0.file == BRW_IMMEDIATE_VALUE));
 
    assert(dest.hstride == BRW_HORIZONTAL_STRIDE_1);
    if (devinfo->gen == 6) {
@@ -2024,13 +2022,6 @@ void gen6_math(struct brw_codegen *p,
    } else {
       assert(src0.type == BRW_REGISTER_TYPE_F);
       assert(src1.type == BRW_REGISTER_TYPE_F);
-      if (function == BRW_MATH_FUNCTION_POW) {
-         assert(src1.file == BRW_GENERAL_REGISTER_FILE ||
-                (devinfo->gen >= 8 && src1.file == BRW_IMMEDIATE_VALUE));
-      } else {
-         assert(src1.file == BRW_ARCHITECTURE_REGISTER_FILE &&
-                src1.nr == BRW_ARF_NULL);
-      }
    }
 
    /* Source modifiers are ignored for extended math instructions on Gen6. */
diff --git a/src/mesa/drivers/dri/i965/test_eu_validate.cpp b/src/mesa/drivers/dri/i965/test_eu_validate.cpp
index 13e9ba4..8276171 100644
--- a/src/mesa/drivers/dri/i965/test_eu_validate.cpp
+++ b/src/mesa/drivers/dri/i965/test_eu_validate.cpp
@@ -152,6 +152,29 @@ TEST_P(validation_test, src1_null_reg)
    EXPECT_FALSE(validate(p));
 }
 
+TEST_P(validation_test, math_src0_null_reg)
+{
+   if (devinfo.gen >= 6) {
+      gen6_math(p, g0, BRW_MATH_FUNCTION_SIN, null, null);
+   } else {
+      gen4_math(p, g0, BRW_MATH_FUNCTION_SIN, 0, null, BRW_MATH_PRECISION_FULL);
+   }
+
+   EXPECT_FALSE(validate(p));
+}
+
+TEST_P(validation_test, math_src1_null_reg)
+{
+   if (devinfo.gen >= 6) {
+      gen6_math(p, g0, BRW_MATH_FUNCTION_POW, g0, null);
+      EXPECT_FALSE(validate(p));
+   } else {
+      /* Math instructions on Gen4/5 are actually SEND messages with payloads.
+       * src1 is an immediate message descriptor set by gen4_math.
+       */
+   }
+}
+
 TEST_P(validation_test, opcode46)
 {
    /* opcode 46 is "push" on Gen 4 and 5
-- 
2.7.3



More information about the mesa-dev mailing list