[Mesa-dev] [PATCH 07/14] glsl_to_tgsi: allocate glsl_to_tgsi_instruction::tex_offsets on demand
Marek Olšák
maraeo at gmail.com
Mon Oct 17 13:39:19 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
sizeof(glsl_to_tgsi_instruction): 384 -> 264
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b7280e3..2ae15c9 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -266,21 +266,21 @@ st_dst_reg::st_dst_reg(st_src_reg reg)
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 resource; /**< sampler or buffer register */
- st_src_reg tex_offsets[MAX_GLSL_TEXTURE_OFFSET];
+ st_src_reg *tex_offsets;
/** 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 */
@@ -4269,20 +4269,23 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
inst->resource.index = sampler_index;
inst->sampler_array_size = sampler_array_size;
inst->sampler_base = sampler_base;
if (reladdr.file != PROGRAM_UNDEFINED) {
inst->resource.reladdr = ralloc(mem_ctx, st_src_reg);
memcpy(inst->resource.reladdr, &reladdr, sizeof(reladdr));
}
if (ir->offset) {
+ if (!inst->tex_offsets)
+ inst->tex_offsets = rzalloc_array(inst, st_src_reg, MAX_GLSL_TEXTURE_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:
inst->tex_target = (sampler_type->sampler_array)
? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX;
break;
--
2.7.4
More information about the mesa-dev
mailing list