From: Kenneth Graunke Date: Sun, 22 Dec 2019 23:43:51 +0000 (-0800) Subject: iris: Fix shader recompile debug printing X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c96c1141fba7d94b4b3b048111d8858ecac7cf55;p=mesa.git iris: Fix shader recompile debug printing I was passing iris keys to brw_debug_key_recompile, leading to out of bounds memory reads. Fixes: 2e654db27a1 ("iris: Create smaller program keys without legacy features") --- diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 9e2f34f2b11..c162141a9f9 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -991,6 +991,7 @@ iris_debug_recompile(struct iris_context *ice, const struct brw_base_prog_key *key) { struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen; + const struct gen_device_info *devinfo = &screen->devinfo; const struct brw_compiler *c = screen->compiler; if (!info) @@ -1001,10 +1002,35 @@ iris_debug_recompile(struct iris_context *ice, info->name ? info->name : "(no identifier)", info->label ? info->label : ""); - const void *old_key = + const void *old_iris_key = iris_find_previous_compile(ice, info->stage, key->program_string_id); - brw_debug_key_recompile(c, &ice->dbg, info->stage, old_key, key); + union brw_any_prog_key old_key; + + switch (info->stage) { + case MESA_SHADER_VERTEX: + old_key.vs = iris_to_brw_vs_key(devinfo, old_iris_key); + break; + case MESA_SHADER_TESS_CTRL: + old_key.tcs = iris_to_brw_tcs_key(devinfo, old_iris_key); + break; + case MESA_SHADER_TESS_EVAL: + old_key.tes = iris_to_brw_tes_key(devinfo, old_iris_key); + break; + case MESA_SHADER_GEOMETRY: + old_key.gs = iris_to_brw_gs_key(devinfo, old_iris_key); + break; + case MESA_SHADER_FRAGMENT: + old_key.wm = iris_to_brw_fs_key(devinfo, old_iris_key); + break; + case MESA_SHADER_COMPUTE: + old_key.cs = iris_to_brw_cs_key(devinfo, old_iris_key); + break; + default: + unreachable("invalid shader stage"); + } + + brw_debug_key_recompile(c, &ice->dbg, info->stage, &old_key.base, key); } /**