From: Eric Anholt Date: Wed, 23 Nov 2011 18:13:39 +0000 (-0800) Subject: i965/fs: Make register file enum 0 be the undefined register file. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a3b8c5ed5bd591d4ae7d215f71f039d3b19200bb;p=mesa.git i965/fs: Make register file enum 0 be the undefined register file. In 6d874d0ee18b3694c49e0206fa519bd8b746ec24, I checked whether a register that had been stored was BAD_FILE (as opposed to a legitimate GRF), but actually the unset register was ARF NULL because it had been memset to 0. Finding BAD_FILE for unset values in debugging was my intention with that file, so make it the case more often by rearranging the enum. There was only one place we relied on the magic enum register_file to hardware register file correspondance anyway. --- diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index de3164457c8..cb93885efe7 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -48,13 +48,13 @@ extern "C" { #include "glsl/ir.h" enum register_file { - ARF = BRW_ARCHITECTURE_REGISTER_FILE, - GRF = BRW_GENERAL_REGISTER_FILE, - MRF = BRW_MESSAGE_REGISTER_FILE, - IMM = BRW_IMMEDIATE_VALUE, + BAD_FILE, + ARF, + GRF, + MRF, + IMM, FIXED_HW_REG, /* a struct brw_reg */ UNIFORM, /* prog_data->params[reg] */ - BAD_FILE }; class fs_reg { @@ -159,7 +159,7 @@ public: struct brw_reg fixed_hw_reg; int smear; /* -1, or a channel of the reg to smear to all channels. */ - /** Value for file == BRW_IMMMEDIATE_FILE */ + /** Value for file == IMM */ union { int32_t i; uint32_t u; diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp index 1ac215e6f40..819c1ef7b66 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp @@ -573,6 +573,23 @@ fs_visitor::generate_pull_constant_load(fs_inst *inst, struct brw_reg dst) } } +static uint32_t brw_file_from_reg(fs_reg *reg) +{ + switch (reg->file) { + case ARF: + return BRW_ARCHITECTURE_REGISTER_FILE; + case GRF: + return BRW_GENERAL_REGISTER_FILE; + case MRF: + return BRW_MESSAGE_REGISTER_FILE; + case IMM: + return BRW_IMMEDIATE_VALUE; + default: + assert(!"not reached"); + return BRW_GENERAL_REGISTER_FILE; + } +} + static struct brw_reg brw_reg_from_fs_reg(fs_reg *reg) { @@ -583,9 +600,9 @@ brw_reg_from_fs_reg(fs_reg *reg) case ARF: case MRF: if (reg->smear == -1) { - brw_reg = brw_vec8_reg(reg->file, reg->reg, 0); + brw_reg = brw_vec8_reg(brw_file_from_reg(reg), reg->reg, 0); } else { - brw_reg = brw_vec1_reg(reg->file, reg->reg, reg->smear); + brw_reg = brw_vec1_reg(brw_file_from_reg(reg), reg->reg, reg->smear); } brw_reg = retype(brw_reg, reg->type); if (reg->sechalf)