diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-21 15:07:36 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-22 12:51:21 -0700 |
commit | 19d58a299b911ce36349485b8d4b5859c719f10a (patch) | |
tree | e5b9e3328032489d309942150c2b284439eef741 /src/panfrost/midgard | |
parent | a89e368c7ff3ead780c90755fa0e4e23c8643f41 (diff) |
pan/midgard: Analyze simple loads/store
For shaders using exclusively direct attribute/varyings, we can work
this out statically. For shaders with indirect access, we just set an
upper bound of 16 (the max attributes/varyings we support) and the
actual count will be reported regardless.
We proceed similarly for textures/samplers, as well as for UBOs. While
UBOs can be *indexed* indirectly, the *UBO itself* -- which is what we
count in the shader descriptor (rather than the UBO descriptors) -- is
statically determinable.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r-- | src/panfrost/midgard/disassemble.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/src/panfrost/midgard/disassemble.c b/src/panfrost/midgard/disassemble.c index 1880ae8352c..c4bdacdef68 100644 --- a/src/panfrost/midgard/disassemble.c +++ b/src/panfrost/midgard/disassemble.c @@ -1028,6 +1028,20 @@ is_op_varying(unsigned op) return false; } +static bool +is_op_attribute(unsigned op) +{ + switch (op) { + case midgard_op_ld_attr_16: + case midgard_op_ld_attr_32: + case midgard_op_ld_attr_32i: + case midgard_op_ld_attr_32u: + return true; + } + + return false; +} + static void print_load_store_arg(uint8_t arg, unsigned index) { @@ -1060,6 +1074,13 @@ print_load_store_arg(uint8_t arg, unsigned index) } static void +update_stats(signed *stat, unsigned address) +{ + if (*stat >= 0) + *stat = MAX2(*stat, address + 1); +} + +static void print_load_store_instr(uint64_t data, unsigned tabs) { @@ -1067,14 +1088,27 @@ print_load_store_instr(uint64_t data, print_ld_st_opcode(word->op); - if (is_op_varying(word->op)) + unsigned address = word->address; + + if (is_op_varying(word->op)) { print_varying_parameters(word); + /* Do some analysis: check if direct cacess */ + + if ((word->arg_2 == 0x1E) && midg_stats.varying_count >= 0) + update_stats(&midg_stats.varying_count, address); + else + midg_stats.varying_count = -16; + } else if (is_op_attribute(word->op)) { + if ((word->arg_2 == 0x1E) && midg_stats.attribute_count >= 0) + update_stats(&midg_stats.attribute_count, address); + else + midg_stats.attribute_count = -16; + } + printf(" r%d", word->reg); print_mask_4(word->mask); - unsigned address = word->address; - if (!OP_IS_STORE(word->op)) update_dest(word->reg); @@ -1096,9 +1130,10 @@ print_load_store_instr(uint64_t data, printf(", "); - if (is_ubo) + if (is_ubo) { printf("ubo%d", word->arg_1); - else + update_stats(&midg_stats.uniform_buffer_count, word->arg_1); + } else print_load_store_arg(word->arg_1, 0); printf(", "); @@ -1272,12 +1307,19 @@ print_texture_word(uint32_t *word, unsigned tabs) print_mask_4(texture->mask); printf(", "); + /* Depending on whether we read from textures directly or indirectly, + * we may be able to update our analysis */ + if (texture->texture_register) { printf("texture["); print_texture_reg_select(texture->texture_handle); printf("], "); + + /* Indirect, tut tut */ + midg_stats.texture_count = -16; } else { printf("texture%d, ", texture->texture_handle); + update_stats(&midg_stats.texture_count, texture->texture_handle); } /* Print the type, GL style */ @@ -1287,8 +1329,11 @@ print_texture_word(uint32_t *word, unsigned tabs) printf("["); print_texture_reg_select(texture->sampler_handle); printf("]"); + + midg_stats.sampler_count = -16; } else { printf("%d", texture->sampler_handle); + update_stats(&midg_stats.sampler_count, texture->sampler_handle); } print_swizzle_vec4(texture->swizzle, false, false); |