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@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15927>
This commit is contained in:
Italo Nicola 2022-04-13 12:24:54 -03:00 committed by Marge Bot
parent e94f89189b
commit 5f6a43cde6
1 changed files with 20 additions and 11 deletions

View File

@ -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));