From: Matt Turner Date: Sat, 5 Nov 2016 22:49:14 +0000 (-0700) Subject: i965: Validate math instruction sources. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ada891d472a32412abacc987cc1963c1438b6548;p=mesa.git i965: Validate math instruction sources. Reviewed-by: Kenneth Graunke --- diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 67094670aa1..48833bce9d4 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -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. */ diff --git a/src/mesa/drivers/dri/i965/test_eu_validate.cpp b/src/mesa/drivers/dri/i965/test_eu_validate.cpp index 13e9ba42f08..82761711967 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