Module: Mesa
Branch: staging/23.2
Commit: a7ee67a3350dc636416ef826f734476dec922ddc
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a7ee67a3350dc636416ef826f734476dec922ddc

Author: Philipp Zabel <[email protected]>
Date:   Mon Jul 17 12:46:59 2023 +0200

etnaviv: fix segfault after compile failure

Do not try to determine the shader stage from the compiled shader
variant, which may be NULL after compile failure. Instead, get it
from the NIR shader.

Fixes a segfault when trying to evaluate etna_shader_stage(NULL)
after compile failure.

Suggested-by: Christian Gmeiner <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Fixes: 3d496190715b ("etnaviv: add support for performance warnings")
Signed-off-by: Philipp Zabel <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24178>
(cherry picked from commit f626605cbff148a15f2448d259530f6d857f56f9)

---

 .pick_status.json                            | 2 +-
 src/gallium/drivers/etnaviv/etnaviv_shader.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 615625fad59..a007677d6bd 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -654,7 +654,7 @@
         "description": "etnaviv: fix segfault after compile failure",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "3d496190715b012613c58de1f22c043e1573d671",
         "notes": null
diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c 
b/src/gallium/drivers/etnaviv/etnaviv_shader.c
index b483966bfff..e0054f94332 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_shader.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c
@@ -347,9 +347,9 @@ etna_shader_update_vs_inputs(struct compiled_shader_state 
*cs,
 }
 
 static inline const char *
-etna_shader_stage(struct etna_shader_variant *shader)
+etna_shader_stage(struct etna_shader *shader)
 {
-   switch (shader->stage) {
+   switch (shader->nir->info.stage) {
    case MESA_SHADER_VERTEX:     return "VERT";
    case MESA_SHADER_FRAGMENT:   return "FRAG";
    case MESA_SHADER_COMPUTE:    return "CL";
@@ -368,7 +368,7 @@ dump_shader_info(struct etna_shader_variant *v, struct 
util_debug_callback *debu
    util_debug_message(debug, SHADER_INFO,
          "%s shader: %u instructions, %u temps, "
          "%u immediates, %u loops",
-         etna_shader_stage(v),
+         etna_shader_stage(v->shader),
          v->code_size / 4,
          v->num_temps,
          v->uniforms.count,
@@ -445,7 +445,7 @@ etna_shader_variant(struct etna_shader *shader,
       perf_debug_message(debug, SHADER_INFO,
                          "%s shader: recompiling at draw time: global "
                          "0x%08x\n",
-                         etna_shader_stage(v), key->global);
+                         etna_shader_stage(shader), key->global);
    }
 
    return v;

Reply via email to