From: Alyssa Rosenzweig Date: Thu, 19 Dec 2019 17:28:42 +0000 (-0500) Subject: pan/decode: Handle gl_VertexID/gl_InstanceID X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3b3d9653a7e7971a754f8debb8b6680f36e88953;p=mesa.git pan/decode: Handle gl_VertexID/gl_InstanceID Just like varyings have special records for point coordinates (etc), attributes have special records for vertex/instance ID. We can parse these fairly easily, although they don't line up exactly with normal attribute records. Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/gallium/drivers/panfrost/pan_varyings.c b/src/gallium/drivers/panfrost/pan_varyings.c index 8383c3efd28..0ec4d5633d2 100644 --- a/src/gallium/drivers/panfrost/pan_varyings.c +++ b/src/gallium/drivers/panfrost/pan_varyings.c @@ -381,7 +381,7 @@ panfrost_emit_varying_descriptor( /* Fix up unaligned addresses */ for (unsigned i = 0; i < so_count; ++i) { - if (varyings[i].elements < MALI_VARYING_SPECIAL) + if (varyings[i].elements < MALI_RECORD_SPECIAL) continue; unsigned align = (varyings[i].elements & 63); diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 7bf23b09836..70ab2585eea 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -816,9 +816,10 @@ enum mali_attr_mode { MALI_ATTR_INTERNAL = 6 }; -/* Pseudo-address for gl_FrontFacing, used with INTERNAL. Same addres is used - * for gl_FragCoord with IMAGE, needing a coordinate flip. Who knows. */ +/* Pseudo-address for gl_VertexID, gl_FragCoord, gl_FrontFacing */ +#define MALI_ATTR_VERTEXID (0x22) +#define MALI_ATTR_INSTANCEID (0x24) #define MALI_VARYING_FRAG_COORD (0x25) #define MALI_VARYING_FRONT_FACING (0x26) @@ -832,7 +833,7 @@ enum mali_attr_mode { /* Used for comparison to check if an address is special. Mostly a guess, but * it doesn't really matter. */ -#define MALI_VARYING_SPECIAL (0x100) +#define MALI_RECORD_SPECIAL (0x100) union mali_attr { /* This is used for actual attributes. */ diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index 5e270f2d93b..73f26402cb0 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -441,9 +441,15 @@ static char *pandecode_attr_mode_short(enum mali_attr_mode mode) } static const char * -pandecode_special_varying(uint64_t v) +pandecode_special_record(uint64_t v, bool* attribute) { switch(v) { + case MALI_ATTR_VERTEXID: + *attribute = true; + return "gl_VertexID"; + case MALI_ATTR_INSTANCEID: + *attribute = true; + return "gl_InstanceID"; case MALI_VARYING_FRAG_COORD: return "gl_FragCoord"; case MALI_VARYING_FRONT_FACING: @@ -451,7 +457,7 @@ pandecode_special_varying(uint64_t v) case MALI_VARYING_POINT_COORD: return "gl_PointCoord"; default: - pandecode_msg("XXX: invalid special varying %" PRIx64 "\n", v); + pandecode_msg("XXX: invalid special record %" PRIx64 "\n", v); return ""; } } @@ -1334,27 +1340,44 @@ pandecode_attributes(const struct pandecode_mapped_memory *mem, for (int i = 0; i < count; ++i) { /* First, check for special records */ - if (attr[i].elements < MALI_VARYING_SPECIAL) { - /* Special records are always varyings */ + if (attr[i].elements < MALI_RECORD_SPECIAL) { + if (attr[i].size) + pandecode_msg("XXX: tripped size=%d\n", attr[i].size); + + if (attr[i].stride) { + /* gl_InstanceID passes a magic divisor in the + * stride field to divide by the padded vertex + * count. No other records should do so, so + * stride should otherwise be zero. Note that + * stride in the usual attribute sense doesn't + * apply to special records. */ + + bool has_divisor = attr[i].elements == MALI_ATTR_INSTANCEID; + + pandecode_log_cont("/* %smagic divisor = %X */ ", + has_divisor ? "" : "XXX: ", attr[i].stride); + } - if (!varying) - pandecode_msg("XXX: Special varying in attribute field\n"); + if (attr[i].shift || attr[i].extra_flags) { + /* Attributes use these fields for + * instancing/padding/etc type issues, but + * varyings don't */ - if (job_type != JOB_TYPE_TILER) - pandecode_msg("XXX: Special varying in non-FS\n"); + pandecode_log_cont("/* %sshift=%d, extra=%d */ ", + varying ? "XXX: " : "", + attr[i].shift, attr[i].extra_flags); + } - /* We're special, so all fields should be zero */ - unsigned zero = attr[i].stride | attr[i].size; - zero |= attr[i].shift | attr[i].extra_flags; + /* Print the special record name */ + bool attribute = false; + pandecode_log("%s_%d = %s;\n", prefix, i, pandecode_special_record(attr[i].elements, &attribute)); - if (zero) - pandecode_msg("XXX: Special varying has non-zero fields\n"); - else { - /* Print the special varying name */ - pandecode_log("varying_%d = %s;", i, pandecode_special_varying(attr[i].elements)); - continue; - } - } + /* Sanity check */ + if (attribute == varying) + pandecode_msg("XXX: mismatched special record\n"); + + continue; + } enum mali_attr_mode mode = attr[i].elements & 7;