svga: lower images before ntt
authorCharmaine Lee <charmainel@vmware.com>
Fri, 16 Jun 2023 01:45:16 +0000 (04:45 +0300)
committerMarge Bot <emma+marge@anholt.net>
Fri, 16 Jun 2023 21:44:22 +0000 (21:44 +0000)
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 <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23697>

src/gallium/drivers/svga/meson.build
src/gallium/drivers/svga/svga_pipe_cs.c
src/gallium/drivers/svga/svga_shader.c

index ba51d1f..7d4df8b 100644 (file)
@@ -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],
 )
 
index 970cc83..49f52b4 100644 (file)
@@ -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
  *
  **********************************************************/
 
+#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++;
index cac90c8..a956bb6 100644 (file)
@@ -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;