pan/bi: Ignore signedness in vertex fetch
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 14 Mar 2023 02:31:28 +0000 (22:31 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 14 Mar 2023 23:10:00 +0000 (23:10 +0000)
We just want a bit-exact transfer for integers. Using .auto32 accomplishes this
without any clamping shenanigans. Fixes gl-3.0-vertexattribipointer.

Note we can't use .auto32 unconditionally, since reading a uint vertex as float
is supposed to convert (or something like that, gl-2.0-vertexattribpointer tests
the bad case at any rate).

Fixes: 482cc273af5 ("pan/bi: Implement load attribute with the builder")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21891>

src/panfrost/ci/panfrost-g52-fails.txt
src/panfrost/compiler/bifrost_compile.c

index c4144a2..b94da48 100644 (file)
@@ -546,7 +546,6 @@ spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
 spec@!opengl 2.1@pbo,Fail
 spec@!opengl 2.1@pbo@test_polygon_stip,Fail
 spec@!opengl 2.1@polygon-stipple-fs,Fail
-spec@!opengl 3.0@gl-3.0-vertexattribipointer,Fail
 spec@!opengl 3.0@gl_vertexid used with glmultidrawarrays,Fail
 spec@!opengl 3.1@primitive-restart-xfb flush,Fail
 spec@!opengl 3.1@primitive-restart-xfb generated,Fail
index 6055322..ea78c1c 100644 (file)
@@ -412,8 +412,17 @@ bi_copy_component(bi_builder *b, nir_intrinsic_instr *instr, bi_index tmp)
 static void
 bi_emit_load_attr(bi_builder *b, nir_intrinsic_instr *instr)
 {
+   /* Disregard the signedness of an integer, since loading 32-bits into a
+    * 32-bit register should be bit exact so should not incur any clamping.
+    *
+    * If we are reading as a u32, then it must be paired with an integer (u32 or
+    * s32) source, so use .auto32 to disregard.
+    */
    nir_alu_type T = nir_intrinsic_dest_type(instr);
-   enum bi_register_format regfmt = bi_reg_fmt_for_nir(T);
+   assert(T == nir_type_uint32 || T == nir_type_int32 || T == nir_type_float32);
+   enum bi_register_format regfmt =
+      T == nir_type_float32 ? BI_REGISTER_FORMAT_F32 : BI_REGISTER_FORMAT_AUTO;
+
    nir_src *offset = nir_get_io_offset_src(instr);
    unsigned component = nir_intrinsic_component(instr);
    enum bi_vecsize vecsize = (instr->num_components + component - 1);