From a9b37e5dad6652e7cb404da6a0452dfd46533d04 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 4 Aug 2020 16:43:51 -0700 Subject: [PATCH] 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: --- 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);