radv: compute the number of records correctly for vertex buffers
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 21 Oct 2019 16:41:33 +0000 (18:41 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 24 Oct 2019 15:14:43 +0000 (17:14 +0200)
On GFX8 the number of records is in bytes while on other chips
it's in units of "stride".

Fixes dEQP-VK.robustness.vertex_access.*.draw.vertex_* on RAVEN.

Tested on GFX6, GFX8, GFX10 and RAVEN.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c

index fb2490f6382d83ffe5e0f0ce5b836430eb4a53b0..d22bc84c897636c69ac5d5164a2b66d35703b7f3 100644 (file)
@@ -2386,7 +2386,6 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer,
            (cmd_buffer->state.dirty & RADV_CMD_DIRTY_VERTEX_BUFFER)) &&
            cmd_buffer->state.pipeline->num_vertex_bindings &&
            radv_get_shader(cmd_buffer->state.pipeline, MESA_SHADER_VERTEX)->info.vs.has_vertex_buffers) {
-               struct radv_vertex_elements_info *velems = &cmd_buffer->state.pipeline->vertex_elements;
                unsigned vb_offset;
                void *vb_ptr;
                uint32_t i = 0;
@@ -2403,6 +2402,7 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer,
                        uint32_t offset;
                        struct radv_buffer *buffer = cmd_buffer->vertex_bindings[i].buffer;
                        uint32_t stride = cmd_buffer->state.pipeline->binding_stride[i];
+                       unsigned num_records;
 
                        if (!buffer)
                                continue;
@@ -2411,12 +2411,14 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer,
 
                        offset = cmd_buffer->vertex_bindings[i].offset;
                        va += offset + buffer->offset;
+
+                       num_records = buffer->size - offset;
+                       if (cmd_buffer->device->physical_device->rad_info.chip_class != GFX8 && stride)
+                               num_records /= stride;
+
                        desc[0] = va;
                        desc[1] = S_008F04_BASE_ADDRESS_HI(va >> 32) | S_008F04_STRIDE(stride);
-                       if (cmd_buffer->device->physical_device->rad_info.chip_class <= GFX7 && stride)
-                               desc[2] = (buffer->size - offset - velems->format_size[i]) / stride + 1;
-                       else
-                               desc[2] = buffer->size - offset;
+                       desc[2] = num_records;
                        desc[3] = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) |
                                  S_008F0C_DST_SEL_Y(V_008F0C_SQ_SEL_Y) |
                                  S_008F0C_DST_SEL_Z(V_008F0C_SQ_SEL_Z) |