i965: Validate math instruction sources.
authorMatt Turner <mattst88@gmail.com>
Sat, 5 Nov 2016 22:49:14 +0000 (15:49 -0700)
committerMatt Turner <mattst88@gmail.com>
Fri, 20 Jan 2017 19:40:52 +0000 (11:40 -0800)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/test_eu_validate.cpp

index 67094670aa106c6081280c5d411251c7056eceb1..48833bce9d48e8ffa1fbb4dae3357bb29fca12a1 100644 (file)
@@ -1975,8 +1975,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) {
@@ -1994,13 +1992,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. */
index 13e9ba42f08f64da4f85f6222e7c0e2b8fbccc1a..82761711967a9f1c50552c57fda1fef4e699abf0 100644 (file)
@@ -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