mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Implement NULL vertex buffer views.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2482af566d
commit
9bbd520e89
@ -4186,17 +4186,19 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12Graphi
|
||||
UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views)
|
||||
{
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList1(iface);
|
||||
const struct vkd3d_null_resources *null_resources;
|
||||
struct vkd3d_gpu_va_allocator *gpu_va_allocator;
|
||||
VkDeviceSize offsets[ARRAY_SIZE(list->strides)];
|
||||
const struct vkd3d_vk_device_procs *vk_procs;
|
||||
VkBuffer buffers[ARRAY_SIZE(list->strides)];
|
||||
unsigned int i, first, count, stride;
|
||||
struct d3d12_resource *resource;
|
||||
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);
|
||||
|
||||
vk_procs = &list->device->vk_procs;
|
||||
null_resources = &list->device->null_resources;
|
||||
gpu_va_allocator = &list->device->gpu_va_allocator;
|
||||
|
||||
if (start_slot >= ARRAY_SIZE(list->strides) || view_count > ARRAY_SIZE(list->strides) - start_slot)
|
||||
@ -4205,25 +4207,19 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12Graphi
|
||||
return;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
first = start_slot;
|
||||
for (i = 0; i < view_count; ++i)
|
||||
{
|
||||
if (views[i].BufferLocation)
|
||||
{
|
||||
resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferLocation);
|
||||
buffers[count] = resource->u.vk_buffer;
|
||||
offsets[count] = views[i].BufferLocation - resource->gpu_address;
|
||||
buffers[i] = resource->u.vk_buffer;
|
||||
offsets[i] = views[i].BufferLocation - resource->gpu_address;
|
||||
stride = views[i].StrideInBytes;
|
||||
++count;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count)
|
||||
VK_CALL(vkCmdBindVertexBuffers(list->vk_command_buffer, first, count, buffers, offsets));
|
||||
count = 0;
|
||||
first = start_slot + i + 1;
|
||||
|
||||
buffers[i] = null_resources->vk_buffer;
|
||||
offsets[i] = 0;
|
||||
stride = 0;
|
||||
}
|
||||
|
||||
@ -4231,8 +4227,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12Graphi
|
||||
list->strides[start_slot + i] = stride;
|
||||
}
|
||||
|
||||
if (count)
|
||||
VK_CALL(vkCmdBindVertexBuffers(list->vk_command_buffer, first, count, buffers, offsets));
|
||||
if (view_count)
|
||||
VK_CALL(vkCmdBindVertexBuffers(list->vk_command_buffer, start_slot, view_count, buffers, offsets));
|
||||
|
||||
if (invalidate)
|
||||
d3d12_command_list_invalidate_current_pipeline(list);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "vkd3d_private.h"
|
||||
|
||||
#define VKD3D_NULL_CBV_BUFFER_SIZE 4
|
||||
#define VKD3D_NULL_BUFFER_SIZE 16
|
||||
#define VKD3D_NULL_VIEW_FORMAT DXGI_FORMAT_R8G8B8A8_UNORM
|
||||
|
||||
static unsigned int vkd3d_select_memory_type(struct d3d12_device *device, uint32_t memory_type_mask,
|
||||
@ -2005,9 +2005,9 @@ void d3d12_desc_create_cbv(struct d3d12_desc *descriptor,
|
||||
else
|
||||
{
|
||||
/* NULL descriptor */
|
||||
buffer_info->buffer = device->null_resources.vk_uniform_buffer;
|
||||
buffer_info->buffer = device->null_resources.vk_buffer;
|
||||
buffer_info->offset = 0;
|
||||
buffer_info->range = VKD3D_NULL_CBV_BUFFER_SIZE;
|
||||
buffer_info->range = VKD3D_NULL_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
descriptor->magic = VKD3D_DESCRIPTOR_MAGIC_CBV;
|
||||
@ -3235,7 +3235,7 @@ static HRESULT vkd3d_init_null_resources_data(struct vkd3d_null_resources *null_
|
||||
}
|
||||
|
||||
/* fill CBV buffer */
|
||||
VK_CALL(vkCmdFillBuffer(vk_command_buffer, null_resource->vk_uniform_buffer, 0, VK_WHOLE_SIZE, 0x00000000));
|
||||
VK_CALL(vkCmdFillBuffer(vk_command_buffer, null_resource->vk_buffer, 0, VK_WHOLE_SIZE, 0x00000000));
|
||||
|
||||
/* transition 2D SRV image */
|
||||
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
@ -3322,7 +3322,7 @@ HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources,
|
||||
/* CBV */
|
||||
resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
resource_desc.Alignment = 0;
|
||||
resource_desc.Width = VKD3D_NULL_CBV_BUFFER_SIZE;
|
||||
resource_desc.Width = VKD3D_NULL_BUFFER_SIZE;
|
||||
resource_desc.Height = 1;
|
||||
resource_desc.DepthOrArraySize = 1;
|
||||
resource_desc.MipLevels = 1;
|
||||
@ -3333,10 +3333,10 @@ HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources,
|
||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE;
|
||||
|
||||
if (FAILED(hr = vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
|
||||
&resource_desc, &null_resources->vk_uniform_buffer)))
|
||||
&resource_desc, &null_resources->vk_buffer)))
|
||||
goto fail;
|
||||
if (FAILED(hr = vkd3d_allocate_buffer_memory(device, null_resources->vk_uniform_buffer,
|
||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_uniform_buffer_memory)))
|
||||
if (FAILED(hr = vkd3d_allocate_buffer_memory(device, null_resources->vk_buffer,
|
||||
&heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_buffer_memory)))
|
||||
goto fail;
|
||||
|
||||
/* 2D SRV */
|
||||
@ -3360,10 +3360,10 @@ HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources,
|
||||
goto fail;
|
||||
|
||||
/* set Vulkan object names */
|
||||
vkd3d_set_vk_object_name_utf8(device, (uint64_t)null_resources->vk_uniform_buffer,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, "NULL CBV buffer");
|
||||
vkd3d_set_vk_object_name_utf8(device, (uint64_t)null_resources->vk_uniform_buffer_memory,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL CBV memory");
|
||||
vkd3d_set_vk_object_name_utf8(device, (uint64_t)null_resources->vk_buffer,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, "NULL buffer");
|
||||
vkd3d_set_vk_object_name_utf8(device, (uint64_t)null_resources->vk_buffer_memory,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL memory");
|
||||
vkd3d_set_vk_object_name_utf8(device, (uint64_t)null_resources->vk_2d_image,
|
||||
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "NULL 2D SRV image");
|
||||
vkd3d_set_vk_object_name_utf8(device, (uint64_t)null_resources->vk_2d_image_memory,
|
||||
@ -3382,8 +3382,8 @@ void vkd3d_destroy_null_resources(struct vkd3d_null_resources *null_resources,
|
||||
{
|
||||
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
|
||||
|
||||
VK_CALL(vkDestroyBuffer(device->vk_device, null_resources->vk_uniform_buffer, NULL));
|
||||
VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_uniform_buffer_memory, NULL));
|
||||
VK_CALL(vkDestroyBuffer(device->vk_device, null_resources->vk_buffer, NULL));
|
||||
VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_buffer_memory, NULL));
|
||||
|
||||
VK_CALL(vkDestroyImage(device->vk_device, null_resources->vk_2d_image, NULL));
|
||||
VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_2d_image_memory, NULL));
|
||||
|
@ -960,8 +960,8 @@ struct d3d12_command_signature *unsafe_impl_from_ID3D12CommandSignature(ID3D12Co
|
||||
/* NULL resources */
|
||||
struct vkd3d_null_resources
|
||||
{
|
||||
VkBuffer vk_uniform_buffer;
|
||||
VkDeviceMemory vk_uniform_buffer_memory;
|
||||
VkBuffer vk_buffer;
|
||||
VkDeviceMemory vk_buffer_memory;
|
||||
|
||||
VkImage vk_2d_image;
|
||||
VkDeviceMemory vk_2d_image_memory;
|
||||
|
Loading…
Reference in New Issue
Block a user