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:
@@ -2904,12 +2904,18 @@ radv_flush_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer, bool pipeline_
|
|||||||
if (pipeline->use_per_attribute_vb_descs) {
|
if (pipeline->use_per_attribute_vb_descs) {
|
||||||
uint32_t attrib_end = pipeline->attrib_ends[i];
|
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 */
|
num_records = 0; /* not enough space for one vertex */
|
||||||
else if (stride == 0)
|
} else if (stride == 0) {
|
||||||
num_records = 1; /* only one vertex */
|
num_records = 1; /* only one vertex */
|
||||||
else
|
} else {
|
||||||
num_records = (num_records - attrib_end) / stride + 1;
|
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
|
/* GFX10 uses OOB_SELECT_RAW if stride==0, so convert num_records from elements into
|
||||||
* into bytes in that case. GFX8 always uses bytes.
|
* into bytes in that case. GFX8 always uses bytes.
|
||||||
|
@@ -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);
|
uint32_t end = desc->offset + vk_format_get_blocksize(desc->format);
|
||||||
pipeline->attrib_ends[desc->location] = end;
|
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;
|
pipeline->attrib_bindings[desc->location] = desc->binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1730,6 +1730,7 @@ struct radv_pipeline {
|
|||||||
|
|
||||||
uint8_t attrib_bindings[MAX_VERTEX_ATTRIBS];
|
uint8_t attrib_bindings[MAX_VERTEX_ATTRIBS];
|
||||||
uint32_t attrib_ends[MAX_VERTEX_ATTRIBS];
|
uint32_t attrib_ends[MAX_VERTEX_ATTRIBS];
|
||||||
|
uint32_t attrib_index_offset[MAX_VERTEX_ATTRIBS];
|
||||||
|
|
||||||
bool use_per_attribute_vb_descs;
|
bool use_per_attribute_vb_descs;
|
||||||
uint32_t vb_desc_usage_mask;
|
uint32_t vb_desc_usage_mask;
|
||||||
|
Reference in New Issue
Block a user