pan/mdg: Add 16 bytes of padding to the end of shaders

Fixes INSTR_INVALID_PC faults when a shader ends on a 16MB boundary.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11551>
(cherry picked from commit 08495a948e)
This commit is contained in:
Icecream95 2021-06-23 20:31:37 +12:00 committed by Eric Engestrom
parent d743d6c173
commit f0d4f840f8
2 changed files with 7 additions and 1 deletions

View file

@ -1264,7 +1264,7 @@
"description": "pan/mdg: Add 16 bytes of padding to the end of shaders",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -3204,6 +3204,12 @@ midgard_compile_shader_nir(nir_shader *nir,
fflush(stdout);
}
/* A shader ending on a 16MB boundary causes INSTR_INVALID_PC faults,
* workaround by adding some padding to the end of the shader. (The
* kernel makes sure shader BOs can't cross 16MB boundaries.) */
if (binary->size)
memset(util_dynarray_grow(binary, uint8_t, 16), 0, 16);
if ((midgard_debug & MIDGARD_DBG_SHADERDB || inputs->shaderdb) &&
!nir->info.internal) {
unsigned nr_bundles = 0, nr_ins = 0;