agx: Align preamble shaders

I don't know if it's ok to have unaligned programs, let's not risk it.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18813>
This commit is contained in:
Alyssa Rosenzweig
2022-09-25 20:55:26 -04:00
parent e466a7d1d8
commit ca4fe9d3f5
+11
View File
@@ -32,6 +32,9 @@
#include "agx_compiler.h"
#include "agx_builder.h"
/* Alignment for shader programs. I'm not sure what the optimal value is. */
#define AGX_CODE_ALIGN 0x100
static const struct debug_named_value agx_debug_options[] = {
{"msgs", AGX_DBG_MSGS, "Print debug messages"},
{"shaders", AGX_DBG_SHADERS, "Dump shaders in NIR and AIR"},
@@ -1801,7 +1804,15 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
agx_lower_pseudo(ctx);
/* Pad binary */
if (binary->size % AGX_CODE_ALIGN) {
unsigned ngrow = AGX_CODE_ALIGN - (binary->size % AGX_CODE_ALIGN);
memset(util_dynarray_grow_bytes(binary, ngrow, 1), 0, ngrow);
}
unsigned offset = binary->size;
assert((offset % AGX_CODE_ALIGN) == 0);
agx_pack_binary(ctx, binary);
/* Don't dump statistics for preambles, since they're not worth optimizing */