radv: Fix handling of attribs 16-31.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 8 Aug 2020 22:51:15 +0000 (00:51 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 18 Aug 2020 18:31:21 +0000 (20:31 +0200)
We really need to update the enum for consistency, but that involves
a bunch of GL & bitfield work which is error-prone, so since this is
a fix for stable lets do the simple things.

Confirmed that nothing in radv/aco/nir/spirv uses MAX_VERT_ATTRIB
except the one thing I bumped.

CC: mesa-stable
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6120>

src/amd/vulkan/radv_shader.h
src/amd/vulkan/radv_shader_info.c

index 08d7fb9aff27d20bfb7db8201dbbc0d1f8d192ca..adf5620ef23f8e2ac79bf7554889e5b624ae2321 100644 (file)
@@ -36,6 +36,8 @@
 #include "vulkan/vulkan.h"
 #include "vulkan/util/vk_object.h"
 
+#define RADV_VERT_ATTRIB_MAX MAX2(VERT_ATTRIB_MAX, VERT_ATTRIB_GENERIC0 + MAX_VERTEX_ATTRIBS)
+
 struct radv_device;
 
 struct radv_shader_module {
@@ -253,7 +255,7 @@ struct radv_shader_info {
        bool is_ngg_passthrough;
        struct {
                uint64_t ls_outputs_written;
-               uint8_t input_usage_mask[VERT_ATTRIB_MAX];
+               uint8_t input_usage_mask[RADV_VERT_ATTRIB_MAX];
                uint8_t output_usage_mask[VARYING_SLOT_VAR31 + 1];
                bool has_vertex_buffers; /* needs vertex buffers and base/start */
                bool needs_draw_id;
index 8f2b6a1f5b1f2cfb1f8b3e6378aa6c19ae1735ae..2c8d4e0511fc57f2f1a608c1c0a7c41e29820fea 100644 (file)
@@ -403,7 +403,7 @@ gather_info_input_decl_vs(const nir_shader *nir, const nir_variable *var,
        unsigned attrib_count = glsl_count_attribute_slots(var->type, true);
        int idx = var->data.location;
 
-       if (idx >= VERT_ATTRIB_GENERIC0 && idx <= VERT_ATTRIB_GENERIC15)
+       if (idx >= VERT_ATTRIB_GENERIC0 && idx < VERT_ATTRIB_GENERIC0 + MAX_VERTEX_ATTRIBS)
                info->vs.has_vertex_buffers = true;
 
        for (unsigned i = 0; i < attrib_count; ++i) {