vkd3d: Check the IASetVertexBuffers() view count against the device limits.

For example, current MoltenVK only supports 31 vertex buffers.
This commit is contained in:
Conor McCarthy 2024-10-25 13:23:43 +10:00 committed by Henri Verbeet
parent fb8660c196
commit 76fd1388d8
Notes: Henri Verbeet 2024-11-06 23:01:00 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1228

View File

@ -4804,15 +4804,16 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12Graphi
VkDeviceSize offsets[ARRAY_SIZE(list->strides)]; VkDeviceSize offsets[ARRAY_SIZE(list->strides)];
const struct vkd3d_vk_device_procs *vk_procs; const struct vkd3d_vk_device_procs *vk_procs;
VkBuffer buffers[ARRAY_SIZE(list->strides)]; VkBuffer buffers[ARRAY_SIZE(list->strides)];
struct d3d12_device *device = list->device;
unsigned int i, stride, max_view_count;
struct d3d12_resource *resource; struct d3d12_resource *resource;
bool invalidate = false; bool invalidate = false;
unsigned int i, stride;
TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
vk_procs = &list->device->vk_procs; vk_procs = &device->vk_procs;
null_resources = &list->device->null_resources; null_resources = &device->null_resources;
gpu_va_allocator = &list->device->gpu_va_allocator; gpu_va_allocator = &device->gpu_va_allocator;
if (!vkd3d_bound_range(start_slot, view_count, ARRAY_SIZE(list->strides))) if (!vkd3d_bound_range(start_slot, view_count, ARRAY_SIZE(list->strides)))
{ {
@ -4820,6 +4821,27 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12Graphi
return; return;
} }
max_view_count = device->vk_info.device_limits.maxVertexInputBindings;
if (start_slot < max_view_count)
max_view_count -= start_slot;
else
max_view_count = 0;
/* Although simply skipping unsupported binding slots isn't especially
* likely to work well in the general case, applications sometimes
* explicitly set all 32 vertex buffer bindings slots supported by
* Direct3D 12, with unused slots set to NULL. "Spider-Man Remastered" is
* an example of such an application. */
if (view_count > max_view_count)
{
for (i = max_view_count; i < view_count; ++i)
{
if (views && views[i].BufferLocation)
WARN("Ignoring unsupported vertex buffer slot %u.\n", start_slot + i);
}
view_count = max_view_count;
}
for (i = 0; i < view_count; ++i) for (i = 0; i < view_count; ++i)
{ {
if (views && views[i].BufferLocation) if (views && views[i].BufferLocation)