}
#define PROGRAM_IMMEDIATE PROGRAM_FILE_MAX
-#define PROGRAM_ANY_CONST ((1 << PROGRAM_LOCAL_PARAM) | \
- (1 << PROGRAM_ENV_PARAM) | \
- (1 << PROGRAM_STATE_VAR) | \
+#define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) | \
(1 << PROGRAM_CONSTANT) | \
(1 << PROGRAM_UNIFORM))
this->index2D = 0;
this->type = type ? type->base_type : GLSL_TYPE_ERROR;
this->reladdr = NULL;
+ this->reladdr2 = NULL;
+ this->has_index2 = false;
}
st_src_reg(gl_register_file file, int index, int type)
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
this->reladdr = NULL;
+ this->reladdr2 = NULL;
+ this->has_index2 = false;
}
st_src_reg(gl_register_file file, int index, int type, int index2D)
this->swizzle = SWIZZLE_XYZW;
this->negate = 0;
this->reladdr = NULL;
+ this->reladdr2 = NULL;
+ this->has_index2 = false;
}
st_src_reg()
this->swizzle = 0;
this->negate = 0;
this->reladdr = NULL;
+ this->reladdr2 = NULL;
+ this->has_index2 = false;
}
explicit st_src_reg(st_dst_reg reg);
int type; /** GLSL_TYPE_* from GLSL IR (enum glsl_base_type) */
/** Register index should be offset by the integer in this reg. */
st_src_reg *reladdr;
+ st_src_reg *reladdr2;
+ bool has_index2;
};
class st_dst_reg {
public:
+ st_dst_reg(gl_register_file file, int writemask, int type, int index)
+ {
+ this->file = file;
+ this->index = index;
+ this->writemask = writemask;
+ this->cond_mask = COND_TR;
+ this->reladdr = NULL;
+ this->type = type;
+ }
+
st_dst_reg(gl_register_file file, int writemask, int type)
{
this->file = file;
this->negate = 0;
this->reladdr = reg.reladdr;
this->index2D = 0;
+ this->reladdr2 = NULL;
+ this->has_index2 = false;
}
st_dst_reg::st_dst_reg(st_src_reg reg)
static st_dst_reg undef_dst = st_dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP, GLSL_TYPE_ERROR);
-static st_dst_reg address_reg = st_dst_reg(PROGRAM_ADDRESS, WRITEMASK_X, GLSL_TYPE_FLOAT);
+static st_dst_reg address_reg = st_dst_reg(PROGRAM_ADDRESS, WRITEMASK_X, GLSL_TYPE_FLOAT, 0);
+static st_dst_reg address_reg2 = st_dst_reg(PROGRAM_ADDRESS, WRITEMASK_X, GLSL_TYPE_FLOAT, 1);
static void
fail_link(struct gl_shader_program *prog, const char *fmt, ...) PRINTFLIKE(2, 3);
* sources into temps.
*/
num_reladdr += dst.reladdr != NULL;
- num_reladdr += src0.reladdr != NULL;
- num_reladdr += src1.reladdr != NULL;
- num_reladdr += src2.reladdr != NULL;
+ num_reladdr += src0.reladdr != NULL || src0.reladdr2 != NULL;
+ num_reladdr += src1.reladdr != NULL || src1.reladdr2 != NULL;
+ num_reladdr += src2.reladdr != NULL || src2.reladdr2 != NULL;
reladdr_to_temp(ir, &src2, &num_reladdr);
reladdr_to_temp(ir, &src1, &num_reladdr);
inst->function = NULL;
- if (op == TGSI_OPCODE_ARL || op == TGSI_OPCODE_UARL)
- this->num_address_regs = 1;
-
/* Update indirect addressing status used by TGSI */
if (dst.reladdr) {
switch(dst.file) {
- case PROGRAM_LOCAL_PARAM:
- case PROGRAM_ENV_PARAM:
case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT:
case PROGRAM_UNIFORM:
for (i=0; i<3; i++) {
if(inst->src[i].reladdr) {
switch(inst->src[i].file) {
- case PROGRAM_LOCAL_PARAM:
- case PROGRAM_ENV_PARAM:
case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT:
case PROGRAM_UNIFORM:
if (src0.type == GLSL_TYPE_INT || src0.type == GLSL_TYPE_UINT)
op = TGSI_OPCODE_UARL;
+ assert(dst.file == PROGRAM_ADDRESS);
+ if (dst.index >= this->num_address_regs)
+ this->num_address_regs = dst.index + 1;
+
emit(NULL, op, dst, src0);
}
/* Search immediate storage to see if we already have an identical
* immediate that we can use instead of adding a duplicate entry.
*/
- foreach_iter(exec_list_iterator, iter, this->immediates) {
- entry = (immediate_storage *)iter.get();
+ foreach_list(node, &this->immediates) {
+ entry = (immediate_storage *) node;
if (entry->size == size &&
entry->type == datatype &&
* at link time.
*/
return 1;
+ case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_INTERFACE:
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
variable_storage *entry;
- foreach_iter(exec_list_iterator, iter, this->variables) {
- entry = (variable_storage *)iter.get();
+ foreach_list(node, &this->variables) {
+ entry = (variable_storage *) node;
if (entry->var == var)
return entry;
if (strcmp(ir->name, "gl_FragCoord") == 0) {
struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
- fp->OriginUpperLeft = ir->origin_upper_left;
- fp->PixelCenterInteger = ir->pixel_center_integer;
+ fp->OriginUpperLeft = ir->data.origin_upper_left;
+ fp->PixelCenterInteger = ir->data.pixel_center_integer;
}
- if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
+ if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
unsigned int i;
const ir_state_slot *const slots = ir->state_slots;
assert(ir->state_slots != NULL);
void
glsl_to_tgsi_visitor::visit(ir_loop *ir)
{
- ir_dereference_variable *counter = NULL;
-
- if (ir->counter != NULL)
- counter = new(ir) ir_dereference_variable(ir->counter);
-
- if (ir->from != NULL) {
- assert(ir->counter != NULL);
-
- ir_assignment *a = new(ir) ir_assignment(counter, ir->from, NULL);
-
- a->accept(this);
- delete a;
- }
-
emit(NULL, TGSI_OPCODE_BGNLOOP);
- if (ir->to) {
- ir_expression *e =
- new(ir) ir_expression(ir->cmp, glsl_type::bool_type,
- counter, ir->to);
- ir_if *if_stmt = new(ir) ir_if(e);
-
- ir_loop_jump *brk = new(ir) ir_loop_jump(ir_loop_jump::jump_break);
-
- if_stmt->then_instructions.push_tail(brk);
-
- if_stmt->accept(this);
-
- delete if_stmt;
- delete e;
- delete brk;
- }
-
visit_exec_list(&ir->body_instructions, this);
- if (ir->increment) {
- ir_expression *e =
- new(ir) ir_expression(ir_binop_add, counter->type,
- counter, ir->increment);
-
- ir_assignment *a = new(ir) ir_assignment(counter, e, NULL);
-
- a->accept(this);
- delete a;
- delete e;
- }
-
emit(NULL, TGSI_OPCODE_ENDLOOP);
}
assert(sig);
- foreach_iter(exec_list_iterator, iter, sig->body) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(node, &sig->body) {
+ ir_instruction *ir = (ir_instruction *) node;
ir->accept(this);
}
glsl_to_tgsi_visitor::reladdr_to_temp(ir_instruction *ir,
st_src_reg *reg, int *num_reladdr)
{
- if (!reg->reladdr)
+ if (!reg->reladdr && !reg->reladdr2)
return;
- emit_arl(ir, address_reg, *reg->reladdr);
+ if (reg->reladdr) emit_arl(ir, address_reg, *reg->reladdr);
+ if (reg->reladdr2) emit_arl(ir, address_reg2, *reg->reladdr2);
if (*num_reladdr != 1) {
st_src_reg temp = get_temp(glsl_type::vec4_type);
case ir_binop_vector_extract:
case ir_triop_vector_insert:
case ir_binop_ldexp:
+ case ir_binop_carry:
+ case ir_binop_borrow:
+ case ir_binop_imul_high:
/* This operation is not supported, or should have already been handled.
*/
assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()");
ir_variable *var = ir->var;
if (!entry) {
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
- var->location);
+ var->data.location);
this->variables.push_tail(entry);
break;
case ir_var_shader_in:
* generic attributes (glBindVertexLocation), and
* user-defined varyings.
*/
- assert(var->location != -1);
+ assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
- var->location);
+ var->data.location);
break;
case ir_var_shader_out:
- assert(var->location != -1);
+ assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_OUTPUT,
- var->location + var->index);
+ var->data.location
+ + var->data.index);
break;
case ir_var_system_value:
entry = new(mem_ctx) variable_storage(var,
PROGRAM_SYSTEM_VALUE,
- var->location);
+ var->data.location);
break;
case ir_var_auto:
case ir_var_temporary:
ir_constant *index;
st_src_reg src;
int element_size = type_size(ir->type);
+ bool is_2D_input;
index = ir->array_index->constant_expression_value();
ir->array->accept(this);
src = this->result;
+ is_2D_input = this->prog->Target == GL_GEOMETRY_PROGRAM_NV &&
+ src.file == PROGRAM_INPUT &&
+ ir->array->ir_type != ir_type_dereference_array;
+
+ if (is_2D_input)
+ element_size = 1;
+
if (index) {
- src.index += index->value.i[0] * element_size;
+ if (is_2D_input) {
+ src.index2D = index->value.i[0];
+ src.has_index2 = true;
+ } else
+ src.index += index->value.i[0] * element_size;
} else {
/* Variable index array dereference. It eats the "vec4" of the
* base of the array and an index that offsets the TGSI register
/* 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) {
+ if (!is_2D_input && src.reladdr != NULL) {
st_src_reg accum_reg = get_temp(native_integers ?
glsl_type::int_type : glsl_type::float_type);
index_reg = accum_reg;
}
- src.reladdr = ralloc(mem_ctx, st_src_reg);
- memcpy(src.reladdr, &index_reg, sizeof(index_reg));
+ if (is_2D_input) {
+ src.reladdr2 = ralloc(mem_ctx, st_src_reg);
+ memcpy(src.reladdr2, &index_reg, sizeof(index_reg));
+ src.index2D = 0;
+ src.has_index2 = true;
+ } else {
+ src.reladdr = ralloc(mem_ctx, st_src_reg);
+ memcpy(src.reladdr, &index_reg, sizeof(index_reg));
+ }
}
/* If the type is smaller than a vec4, replicate the last channel out. */
assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
l.writemask = WRITEMASK_XYZW;
} else if (ir->lhs->type->is_scalar() &&
- ir->lhs->variable_referenced()->mode == ir_var_shader_out) {
+ ir->lhs->variable_referenced()->data.mode == ir_var_shader_out) {
/* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
* FINISHME: W component of fragment shader output zero, work correctly.
*/
st_src_reg temp_base = get_temp(ir->type);
st_dst_reg temp = st_dst_reg(temp_base);
- foreach_iter(exec_list_iterator, iter, ir->components) {
- ir_constant *field_value = (ir_constant *)iter.get();
+ foreach_list(node, &ir->components) {
+ ir_constant *field_value = (ir_constant *) node;
int size = type_size(field_value->type);
assert(size > 0);
{
function_entry *entry;
- foreach_iter(exec_list_iterator, iter, this->function_signatures) {
- entry = (function_entry *)iter.get();
+ foreach_list(node, &this->function_signatures) {
+ entry = (function_entry *) node;
if (entry->sig == sig)
return entry;
entry->bgn_inst = NULL;
/* Allocate storage for all the parameters. */
- foreach_iter(exec_list_iterator, iter, sig->parameters) {
- ir_variable *param = (ir_variable *)iter.get();
+ foreach_list(node, &sig->parameters) {
+ ir_variable *param = (ir_variable *) node;
variable_storage *storage;
storage = find_variable_storage(param);
int i;
/* Process in parameters. */
- exec_list_iterator sig_iter = sig->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param_rval = (ir_rvalue *)iter.get();
- ir_variable *param = (ir_variable *)sig_iter.get();
+ foreach_two_lists(formal_node, &sig->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_rvalue *param_rval = (ir_rvalue *) actual_node;
+ ir_variable *param = (ir_variable *) formal_node;
- if (param->mode == ir_var_function_in ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_in ||
+ param->data.mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);
r.index++;
}
}
-
- sig_iter.next();
}
- assert(!sig_iter.has_next());
/* Emit call instruction */
call_inst = emit(ir, TGSI_OPCODE_CAL);
call_inst->function = entry;
/* Process out parameters. */
- sig_iter = sig->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param_rval = (ir_rvalue *)iter.get();
- ir_variable *param = (ir_variable *)sig_iter.get();
+ foreach_two_lists(formal_node, &sig->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_rvalue *param_rval = (ir_rvalue *) actual_node;
+ ir_variable *param = (ir_variable *) formal_node;
- if (param->mode == ir_var_function_out ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_out ||
+ param->data.mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);
r.index++;
}
}
-
- sig_iter.next();
}
- assert(!sig_iter.has_next());
/* Process return value. */
this->result = entry->return_reg;
case ir_tg4:
assert(!"Unexpected ir_tg4 opcode");
break;
+ case ir_query_levels:
+ assert(!"Unexpected ir_query_levels opcode");
+ break;
}
if (ir->projector) {
if_inst = emit(ir->condition, TGSI_OPCODE_ENDIF);
}
+
void
glsl_to_tgsi_visitor::visit(ir_emit_vertex *ir)
{
- assert(!"Geometry shaders not supported.");
+ assert(this->prog->Target == GL_GEOMETRY_PROGRAM_NV);
+ emit(ir, TGSI_OPCODE_EMIT);
}
void
glsl_to_tgsi_visitor::visit(ir_end_primitive *ir)
{
- assert(!"Geometry shaders not supported.");
+ assert(this->prog->Target == GL_GEOMETRY_PROGRAM_NV);
+ emit(ir, TGSI_OPCODE_ENDPRIM);
}
glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
{
v->samplers_used = 0;
- foreach_iter(exec_list_iterator, iter, v->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &v->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
if (is_tex_instruction(inst->op)) {
v->samplers_used |= 1 << inst->sampler;
memset(tempWrites, 0, sizeof(unsigned) * MAX_TEMPS);
memset(outputWrites, 0, sizeof(outputWrites));
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
unsigned prevWriteMask = 0;
/* Give up if we encounter relative addressing or flow control. */
void
glsl_to_tgsi_visitor::rename_temp_register(int index, int new_index)
{
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
unsigned j;
for (j=0; j < num_inst_src_regs(inst->op); j++) {
int loop_start = -1; /* index of the first active BGNLOOP (if any) */
unsigned i = 0, j;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
for (j=0; j < num_inst_src_regs(inst->op); j++) {
if (inst->src[j].file == PROGRAM_TEMPORARY &&
int loop_start = -1; /* index of the first active BGNLOOP (if any) */
int i = 0;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) {
return (depth == 0) ? i : loop_start;
int last = -1; /* index of last instruction that reads the temporary */
unsigned i = 0, j;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
for (j=0; j < num_inst_src_regs(inst->op); j++) {
if (inst->src[j].file == PROGRAM_TEMPORARY &&
int last = -1; /* index of last instruction that writes to the temporary */
int i = 0;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index)
last = (depth == 0) ? i : -2;
int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4);
int level = 0;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
int acp_base = inst->src[r].index * 4;
if (inst->src[r].file != PROGRAM_TEMPORARY ||
- inst->src[r].reladdr)
+ inst->src[r].reladdr ||
+ inst->src[r].reladdr2)
continue;
/* See if we can find entries in the ACP consisting of MOVs
*/
inst->src[r].file = first->src[0].file;
inst->src[r].index = first->src[0].index;
+ inst->src[r].index2D = first->src[0].index2D;
+ inst->src[r].has_index2 = first->src[0].has_index2;
int swizzle = 0;
for (int i = 0; i < 4; i++) {
!inst->dst.reladdr &&
!inst->saturate &&
!inst->src[0].reladdr &&
+ !inst->src[0].reladdr2 &&
!inst->src[0].negate) {
for (int i = 0; i < 4; i++) {
if (inst->dst.writemask & (1 << i)) {
int last_read = get_last_temp_read(i);
int j = 0;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list_safe(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == i &&
j > last_read)
{
- iter.remove();
+ inst->remove();
delete inst;
}
int level = 0;
int removed = 0;
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
/* Now actually remove the instructions that are completely dead and update
* the writemask of other instructions with dead channels.
*/
- foreach_iter(exec_list_iterator, iter, this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list_safe(node, &this->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
if (!inst->dead_mask || !inst->dst.writemask)
continue;
else if ((inst->dst.writemask & ~inst->dead_mask) == 0) {
- iter.remove();
+ inst->remove();
delete inst;
removed++;
} else
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
- foreach_iter(exec_list_iterator, iter, original->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &original->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
glsl_to_tgsi_instruction *newinst;
st_src_reg src_regs[3];
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
- foreach_iter(exec_list_iterator, iter, original->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get();
+ foreach_list(node, &original->instructions) {
+ glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
glsl_to_tgsi_instruction *newinst;
st_src_reg src_regs[3];
struct ureg_src *immediates;
struct ureg_dst outputs[PIPE_MAX_SHADER_OUTPUTS];
struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS];
- struct ureg_dst address[1];
+ struct ureg_dst address[2];
struct ureg_src samplers[PIPE_MAX_SAMPLERS];
struct ureg_src systemValues[SYSTEM_VALUE_MAX];
case PROGRAM_ARRAY:
return ureg_src(dst_register(t, file, index));
- case PROGRAM_ENV_PARAM:
- case PROGRAM_LOCAL_PARAM:
case PROGRAM_UNIFORM:
assert(index >= 0);
return t->constants[index];
{
struct ureg_src src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D);
+ if (t->procType == TGSI_PROCESSOR_GEOMETRY && src_reg->has_index2) {
+ src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D);
+ if (src_reg->reladdr2)
+ src = ureg_src_dimension_indirect(src, ureg_src(t->address[1]),
+ src_reg->index2D);
+ else
+ src = ureg_src_dimension(src, src_reg->index2D);
+ }
+
src = ureg_swizzle(src,
GET_SWZ(src_reg->swizzle, 0) & 0x3,
GET_SWZ(src_reg->swizzle, 1) & 0x3,
t->outputs[i] = ureg_DECL_output(ureg,
outputSemanticName[i],
outputSemanticIndex[i]);
+ if (outputSemanticName[i] == TGSI_SEMANTIC_FOG) {
+ /* force register to contain a fog coordinate in the form (F, 0, 0, 1). */
+ ureg_MOV(ureg,
+ ureg_writemask(t->outputs[i], TGSI_WRITEMASK_YZW),
+ ureg_imm4f(ureg, 0.0f, 0.0f, 0.0f, 1.0f));
+ t->outputs[i] = ureg_writemask(t->outputs[i], TGSI_WRITEMASK_X);
+ }
}
if (passthrough_edgeflags)
emit_edgeflags(t);
/* Declare address register.
*/
if (program->num_address_regs > 0) {
- assert(program->num_address_regs == 1);
+ assert(program->num_address_regs <= 2);
t->address[0] = ureg_DECL_address(ureg);
+ if (program->num_address_regs == 2)
+ t->address[1] = ureg_DECL_address(ureg);
}
/* Declare misc input registers
for (i = 0; i < proginfo->Parameters->NumParameters; i++) {
switch (proginfo->Parameters->Parameters[i].Type) {
- case PROGRAM_ENV_PARAM:
- case PROGRAM_LOCAL_PARAM:
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
t->constants[i] = ureg_DECL_constant(ureg, i);
goto out;
}
i = 0;
- foreach_iter(exec_list_iterator, iter, program->immediates) {
- immediate_storage *imm = (immediate_storage *)iter.get();
+ foreach_list(node, &program->immediates) {
+ immediate_storage *imm = (immediate_storage *) node;
assert(i < program->num_immediates);
t->immediates[i++] = emit_immediate(t, imm->values, imm->type, imm->size);
}
assert(i == program->num_immediates);
/* texture samplers */
- for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) {
if (program->samplers_used & (1 << i)) {
t->samplers[i] = ureg_DECL_sampler(ureg, i);
}
/* Emit each instruction in turn:
*/
- foreach_iter(exec_list_iterator, iter, program->instructions) {
+ foreach_list(n, &program->instructions) {
set_insn_start(t, ureg_get_instruction_number(ureg));
- compile_tgsi_instruction(t, (glsl_to_tgsi_instruction *)iter.get(),
- clamp_color);
+ compile_tgsi_instruction(t, (glsl_to_tgsi_instruction *) n, clamp_color);
}
/* Fix up all emitted labels:
* prog->ParameterValues to get reallocated (e.g., anything that adds a
* program constant) has to happen before creating this linkage.
*/
- for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (program->shader_program->_LinkedShaders[i] == NULL)
continue;
}
/* ----------------------------- End TGSI code ------------------------------ */
+
+static unsigned
+shader_stage_to_ptarget(gl_shader_stage stage)
+{
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ return PIPE_SHADER_VERTEX;
+ case MESA_SHADER_FRAGMENT:
+ return PIPE_SHADER_FRAGMENT;
+ case MESA_SHADER_GEOMETRY:
+ return PIPE_SHADER_GEOMETRY;
+ }
+
+ assert(!"should not be reached");
+ return PIPE_SHADER_VERTEX;
+}
+
+
/**
* Convert a shader's GLSL IR into a Mesa gl_program, although without
* generating Mesa IR.
{
glsl_to_tgsi_visitor* v;
struct gl_program *prog;
- GLenum target;
+ GLenum target = _mesa_shader_stage_to_program(shader->Stage);
bool progress;
struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
+ &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
struct pipe_screen *pscreen = ctx->st->pipe->screen;
- unsigned ptarget;
-
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
- target = GL_VERTEX_PROGRAM_ARB;
- ptarget = PIPE_SHADER_VERTEX;
- break;
- case GL_FRAGMENT_SHADER:
- target = GL_FRAGMENT_PROGRAM_ARB;
- ptarget = PIPE_SHADER_FRAGMENT;
- break;
- case GL_GEOMETRY_SHADER:
- target = GL_GEOMETRY_PROGRAM_NV;
- ptarget = PIPE_SHADER_GEOMETRY;
- break;
- default:
- assert(!"should not be reached");
- return NULL;
- }
+ unsigned ptarget = shader_stage_to_ptarget(shader->Stage);
validate_ir_tree(shader->ir);
do {
progress = GL_FALSE;
- foreach_iter(exec_list_iterator, iter, v->function_signatures) {
- function_entry *entry = (function_entry *)iter.get();
+ foreach_list(node, &v->function_signatures) {
+ function_entry *entry = (function_entry *) node;
if (!entry->bgn_inst) {
v->current_function = entry;
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("\n");
printf("GLSL IR for linked %s program %d:\n",
- _mesa_glsl_shader_target_name(shader->Type),
+ _mesa_shader_stage_to_string(shader->Stage),
shader_program->Name);
_mesa_print_ir(shader->ir, NULL);
printf("\n");
prog->Instructions = NULL;
prog->NumInstructions = 0;
- do_set_program_inouts(shader->ir, prog, shader->Type);
+ do_set_program_inouts(shader->ir, prog, shader->Stage);
count_resources(v, prog);
_mesa_reference_program(ctx, &shader->Program, prog);
case GL_GEOMETRY_SHADER:
stgp = (struct st_geometry_program *)prog;
stgp->glsl_to_tgsi = v;
+ stgp->Base.InputType = shader_program->Geom.InputType;
+ stgp->Base.OutputType = shader_program->Geom.OutputType;
+ stgp->Base.VerticesOut = shader_program->Geom.VerticesOut;
break;
default:
assert(!"should not be reached");
shader = rzalloc(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
+ shader->Stage = _mesa_shader_enum_to_shader_stage(type);
shader->Name = name;
_mesa_init_shader(ctx, shader);
}
{
assert(prog->LinkStatus);
- for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (prog->_LinkedShaders[i] == NULL)
continue;
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
const struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)];
+ &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)];
/* If there are forms of indirect addressing that the driver
* cannot handle, perform the lowering pass.
validate_ir_tree(ir);
}
- for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_program *linked_prog;
if (prog->_LinkedShaders[i] == NULL)
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
linked_prog);
if (!ctx->Driver.ProgramStringNotify(ctx,
- _mesa_program_index_to_target(i),
+ _mesa_shader_stage_to_program(i),
linked_prog)) {
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
NULL);