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_TXB,
|
||||||
FS_OPCODE_TXD,
|
FS_OPCODE_TXD,
|
||||||
FS_OPCODE_TXL,
|
FS_OPCODE_TXL,
|
||||||
|
FS_OPCODE_TXS,
|
||||||
FS_OPCODE_DISCARD,
|
FS_OPCODE_DISCARD,
|
||||||
FS_OPCODE_SPILL,
|
FS_OPCODE_SPILL,
|
||||||
FS_OPCODE_UNSPILL,
|
FS_OPCODE_UNSPILL,
|
||||||
@@ -781,6 +782,7 @@ enum opcode {
|
|||||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS 4
|
#define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS 4
|
||||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
|
#define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
|
||||||
#define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE 6
|
#define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE 6
|
||||||
|
#define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO 10
|
||||||
|
|
||||||
/* for GEN5 only */
|
/* for GEN5 only */
|
||||||
#define BRW_SAMPLER_SIMD_MODE_SIMD4X2 0
|
#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_TXB:
|
||||||
case FS_OPCODE_TXD:
|
case FS_OPCODE_TXD:
|
||||||
case FS_OPCODE_TXL:
|
case FS_OPCODE_TXL:
|
||||||
|
case FS_OPCODE_TXS:
|
||||||
return 1;
|
return 1;
|
||||||
case FS_OPCODE_FB_WRITE:
|
case FS_OPCODE_FB_WRITE:
|
||||||
return 2;
|
return 2;
|
||||||
|
@@ -291,7 +291,8 @@ public:
|
|||||||
return (opcode == FS_OPCODE_TEX ||
|
return (opcode == FS_OPCODE_TEX ||
|
||||||
opcode == FS_OPCODE_TXB ||
|
opcode == FS_OPCODE_TXB ||
|
||||||
opcode == FS_OPCODE_TXD ||
|
opcode == FS_OPCODE_TXD ||
|
||||||
opcode == FS_OPCODE_TXL);
|
opcode == FS_OPCODE_TXL ||
|
||||||
|
opcode == FS_OPCODE_TXS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_math()
|
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;
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LOD;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case FS_OPCODE_TXS:
|
||||||
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO;
|
||||||
|
break;
|
||||||
case FS_OPCODE_TXD:
|
case FS_OPCODE_TXD:
|
||||||
/* There is no sample_d_c message; comparisons are done manually */
|
/* There is no sample_d_c message; comparisons are done manually */
|
||||||
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
|
||||||
@@ -775,6 +778,7 @@ fs_visitor::generate_code()
|
|||||||
case FS_OPCODE_TXB:
|
case FS_OPCODE_TXB:
|
||||||
case FS_OPCODE_TXD:
|
case FS_OPCODE_TXD:
|
||||||
case FS_OPCODE_TXL:
|
case FS_OPCODE_TXL:
|
||||||
|
case FS_OPCODE_TXS:
|
||||||
generate_tex(inst, dst, src[0]);
|
generate_tex(inst, dst, src[0]);
|
||||||
break;
|
break;
|
||||||
case FS_OPCODE_DISCARD:
|
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 base_mrf = 2;
|
||||||
int reg_width = c->dispatch_width / 8;
|
int reg_width = c->dispatch_width / 8;
|
||||||
bool header_present = false;
|
bool header_present = false;
|
||||||
|
const int vector_elements =
|
||||||
|
ir->coordinate ? ir->coordinate->type->vector_elements : 0;
|
||||||
|
|
||||||
if (ir->offset) {
|
if (ir->offset) {
|
||||||
/* The offsets set up by the ir_texture visitor are in the
|
/* 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--;
|
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_inst *inst = emit(BRW_OPCODE_MOV,
|
||||||
fs_reg(MRF, base_mrf + mlen + i * reg_width),
|
fs_reg(MRF, base_mrf + mlen + i * reg_width),
|
||||||
coordinate);
|
coordinate);
|
||||||
@@ -769,7 +771,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
|||||||
inst->saturate = true;
|
inst->saturate = true;
|
||||||
coordinate.reg_offset++;
|
coordinate.reg_offset++;
|
||||||
}
|
}
|
||||||
mlen += ir->coordinate->type->vector_elements * reg_width;
|
mlen += vector_elements * reg_width;
|
||||||
|
|
||||||
if (ir->shadow_comparitor && ir->op != ir_txd) {
|
if (ir->shadow_comparitor && ir->op != ir_txd) {
|
||||||
mlen = MAX2(mlen, header_present + 4 * reg_width);
|
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);
|
inst = emit(FS_OPCODE_TXD, dst);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ir_txf:
|
|
||||||
case ir_txs:
|
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");
|
assert(!"GLSL 1.30 features unsupported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -927,14 +935,19 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ir_txf:
|
|
||||||
case ir_txs:
|
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");
|
assert(!"GLSL 1.30 features unsupported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the coordinate (except for TXD where it was done earlier) */
|
/* 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++) {
|
for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
|
||||||
fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
|
fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
|
||||||
coordinate);
|
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_txl: inst = emit(FS_OPCODE_TXL, dst); break;
|
||||||
case ir_txd: inst = emit(FS_OPCODE_TXD, dst); break;
|
case ir_txd: inst = emit(FS_OPCODE_TXD, dst); break;
|
||||||
case ir_txf: assert(!"TXF unsupported."); 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->base_mrf = base_mrf;
|
||||||
inst->mlen = mlen;
|
inst->mlen = mlen;
|
||||||
@@ -988,7 +1001,8 @@ fs_visitor::visit(ir_texture *ir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->result = reg_undef;
|
this->result = reg_undef;
|
||||||
ir->coordinate->accept(this);
|
if (ir->coordinate)
|
||||||
|
ir->coordinate->accept(this);
|
||||||
fs_reg coordinate = this->result;
|
fs_reg coordinate = this->result;
|
||||||
|
|
||||||
if (ir->offset != NULL) {
|
if (ir->offset != NULL) {
|
||||||
|
@@ -2104,7 +2104,10 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
|
|||||||
ir_to_mesa_instruction *inst = NULL;
|
ir_to_mesa_instruction *inst = NULL;
|
||||||
prog_opcode opcode = OPCODE_NOP;
|
prog_opcode opcode = OPCODE_NOP;
|
||||||
|
|
||||||
ir->coordinate->accept(this);
|
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,
|
/* Put our coords in a temp. We'll need to modify them for shadow,
|
||||||
* projection, or LOD, so the only case we'd use it as is is if
|
* projection, or LOD, so the only case we'd use it as is is if
|
||||||
@@ -2128,6 +2131,7 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
|
|||||||
|
|
||||||
switch (ir->op) {
|
switch (ir->op) {
|
||||||
case ir_tex:
|
case ir_tex:
|
||||||
|
case ir_txs:
|
||||||
opcode = OPCODE_TEX;
|
opcode = OPCODE_TEX;
|
||||||
break;
|
break;
|
||||||
case ir_txb:
|
case ir_txb:
|
||||||
@@ -2148,7 +2152,6 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
|
|||||||
dy = this->result;
|
dy = this->result;
|
||||||
break;
|
break;
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
case ir_txs:
|
|
||||||
assert(!"GLSL 1.30 features unsupported");
|
assert(!"GLSL 1.30 features unsupported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user