Mesa (master): freedreno/ir3: Include at least 4 NOPs so that cffdump doesn't disasm junk.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 16 22:33:02 UTC 2020
Module: Mesa
Branch: master
Commit: a9b37e5dad6652e7cb404da6a0452dfd46533d04
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9b37e5dad6652e7cb404da6a0452dfd46533d04
Author: Eric Anholt <eric at anholt.net>
Date: Tue Aug 4 16:43:51 2020 -0700
freedreno/ir3: Include at least 4 NOPs so that cffdump doesn't disasm junk.
cffdump looks at the following 4 instructions to decide if the shader has
*really* ended, so if we pack data after that (such as turnip's next
stage's shader), it might decode instructions that aren't really part of
the shader.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5810>
---
src/freedreno/ir3/ir3.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c
index 3705c85936b..84aa8eb46d9 100644
--- a/src/freedreno/ir3/ir3.c
+++ b/src/freedreno/ir3/ir3.c
@@ -938,8 +938,17 @@ void * ir3_assemble(struct ir3_shader_variant *v)
v->instrlen = DIV_ROUND_UP(instr_count, compiler->instr_align);
- /* Pad out with NOPs to instrlen. */
- info->sizedwords = v->instrlen * compiler->instr_align * sizeof(instr_t) / 4;
+ /* Pad out with NOPs to instrlen, including at least 4 so that cffdump
+ * doesn't try to decode the following data as instructions (such as the
+ * next stage's shader in turnip)
+ */
+ info->sizedwords = MAX2(v->instrlen * compiler->instr_align,
+ instr_count + 4) * sizeof(instr_t) / 4;
+
+ /* Pad out the size so that when turnip uploads the shaders in
+ * sequence, the starting offset of the next one is properly aligned.
+ */
+ info->sizedwords = align(info->sizedwords, compiler->instr_align * sizeof(instr_t) / 4);
ptr = dwords = rzalloc_size(v, 4 * info->sizedwords);
More information about the mesa-commit
mailing list