Mesa (main): mesa/st: call pipe->link_shader even if ir loaded from cache when linking

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 25 15:00:48 UTC 2022


Module: Mesa
Branch: main
Commit: 5f6a43cde66bc3b2af35a97ee12a22f2a653b8c7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f6a43cde66bc3b2af35a97ee12a22f2a653b8c7

Author: Italo Nicola <italonicola at collabora.com>
Date:   Wed Apr 13 12:24:54 2022 -0300

mesa/st: call pipe->link_shader even if ir loaded from cache when linking

Previously, if the shader was already cached, the pipe->link_shader hook
wouldn't be called, and the gallium driver wouldn't know that shaders
were being linked.

This helps VirGL, because sometimes the guest shader cache can be hit,
while the host shader cache would be missed. VirGL uses this hook to
make the host immediately link shaders, instead of lazily linking them
when a draw call happens, which can degrade performance.

Signed-off-by: Italo Nicola <italonicola at collabora.com>
Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15927>

---

 src/mesa/state_tracker/st_glsl_to_ir.cpp | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_ir.cpp b/src/mesa/state_tracker/st_glsl_to_ir.cpp
index 12d31b9bab5..a44b68ad633 100644
--- a/src/mesa/state_tracker/st_glsl_to_ir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_ir.cpp
@@ -35,20 +35,11 @@
 
 #include "tgsi/tgsi_from_mesa.h"
 
-extern "C" {
-
-/**
- * Link a shader.
- * Called via ctx->Driver.LinkShader()
- * This is a shared function that branches off to either GLSL IR -> TGSI or
- * GLSL IR -> NIR
- */
-GLboolean
-st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
+static GLboolean
+link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 {
    GLboolean ret;
    struct st_context *sctx = st_context(ctx);
-   struct pipe_context *pctx = sctx->pipe;
    struct pipe_screen *pscreen = sctx->screen;
 
    enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir)
@@ -177,6 +168,24 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
    else
       ret = st_link_tgsi(ctx, prog);
 
+   return ret;
+}
+
+extern "C" {
+
+/**
+ * Link a shader.
+ * Called via ctx->Driver.LinkShader()
+ * This is a shared function that branches off to either GLSL IR -> TGSI or
+ * GLSL IR -> NIR
+ */
+GLboolean
+st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
+{
+   struct pipe_context *pctx = st_context(ctx)->pipe;
+
+   GLboolean ret = link_shader(ctx, prog);
+    
    if (pctx->link_shader) {
       void *driver_handles[PIPE_SHADER_TYPES];
       memset(driver_handles, 0, sizeof(driver_handles));



More information about the mesa-commit mailing list