From 8adeeaa7f21a939a3e9610c6e3684a9652f32546 Mon Sep 17 00:00:00 2001 From: Andreas Baierl Date: Mon, 9 Dec 2019 12:42:30 +0100 Subject: [PATCH] lima/parser: Add texture descriptor parser Signed-off-by: Andreas Baierl Part-of: --- src/gallium/drivers/lima/lima_parser.c | 117 ++++++++++++++++++++++++ src/gallium/drivers/lima/lima_parser.h | 1 + src/gallium/drivers/lima/lima_texture.c | 5 + src/gallium/drivers/lima/lima_util.c | 7 ++ src/gallium/drivers/lima/lima_util.h | 1 + 5 files changed, 131 insertions(+) diff --git a/src/gallium/drivers/lima/lima_parser.c b/src/gallium/drivers/lima/lima_parser.c index a0c22b432e0..2becad8c121 100644 --- a/src/gallium/drivers/lima/lima_parser.c +++ b/src/gallium/drivers/lima/lima_parser.c @@ -29,7 +29,9 @@ #include #include +#include "lima_context.h" #include "lima_parser.h" +#include "lima_texture.h" typedef struct { char *info; @@ -588,3 +590,118 @@ lima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start) } fprintf(fp, "/* ============ RSW END =========================== */\n"); } + +static void +parse_texture(FILE *fp, uint32_t *data, uint32_t start, uint32_t offset) +{ + uint32_t i = 0; + offset /= 4; + lima_tex_desc *desc = (lima_tex_desc *)&data[offset]; + + /* Word 0 */ + fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x\n", + start + i * 4, i * 4, *(&data[i + offset])); + i++; + fprintf(fp, "\t format: 0x%x (%d)\n", desc->format, desc->format); + fprintf(fp, "\t flag1: 0x%x (%d)\n", desc->flag1, desc->flag1); + fprintf(fp, "\t swap_r_b: 0x%x (%d)\n", desc->swap_r_b, desc->swap_r_b); + fprintf(fp, "\t unknown_0_1: 0x%x (%d)\n", desc->unknown_0_1, desc->unknown_0_1); + fprintf(fp, "\t stride: 0x%x (%d)\n", desc->stride, desc->stride); + fprintf(fp, "\t unknown_0_2: 0x%x (%d)\n", desc->unknown_0_2, desc->unknown_0_2); + + /* Word 1 - 3 */ + fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x 0x%08x 0x%08x\n", + start + i * 4, i * 4, *(&data[i + offset]), *(&data[i + 1 + offset]), *(&data[i + 2 + offset])); + i += 3; + fprintf(fp, "\t unknown_1_1: 0x%x (%d)\n", desc->unknown_1_1, desc->unknown_1_1); + fprintf(fp, "\t unnorm_coords: 0x%x (%d)\n", desc->unnorm_coords, desc->unnorm_coords); + fprintf(fp, "\t unknown_1_2: 0x%x (%d)\n", desc->unknown_1_2, desc->unknown_1_2); + fprintf(fp, "\t texture_type: 0x%x (%d)\n", desc->texture_type, desc->texture_type); + fprintf(fp, "\t unknown_1_3: 0x%x (%d)\n", desc->unknown_1_3, desc->unknown_1_3); + fprintf(fp, "\t miplevels: 0x%x (%d)\n", desc->miplevels, desc->miplevels); + fprintf(fp, "\t min_mipfilter_1: 0x%x (%d)\n", desc->min_mipfilter_1, desc->min_mipfilter_1); + fprintf(fp, "\t unknown_2_1: 0x%x (%d)\n", desc->unknown_2_1, desc->unknown_2_1); + fprintf(fp, "\t has_stride: 0x%x (%d)\n", desc->has_stride, desc->has_stride); + fprintf(fp, "\t min_mipfilter_2: 0x%x (%d)\n", desc->min_mipfilter_2, desc->min_mipfilter_2); + fprintf(fp, "\t min_img_filter_nearest: 0x%x (%d)\n", desc->min_img_filter_nearest, desc->min_img_filter_nearest); + fprintf(fp, "\t mag_img_filter_nearest: 0x%x (%d)\n", desc->mag_img_filter_nearest, desc->mag_img_filter_nearest); + fprintf(fp, "\t wrap_s_clamp_to_edge: 0x%x (%d)\n", desc->wrap_s_clamp_to_edge, desc->wrap_s_clamp_to_edge); + fprintf(fp, "\t wrap_s_clamp: 0x%x (%d)\n", desc->wrap_s_clamp, desc->wrap_s_clamp); + fprintf(fp, "\t wrap_s_mirror_repeat: 0x%x (%d)\n", desc->wrap_s_mirror_repeat, desc->wrap_s_mirror_repeat); + fprintf(fp, "\t wrap_t_clamp_to_edge: 0x%x (%d)\n", desc->wrap_t_clamp_to_edge, desc->wrap_t_clamp_to_edge); + fprintf(fp, "\t wrap_t_clamp: 0x%x (%d)\n", desc->wrap_t_clamp, desc->wrap_t_clamp); + fprintf(fp, "\t wrap_t_mirror_repeat: 0x%x (%d)\n", desc->wrap_t_mirror_repeat, desc->wrap_t_mirror_repeat); + fprintf(fp, "\t unknown_2_2: 0x%x (%d)\n", desc->unknown_2_2, desc->unknown_2_2); + fprintf(fp, "\t width: 0x%x (%d)\n", desc->width, desc->width); + fprintf(fp, "\t height: 0x%x (%d)\n", desc->height, desc->height); + fprintf(fp, "\t unknown_3_1: 0x%x (%d)\n", desc->unknown_3_1, desc->unknown_3_1); + fprintf(fp, "\t unknown_3_2: 0x%x (%d)\n", desc->unknown_3_2, desc->unknown_3_2); + + /* Word 4 */ + fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x\n", + start + i * 4, i * 4, *(&data[i + offset])); + i++; + fprintf(fp, "\t unknown_4: 0x%x (%d)\n", desc->unknown_4, desc->unknown_4); + + /* Word 5 */ + fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x\n", + start + i * 4, i * 4, *(&data[i + offset])); + i++; + fprintf(fp, "\t unknown_5: 0x%x (%d)\n", desc->unknown_5, desc->unknown_5); + + /* Word 6 - */ + fprintf(fp, "/* 0x%08x (0x%08x) */", + start + i * 4, i * 4); + fprintf(fp, "\t"); + for (int k = 0; k < ((((desc->miplevels + 1) * 26) + 64) / 32); k++) + fprintf(fp, "0x%08x ", *(&data[i + offset + k])); + fprintf(fp, "\n"); + + i++; + fprintf(fp, "\t unknown_6_1: 0x%x (%d)\n", desc->va_s.unknown_6_1, desc->va_s.unknown_6_1); + fprintf(fp, "\t layout: 0x%x (%d)\n", desc->va_s.layout, desc->va_s.layout); + fprintf(fp, "\t unknown_6_2: 0x%x (%d)\n", desc->va_s.unknown_6_2, desc->va_s.unknown_6_2); + fprintf(fp, "\t unknown_6_3: 0x%x (%d)\n", desc->va_s.unknown_6_3, desc->va_s.unknown_6_3); + + /* first level */ + fprintf(fp, "\t va_0: 0x%x \n", desc->va_s.va_0 << 6); + + /* second level up to desc->miplevels */ + int j; + unsigned va_bit_idx; + unsigned va_idx; + uint32_t va; + uint32_t va_1; + uint32_t va_2; + for (j = 1; j <= desc->miplevels; j++) { + va = 0; + va_1 = 0; + va_2 = 0; + + va_bit_idx = VA_BIT_OFFSET + (VA_BIT_SIZE * j); + va_idx = va_bit_idx / 32; + va_bit_idx %= 32; + + /* the first (32 - va_bit_idx) bits */ + va_1 |= (*(&data[i + offset + va_idx - 1]) >> va_bit_idx); + + /* do we need some bits from the following word? */ + if (va_bit_idx > 6) { + /* shift left and right again to erase the unneeded bits, keep space for va1 */ + va_2 |= (*(&data[i + offset + va_idx]) << (2 * 32 - VA_BIT_SIZE - va_bit_idx)); + va_2 >>= ((2 * 32 - VA_BIT_SIZE - va_bit_idx) - (32 - va_bit_idx)); + va |= va_2; + } + va |= va_1; + va <<= 6; + fprintf(fp, "\t va_%d: 0x%x \n", j, va); + } +} + +void +lima_parse_texture_descriptor(FILE *fp, uint32_t *data, int size, uint32_t start, uint32_t offset) +{ + fprintf(fp, "/* ============ TEXTURE BEGIN ===================== */\n"); + parse_texture(fp, data, start, offset); + fprintf(fp, "/* ============ TEXTURE END ======================= */\n"); +} diff --git a/src/gallium/drivers/lima/lima_parser.h b/src/gallium/drivers/lima/lima_parser.h index 18a6c201335..fba8e50f11b 100644 --- a/src/gallium/drivers/lima/lima_parser.h +++ b/src/gallium/drivers/lima/lima_parser.h @@ -27,5 +27,6 @@ void lima_parse_vs(FILE *fp, uint32_t *data, int size, uint32_t start); void lima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start); void lima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start); +void lima_parse_texture_descriptor(FILE *fp, uint32_t *data, int size, uint32_t start, uint32_t offset); #endif diff --git a/src/gallium/drivers/lima/lima_texture.c b/src/gallium/drivers/lima/lima_texture.c index 39433c05801..307cf8e2491 100644 --- a/src/gallium/drivers/lima/lima_texture.c +++ b/src/gallium/drivers/lima/lima_texture.c @@ -272,4 +272,9 @@ lima_update_textures(struct lima_context *ctx) lima_dump_command_stream_print( descs, size, false, "add textures_desc at va %x\n", lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc, 0)); + + lima_dump_texture_descriptor( + descs, size, + lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc, 0) + lima_tex_list_size, + lima_tex_list_size); } diff --git a/src/gallium/drivers/lima/lima_util.c b/src/gallium/drivers/lima/lima_util.c index 706529483bb..e162b4c556f 100644 --- a/src/gallium/drivers/lima/lima_util.c +++ b/src/gallium/drivers/lima/lima_util.c @@ -91,6 +91,13 @@ lima_dump_rsw_command_stream_print(void *data, int size, uint32_t start) lima_parse_render_state(lima_dump_command_stream, (uint32_t *)data, size, start); } +void +lima_dump_texture_descriptor(void *data, int size, uint32_t start, uint32_t offset) +{ + if (lima_dump_command_stream) + lima_parse_texture_descriptor(lima_dump_command_stream, (uint32_t *)data, size, start, offset); +} + void lima_dump_command_stream_print(void *data, int size, bool is_float, const char *fmt, ...) diff --git a/src/gallium/drivers/lima/lima_util.h b/src/gallium/drivers/lima/lima_util.h index e0b1b8805a5..36b6aaacabc 100644 --- a/src/gallium/drivers/lima/lima_util.h +++ b/src/gallium/drivers/lima/lima_util.h @@ -34,6 +34,7 @@ void lima_dump_blob(FILE *fp, void *data, int size, bool is_float); void lima_dump_vs_command_stream_print(void *data, int size, uint32_t start); void lima_dump_plbu_command_stream_print(void *data, int size, uint32_t start); void lima_dump_rsw_command_stream_print(void *data, int size, uint32_t start); +void lima_dump_texture_descriptor(void *data, int size, uint32_t start, uint32_t offset); void lima_dump_command_stream_print(void *data, int size, bool is_float, const char *fmt, ...); -- 2.30.2