i965/vec4: Replace vec4_instruction::regs_written with ::size_written field in bytes.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_eu_validate.c
index 6f55df96bde41c8a71737c2b2bb9ef37734cdfb2..0e736ed01d8d10a98d16d106a426cd98f33edffc 100644 (file)
@@ -55,21 +55,27 @@ cat(struct string *dest, const struct string src)
    } while(0)
 
 static bool
-src0_is_null(const struct brw_device_info *devinfo, const brw_inst *inst)
+src0_is_null(const struct gen_device_info *devinfo, const brw_inst *inst)
 {
    return brw_inst_src0_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
           brw_inst_src0_da_reg_nr(devinfo, inst) == BRW_ARF_NULL;
 }
 
 static bool
-src1_is_null(const struct brw_device_info *devinfo, const brw_inst *inst)
+src1_is_null(const struct gen_device_info *devinfo, const brw_inst *inst)
 {
    return brw_inst_src1_reg_file(devinfo, inst) == BRW_ARCHITECTURE_REGISTER_FILE &&
           brw_inst_src1_da_reg_nr(devinfo, inst) == BRW_ARF_NULL;
 }
 
+static bool
+src0_is_grf(const struct gen_device_info *devinfo, const brw_inst *inst)
+{
+   return brw_inst_src0_reg_file(devinfo, inst) == BRW_GENERAL_REGISTER_FILE;
+}
+
 static unsigned
-num_sources_from_inst(const struct brw_device_info *devinfo,
+num_sources_from_inst(const struct gen_device_info *devinfo,
                       const brw_inst *inst)
 {
    const struct opcode_desc *desc =
@@ -118,18 +124,17 @@ num_sources_from_inst(const struct brw_device_info *devinfo,
 }
 
 static bool
-is_unsupported_inst(const struct brw_device_info *devinfo,
+is_unsupported_inst(const struct gen_device_info *devinfo,
                     const brw_inst *inst)
 {
-   int gen = gen_from_devinfo(devinfo);
-   return (opcode_descs[brw_inst_opcode(devinfo, inst)].gens & gen) == 0;
+   return brw_opcode_desc(devinfo, brw_inst_opcode(devinfo, inst)) == NULL;
 }
 
 bool
 brw_validate_instructions(const struct brw_codegen *p, int start_offset,
                           struct annotation_info *annotation)
 {
-   const struct brw_device_info *devinfo = p->devinfo;
+   const struct gen_device_info *devinfo = p->devinfo;
    const void *store = p->store + start_offset / 16;
    bool valid = true;
 
@@ -158,6 +163,18 @@ brw_validate_instructions(const struct brw_codegen *p, int start_offset,
       ERROR_IF(is_unsupported_inst(devinfo, inst),
                "Instruction not supported on this Gen");
 
+      if (brw_inst_opcode(devinfo, inst) == BRW_OPCODE_SEND) {
+         ERROR_IF(brw_inst_src0_address_mode(devinfo, inst) !=
+                  BRW_ADDRESS_DIRECT, "send must use direct addressing");
+
+         if (devinfo->gen >= 7) {
+            ERROR_IF(!src0_is_grf(devinfo, inst), "send from non-GRF");
+            ERROR_IF(brw_inst_eot(devinfo, inst) &&
+                     brw_inst_src0_da_reg_nr(devinfo, inst) < 112,
+                     "send with EOT must use g112-g127");
+         }
+      }
+
       if (error_msg.str && annotation) {
          annotation_insert_error(annotation, src_offset, error_msg.str);
       }