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
|
@ -577,7 +577,7 @@ glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i=0; i<4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if(inst->src[i].reladdr) {
|
if(inst->src[i].reladdr) {
|
||||||
switch(inst->src[i].file) {
|
switch(inst->src[i].file) {
|
||||||
case PROGRAM_STATE_VAR:
|
case PROGRAM_STATE_VAR:
|
||||||
|
@ -1757,8 +1757,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
|
||||||
case ir_unop_sqrt:
|
case ir_unop_sqrt:
|
||||||
if (have_sqrt) {
|
if (have_sqrt) {
|
||||||
emit_scalar(ir, TGSI_OPCODE_SQRT, result_dst, op[0]);
|
emit_scalar(ir, TGSI_OPCODE_SQRT, result_dst, op[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/* sqrt(x) = x * rsq(x). */
|
/* sqrt(x) = x * rsq(x). */
|
||||||
emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, op[0]);
|
emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, op[0]);
|
||||||
emit(ir, TGSI_OPCODE_MUL, result_dst, result_src, op[0]);
|
emit(ir, TGSI_OPCODE_MUL, result_dst, result_src, op[0]);
|
||||||
|
@ -2975,7 +2974,6 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
|
||||||
} else {
|
} else {
|
||||||
coord_dst.writemask = WRITEMASK_Z;
|
coord_dst.writemask = WRITEMASK_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
|
emit(ir, TGSI_OPCODE_MOV, coord_dst, this->result);
|
||||||
coord_dst.writemask = WRITEMASK_XYZW;
|
coord_dst.writemask = WRITEMASK_XYZW;
|
||||||
}
|
}
|
||||||
|
@ -3225,7 +3223,6 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prog->SamplersUsed = v->samplers_used;
|
prog->SamplersUsed = v->samplers_used;
|
||||||
|
|
||||||
if (v->shader_program != NULL)
|
if (v->shader_program != NULL)
|
||||||
|
@ -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) {
|
foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
|
||||||
unsigned j;
|
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 &&
|
if (inst->src[j].file == PROGRAM_TEMPORARY &&
|
||||||
inst->src[j].index == index) {
|
inst->src[j].index == index) {
|
||||||
inst->src[j].index = new_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 &&
|
if (inst->tex_offsets[j].file == PROGRAM_TEMPORARY &&
|
||||||
inst->tex_offsets[j].index == index) {
|
inst->tex_offsets[j].index == index) {
|
||||||
inst->tex_offsets[j].index = new_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;
|
unsigned i = 0, j;
|
||||||
|
|
||||||
foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
|
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 &&
|
if (inst->src[j].file == PROGRAM_TEMPORARY &&
|
||||||
inst->src[j].index == index) {
|
inst->src[j].index == index) {
|
||||||
return (depth == 0) ? i : loop_start;
|
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 &&
|
if (inst->tex_offsets[j].file == PROGRAM_TEMPORARY &&
|
||||||
inst->tex_offsets[j].index == index) {
|
inst->tex_offsets[j].index == index) {
|
||||||
return (depth == 0) ? i : loop_start;
|
return (depth == 0) ? i : loop_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst->op == TGSI_OPCODE_BGNLOOP) {
|
if (inst->op == TGSI_OPCODE_BGNLOOP) {
|
||||||
if(depth++ == 0)
|
if(depth++ == 0)
|
||||||
loop_start = i;
|
loop_start = i;
|
||||||
|
@ -3393,10 +3389,8 @@ glsl_to_tgsi_visitor::get_first_temp_read(int index)
|
||||||
loop_start = -1;
|
loop_start = -1;
|
||||||
}
|
}
|
||||||
assert(depth >= 0);
|
assert(depth >= 0);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
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) {
|
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) {
|
||||||
return (depth == 0) ? i : loop_start;
|
return (depth == 0) ? i : loop_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst->op == TGSI_OPCODE_BGNLOOP) {
|
if (inst->op == TGSI_OPCODE_BGNLOOP) {
|
||||||
if(depth++ == 0)
|
if(depth++ == 0)
|
||||||
loop_start = i;
|
loop_start = i;
|
||||||
|
@ -3420,10 +3413,8 @@ glsl_to_tgsi_visitor::get_first_temp_write(int index)
|
||||||
loop_start = -1;
|
loop_start = -1;
|
||||||
}
|
}
|
||||||
assert(depth >= 0);
|
assert(depth >= 0);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3435,28 +3426,25 @@ glsl_to_tgsi_visitor::get_last_temp_read(int index)
|
||||||
unsigned i = 0, j;
|
unsigned i = 0, j;
|
||||||
|
|
||||||
foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
|
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 &&
|
if (inst->src[j].file == PROGRAM_TEMPORARY &&
|
||||||
inst->src[j].index == index) {
|
inst->src[j].index == index) {
|
||||||
last = (depth == 0) ? i : -2;
|
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 &&
|
if (inst->tex_offsets[j].file == PROGRAM_TEMPORARY &&
|
||||||
inst->tex_offsets[j].index == index)
|
inst->tex_offsets[j].index == index)
|
||||||
last = (depth == 0) ? i : -2;
|
last = (depth == 0) ? i : -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst->op == TGSI_OPCODE_BGNLOOP)
|
if (inst->op == TGSI_OPCODE_BGNLOOP)
|
||||||
depth++;
|
depth++;
|
||||||
else if (inst->op == TGSI_OPCODE_ENDLOOP)
|
else if (inst->op == TGSI_OPCODE_ENDLOOP)
|
||||||
if (--depth == 0 && last == -2)
|
if (--depth == 0 && last == -2)
|
||||||
last = i;
|
last = i;
|
||||||
assert(depth >= 0);
|
assert(depth >= 0);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(last >= -1);
|
assert(last >= -1);
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
@ -3478,10 +3466,8 @@ glsl_to_tgsi_visitor::get_last_temp_write(int index)
|
||||||
if (--depth == 0 && last == -2)
|
if (--depth == 0 && last == -2)
|
||||||
last = i;
|
last = i;
|
||||||
assert(depth >= 0);
|
assert(depth >= 0);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(last >= -1);
|
assert(last >= -1);
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
@ -3570,8 +3556,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int src_chan = GET_SWZ(inst->src[r].swizzle, i);
|
int src_chan = GET_SWZ(inst->src[r].swizzle, i);
|
||||||
glsl_to_tgsi_instruction *copy_inst = acp[acp_base + src_chan];
|
glsl_to_tgsi_instruction *copy_inst = acp[acp_base + src_chan];
|
||||||
swizzle |= (GET_SWZ(copy_inst->src[0].swizzle, src_chan) <<
|
swizzle |= (GET_SWZ(copy_inst->src[0].swizzle, src_chan) << (3 * i));
|
||||||
(3 * i));
|
|
||||||
}
|
}
|
||||||
inst->src[r].swizzle = swizzle;
|
inst->src[r].swizzle = swizzle;
|
||||||
}
|
}
|
||||||
|
@ -3652,12 +3637,10 @@ glsl_to_tgsi_visitor::copy_propagate(void)
|
||||||
if (acp[4 * r + c]->src[0].file == inst->dst.file &&
|
if (acp[4 * r + c]->src[0].file == inst->dst.file &&
|
||||||
acp[4 * r + c]->src[0].index == inst->dst.index &&
|
acp[4 * r + c]->src[0].index == inst->dst.index &&
|
||||||
inst->dst.writemask & (1 << src_chan))
|
inst->dst.writemask & (1 << src_chan))
|
||||||
{
|
|
||||||
acp[4 * r + c] = NULL;
|
acp[4 * r + c] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3744,17 +3727,14 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
|
||||||
write_level[4 * r + c] = level-1;
|
write_level[4 * r + c] = level-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inst->op == TGSI_OPCODE_ENDIF)
|
if(inst->op == TGSI_OPCODE_ENDIF)
|
||||||
--level;
|
--level;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_OPCODE_IF:
|
case TGSI_OPCODE_IF:
|
||||||
case TGSI_OPCODE_UIF:
|
case TGSI_OPCODE_UIF:
|
||||||
++level;
|
++level;
|
||||||
/* fallthrough to default case to mark the condition as read */
|
/* fallthrough to default case to mark the condition as read */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Continuing the block, clear any channels from the write array that
|
/* Continuing the block, clear any channels from the write array that
|
||||||
* are read by this instruction.
|
* are read by this instruction.
|
||||||
|
@ -3773,12 +3753,11 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
|
||||||
src_chans |= 1 << GET_SWZ(inst->src[i].swizzle, 3);
|
src_chans |= 1 << GET_SWZ(inst->src[i].swizzle, 3);
|
||||||
|
|
||||||
for (int c = 0; c < 4; c++) {
|
for (int c = 0; c < 4; c++) {
|
||||||
if (src_chans & (1 << c)) {
|
if (src_chans & (1 << c))
|
||||||
writes[4 * inst->src[i].index + c] = NULL;
|
writes[4 * inst->src[i].index + c] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (unsigned i = 0; i < inst->tex_offset_num_offset; i++) {
|
for (unsigned i = 0; i < inst->tex_offset_num_offset; i++) {
|
||||||
if (inst->tex_offsets[i].file == PROGRAM_TEMPORARY && inst->tex_offsets[i].reladdr){
|
if (inst->tex_offsets[i].file == PROGRAM_TEMPORARY && inst->tex_offsets[i].reladdr){
|
||||||
/* Any temporary might be read, so no dead code elimination
|
/* Any temporary might be read, so no dead code elimination
|
||||||
|
@ -3793,12 +3772,11 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
|
||||||
src_chans |= 1 << GET_SWZ(inst->tex_offsets[i].swizzle, 3);
|
src_chans |= 1 << GET_SWZ(inst->tex_offsets[i].swizzle, 3);
|
||||||
|
|
||||||
for (int c = 0; c < 4; c++) {
|
for (int c = 0; c < 4; c++) {
|
||||||
if (src_chans & (1 << c)) {
|
if (src_chans & (1 << c))
|
||||||
writes[4 * inst->tex_offsets[i].index + c] = NULL;
|
writes[4 * inst->tex_offsets[i].index + c] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
/* 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
|
* into an array so that we don't have to traverse the instruction list as
|
||||||
* much. */
|
* 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);
|
last_reads[i] = get_last_temp_read(i);
|
||||||
first_writes[i] = get_first_temp_write(i);
|
first_writes[i] = get_first_temp_write(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start looking for registers with non-overlapping usages that can be
|
/* Start looking for registers with non-overlapping usages that can be
|
||||||
* merged together. */
|
* merged together. */
|
||||||
for (i=0; i < this->next_temp; i++) {
|
for (i = 0; i < this->next_temp; i++) {
|
||||||
/* Don't touch unused registers. */
|
/* Don't touch unused registers. */
|
||||||
if (last_reads[i] < 0 || first_writes[i] < 0) continue;
|
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. */
|
/* Don't touch unused registers. */
|
||||||
if (last_reads[j] < 0 || first_writes[j] < 0) continue;
|
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
|
* register at index i will always be used earlier or at the same time
|
||||||
* as the register at index j. */
|
* as the register at index j. */
|
||||||
if (first_writes[i] <= first_writes[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.*/
|
rename_temp_register(j, i); /* Replace all references to j with i.*/
|
||||||
|
|
||||||
/* Update the first_writes and last_reads arrays with the new
|
/* 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 i = 0;
|
||||||
int new_index = 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 (get_first_temp_read(i) < 0) continue;
|
||||||
if (i != new_index)
|
if (i != new_index)
|
||||||
rename_temp_register(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)
|
if (inst->dst.file == PROGRAM_OUTPUT)
|
||||||
prog->OutputsWritten |= BITFIELD64_BIT(inst->dst.index);
|
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];
|
src_regs[i] = inst->src[i];
|
||||||
if (src_regs[i].file == PROGRAM_INPUT &&
|
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].file = PROGRAM_TEMPORARY;
|
||||||
src_regs[i].index = src0.index;
|
src_regs[i].index = src0.index;
|
||||||
}
|
}
|
||||||
|
@ -4117,7 +4093,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
|
||||||
if (inst->dst.file == PROGRAM_OUTPUT)
|
if (inst->dst.file == PROGRAM_OUTPUT)
|
||||||
prog->OutputsWritten |= BITFIELD64_BIT(inst->dst.index);
|
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];
|
src_regs[i] = inst->src[i];
|
||||||
if (src_regs[i].file == PROGRAM_INPUT)
|
if (src_regs[i].file == PROGRAM_INPUT)
|
||||||
prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
|
prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
|
||||||
|
@ -5290,7 +5266,7 @@ get_mesa_program(struct gl_context *ctx,
|
||||||
#if 0
|
#if 0
|
||||||
/* Print out some information (for debugging purposes) used by the
|
/* Print out some information (for debugging purposes) used by the
|
||||||
* optimization passes. */
|
* 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 fr = v->get_first_temp_read(i);
|
||||||
int fw = v->get_first_temp_write(i);
|
int fw = v->get_first_temp_write(i);
|
||||||
int lr = v->get_last_temp_read(i);
|
int lr = v->get_last_temp_read(i);
|
||||||
|
|
Loading…
Reference in New Issue