From c91fa697e9e81c709824ebd874a325c29935b904 Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Mon, 27 Feb 2023 15:43:49 +0000 Subject: [PATCH] pvr: Add handling for missing entries in pvr_setup_vertex_buffers() Signed-off-by: Karmjit Mahil Reviewed-by: Frank Binns Part-of: --- src/imagination/vulkan/pvr_cmd_buffer.c | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index 59c97c6..c82ec1a 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -3038,6 +3038,19 @@ pvr_setup_vertex_buffers(struct pvr_cmd_buffer *cmd_buffer, break; } + case PVR_PDS_CONST_MAP_ENTRY_TYPE_BASE_VERTEX: { + const struct pvr_const_map_entry_base_instance *const base_instance = + (struct pvr_const_map_entry_base_instance *)entries; + + PVR_WRITE(dword_buffer, + state->draw_state.base_vertex, + base_instance->const_offset, + pds_info->data_size_in_dwords); + + entries += sizeof(*base_instance); + break; + } + case PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTRIBUTE_ADDRESS: { const struct pvr_const_map_entry_vertex_attribute_address *const attribute = @@ -3096,6 +3109,49 @@ pvr_setup_vertex_buffers(struct pvr_cmd_buffer *cmd_buffer, break; } + case PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTRIBUTE_MAX_INDEX: { + const struct pvr_const_map_entry_vertex_attribute_max_index *attribute = + (struct pvr_const_map_entry_vertex_attribute_max_index *)entries; + const struct pvr_vertex_binding *const binding = + &state->vertex_bindings[attribute->binding_index]; + const uint64_t bound_size = binding->buffer->vk.size - binding->offset; + const uint32_t attribute_end = + attribute->offset + attribute->component_size_in_bytes; + uint32_t max_index; + + if (PVR_HAS_FEATURE(&cmd_buffer->device->pdevice->dev_info, + pds_ddmadt)) { + /* TODO: PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTRIBUTE_MAX_INDEX + * has the same define value as + * PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTR_DDMADT_OOB_BUFFER_SIZE + * so maybe we want to remove one of the defines or change the + * values. + */ + pvr_finishme("Unimplemented robust buffer access with DDMADT"); + assert(false); + } + + /* If the stride is 0 then all attributes use the same single element + * from the binding so the index can only be up to 0. + */ + if (bound_size < attribute_end || attribute->stride == 0) { + max_index = 0; + } else { + max_index = (uint32_t)(bound_size / attribute->stride) - 1; + + /* There's one last attribute that can fit in. */ + if (bound_size % attribute->stride >= attribute_end) + max_index++; + } + + PVR_WRITE(dword_buffer, + max_index, + attribute->const_offset, + pds_info->data_size_in_dwords); + + break; + } + default: unreachable("Unsupported data section map"); break; -- 2.7.4