tgsi_to_nir: Emit load_ubo_vec4 instead of load_ubo on non-integer HW.
authorEmma Anholt <emma@anholt.net>
Fri, 4 Feb 2022 19:29:27 +0000 (11:29 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 20 Apr 2022 13:47:50 +0000 (13:47 +0000)
Otherwise, we get an ishl that the HW can't support, and a ushr if the NIR
ends up being lowered to ubo_vec4, which may not get constant-folded if
the offset was non-constant.

This matches what mesa/st uses for this arg to uniform lowering.

Fixes: #5971
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14883>

src/gallium/auxiliary/nir/tgsi_to_nir.c

index 3823089..c13a652 100644 (file)
@@ -93,6 +93,7 @@ struct ttn_compile {
    bool cap_position_is_sysval;
    bool cap_point_is_sysval;
    bool cap_samplers_as_deref;
+   bool cap_integers;
 };
 
 #define ttn_swizzle(b, src, x, y, z, w) \
@@ -2276,6 +2277,7 @@ ttn_read_pipe_caps(struct ttn_compile *c,
    c->cap_face_is_sysval = screen->get_param(screen, PIPE_CAP_FS_FACE_IS_INTEGER_SYSVAL);
    c->cap_position_is_sysval = screen->get_param(screen, PIPE_CAP_FS_POSITION_IS_SYSVAL);
    c->cap_point_is_sysval = screen->get_param(screen, PIPE_CAP_FS_POINT_IS_SYSVAL);
+   c->cap_integers = screen->get_shader_param(screen, c->scan->processor, PIPE_SHADER_CAP_INTEGERS);
 }
 
 /**
@@ -2481,7 +2483,7 @@ ttn_finalize_nir(struct ttn_compile *c, struct pipe_screen *screen)
    }
 
    if (nir->options->lower_uniforms_to_ubo)
-      NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, false, false);
+      NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, false, !c->cap_integers);
 
    if (!c->cap_samplers_as_deref)
       NIR_PASS_V(nir, nir_lower_samplers);