From 63c883ee006dc35136fb4a2403f11fbfdf14e6c5 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Fri, 16 Jun 2023 04:45:16 +0300 Subject: [PATCH] svga: lower images before ntt ntt requires lowered images, so call gl_nir_lower_images first before passing the shader to ntt. Fixes piglit failures spec@glsl-4.30@execution@built-in-functions@cs* Fixes: 0ac95418048 ("gallium: Drop PIPE_SHADER_CAP_PREFERRED_IR") Reviewed-by: Neha Bhende Part-of: --- src/gallium/drivers/svga/meson.build | 1 + src/gallium/drivers/svga/svga_pipe_cs.c | 11 +++++++++-- src/gallium/drivers/svga/svga_shader.c | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/svga/meson.build b/src/gallium/drivers/svga/meson.build index ba51d1f..7d4df8b 100644 --- a/src/gallium/drivers/svga/meson.build +++ b/src/gallium/drivers/svga/meson.build @@ -92,6 +92,7 @@ libsvga = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, include_directories('include') ], + link_with : [libglsl], dependencies : [idep_mesautil, idep_nir], ) diff --git a/src/gallium/drivers/svga/svga_pipe_cs.c b/src/gallium/drivers/svga/svga_pipe_cs.c index 970cc83..49f52b4 100644 --- a/src/gallium/drivers/svga/svga_pipe_cs.c +++ b/src/gallium/drivers/svga/svga_pipe_cs.c @@ -1,5 +1,5 @@ /********************************************************** - * Copyright 2022 VMware, Inc. All rights reserved. + * Copyright 2022-2023 VMware, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -23,7 +23,10 @@ * **********************************************************/ +#include "compiler/nir/nir.h" +#include "compiler/glsl/gl_nir.h" #include "nir/nir_to_tgsi.h" + #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_bitmask.h" @@ -47,6 +50,7 @@ svga_create_compute_state(struct pipe_context *pipe, struct svga_context *svga = svga_context(pipe); struct svga_compute_shader *cs = CALLOC_STRUCT(svga_compute_shader); + nir_shader *nir = (nir_shader *)templ->prog; if (!cs) return NULL; @@ -54,7 +58,10 @@ svga_create_compute_state(struct pipe_context *pipe, SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_CREATECS); assert(templ->ir_type == PIPE_SHADER_IR_NIR); - cs->base.tokens = nir_to_tgsi((void *)templ->prog, pipe->screen); + /* nir_to_tgsi requires lowered images */ + NIR_PASS_V(nir, gl_nir_lower_images, false); + + cs->base.tokens = nir_to_tgsi((void *)nir, pipe->screen); struct svga_shader *shader = &cs->base; shader->id = svga->debug.shader_id++; diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c index cac90c8..a956bb6 100644 --- a/src/gallium/drivers/svga/svga_shader.c +++ b/src/gallium/drivers/svga/svga_shader.c @@ -1,5 +1,5 @@ /********************************************************** - * Copyright 2008-2022 VMware, Inc. All rights reserved. + * Copyright 2008-2023 VMware, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -33,6 +33,9 @@ #include "svga_tgsi.h" #include "svga_resource_texture.h" #include "VGPU10ShaderTokens.h" + +#include "compiler/nir/nir.h" +#include "compiler/glsl/gl_nir.h" #include "nir/nir_to_tgsi.h" @@ -918,6 +921,7 @@ svga_create_shader(struct pipe_context *pipe, { struct svga_context *svga = svga_context(pipe); struct svga_shader *shader = CALLOC(1, shader_structlen); + nir_shader *nir = (nir_shader *)templ->ir.nir; if (shader == NULL) return NULL; @@ -925,6 +929,10 @@ svga_create_shader(struct pipe_context *pipe, shader->id = svga->debug.shader_id++; shader->stage = stage; + if (templ->type == PIPE_SHADER_IR_NIR) { + /* nir_to_tgsi requires lowered images */ + NIR_PASS_V(nir, gl_nir_lower_images, false); + } shader->tokens = pipe_shader_state_to_tgsi_tokens(pipe->screen, templ); shader->type = PIPE_SHADER_IR_TGSI; -- 2.7.4