From 024f9cf24ff012e6fdf582c2852b591d2d51d00d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 20 Aug 2019 14:58:46 -0700 Subject: pan/decode: Validate texture dimensionality Textures of a smaller dimension don't need higher dimensions printed. This allows us to be more compact, while enforcing verification that higher dimensions must be zero. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/pandecode/decode.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index e5d22b5562b..3a32d25cabe 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -1759,14 +1759,41 @@ pandecode_texture(mali_ptr u, pandecode_log("struct mali_texture_descriptor texture_descriptor_%"PRIx64"_%d_%d = {\n", u, job_no, tex); pandecode_indent++; - pandecode_prop("width = MALI_POSITIVE(%" PRId16 ")", t->width + 1); - pandecode_prop("height = MALI_POSITIVE(%" PRId16 ")", t->height + 1); - pandecode_prop("depth = MALI_POSITIVE(%" PRId16 ")", t->depth + 1); - pandecode_prop("array_size = MALI_POSITIVE(%" PRId16 ")", t->array_size + 1); - pandecode_prop("nr_mipmap_levels = %" PRId8, t->nr_mipmap_levels); - struct mali_texture_format f = t->format; + /* See the definiton of enum mali_texture_type */ + + unsigned dimension = + (f.type == MALI_TEX_CUBE) ? 2 : f.type; + + /* All four width/height/depth/array_size dimensions are present + * regardless of the type of texture, but it is an error to have + * non-zero dimensions for unused dimensions. Verify this. array_size + * can always be set, as can width. */ + + if (t->height && dimension < 2) + pandecode_msg("XXX: nonzero height for <2D texture\n"); + + if (t->depth && dimension < 3) + pandecode_msg("XXX: nonzero depth for <2D texture\n"); + + /* Print only the dimensions that are actually there */ + + pandecode_log("dim: %d", t->width + 1); + + if (dimension >= 2) + pandecode_log_cont("x%u", t->height + 1); + + if (dimension >= 3) + pandecode_log_cont("x%u", t->depth + 1); + + if (t->array_size) + pandecode_log_cont("[%u]", t->array_size + 1); + + pandecode_log_cont("\n"); + + pandecode_prop("nr_mipmap_levels = %" PRId8, t->nr_mipmap_levels); + pandecode_log(".format = {\n"); pandecode_indent++; -- cgit v1.2.3