glsl: Add a new ir_txs (textureSize) opcode to ir_texture.
One unique aspect of TXS is that it doesn't have a coordinate. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
8f26b59f53
commit
1e3bcbdf31
|
@ -1121,7 +1121,7 @@ ir_dereference::is_lvalue() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" };
|
const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf", "txs" };
|
||||||
|
|
||||||
const char *ir_texture::opcode_string()
|
const char *ir_texture::opcode_string()
|
||||||
{
|
{
|
||||||
|
@ -1150,11 +1150,15 @@ ir_texture::set_sampler(ir_dereference *sampler, const glsl_type *type)
|
||||||
this->sampler = sampler;
|
this->sampler = sampler;
|
||||||
this->type = type;
|
this->type = type;
|
||||||
|
|
||||||
assert(sampler->type->sampler_type == (int) type->base_type);
|
if (this->op == ir_txs) {
|
||||||
if (sampler->type->sampler_shadow)
|
assert(type->base_type == GLSL_TYPE_INT);
|
||||||
assert(type->vector_elements == 4 || type->vector_elements == 1);
|
} else {
|
||||||
else
|
assert(sampler->type->sampler_type == (int) type->base_type);
|
||||||
assert(type->vector_elements == 4);
|
if (sampler->type->sampler_shadow)
|
||||||
|
assert(type->vector_elements == 4 || type->vector_elements == 1);
|
||||||
|
else
|
||||||
|
assert(type->vector_elements == 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1212,7 +1212,8 @@ enum ir_texture_opcode {
|
||||||
ir_txb, /**< Texture look-up with LOD bias */
|
ir_txb, /**< Texture look-up with LOD bias */
|
||||||
ir_txl, /**< Texture look-up with explicit LOD */
|
ir_txl, /**< Texture look-up with explicit LOD */
|
||||||
ir_txd, /**< Texture look-up with partial derivatvies */
|
ir_txd, /**< Texture look-up with partial derivatvies */
|
||||||
ir_txf /**< Texel fetch with explicit LOD */
|
ir_txf, /**< Texel fetch with explicit LOD */
|
||||||
|
ir_txs /**< Texture size */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1233,6 +1234,7 @@ enum ir_texture_opcode {
|
||||||
* (txl <type> <sampler> <coordinate> 0 1 ( ) <lod>)
|
* (txl <type> <sampler> <coordinate> 0 1 ( ) <lod>)
|
||||||
* (txd <type> <sampler> <coordinate> 0 1 ( ) (dPdx dPdy))
|
* (txd <type> <sampler> <coordinate> 0 1 ( ) (dPdx dPdy))
|
||||||
* (txf <type> <sampler> <coordinate> 0 <lod>)
|
* (txf <type> <sampler> <coordinate> 0 <lod>)
|
||||||
|
* (txs <type> <sampler> <lod>)
|
||||||
*/
|
*/
|
||||||
class ir_texture : public ir_rvalue {
|
class ir_texture : public ir_rvalue {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -222,7 +222,8 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const
|
||||||
new_tex->type = this->type;
|
new_tex->type = this->type;
|
||||||
|
|
||||||
new_tex->sampler = this->sampler->clone(mem_ctx, ht);
|
new_tex->sampler = this->sampler->clone(mem_ctx, ht);
|
||||||
new_tex->coordinate = this->coordinate->clone(mem_ctx, ht);
|
if (this->coordinate)
|
||||||
|
new_tex->coordinate = this->coordinate->clone(mem_ctx, ht);
|
||||||
if (this->projector)
|
if (this->projector)
|
||||||
new_tex->projector = this->projector->clone(mem_ctx, ht);
|
new_tex->projector = this->projector->clone(mem_ctx, ht);
|
||||||
if (this->shadow_comparitor) {
|
if (this->shadow_comparitor) {
|
||||||
|
@ -240,6 +241,7 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const
|
||||||
break;
|
break;
|
||||||
case ir_txl:
|
case ir_txl:
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
|
case ir_txs:
|
||||||
new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht);
|
new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht);
|
||||||
break;
|
break;
|
||||||
case ir_txd:
|
case ir_txd:
|
||||||
|
|
|
@ -171,9 +171,11 @@ ir_texture::accept(ir_hierarchical_visitor *v)
|
||||||
if (s != visit_continue)
|
if (s != visit_continue)
|
||||||
return (s == visit_continue_with_parent) ? visit_continue : s;
|
return (s == visit_continue_with_parent) ? visit_continue : s;
|
||||||
|
|
||||||
s = this->coordinate->accept(v);
|
if (this->coordinate) {
|
||||||
if (s != visit_continue)
|
s = this->coordinate->accept(v);
|
||||||
return (s == visit_continue_with_parent) ? visit_continue : s;
|
if (s != visit_continue)
|
||||||
|
return (s == visit_continue_with_parent) ? visit_continue : s;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->projector) {
|
if (this->projector) {
|
||||||
s = this->projector->accept(v);
|
s = this->projector->accept(v);
|
||||||
|
@ -203,6 +205,7 @@ ir_texture::accept(ir_hierarchical_visitor *v)
|
||||||
break;
|
break;
|
||||||
case ir_txl:
|
case ir_txl:
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
|
case ir_txs:
|
||||||
s = this->lod_info.lod->accept(v);
|
s = this->lod_info.lod->accept(v);
|
||||||
if (s != visit_continue)
|
if (s != visit_continue)
|
||||||
return (s == visit_continue_with_parent) ? visit_continue : s;
|
return (s == visit_continue_with_parent) ? visit_continue : s;
|
||||||
|
|
|
@ -244,19 +244,21 @@ void ir_print_visitor::visit(ir_texture *ir)
|
||||||
ir->sampler->accept(this);
|
ir->sampler->accept(this);
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
||||||
ir->coordinate->accept(this);
|
if (ir->op != ir_txs) {
|
||||||
|
ir->coordinate->accept(this);
|
||||||
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
||||||
if (ir->offset != NULL) {
|
if (ir->offset != NULL) {
|
||||||
ir->offset->accept(this);
|
ir->offset->accept(this);
|
||||||
} else {
|
} else {
|
||||||
printf("0");
|
printf("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" ");
|
if (ir->op != ir_txf && ir->op != ir_txs) {
|
||||||
|
|
||||||
if (ir->op != ir_txf) {
|
|
||||||
if (ir->projector)
|
if (ir->projector)
|
||||||
ir->projector->accept(this);
|
ir->projector->accept(this);
|
||||||
else
|
else
|
||||||
|
@ -280,6 +282,7 @@ void ir_print_visitor::visit(ir_texture *ir)
|
||||||
break;
|
break;
|
||||||
case ir_txl:
|
case ir_txl:
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
|
case ir_txs:
|
||||||
ir->lod_info.lod->accept(this);
|
ir->lod_info.lod->accept(this);
|
||||||
break;
|
break;
|
||||||
case ir_txd:
|
case ir_txd:
|
||||||
|
|
|
@ -885,6 +885,8 @@ ir_reader::read_texture(s_expression *expr)
|
||||||
{ "tex", s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow };
|
{ "tex", s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow };
|
||||||
s_pattern txf_pattern[] =
|
s_pattern txf_pattern[] =
|
||||||
{ "txf", s_type, s_sampler, s_coord, s_offset, s_lod };
|
{ "txf", s_type, s_sampler, s_coord, s_offset, s_lod };
|
||||||
|
s_pattern txs_pattern[] =
|
||||||
|
{ "txs", s_type, s_sampler, s_lod };
|
||||||
s_pattern other_pattern[] =
|
s_pattern other_pattern[] =
|
||||||
{ tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod };
|
{ tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod };
|
||||||
|
|
||||||
|
@ -892,6 +894,8 @@ ir_reader::read_texture(s_expression *expr)
|
||||||
op = ir_tex;
|
op = ir_tex;
|
||||||
} else if (MATCH(expr, txf_pattern)) {
|
} else if (MATCH(expr, txf_pattern)) {
|
||||||
op = ir_txf;
|
op = ir_txf;
|
||||||
|
} else if (MATCH(expr, txs_pattern)) {
|
||||||
|
op = ir_txs;
|
||||||
} else if (MATCH(expr, other_pattern)) {
|
} else if (MATCH(expr, other_pattern)) {
|
||||||
op = ir_texture::get_opcode(tag->value());
|
op = ir_texture::get_opcode(tag->value());
|
||||||
if (op == -1)
|
if (op == -1)
|
||||||
|
@ -920,25 +924,27 @@ ir_reader::read_texture(s_expression *expr)
|
||||||
}
|
}
|
||||||
tex->set_sampler(sampler, type);
|
tex->set_sampler(sampler, type);
|
||||||
|
|
||||||
// Read coordinate (any rvalue)
|
if (op != ir_txs) {
|
||||||
tex->coordinate = read_rvalue(s_coord);
|
// Read coordinate (any rvalue)
|
||||||
if (tex->coordinate == NULL) {
|
tex->coordinate = read_rvalue(s_coord);
|
||||||
ir_read_error(NULL, "when reading coordinate in (%s ...)",
|
if (tex->coordinate == NULL) {
|
||||||
tex->opcode_string());
|
ir_read_error(NULL, "when reading coordinate in (%s ...)",
|
||||||
return NULL;
|
tex->opcode_string());
|
||||||
}
|
|
||||||
|
|
||||||
// Read texel offset - either 0 or an rvalue.
|
|
||||||
s_int *si_offset = SX_AS_INT(s_offset);
|
|
||||||
if (si_offset == NULL || si_offset->value() != 0) {
|
|
||||||
tex->offset = read_rvalue(s_offset);
|
|
||||||
if (tex->offset == NULL) {
|
|
||||||
ir_read_error(s_offset, "expected 0 or an expression");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read texel offset - either 0 or an rvalue.
|
||||||
|
s_int *si_offset = SX_AS_INT(s_offset);
|
||||||
|
if (si_offset == NULL || si_offset->value() != 0) {
|
||||||
|
tex->offset = read_rvalue(s_offset);
|
||||||
|
if (tex->offset == NULL) {
|
||||||
|
ir_read_error(s_offset, "expected 0 or an expression");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op != ir_txf) {
|
if (op != ir_txf && op != ir_txs) {
|
||||||
s_int *proj_as_int = SX_AS_INT(s_proj);
|
s_int *proj_as_int = SX_AS_INT(s_proj);
|
||||||
if (proj_as_int && proj_as_int->value() == 1) {
|
if (proj_as_int && proj_as_int->value() == 1) {
|
||||||
tex->projector = NULL;
|
tex->projector = NULL;
|
||||||
|
@ -973,6 +979,7 @@ ir_reader::read_texture(s_expression *expr)
|
||||||
break;
|
break;
|
||||||
case ir_txl:
|
case ir_txl:
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
|
case ir_txs:
|
||||||
tex->lod_info.lod = read_rvalue(s_lod);
|
tex->lod_info.lod = read_rvalue(s_lod);
|
||||||
if (tex->lod_info.lod == NULL) {
|
if (tex->lod_info.lod == NULL) {
|
||||||
ir_read_error(NULL, "when reading LOD in (%s ...)",
|
ir_read_error(NULL, "when reading LOD in (%s ...)",
|
||||||
|
|
|
@ -63,6 +63,7 @@ ir_rvalue_visitor::visit_leave(ir_texture *ir)
|
||||||
break;
|
break;
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
case ir_txl:
|
case ir_txl:
|
||||||
|
case ir_txs:
|
||||||
handle_rvalue(&ir->lod_info.lod);
|
handle_rvalue(&ir->lod_info.lod);
|
||||||
break;
|
break;
|
||||||
case ir_txd:
|
case ir_txd:
|
||||||
|
|
|
@ -258,6 +258,7 @@ ir_tree_grafting_visitor::visit_enter(ir_texture *ir)
|
||||||
break;
|
break;
|
||||||
case ir_txf:
|
case ir_txf:
|
||||||
case ir_txl:
|
case ir_txl:
|
||||||
|
case ir_txs:
|
||||||
if (do_graft(&ir->lod_info.lod))
|
if (do_graft(&ir->lod_info.lod))
|
||||||
return visit_stop;
|
return visit_stop;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -716,6 +716,7 @@ fs_visitor::emit_texture_gen4(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_txf:
|
||||||
|
case ir_txs:
|
||||||
assert(!"GLSL 1.30 features unsupported");
|
assert(!"GLSL 1.30 features unsupported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -837,6 +838,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -926,6 +928,7 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -949,7 +952,8 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
|
||||||
case ir_txb: inst = emit(FS_OPCODE_TXB, dst); break;
|
case ir_txb: inst = emit(FS_OPCODE_TXB, dst); break;
|
||||||
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.");
|
case ir_txf: assert(!"TXF unsupported."); break;
|
||||||
|
case ir_txs: assert(!"TXS unsupported."); break;
|
||||||
}
|
}
|
||||||
inst->base_mrf = base_mrf;
|
inst->base_mrf = base_mrf;
|
||||||
inst->mlen = mlen;
|
inst->mlen = mlen;
|
||||||
|
|
|
@ -2148,6 +2148,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2469,6 +2469,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
|
||||||
ir->lod_info.grad.dPdy->accept(this);
|
ir->lod_info.grad.dPdy->accept(this);
|
||||||
dy = this->result;
|
dy = this->result;
|
||||||
break;
|
break;
|
||||||
|
case ir_txs:
|
||||||
case ir_txf: /* TODO: use TGSI_OPCODE_TXF here */
|
case ir_txf: /* TODO: use TGSI_OPCODE_TXF here */
|
||||||
assert(!"GLSL 1.30 features unsupported");
|
assert(!"GLSL 1.30 features unsupported");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue