#define MAX_TEMPS 4096
+/* will be 4 for GLSL 4.00 */
+#define MAX_GLSL_TEXTURE_OFFSET 1
+
class st_src_reg;
class st_dst_reg;
int sampler; /**< sampler index */
int tex_target; /**< One of TEXTURE_*_INDEX */
GLboolean tex_shadow;
+ struct tgsi_texture_offset tex_offsets[MAX_GLSL_TEXTURE_OFFSET];
+ unsigned tex_offset_num_offset;
int dead_mask; /**< Used in dead code elimination */
class function_entry *function; /* Set on TGSI_OPCODE_CAL or TGSI_OPCODE_BGNSUB */
void emit_scalar(ir_instruction *ir, unsigned op,
st_dst_reg dst, st_src_reg src0, st_src_reg src1);
+ void try_emit_float_set(ir_instruction *ir, unsigned op, st_dst_reg dst);
+
void emit_arl(ir_instruction *ir, st_dst_reg dst, st_src_reg src0);
void emit_scs(ir_instruction *ir, unsigned op,
inst->function = NULL;
- if (op == TGSI_OPCODE_ARL)
+ if (op == TGSI_OPCODE_ARL || op == TGSI_OPCODE_UARL)
this->num_address_regs = 1;
/* Update indirect addressing status used by TGSI */
}
this->instructions.push_tail(inst);
-
+
+ if (native_integers)
+ try_emit_float_set(ir, op, dst);
+
return inst;
}
return emit(ir, op, undef_dst, undef_src, undef_src, undef_src);
}
+ /**
+ * Emits the code to convert the result of float SET instructions to integers.
+ */
+void
+glsl_to_tgsi_visitor::try_emit_float_set(ir_instruction *ir, unsigned op,
+ st_dst_reg dst)
+{
+ if ((op == TGSI_OPCODE_SEQ ||
+ op == TGSI_OPCODE_SNE ||
+ op == TGSI_OPCODE_SGE ||
+ op == TGSI_OPCODE_SLT))
+ {
+ st_src_reg src = st_src_reg(dst);
+ src.negate = ~src.negate;
+ dst.type = GLSL_TYPE_FLOAT;
+ emit(ir, TGSI_OPCODE_F2I, dst, src);
+ }
+}
+
/**
* Determines whether to use an integer, unsigned integer, or float opcode
* based on the operands and input opcode, then emits the result.
- *
- * TODO: type checking for remaining TGSI opcodes
*/
unsigned
glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op,
if (src0.type == GLSL_TYPE_FLOAT || src1.type == GLSL_TYPE_FLOAT)
type = GLSL_TYPE_FLOAT;
else if (native_integers)
- type = src0.type;
+ type = src0.type == GLSL_TYPE_BOOL ? GLSL_TYPE_INT : src0.type;
#define case4(c, f, i, u) \
case TGSI_OPCODE_##c: \
case3(SGE, ISGE, USGE);
case3(SLT, ISLT, USLT);
- case2iu(SHL, SHL);
case2iu(ISHR, USHR);
- case2iu(NOT, NOT);
- case2iu(AND, AND);
- case2iu(OR, OR);
- case2iu(XOR, XOR);
default: break;
}
glsl_to_tgsi_visitor::emit_arl(ir_instruction *ir,
st_dst_reg dst, st_src_reg src0)
{
- st_src_reg tmp = get_temp(glsl_type::float_type);
+ int op = TGSI_OPCODE_ARL;
- if (src0.type == GLSL_TYPE_INT)
- emit(NULL, TGSI_OPCODE_I2F, st_dst_reg(tmp), src0);
- else if (src0.type == GLSL_TYPE_UINT)
- emit(NULL, TGSI_OPCODE_U2F, st_dst_reg(tmp), src0);
- else
- tmp = src0;
-
- emit(NULL, TGSI_OPCODE_ARL, dst, tmp);
+ if (src0.type == GLSL_TYPE_INT || src0.type == GLSL_TYPE_UINT)
+ op = TGSI_OPCODE_UARL;
+
+ emit(NULL, op, dst, src0);
}
/**
switch (ir->operation) {
case ir_unop_logic_not:
if (result_dst.type != GLSL_TYPE_FLOAT)
- emit(ir, TGSI_OPCODE_SEQ, result_dst, op[0], st_src_reg_for_type(result_dst.type, 0));
+ emit(ir, TGSI_OPCODE_NOT, result_dst, op[0]);
else {
/* Previously 'SEQ dst, src, 0.0' was used for this. However, many
* older GPUs implement SEQ using multiple instructions (i915 uses two
emit(ir, TGSI_OPCODE_SLT, result_dst, op[0], op[1]);
break;
case ir_binop_greater:
- emit(ir, TGSI_OPCODE_SGT, result_dst, op[0], op[1]);
+ emit(ir, TGSI_OPCODE_SLT, result_dst, op[1], op[0]);
break;
case ir_binop_lequal:
- emit(ir, TGSI_OPCODE_SLE, result_dst, op[0], op[1]);
+ emit(ir, TGSI_OPCODE_SGE, result_dst, op[1], op[0]);
break;
case ir_binop_gequal:
emit(ir, TGSI_OPCODE_SGE, result_dst, op[0], op[1]);
st_src_reg temp = get_temp(native_integers ?
glsl_type::get_instance(ir->operands[0]->type->base_type, 4, 1) :
glsl_type::vec4_type);
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
- emit(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
-
- /* After the dot-product, the value will be an integer on the
- * range [0,4]. Zero becomes 1.0, and positive values become zero.
- */
- emit_dp(ir, result_dst, temp, temp, vector_elements);
- if (result_dst.type == GLSL_TYPE_FLOAT) {
+ if (native_integers) {
+ st_dst_reg temp_dst = st_dst_reg(temp);
+ st_src_reg temp1 = st_src_reg(temp), temp2 = st_src_reg(temp);
+
+ emit(ir, TGSI_OPCODE_SEQ, st_dst_reg(temp), op[0], op[1]);
+
+ /* Emit 1-3 AND operations to combine the SEQ results. */
+ switch (ir->operands[0]->type->vector_elements) {
+ case 2:
+ break;
+ case 3:
+ temp_dst.writemask = WRITEMASK_Y;
+ temp1.swizzle = SWIZZLE_YYYY;
+ temp2.swizzle = SWIZZLE_ZZZZ;
+ emit(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
+ break;
+ case 4:
+ temp_dst.writemask = WRITEMASK_X;
+ temp1.swizzle = SWIZZLE_XXXX;
+ temp2.swizzle = SWIZZLE_YYYY;
+ emit(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
+ temp_dst.writemask = WRITEMASK_Y;
+ temp1.swizzle = SWIZZLE_ZZZZ;
+ temp2.swizzle = SWIZZLE_WWWW;
+ emit(ir, TGSI_OPCODE_AND, temp_dst, temp1, temp2);
+ }
+
+ temp1.swizzle = SWIZZLE_XXXX;
+ temp2.swizzle = SWIZZLE_YYYY;
+ emit(ir, TGSI_OPCODE_AND, result_dst, temp1, temp2);
+ } else {
+ emit(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
+
+ /* After the dot-product, the value will be an integer on the
+ * range [0,4]. Zero becomes 1.0, and positive values become zero.
+ */
+ emit_dp(ir, result_dst, temp, temp, vector_elements);
+
/* Negating the result of the dot-product gives values on the range
* [-4, 0]. Zero becomes 1.0, and negative values become zero.
* This is achieved using SGE.
st_src_reg sge_src = result_src;
sge_src.negate = ~sge_src.negate;
emit(ir, TGSI_OPCODE_SGE, result_dst, sge_src, st_src_reg_for_float(0.0));
- } else {
- /* The TGSI negate flag doesn't work for integers, so use SEQ 0
- * instead.
- */
- emit(ir, TGSI_OPCODE_SEQ, result_dst, result_src, st_src_reg_for_int(0));
}
} else {
emit(ir, TGSI_OPCODE_SEQ, result_dst, op[0], op[1]);
st_src_reg temp = get_temp(native_integers ?
glsl_type::get_instance(ir->operands[0]->type->base_type, 4, 1) :
glsl_type::vec4_type);
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
emit(ir, TGSI_OPCODE_SNE, st_dst_reg(temp), op[0], op[1]);
- /* After the dot-product, the value will be an integer on the
- * range [0,4]. Zero stays zero, and positive values become 1.0.
- */
- glsl_to_tgsi_instruction *const dp =
- emit_dp(ir, result_dst, temp, temp, vector_elements);
- if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
- result_dst.type == GLSL_TYPE_FLOAT) {
- /* The clamping to [0,1] can be done for free in the fragment
- * shader with a saturate.
- */
- dp->saturate = true;
- } else if (result_dst.type == GLSL_TYPE_FLOAT) {
- /* Negating the result of the dot-product gives values on the range
- * [-4, 0]. Zero stays zero, and negative values become 1.0. This
- * achieved using SLT.
- */
- st_src_reg slt_src = result_src;
- slt_src.negate = ~slt_src.negate;
- emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ if (native_integers) {
+ st_dst_reg temp_dst = st_dst_reg(temp);
+ st_src_reg temp1 = st_src_reg(temp), temp2 = st_src_reg(temp);
+
+ /* Emit 1-3 OR operations to combine the SNE results. */
+ switch (ir->operands[0]->type->vector_elements) {
+ case 2:
+ break;
+ case 3:
+ temp_dst.writemask = WRITEMASK_Y;
+ temp1.swizzle = SWIZZLE_YYYY;
+ temp2.swizzle = SWIZZLE_ZZZZ;
+ emit(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
+ break;
+ case 4:
+ temp_dst.writemask = WRITEMASK_X;
+ temp1.swizzle = SWIZZLE_XXXX;
+ temp2.swizzle = SWIZZLE_YYYY;
+ emit(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
+ temp_dst.writemask = WRITEMASK_Y;
+ temp1.swizzle = SWIZZLE_ZZZZ;
+ temp2.swizzle = SWIZZLE_WWWW;
+ emit(ir, TGSI_OPCODE_OR, temp_dst, temp1, temp2);
+ }
+
+ temp1.swizzle = SWIZZLE_XXXX;
+ temp2.swizzle = SWIZZLE_YYYY;
+ emit(ir, TGSI_OPCODE_OR, result_dst, temp1, temp2);
} else {
- emit(ir, TGSI_OPCODE_SNE, result_dst, result_src, st_src_reg_for_int(0));
+ /* After the dot-product, the value will be an integer on the
+ * range [0,4]. Zero stays zero, and positive values become 1.0.
+ */
+ glsl_to_tgsi_instruction *const dp =
+ emit_dp(ir, result_dst, temp, temp, vector_elements);
+ if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
+ /* The clamping to [0,1] can be done for free in the fragment
+ * shader with a saturate.
+ */
+ dp->saturate = true;
+ } else {
+ /* Negating the result of the dot-product gives values on the range
+ * [-4, 0]. Zero stays zero, and negative values become 1.0. This
+ * achieved using SLT.
+ */
+ st_src_reg slt_src = result_src;
+ slt_src.negate = ~slt_src.negate;
+ emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ }
}
} else {
emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
}
case ir_binop_logic_xor:
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
+ if (native_integers)
+ emit(ir, TGSI_OPCODE_XOR, result_dst, op[0], op[1]);
+ else
+ emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], op[1]);
break;
case ir_binop_logic_or: {
- /* After the addition, the value will be an integer on the
- * range [0,2]. Zero stays zero, and positive values become 1.0.
- */
- glsl_to_tgsi_instruction *add =
- emit(ir, TGSI_OPCODE_ADD, result_dst, op[0], op[1]);
- if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
- result_dst.type == GLSL_TYPE_FLOAT) {
- /* The clamping to [0,1] can be done for free in the fragment
- * shader with a saturate if floats are being used as boolean values.
- */
- add->saturate = true;
- } else if (result_dst.type == GLSL_TYPE_FLOAT) {
- /* Negating the result of the addition gives values on the range
- * [-2, 0]. Zero stays zero, and negative values become 1.0. This
- * is achieved using SLT.
+ if (native_integers) {
+ /* If integers are used as booleans, we can use an actual "or"
+ * instruction.
*/
- st_src_reg slt_src = result_src;
- slt_src.negate = ~slt_src.negate;
- emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ assert(native_integers);
+ emit(ir, TGSI_OPCODE_OR, result_dst, op[0], op[1]);
} else {
- /* Use an SNE on the result of the addition. Zero stays zero,
- * 1 stays 1, and 2 becomes 1.
+ /* After the addition, the value will be an integer on the
+ * range [0,2]. Zero stays zero, and positive values become 1.0.
*/
- emit(ir, TGSI_OPCODE_SNE, result_dst, result_src, st_src_reg_for_int(0));
+ glsl_to_tgsi_instruction *add =
+ emit(ir, TGSI_OPCODE_ADD, result_dst, op[0], op[1]);
+ if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
+ /* The clamping to [0,1] can be done for free in the fragment
+ * shader with a saturate if floats are being used as boolean values.
+ */
+ add->saturate = true;
+ } else {
+ /* Negating the result of the addition gives values on the range
+ * [-2, 0]. Zero stays zero, and negative values become 1.0. This
+ * is achieved using SLT.
+ */
+ st_src_reg slt_src = result_src;
+ slt_src.negate = ~slt_src.negate;
+ emit(ir, TGSI_OPCODE_SLT, result_dst, slt_src, st_src_reg_for_float(0.0));
+ }
}
break;
}
case ir_binop_logic_and:
- /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */
- emit(ir, TGSI_OPCODE_MUL, result_dst, op[0], op[1]);
+ /* If native integers are disabled, the bool args are stored as float 0.0
+ * or 1.0, so "mul" gives us "and". If they're enabled, just use the
+ * actual AND opcode.
+ */
+ if (native_integers)
+ emit(ir, TGSI_OPCODE_AND, result_dst, op[0], op[1]);
+ else
+ emit(ir, TGSI_OPCODE_MUL, result_dst, op[0], op[1]);
break;
case ir_binop_dot:
emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, op[0]);
break;
case ir_unop_i2f:
- case ir_unop_b2f:
if (native_integers) {
emit(ir, TGSI_OPCODE_I2F, result_dst, op[0]);
break;
}
+ /* fallthrough to next case otherwise */
+ case ir_unop_b2f:
+ if (native_integers) {
+ emit(ir, TGSI_OPCODE_AND, result_dst, op[0], st_src_reg_for_float(1.0));
+ break;
+ }
+ /* fallthrough to next case otherwise */
case ir_unop_i2u:
case ir_unop_u2i:
/* Converting between signed and unsigned integers is a no-op. */
- case ir_unop_b2i:
- /* Booleans are stored as integers (or floats in GLSL 1.20 and lower). */
result_src = op[0];
break;
+ case ir_unop_b2i:
+ if (native_integers) {
+ /* Booleans are stored as integers using ~0 for true and 0 for false.
+ * GLSL requires that int(bool) return 1 for true and 0 for false.
+ * This conversion is done with AND, but it could be done with NEG.
+ */
+ emit(ir, TGSI_OPCODE_AND, result_dst, op[0], st_src_reg_for_int(1));
+ } else {
+ /* Booleans and integers are both stored as floats when native
+ * integers are disabled.
+ */
+ result_src = op[0];
+ }
+ break;
case ir_unop_f2i:
if (native_integers)
emit(ir, TGSI_OPCODE_F2I, result_dst, op[0]);
emit(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_f2b:
+ emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
+ break;
case ir_unop_i2b:
- emit(ir, TGSI_OPCODE_SNE, result_dst, op[0],
- st_src_reg_for_type(result_dst.type, 0));
+ if (native_integers)
+ emit(ir, TGSI_OPCODE_INEG, result_dst, op[0]);
+ else
+ emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
break;
case ir_unop_trunc:
emit(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_bit_not:
- if (glsl_version >= 130) {
+ if (native_integers) {
emit(ir, TGSI_OPCODE_NOT, result_dst, op[0]);
break;
}
break;
}
case ir_binop_lshift:
- if (glsl_version >= 130) {
+ if (native_integers) {
emit(ir, TGSI_OPCODE_SHL, result_dst, op[0]);
break;
}
case ir_binop_rshift:
- if (glsl_version >= 130) {
+ if (native_integers) {
emit(ir, TGSI_OPCODE_ISHR, result_dst, op[0]);
break;
}
case ir_binop_bit_and:
- if (glsl_version >= 130) {
+ if (native_integers) {
emit(ir, TGSI_OPCODE_AND, result_dst, op[0]);
break;
}
case ir_binop_bit_xor:
- if (glsl_version >= 130) {
+ if (native_integers) {
emit(ir, TGSI_OPCODE_XOR, result_dst, op[0]);
break;
}
case ir_binop_bit_or:
- if (glsl_version >= 130) {
+ if (native_integers) {
emit(ir, TGSI_OPCODE_OR, result_dst, op[0]);
break;
}
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var->location);
- if (this->prog->Target == GL_VERTEX_PROGRAM_ARB &&
- var->location >= VERT_ATTRIB_GENERIC0) {
- _mesa_add_attribute(this->prog->Attributes,
- var->name,
- _mesa_sizeof_glsl_type(var->type->gl_type),
- var->type->gl_type,
- var->location - VERT_ATTRIB_GENERIC0);
- }
break;
case ir_var_out:
assert(var->location != -1);
if (element_size == 1) {
index_reg = this->result;
} else {
- index_reg = get_temp(glsl_type::float_type);
+ index_reg = get_temp(native_integers ?
+ glsl_type::int_type : glsl_type::float_type);
emit(ir, TGSI_OPCODE_MUL, st_dst_reg(index_reg),
- this->result, st_src_reg_for_float(element_size));
+ this->result, st_src_reg_for_type(index_reg.type, element_size));
}
/* If there was already a relative address register involved, add the
* new and the old together to get the new offset.
*/
if (src.reladdr != NULL) {
- st_src_reg accum_reg = get_temp(glsl_type::float_type);
+ st_src_reg accum_reg = get_temp(native_integers ?
+ glsl_type::int_type : glsl_type::float_type);
emit(ir, TGSI_OPCODE_ADD, st_dst_reg(accum_reg),
index_reg, *src.reladdr);
for (i = 0; i < type_size(ir->lhs->type); i++) {
st_src_reg l_src = st_src_reg(l);
+ st_src_reg condition_temp = condition;
l_src.swizzle = swizzle_for_size(ir->lhs->type->vector_elements);
+ if (native_integers) {
+ /* This is necessary because TGSI's CMP instruction expects the
+ * condition to be a float, and we store booleans as integers.
+ * If TGSI had a UCMP instruction or similar, this extra
+ * instruction would not be necessary.
+ */
+ condition_temp = get_temp(glsl_type::vec4_type);
+ condition.negate = 0;
+ emit(ir, TGSI_OPCODE_I2F, st_dst_reg(condition_temp), condition);
+ condition_temp.swizzle = condition.swizzle;
+ }
+
if (switch_order) {
- emit(ir, TGSI_OPCODE_CMP, l, condition, l_src, r);
+ emit(ir, TGSI_OPCODE_CMP, l, condition_temp, l_src, r);
} else {
- emit(ir, TGSI_OPCODE_CMP, l, condition, r, l_src);
+ emit(ir, TGSI_OPCODE_CMP, l, condition_temp, r, l_src);
}
l.index++;
inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
new_inst = emit(ir, inst->op, l, inst->src[0], inst->src[1], inst->src[2]);
new_inst->saturate = inst->saturate;
+ inst->dead_mask = inst->dst.writemask;
} else {
for (i = 0; i < type_size(ir->lhs->type); i++) {
emit(ir, TGSI_OPCODE_MOV, l, r);
void
glsl_to_tgsi_visitor::visit(ir_texture *ir)
{
- st_src_reg result_src, coord, lod_info, projector, dx, dy;
+ st_src_reg result_src, coord, lod_info, projector, dx, dy, offset;
st_dst_reg result_dst, coord_dst;
glsl_to_tgsi_instruction *inst = NULL;
unsigned opcode = TGSI_OPCODE_NOP;
opcode = TGSI_OPCODE_TXF;
ir->lod_info.lod->accept(this);
lod_info = this->result;
+ if (ir->offset) {
+ ir->offset->accept(this);
+ offset = this->result;
+ }
break;
}
+ const glsl_type *sampler_type = ir->sampler->type;
+
if (ir->projector) {
if (opcode == TGSI_OPCODE_TEX) {
/* Slot the projector in as the last component of the coord. */
tmp_src = get_temp(glsl_type::vec4_type);
st_dst_reg tmp_dst = st_dst_reg(tmp_src);
+ /* Projective division not allowed for array samplers. */
+ assert(!sampler_type->sampler_array);
+
tmp_dst.writemask = WRITEMASK_Z;
emit(ir, TGSI_OPCODE_MOV, tmp_dst, this->result);
* coord.
*/
ir->shadow_comparitor->accept(this);
- coord_dst.writemask = WRITEMASK_Z;
+
+ /* XXX This will need to be updated for cubemap array samplers. */
+ if (sampler_type->sampler_dimensionality == GLSL_SAMPLER_DIM_2D &&
+ sampler_type->sampler_array) {
+ coord_dst.writemask = WRITEMASK_W;
+ } else {
+ coord_dst.writemask = WRITEMASK_Z;
+ }
+
emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
coord_dst.writemask = WRITEMASK_XYZW;
}
inst = emit(ir, opcode, result_dst, coord, dx, dy);
else if (opcode == TGSI_OPCODE_TXQ)
inst = emit(ir, opcode, result_dst, lod_info);
- else
+ else if (opcode == TGSI_OPCODE_TXF) {
+ inst = emit(ir, opcode, result_dst, coord);
+ } else
inst = emit(ir, opcode, result_dst, coord);
if (ir->shadow_comparitor)
this->shader_program,
this->prog);
- const glsl_type *sampler_type = ir->sampler->type;
+ if (ir->offset) {
+ inst->tex_offset_num_offset = 1;
+ inst->tex_offsets[0].Index = offset.index;
+ inst->tex_offsets[0].File = offset.file;
+ inst->tex_offsets[0].SwizzleX = GET_SWZ(offset.swizzle, 0);
+ inst->tex_offsets[0].SwizzleY = GET_SWZ(offset.swizzle, 1);
+ inst->tex_offsets[0].SwizzleZ = GET_SWZ(offset.swizzle, 2);
+ }
switch (sampler_type->sampler_dimensionality) {
case GLSL_SAMPLER_DIM_1D:
/* Make modifications to fragment program info. */
prog->Parameters = _mesa_combine_parameter_lists(params,
original->prog->Parameters);
- prog->Attributes = _mesa_clone_parameter_list(original->prog->Attributes);
- prog->Varying = _mesa_clone_parameter_list(original->prog->Varying);
_mesa_free_parameter_list(params);
count_resources(v, prog);
fp->glsl_to_tgsi = v;
/* Make modifications to fragment program info. */
prog->Parameters = _mesa_clone_parameter_list(original->prog->Parameters);
- prog->Attributes = _mesa_clone_parameter_list(original->prog->Attributes);
- prog->Varying = _mesa_clone_parameter_list(original->prog->Varying);
count_resources(v, prog);
fp->glsl_to_tgsi = v;
}
return src;
}
+static struct tgsi_texture_offset
+translate_tex_offset(struct st_translate *t,
+ const struct tgsi_texture_offset *in_offset)
+{
+ struct tgsi_texture_offset offset;
+
+ assert(in_offset->File == PROGRAM_IMMEDIATE);
+
+ offset.File = TGSI_FILE_IMMEDIATE;
+ offset.Index = in_offset->Index;
+ offset.SwizzleX = in_offset->SwizzleX;
+ offset.SwizzleY = in_offset->SwizzleY;
+ offset.SwizzleZ = in_offset->SwizzleZ;
+
+ return offset;
+}
+
static void
compile_tgsi_instruction(struct st_translate *t,
const glsl_to_tgsi_instruction *inst)
GLuint i;
struct ureg_dst dst[1];
struct ureg_src src[4];
+ struct tgsi_texture_offset texoffsets[MAX_GLSL_TEXTURE_OFFSET];
+
unsigned num_dst;
unsigned num_src;
case TGSI_OPCODE_TXQ:
case TGSI_OPCODE_TXF:
src[num_src++] = t->samplers[inst->sampler];
+ for (i = 0; i < inst->tex_offset_num_offset; i++) {
+ texoffsets[i] = translate_tex_offset(t, &inst->tex_offsets[i]);
+ }
ureg_tex_insn(ureg,
inst->op,
dst, num_dst,
translate_texture_target(inst->tex_target, inst->tex_shadow),
+ texoffsets, inst->tex_offset_num_offset,
src, num_src);
return;
if (!prog)
return NULL;
prog->Parameters = _mesa_new_parameter_list();
- prog->Varying = _mesa_new_parameter_list();
- prog->Attributes = _mesa_new_parameter_list();
v->ctx = ctx;
v->prog = prog;
v->shader_program = shader_program;
progress = lower_quadop_vector(ir, false) || progress;
- if (options->EmitNoIfs) {
+ if (options->MaxIfDepth == 0)
progress = lower_discard(ir) || progress;
- progress = lower_if_to_cond_assign(ir) || progress;
- }
+
+ progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
if (options->EmitNoNoise)
progress = lower_noise(ir) || progress;
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
if (linked_prog) {
- bool ok = true;
-
- switch (prog->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER:
- _mesa_reference_vertprog(ctx, &prog->VertexProgram,
- (struct gl_vertex_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_FRAGMENT_SHADER:
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
- (struct gl_fragment_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_GEOMETRY_SHADER:
- _mesa_reference_geomprog(ctx, &prog->GeometryProgram,
- (struct gl_geometry_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
- linked_prog);
- break;
- }
- if (!ok) {
+ static const GLenum targets[] = {
+ GL_VERTEX_PROGRAM_ARB,
+ GL_FRAGMENT_PROGRAM_ARB,
+ GL_GEOMETRY_PROGRAM_NV
+ };
+
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ linked_prog);
+ if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ NULL);
_mesa_reference_program(ctx, &linked_prog, NULL);
return GL_FALSE;
}