radv: adjust num_records when offset>stride

If an attribute's offset is larger than the stride, the compiler will
increase the vertex index and use offset%stride instead as the offset.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5007
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11642>
This commit is contained in:
Rhys Perry
2021-06-29 16:30:00 +01:00
committed by Marge Bot
parent e4fbb200fc
commit a2ac660eb7
3 changed files with 13 additions and 3 deletions

View File

@@ -2904,12 +2904,18 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer, bool pipeline_
if (pipeline->use_per_attribute_vb_descs) {
uint32_t attrib_end = pipeline->attrib_ends[i];
if (num_records < attrib_end)
if (num_records < attrib_end) {
num_records = 0; /* not enough space for one vertex */
else if (stride == 0)
} else if (stride == 0) {
num_records = 1; /* only one vertex */
else
} else {
num_records = (num_records - attrib_end) / stride + 1;
/* If attrib_offset>stride, then the compiler will increase the vertex index by
* attrib_offset/stride and decrease the offset by attrib_offset%stride. This is
* only allowed with static strides.
*/
num_records += pipeline->attrib_index_offset[i];
}
/* GFX10 uses OOB_SELECT_RAW if stride==0, so convert num_records from elements into
* into bytes in that case. GFX8 always uses bytes.

View File

@@ -5316,6 +5316,9 @@ radv_pipeline_init_vertex_input_state(struct radv_pipeline *pipeline,
uint32_t end = desc->offset + vk_format_get_blocksize(desc->format);
pipeline->attrib_ends[desc->location] = end;
if (pipeline->binding_stride[desc->binding])
pipeline->attrib_index_offset[desc->location] =
desc->offset / pipeline->binding_stride[desc->binding];
pipeline->attrib_bindings[desc->location] = desc->binding;
}

View File

@@ -1730,6 +1730,7 @@ struct radv_pipeline {
uint8_t attrib_bindings[MAX_VERTEX_ATTRIBS];
uint32_t attrib_ends[MAX_VERTEX_ATTRIBS];
uint32_t attrib_index_offset[MAX_VERTEX_ATTRIBS];
bool use_per_attribute_vb_descs;
uint32_t vb_desc_usage_mask;