st/glsl_to_tgsi: fix whitespace
everytime I open this file in emacs with show trailing whitespace or git add from it my screen flares with red. Just do a general cleanup, makes working on fp64 support not as jarring. I'm not saying this is perfect, its just better than before. Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
b53fbec01d
commit
59292b38eb
|
@ -394,14 +394,14 @@ public:
|
|||
glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op);
|
||||
|
||||
glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0);
|
||||
st_dst_reg dst, st_src_reg src0);
|
||||
|
||||
glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1);
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1);
|
||||
|
||||
glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst,
|
||||
st_src_reg src0, st_src_reg src1, st_src_reg src2);
|
||||
st_dst_reg dst,
|
||||
st_src_reg src0, st_src_reg src1, st_src_reg src2);
|
||||
|
||||
glsl_to_tgsi_instruction *emit(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst,
|
||||
|
@ -422,15 +422,15 @@ public:
|
|||
unsigned elements);
|
||||
|
||||
void emit_scalar(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0);
|
||||
st_dst_reg dst, st_src_reg src0);
|
||||
|
||||
void emit_scalar(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1);
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1);
|
||||
|
||||
void emit_arl(ir_instruction *ir, st_dst_reg dst, st_src_reg src0);
|
||||
|
||||
void emit_scs(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, const st_src_reg &src);
|
||||
st_dst_reg dst, const st_src_reg &src);
|
||||
|
||||
bool try_emit_mad(ir_expression *ir,
|
||||
int mul_operand);
|
||||
|
@ -577,7 +577,7 @@ glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
|
|||
}
|
||||
}
|
||||
else {
|
||||
for (i=0; i<4; i++) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
if(inst->src[i].reladdr) {
|
||||
switch(inst->src[i].file) {
|
||||
case PROGRAM_STATE_VAR:
|
||||
|
@ -610,14 +610,14 @@ glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
|
|||
|
||||
glsl_to_tgsi_instruction *
|
||||
glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1)
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1)
|
||||
{
|
||||
return emit(ir, op, dst, src0, src1, undef_src, undef_src);
|
||||
}
|
||||
|
||||
glsl_to_tgsi_instruction *
|
||||
glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0)
|
||||
st_dst_reg dst, st_src_reg src0)
|
||||
{
|
||||
assert(dst.writemask != 0);
|
||||
return emit(ir, op, dst, src0, undef_src, undef_src, undef_src);
|
||||
|
@ -635,8 +635,8 @@ glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op)
|
|||
*/
|
||||
unsigned
|
||||
glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst,
|
||||
st_src_reg src0, st_src_reg src1)
|
||||
st_dst_reg dst,
|
||||
st_src_reg src0, st_src_reg src1)
|
||||
{
|
||||
int type = GLSL_TYPE_FLOAT;
|
||||
|
||||
|
@ -710,8 +710,8 @@ glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op,
|
|||
|
||||
glsl_to_tgsi_instruction *
|
||||
glsl_to_tgsi_visitor::emit_dp(ir_instruction *ir,
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1,
|
||||
unsigned elements)
|
||||
st_dst_reg dst, st_src_reg src0, st_src_reg src1,
|
||||
unsigned elements)
|
||||
{
|
||||
static const unsigned dot_opcodes[] = {
|
||||
TGSI_OPCODE_DP2, TGSI_OPCODE_DP3, TGSI_OPCODE_DP4
|
||||
|
@ -730,8 +730,8 @@ glsl_to_tgsi_visitor::emit_dp(ir_instruction *ir,
|
|||
*/
|
||||
void
|
||||
glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst,
|
||||
st_src_reg orig_src0, st_src_reg orig_src1)
|
||||
st_dst_reg dst,
|
||||
st_src_reg orig_src0, st_src_reg orig_src1)
|
||||
{
|
||||
int i, j;
|
||||
int done_mask = ~dst.writemask;
|
||||
|
@ -763,9 +763,9 @@ glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
|
|||
}
|
||||
}
|
||||
src0.swizzle = MAKE_SWIZZLE4(src0_swiz, src0_swiz,
|
||||
src0_swiz, src0_swiz);
|
||||
src0_swiz, src0_swiz);
|
||||
src1.swizzle = MAKE_SWIZZLE4(src1_swiz, src1_swiz,
|
||||
src1_swiz, src1_swiz);
|
||||
src1_swiz, src1_swiz);
|
||||
|
||||
inst = emit(ir, op, dst, src0, src1);
|
||||
inst->dst.writemask = this_mask;
|
||||
|
@ -775,7 +775,7 @@ glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
|
|||
|
||||
void
|
||||
glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst, st_src_reg src0)
|
||||
st_dst_reg dst, st_src_reg src0)
|
||||
{
|
||||
st_src_reg undef = undef_src;
|
||||
|
||||
|
@ -786,7 +786,7 @@ glsl_to_tgsi_visitor::emit_scalar(ir_instruction *ir, unsigned op,
|
|||
|
||||
void
|
||||
glsl_to_tgsi_visitor::emit_arl(ir_instruction *ir,
|
||||
st_dst_reg dst, st_src_reg src0)
|
||||
st_dst_reg dst, st_src_reg src0)
|
||||
{
|
||||
int op = TGSI_OPCODE_ARL;
|
||||
|
||||
|
@ -816,8 +816,8 @@ glsl_to_tgsi_visitor::emit_arl(ir_instruction *ir,
|
|||
*/
|
||||
void
|
||||
glsl_to_tgsi_visitor::emit_scs(ir_instruction *ir, unsigned op,
|
||||
st_dst_reg dst,
|
||||
const st_src_reg &src)
|
||||
st_dst_reg dst,
|
||||
const st_src_reg &src)
|
||||
{
|
||||
/* Vertex programs cannot use the SCS opcode.
|
||||
*/
|
||||
|
@ -856,7 +856,7 @@ glsl_to_tgsi_visitor::emit_scs(ir_instruction *ir, unsigned op,
|
|||
unsigned src0_swiz = GET_SWZ(src.swizzle, i);
|
||||
|
||||
src0.swizzle = MAKE_SWIZZLE4(src0_swiz, src0_swiz,
|
||||
src0_swiz, src0_swiz);
|
||||
src0_swiz, src0_swiz);
|
||||
for (unsigned j = i + 1; j < 4; j++) {
|
||||
/* If there is another enabled component in the destination that is
|
||||
* derived from the same inputs, generate its value on this pass as
|
||||
|
@ -881,7 +881,7 @@ glsl_to_tgsi_visitor::emit_scs(ir_instruction *ir, unsigned op,
|
|||
* the destination.
|
||||
*/
|
||||
tmp.swizzle = MAKE_SWIZZLE4(component, component,
|
||||
component, component);
|
||||
component, component);
|
||||
inst = emit(ir, TGSI_OPCODE_SCS, dst, tmp);
|
||||
inst->dst.writemask = this_mask;
|
||||
} else {
|
||||
|
@ -897,8 +897,8 @@ glsl_to_tgsi_visitor::emit_scs(ir_instruction *ir, unsigned op,
|
|||
|
||||
int
|
||||
glsl_to_tgsi_visitor::add_constant(gl_register_file file,
|
||||
gl_constant_value values[4], int size, int datatype,
|
||||
GLuint *swizzle_out)
|
||||
gl_constant_value values[4], int size, int datatype,
|
||||
GLuint *swizzle_out)
|
||||
{
|
||||
if (file == PROGRAM_CONSTANT) {
|
||||
return _mesa_add_typed_unnamed_constant(this->prog->Parameters, values,
|
||||
|
@ -1111,7 +1111,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
|
|||
|
||||
for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
|
||||
int index = _mesa_add_state_reference(this->prog->Parameters,
|
||||
(gl_state_index *)slots[i].tokens);
|
||||
(gl_state_index *)slots[i].tokens);
|
||||
|
||||
if (storage->file == PROGRAM_STATE_VAR) {
|
||||
if (storage->index == -1) {
|
||||
|
@ -1120,11 +1120,11 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
|
|||
assert(index == storage->index + (int)i);
|
||||
}
|
||||
} else {
|
||||
/* We use GLSL_TYPE_FLOAT here regardless of the actual type of
|
||||
* the data being moved since MOV does not care about the type of
|
||||
* data it is moving, and we don't want to declare registers with
|
||||
* array or struct types.
|
||||
*/
|
||||
/* We use GLSL_TYPE_FLOAT here regardless of the actual type of
|
||||
* the data being moved since MOV does not care about the type of
|
||||
* data it is moving, and we don't want to declare registers with
|
||||
* array or struct types.
|
||||
*/
|
||||
st_src_reg src(PROGRAM_STATE_VAR, index, GLSL_TYPE_FLOAT);
|
||||
src.swizzle = slots[i].swizzle;
|
||||
emit(ir, TGSI_OPCODE_MOV, dst, src);
|
||||
|
@ -1136,9 +1136,9 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
|
|||
if (storage->file == PROGRAM_TEMPORARY &&
|
||||
dst.index != storage->index + (int) ir->get_num_state_slots()) {
|
||||
fail_link(this->shader_program,
|
||||
"failed to load builtin uniform `%s' (%d/%d regs loaded)\n",
|
||||
ir->name, dst.index - storage->index,
|
||||
type_size(ir->type));
|
||||
"failed to load builtin uniform `%s' (%d/%d regs loaded)\n",
|
||||
ir->name, dst.index - storage->index,
|
||||
type_size(ir->type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1262,7 +1262,7 @@ glsl_to_tgsi_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operan
|
|||
|
||||
void
|
||||
glsl_to_tgsi_visitor::reladdr_to_temp(ir_instruction *ir,
|
||||
st_src_reg *reg, int *num_reladdr)
|
||||
st_src_reg *reg, int *num_reladdr)
|
||||
{
|
||||
if (!reg->reladdr && !reg->reladdr2)
|
||||
return;
|
||||
|
@ -1301,9 +1301,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
|
|||
*/
|
||||
if (!native_integers && ir->operation == ir_binop_logic_and) {
|
||||
if (try_emit_mad_for_and_not(ir, 1))
|
||||
return;
|
||||
return;
|
||||
if (try_emit_mad_for_and_not(ir, 0))
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ir->operation == ir_quadop_vector)
|
||||
|
@ -1329,7 +1329,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
|
|||
int vector_elements = ir->operands[0]->type->vector_elements;
|
||||
if (ir->operands[1]) {
|
||||
vector_elements = MAX2(vector_elements,
|
||||
ir->operands[1]->type->vector_elements);
|
||||
ir->operands[1]->type->vector_elements);
|
||||
}
|
||||
|
||||
this->result.file = PROGRAM_UNDEFINED;
|
||||
|
@ -1757,8 +1757,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
|
|||
case ir_unop_sqrt:
|
||||
if (have_sqrt) {
|
||||
emit_scalar(ir, TGSI_OPCODE_SQRT, result_dst, op[0]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* sqrt(x) = x * rsq(x). */
|
||||
emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, op[0]);
|
||||
emit(ir, TGSI_OPCODE_MUL, result_dst, result_src, op[0]);
|
||||
|
@ -2092,7 +2091,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
|
|||
switch (var->data.mode) {
|
||||
case ir_var_uniform:
|
||||
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
|
||||
var->data.location);
|
||||
var->data.location);
|
||||
this->variables.push_tail(entry);
|
||||
break;
|
||||
case ir_var_shader_in:
|
||||
|
@ -2932,8 +2931,8 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
|
|||
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);
|
||||
/* 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);
|
||||
|
@ -2975,7 +2974,6 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
|
|||
} else {
|
||||
coord_dst.writemask = WRITEMASK_Z;
|
||||
}
|
||||
|
||||
emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
|
||||
coord_dst.writemask = WRITEMASK_XYZW;
|
||||
}
|
||||
|
@ -3225,7 +3223,6 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
prog->SamplersUsed = v->samplers_used;
|
||||
|
||||
if (v->shader_program != NULL)
|
||||
|
@ -3264,9 +3261,9 @@ get_src_arg_mask(st_dst_reg dst, st_src_reg src)
|
|||
* Here is why this conversion is safe:
|
||||
* CMP T0, T1 T2 T0 can be expanded to:
|
||||
* if (T1 < 0.0)
|
||||
* MOV T0, T2;
|
||||
* MOV T0, T2;
|
||||
* else
|
||||
* MOV T0, T0;
|
||||
* MOV T0, T0;
|
||||
*
|
||||
* If (T1 < 0.0) evaluates to true then our replacement MOV T0, T2 is the same
|
||||
* as the original program. If (T1 < 0.0) evaluates to false, executing
|
||||
|
@ -3344,14 +3341,14 @@ glsl_to_tgsi_visitor::rename_temp_register(int index, int new_index)
|
|||
foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
|
||||
unsigned j;
|
||||
|
||||
for (j=0; j < num_inst_src_regs(inst->op); j++) {
|
||||
for (j = 0; j < num_inst_src_regs(inst->op); j++) {
|
||||
if (inst->src[j].file == PROGRAM_TEMPORARY &&
|
||||
inst->src[j].index == index) {
|
||||
inst->src[j].index = new_index;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0; j < inst->tex_offset_num_offset; j++) {
|
||||
for (j = 0; j < inst->tex_offset_num_offset; j++) {
|
||||
if (inst->tex_offsets[j].file == PROGRAM_TEMPORARY &&
|
||||
inst->tex_offsets[j].index == index) {
|
||||
inst->tex_offsets[j].index = new_index;
|
||||
|
@ -3372,19 +3369,18 @@ glsl_to_tgsi_visitor::get_first_temp_read(int index)
|
|||
unsigned i = 0, j;
|
||||
|
||||
foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
|
||||
for (j=0; j < num_inst_src_regs(inst->op); j++) {
|
||||
for (j = 0; j < num_inst_src_regs(inst->op); j++) {
|
||||
if (inst->src[j].file == PROGRAM_TEMPORARY &&
|
||||
inst->src[j].index == index) {
|
||||
return (depth == 0) ? i : loop_start;
|
||||
}
|
||||
}
|
||||
for (j=0; j < inst->tex_offset_num_offset; j++) {
|
||||
for (j = 0; j < inst->tex_offset_num_offset; j++) {
|
||||
if (inst->tex_offsets[j].file == PROGRAM_TEMPORARY &&
|
||||
inst->tex_offsets[j].index == index) {
|
||||
return (depth == 0) ? i : loop_start;
|
||||
}
|
||||
}
|
||||
|
||||
if (inst->op == TGSI_OPCODE_BGNLOOP) {
|
||||
if(depth++ == 0)
|
||||
loop_start = i;
|
||||
|
@ -3393,10 +3389,8 @@ glsl_to_tgsi_visitor::get_first_temp_read(int index)
|
|||
loop_start = -1;
|
||||
}
|
||||
assert(depth >= 0);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -3411,7 +3405,6 @@ glsl_to_tgsi_visitor::get_first_temp_write(int index)
|
|||
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) {
|
||||
return (depth == 0) ? i : loop_start;
|
||||
}
|
||||
|
||||
if (inst->op == TGSI_OPCODE_BGNLOOP) {
|
||||
if(depth++ == 0)
|
||||
loop_start = i;
|
||||
|
@ -3420,10 +3413,8 @@ glsl_to_tgsi_visitor::get_first_temp_write(int index)
|
|||
loop_start = -1;
|
||||
}
|
||||
assert(depth >= 0);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -3435,28 +3426,25 @@ glsl_to_tgsi_visitor::get_last_temp_read(int index)
|
|||
unsigned i = 0, j;
|
||||
|
||||
foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
|
||||
for (j=0; j < num_inst_src_regs(inst->op); j++) {
|
||||
for (j = 0; j < num_inst_src_regs(inst->op); j++) {
|
||||
if (inst->src[j].file == PROGRAM_TEMPORARY &&
|
||||
inst->src[j].index == index) {
|
||||
last = (depth == 0) ? i : -2;
|
||||
}
|
||||
}
|
||||
for (j=0; j < inst->tex_offset_num_offset; j++) {
|
||||
for (j = 0; j < inst->tex_offset_num_offset; j++) {
|
||||
if (inst->tex_offsets[j].file == PROGRAM_TEMPORARY &&
|
||||
inst->tex_offsets[j].index == index)
|
||||
last = (depth == 0) ? i : -2;
|
||||
}
|
||||
|
||||
if (inst->op == TGSI_OPCODE_BGNLOOP)
|
||||
depth++;
|
||||
else if (inst->op == TGSI_OPCODE_ENDLOOP)
|
||||
if (--depth == 0 && last == -2)
|
||||
last = i;
|
||||
assert(depth >= 0);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
assert(last >= -1);
|
||||
return last;
|
||||
}
|
||||
|
@ -3478,10 +3466,8 @@ glsl_to_tgsi_visitor::get_last_temp_write(int index)
|
|||
if (--depth == 0 && last == -2)
|
||||
last = i;
|
||||
assert(depth >= 0);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
assert(last >= -1);
|
||||
return last;
|
||||
}
|
||||
|
@ -3510,8 +3496,8 @@ void
|
|||
glsl_to_tgsi_visitor::copy_propagate(void)
|
||||
{
|
||||
glsl_to_tgsi_instruction **acp = rzalloc_array(mem_ctx,
|
||||
glsl_to_tgsi_instruction *,
|
||||
this->next_temp * 4);
|
||||
glsl_to_tgsi_instruction *,
|
||||
this->next_temp * 4);
|
||||
int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4);
|
||||
int level = 0;
|
||||
|
||||
|
@ -3551,8 +3537,8 @@ glsl_to_tgsi_visitor::copy_propagate(void)
|
|||
if (first->src[0].file != copy_chan->src[0].file ||
|
||||
first->src[0].index != copy_chan->src[0].index ||
|
||||
first->src[0].index2D != copy_chan->src[0].index2D) {
|
||||
good = false;
|
||||
break;
|
||||
good = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3570,8 +3556,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
|
|||
for (int i = 0; i < 4; i++) {
|
||||
int src_chan = GET_SWZ(inst->src[r].swizzle, i);
|
||||
glsl_to_tgsi_instruction *copy_inst = acp[acp_base + src_chan];
|
||||
swizzle |= (GET_SWZ(copy_inst->src[0].swizzle, src_chan) <<
|
||||
(3 * i));
|
||||
swizzle |= (GET_SWZ(copy_inst->src[0].swizzle, src_chan) << (3 * i));
|
||||
}
|
||||
inst->src[r].swizzle = swizzle;
|
||||
}
|
||||
|
@ -3597,10 +3582,10 @@ glsl_to_tgsi_visitor::copy_propagate(void)
|
|||
for (int r = 0; r < this->next_temp; r++) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (!acp[4 * r + c])
|
||||
continue;
|
||||
continue;
|
||||
|
||||
if (acp_level[4 * r + c] >= level)
|
||||
acp[4 * r + c] = NULL;
|
||||
acp[4 * r + c] = NULL;
|
||||
}
|
||||
}
|
||||
if (inst->op == TGSI_OPCODE_ENDIF)
|
||||
|
@ -3617,44 +3602,42 @@ glsl_to_tgsi_visitor::copy_propagate(void)
|
|||
*/
|
||||
memset(acp, 0, sizeof(*acp) * this->next_temp * 4);
|
||||
} else if (inst->dst.file == PROGRAM_OUTPUT &&
|
||||
inst->dst.reladdr) {
|
||||
inst->dst.reladdr) {
|
||||
/* Any output might be written, so no copy propagation
|
||||
* from outputs across this instruction.
|
||||
*/
|
||||
for (int r = 0; r < this->next_temp; r++) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (!acp[4 * r + c])
|
||||
continue;
|
||||
if (!acp[4 * r + c])
|
||||
continue;
|
||||
|
||||
if (acp[4 * r + c]->src[0].file == PROGRAM_OUTPUT)
|
||||
acp[4 * r + c] = NULL;
|
||||
if (acp[4 * r + c]->src[0].file == PROGRAM_OUTPUT)
|
||||
acp[4 * r + c] = NULL;
|
||||
}
|
||||
}
|
||||
} else if (inst->dst.file == PROGRAM_TEMPORARY ||
|
||||
inst->dst.file == PROGRAM_OUTPUT) {
|
||||
inst->dst.file == PROGRAM_OUTPUT) {
|
||||
/* Clear where it's used as dst. */
|
||||
if (inst->dst.file == PROGRAM_TEMPORARY) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (inst->dst.writemask & (1 << c)) {
|
||||
acp[4 * inst->dst.index + c] = NULL;
|
||||
}
|
||||
if (inst->dst.writemask & (1 << c)) {
|
||||
acp[4 * inst->dst.index + c] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear where it's used as src. */
|
||||
for (int r = 0; r < this->next_temp; r++) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (!acp[4 * r + c])
|
||||
continue;
|
||||
if (!acp[4 * r + c])
|
||||
continue;
|
||||
|
||||
int src_chan = GET_SWZ(acp[4 * r + c]->src[0].swizzle, c);
|
||||
int src_chan = GET_SWZ(acp[4 * r + c]->src[0].swizzle, c);
|
||||
|
||||
if (acp[4 * r + c]->src[0].file == inst->dst.file &&
|
||||
acp[4 * r + c]->src[0].index == inst->dst.index &&
|
||||
inst->dst.writemask & (1 << src_chan))
|
||||
{
|
||||
acp[4 * r + c] = NULL;
|
||||
}
|
||||
if (acp[4 * r + c]->src[0].file == inst->dst.file &&
|
||||
acp[4 * r + c]->src[0].index == inst->dst.index &&
|
||||
inst->dst.writemask & (1 << src_chan))
|
||||
acp[4 * r + c] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3738,23 +3721,20 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
|
|||
for (int r = 0; r < this->next_temp; r++) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (!writes[4 * r + c])
|
||||
continue;
|
||||
continue;
|
||||
|
||||
if (write_level[4 * r + c] == level)
|
||||
write_level[4 * r + c] = level-1;
|
||||
write_level[4 * r + c] = level-1;
|
||||
}
|
||||
}
|
||||
|
||||
if(inst->op == TGSI_OPCODE_ENDIF)
|
||||
--level;
|
||||
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_IF:
|
||||
case TGSI_OPCODE_UIF:
|
||||
++level;
|
||||
/* fallthrough to default case to mark the condition as read */
|
||||
|
||||
default:
|
||||
/* Continuing the block, clear any channels from the write array that
|
||||
* are read by this instruction.
|
||||
|
@ -3773,9 +3753,8 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
|
|||
src_chans |= 1 << GET_SWZ(inst->src[i].swizzle, 3);
|
||||
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (src_chans & (1 << c)) {
|
||||
writes[4 * inst->src[i].index + c] = NULL;
|
||||
}
|
||||
if (src_chans & (1 << c))
|
||||
writes[4 * inst->src[i].index + c] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3793,9 +3772,8 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
|
|||
src_chans |= 1 << GET_SWZ(inst->tex_offsets[i].swizzle, 3);
|
||||
|
||||
for (int c = 0; c < 4; c++) {
|
||||
if (src_chans & (1 << c)) {
|
||||
writes[4 * inst->tex_offsets[i].index + c] = NULL;
|
||||
}
|
||||
if (src_chans & (1 << c))
|
||||
writes[4 * inst->tex_offsets[i].index + c] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3868,18 +3846,18 @@ glsl_to_tgsi_visitor::merge_registers(void)
|
|||
/* Read the indices of the last read and first write to each temp register
|
||||
* into an array so that we don't have to traverse the instruction list as
|
||||
* much. */
|
||||
for (i=0; i < this->next_temp; i++) {
|
||||
for (i = 0; i < this->next_temp; i++) {
|
||||
last_reads[i] = get_last_temp_read(i);
|
||||
first_writes[i] = get_first_temp_write(i);
|
||||
}
|
||||
|
||||
/* Start looking for registers with non-overlapping usages that can be
|
||||
* merged together. */
|
||||
for (i=0; i < this->next_temp; i++) {
|
||||
for (i = 0; i < this->next_temp; i++) {
|
||||
/* Don't touch unused registers. */
|
||||
if (last_reads[i] < 0 || first_writes[i] < 0) continue;
|
||||
|
||||
for (j=0; j < this->next_temp; j++) {
|
||||
for (j = 0; j < this->next_temp; j++) {
|
||||
/* Don't touch unused registers. */
|
||||
if (last_reads[j] < 0 || first_writes[j] < 0) continue;
|
||||
|
||||
|
@ -3888,8 +3866,7 @@ glsl_to_tgsi_visitor::merge_registers(void)
|
|||
* register at index i will always be used earlier or at the same time
|
||||
* as the register at index j. */
|
||||
if (first_writes[i] <= first_writes[j] &&
|
||||
last_reads[i] <= first_writes[j])
|
||||
{
|
||||
last_reads[i] <= first_writes[j]) {
|
||||
rename_temp_register(j, i); /* Replace all references to j with i.*/
|
||||
|
||||
/* Update the first_writes and last_reads arrays with the new
|
||||
|
@ -3914,7 +3891,7 @@ glsl_to_tgsi_visitor::renumber_registers(void)
|
|||
int i = 0;
|
||||
int new_index = 0;
|
||||
|
||||
for (i=0; i < this->next_temp; i++) {
|
||||
for (i = 0; i < this->next_temp; i++) {
|
||||
if (get_first_temp_read(i) < 0) continue;
|
||||
if (i != new_index)
|
||||
rename_temp_register(i, new_index);
|
||||
|
@ -4031,11 +4008,10 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
|
|||
if (inst->dst.file == PROGRAM_OUTPUT)
|
||||
prog->OutputsWritten |= BITFIELD64_BIT(inst->dst.index);
|
||||
|
||||
for (int i=0; i<3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
src_regs[i] = inst->src[i];
|
||||
if (src_regs[i].file == PROGRAM_INPUT &&
|
||||
src_regs[i].index == VARYING_SLOT_COL0)
|
||||
{
|
||||
src_regs[i].index == VARYING_SLOT_COL0) {
|
||||
src_regs[i].file = PROGRAM_TEMPORARY;
|
||||
src_regs[i].index = src0.index;
|
||||
}
|
||||
|
@ -4117,7 +4093,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
|
|||
if (inst->dst.file == PROGRAM_OUTPUT)
|
||||
prog->OutputsWritten |= BITFIELD64_BIT(inst->dst.index);
|
||||
|
||||
for (int i=0; i<3; i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
src_regs[i] = inst->src[i];
|
||||
if (src_regs[i].file == PROGRAM_INPUT)
|
||||
prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
|
||||
|
@ -5020,7 +4996,7 @@ st_translate_program(
|
|||
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);
|
||||
|
@ -5252,7 +5228,7 @@ get_mesa_program(struct gl_context *ctx,
|
|||
|
||||
_mesa_copy_linked_program_data(shader->Stage, shader_program, prog);
|
||||
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
|
||||
prog->Parameters);
|
||||
prog->Parameters);
|
||||
|
||||
/* Remove reads from output registers. */
|
||||
lower_output_reads(shader->ir);
|
||||
|
@ -5290,7 +5266,7 @@ get_mesa_program(struct gl_context *ctx,
|
|||
#if 0
|
||||
/* Print out some information (for debugging purposes) used by the
|
||||
* optimization passes. */
|
||||
for (i=0; i < v->next_temp; i++) {
|
||||
for (i = 0; i < v->next_temp; i++) {
|
||||
int fr = v->get_first_temp_read(i);
|
||||
int fw = v->get_first_temp_write(i);
|
||||
int lr = v->get_last_temp_read(i);
|
||||
|
@ -5446,7 +5422,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
|
||||
progress = do_common_optimization(ir, true, true, options,
|
||||
ctx->Const.NativeIntegers)
|
||||
|| progress;
|
||||
|| progress;
|
||||
|
||||
progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
|
||||
|
||||
|
@ -5464,13 +5440,13 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
|
||||
|
||||
if (linked_prog) {
|
||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||
linked_prog);
|
||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||
linked_prog);
|
||||
if (!ctx->Driver.ProgramStringNotify(ctx,
|
||||
_mesa_shader_stage_to_program(i),
|
||||
linked_prog)) {
|
||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||
NULL);
|
||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||
NULL);
|
||||
_mesa_reference_program(ctx, &linked_prog, NULL);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue