/** Flags to _texture() */
#define TEX_PROJECT 1
#define TEX_OFFSET 2
+#define TEX_COMPONENT 4
ir_function_signature *_texture(ir_texture_opcode opcode,
builtin_available_predicate avail,
tex->offset = var_ref(offset);
}
+ if (opcode == ir_tg4) {
+ if (flags & TEX_COMPONENT) {
+ ir_variable *component =
+ new(mem_ctx) ir_variable(glsl_type::int_type, "comp", ir_var_const_in);
+ sig->parameters.push_tail(component);
+ tex->lod_info.component = var_ref(component);
+ }
+ else {
+ tex->lod_info.component = imm(0);
+ }
+ }
+
/* The "bias" parameter comes /after/ the "offset" parameter, which is
* inconsistent with both textureLodOffset and textureGradOffset.
*/
* <type> <sampler> <coordinate> <sample_index>)
* (txs <type> <sampler> <lod>)
* (lod <type> <sampler> <coordinate>)
- * (tg4 <type> <sampler> <coordinate> 0)
+ * (tg4 <type> <sampler> <coordinate> <offset> <component>)
* (query_levels <type> <sampler>)
*/
class ir_texture : public ir_rvalue {
ir_rvalue *lod; /**< Floating point LOD */
ir_rvalue *bias; /**< Floating point LOD bias */
ir_rvalue *sample_index; /**< MSAA sample index */
+ ir_rvalue *component; /**< Gather component selector */
struct {
ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */
ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */
switch (this->op) {
case ir_tex:
case ir_lod:
- case ir_tg4:
case ir_query_levels:
break;
case ir_txb:
new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(mem_ctx, ht);
new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(mem_ctx, ht);
break;
+ case ir_tg4:
+ new_tex->lod_info.component = this->lod_info.component->clone(mem_ctx, ht);
+ break;
}
return new_tex;
switch (this->op) {
case ir_tex:
case ir_lod:
- case ir_tg4:
case ir_query_levels:
break;
case ir_txb:
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
break;
+ case ir_tg4:
+ s = this->lod_info.component->accept(v);
+ if (s != visit_continue)
+ return (s == visit_continue_with_parent) ? visit_continue : s;
+ break;
}
return (s == visit_stop) ? s : v->visit_leave(this);
{
case ir_tex:
case ir_lod:
- case ir_tg4:
case ir_query_levels:
break;
case ir_txb:
ir->lod_info.grad.dPdy->accept(this);
printf(")");
break;
+ case ir_tg4:
+ ir->lod_info.component->accept(this);
+ break;
};
printf(")");
}
s_list *s_shadow = NULL;
s_expression *s_lod = NULL;
s_expression *s_sample_index = NULL;
+ s_expression *s_component = NULL;
ir_texture_opcode op = ir_tex; /* silence warning */
s_pattern txs_pattern[] =
{ "txs", s_type, s_sampler, s_lod };
s_pattern tg4_pattern[] =
- { "tg4", s_type, s_sampler, s_coord, s_offset };
+ { "tg4", s_type, s_sampler, s_coord, s_offset, s_component };
s_pattern query_levels_pattern[] =
{ "query_levels", s_type, s_sampler };
s_pattern other_pattern[] =
}
break;
}
+ case ir_tg4:
+ tex->lod_info.component = read_rvalue(s_component);
+ if (tex->lod_info.component == NULL) {
+ ir_read_error(NULL, "when reading component in (tg4 ...)");
+ return NULL;
+ }
+ break;
default:
// tex and lod don't have any extra parameters.
break;
switch (ir->op) {
case ir_tex:
case ir_lod:
- case ir_tg4:
case ir_query_levels:
break;
case ir_txb:
handle_rvalue(&ir->lod_info.grad.dPdx);
handle_rvalue(&ir->lod_info.grad.dPdy);
break;
+ case ir_tg4:
+ handle_rvalue(&ir->lod_info.component);
+ break;
}
return visit_continue;
switch (ir->op) {
case ir_tex:
case ir_lod:
- case ir_tg4:
case ir_query_levels:
break;
case ir_txb:
do_graft(&ir->lod_info.grad.dPdy))
return visit_stop;
break;
+ case ir_tg4:
+ if (do_graft(&ir->lod_info.component))
+ return visit_stop;
+ break;
}
return visit_continue;