i965/fs: Implement textureSize (TXS) on Gen5+.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
@@ -634,6 +634,7 @@ enum opcode {
|
||||
FS_OPCODE_TXB,
|
||||
FS_OPCODE_TXD,
|
||||
FS_OPCODE_TXL,
|
||||
FS_OPCODE_TXS,
|
||||
FS_OPCODE_DISCARD,
|
||||
FS_OPCODE_SPILL,
|
||||
FS_OPCODE_UNSPILL,
|
||||
@@ -781,6 +782,7 @@ enum opcode {
|
||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS 4
|
||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
|
||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE 6
|
||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO 10
|
||||
|
||||
/* for GEN5 only */
|
||||
#define BRW_SAMPLER_SIMD_MODE_SIMD4X2 0
|
||||
|
@@ -157,6 +157,7 @@ fs_visitor::implied_mrf_writes(fs_inst *inst)
|
||||
case FS_OPCODE_TXB:
|
||||
case FS_OPCODE_TXD:
|
||||
case FS_OPCODE_TXL:
|
||||
case FS_OPCODE_TXS:
|
||||
return 1;
|
||||
case FS_OPCODE_FB_WRITE:
|
||||
return 2;
|
||||
|
@@ -291,7 +291,8 @@ public:
|
||||
return (opcode == FS_OPCODE_TEX ||
|
||||
opcode == FS_OPCODE_TXB ||
|
||||
opcode == FS_OPCODE_TXD ||
|
||||
opcode == FS_OPCODE_TXL);
|
||||
opcode == FS_OPCODE_TXL ||
|
||||
opcode == FS_OPCODE_TXS);
|
||||
}
|
||||
|
||||
bool is_math()
|
||||
|
@@ -242,6 +242,9 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
|
||||
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LOD;
|
||||
}
|
||||
break;
|
||||
case FS_OPCODE_TXS:
|
||||
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO;
|
||||
break;
|
||||
case FS_OPCODE_TXD:
|
||||
/* There is no sample_d_c message; comparisons are done manually */
|
||||
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
|
||||
@@ -775,6 +778,7 @@ fs_visitor::generate_code()
|
||||
case FS_OPCODE_TXB:
|
||||
case FS_OPCODE_TXD:
|
||||
case FS_OPCODE_TXL:
|
||||
case FS_OPCODE_TXS:
|
||||
generate_tex(inst, dst, src[0]);
|
||||
break;
|
||||
case FS_OPCODE_DISCARD:
|
||||
|
@@ -751,6 +751,8 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||
int base_mrf = 2;
|
||||
int reg_width = c->dispatch_width / 8;
|
||||
bool header_present = false;
|
||||
const int vector_elements =
|
||||
ir->coordinate ? ir->coordinate->type->vector_elements : 0;
|
||||
|
||||
if (ir->offset) {
|
||||
/* The offsets set up by the ir_texture visitor are in the
|
||||
@@ -761,7 +763,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||
base_mrf--;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
|
||||
for (int i = 0; i < vector_elements; i++) {
|
||||
fs_inst *inst = emit(BRW_OPCODE_MOV,
|
||||
fs_reg(MRF, base_mrf + mlen + i * reg_width),
|
||||
coordinate);
|
||||
@@ -769,7 +771,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||
inst->saturate = true;
|
||||
coordinate.reg_offset++;
|
||||
}
|
||||
mlen += ir->coordinate->type->vector_elements * reg_width;
|
||||
mlen += vector_elements * reg_width;
|
||||
|
||||
if (ir->shadow_comparitor && ir->op != ir_txd) {
|
||||
mlen = MAX2(mlen, header_present + 4 * reg_width);
|
||||
@@ -837,8 +839,14 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||
inst = emit(FS_OPCODE_TXD, dst);
|
||||
break;
|
||||
}
|
||||
case ir_txf:
|
||||
case ir_txs:
|
||||
this->result = reg_undef;
|
||||
ir->lod_info.lod->accept(this);
|
||||
emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), this->result);
|
||||
mlen += reg_width;
|
||||
inst = emit(FS_OPCODE_TXS, dst);
|
||||
break;
|
||||
case ir_txf:
|
||||
assert(!"GLSL 1.30 features unsupported");
|
||||
break;
|
||||
}
|
||||
@@ -927,14 +935,19 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ir_txf:
|
||||
case ir_txs:
|
||||
this->result = reg_undef;
|
||||
ir->lod_info.lod->accept(this);
|
||||
emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_UD), this->result);
|
||||
mlen += reg_width;
|
||||
break;
|
||||
case ir_txf:
|
||||
assert(!"GLSL 1.30 features unsupported");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set up the coordinate (except for TXD where it was done earlier) */
|
||||
if (ir->op != ir_txd) {
|
||||
if (ir->op != ir_txd && ir->op != ir_txs) {
|
||||
for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
|
||||
fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
|
||||
coordinate);
|
||||
@@ -953,7 +966,7 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||
case ir_txl: inst = emit(FS_OPCODE_TXL, dst); break;
|
||||
case ir_txd: inst = emit(FS_OPCODE_TXD, dst); break;
|
||||
case ir_txf: assert(!"TXF unsupported."); break;
|
||||
case ir_txs: assert(!"TXS unsupported."); break;
|
||||
case ir_txs: inst = emit(FS_OPCODE_TXS, dst); break;
|
||||
}
|
||||
inst->base_mrf = base_mrf;
|
||||
inst->mlen = mlen;
|
||||
@@ -988,6 +1001,7 @@ fs_visitor::visit(ir_texture *ir)
|
||||
}
|
||||
|
||||
this->result = reg_undef;
|
||||
if (ir->coordinate)
|
||||
ir->coordinate->accept(this);
|
||||
fs_reg coordinate = this->result;
|
||||
|
||||
|
@@ -2104,6 +2104,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
|
||||
ir_to_mesa_instruction *inst = NULL;
|
||||
prog_opcode opcode = OPCODE_NOP;
|
||||
|
||||
if (ir->op == ir_txs)
|
||||
this->result = src_reg_for_float(0.0);
|
||||
else
|
||||
ir->coordinate->accept(this);
|
||||
|
||||
/* Put our coords in a temp. We'll need to modify them for shadow,
|
||||
@@ -2128,6 +2131,7 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
|
||||
|
||||
switch (ir->op) {
|
||||
case ir_tex:
|
||||
case ir_txs:
|
||||
opcode = OPCODE_TEX;
|
||||
break;
|
||||
case ir_txb:
|
||||
@@ -2148,7 +2152,6 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
|
||||
dy = this->result;
|
||||
break;
|
||||
case ir_txf:
|
||||
case ir_txs:
|
||||
assert(!"GLSL 1.30 features unsupported");
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user