agx: fix load_first_vertex

base vertex is GL, first vertex is VK. because we missed this check, VK (but not
GL) shaders using first vertex (but not base instance) would not get that flag
set and so hk wouldn't bother uploading the draw parameters, so first_vertex
would read garbage.

because vertex ID is defined differently between the Khronos and Microsoft APIs,
every complex DXVK vertex shader will implement vertex ID with a subtraction of
first vertex.

forcing geometry shaders worked around the bug, because IIRC geometry shaders
also force the draw parameter upload path for $REASONS. maybe

disabling preambles changed symptoms simply because the uniform file looked
different, and we were reading uninitialized garbage regardless writing stuff in
preambles would maybe change the garbage for other draws or something.  (Not
sure on the details but the physical uniform registers I guess get reused over
the lifetime of a shader core and never zero initialized) So we were reading
uninitialized garbage and yeah everything blows up

Anyway. I just wasted too much of my life on this.

This single line of code fixes rendering in every DX11 game. that's probably not
an exaggeration.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31532>
This commit is contained in:
Alyssa Rosenzweig
2024-09-28 14:35:35 -04:00
committed by Marge Bot
parent f786bcc8c2
commit cbd9cb04cf
+1
View File
@@ -3781,6 +3781,7 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID);
info->uses_base_param =
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FIRST_VERTEX) ||
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX) ||
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_INSTANCE);