wined3d: Provide a null counter BO for slots with no corresponding XFB buffer bound.

The Vulkan specification does not currently mandate this. However, an
(unfortunately internal) Khronos discussion determined that this is an
oversight, and that many drivers likely expect that no counter buffer will be
bound if no XFB buffer is bound. Accordingly the specification will probably
mandate this in the future.

lavapipe is such a driver. This fixes a crash with llvmpipe in
test_index_buffer_offset().
This commit is contained in:
Zebediah Figura 2023-11-08 18:10:31 -06:00 committed by Alexandre Julliard
parent ce59348c8f
commit fbd53c3a3f

View file

@ -2820,13 +2820,12 @@ static void wined3d_context_vk_bind_stream_output_buffers(struct wined3d_context
if (!wined3d_context_vk_create_bo(context_vk, ARRAY_SIZE(context_vk->vk_so_counters) * sizeof(uint32_t) * 2,
VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, bo))
ERR("Failed to create counter BO.\n");
for (i = 0; i < ARRAY_SIZE(context_vk->vk_so_counters); ++i)
{
context_vk->vk_so_counters[i] = bo->vk_buffer;
context_vk->vk_so_offsets[i] = bo->b.buffer_offset + i * sizeof(uint32_t) * 2;
}
}
memset(context_vk->vk_so_counters, 0, sizeof(context_vk->vk_so_counters));
first = 0;
count = 0;
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
@ -2835,6 +2834,8 @@ static void wined3d_context_vk_bind_stream_output_buffers(struct wined3d_context
if ((buffer = stream->buffer))
{
context_vk->vk_so_counters[i] = context_vk->vk_so_counter_bo.vk_buffer;
buffer_vk = wined3d_buffer_vk(buffer);
buffer_info = wined3d_buffer_vk_get_buffer_info(buffer_vk);
wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer->buffer_object));