From: Marek Olšák <marek.ol...@amd.com> sizeof(glsl_to_tgsi_instruction): 416 -> 384 --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 63 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 32 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index b3654fe..b7280e3 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -265,23 +265,22 @@ st_dst_reg::st_dst_reg(st_src_reg reg) this->has_index2 = reg.has_index2; this->array_id = reg.array_id; } class glsl_to_tgsi_instruction : public exec_node { public: DECLARE_RALLOC_CXX_OPERATORS(glsl_to_tgsi_instruction) st_dst_reg dst[2]; st_src_reg src[4]; - st_src_reg sampler; /**< sampler register */ + st_src_reg resource; /**< sampler or buffer register */ st_src_reg tex_offsets[MAX_GLSL_TEXTURE_OFFSET]; - st_src_reg buffer; /**< buffer register */ /** Pointer to the ir source this tree came from for debugging */ ir_instruction *ir; unsigned op:8; /**< TGSI opcode */ unsigned saturate:1; unsigned is_64bit_expanded:1; unsigned sampler_base:5; unsigned sampler_array_size:6; /**< 1-based size of sampler array, 1 if not array */ unsigned tex_target:4; /**< One of TEXTURE_*_INDEX */ @@ -2273,21 +2272,21 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) st_src_reg buffer( PROGRAM_BUFFER, ctx->Const.Program[shader->Stage].MaxAtomicBuffers + (const_offset ? const_offset->value.u[0] : 0), GLSL_TYPE_UINT); if (!const_offset) { buffer.reladdr = ralloc(mem_ctx, st_src_reg); *buffer.reladdr = op[0]; emit_arl(ir, sampler_reladdr, op[0]); } - emit_asm(ir, TGSI_OPCODE_RESQ, result_dst)->buffer = buffer; + emit_asm(ir, TGSI_OPCODE_RESQ, result_dst)->resource = buffer; break; } case ir_unop_vote_any: emit_asm(ir, TGSI_OPCODE_VOTE_ANY, result_dst, op[0]); break; case ir_unop_vote_all: emit_asm(ir, TGSI_OPCODE_VOTE_ALL, result_dst, op[0]); break; case ir_unop_vote_eq: @@ -3304,21 +3303,21 @@ glsl_to_tgsi_visitor::visit_atomic_counter_intrinsic(ir_call *ir) break; } default: assert(!"Unexpected intrinsic"); return; } inst = emit_asm(ir, opcode, dst, offset, data, data2); } - inst->buffer = buffer; + inst->resource = buffer; } void glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir) { exec_node *param = ir->actual_parameters.get_head(); ir_rvalue *block = ((ir_instruction *)param)->as_rvalue(); param = param->get_next(); @@ -3417,27 +3416,27 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir) if (!param->is_tail_sentinel()) { access = ((ir_instruction *)param)->as_constant(); assert(access); } /* The emit_asm() might have actually split the op into pieces, e.g. for * double stores. We have to go back and fix up all the generated ops. */ unsigned op = inst->op; do { - inst->buffer = buffer; + inst->resource = buffer; if (access) inst->buffer_access = access->value.u[0]; inst = (glsl_to_tgsi_instruction *)inst->get_prev(); if (inst->op == TGSI_OPCODE_UADD) inst = (glsl_to_tgsi_instruction *)inst->get_prev(); - } while (inst && inst->op == op && inst->buffer.file == PROGRAM_UNDEFINED); + } while (inst && inst->op == op && inst->resource.file == PROGRAM_UNDEFINED); } void glsl_to_tgsi_visitor::visit_membar_intrinsic(ir_call *ir) { switch (ir->callee->intrinsic_id) { case ir_intrinsic_memory_barrier: emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(TGSI_MEMBAR_SHADER_BUFFER | TGSI_MEMBAR_ATOMIC_BUFFER | @@ -3490,34 +3489,34 @@ glsl_to_tgsi_visitor::visit_shared_intrinsic(ir_call *ir) if (ir->return_deref) { ir->return_deref->accept(this); dst = st_dst_reg(this->result); dst.writemask = (1 << ir->return_deref->type->vector_elements) - 1; } glsl_to_tgsi_instruction *inst; if (ir->callee->intrinsic_id == ir_intrinsic_shared_load) { inst = emit_asm(ir, TGSI_OPCODE_LOAD, dst, off); - inst->buffer = buffer; + inst->resource = buffer; } else if (ir->callee->intrinsic_id == ir_intrinsic_shared_store) { param = param->get_next(); ir_rvalue *val = ((ir_instruction *)param)->as_rvalue(); val->accept(this); param = param->get_next(); ir_constant *write_mask = ((ir_instruction *)param)->as_constant(); assert(write_mask); dst.writemask = write_mask->value.u[0]; dst.type = this->result.type; inst = emit_asm(ir, TGSI_OPCODE_STORE, dst, off, this->result); - inst->buffer = buffer; + inst->resource = buffer; } else { param = param->get_next(); ir_rvalue *val = ((ir_instruction *)param)->as_rvalue(); val->accept(this); st_src_reg data = this->result, data2 = undef_src; unsigned opcode; switch (ir->callee->intrinsic_id) { case ir_intrinsic_shared_atomic_add: opcode = TGSI_OPCODE_ATOMUADD; @@ -3546,21 +3545,21 @@ glsl_to_tgsi_visitor::visit_shared_intrinsic(ir_call *ir) val = ((ir_instruction *)param)->as_rvalue(); val->accept(this); data2 = this->result; break; default: assert(!"Unexpected intrinsic"); return; } inst = emit_asm(ir, opcode, dst, off, data, data2); - inst->buffer = buffer; + inst->resource = buffer; } } void glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir) { exec_node *param = ir->actual_parameters.get_head(); ir_dereference *img = (ir_dereference *)param; const ir_variable *imgvar = img->variable_referenced(); @@ -3677,21 +3676,21 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir) default: assert(!"Unexpected intrinsic"); return; } inst = emit_asm(ir, opcode, dst, coord, arg1, arg2); if (opcode == TGSI_OPCODE_STORE) inst->dst[0].writemask = WRITEMASK_XYZW; } - inst->buffer = image; + inst->resource = image; inst->sampler_array_size = sampler_array_size; inst->sampler_base = sampler_base; switch (type->sampler_dimensionality) { case GLSL_SAMPLER_DIM_1D: inst->tex_target = (type->sampler_array) ? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX; break; case GLSL_SAMPLER_DIM_2D: inst->tex_target = (type->sampler_array) @@ -4260,27 +4259,27 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) inst = emit_asm(ir, opcode, result_dst, coord, cube_sc); } else { inst = emit_asm(ir, opcode, result_dst, coord, component); } } else inst = emit_asm(ir, opcode, result_dst, coord); if (ir->shadow_comparitor) inst->tex_shadow = GL_TRUE; - inst->sampler.index = sampler_index; + inst->resource.index = sampler_index; inst->sampler_array_size = sampler_array_size; inst->sampler_base = sampler_base; if (reladdr.file != PROGRAM_UNDEFINED) { - inst->sampler.reladdr = ralloc(mem_ctx, st_src_reg); - memcpy(inst->sampler.reladdr, &reladdr, sizeof(reladdr)); + inst->resource.reladdr = ralloc(mem_ctx, st_src_reg); + memcpy(inst->resource.reladdr, &reladdr, sizeof(reladdr)); } if (ir->offset) { for (i = 0; i < MAX_GLSL_TEXTURE_OFFSET && offset[i].file != PROGRAM_UNDEFINED; i++) inst->tex_offsets[i] = offset[i]; inst->tex_offset_num_offset = i; } switch (sampler_type->sampler_dimensionality) { case GLSL_SAMPLER_DIM_1D: @@ -4483,37 +4482,37 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog) for (int i = 0; i < inst->sampler_array_size; i++) { unsigned idx = inst->sampler_base + i; v->samplers_used |= 1u << idx; debug_assert(idx < (int)ARRAY_SIZE(v->sampler_types)); v->sampler_types[idx] = inst->tex_type; v->sampler_targets[idx] = st_translate_texture_target(inst->tex_target, inst->tex_shadow); if (inst->tex_shadow) { - prog->ShadowSamplers |= 1 << (inst->sampler.index + i); + prog->ShadowSamplers |= 1 << (inst->resource.index + i); } } } if (inst->tex_target == TEXTURE_EXTERNAL_INDEX) - prog->ExternalSamplersUsed |= 1 << inst->sampler.index; + prog->ExternalSamplersUsed |= 1 << inst->resource.index; - if (inst->buffer.file != PROGRAM_UNDEFINED && ( + if (inst->resource.file != PROGRAM_UNDEFINED && ( is_resource_instruction(inst->op) || inst->op == TGSI_OPCODE_STORE)) { - if (inst->buffer.file == PROGRAM_BUFFER) { - v->buffers_used |= 1 << inst->buffer.index; - } else if (inst->buffer.file == PROGRAM_MEMORY) { + if (inst->resource.file == PROGRAM_BUFFER) { + v->buffers_used |= 1 << inst->resource.index; + } else if (inst->resource.file == PROGRAM_MEMORY) { v->use_shared_memory = true; } else { - assert(inst->buffer.file == PROGRAM_IMAGE); + assert(inst->resource.file == PROGRAM_IMAGE); for (int i = 0; i < inst->sampler_array_size; i++) { unsigned idx = inst->sampler_base + i; v->images_used |= 1 << idx; v->image_targets[idx] = st_translate_texture_target(inst->tex_target, false); v->image_formats[idx] = inst->image_format; } } } } @@ -5761,23 +5760,23 @@ compile_tgsi_instruction(struct st_translate *t, case TGSI_OPCODE_TXL: case TGSI_OPCODE_TXP: case TGSI_OPCODE_TXQ: case TGSI_OPCODE_TXQS: case TGSI_OPCODE_TXF: case TGSI_OPCODE_TEX2: case TGSI_OPCODE_TXB2: case TGSI_OPCODE_TXL2: case TGSI_OPCODE_TG4: case TGSI_OPCODE_LODQ: - src[num_src] = t->samplers[inst->sampler.index]; + src[num_src] = t->samplers[inst->resource.index]; assert(src[num_src].File != TGSI_FILE_NULL); - if (inst->sampler.reladdr) + if (inst->resource.reladdr) src[num_src] = ureg_src_indirect(src[num_src], ureg_src(t->address[2])); num_src++; for (i = 0; i < (int)inst->tex_offset_num_offset; i++) { texoffsets[i] = translate_tex_offset(t, &inst->tex_offsets[i]); } tex_target = st_translate_texture_target(inst->tex_target, inst->tex_shadow); ureg_tex_insn(ureg, inst->op, @@ -5795,47 +5794,47 @@ compile_tgsi_instruction(struct st_translate *t, case TGSI_OPCODE_ATOMAND: case TGSI_OPCODE_ATOMOR: case TGSI_OPCODE_ATOMXOR: case TGSI_OPCODE_ATOMUMIN: case TGSI_OPCODE_ATOMUMAX: case TGSI_OPCODE_ATOMIMIN: case TGSI_OPCODE_ATOMIMAX: for (i = num_src - 1; i >= 0; i--) src[i + 1] = src[i]; num_src++; - if (inst->buffer.file == PROGRAM_MEMORY) { + if (inst->resource.file == PROGRAM_MEMORY) { src[0] = t->shared_memory; - } else if (inst->buffer.file == PROGRAM_BUFFER) { - src[0] = t->buffers[inst->buffer.index]; + } else if (inst->resource.file == PROGRAM_BUFFER) { + src[0] = t->buffers[inst->resource.index]; } else { - src[0] = t->images[inst->buffer.index]; + src[0] = t->images[inst->resource.index]; tex_target = st_translate_texture_target(inst->tex_target, inst->tex_shadow); } - if (inst->buffer.reladdr) + if (inst->resource.reladdr) src[0] = ureg_src_indirect(src[0], ureg_src(t->address[2])); assert(src[0].File != TGSI_FILE_NULL); ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src, inst->buffer_access, tex_target, inst->image_format); break; case TGSI_OPCODE_STORE: - if (inst->buffer.file == PROGRAM_MEMORY) { + if (inst->resource.file == PROGRAM_MEMORY) { dst[0] = ureg_dst(t->shared_memory); - } else if (inst->buffer.file == PROGRAM_BUFFER) { - dst[0] = ureg_dst(t->buffers[inst->buffer.index]); + } else if (inst->resource.file == PROGRAM_BUFFER) { + dst[0] = ureg_dst(t->buffers[inst->resource.index]); } else { - dst[0] = ureg_dst(t->images[inst->buffer.index]); + dst[0] = ureg_dst(t->images[inst->resource.index]); tex_target = st_translate_texture_target(inst->tex_target, inst->tex_shadow); } dst[0] = ureg_writemask(dst[0], inst->dst[0].writemask); - if (inst->buffer.reladdr) + if (inst->resource.reladdr) dst[0] = ureg_dst_indirect(dst[0], ureg_src(t->address[2])); assert(dst[0].File != TGSI_FILE_NULL); ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src, inst->buffer_access, tex_target, inst->image_format); break; case TGSI_OPCODE_SCS: dst[0] = ureg_writemask(dst[0], TGSI_WRITEMASK_XY); ureg_insn(ureg, inst->op, dst, num_dst, src, num_src); -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev