ReactOS 0.4.17-dev-923-g4c9a150
resource.c
Go to the documentation of this file.
1/*
2 * Copyright 2016 Józef Kucia for CodeWeavers
3 * Copyright 2019 Conor McCarthy for CodeWeavers
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include "vkd3d_private.h"
21
22#define VKD3D_NULL_BUFFER_SIZE 16
23#define VKD3D_NULL_VIEW_FORMAT DXGI_FORMAT_R8G8B8A8_UNORM
24
26
27static inline bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *properties)
28{
29 if (properties->Type == D3D12_HEAP_TYPE_DEFAULT)
30 return false;
31 if (properties->Type == D3D12_HEAP_TYPE_CUSTOM)
32 {
35 }
36 return true;
37}
38
40 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, unsigned int *type_index)
41{
42 const VkPhysicalDeviceMemoryProperties *memory_info = &device->memory_properties;
44 unsigned int i, j, count = 0;
45
46 switch (heap_properties->Type)
47 {
50 break;
51
54 break;
55
60 break;
61
64 || (heap_properties->MemoryPoolPreference == D3D12_MEMORY_POOL_L1
65 && (is_cpu_accessible_heap(heap_properties) || d3d12_device_is_uma(device, NULL))))
66 {
67 WARN("Invalid memory pool preference.\n");
68 return E_INVALIDARG;
69 }
70
71 switch (heap_properties->CPUPageProperty)
72 {
76 /* Fall through. */
79 /* Fall through. */
82 break;
84 default:
85 WARN("Invalid CPU page property.\n");
86 return E_INVALIDARG;
87 }
88 break;
89
90 default:
91 WARN("Invalid heap type %#x.\n", heap_properties->Type);
92 return E_INVALIDARG;
93 }
94
95 for (j = 0; j < count; ++j)
96 {
97 VkMemoryPropertyFlags preferred_flags = flags[j];
98
99 for (i = 0; i < memory_info->memoryTypeCount; ++i)
100 {
101 if (!(memory_type_mask & (1u << i)))
102 continue;
103 if ((memory_info->memoryTypes[i].propertyFlags & preferred_flags) == preferred_flags)
104 {
105 *type_index = i;
106 return S_OK;
107 }
108 }
109 }
110
111 return E_FAIL;
112}
113
115 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
116 const VkMemoryRequirements *memory_requirements,
117 const VkMemoryDedicatedAllocateInfo *dedicated_allocate_info,
118 VkDeviceMemory *vk_memory, uint32_t *vk_memory_type)
119{
120 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
121 VkMemoryAllocateInfo allocate_info;
122 VkResult vr;
123 HRESULT hr;
124
125 TRACE("Memory requirements: size %#"PRIx64", alignment %#"PRIx64".\n",
126 memory_requirements->size, memory_requirements->alignment);
127
129 allocate_info.pNext = dedicated_allocate_info;
130 allocate_info.allocationSize = memory_requirements->size;
131 if (FAILED(hr = vkd3d_select_memory_type(device, memory_requirements->memoryTypeBits,
132 heap_properties, heap_flags, &allocate_info.memoryTypeIndex)))
133 {
134 if (hr != E_INVALIDARG)
135 FIXME("Failed to find suitable memory type (allowed types %#x).\n", memory_requirements->memoryTypeBits);
136 *vk_memory = VK_NULL_HANDLE;
137 return hr;
138 }
139
140 TRACE("Allocating memory type %u.\n", allocate_info.memoryTypeIndex);
141
142 if ((vr = VK_CALL(vkAllocateMemory(device->vk_device, &allocate_info, NULL, vk_memory))) < 0)
143 {
144 WARN("Failed to allocate device memory, vr %d.\n", vr);
145 *vk_memory = VK_NULL_HANDLE;
146 return hresult_from_vk_result(vr);
147 }
148
149 if (vk_memory_type)
150 *vk_memory_type = allocate_info.memoryTypeIndex;
151
152 return S_OK;
153}
154
156 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
157 VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
158{
159 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
160 VkMemoryDedicatedAllocateInfo *dedicated_allocation = NULL;
161 VkMemoryDedicatedRequirements dedicated_requirements;
162 VkMemoryDedicatedAllocateInfo dedicated_info;
163 VkMemoryRequirements2 memory_requirements2;
164 VkMemoryRequirements *memory_requirements;
166 VkResult vr;
167 HRESULT hr;
168
169 memory_requirements = &memory_requirements2.memoryRequirements;
170
171 if (device->vk_info.KHR_dedicated_allocation)
172 {
174 info.pNext = NULL;
175 info.buffer = vk_buffer;
176
178 dedicated_requirements.pNext = NULL;
179
180 memory_requirements2.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
181 memory_requirements2.pNext = &dedicated_requirements;
182
183 VK_CALL(vkGetBufferMemoryRequirements2KHR(device->vk_device, &info, &memory_requirements2));
184
185 if (dedicated_requirements.prefersDedicatedAllocation)
186 {
187 dedicated_allocation = &dedicated_info;
188
190 dedicated_info.pNext = NULL;
191 dedicated_info.image = VK_NULL_HANDLE;
192 dedicated_info.buffer = vk_buffer;
193 }
194 }
195 else
196 {
197 VK_CALL(vkGetBufferMemoryRequirements(device->vk_device, vk_buffer, memory_requirements));
198 }
199
200 if (FAILED(hr = vkd3d_allocate_device_memory(device, heap_properties, heap_flags,
201 memory_requirements, dedicated_allocation, vk_memory, vk_memory_type)))
202 return hr;
203
204 if ((vr = VK_CALL(vkBindBufferMemory(device->vk_device, vk_buffer, *vk_memory, 0))) < 0)
205 {
206 WARN("Failed to bind memory, vr %d.\n", vr);
207 VK_CALL(vkFreeMemory(device->vk_device, *vk_memory, NULL));
208 *vk_memory = VK_NULL_HANDLE;
209 }
210
211 if (vk_memory_size)
212 *vk_memory_size = memory_requirements->size;
213
214 return hresult_from_vk_result(vr);
215}
216
218 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
219 VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
220{
221 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
222 VkMemoryDedicatedAllocateInfo *dedicated_allocation = NULL;
223 VkMemoryDedicatedRequirements dedicated_requirements;
224 VkMemoryDedicatedAllocateInfo dedicated_info;
225 VkMemoryRequirements2 memory_requirements2;
226 VkMemoryRequirements *memory_requirements;
228 VkResult vr;
229 HRESULT hr;
230
231 memory_requirements = &memory_requirements2.memoryRequirements;
232
233 if (device->vk_info.KHR_dedicated_allocation)
234 {
236 info.pNext = NULL;
237 info.image = vk_image;
238
240 dedicated_requirements.pNext = NULL;
241
242 memory_requirements2.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
243 memory_requirements2.pNext = &dedicated_requirements;
244
245 VK_CALL(vkGetImageMemoryRequirements2KHR(device->vk_device, &info, &memory_requirements2));
246
247 if (dedicated_requirements.prefersDedicatedAllocation)
248 {
249 dedicated_allocation = &dedicated_info;
250
252 dedicated_info.pNext = NULL;
253 dedicated_info.image = vk_image;
254 dedicated_info.buffer = VK_NULL_HANDLE;
255 }
256 }
257 else
258 {
259 VK_CALL(vkGetImageMemoryRequirements(device->vk_device, vk_image, memory_requirements));
260 }
261
262 if (FAILED(hr = vkd3d_allocate_device_memory(device, heap_properties, heap_flags,
263 memory_requirements, dedicated_allocation, vk_memory, vk_memory_type)))
264 return hr;
265
266 if ((vr = VK_CALL(vkBindImageMemory(device->vk_device, vk_image, *vk_memory, 0))) < 0)
267 {
268 WARN("Failed to bind memory, vr %d.\n", vr);
269 VK_CALL(vkFreeMemory(device->vk_device, *vk_memory, NULL));
270 *vk_memory = VK_NULL_HANDLE;
271 return hresult_from_vk_result(vr);
272 }
273
274 if (vk_memory_size)
275 *vk_memory_size = memory_requirements->size;
276
277 return S_OK;
278}
279
280/* ID3D12Heap */
281static inline struct d3d12_heap *impl_from_ID3D12Heap(ID3D12Heap *iface)
282{
283 return CONTAINING_RECORD(iface, struct d3d12_heap, ID3D12Heap_iface);
284}
285
287 REFIID iid, void **object)
288{
289 TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
290
291 if (IsEqualGUID(iid, &IID_ID3D12Heap)
292 || IsEqualGUID(iid, &IID_ID3D12Pageable)
293 || IsEqualGUID(iid, &IID_ID3D12DeviceChild)
294 || IsEqualGUID(iid, &IID_ID3D12Object)
295 || IsEqualGUID(iid, &IID_IUnknown))
296 {
297 ID3D12Heap_AddRef(iface);
298 *object = iface;
299 return S_OK;
300 }
301
302 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
303
304 *object = NULL;
305 return E_NOINTERFACE;
306}
307
309{
310 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
311 unsigned int refcount = vkd3d_atomic_increment_u32(&heap->refcount);
312
313 TRACE("%p increasing refcount to %u.\n", heap, refcount);
314
315 VKD3D_ASSERT(!heap->is_private);
316
317 return refcount;
318}
319
321{
322 struct d3d12_device *device = heap->device;
323 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
324
325 TRACE("Destroying heap %p.\n", heap);
326
327 vkd3d_private_store_destroy(&heap->private_store);
328
329 if (heap->map_ptr)
330 VK_CALL(vkUnmapMemory(device->vk_device, heap->vk_memory));
331
332 VK_CALL(vkFreeMemory(device->vk_device, heap->vk_memory, NULL));
333
334 vkd3d_mutex_destroy(&heap->mutex);
335
336 if (heap->is_private)
337 device = NULL;
338
340
341 if (device)
343}
344
346{
347 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
348 unsigned int refcount = vkd3d_atomic_decrement_u32(&heap->refcount);
349
350 TRACE("%p decreasing refcount to %u.\n", heap, refcount);
351
352 /* A heap must not be destroyed until all contained resources are destroyed. */
353 if (!refcount && !heap->resource_count)
355
356 return refcount;
357}
358
360{
361 if (!vkd3d_atomic_decrement_u32(&heap->resource_count) && (!heap->refcount || heap->is_private))
363}
364
366 REFGUID guid, UINT *data_size, void *data)
367{
368 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
369
370 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
371
372 return vkd3d_get_private_data(&heap->private_store, guid, data_size, data);
373}
374
376 REFGUID guid, UINT data_size, const void *data)
377{
378 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
379
380 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
381
382 return vkd3d_set_private_data(&heap->private_store, guid, data_size, data);
383}
384
386 REFGUID guid, const IUnknown *data)
387{
388 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
389
390 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
391
392 return vkd3d_set_private_data_interface(&heap->private_store, guid, data);
393}
394
396{
397 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
398
399 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, heap->device->wchar_size));
400
401 return vkd3d_set_vk_object_name(heap->device, (uint64_t)heap->vk_memory,
403}
404
406{
407 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
408
409 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
410
411 return d3d12_device_query_interface(heap->device, iid, device);
412}
413
416{
417 struct d3d12_heap *heap = impl_from_ID3D12Heap(iface);
418
419 TRACE("iface %p, desc %p.\n", iface, desc);
420
421 *desc = heap->desc;
422 return desc;
423}
424
425static const struct ID3D12HeapVtbl d3d12_heap_vtbl =
426{
427 /* IUnknown methods */
431 /* ID3D12Object methods */
436 /* ID3D12DeviceChild methods */
438 /* ID3D12Heap methods */
440};
441
443{
444 if (!iface)
445 return NULL;
446 VKD3D_ASSERT(iface->lpVtbl == &d3d12_heap_vtbl);
447 return impl_from_ID3D12Heap(iface);
448}
449
451{
452 if (!resource && !desc->SizeInBytes)
453 {
454 WARN("Invalid size %"PRIu64".\n", desc->SizeInBytes);
455 return E_INVALIDARG;
456 }
457
460 {
461 WARN("Invalid alignment %"PRIu64".\n", desc->Alignment);
462 return E_INVALIDARG;
463 }
464
466 {
467 WARN("D3D12_HEAP_FLAG_ALLOW_DISPLAY is only for committed resources.\n");
468 return E_INVALIDARG;
469 }
470
471 return S_OK;
472}
473
475{
476 return heap->device->memory_properties.memoryTypes[heap->vk_memory_type].propertyFlags;
477}
478
480 struct d3d12_device *device, const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource)
481{
482 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
483 VkMemoryRequirements memory_requirements;
484 VkDeviceSize vk_memory_size;
485 VkResult vr;
486 HRESULT hr;
487
488 heap->ID3D12Heap_iface.lpVtbl = &d3d12_heap_vtbl;
489 heap->refcount = 1;
490 heap->resource_count = 0;
491
492 heap->is_private = !!resource;
493
494 heap->desc = *desc;
495
496 heap->map_ptr = NULL;
497 heap->map_count = 0;
498
499 if (!heap->desc.Properties.CreationNodeMask)
500 heap->desc.Properties.CreationNodeMask = 1;
501 if (!heap->desc.Properties.VisibleNodeMask)
502 heap->desc.Properties.VisibleNodeMask = 1;
503
504 debug_ignored_node_mask(heap->desc.Properties.CreationNodeMask);
505 debug_ignored_node_mask(heap->desc.Properties.VisibleNodeMask);
506
507 if (!heap->desc.Alignment)
509
510 if (FAILED(hr = validate_heap_desc(&heap->desc, resource)))
511 return hr;
512
513 vkd3d_mutex_init(&heap->mutex);
514
515 if (FAILED(hr = vkd3d_private_store_init(&heap->private_store)))
516 {
517 vkd3d_mutex_destroy(&heap->mutex);
518 return hr;
519 }
520
521 if (resource)
522 {
524 {
526 &heap->desc.Properties, heap->desc.Flags,
527 &heap->vk_memory, &heap->vk_memory_type, &vk_memory_size);
528 }
529 else
530 {
532 &heap->desc.Properties, heap->desc.Flags,
533 &heap->vk_memory, &heap->vk_memory_type, &vk_memory_size);
534 }
535
536 heap->desc.SizeInBytes = vk_memory_size;
537 }
538 else
539 {
540 memory_requirements.size = heap->desc.SizeInBytes;
541 memory_requirements.alignment = heap->desc.Alignment;
542 memory_requirements.memoryTypeBits = ~(uint32_t)0;
543
544 hr = vkd3d_allocate_device_memory(device, &heap->desc.Properties,
545 heap->desc.Flags, &memory_requirements, NULL,
546 &heap->vk_memory, &heap->vk_memory_type);
547 }
548 if (FAILED(hr))
549 {
550 vkd3d_private_store_destroy(&heap->private_store);
551 vkd3d_mutex_destroy(&heap->mutex);
552 return hr;
553 }
554
555 heap->device = device;
556 if (!heap->is_private)
557 d3d12_device_add_ref(heap->device);
558 else
559 heap->resource_count = 1;
560
562 {
563 if ((vr = VK_CALL(vkMapMemory(device->vk_device,
564 heap->vk_memory, 0, VK_WHOLE_SIZE, 0, &heap->map_ptr))) < 0)
565 {
566 heap->map_ptr = NULL;
567 ERR("Failed to map memory, vr %d.\n", vr);
570 }
571 }
572
573 return S_OK;
574}
575
577 const struct d3d12_resource *resource, ID3D12ProtectedResourceSession *protected_session,
578 struct d3d12_heap **heap)
579{
580 struct d3d12_heap *object;
581 HRESULT hr;
582
583 if (protected_session)
584 FIXME("Protected session is not supported.\n");
585
586 if (!(object = vkd3d_malloc(sizeof(*object))))
587 return E_OUTOFMEMORY;
588
589 if (FAILED(hr = d3d12_heap_init(object, device, desc, resource)))
590 {
591 vkd3d_free(object);
592 return hr;
593 }
594
595 TRACE("Created %s %p.\n", object->is_private ? "private heap" : "heap", object);
596
597 *heap = object;
598
599 return S_OK;
600}
601
603{
604 switch (dimension)
605 {
607 return VK_IMAGE_TYPE_1D;
609 return VK_IMAGE_TYPE_2D;
611 return VK_IMAGE_TYPE_3D;
612 default:
613 ERR("Invalid resource dimension %#x.\n", dimension);
614 return VK_IMAGE_TYPE_2D;
615 }
616}
617
619{
620 switch (sample_count)
621 {
622 case 1:
624 case 2:
626 case 4:
628 case 8:
630 case 16:
632 case 32:
634 case 64:
636 default:
637 return 0;
638 }
639}
640
642{
643 VkSampleCountFlagBits vk_samples;
644
645 if ((vk_samples = vk_samples_from_sample_count(desc->Count)))
646 return vk_samples;
647
648 FIXME("Unhandled sample count %u.\n", desc->Count);
650}
651
653 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
654 const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer)
655{
656 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
657 const bool sparse_resource = !heap_properties;
658 VkBufferCreateInfo buffer_info;
659 D3D12_HEAP_TYPE heap_type;
660 VkResult vr;
661
662 heap_type = heap_properties ? heap_properties->Type : D3D12_HEAP_TYPE_DEFAULT;
663
665 buffer_info.pNext = NULL;
666 buffer_info.flags = 0;
667 buffer_info.size = desc->Width;
668
669 if (sparse_resource)
670 {
672 if (device->vk_info.sparse_properties.residencyNonResidentStrict)
674 }
675
682
683 if (device->vk_info.EXT_conditional_rendering)
685
686 if (heap_type == D3D12_HEAP_TYPE_DEFAULT && device->vk_info.EXT_transform_feedback)
687 {
690 }
691
692 if (heap_type == D3D12_HEAP_TYPE_UPLOAD)
693 buffer_info.usage &= ~VK_BUFFER_USAGE_TRANSFER_DST_BIT;
694 else if (heap_type == D3D12_HEAP_TYPE_READBACK)
696
701
702 /* Buffers always have properties of D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS. */
704 {
705 WARN("D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS cannot be set for buffers.\n");
706 return E_INVALIDARG;
707 }
708
709 if (device->queue_family_count > 1)
710 {
712 buffer_info.queueFamilyIndexCount = device->queue_family_count;
713 buffer_info.pQueueFamilyIndices = device->queue_family_indices;
714 }
715 else
716 {
718 buffer_info.queueFamilyIndexCount = 0;
719 buffer_info.pQueueFamilyIndices = NULL;
720 }
721
723 FIXME("Unsupported resource flags %#x.\n", desc->Flags);
724
725 if ((vr = VK_CALL(vkCreateBuffer(device->vk_device, &buffer_info, NULL, vk_buffer))) < 0)
726 {
727 WARN("Failed to create Vulkan buffer, vr %d.\n", vr);
728 *vk_buffer = VK_NULL_HANDLE;
729 }
730
731 return hresult_from_vk_result(vr);
732}
733
735{
736 unsigned int size = max(desc->Width, desc->Height);
738 return vkd3d_log2i(size) + 1;
739}
740
743{
744 unsigned int i;
745
746 for (i = 0; i < device->format_compatibility_list_count; ++i)
747 {
748 if (device->format_compatibility_lists[i].typeless_format == dxgi_format)
749 return &device->format_compatibility_lists[i];
750 }
751
752 return NULL;
753}
754
756{
757 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
758 VkImageFormatProperties properties;
759 VkResult vr;
760
761 if ((vr = VK_CALL(vkGetPhysicalDeviceImageFormatProperties(device->vk_physical_device, image_info->format,
762 image_info->imageType, VK_IMAGE_TILING_LINEAR, image_info->usage, image_info->flags, &properties))) < 0)
763 {
765 WARN("Failed to get device image format properties, vr %d.\n", vr);
766
767 return false;
768 }
769
770 return image_info->extent.depth <= properties.maxExtent.depth
771 && image_info->mipLevels <= properties.maxMipLevels
772 && image_info->arrayLayers <= properties.maxArrayLayers
773 && (image_info->samples & properties.sampleCounts);
774}
775
777 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
778 const D3D12_RESOURCE_DESC1 *desc, struct d3d12_resource *resource, VkImage *vk_image)
779{
780 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
781 const struct vkd3d_format_compatibility_list *compat_list;
782 const bool sparse_resource = !heap_properties;
784 const struct vkd3d_format *format;
785 VkImageCreateInfo image_info;
787 VkResult vr;
788
789 if (resource)
790 {
791 format = resource->format;
792 }
794 {
795 WARN("Invalid DXGI format %#x.\n", desc->Format);
796 return E_INVALIDARG;
797 }
798
800 image_info.pNext = NULL;
801 image_info.flags = 0;
803 {
804 /* Format compatibility rules are more relaxed for UAVs. */
805 if (format->type != VKD3D_FORMAT_TYPE_UINT)
807 }
809 {
811
812 if ((compat_list = vkd3d_get_format_compatibility_list(device, desc->Format)))
813 {
815 format_list.pNext = NULL;
816 format_list.viewFormatCount = compat_list->format_count;
817 format_list.pViewFormats = compat_list->vk_formats;
818
819 image_info.pNext = &format_list;
820 }
821 }
823 && desc->Width == desc->Height && desc->DepthOrArraySize >= 6
824 && desc->SampleDesc.Count == 1)
828
829 if (sparse_resource)
830 {
832 if (device->vk_info.sparse_properties.residencyNonResidentStrict)
834 }
835
837 image_info.format = format->vk_format;
838 image_info.extent.width = desc->Width;
839 image_info.extent.height = desc->Height;
840
842 {
843 image_info.extent.depth = desc->DepthOrArraySize;
844 image_info.arrayLayers = 1;
845 }
846 else
847 {
848 image_info.extent.depth = 1;
849 image_info.arrayLayers = desc->DepthOrArraySize;
850 }
851
852 image_info.mipLevels = min(desc->MipLevels, max_miplevel_count(desc));
853 image_info.samples = vk_samples_from_dxgi_sample_desc(&desc->SampleDesc);
854
855 if (sparse_resource)
856 {
858 {
859 WARN("D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE must be used for reserved texture.\n");
860 return E_INVALIDARG;
861 }
862
863 image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
864 }
865 else if (desc->Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN)
866 {
867 image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
868 }
869 else if (desc->Layout == D3D12_TEXTURE_LAYOUT_ROW_MAJOR)
870 {
871 image_info.tiling = VK_IMAGE_TILING_LINEAR;
872 }
873 else
874 {
875 FIXME("Unsupported layout %#x.\n", desc->Layout);
876 return E_NOTIMPL;
877 }
878
885 image_info.usage |= VK_IMAGE_USAGE_STORAGE_BIT;
887 image_info.usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
888
889 if ((desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS) && device->queue_family_count > 1)
890 {
891 TRACE("Creating image with VK_SHARING_MODE_CONCURRENT.\n");
893 image_info.queueFamilyIndexCount = device->queue_family_count;
894 image_info.pQueueFamilyIndices = device->queue_family_indices;
895 }
896 else
897 {
899 image_info.queueFamilyIndexCount = 0;
900 image_info.pQueueFamilyIndices = NULL;
901 }
902
903 if (heap_properties && is_cpu_accessible_heap(heap_properties))
904 {
906
908 {
909 /* Required for ReadFromSubresource(). */
910 WARN("Forcing VK_IMAGE_TILING_LINEAR for CPU readable texture.\n");
911 image_info.tiling = VK_IMAGE_TILING_LINEAR;
912 }
913 }
914 else
915 {
917 }
918
919 if (resource && image_info.tiling == VK_IMAGE_TILING_LINEAR)
921
922 if (sparse_resource)
923 {
924 count = 0;
926 image_info.imageType, image_info.samples, image_info.usage, image_info.tiling, &count, NULL));
927
928 if (!count)
929 {
930 FIXME("Sparse images are not supported with format %u, type %u, samples %u, usage %#x.\n",
931 image_info.format, image_info.imageType, image_info.samples, image_info.usage);
932 return E_INVALIDARG;
933 }
934 }
935
936 if ((vr = VK_CALL(vkCreateImage(device->vk_device, &image_info, NULL, vk_image))) < 0)
937 WARN("Failed to create Vulkan image, vr %d.\n", vr);
938
939 return hresult_from_vk_result(vr);
940}
941
943 const D3D12_RESOURCE_DESC1 *desc, struct vkd3d_resource_allocation_info *allocation_info)
944{
945 static const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_DEFAULT};
946 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
947 D3D12_RESOURCE_DESC1 validated_desc;
948 VkMemoryRequirements requirements;
949 VkImage vk_image;
950 bool tiled;
951 HRESULT hr;
952
955
956 if (!desc->MipLevels)
957 {
958 validated_desc = *desc;
959 validated_desc.MipLevels = max_miplevel_count(desc);
960 desc = &validated_desc;
961 }
962
964
965 /* XXX: We have to create an image to get its memory requirements. */
966 if (SUCCEEDED(hr = vkd3d_create_image(device, tiled ? NULL : &heap_properties, 0, desc, NULL, &vk_image)))
967 {
968 VK_CALL(vkGetImageMemoryRequirements(device->vk_device, vk_image, &requirements));
969 VK_CALL(vkDestroyImage(device->vk_device, vk_image, NULL));
970
971 allocation_info->size_in_bytes = requirements.size;
972 allocation_info->alignment = requirements.alignment;
973 }
974
975 return hr;
976}
977
979{
980 vkd3d_free(resource->tiles.subresources);
981}
982
984{
985 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
986
988 return;
989
990 if (resource->gpu_address)
991 vkd3d_gpu_va_allocator_free(&device->gpu_va_allocator, resource->gpu_address);
992
994 VK_CALL(vkDestroyBuffer(device->vk_device, resource->u.vk_buffer, NULL));
995 else
996 VK_CALL(vkDestroyImage(device->vk_device, resource->u.vk_image, NULL));
997
999
1000 if (resource->heap)
1002}
1003
1005{
1006 unsigned int refcount = vkd3d_atomic_increment_u32(&resource->internal_refcount);
1007
1008 TRACE("%p increasing refcount to %u.\n", resource, refcount);
1009
1010 return refcount;
1011}
1012
1014{
1015 unsigned int refcount = vkd3d_atomic_decrement_u32(&resource->internal_refcount);
1016
1017 TRACE("%p decreasing refcount to %u.\n", resource, refcount);
1018
1019 if (!refcount)
1020 {
1021 vkd3d_private_store_destroy(&resource->private_store);
1024 }
1025
1026 return refcount;
1027}
1028
1030{
1031 return resource->heap && is_cpu_accessible_heap(&resource->heap->desc.Properties);
1032}
1033
1035 unsigned int sub_resource_idx, const D3D12_BOX *box)
1036{
1037 unsigned int mip_level = sub_resource_idx % resource->desc.MipLevels;
1038 const struct vkd3d_format *vkd3d_format;
1039 uint32_t width_mask, height_mask;
1041
1042 width = d3d12_resource_desc_get_width(&resource->desc, mip_level);
1043 height = d3d12_resource_desc_get_height(&resource->desc, mip_level);
1044 depth = d3d12_resource_desc_get_depth(&resource->desc, mip_level);
1045
1046 vkd3d_format = resource->format;
1048 width_mask = vkd3d_format->block_width - 1;
1049 height_mask = vkd3d_format->block_height - 1;
1050
1051 return box->left <= width && box->right <= width
1052 && box->top <= height && box->bottom <= height
1053 && box->front <= depth && box->back <= depth
1054 && !(box->left & width_mask)
1055 && !(box->right & width_mask)
1056 && !(box->top & height_mask)
1057 && !(box->bottom & height_mask);
1058}
1059
1061 unsigned int level, D3D12_BOX *box)
1062{
1063 box->left = 0;
1064 box->top = 0;
1065 box->front = 0;
1069}
1070
1072 const struct D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx,
1074{
1075 unsigned int width, height, depth;
1076
1077 width = d3d12_resource_desc_get_width(desc, miplevel_idx);
1079 depth = d3d12_resource_desc_get_depth(desc, miplevel_idx);
1080 size->width = (width + tile_extent->width - 1) / tile_extent->width;
1081 size->height = (height + tile_extent->height - 1) / tile_extent->height;
1082 size->depth = (depth + tile_extent->depth - 1) / tile_extent->depth;
1083}
1084
1086 UINT *total_tile_count, D3D12_PACKED_MIP_INFO *packed_mip_info, D3D12_TILE_SHAPE *standard_tile_shape,
1087 UINT *subresource_tiling_count, UINT first_subresource_tiling,
1088 D3D12_SUBRESOURCE_TILING *subresource_tilings)
1089{
1090 unsigned int i, subresource, subresource_count, miplevel_idx, count;
1091 const struct vkd3d_subresource_tile_info *tile_info;
1092 const VkExtent3D *tile_extent;
1093
1094 tile_extent = &resource->tiles.tile_extent;
1095
1096 if (packed_mip_info)
1097 {
1098 packed_mip_info->NumStandardMips = resource->tiles.standard_mip_count;
1099 packed_mip_info->NumPackedMips = resource->desc.MipLevels - packed_mip_info->NumStandardMips;
1100 packed_mip_info->NumTilesForPackedMips = !!resource->tiles.packed_mip_tile_count; /* non-zero dummy value */
1101 packed_mip_info->StartTileIndexInOverallResource = packed_mip_info->NumPackedMips
1102 ? resource->tiles.subresources[resource->tiles.standard_mip_count].offset : 0;
1103 }
1104
1105 if (standard_tile_shape)
1106 {
1107 /* D3D12 docs say tile shape is cleared to zero if there is no standard mip, but drivers don't to do this. */
1108 standard_tile_shape->WidthInTexels = tile_extent->width;
1109 standard_tile_shape->HeightInTexels = tile_extent->height;
1110 standard_tile_shape->DepthInTexels = tile_extent->depth;
1111 }
1112
1113 if (total_tile_count)
1114 *total_tile_count = resource->tiles.total_count;
1115
1116 if (!subresource_tiling_count)
1117 return;
1118
1119 subresource_count = resource->tiles.subresource_count;
1120
1121 count = subresource_count - min(first_subresource_tiling, subresource_count);
1122 count = min(count, *subresource_tiling_count);
1123
1124 for (i = 0; i < count; ++i)
1125 {
1126 subresource = i + first_subresource_tiling;
1127 miplevel_idx = subresource % resource->desc.MipLevels;
1128 if (miplevel_idx >= resource->tiles.standard_mip_count)
1129 {
1130 memset(&subresource_tilings[i], 0, sizeof(subresource_tilings[i]));
1132 continue;
1133 }
1134
1135 tile_info = &resource->tiles.subresources[subresource];
1136 subresource_tilings[i].StartTileIndexInOverallResource = tile_info->offset;
1137 subresource_tilings[i].WidthInTiles = tile_info->extent.width;
1138 subresource_tilings[i].HeightInTiles = tile_info->extent.height;
1139 subresource_tilings[i].DepthInTiles = tile_info->extent.depth;
1140 }
1141 *subresource_tiling_count = i;
1142}
1143
1145{
1146 unsigned int i, start_idx, subresource_count, tile_count, miplevel_idx;
1147 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1148 VkSparseImageMemoryRequirements *sparse_requirements_array;
1149 VkSparseImageMemoryRequirements sparse_requirements = {0};
1150 struct vkd3d_subresource_tile_info *tile_info;
1151 VkMemoryRequirements requirements;
1152 const VkExtent3D *tile_extent;
1153 uint32_t requirement_count;
1154
1155 subresource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
1156
1157 if (!(resource->tiles.subresources = vkd3d_calloc(subresource_count, sizeof(*resource->tiles.subresources))))
1158 {
1159 ERR("Failed to allocate subresource info array.\n");
1160 return false;
1161 }
1162
1164 {
1165 VKD3D_ASSERT(subresource_count == 1);
1166
1167 VK_CALL(vkGetBufferMemoryRequirements(device->vk_device, resource->u.vk_buffer, &requirements));
1168 if (requirements.alignment > D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES)
1169 FIXME("Vulkan device tile size is greater than the standard D3D12 tile size.\n");
1170
1171 tile_info = &resource->tiles.subresources[0];
1172 tile_info->offset = 0;
1173 tile_info->extent.width = align(resource->desc.Width, D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES)
1175 tile_info->extent.height = 1;
1176 tile_info->extent.depth = 1;
1177 tile_info->count = tile_info->extent.width;
1178
1179 resource->tiles.tile_extent.width = D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES;
1180 resource->tiles.tile_extent.height = 1;
1181 resource->tiles.tile_extent.depth = 1;
1182 resource->tiles.total_count = tile_info->extent.width;
1183 resource->tiles.subresource_count = 1;
1184 resource->tiles.standard_mip_count = 1;
1185 resource->tiles.packed_mip_tile_count = 0;
1186 }
1187 else
1188 {
1189 VK_CALL(vkGetImageMemoryRequirements(device->vk_device, resource->u.vk_image, &requirements));
1190 if (requirements.alignment > D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES)
1191 FIXME("Vulkan device tile size is greater than the standard D3D12 tile size.\n");
1192
1193 requirement_count = 0;
1194 VK_CALL(vkGetImageSparseMemoryRequirements(device->vk_device, resource->u.vk_image, &requirement_count, NULL));
1195 if (!(sparse_requirements_array = vkd3d_calloc(requirement_count, sizeof(*sparse_requirements_array))))
1196 {
1197 ERR("Failed to allocate sparse requirements array.\n");
1198 return false;
1199 }
1201 &requirement_count, sparse_requirements_array));
1202
1203 for (i = 0; i < requirement_count; ++i)
1204 {
1205 if (sparse_requirements_array[i].formatProperties.aspectMask & resource->format->vk_aspect_mask)
1206 {
1207 if (sparse_requirements.formatProperties.aspectMask)
1208 {
1209 WARN("Ignoring properties for aspect mask %#x.\n",
1210 sparse_requirements_array[i].formatProperties.aspectMask);
1211 }
1212 else
1213 {
1214 sparse_requirements = sparse_requirements_array[i];
1215 }
1216 }
1217 }
1218 vkd3d_free(sparse_requirements_array);
1219 if (!sparse_requirements.formatProperties.aspectMask)
1220 {
1221 WARN("Failed to get sparse requirements.\n");
1222 return false;
1223 }
1224
1225 resource->tiles.tile_extent = sparse_requirements.formatProperties.imageGranularity;
1226 resource->tiles.subresource_count = subresource_count;
1227 resource->tiles.standard_mip_count = sparse_requirements.imageMipTailSize
1228 ? sparse_requirements.imageMipTailFirstLod : resource->desc.MipLevels;
1229 resource->tiles.packed_mip_tile_count = (resource->tiles.standard_mip_count < resource->desc.MipLevels)
1230 ? sparse_requirements.imageMipTailSize / requirements.alignment : 0;
1231
1232 for (i = 0, start_idx = 0; i < subresource_count; ++i)
1233 {
1234 miplevel_idx = i % resource->desc.MipLevels;
1235
1236 tile_extent = &sparse_requirements.formatProperties.imageGranularity;
1237 tile_info = &resource->tiles.subresources[i];
1238 compute_image_subresource_size_in_tiles(tile_extent, &resource->desc, miplevel_idx, &tile_info->extent);
1239 tile_info->offset = start_idx;
1240 tile_info->count = 0;
1241
1242 if (miplevel_idx < resource->tiles.standard_mip_count)
1243 {
1244 tile_count = tile_info->extent.width * tile_info->extent.height * tile_info->extent.depth;
1245 start_idx += tile_count;
1246 tile_info->count = tile_count;
1247 }
1248 else if (miplevel_idx == resource->tiles.standard_mip_count)
1249 {
1250 tile_info->count = 1; /* Non-zero dummy value */
1251 start_idx += 1;
1252 }
1253 }
1254 resource->tiles.total_count = start_idx;
1255 }
1256
1257 return true;
1258}
1259
1260/* ID3D12Resource */
1262 REFIID riid, void **object)
1263{
1264 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
1265
1266 if (IsEqualGUID(riid, &IID_ID3D12Resource2)
1267 || IsEqualGUID(riid, &IID_ID3D12Resource1)
1268 || IsEqualGUID(riid, &IID_ID3D12Resource)
1269 || IsEqualGUID(riid, &IID_ID3D12Pageable)
1270 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
1271 || IsEqualGUID(riid, &IID_ID3D12Object)
1273 {
1274 ID3D12Resource2_AddRef(iface);
1275 *object = iface;
1276 return S_OK;
1277 }
1278
1279 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
1280
1281 *object = NULL;
1282 return E_NOINTERFACE;
1283}
1284
1286{
1288 unsigned int refcount = vkd3d_atomic_increment_u32(&resource->refcount);
1289
1290 TRACE("%p increasing refcount to %u.\n", resource, refcount);
1291
1292 if (refcount == 1)
1293 {
1294 struct d3d12_device *device = resource->device;
1295
1298 }
1299
1300 return refcount;
1301}
1302
1304{
1306 unsigned int refcount = vkd3d_atomic_decrement_u32(&resource->refcount);
1307
1308 TRACE("%p decreasing refcount to %u.\n", resource, refcount);
1309
1310 if (!refcount)
1311 {
1312 struct d3d12_device *device = resource->device;
1313
1315
1317 }
1318
1319 return refcount;
1320}
1321
1323 REFGUID guid, UINT *data_size, void *data)
1324{
1326
1327 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
1328
1329 return vkd3d_get_private_data(&resource->private_store, guid, data_size, data);
1330}
1331
1333 REFGUID guid, UINT data_size, const void *data)
1334{
1336
1337 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
1338
1339 return vkd3d_set_private_data(&resource->private_store, guid, data_size, data);
1340}
1341
1343 REFGUID guid, const IUnknown *data)
1344{
1346
1347 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
1348
1349 return vkd3d_set_private_data_interface(&resource->private_store, guid, data);
1350}
1351
1353{
1355 HRESULT hr;
1356
1357 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, resource->device->wchar_size));
1358
1360 {
1361 if (FAILED(hr = d3d12_heap_SetName(&resource->heap->ID3D12Heap_iface, name)))
1362 return hr;
1363 }
1364
1366 return vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->u.vk_buffer,
1368 else
1369 return vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->u.vk_image,
1371}
1372
1374{
1376
1377 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
1378
1379 return d3d12_device_query_interface(resource->device, iid, device);
1380}
1381
1383{
1384 VKD3D_ASSERT(resource->heap->map_ptr);
1385 return (uint8_t *)resource->heap->map_ptr + resource->heap_offset;
1386}
1387
1390{
1392 vk_range->pNext = NULL;
1393 vk_range->memory = resource->heap->vk_memory;
1394 vk_range->offset = resource->heap_offset + offset;
1395 vk_range->size = size;
1396}
1397
1399{
1400 const struct vkd3d_vk_device_procs *vk_procs = &resource->device->vk_procs;
1401 VkMappedMemoryRange vk_range;
1402 VkResult vr;
1403
1405 return;
1406
1408 if ((vr = VK_CALL(vkInvalidateMappedMemoryRanges(resource->device->vk_device, 1, &vk_range))) < 0)
1409 ERR("Failed to invalidate memory, vr %d.\n", vr);
1410}
1411
1413{
1414 const struct vkd3d_vk_device_procs *vk_procs = &resource->device->vk_procs;
1415 VkMappedMemoryRange vk_range;
1416 VkResult vr;
1417
1419 return;
1420
1422 if ((vr = VK_CALL(vkFlushMappedMemoryRanges(resource->device->vk_device, 1, &vk_range))) < 0)
1423 ERR("Failed to flush memory, vr %d.\n", vr);
1424}
1425
1427 const D3D12_RANGE *read_range, void **data)
1428{
1430 unsigned int sub_resource_count;
1431
1432 TRACE("iface %p, sub_resource %u, read_range %p, data %p.\n",
1433 iface, sub_resource, read_range, data);
1434
1436 {
1437 WARN("Resource is not CPU accessible.\n");
1438 return E_INVALIDARG;
1439 }
1440
1441 sub_resource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
1442 if (sub_resource >= sub_resource_count)
1443 {
1444 WARN("Sub-resource index %u is out of range (%u sub-resources).\n", sub_resource, sub_resource_count);
1445 return E_INVALIDARG;
1446 }
1447
1449 {
1450 /* Textures seem to be mappable only on UMA adapters. */
1451 FIXME("Not implemented for textures.\n");
1452 return E_INVALIDARG;
1453 }
1454
1455 if (!resource->heap)
1456 {
1457 FIXME("Not implemented for this resource type.\n");
1458 return E_NOTIMPL;
1459 }
1460
1461 if (data)
1462 {
1464 TRACE("Returning pointer %p.\n", *data);
1465 }
1466
1467 if (!read_range)
1469 else if (read_range->End > read_range->Begin)
1470 d3d12_resource_invalidate(resource, read_range->Begin, read_range->End - read_range->Begin);
1471
1472 return S_OK;
1473}
1474
1476 const D3D12_RANGE *written_range)
1477{
1479 unsigned int sub_resource_count;
1480
1481 TRACE("iface %p, sub_resource %u, written_range %p.\n",
1482 iface, sub_resource, written_range);
1483
1484 sub_resource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
1485 if (sub_resource >= sub_resource_count)
1486 {
1487 WARN("Sub-resource index %u is out of range (%u sub-resources).\n", sub_resource, sub_resource_count);
1488 return;
1489 }
1490
1491 if (!written_range)
1492 d3d12_resource_flush(resource, 0, resource->desc.Width);
1493 else if (written_range->End > written_range->Begin)
1494 d3d12_resource_flush(resource, written_range->Begin, written_range->End - written_range->Begin);
1495}
1496
1498 D3D12_RESOURCE_DESC *resource_desc)
1499{
1501
1502 TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
1503
1504 memcpy(resource_desc, &resource->desc, sizeof(*resource_desc));
1505 return resource_desc;
1506}
1507
1509{
1511
1512 TRACE("iface %p.\n", iface);
1513
1514 return resource->gpu_address;
1515}
1516
1518 UINT dst_sub_resource, const D3D12_BOX *dst_box, const void *src_data,
1519 UINT src_row_pitch, UINT src_slice_pitch)
1520{
1522 const struct vkd3d_vk_device_procs *vk_procs;
1523 VkImageSubresource vk_sub_resource;
1524 const struct vkd3d_format *format;
1525 VkSubresourceLayout vk_layout;
1526 uint64_t dst_offset, dst_size;
1527 struct d3d12_device *device;
1528 uint8_t *dst_data;
1529 D3D12_BOX box;
1530
1531 TRACE("iface %p, src_data %p, src_row_pitch %u, src_slice_pitch %u, "
1532 "dst_sub_resource %u, dst_box %s.\n",
1533 iface, src_data, src_row_pitch, src_slice_pitch, dst_sub_resource, debug_d3d12_box(dst_box));
1534
1536 {
1537 WARN("Buffers are not supported.\n");
1538 return E_INVALIDARG;
1539 }
1540
1541 device = resource->device;
1542 vk_procs = &device->vk_procs;
1543
1544 format = resource->format;
1545 if (format->vk_aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT)
1546 {
1547 FIXME("Not supported for format %#x.\n", format->dxgi_format);
1548 return E_NOTIMPL;
1549 }
1550
1551 vk_sub_resource.arrayLayer = dst_sub_resource / resource->desc.MipLevels;
1552 vk_sub_resource.mipLevel = dst_sub_resource % resource->desc.MipLevels;
1553 vk_sub_resource.aspectMask = format->vk_aspect_mask;
1554
1555 if (!dst_box)
1556 {
1558 dst_box = &box;
1559 }
1560 else if (!d3d12_resource_validate_box(resource, dst_sub_resource, dst_box))
1561 {
1562 WARN("Invalid box %s.\n", debug_d3d12_box(dst_box));
1563 return E_INVALIDARG;
1564 }
1565
1566 if (d3d12_box_is_empty(dst_box))
1567 {
1568 WARN("Empty box %s.\n", debug_d3d12_box(dst_box));
1569 return S_OK;
1570 }
1571
1573 {
1574 FIXME_ONCE("Not implemented for this resource type.\n");
1575 return E_NOTIMPL;
1576 }
1577 if (!(resource->flags & VKD3D_RESOURCE_LINEAR_TILING))
1578 {
1579 FIXME_ONCE("Not implemented for image tiling other than VK_IMAGE_TILING_LINEAR.\n");
1580 return E_NOTIMPL;
1581 }
1582
1583 VK_CALL(vkGetImageSubresourceLayout(device->vk_device, resource->u.vk_image, &vk_sub_resource, &vk_layout));
1584 TRACE("Offset %#"PRIx64", size %#"PRIx64", row pitch %#"PRIx64", depth pitch %#"PRIx64".\n",
1585 vk_layout.offset, vk_layout.size, vk_layout.rowPitch, vk_layout.depthPitch);
1586
1588 dst_offset = vk_layout.offset + vkd3d_format_get_data_offset(format, vk_layout.rowPitch,
1589 vk_layout.depthPitch, dst_box->left, dst_box->top, dst_box->front);
1590 dst_size = vk_layout.offset + vkd3d_format_get_data_offset(format, vk_layout.rowPitch,
1591 vk_layout.depthPitch, dst_box->right, dst_box->bottom - 1, dst_box->back - 1) - dst_offset;
1592
1593 vkd3d_format_copy_data(format, src_data, src_row_pitch, src_slice_pitch,
1594 dst_data + dst_offset, vk_layout.rowPitch, vk_layout.depthPitch, dst_box->right - dst_box->left,
1595 dst_box->bottom - dst_box->top, dst_box->back - dst_box->front);
1596
1597 d3d12_resource_flush(resource, dst_offset, dst_size);
1598
1599 return S_OK;
1600}
1601
1603 void *dst_data, UINT dst_row_pitch, UINT dst_slice_pitch,
1604 UINT src_sub_resource, const D3D12_BOX *src_box)
1605{
1607 const struct vkd3d_vk_device_procs *vk_procs;
1608 VkImageSubresource vk_sub_resource;
1609 const struct vkd3d_format *format;
1610 VkSubresourceLayout vk_layout;
1611 uint64_t src_offset, src_size;
1612 struct d3d12_device *device;
1613 uint8_t *src_data;
1614 D3D12_BOX box;
1615
1616 TRACE("iface %p, dst_data %p, dst_row_pitch %u, dst_slice_pitch %u, "
1617 "src_sub_resource %u, src_box %s.\n",
1618 iface, dst_data, dst_row_pitch, dst_slice_pitch, src_sub_resource, debug_d3d12_box(src_box));
1619
1621 {
1622 WARN("Buffers are not supported.\n");
1623 return E_INVALIDARG;
1624 }
1625
1626 device = resource->device;
1627 vk_procs = &device->vk_procs;
1628
1629 format = resource->format;
1630 if (format->vk_aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT)
1631 {
1632 FIXME("Not supported for format %#x.\n", format->dxgi_format);
1633 return E_NOTIMPL;
1634 }
1635
1636 vk_sub_resource.arrayLayer = src_sub_resource / resource->desc.MipLevels;
1637 vk_sub_resource.mipLevel = src_sub_resource % resource->desc.MipLevels;
1638 vk_sub_resource.aspectMask = format->vk_aspect_mask;
1639
1640 if (!src_box)
1641 {
1643 src_box = &box;
1644 }
1645 else if (!d3d12_resource_validate_box(resource, src_sub_resource, src_box))
1646 {
1647 WARN("Invalid box %s.\n", debug_d3d12_box(src_box));
1648 return E_INVALIDARG;
1649 }
1650
1651 if (d3d12_box_is_empty(src_box))
1652 {
1653 WARN("Empty box %s.\n", debug_d3d12_box(src_box));
1654 return S_OK;
1655 }
1656
1658 {
1659 FIXME_ONCE("Not implemented for this resource type.\n");
1660 return E_NOTIMPL;
1661 }
1662 if (!(resource->flags & VKD3D_RESOURCE_LINEAR_TILING))
1663 {
1664 FIXME_ONCE("Not implemented for image tiling other than VK_IMAGE_TILING_LINEAR.\n");
1665 return E_NOTIMPL;
1666 }
1667
1668 VK_CALL(vkGetImageSubresourceLayout(device->vk_device, resource->u.vk_image, &vk_sub_resource, &vk_layout));
1669 TRACE("Offset %#"PRIx64", size %#"PRIx64", row pitch %#"PRIx64", depth pitch %#"PRIx64".\n",
1670 vk_layout.offset, vk_layout.size, vk_layout.rowPitch, vk_layout.depthPitch);
1671
1673 src_offset = vk_layout.offset + vkd3d_format_get_data_offset(format, vk_layout.rowPitch,
1674 vk_layout.depthPitch, src_box->left, src_box->top, src_box->front);
1675 src_size = vk_layout.offset + vkd3d_format_get_data_offset(format, vk_layout.rowPitch,
1676 vk_layout.depthPitch, src_box->right, src_box->bottom - 1, src_box->back - 1) - src_offset;
1677
1678 d3d12_resource_invalidate(resource, src_offset, src_size);
1679
1680 vkd3d_format_copy_data(format, src_data + src_offset, vk_layout.rowPitch, vk_layout.depthPitch,
1681 dst_data, dst_row_pitch, dst_slice_pitch, src_box->right - src_box->left,
1682 src_box->bottom - src_box->top, src_box->back - src_box->front);
1683
1684 return S_OK;
1685}
1686
1688 D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags)
1689{
1691 struct d3d12_heap *heap;
1692
1693 TRACE("iface %p, heap_properties %p, flags %p.\n",
1694 iface, heap_properties, flags);
1695
1696 if (resource->flags & VKD3D_RESOURCE_EXTERNAL)
1697 {
1698 if (heap_properties)
1699 {
1700 memset(heap_properties, 0, sizeof(*heap_properties));
1701 heap_properties->Type = D3D12_HEAP_TYPE_DEFAULT;
1702 heap_properties->CreationNodeMask = 1;
1703 heap_properties->VisibleNodeMask = 1;
1704 }
1705 if (flags)
1707 return S_OK;
1708 }
1709
1710 if (!(heap = resource->heap))
1711 {
1712 WARN("Cannot get heap properties for reserved resources.\n");
1713 return E_INVALIDARG;
1714 }
1715
1716 if (heap_properties)
1717 *heap_properties = heap->desc.Properties;
1718 if (flags)
1719 *flags = heap->desc.Flags;
1720
1721 return S_OK;
1722}
1723
1725 REFIID iid, void **session)
1726{
1727 FIXME("iface %p, iid %s, session %p stub!\n", iface, debugstr_guid(iid), session);
1728
1729 return DXGI_ERROR_NOT_FOUND;
1730}
1731
1733 D3D12_RESOURCE_DESC1 *resource_desc)
1734{
1736
1737 TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
1738
1739 *resource_desc = resource->desc;
1740 return resource_desc;
1741}
1742
1743static const struct ID3D12Resource2Vtbl d3d12_resource_vtbl =
1744{
1745 /* IUnknown methods */
1749 /* ID3D12Object methods */
1754 /* ID3D12DeviceChild methods */
1756 /* ID3D12Resource methods */
1764 /* ID3D12Resource1 methods */
1766 /* ID3D12Resource2 methods */
1768};
1769
1771{
1772 if (!iface)
1773 return NULL;
1774 VKD3D_ASSERT(iface->lpVtbl == (ID3D12ResourceVtbl *)&d3d12_resource_vtbl);
1775 return impl_from_ID3D12Resource(iface);
1776}
1777
1779{
1780 unsigned int unknown_flags = flags & ~(D3D12_RESOURCE_FLAG_NONE
1787
1788 if (unknown_flags)
1789 FIXME("Unknown resource flags %#x.\n", unknown_flags);
1791 FIXME("Ignoring D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER.\n");
1792}
1793
1795 const struct vkd3d_format *format)
1796{
1797 if (desc->Format == DXGI_FORMAT_UNKNOWN)
1798 {
1799 WARN("DXGI_FORMAT_UNKNOWN is invalid for textures.\n");
1800 return false;
1801 }
1802
1804 return true;
1805
1806 if (desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE1D && format->block_height > 1)
1807 {
1808 WARN("1D texture with a format block height > 1.\n");
1809 return false;
1810 }
1811
1812 return true;
1813}
1814
1816 const struct vkd3d_format *format)
1817{
1818 uint64_t estimated_size;
1819
1820 if (!desc->Alignment)
1821 return true;
1822
1825 && (desc->SampleDesc.Count == 1 || desc->Alignment != D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT))
1826 {
1827 WARN("Invalid resource alignment %#"PRIx64".\n", desc->Alignment);
1828 return false;
1829 }
1830
1832 {
1833 /* Windows uses the slice size to determine small alignment eligibility. DepthOrArraySize is ignored. */
1834 estimated_size = desc->Width * desc->Height * format->byte_count * format->block_byte_count
1835 / (format->block_width * format->block_height);
1836 if (estimated_size > D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
1837 {
1838 WARN("Invalid resource alignment %#"PRIx64" (required %#x).\n",
1840 return false;
1841 }
1842 }
1843
1844 /* The size check for MSAA textures with D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT is probably
1845 * not important. The 4MB requirement is no longer universal and Vulkan has no such requirement. */
1846
1847 return true;
1848}
1849
1851{
1852 const D3D12_MIP_REGION *mip_region = &desc->SamplerFeedbackMipRegion;
1853 const struct vkd3d_format *format;
1854
1855 switch (desc->Dimension)
1856 {
1858 if (desc->MipLevels != 1)
1859 {
1860 WARN("Invalid miplevel count %u for buffer.\n", desc->MipLevels);
1861 return E_INVALIDARG;
1862 }
1863
1864 if (desc->Format != DXGI_FORMAT_UNKNOWN || desc->Layout != D3D12_TEXTURE_LAYOUT_ROW_MAJOR
1865 || desc->Height != 1 || desc->DepthOrArraySize != 1
1866 || desc->SampleDesc.Count != 1 || desc->SampleDesc.Quality != 0
1867 || (desc->Alignment != 0 && desc->Alignment != D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT))
1868 {
1869 WARN("Invalid parameters for a buffer resource.\n");
1870 return E_INVALIDARG;
1871 }
1872 break;
1873
1875 if (desc->Height != 1)
1876 {
1877 WARN("1D texture with a height of %u.\n", desc->Height);
1878 return E_INVALIDARG;
1879 }
1880 /* Fall through. */
1883 if (!desc->SampleDesc.Count)
1884 {
1885 WARN("Invalid sample count 0.\n");
1886 return E_INVALIDARG;
1887 }
1888 if (desc->SampleDesc.Count > 1
1890 {
1891 WARN("Sample count %u invalid without ALLOW_RENDER_TARGET or ALLOW_DEPTH_STENCIL.\n",
1892 desc->SampleDesc.Count);
1893 return E_INVALIDARG;
1894 }
1895
1897 {
1898 WARN("Invalid format %#x.\n", desc->Format);
1899 return E_INVALIDARG;
1900 }
1901
1903 {
1904 if (desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D && !device->vk_info.sparse_residency_3d)
1905 {
1906 WARN("The device does not support tiled 3D images.\n");
1907 return E_INVALIDARG;
1908 }
1909 if (format->plane_count > 1)
1910 {
1911 WARN("Invalid format %#x. D3D12 does not support multiplanar formats for tiled resources.\n",
1912 format->dxgi_format);
1913 return E_INVALIDARG;
1914 }
1915 }
1916
1919 return E_INVALIDARG;
1920 break;
1921
1922 default:
1923 WARN("Invalid resource dimension %#x.\n", desc->Dimension);
1924 return E_INVALIDARG;
1925 }
1926
1928
1929 if (mip_region->Width && mip_region->Height && mip_region->Depth)
1930 {
1931 FIXME("Unhandled sampler feedback mip region size (%u, %u, %u).\n", mip_region->Width, mip_region->Height,
1932 mip_region->Depth);
1933 }
1934
1935 return S_OK;
1936}
1937
1939 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_RESOURCE_STATES initial_state)
1940{
1941 if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD
1942 || heap_properties->Type == D3D12_HEAP_TYPE_READBACK)
1943 {
1945 {
1946 WARN("Textures cannot be created on upload/readback heaps.\n");
1947 return false;
1948 }
1949
1951 {
1952 WARN("Render target and unordered access buffers cannot be created on upload/readback heaps.\n");
1953 return false;
1954 }
1955 }
1956
1957 if (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD && initial_state != D3D12_RESOURCE_STATE_GENERIC_READ)
1958 {
1959 WARN("For D3D12_HEAP_TYPE_UPLOAD the state must be D3D12_RESOURCE_STATE_GENERIC_READ.\n");
1960 return false;
1961 }
1962 if (heap_properties->Type == D3D12_HEAP_TYPE_READBACK && initial_state != D3D12_RESOURCE_STATE_COPY_DEST)
1963 {
1964 WARN("For D3D12_HEAP_TYPE_READBACK the state must be D3D12_RESOURCE_STATE_COPY_DEST.\n");
1965 return false;
1966 }
1967
1968 return true;
1969}
1970
1972 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
1973 const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state,
1974 const D3D12_CLEAR_VALUE *optimized_clear_value)
1975{
1976 HRESULT hr;
1977
1978 resource->ID3D12Resource2_iface.lpVtbl = &d3d12_resource_vtbl;
1979 resource->refcount = 1;
1980 resource->internal_refcount = 1;
1981
1982 resource->desc = *desc;
1983
1984 if (!heap_properties && !device->vk_info.sparse_binding)
1985 {
1986 WARN("The device does not support tiled images.\n");
1987 return E_INVALIDARG;
1988 }
1989
1990 if (heap_properties && !d3d12_resource_validate_heap_properties(resource, heap_properties, initial_state))
1991 return E_INVALIDARG;
1992
1993 if (!is_valid_resource_state(initial_state))
1994 {
1995 WARN("Invalid initial resource state %#x.\n", initial_state);
1996 return E_INVALIDARG;
1997 }
1999 {
2000 WARN("Invalid initial resource state %#x for non-render-target.\n", initial_state);
2001 return E_INVALIDARG;
2002 }
2003
2004 if (optimized_clear_value && d3d12_resource_is_buffer(resource))
2005 {
2006 WARN("Optimized clear value must be NULL for buffers.\n");
2007 return E_INVALIDARG;
2008 }
2009
2010 if (optimized_clear_value)
2011 WARN("Ignoring optimized clear value.\n");
2012
2013 resource->gpu_address = 0;
2014 resource->flags = 0;
2015
2017 return hr;
2018
2020
2021 switch (desc->Dimension)
2022 {
2024 if (FAILED(hr = vkd3d_create_buffer(device, heap_properties, heap_flags,
2025 &resource->desc, &resource->u.vk_buffer)))
2026 return hr;
2027 if (!(resource->gpu_address = vkd3d_gpu_va_allocator_allocate(&device->gpu_va_allocator,
2028 desc->Alignment ? desc->Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
2029 desc->Width, resource)))
2030 {
2031 ERR("Failed to allocate GPU VA.\n");
2033 return E_OUTOFMEMORY;
2034 }
2035 break;
2036
2040 if (!resource->desc.MipLevels)
2041 resource->desc.MipLevels = max_miplevel_count(desc);
2043 if (FAILED(hr = vkd3d_create_image(device, heap_properties, heap_flags,
2044 &resource->desc, resource, &resource->u.vk_image)))
2045 return hr;
2046 break;
2047
2048 default:
2049 WARN("Invalid resource dimension %#x.\n", resource->desc.Dimension);
2050 return E_INVALIDARG;
2051 }
2052
2053 resource->map_count = 0;
2054
2055 resource->initial_state = initial_state;
2056
2057 resource->heap = NULL;
2058 resource->heap_offset = 0;
2059
2060 memset(&resource->tiles, 0, sizeof(resource->tiles));
2061
2062 if (FAILED(hr = vkd3d_private_store_init(&resource->private_store)))
2063 {
2065 return hr;
2066 }
2067
2069
2070 return S_OK;
2071}
2072
2074 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
2075 const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state,
2076 const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
2077{
2078 struct d3d12_resource *object;
2079 HRESULT hr;
2080
2081 if (!(object = vkd3d_malloc(sizeof(*object))))
2082 return E_OUTOFMEMORY;
2083
2084 if (FAILED(hr = d3d12_resource_init(object, device, heap_properties, heap_flags,
2085 desc, initial_state, optimized_clear_value)))
2086 {
2087 vkd3d_free(object);
2088 return hr;
2089 }
2090
2091 *resource = object;
2092
2093 return hr;
2094}
2095
2097 struct d3d12_device *device, struct d3d12_resource *resource,
2098 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
2099{
2100 D3D12_HEAP_DESC heap_desc;
2101 HRESULT hr;
2102
2103 heap_desc.SizeInBytes = 0;
2104 heap_desc.Properties = *heap_properties;
2105 heap_desc.Alignment = 0;
2106 heap_desc.Flags = heap_flags;
2107 if (SUCCEEDED(hr = d3d12_heap_create(device, &heap_desc, resource, NULL, &resource->heap)))
2109 return hr;
2110}
2111
2113 const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
2115 const D3D12_CLEAR_VALUE *optimized_clear_value, ID3D12ProtectedResourceSession *protected_session,
2116 struct d3d12_resource **resource)
2117{
2118 struct d3d12_resource *object;
2119 HRESULT hr;
2120
2121 if (!heap_properties)
2122 {
2123 WARN("Heap properties are NULL.\n");
2124 return E_INVALIDARG;
2125 }
2126
2127 if (protected_session)
2128 FIXME("Protected session is not supported.\n");
2129
2130 if (FAILED(hr = d3d12_resource_create(device, heap_properties, heap_flags,
2131 desc, initial_state, optimized_clear_value, &object)))
2132 return hr;
2133
2134 if (FAILED(hr = vkd3d_allocate_resource_memory(device, object, heap_properties, heap_flags)))
2135 {
2136 d3d12_resource_Release(&object->ID3D12Resource2_iface);
2137 return hr;
2138 }
2139
2140 TRACE("Created committed resource %p.\n", object);
2141
2142 *resource = object;
2143
2144 return S_OK;
2145}
2146
2149{
2150 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2151 VkDevice vk_device = device->vk_device;
2152 VkMemoryRequirements requirements;
2153 VkResult vr;
2154
2156 {
2157 VK_CALL(vkGetBufferMemoryRequirements(vk_device, resource->u.vk_buffer, &requirements));
2158 }
2159 else
2160 {
2161 VK_CALL(vkGetImageMemoryRequirements(vk_device, resource->u.vk_image, &requirements));
2162 /* Padding in d3d12_device_GetResourceAllocationInfo() leaves room to align the offset. */
2163 heap_offset = align(heap_offset, requirements.alignment);
2164 }
2165
2166 if (heap_offset > heap->desc.SizeInBytes || requirements.size > heap->desc.SizeInBytes - heap_offset)
2167 {
2168 WARN("Heap too small for the resource (offset %"PRIu64", resource size %"PRIu64", heap size %"PRIu64".\n",
2169 heap_offset, requirements.size, heap->desc.SizeInBytes);
2170 return E_INVALIDARG;
2171 }
2172
2173 if (heap_offset % requirements.alignment)
2174 {
2175 FIXME("Invalid heap offset %#"PRIx64" (alignment %#"PRIx64").\n",
2176 heap_offset, requirements.alignment);
2177 goto allocate_memory;
2178 }
2179
2180 if (!(requirements.memoryTypeBits & (1u << heap->vk_memory_type)))
2181 {
2182 FIXME("Memory type %u cannot be bound to resource %p (allowed types %#x).\n",
2183 heap->vk_memory_type, resource, requirements.memoryTypeBits);
2184 goto allocate_memory;
2185 }
2186
2187 /* Synchronisation is not required for binding, but vkMapMemory() may be called
2188 * from another thread and it requires exclusive access. */
2189 vkd3d_mutex_lock(&heap->mutex);
2190
2192 vr = VK_CALL(vkBindBufferMemory(vk_device, resource->u.vk_buffer, heap->vk_memory, heap_offset));
2193 else
2194 vr = VK_CALL(vkBindImageMemory(vk_device, resource->u.vk_image, heap->vk_memory, heap_offset));
2195
2196 vkd3d_mutex_unlock(&heap->mutex);
2197
2198 if (vr == VK_SUCCESS)
2199 {
2200 resource->heap = heap;
2201 resource->heap_offset = heap_offset;
2202 vkd3d_atomic_increment_u32(&heap->resource_count);
2203 }
2204 else
2205 {
2206 WARN("Failed to bind memory, vr %d.\n", vr);
2207 }
2208
2209 return hresult_from_vk_result(vr);
2210
2211allocate_memory:
2212 FIXME("Allocating device memory.\n");
2213 return vkd3d_allocate_resource_memory(device, resource, &heap->desc.Properties, heap->desc.Flags);
2214}
2215
2217 const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state,
2218 const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
2219{
2220 struct d3d12_resource *object;
2221 HRESULT hr;
2222
2223 if (FAILED(hr = d3d12_resource_create(device, &heap->desc.Properties, heap->desc.Flags,
2224 desc, initial_state, optimized_clear_value, &object)))
2225 return hr;
2226
2228 {
2229 d3d12_resource_Release(&object->ID3D12Resource2_iface);
2230 return hr;
2231 }
2232
2233 TRACE("Created placed resource %p.\n", object);
2234
2235 *resource = object;
2236
2237 return S_OK;
2238}
2239
2242 const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
2243{
2244 struct d3d12_resource *object;
2245 HRESULT hr;
2246
2248 desc, initial_state, optimized_clear_value, &object)))
2249 return hr;
2250
2251 if (!d3d12_resource_init_tiles(object, device))
2252 {
2253 d3d12_resource_Release(&object->ID3D12Resource2_iface);
2254 return E_OUTOFMEMORY;
2255 }
2256
2257 TRACE("Created reserved resource %p.\n", object);
2258
2259 *resource = object;
2260
2261 return S_OK;
2262}
2263
2265 const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
2266{
2268 struct d3d12_resource *object;
2269 HRESULT hr;
2270
2271 TRACE("device %p, create_info %p, resource %p.\n", device, create_info, resource);
2272
2273 if (!create_info || !resource)
2274 return E_INVALIDARG;
2276 {
2277 WARN("Invalid structure type %#x.\n", create_info->type);
2278 return E_INVALIDARG;
2279 }
2280 if (create_info->next)
2281 WARN("Unhandled next %p.\n", create_info->next);
2282
2283 if (!(object = vkd3d_malloc(sizeof(*object))))
2284 return E_OUTOFMEMORY;
2285
2286 memset(object, 0, sizeof(*object));
2287
2288 object->ID3D12Resource2_iface.lpVtbl = &d3d12_resource_vtbl;
2289 object->refcount = 1;
2290 object->internal_refcount = 1;
2291 d3d12_resource_desc1_from_desc(&object->desc, &create_info->desc);
2292 object->format = vkd3d_format_from_d3d12_resource_desc(d3d12_device, &object->desc, 0);
2293 object->u.vk_image = create_info->vk_image;
2294 object->flags = VKD3D_RESOURCE_EXTERNAL;
2295 object->flags |= create_info->flags & VKD3D_RESOURCE_PUBLIC_FLAGS;
2296 object->initial_state = D3D12_RESOURCE_STATE_COMMON;
2298 object->present_state = create_info->present_state;
2299 else
2300 object->present_state = D3D12_RESOURCE_STATE_COMMON;
2301
2302 if (FAILED(hr = vkd3d_private_store_init(&object->private_store)))
2303 {
2304 vkd3d_free(object);
2305 return hr;
2306 }
2307
2309
2310 TRACE("Created resource %p.\n", object);
2311
2312 *resource = (ID3D12Resource *)&object->ID3D12Resource2_iface;
2313
2314 return S_OK;
2315}
2316
2318{
2319 TRACE("resource %p.\n", resource);
2321}
2322
2324{
2325 TRACE("resource %p.\n", resource);
2327}
2328
2329#define HEAD_INDEX_MASK (ARRAY_SIZE(cache->heads) - 1)
2330
2331/* Objects are cached so that vkd3d_view_incref() can safely check the refcount of an
2332 * object freed by another thread. This could be implemented as a single atomic linked
2333 * list, but it requires handling the ABA problem, which brings issues with cross-platform
2334 * support, compiler support, and non-universal x86-64 support for 128-bit CAS. */
2336{
2337 union d3d12_desc_object u;
2338 unsigned int i;
2339
2341
2343 for (;;)
2344 {
2345 if (vkd3d_atomic_compare_exchange_u32(&cache->heads[i].spinlock, 0, 1))
2346 {
2347 if ((u.object = cache->heads[i].head))
2348 {
2349 vkd3d_atomic_decrement_u32(&cache->free_count);
2350 cache->heads[i].head = u.header->next;
2351 vkd3d_atomic_exchange_u32(&cache->heads[i].spinlock, 0);
2352 return u.object;
2353 }
2354 vkd3d_atomic_exchange_u32(&cache->heads[i].spinlock, 0);
2355 }
2356 /* Keeping a free count avoids uncertainty over when this loop should terminate,
2357 * which could result in excess allocations gradually increasing without limit. */
2358 if (cache->free_count < ARRAY_SIZE(cache->heads))
2359 return vkd3d_malloc(cache->size);
2360
2361 i = (i + 1) & HEAD_INDEX_MASK;
2362 }
2363}
2364
2366{
2367 union d3d12_desc_object u = {object};
2368 unsigned int i;
2369 void *head;
2370
2371 /* Using the same index as above may result in a somewhat uneven distribution,
2372 * but the main objective is to avoid costly spinlock contention. */
2374 for (;;)
2375 {
2376 if (vkd3d_atomic_compare_exchange_u32(&cache->heads[i].spinlock, 0, 1))
2377 break;
2378 i = (i + 1) & HEAD_INDEX_MASK;
2379 }
2380
2381 head = cache->heads[i].head;
2382 u.header->next = head;
2383 cache->heads[i].head = u.object;
2384 vkd3d_atomic_exchange_u32(&cache->heads[i].spinlock, 0);
2385 vkd3d_atomic_increment_u32(&cache->free_count);
2386}
2387
2388#undef HEAD_INDEX_MASK
2389
2391{
2392 struct vkd3d_cbuffer_desc *desc;
2393
2394 if (!(desc = vkd3d_desc_object_cache_get(&device->cbuffer_desc_cache)))
2395 return NULL;
2396
2398 desc->h.vk_descriptor_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
2399 desc->h.refcount = 1;
2400
2401 return desc;
2402}
2403
2404static struct vkd3d_view *vkd3d_view_create(uint32_t magic, VkDescriptorType vk_descriptor_type,
2406{
2407 struct vkd3d_view *view;
2408
2409 VKD3D_ASSERT(magic);
2410
2411 if (!(view = vkd3d_desc_object_cache_get(&device->view_desc_cache)))
2412 {
2413 ERR("Failed to allocate descriptor object.\n");
2414 return NULL;
2415 }
2416
2417 view->h.magic = magic;
2418 view->h.vk_descriptor_type = vk_descriptor_type;
2419 view->h.refcount = 1;
2420 view->v.type = type;
2421 view->v.vk_counter_view = VK_NULL_HANDLE;
2422
2423 return view;
2424}
2425
2427{
2428 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2429
2430 TRACE("Destroying view %p.\n", view);
2431
2432 switch (view->v.type)
2433 {
2435 VK_CALL(vkDestroyBufferView(device->vk_device, view->v.u.vk_buffer_view, NULL));
2436 break;
2438 VK_CALL(vkDestroyImageView(device->vk_device, view->v.u.vk_image_view, NULL));
2439 break;
2441 VK_CALL(vkDestroySampler(device->vk_device, view->v.u.vk_sampler, NULL));
2442 break;
2443 default:
2444 WARN("Unhandled view type %d.\n", view->v.type);
2445 }
2446
2447 if (view->v.vk_counter_view)
2448 VK_CALL(vkDestroyBufferView(device->vk_device, view->v.vk_counter_view, NULL));
2449
2450 vkd3d_desc_object_cache_push(&device->view_desc_cache, view);
2451}
2452
2454{
2455 union d3d12_desc_object u = {view};
2456
2457 if (vkd3d_atomic_decrement_u32(&u.header->refcount))
2458 return;
2459
2460 if (u.header->magic != VKD3D_DESCRIPTOR_MAGIC_CBV)
2462 else
2463 vkd3d_desc_object_cache_push(&device->cbuffer_desc_cache, u.object);
2464}
2465
2466static inline void d3d12_desc_replace(struct d3d12_desc *dst, void *view, struct d3d12_device *device)
2467{
2468 if ((view = vkd3d_atomic_exchange_ptr(&dst->s.u.object, view)))
2470}
2471
2472#define VKD3D_DESCRIPTOR_WRITE_BUFFER_SIZE 24
2473
2475{
2481 unsigned int count;
2482 unsigned int held_ref_count;
2483};
2484
2486{
2487 unsigned int i;
2488 for (i = 0; i < writes->held_ref_count; ++i)
2490 writes->held_ref_count = 0;
2491}
2492
2494 uint32_t dst_array_element, struct descriptor_writes *writes, struct d3d12_device *device)
2495{
2496 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2497 struct d3d12_descriptor_heap_vk_set *descriptor_set;
2499 unsigned int i = writes->count;
2500
2501 end = device->vk_info.EXT_mutable_descriptor_type ? VKD3D_SET_INDEX_MUTABLE
2503 /* Binding a shader with the wrong null descriptor type works in Windows.
2504 * To support that here we must write one to all applicable Vulkan sets. */
2506 {
2507 descriptor_set = &descriptor_heap->vk_descriptor_sets[set];
2509 writes->vk_descriptor_writes[i].pNext = NULL;
2510 writes->vk_descriptor_writes[i].dstSet = descriptor_set->vk_set;
2511 writes->vk_descriptor_writes[i].dstBinding = 0;
2512 writes->vk_descriptor_writes[i].dstArrayElement = dst_array_element;
2514 writes->vk_descriptor_writes[i].descriptorType = descriptor_set->vk_type;
2515 switch (set)
2516 {
2521 break;
2524 writes->vk_descriptor_writes[i].pImageInfo = &writes->vk_image_infos[i];
2527 writes->vk_image_infos[i].sampler = VK_NULL_HANDLE;
2528 writes->vk_image_infos[i].imageView = VK_NULL_HANDLE;
2531 break;
2537 break;
2538 default:
2539 VKD3D_ASSERT(false);
2540 break;
2541 }
2542 if (++i < ARRAY_SIZE(writes->vk_descriptor_writes) - 1)
2543 continue;
2546 i = 0;
2547 }
2548
2549 writes->count = i;
2550}
2551
2552static void d3d12_desc_write_vk_heap(struct d3d12_descriptor_heap *descriptor_heap, unsigned int dst_array_element,
2553 struct descriptor_writes *writes, void *object, struct d3d12_device *device)
2554{
2555 struct d3d12_descriptor_heap_vk_set *descriptor_set;
2556 const struct vkd3d_vk_device_procs *vk_procs;
2557 union d3d12_desc_object u = {object};
2558 unsigned int i = writes->count;
2560 bool is_null = false;
2561
2562 type = u.header->vk_descriptor_type;
2564 vk_procs = &device->vk_procs;
2565
2567 writes->vk_descriptor_writes[i].pNext = NULL;
2568 writes->vk_descriptor_writes[i].dstSet = descriptor_set->vk_set;
2569 writes->vk_descriptor_writes[i].dstBinding = 0;
2570 writes->vk_descriptor_writes[i].dstArrayElement = dst_array_element;
2573 switch (type)
2574 {
2577 writes->vk_descriptor_writes[i].pBufferInfo = &u.cb_desc->vk_cbv_info;
2579 is_null = !u.cb_desc->vk_cbv_info.buffer;
2580 break;
2583 writes->vk_descriptor_writes[i].pImageInfo = &writes->vk_image_infos[i];
2586 writes->vk_image_infos[i].sampler = VK_NULL_HANDLE;
2587 is_null = !(writes->vk_image_infos[i].imageView = u.view->v.u.vk_image_view);
2590 break;
2595 writes->vk_descriptor_writes[i].pTexelBufferView = &u.view->v.u.vk_buffer_view;
2596 is_null = !u.view->v.u.vk_buffer_view;
2597 break;
2599 writes->vk_descriptor_writes[i].pImageInfo = &writes->vk_image_infos[i];
2602 writes->vk_image_infos[i].sampler = u.view->v.u.vk_sampler;
2603 writes->vk_image_infos[i].imageView = VK_NULL_HANDLE;
2605 break;
2606 default:
2607 ERR("Unhandled descriptor type %#x.\n", type);
2608 break;
2609 }
2610 if (is_null && device->vk_info.EXT_robustness2)
2611 return d3d12_desc_write_vk_heap_null_descriptor(descriptor_heap, dst_array_element, writes, device);
2612
2613 ++i;
2614 if (u.header->magic == VKD3D_DESCRIPTOR_MAGIC_UAV && u.view->v.vk_counter_view)
2615 {
2616 descriptor_set = &descriptor_heap->vk_descriptor_sets[VKD3D_SET_INDEX_UAV_COUNTER];
2618 writes->vk_descriptor_writes[i].pNext = NULL;
2619 writes->vk_descriptor_writes[i].dstSet = descriptor_set->vk_set;
2620 writes->vk_descriptor_writes[i].dstBinding = 0;
2621 writes->vk_descriptor_writes[i].dstArrayElement = dst_array_element;
2626 writes->vk_descriptor_writes[i++].pTexelBufferView = &u.view->v.vk_counter_view;
2627 }
2628
2629 if (i >= ARRAY_SIZE(writes->vk_descriptor_writes) - 1)
2630 {
2633 i = 0;
2634 }
2635
2636 writes->count = i;
2637}
2638
2640{
2641 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2642 struct d3d12_desc *descriptors, *src;
2643 struct descriptor_writes writes;
2644 union d3d12_desc_object u;
2645 unsigned int i, next;
2646
2647 if ((i = vkd3d_atomic_exchange_u32(&descriptor_heap->dirty_list_head, UINT_MAX)) == UINT_MAX)
2648 return;
2649
2650 writes.null_vk_cbv_info.buffer = VK_NULL_HANDLE;
2651 writes.null_vk_cbv_info.offset = 0;
2652 writes.null_vk_cbv_info.range = VK_WHOLE_SIZE;
2654 writes.count = 0;
2655 writes.held_ref_count = 0;
2656
2657 descriptors = (struct d3d12_desc *)descriptor_heap->descriptors;
2658
2659 for (; i != UINT_MAX; i = next)
2660 {
2661 src = &descriptors[i];
2662 next = vkd3d_atomic_exchange_u32(&src->next, 0);
2663 next = (int)next >> 1;
2664
2665 /* A race exists here between updating src->next and getting the current object. The best
2666 * we can do is get the object last, which may result in a harmless rewrite later. */
2668
2669 if (!u.object)
2670 continue;
2671
2672 writes.held_refs[writes.held_ref_count++] = u.object;
2673 d3d12_desc_write_vk_heap(descriptor_heap, i, &writes, u.object, device);
2674 }
2675
2676 /* Avoid thunk calls wherever possible. */
2677 if (writes.count)
2678 VK_CALL(vkUpdateDescriptorSets(device->vk_device, writes.count, writes.vk_descriptor_writes, 0, NULL));
2680}
2681
2682static void d3d12_desc_mark_as_modified(struct d3d12_desc *dst, struct d3d12_descriptor_heap *descriptor_heap)
2683{
2684 unsigned int i, head;
2685
2686 i = dst->index;
2687 head = descriptor_heap->dirty_list_head;
2688
2689 /* Only one thread can swap the value away from zero. */
2690 if (!vkd3d_atomic_compare_exchange_u32(&dst->next, 0, (head << 1) | 1))
2691 return;
2692 /* Now it is safe to modify 'next' to another nonzero value if necessary. */
2693 while (!vkd3d_atomic_compare_exchange_u32(&descriptor_heap->dirty_list_head, head, i))
2694 {
2695 head = descriptor_heap->dirty_list_head;
2696 vkd3d_atomic_exchange_u32(&dst->next, (head << 1) | 1);
2697 }
2698}
2699
2700static inline void descriptor_heap_write_atomic(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_desc *dst,
2701 const struct d3d12_desc *src, struct d3d12_device *device)
2702{
2703 void *object = src->s.u.object;
2704
2705 d3d12_desc_replace(dst, object, device);
2706 if (descriptor_heap->use_vk_heaps && object && !dst->next)
2707 d3d12_desc_mark_as_modified(dst, descriptor_heap);
2708}
2709
2711 struct d3d12_device *device)
2712{
2714}
2715
2717{
2719}
2720
2721/* This is a major performance bottleneck for some games, so do not load the device
2722 * pointer from dst_heap. In some cases device will not be used. */
2723void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_descriptor_heap *dst_heap,
2724 struct d3d12_device *device)
2725{
2726 struct d3d12_desc tmp;
2727
2728 VKD3D_ASSERT(dst != src);
2729
2730 tmp.s.u.object = d3d12_desc_get_object_ref(src, device);
2731 descriptor_heap_write_atomic(dst_heap, dst, &tmp, device);
2732}
2733
2735 const struct vkd3d_format *format)
2736{
2738 const struct vkd3d_vulkan_info *vk_info = &device->vk_info;
2740
2741 if (vk_info->EXT_texel_buffer_alignment)
2742 {
2743 properties = &vk_info->texel_buffer_alignment_properties;
2744
2745 alignment = max(properties->storageTexelBufferOffsetAlignmentBytes,
2746 properties->uniformTexelBufferOffsetAlignmentBytes);
2747
2750 {
2752 return min(format->byte_count, alignment);
2753 }
2754
2755 return alignment;
2756 }
2757
2758 return vk_info->device_limits.minTexelBufferOffsetAlignment;
2759}
2760
2762 VkBuffer vk_buffer, const struct vkd3d_format *format,
2763 VkDeviceSize offset, VkDeviceSize range, VkBufferView *vk_view)
2764{
2765 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2766 struct VkBufferViewCreateInfo view_desc;
2768 VkResult vr;
2769
2771 {
2772 WARN("Invalid format for buffer view %#x.\n", format->dxgi_format);
2773 return false;
2774 }
2775
2777 if (offset % alignment)
2778 FIXME("Offset %#"PRIx64" violates the required alignment %#"PRIx64".\n", offset, alignment);
2779
2781 view_desc.pNext = NULL;
2782 view_desc.flags = 0;
2783 view_desc.buffer = vk_buffer;
2784 view_desc.format = format->vk_format;
2785 view_desc.offset = offset;
2786 view_desc.range = range;
2787 if ((vr = VK_CALL(vkCreateBufferView(device->vk_device, &view_desc, NULL, vk_view))) < 0)
2788 WARN("Failed to create Vulkan buffer view, vr %d.\n", vr);
2789 return vr == VK_SUCCESS;
2790}
2791
2792bool vkd3d_create_buffer_view(struct d3d12_device *device, uint32_t magic, VkBuffer vk_buffer,
2794 struct vkd3d_view **view)
2795{
2796 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2797 VkBufferView vk_view = VK_NULL_HANDLE;
2798 struct vkd3d_view *object;
2799
2800 if (vk_buffer && !vkd3d_create_vk_buffer_view(device, vk_buffer, format, offset, size, &vk_view))
2801 return false;
2802
2803 if (!(object = vkd3d_view_create(magic, magic == VKD3D_DESCRIPTOR_MAGIC_UAV
2806 {
2807 VK_CALL(vkDestroyBufferView(device->vk_device, vk_view, NULL));
2808 return false;
2809 }
2810
2811 object->v.u.vk_buffer_view = vk_view;
2812 object->v.format = format;
2813 object->v.info.buffer.offset = offset;
2814 object->v.info.buffer.size = size;
2815 *view = object;
2816 return true;
2817}
2818
2819#define VKD3D_VIEW_RAW_BUFFER 0x1
2820
2822 uint32_t magic, struct d3d12_resource *resource, DXGI_FORMAT view_format,
2823 unsigned int offset, unsigned int size, unsigned int structure_stride,
2824 unsigned int flags, struct vkd3d_view **view)
2825{
2826 const struct vkd3d_format *format;
2828
2829 if (view_format == DXGI_FORMAT_R32_TYPELESS && (flags & VKD3D_VIEW_RAW_BUFFER))
2830 {
2832 element_size = format->byte_count;
2833 }
2834 else if (view_format == DXGI_FORMAT_UNKNOWN && structure_stride)
2835 {
2837 element_size = structure_stride;
2838 }
2839 else if ((format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format)))
2840 {
2841 /* TODO: if view_format is DXGI_FORMAT_UNKNOWN, this is always 1, which
2842 * may not match driver behaviour (return false?). */
2843 element_size = format->byte_count;
2844 }
2845 else
2846 {
2847 WARN("Failed to find format for %#x.\n", resource->desc.Format);
2848 return false;
2849 }
2850
2852
2853 return vkd3d_create_buffer_view(device, magic, resource->u.vk_buffer,
2855}
2856
2858 const struct vkd3d_format *format, bool allowed_swizzle)
2859{
2864
2865 if (format->vk_aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT)
2866 {
2867 if (allowed_swizzle)
2868 {
2873 }
2874 else
2875 {
2876 FIXME("Stencil swizzle is not supported for format %#x.\n",
2877 format->dxgi_format);
2878 }
2879 }
2880
2881 if (format->dxgi_format == DXGI_FORMAT_A8_UNORM)
2882 {
2883 if (allowed_swizzle)
2884 {
2889 }
2890 else
2891 {
2892 FIXME("Alpha swizzle is not supported.\n");
2893 }
2894 }
2895
2896 if (format->dxgi_format == DXGI_FORMAT_B8G8R8X8_UNORM
2897 || format->dxgi_format == DXGI_FORMAT_B8G8R8X8_UNORM_SRGB)
2898 {
2899 if (allowed_swizzle)
2900 {
2905 }
2906 else
2907 {
2908 FIXME("B8G8R8X8 swizzle is not supported.\n");
2909 }
2910 }
2911}
2912
2913static VkComponentSwizzle vk_component_swizzle_from_d3d12(unsigned int component_mapping,
2914 unsigned int component_index)
2915{
2917 = D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(component_index, component_mapping);
2918
2919 switch (mapping)
2920 {
2933 }
2934
2935 FIXME("Invalid component mapping %#x.\n", mapping);
2937}
2938
2940 unsigned int component_mapping)
2941{
2942 components->r = vk_component_swizzle_from_d3d12(component_mapping, 0);
2943 components->g = vk_component_swizzle_from_d3d12(component_mapping, 1);
2944 components->b = vk_component_swizzle_from_d3d12(component_mapping, 2);
2945 components->a = vk_component_swizzle_from_d3d12(component_mapping, 3);
2946}
2947
2950{
2951 switch (swizzle)
2952 {
2954 break;
2955
2957 component = components->r;
2958 break;
2959
2961 component = components->g;
2962 break;
2963
2965 component = components->b;
2966 break;
2967
2969 component = components->a;
2970 break;
2971
2975 break;
2976
2977 default:
2978 FIXME("Invalid component swizzle %#x.\n", swizzle);
2979 break;
2980 }
2981
2983 return component;
2984}
2985
2987{
2988 const VkComponentMapping a = *dst;
2989
2990 dst->r = swizzle_vk_component(&a, a.r, b->r);
2991 dst->g = swizzle_vk_component(&a, a.g, b->g);
2992 dst->b = swizzle_vk_component(&a, a.b, b->b);
2993 dst->a = swizzle_vk_component(&a, a.a, b->a);
2994}
2995
2997 struct d3d12_resource *resource, DXGI_FORMAT view_format)
2998{
2999 const struct d3d12_device *device = resource->device;
3000
3001 if (view_format == resource->desc.Format)
3002 {
3003 desc->format = resource->format;
3004 }
3005 else if (!(desc->format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format)))
3006 {
3007 FIXME("Failed to find format (resource format %#x, view format %#x).\n",
3008 resource->desc.Format, view_format);
3009 return false;
3010 }
3011
3012 desc->miplevel_idx = 0;
3013 desc->miplevel_count = 1;
3014 desc->layer_idx = 0;
3015 desc->layer_count = d3d12_resource_desc_get_layer_count(&resource->desc);
3016 desc->vk_image_aspect = desc->format->vk_aspect_mask;
3017
3018 switch (resource->desc.Dimension)
3019 {
3021 desc->view_type = resource->desc.DepthOrArraySize > 1
3023 break;
3024
3026 desc->view_type = resource->desc.DepthOrArraySize > 1
3028 break;
3029
3031 desc->view_type = VK_IMAGE_VIEW_TYPE_3D;
3032 desc->layer_count = 1;
3033 break;
3034
3035 default:
3036 FIXME("Resource dimension %#x not implemented.\n", resource->desc.Dimension);
3037 return false;
3038 }
3039
3040 desc->components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
3041 desc->components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
3042 desc->components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
3043 desc->components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
3044 desc->allowed_swizzle = false;
3045 desc->usage = 0;
3046 return true;
3047}
3048
3050 const D3D12_RESOURCE_DESC1 *resource_desc)
3051{
3052 unsigned int max_layer_count;
3053
3054 if (resource_desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
3055 {
3056 if (desc->view_type == VK_IMAGE_VIEW_TYPE_2D_ARRAY)
3057 max_layer_count = max(1, resource_desc->DepthOrArraySize >> desc->miplevel_idx);
3058 else
3059 max_layer_count = 1;
3060 }
3061 else
3062 {
3063 max_layer_count = resource_desc->DepthOrArraySize;
3064 }
3065
3066 if (desc->layer_idx >= max_layer_count)
3067 {
3068 WARN("Layer index %u exceeds maximum available layer %u.\n", desc->layer_idx, max_layer_count - 1);
3069 desc->layer_count = 1;
3070 return;
3071 }
3072
3073 max_layer_count -= desc->layer_idx;
3074 if (desc->layer_count <= max_layer_count)
3075 return;
3076
3077 if (desc->layer_count != UINT_MAX)
3078 WARN("Layer count %u exceeds maximum %u.\n", desc->layer_count, max_layer_count);
3079 desc->layer_count = max_layer_count;
3080}
3081
3082bool vkd3d_create_texture_view(struct d3d12_device *device, uint32_t magic, VkImage vk_image,
3083 const struct vkd3d_texture_view_desc *desc, struct vkd3d_view **view)
3084{
3085 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
3086 const struct vkd3d_format *format = desc->format;
3088 struct VkImageViewCreateInfo view_desc;
3089 VkImageView vk_view = VK_NULL_HANDLE;
3090 struct vkd3d_view *object;
3091 VkResult vr;
3092
3093 if (vk_image)
3094 {
3096 view_desc.pNext = NULL;
3097 view_desc.flags = 0;
3098 view_desc.image = vk_image;
3099 view_desc.viewType = desc->view_type;
3100 view_desc.format = format->vk_format;
3101 vkd3d_set_view_swizzle_for_format(&view_desc.components, format, desc->allowed_swizzle);
3102 if (desc->allowed_swizzle)
3103 vk_component_mapping_compose(&view_desc.components, &desc->components);
3104 view_desc.subresourceRange.aspectMask = desc->vk_image_aspect;
3105 view_desc.subresourceRange.baseMipLevel = desc->miplevel_idx;
3106 view_desc.subresourceRange.levelCount = desc->miplevel_count;
3107 view_desc.subresourceRange.baseArrayLayer = desc->layer_idx;
3108 view_desc.subresourceRange.layerCount = desc->layer_count;
3109 if (device->vk_info.KHR_maintenance2)
3110 {
3112 usage_desc.pNext = NULL;
3113 usage_desc.usage = desc->usage;
3114 view_desc.pNext = &usage_desc;
3115 }
3116 if ((vr = VK_CALL(vkCreateImageView(device->vk_device, &view_desc, NULL, &vk_view))) < 0)
3117 {
3118 WARN("Failed to create Vulkan image view, vr %d.\n", vr);
3119 return false;
3120 }
3121 }
3122
3125 {
3126 VK_CALL(vkDestroyImageView(device->vk_device, vk_view, NULL));
3127 return false;
3128 }
3129
3130 object->v.u.vk_image_view = vk_view;
3131 object->v.format = format;
3132 object->v.info.texture.vk_view_type = desc->view_type;
3133 object->v.info.texture.miplevel_idx = desc->miplevel_idx;
3134 object->v.info.texture.layer_idx = desc->layer_idx;
3135 object->v.info.texture.layer_count = desc->layer_count;
3136 *view = object;
3137 return true;
3138}
3139
3142{
3143 struct VkDescriptorBufferInfo *buffer_info;
3144 struct vkd3d_cbuffer_desc *cb_desc;
3145 struct d3d12_resource *resource;
3146
3147 if (!desc)
3148 {
3149 WARN("Constant buffer desc is NULL.\n");
3150 return;
3151 }
3152
3153 if (!(cb_desc = vkd3d_cbuffer_desc_create(device)))
3154 {
3155 ERR("Failed to allocate descriptor object.\n");
3156 return;
3157 }
3158
3160 {
3161 WARN("Size is not %u bytes aligned.\n", D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
3162 return;
3163 }
3164
3165 buffer_info = &cb_desc->vk_cbv_info;
3166 if (desc->BufferLocation)
3167 {
3168 resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, desc->BufferLocation);
3169 buffer_info->buffer = resource->u.vk_buffer;
3170 buffer_info->offset = desc->BufferLocation - resource->gpu_address;
3171 buffer_info->range = min(desc->SizeInBytes, resource->desc.Width - buffer_info->offset);
3172 }
3173 else
3174 {
3175 /* NULL descriptor */
3176 buffer_info->buffer = device->null_resources.vk_buffer;
3177 buffer_info->offset = 0;
3178 buffer_info->range = VK_WHOLE_SIZE;
3179 }
3180
3181 descriptor->s.u.cb_desc = cb_desc;
3182}
3183
3185{
3187 return VKD3D_VIEW_RAW_BUFFER;
3188 if (flags)
3189 FIXME("Unhandled buffer SRV flags %#x.\n", flags);
3190 return 0;
3191}
3192
3195{
3196 struct vkd3d_null_resources *null_resources = &device->null_resources;
3197 struct vkd3d_texture_view_desc vkd3d_desc;
3198 VkImage vk_image;
3199
3200 if (!desc)
3201 {
3202 WARN("D3D12_SHADER_RESOURCE_VIEW_DESC is required for NULL view.\n");
3203 return;
3204 }
3205
3206 switch (desc->ViewDimension)
3207 {
3209 if (!device->vk_info.EXT_robustness2)
3210 WARN("Creating NULL buffer SRV %#x.\n", desc->Format);
3211
3214 0, VKD3D_NULL_BUFFER_SIZE, &descriptor->s.u.view);
3215 return;
3216
3218 vk_image = null_resources->vk_2d_image;
3219 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3220 break;
3222 vk_image = null_resources->vk_2d_image;
3224 break;
3225
3226 default:
3227 if (device->vk_info.EXT_robustness2)
3228 {
3229 vk_image = VK_NULL_HANDLE;
3230 /* view_type is not used for Vulkan null descriptors, but make it valid. */
3231 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3232 break;
3233 }
3234 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3235 return;
3236 }
3237
3238 if (!device->vk_info.EXT_robustness2)
3239 WARN("Creating NULL SRV %#x.\n", desc->ViewDimension);
3240
3242 vkd3d_desc.miplevel_idx = 0;
3243 vkd3d_desc.miplevel_count = 1;
3244 vkd3d_desc.layer_idx = 0;
3245 vkd3d_desc.layer_count = 1;
3251 vkd3d_desc.allowed_swizzle = true;
3252 vkd3d_desc.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
3253
3254 vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_SRV, vk_image, &vkd3d_desc, &descriptor->s.u.view);
3255}
3256
3258 struct d3d12_device *device, struct d3d12_resource *resource,
3260{
3261 unsigned int flags;
3262
3263 if (!desc)
3264 {
3265 FIXME("Default SRV views not supported.\n");
3266 return;
3267 }
3268
3269 if (desc->ViewDimension != D3D12_SRV_DIMENSION_BUFFER)
3270 {
3271 WARN("Unexpected view dimension %#x.\n", desc->ViewDimension);
3272 return;
3273 }
3274
3277 desc->u.Buffer.FirstElement, desc->u.Buffer.NumElements,
3278 desc->u.Buffer.StructureByteStride, flags, &descriptor->s.u.view);
3279}
3280
3282 unsigned int plane_slice)
3283{
3284 VkImageAspectFlags aspect_flags = format->vk_aspect_mask;
3285 unsigned int i;
3286
3287 /* For all formats we currently handle, the n-th aspect bit in Vulkan, if the lowest bit set is
3288 * n = 0, corresponds to the n-th plane in D3D12, so clear the lowest bit for each slice skipped. */
3289 for (i = 0; i < plane_slice; i++)
3290 aspect_flags &= aspect_flags - 1;
3291
3292 if (!aspect_flags)
3293 {
3294 WARN("Invalid plane slice %u for format %#x.\n", plane_slice, format->vk_format);
3295 aspect_flags = format->vk_aspect_mask;
3296 }
3297
3298 /* The selected slice is now the lowest bit in the aspect flags, so clear the others. */
3299 return aspect_flags & -aspect_flags;
3300}
3301
3303 struct d3d12_device *device, struct d3d12_resource *resource,
3305{
3306 struct vkd3d_texture_view_desc vkd3d_desc;
3307
3308 if (!resource)
3309 {
3311 return;
3312 }
3313
3315 {
3317 return;
3318 }
3319
3320 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3321 return;
3322
3324 vkd3d_desc.allowed_swizzle = true;
3325 vkd3d_desc.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
3326
3327 if (desc)
3328 {
3329 if (desc->Shader4ComponentMapping != D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING)
3330 {
3331 TRACE("Component mapping %s for format %#x.\n",
3332 debug_d3d12_shader_component_mapping(desc->Shader4ComponentMapping), desc->Format);
3333
3334 vk_component_mapping_from_d3d12(&vkd3d_desc.components, desc->Shader4ComponentMapping);
3335 }
3336
3337 switch (desc->ViewDimension)
3338 {
3340 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_1D;
3341 vkd3d_desc.miplevel_idx = desc->u.Texture1D.MostDetailedMip;
3342 vkd3d_desc.miplevel_count = desc->u.Texture1D.MipLevels;
3343 break;
3345 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3346 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MostDetailedMip;
3347 vkd3d_desc.miplevel_count = desc->u.Texture2D.MipLevels;
3348 if (desc->u.Texture2D.PlaneSlice)
3350 desc->u.Texture2D.PlaneSlice);
3351 if (desc->u.Texture2D.ResourceMinLODClamp)
3352 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.Texture2D.ResourceMinLODClamp);
3353 break;
3356 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MostDetailedMip;
3357 vkd3d_desc.miplevel_count = desc->u.Texture2DArray.MipLevels;
3358 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3359 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3360 if (desc->u.Texture2DArray.PlaneSlice)
3362 desc->u.Texture2DArray.PlaneSlice);
3363 if (desc->u.Texture2DArray.ResourceMinLODClamp)
3364 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.Texture2DArray.ResourceMinLODClamp);
3365 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3366 break;
3368 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3369 break;
3372 vkd3d_desc.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
3373 vkd3d_desc.layer_count = desc->u.Texture2DMSArray.ArraySize;
3374 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3375 break;
3377 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_3D;
3378 vkd3d_desc.miplevel_idx = desc->u.Texture3D.MostDetailedMip;
3379 vkd3d_desc.miplevel_count = desc->u.Texture3D.MipLevels;
3380 if (desc->u.Texture3D.ResourceMinLODClamp)
3381 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.Texture2D.ResourceMinLODClamp);
3382 break;
3385 vkd3d_desc.miplevel_idx = desc->u.TextureCube.MostDetailedMip;
3386 vkd3d_desc.miplevel_count = desc->u.TextureCube.MipLevels;
3387 vkd3d_desc.layer_count = 6;
3388 if (desc->u.TextureCube.ResourceMinLODClamp)
3389 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.TextureCube.ResourceMinLODClamp);
3390 break;
3393 vkd3d_desc.miplevel_idx = desc->u.TextureCubeArray.MostDetailedMip;
3394 vkd3d_desc.miplevel_count = desc->u.TextureCubeArray.MipLevels;
3395 vkd3d_desc.layer_idx = desc->u.TextureCubeArray.First2DArrayFace;
3396 vkd3d_desc.layer_count = desc->u.TextureCubeArray.NumCubes;
3397 if (vkd3d_desc.layer_count != UINT_MAX)
3398 vkd3d_desc.layer_count *= 6;
3399 if (desc->u.TextureCubeArray.ResourceMinLODClamp)
3400 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.TextureCubeArray.ResourceMinLODClamp);
3401 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3402 break;
3403 default:
3404 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3405 }
3406 }
3407
3409 &descriptor->s.u.view);
3410}
3411
3413{
3415 return VKD3D_VIEW_RAW_BUFFER;
3416 if (flags)
3417 FIXME("Unhandled buffer UAV flags %#x.\n", flags);
3418 return 0;
3419}
3420
3423{
3424 struct vkd3d_null_resources *null_resources = &device->null_resources;
3425 struct vkd3d_texture_view_desc vkd3d_desc;
3426 VkImage vk_image;
3427
3428 if (!desc)
3429 {
3430 WARN("View desc is required for NULL view.\n");
3431 return;
3432 }
3433
3434 switch (desc->ViewDimension)
3435 {
3437 if (!device->vk_info.EXT_robustness2)
3438 WARN("Creating NULL buffer UAV %#x.\n", desc->Format);
3439
3442 0, VKD3D_NULL_BUFFER_SIZE, &descriptor->s.u.view);
3443 return;
3444
3446 vk_image = null_resources->vk_2d_storage_image;
3447 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3448 break;
3450 vk_image = null_resources->vk_2d_storage_image;
3452 break;
3453
3454 default:
3455 if (device->vk_info.EXT_robustness2)
3456 {
3457 vk_image = VK_NULL_HANDLE;
3458 /* view_type is not used for Vulkan null descriptors, but make it valid. */
3459 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3460 break;
3461 }
3462 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3463 return;
3464 }
3465
3466 if (!device->vk_info.EXT_robustness2)
3467 WARN("Creating NULL UAV %#x.\n", desc->ViewDimension);
3468
3470 vkd3d_desc.miplevel_idx = 0;
3471 vkd3d_desc.miplevel_count = 1;
3472 vkd3d_desc.layer_idx = 0;
3473 vkd3d_desc.layer_count = 1;
3475 vkd3d_desc.components.r = VK_COMPONENT_SWIZZLE_R;
3476 vkd3d_desc.components.g = VK_COMPONENT_SWIZZLE_G;
3477 vkd3d_desc.components.b = VK_COMPONENT_SWIZZLE_B;
3478 vkd3d_desc.components.a = VK_COMPONENT_SWIZZLE_A;
3479 vkd3d_desc.allowed_swizzle = false;
3480 vkd3d_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
3481
3482 vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_UAV, vk_image, &vkd3d_desc, &descriptor->s.u.view);
3483}
3484
3486 struct d3d12_resource *resource, struct d3d12_resource *counter_resource,
3488{
3489 struct vkd3d_view *view;
3490 unsigned int flags;
3491
3492 if (!desc)
3493 {
3494 FIXME("Default UAV views not supported.\n");
3495 return;
3496 }
3497
3498 if (desc->ViewDimension != D3D12_UAV_DIMENSION_BUFFER)
3499 {
3500 WARN("Unexpected view dimension %#x.\n", desc->ViewDimension);
3501 return;
3502 }
3503
3506 desc->u.Buffer.FirstElement, desc->u.Buffer.NumElements,
3507 desc->u.Buffer.StructureByteStride, flags, &view))
3508 return;
3509
3510 if (counter_resource)
3511 {
3512 const struct vkd3d_format *format;
3513
3514 VKD3D_ASSERT(d3d12_resource_is_buffer(counter_resource));
3515 VKD3D_ASSERT(desc->u.Buffer.StructureByteStride);
3516
3518 if (!vkd3d_create_vk_buffer_view(device, counter_resource->u.vk_buffer, format,
3519 desc->u.Buffer.CounterOffsetInBytes, sizeof(uint32_t), &view->v.vk_counter_view))
3520 {
3521 WARN("Failed to create counter buffer view.\n");
3522 view->v.vk_counter_view = VK_NULL_HANDLE;
3524 return;
3525 }
3526 }
3527
3528 descriptor->s.u.view = view;
3529}
3530
3532 struct d3d12_device *device, struct d3d12_resource *resource,
3534{
3535 struct vkd3d_texture_view_desc vkd3d_desc;
3536
3537 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3538 return;
3539
3540 vkd3d_desc.usage = VK_IMAGE_USAGE_STORAGE_BIT;
3541
3542 if (vkd3d_format_is_compressed(vkd3d_desc.format))
3543 {
3544 WARN("UAVs cannot be created for compressed formats.\n");
3545 return;
3546 }
3547
3548 if (desc)
3549 {
3550 switch (desc->ViewDimension)
3551 {
3553 vkd3d_desc.miplevel_idx = desc->u.Texture1D.MipSlice;
3554 break;
3556 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MipSlice;
3557 if (desc->u.Texture2D.PlaneSlice)
3559 desc->u.Texture2D.PlaneSlice);
3560 break;
3563 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MipSlice;
3564 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3565 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3566 if (desc->u.Texture2DArray.PlaneSlice)
3568 desc->u.Texture2DArray.PlaneSlice);
3569 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3570 break;
3572 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_3D;
3573 vkd3d_desc.miplevel_idx = desc->u.Texture3D.MipSlice;
3574 if (desc->u.Texture3D.FirstWSlice || (desc->u.Texture3D.WSize != UINT_MAX
3575 && desc->u.Texture3D.WSize != max(1u,
3576 resource->desc.DepthOrArraySize >> desc->u.Texture3D.MipSlice)))
3577 FIXME("Unhandled depth view %u-%u.\n",
3578 desc->u.Texture3D.FirstWSlice, desc->u.Texture3D.WSize);
3579 break;
3580 default:
3581 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3582 }
3583 }
3584
3586 &descriptor->s.u.view);
3587}
3588
3590 struct d3d12_resource *resource, struct d3d12_resource *counter_resource,
3592{
3593 if (!resource)
3594 {
3595 if (counter_resource)
3596 FIXME("Ignoring counter resource %p.\n", counter_resource);
3598 return;
3599 }
3600
3602 {
3604 }
3605 else
3606 {
3607 if (counter_resource)
3608 FIXME("Unexpected counter resource for texture view.\n");
3610 }
3611}
3612
3614 D3D12_GPU_VIRTUAL_ADDRESS gpu_address, D3D12_ROOT_PARAMETER_TYPE parameter_type, VkBufferView *vk_buffer_view)
3615{
3616 const struct vkd3d_format *format;
3617 struct d3d12_resource *resource;
3618
3620
3621 if (!gpu_address)
3622 {
3623 if (device->vk_info.EXT_robustness2)
3624 {
3625 *vk_buffer_view = VK_NULL_HANDLE;
3626 return true;
3627 }
3628 WARN("Creating null buffer view.\n");
3630 ? device->null_resources.vk_storage_buffer : device->null_resources.vk_buffer,
3631 format, 0, VK_WHOLE_SIZE, vk_buffer_view);
3632 }
3633
3636 return vkd3d_create_vk_buffer_view(device, resource->u.vk_buffer, format,
3637 gpu_address - resource->gpu_address, VK_WHOLE_SIZE, vk_buffer_view);
3638}
3639
3640/* samplers */
3642{
3643 switch (type)
3644 {
3646 return VK_FILTER_NEAREST;
3648 return VK_FILTER_LINEAR;
3649 default:
3650 FIXME("Unhandled filter type %#x.\n", type);
3651 return VK_FILTER_NEAREST;
3652 }
3653}
3654
3656{
3657 switch (type)
3658 {
3663 default:
3664 FIXME("Unhandled filter type %#x.\n", type);
3666 }
3667}
3668
3671{
3672 switch (mode)
3673 {
3683 if (device->vk_info.KHR_sampler_mirror_clamp_to_edge)
3685 /* Fall through */
3686 default:
3687 FIXME("Unhandled address mode %#x.\n", mode);
3689 }
3690}
3691
3693{
3694 switch (colour)
3695 {
3702 default:
3703 FIXME("Unhandled border colour %#x.\n", colour);
3705 }
3706}
3707
3710 D3D12_TEXTURE_ADDRESS_MODE address_w, float mip_lod_bias, unsigned int max_anisotropy,
3711 D3D12_COMPARISON_FUNC comparison_func, D3D12_STATIC_BORDER_COLOR border_colour,
3712 float min_lod, float max_lod, VkSampler *vk_sampler)
3713{
3714 const struct vkd3d_vk_device_procs *vk_procs;
3715 struct VkSamplerCreateInfo sampler_desc;
3716 VkResult vr;
3717
3718 vk_procs = &device->vk_procs;
3719
3720 if (D3D12_DECODE_FILTER_REDUCTION(filter) == D3D12_FILTER_REDUCTION_TYPE_MINIMUM
3721 || D3D12_DECODE_FILTER_REDUCTION(filter) == D3D12_FILTER_REDUCTION_TYPE_MAXIMUM)
3722 FIXME("Min/max reduction mode not supported.\n");
3723
3725 sampler_desc.pNext = NULL;
3726 sampler_desc.flags = 0;
3727 sampler_desc.magFilter = vk_filter_from_d3d12(D3D12_DECODE_MAG_FILTER(filter));
3728 sampler_desc.minFilter = vk_filter_from_d3d12(D3D12_DECODE_MIN_FILTER(filter));
3729 sampler_desc.mipmapMode = vk_mipmap_mode_from_d3d12(D3D12_DECODE_MIP_FILTER(filter));
3730 sampler_desc.addressModeU = vk_address_mode_from_d3d12(device, address_u);
3731 sampler_desc.addressModeV = vk_address_mode_from_d3d12(device, address_v);
3732 sampler_desc.addressModeW = vk_address_mode_from_d3d12(device, address_w);
3733 sampler_desc.mipLodBias = mip_lod_bias;
3734 sampler_desc.anisotropyEnable = D3D12_DECODE_IS_ANISOTROPIC_FILTER(filter);
3735 sampler_desc.maxAnisotropy = max_anisotropy;
3736 sampler_desc.compareEnable = D3D12_DECODE_IS_COMPARISON_FILTER(filter);
3737 sampler_desc.compareOp = sampler_desc.compareEnable ? vk_compare_op_from_d3d12(comparison_func) : 0;
3738 sampler_desc.minLod = min_lod;
3739 sampler_desc.maxLod = max_lod;
3741 sampler_desc.unnormalizedCoordinates = VK_FALSE;
3742
3744 || address_w == D3D12_TEXTURE_ADDRESS_MODE_BORDER)
3745 sampler_desc.borderColor = vk_border_colour_from_d3d12(border_colour);
3746
3747 if ((vr = VK_CALL(vkCreateSampler(device->vk_device, &sampler_desc, NULL, vk_sampler))) < 0)
3748 WARN("Failed to create Vulkan sampler, vr %d.\n", vr);
3749
3750 return vr;
3751}
3752
3754{
3755 unsigned int i;
3756
3757 static const struct
3758 {
3759 float colour[4];
3760 D3D12_STATIC_BORDER_COLOR static_colour;
3761 }
3762 colours[] =
3763 {
3764 {{0.0f, 0.0f, 0.0f, 0.0f}, D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK},
3765 {{0.0f, 0.0f, 0.0f, 1.0f}, D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK},
3766 {{1.0f, 1.0f, 1.0f, 1.0f}, D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE},
3767 };
3768
3769 for (i = 0; i < ARRAY_SIZE(colours); ++i)
3770 {
3771 if (!memcmp(colour, colours[i].colour, sizeof(colours[i].colour)))
3772 return colours[i].static_colour;
3773 }
3774
3775 FIXME("Unhandled border colour {%.8e, %.8e, %.8e, %.8e}.\n", colour[0], colour[1], colour[2], colour[3]);
3776
3778}
3779
3782{
3784 struct vkd3d_view *view;
3785
3786 if (!desc)
3787 {
3788 WARN("NULL sampler desc.\n");
3789 return;
3790 }
3791
3795 static_colour = d3d12_static_border_colour(desc->BorderColor);
3796
3799 return;
3800 view->v.u.vk_sampler = VK_NULL_HANDLE;
3801 view->v.format = NULL;
3802
3803 if (d3d12_create_sampler(device, desc->Filter, desc->AddressU, desc->AddressV,
3804 desc->AddressW, desc->MipLODBias, desc->MaxAnisotropy, desc->ComparisonFunc,
3805 static_colour, desc->MinLOD, desc->MaxLOD, &view->v.u.vk_sampler) < 0)
3806 {
3808 return;
3809 }
3810
3811 sampler->s.u.view = view;
3812}
3813
3815 const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler)
3816{
3817 VkResult vr;
3818
3819 vr = d3d12_create_sampler(device, desc->Filter, desc->AddressU, desc->AddressV,
3820 desc->AddressW, desc->MipLODBias, desc->MaxAnisotropy, desc->ComparisonFunc,
3821 desc->BorderColor, desc->MinLOD, desc->MaxLOD, vk_sampler);
3822 return hresult_from_vk_result(vr);
3823}
3824
3825/* RTVs */
3827{
3828 if (!rtv->view)
3829 return;
3830
3832 memset(rtv, 0, sizeof(*rtv));
3833}
3834
3837{
3838 struct vkd3d_texture_view_desc vkd3d_desc;
3839 struct vkd3d_view *view;
3840
3841 d3d12_rtv_desc_destroy(rtv_desc, device);
3842
3843 if (!resource)
3844 {
3845 FIXME("NULL resource RTV not implemented.\n");
3846 return;
3847 }
3848
3849 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3850 return;
3851
3853
3854 if (vkd3d_desc.format->vk_aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT)
3855 {
3856 WARN("Trying to create RTV for depth/stencil format %#x.\n", vkd3d_desc.format->dxgi_format);
3857 return;
3858 }
3859
3860 if (desc)
3861 {
3862 switch (desc->ViewDimension)
3863 {
3865 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MipSlice;
3866 if (desc->u.Texture2D.PlaneSlice)
3868 desc->u.Texture2D.PlaneSlice);
3869 break;
3872 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MipSlice;
3873 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3874 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3875 if (desc->u.Texture2DArray.PlaneSlice)
3877 desc->u.Texture2DArray.PlaneSlice);
3878 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3879 break;
3881 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3882 break;
3885 vkd3d_desc.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
3886 vkd3d_desc.layer_count = desc->u.Texture2DMSArray.ArraySize;
3887 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3888 break;
3891 vkd3d_desc.miplevel_idx = desc->u.Texture3D.MipSlice;
3892 vkd3d_desc.layer_idx = desc->u.Texture3D.FirstWSlice;
3893 vkd3d_desc.layer_count = desc->u.Texture3D.WSize;
3894 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3895 break;
3896 default:
3897 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3898 }
3899 }
3900 else if (resource->desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
3901 {
3903 vkd3d_desc.layer_idx = 0;
3904 vkd3d_desc.layer_count = resource->desc.DepthOrArraySize;
3905 }
3906
3908
3909 if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_RTV, resource->u.vk_image, &vkd3d_desc, &view))
3910 return;
3911
3912 rtv_desc->sample_count = vk_samples_from_dxgi_sample_desc(&resource->desc.SampleDesc);
3913 rtv_desc->format = vkd3d_desc.format;
3914 rtv_desc->width = d3d12_resource_desc_get_width(&resource->desc, vkd3d_desc.miplevel_idx);
3915 rtv_desc->height = d3d12_resource_desc_get_height(&resource->desc, vkd3d_desc.miplevel_idx);
3916 rtv_desc->layer_count = vkd3d_desc.layer_count;
3917 rtv_desc->view = view;
3918 rtv_desc->resource = resource;
3919}
3920
3921/* DSVs */
3923{
3924 if (!dsv->view)
3925 return;
3926
3928 memset(dsv, 0, sizeof(*dsv));
3929}
3930
3933{
3934 struct vkd3d_texture_view_desc vkd3d_desc;
3935 struct vkd3d_view *view;
3936
3937 d3d12_dsv_desc_destroy(dsv_desc, device);
3938
3939 if (!resource)
3940 {
3941 FIXME("NULL resource DSV not implemented.\n");
3942 return;
3943 }
3944
3945 if (resource->desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
3946 {
3947 WARN("Cannot create DSV for 3D texture.\n");
3948 return;
3949 }
3950
3951 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3952 return;
3953
3955
3956 if (!(vkd3d_desc.format->vk_aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)))
3957 {
3958 WARN("Trying to create DSV for format %#x.\n", vkd3d_desc.format->dxgi_format);
3959 return;
3960 }
3961
3962 if (desc)
3963 {
3964 if (desc->Flags)
3965 FIXME("Ignoring flags %#x.\n", desc->Flags);
3966
3967 switch (desc->ViewDimension)
3968 {
3970 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MipSlice;
3971 break;
3974 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MipSlice;
3975 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3976 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3977 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3978 break;
3980 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3981 break;
3984 vkd3d_desc.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
3985 vkd3d_desc.layer_count = desc->u.Texture2DMSArray.ArraySize;
3986 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3987 break;
3988 default:
3989 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3990 }
3991 }
3992
3994
3995 if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_DSV, resource->u.vk_image, &vkd3d_desc, &view))
3996 return;
3997
3998 dsv_desc->sample_count = vk_samples_from_dxgi_sample_desc(&resource->desc.SampleDesc);
3999 dsv_desc->format = vkd3d_desc.format;
4000 dsv_desc->width = d3d12_resource_desc_get_width(&resource->desc, vkd3d_desc.miplevel_idx);
4001 dsv_desc->height = d3d12_resource_desc_get_height(&resource->desc, vkd3d_desc.miplevel_idx);
4002 dsv_desc->layer_count = vkd3d_desc.layer_count;
4003 dsv_desc->view = view;
4004 dsv_desc->resource = resource;
4005}
4006
4007/* ID3D12DescriptorHeap */
4009{
4011}
4012
4014 REFIID riid, void **object)
4015{
4016 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
4017
4018 if (IsEqualGUID(riid, &IID_ID3D12DescriptorHeap)
4019 || IsEqualGUID(riid, &IID_ID3D12Pageable)
4020 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
4021 || IsEqualGUID(riid, &IID_ID3D12Object)
4023 {
4024 ID3D12DescriptorHeap_AddRef(iface);
4025 *object = iface;
4026 return S_OK;
4027 }
4028
4029 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
4030
4031 *object = NULL;
4032 return E_NOINTERFACE;
4033}
4034
4036{
4038 unsigned int refcount = vkd3d_atomic_increment_u32(&heap->refcount);
4039
4040 TRACE("%p increasing refcount to %u.\n", heap, refcount);
4041
4042 return refcount;
4043}
4044
4046{
4048 unsigned int refcount = vkd3d_atomic_decrement_u32(&heap->refcount);
4049
4050 TRACE("%p decreasing refcount to %u.\n", heap, refcount);
4051
4052 if (!refcount)
4053 {
4054 const struct vkd3d_vk_device_procs *vk_procs;
4055 struct d3d12_device *device = heap->device;
4056 unsigned int i;
4057
4058 vk_procs = &device->vk_procs;
4059
4060 vkd3d_private_store_destroy(&heap->private_store);
4061
4062 switch (heap->desc.Type)
4063 {
4066 {
4067 struct d3d12_desc *descriptors = (struct d3d12_desc *)heap->descriptors;
4068
4069 if (heap->use_vk_heaps)
4071
4072 for (i = 0; i < heap->desc.NumDescriptors; ++i)
4073 {
4074 d3d12_desc_destroy(&descriptors[i], device);
4075 }
4076
4077 break;
4078 }
4079
4081 {
4082 struct d3d12_rtv_desc *rtvs = (struct d3d12_rtv_desc *)heap->descriptors;
4083
4084 for (i = 0; i < heap->desc.NumDescriptors; ++i)
4085 {
4087 }
4088 break;
4089 }
4090
4092 {
4093 struct d3d12_dsv_desc *dsvs = (struct d3d12_dsv_desc *)heap->descriptors;
4094
4095 for (i = 0; i < heap->desc.NumDescriptors; ++i)
4096 {
4098 }
4099 break;
4100 }
4101
4102 default:
4103 break;
4104 }
4105
4106 VK_CALL(vkDestroyDescriptorPool(device->vk_device, heap->vk_descriptor_pool, NULL));
4107 vkd3d_mutex_destroy(&heap->vk_sets_mutex);
4108
4110
4112 }
4113
4114 return refcount;
4115}
4116
4118 REFGUID guid, UINT *data_size, void *data)
4119{
4121
4122 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
4123
4124 return vkd3d_get_private_data(&heap->private_store, guid, data_size, data);
4125}
4126
4128 REFGUID guid, UINT data_size, const void *data)
4129{
4131
4132 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
4133
4134 return vkd3d_set_private_data(&heap->private_store, guid, data_size, data);
4135}
4136
4138 REFGUID guid, const IUnknown *data)
4139{
4141
4142 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
4143
4144 return vkd3d_set_private_data_interface(&heap->private_store, guid, data);
4145}
4146
4148{
4150
4151 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, heap->device->wchar_size));
4152
4153 return name ? S_OK : E_INVALIDARG;
4154}
4155
4157{
4159
4160 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
4161
4162 return d3d12_device_query_interface(heap->device, iid, device);
4163}
4164
4167{
4169
4170 TRACE("iface %p, desc %p.\n", iface, desc);
4171
4172 *desc = heap->desc;
4173 return desc;
4174}
4175
4178{
4180
4181 TRACE("iface %p, descriptor %p.\n", iface, descriptor);
4182
4183 descriptor->ptr = (SIZE_T)heap->descriptors;
4184
4185 return descriptor;
4186}
4187
4190{
4192
4193 TRACE("iface %p, descriptor %p.\n", iface, descriptor);
4194
4196 {
4197 descriptor->ptr = (uint64_t)(intptr_t)heap->descriptors;
4198 }
4199 else
4200 {
4201 WARN("Heap %p is not shader-visible.\n", iface);
4202 descriptor->ptr = 0;
4203 }
4204
4205 return descriptor;
4206}
4207
4208static const struct ID3D12DescriptorHeapVtbl d3d12_descriptor_heap_vtbl =
4209{
4210 /* IUnknown methods */
4214 /* ID3D12Object methods */
4219 /* ID3D12DeviceChild methods */
4221 /* ID3D12DescriptorHeap methods */
4225};
4226
4228{
4236};
4237
4240{
4241 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4243 struct VkDescriptorPoolCreateInfo pool_desc;
4244 VkDevice vk_device = device->vk_device;
4246 VkResult vr;
4247
4248 for (set = 0, pool_desc.poolSizeCount = 0; set < ARRAY_SIZE(device->vk_descriptor_heap_layouts); ++set)
4249 {
4250 if (device->vk_descriptor_heap_layouts[set].applicable_heap_type == desc->Type
4251 && device->vk_descriptor_heap_layouts[set].vk_set_layout)
4252 {
4253 pool_sizes[pool_desc.poolSizeCount].type =
4254 (device->vk_info.EXT_mutable_descriptor_type && set == VKD3D_SET_INDEX_MUTABLE)
4255 ? VK_DESCRIPTOR_TYPE_MUTABLE_EXT : device->vk_descriptor_heap_layouts[set].type;
4256 pool_sizes[pool_desc.poolSizeCount++].descriptorCount = desc->NumDescriptors;
4257 }
4258 }
4259
4261 pool_desc.pNext = NULL;
4263 pool_desc.maxSets = pool_desc.poolSizeCount;
4264 pool_desc.pPoolSizes = pool_sizes;
4265 if ((vr = VK_CALL(vkCreateDescriptorPool(vk_device, &pool_desc, NULL, &descriptor_heap->vk_descriptor_pool))) < 0)
4266 ERR("Failed to create descriptor pool, vr %d.\n", vr);
4267
4268 return hresult_from_vk_result(vr);
4269}
4270
4272 struct d3d12_device *device, unsigned int set)
4273{
4274 struct d3d12_descriptor_heap_vk_set *descriptor_set = &descriptor_heap->vk_descriptor_sets[set];
4275 uint32_t variable_binding_size = descriptor_heap->desc.NumDescriptors;
4276 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4279 VkResult vr;
4280 HRESULT hr;
4281
4282 if (!device->vk_descriptor_heap_layouts[set].vk_set_layout)
4283 {
4284 /* Mutable descriptors are in use, and this set is unused. */
4285 if (!descriptor_heap->vk_descriptor_sets[VKD3D_SET_INDEX_MUTABLE].vk_set
4288 return hr;
4289 descriptor_set->vk_set = descriptor_heap->vk_descriptor_sets[VKD3D_SET_INDEX_MUTABLE].vk_set;
4290 descriptor_set->vk_type = device->vk_descriptor_heap_layouts[set].type;
4291 return S_OK;
4292 }
4293
4295 set_desc.pNext = &set_size;
4296 set_desc.descriptorPool = descriptor_heap->vk_descriptor_pool;
4297 set_desc.descriptorSetCount = 1;
4298 set_desc.pSetLayouts = &device->vk_descriptor_heap_layouts[set].vk_set_layout;
4300 set_size.pNext = NULL;
4301 set_size.descriptorSetCount = 1;
4302 set_size.pDescriptorCounts = &variable_binding_size;
4303 if ((vr = VK_CALL(vkAllocateDescriptorSets(device->vk_device, &set_desc, &descriptor_set->vk_set))) >= 0)
4304 {
4305 descriptor_set->vk_type = device->vk_descriptor_heap_layouts[set].type;
4306 return S_OK;
4307 }
4308
4309 ERR("Failed to allocate descriptor set, vr %d.\n", vr);
4310 return hresult_from_vk_result(vr);
4311}
4312
4315{
4317 HRESULT hr;
4318
4319 descriptor_heap->vk_descriptor_pool = VK_NULL_HANDLE;
4320 memset(descriptor_heap->vk_descriptor_sets, 0, sizeof(descriptor_heap->vk_descriptor_sets));
4321
4322 if (!descriptor_heap->use_vk_heaps || (desc->Type != D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV
4324 return S_OK;
4325
4327 return hr;
4328
4329 for (set = 0; set < ARRAY_SIZE(descriptor_heap->vk_descriptor_sets); ++set)
4330 {
4331 if (device->vk_descriptor_heap_layouts[set].applicable_heap_type == desc->Type
4333 return hr;
4334 }
4335
4336 return S_OK;
4337}
4338
4341{
4342 HRESULT hr;
4343
4344 descriptor_heap->ID3D12DescriptorHeap_iface.lpVtbl = &d3d12_descriptor_heap_vtbl;
4345 descriptor_heap->refcount = 1;
4347
4348 descriptor_heap->desc = *desc;
4349
4350 if (FAILED(hr = vkd3d_private_store_init(&descriptor_heap->private_store)))
4351 return hr;
4352
4353 descriptor_heap->use_vk_heaps = device->use_vk_heaps && (desc->Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE);
4355 {
4356 vkd3d_private_store_destroy(&descriptor_heap->private_store);
4357 return hr;
4358 }
4359 vkd3d_mutex_init(&descriptor_heap->vk_sets_mutex);
4360
4361 d3d12_device_add_ref(descriptor_heap->device = device);
4362
4363 return S_OK;
4364}
4365
4367 const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap)
4368{
4369 size_t max_descriptor_count, descriptor_size;
4371 struct d3d12_desc *dst;
4372 unsigned int i;
4373 HRESULT hr;
4374
4375 if (!(descriptor_size = d3d12_device_get_descriptor_handle_increment_size(device, desc->Type)))
4376 {
4377 WARN("No descriptor size for descriptor type %#x.\n", desc->Type);
4378 return E_INVALIDARG;
4379 }
4380
4383 {
4384 WARN("RTV/DSV descriptor heaps cannot be shader visible.\n");
4385 return E_INVALIDARG;
4386 }
4387
4388 max_descriptor_count = (~(size_t)0 - sizeof(*object)) / descriptor_size;
4389 if (desc->NumDescriptors > max_descriptor_count)
4390 {
4391 WARN("Invalid descriptor count %u (max %zu).\n", desc->NumDescriptors, max_descriptor_count);
4392 return E_OUTOFMEMORY;
4393 }
4394
4395 if (!(object = vkd3d_malloc(offsetof(struct d3d12_descriptor_heap,
4396 descriptors[descriptor_size * desc->NumDescriptors]))))
4397 return E_OUTOFMEMORY;
4398
4400 {
4401 vkd3d_free(object);
4402 return hr;
4403 }
4404
4406 {
4407 dst = (struct d3d12_desc *)object->descriptors;
4408 for (i = 0; i < desc->NumDescriptors; ++i)
4409 {
4410 memset(&dst[i].s, 0, sizeof(dst[i].s));
4411 dst[i].index = i;
4412 dst[i].next = 0;
4413 }
4414 object->dirty_list_head = UINT_MAX;
4415
4416 if (object->use_vk_heaps && FAILED(hr = d3d12_device_add_descriptor_heap(device, object)))
4417 {
4418 vkd3d_free(object);
4419 return hr;
4420 }
4421 }
4422 else
4423 {
4424 memset(object->descriptors, 0, descriptor_size * desc->NumDescriptors);
4425 }
4426
4427 TRACE("Created descriptor heap %p.\n", object);
4428
4429 *descriptor_heap = object;
4430
4431 return S_OK;
4432}
4433
4434/* ID3D12QueryHeap */
4436{
4438}
4439
4441 REFIID iid, void **out)
4442{
4443 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
4444
4445 if (IsEqualGUID(iid, &IID_ID3D12QueryHeap)
4446 || IsEqualGUID(iid, &IID_ID3D12Pageable)
4447 || IsEqualGUID(iid, &IID_ID3D12DeviceChild)
4448 || IsEqualGUID(iid, &IID_ID3D12Object)
4449 || IsEqualGUID(iid, &IID_IUnknown))
4450 {
4451 ID3D12QueryHeap_AddRef(iface);
4452 *out = iface;
4453 return S_OK;
4454 }
4455
4456 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
4457
4458 *out = NULL;
4459 return E_NOINTERFACE;
4460}
4461
4463{
4465 unsigned int refcount = vkd3d_atomic_increment_u32(&heap->refcount);
4466
4467 TRACE("%p increasing refcount to %u.\n", heap, refcount);
4468
4469 return refcount;
4470}
4471
4473{
4475 unsigned int refcount = vkd3d_atomic_decrement_u32(&heap->refcount);
4476
4477 TRACE("%p decreasing refcount to %u.\n", heap, refcount);
4478
4479 if (!refcount)
4480 {
4481 struct d3d12_device *device = heap->device;
4482 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4483
4484 vkd3d_private_store_destroy(&heap->private_store);
4485
4486 VK_CALL(vkDestroyQueryPool(device->vk_device, heap->vk_query_pool, NULL));
4487
4489
4491 }
4492
4493 return refcount;
4494}
4495
4497 REFGUID guid, UINT *data_size, void *data)
4498{
4500
4501 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
4502
4503 return vkd3d_get_private_data(&heap->private_store, guid, data_size, data);
4504}
4505
4507 REFGUID guid, UINT data_size, const void *data)
4508{
4510
4511 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
4512
4513 return vkd3d_set_private_data(&heap->private_store, guid, data_size, data);
4514}
4515
4517 REFGUID guid, const IUnknown *data)
4518{
4520
4521 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
4522
4523 return vkd3d_set_private_data_interface(&heap->private_store, guid, data);
4524}
4525
4527{
4529
4530 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, heap->device->wchar_size));
4531
4532 return vkd3d_set_vk_object_name(heap->device, (uint64_t)heap->vk_query_pool,
4534}
4535
4537{
4539
4540 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
4541
4542 return d3d12_device_query_interface(heap->device, iid, device);
4543}
4544
4545static const struct ID3D12QueryHeapVtbl d3d12_query_heap_vtbl =
4546{
4547 /* IUnknown methods */
4551 /* ID3D12Object methods */
4556 /* ID3D12DeviceChild methods */
4558};
4559
4561{
4562 if (!iface)
4563 return NULL;
4564 VKD3D_ASSERT(iface->lpVtbl == &d3d12_query_heap_vtbl);
4565 return impl_from_ID3D12QueryHeap(iface);
4566}
4567
4569 struct d3d12_query_heap **heap)
4570{
4571 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4572 struct d3d12_query_heap *object;
4573 VkQueryPoolCreateInfo pool_info;
4574 unsigned int element_count;
4575 VkResult vr;
4576 HRESULT hr;
4577
4578 element_count = DIV_ROUND_UP(desc->Count, sizeof(*object->availability_mask) * CHAR_BIT);
4580 return E_OUTOFMEMORY;
4581
4582 object->ID3D12QueryHeap_iface.lpVtbl = &d3d12_query_heap_vtbl;
4583 object->refcount = 1;
4584 object->device = device;
4585 memset(object->availability_mask, 0, element_count * sizeof(*object->availability_mask));
4586
4588 pool_info.pNext = NULL;
4589 pool_info.flags = 0;
4590 pool_info.queryCount = desc->Count;
4591
4592 switch (desc->Type)
4593 {
4596 pool_info.pipelineStatistics = 0;
4597 break;
4598
4601 pool_info.pipelineStatistics = 0;
4602 break;
4603
4617 break;
4618
4620 if (!device->vk_info.transform_feedback_queries)
4621 {
4622 FIXME("Transform feedback queries are not supported by Vulkan implementation.\n");
4623 vkd3d_free(object);
4624 return E_NOTIMPL;
4625 }
4626
4628 pool_info.pipelineStatistics = 0;
4629 break;
4630
4631 default:
4632 WARN("Invalid query heap type %u.\n", desc->Type);
4633 vkd3d_free(object);
4634 return E_INVALIDARG;
4635 }
4636
4637 if (FAILED(hr = vkd3d_private_store_init(&object->private_store)))
4638 {
4639 vkd3d_free(object);
4640 return hr;
4641 }
4642
4643 if ((vr = VK_CALL(vkCreateQueryPool(device->vk_device, &pool_info, NULL, &object->vk_query_pool))) < 0)
4644 {
4645 WARN("Failed to create Vulkan query pool, vr %d.\n", vr);
4646 vkd3d_private_store_destroy(&object->private_store);
4647 vkd3d_free(object);
4648 return hresult_from_vk_result(vr);
4649 }
4650
4652
4653 TRACE("Created query heap %p.\n", object);
4654
4655 *heap = object;
4656
4657 return S_OK;
4658}
4659
4661 struct d3d12_device *device)
4662{
4663 const bool use_sparse_resources = device->vk_info.sparse_properties.residencyNonResidentStrict;
4664 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4665 static const VkClearColorValue clear_color = {{0}};
4666 VkCommandBufferAllocateInfo command_buffer_info;
4667 VkCommandPool vk_command_pool = VK_NULL_HANDLE;
4668 VkCommandPoolCreateInfo command_pool_info;
4669 VkDevice vk_device = device->vk_device;
4670 VkCommandBufferBeginInfo begin_info;
4671 VkCommandBuffer vk_command_buffer;
4672 VkFence vk_fence = VK_NULL_HANDLE;
4674 VkImageMemoryBarrier barrier;
4675 VkFenceCreateInfo fence_info;
4676 struct vkd3d_queue *queue;
4677 VkSubmitInfo submit_info;
4678 VkQueue vk_queue;
4679 VkResult vr;
4680
4682
4684 command_pool_info.pNext = NULL;
4685 command_pool_info.flags = 0;
4686 command_pool_info.queueFamilyIndex = queue->vk_family_index;
4687
4688 if ((vr = VK_CALL(vkCreateCommandPool(vk_device, &command_pool_info, NULL, &vk_command_pool))) < 0)
4689 {
4690 WARN("Failed to create Vulkan command pool, vr %d.\n", vr);
4691 goto done;
4692 }
4693
4695 command_buffer_info.pNext = NULL;
4696 command_buffer_info.commandPool = vk_command_pool;
4697 command_buffer_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
4698 command_buffer_info.commandBufferCount = 1;
4699
4700 if ((vr = VK_CALL(vkAllocateCommandBuffers(vk_device, &command_buffer_info, &vk_command_buffer))) < 0)
4701 {
4702 WARN("Failed to allocate Vulkan command buffer, vr %d.\n", vr);
4703 goto done;
4704 }
4705
4707 begin_info.pNext = NULL;
4709 begin_info.pInheritanceInfo = NULL;
4710
4711 if ((vr = VK_CALL(vkBeginCommandBuffer(vk_command_buffer, &begin_info))) < 0)
4712 {
4713 WARN("Failed to begin command buffer, vr %d.\n", vr);
4714 goto done;
4715 }
4716
4717 /* fill buffer */
4718 VK_CALL(vkCmdFillBuffer(vk_command_buffer, null_resource->vk_buffer, 0, VK_WHOLE_SIZE, 0x00000000));
4719
4720 if (use_sparse_resources)
4721 {
4722 /* transition 2D UAV image */
4724 barrier.pNext = NULL;
4725 barrier.srcAccessMask = 0;
4726 barrier.dstAccessMask = 0;
4731 barrier.image = null_resource->vk_2d_storage_image;
4733 barrier.subresourceRange.baseMipLevel = 0;
4735 barrier.subresourceRange.baseArrayLayer = 0;
4737
4738 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
4740 0, NULL, 0, NULL, 1, &barrier));
4741 }
4742 else
4743 {
4744 /* fill UAV buffer */
4745 VK_CALL(vkCmdFillBuffer(vk_command_buffer,
4746 null_resource->vk_storage_buffer, 0, VK_WHOLE_SIZE, 0x00000000));
4747
4748 /* clear 2D UAV image */
4750 barrier.pNext = NULL;
4751 barrier.srcAccessMask = 0;
4757 barrier.image = null_resource->vk_2d_storage_image;
4759 barrier.subresourceRange.baseMipLevel = 0;
4761 barrier.subresourceRange.baseArrayLayer = 0;
4763
4764 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
4766 0, NULL, 0, NULL, 1, &barrier));
4767
4768 range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
4769 range.baseMipLevel = 0;
4770 range.levelCount = 1;
4771 range.baseArrayLayer = 0;
4772 range.layerCount = 1;
4773
4774 VK_CALL(vkCmdClearColorImage(vk_command_buffer,
4775 null_resource->vk_2d_storage_image, VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range));
4776 }
4777
4778 /* transition 2D SRV image */
4780 barrier.pNext = NULL;
4781 barrier.srcAccessMask = 0;
4782 barrier.dstAccessMask = 0;
4787 barrier.image = null_resource->vk_2d_image;
4789 barrier.subresourceRange.baseMipLevel = 0;
4791 barrier.subresourceRange.baseArrayLayer = 0;
4793
4794 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
4796 0, NULL, 0, NULL, 1, &barrier));
4797
4798 if ((vr = VK_CALL(vkEndCommandBuffer(vk_command_buffer))) < 0)
4799 {
4800 WARN("Failed to end command buffer, vr %d.\n", vr);
4801 goto done;
4802 }
4803
4805 fence_info.pNext = NULL;
4806 fence_info.flags = 0;
4807
4808 if ((vr = VK_CALL(vkCreateFence(device->vk_device, &fence_info, NULL, &vk_fence))) < 0)
4809 {
4810 WARN("Failed to create Vulkan fence, vr %d.\n", vr);
4811 goto done;
4812 }
4813
4815 submit_info.pNext = NULL;
4816 submit_info.waitSemaphoreCount = 0;
4817 submit_info.pWaitSemaphores = NULL;
4818 submit_info.pWaitDstStageMask = NULL;
4819 submit_info.commandBufferCount = 1;
4820 submit_info.pCommandBuffers = &vk_command_buffer;
4821 submit_info.signalSemaphoreCount = 0;
4822 submit_info.pSignalSemaphores = NULL;
4823
4825 {
4826 WARN("Failed to acquire queue %p.\n", queue);
4827 goto done;
4828 }
4829
4830 if ((vr = VK_CALL(vkQueueSubmit(vk_queue, 1, &submit_info, vk_fence))) < 0)
4831 ERR("Failed to submit, vr %d.\n", vr);
4832
4834
4835 vr = VK_CALL(vkWaitForFences(device->vk_device, 1, &vk_fence, VK_FALSE, ~(uint64_t)0));
4836 if (vr != VK_SUCCESS)
4837 WARN("Failed to wait for fence, vr %d.\n", vr);
4838
4839done:
4840 VK_CALL(vkDestroyCommandPool(vk_device, vk_command_pool, NULL));
4841 VK_CALL(vkDestroyFence(vk_device, vk_fence, NULL));
4842
4843 return hresult_from_vk_result(vr);
4844}
4845
4847 struct d3d12_device *device)
4848{
4849 const bool use_sparse_resources = device->vk_info.sparse_properties.residencyNonResidentStrict;
4850 D3D12_HEAP_PROPERTIES heap_properties;
4851 D3D12_RESOURCE_DESC1 resource_desc;
4852 HRESULT hr;
4853
4854 TRACE("Creating resources for NULL views.\n");
4855
4856 memset(null_resources, 0, sizeof(*null_resources));
4857
4858 if (device->vk_info.EXT_robustness2)
4859 return S_OK;
4860
4861 memset(&heap_properties, 0, sizeof(heap_properties));
4862 heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
4863
4864 /* buffer */
4866 resource_desc.Alignment = 0;
4867 resource_desc.Width = VKD3D_NULL_BUFFER_SIZE;
4868 resource_desc.Height = 1;
4869 resource_desc.DepthOrArraySize = 1;
4870 resource_desc.MipLevels = 1;
4871 resource_desc.Format = DXGI_FORMAT_UNKNOWN;
4872 resource_desc.SampleDesc.Count = 1;
4873 resource_desc.SampleDesc.Quality = 0;
4874 resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
4875 resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
4876 memset(&resource_desc.SamplerFeedbackMipRegion, 0, sizeof(resource_desc.SamplerFeedbackMipRegion));
4877
4878 if (FAILED(hr = vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
4879 &resource_desc, &null_resources->vk_buffer)))
4880 goto fail;
4881 if (FAILED(hr = vkd3d_allocate_buffer_memory(device, null_resources->vk_buffer,
4882 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_buffer_memory, NULL, NULL)))
4883 goto fail;
4884
4885 /* buffer UAV */
4887
4888 if (FAILED(hr = vkd3d_create_buffer(device, use_sparse_resources ? NULL : &heap_properties, D3D12_HEAP_FLAG_NONE,
4889 &resource_desc, &null_resources->vk_storage_buffer)))
4890 goto fail;
4891 if (!use_sparse_resources && FAILED(hr = vkd3d_allocate_buffer_memory(device, null_resources->vk_storage_buffer,
4892 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_storage_buffer_memory, NULL, NULL)))
4893 goto fail;
4894
4895 /* 2D SRV */
4897 resource_desc.Alignment = 0;
4898 resource_desc.Width = 1;
4899 resource_desc.Height = 1;
4900 resource_desc.DepthOrArraySize = 1;
4901 resource_desc.MipLevels = 1;
4902 resource_desc.Format = VKD3D_NULL_VIEW_FORMAT;
4903 resource_desc.SampleDesc.Count = 1;
4904 resource_desc.SampleDesc.Quality = 0;
4905 resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
4906 resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
4907
4908 if (FAILED(hr = vkd3d_create_image(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
4909 &resource_desc, NULL, &null_resources->vk_2d_image)))
4910 goto fail;
4912 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_2d_image_memory, NULL, NULL)))
4913 goto fail;
4914
4915 /* 2D UAV */
4917 resource_desc.Alignment = 0;
4918 resource_desc.Width = 1;
4919 resource_desc.Height = 1;
4920 resource_desc.DepthOrArraySize = 1;
4921 resource_desc.MipLevels = 1;
4922 resource_desc.Format = VKD3D_NULL_VIEW_FORMAT;
4923 resource_desc.SampleDesc.Count = 1;
4924 resource_desc.SampleDesc.Quality = 0;
4925 resource_desc.Layout = use_sparse_resources
4928
4929 if (FAILED(hr = vkd3d_create_image(device, use_sparse_resources ? NULL : &heap_properties, D3D12_HEAP_FLAG_NONE,
4930 &resource_desc, NULL, &null_resources->vk_2d_storage_image)))
4931 goto fail;
4932 if (!use_sparse_resources && FAILED(hr = vkd3d_allocate_image_memory(device, null_resources->vk_2d_storage_image,
4933 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_2d_storage_image_memory, NULL, NULL)))
4934 goto fail;
4935
4936 /* set Vulkan object names */
4942 VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, "NULL UAV buffer");
4944 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "NULL 2D SRV image");
4946 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL 2D SRV memory");
4948 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "NULL 2D UAV image");
4949 if (!use_sparse_resources)
4950 {
4952 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL UAV buffer memory");
4954 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL 2D UAV memory");
4955 }
4956
4957 return vkd3d_init_null_resources_data(null_resources, device);
4958
4959fail:
4960 ERR("Failed to initialise NULL resources, hr %s.\n", debugstr_hresult(hr));
4961 vkd3d_destroy_null_resources(null_resources, device);
4962 return hr;
4963}
4964
4966 struct d3d12_device *device)
4967{
4968 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4969
4970 VK_CALL(vkDestroyBuffer(device->vk_device, null_resources->vk_buffer, NULL));
4971 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_buffer_memory, NULL));
4972
4973 VK_CALL(vkDestroyBuffer(device->vk_device, null_resources->vk_storage_buffer, NULL));
4974 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_storage_buffer_memory, NULL));
4975
4976 VK_CALL(vkDestroyImage(device->vk_device, null_resources->vk_2d_image, NULL));
4977 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_2d_image_memory, NULL));
4978
4979 VK_CALL(vkDestroyImage(device->vk_device, null_resources->vk_2d_storage_image, NULL));
4980 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_2d_storage_image_memory, NULL));
4981
4982 memset(null_resources, 0, sizeof(*null_resources));
4983}
struct outqueuenode * head
Definition: adnsresfilter.c:66
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
Definition: align.cpp:48
#define ARRAY_SIZE(A)
Definition: main.h:20
static void set_size(float size)
Definition: wordpad.c:316
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
Definition: _set.h:50
void vkd3d_queue_release(struct vkd3d_queue *queue)
Definition: command.c:101
struct vkd3d_queue * d3d12_device_get_vkd3d_queue(struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type)
Definition: command.c:1800
VkQueue vkd3d_queue_acquire(struct vkd3d_queue *queue)
Definition: command.c:91
D3D12_STATIC_BORDER_COLOR
Definition: d3d12.idl:1221
@ D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK
Definition: d3d12.idl:1222
@ D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE
Definition: d3d12.idl:1224
@ D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK
Definition: d3d12.idl:1223
@ D3D12_FILTER_REDUCTION_TYPE_MINIMUM
Definition: d3d12.idl:1284
@ D3D12_FILTER_REDUCTION_TYPE_MAXIMUM
Definition: d3d12.idl:1285
D3D12_RESOURCE_STATES
Definition: d3d12.idl:903
@ D3D12_RESOURCE_STATE_GENERIC_READ
Definition: d3d12.idl:921
@ D3D12_RESOURCE_STATE_COPY_DEST
Definition: d3d12.idl:915
@ D3D12_RESOURCE_STATE_RENDER_TARGET
Definition: d3d12.idl:907
@ D3D12_RESOURCE_STATE_COMMON
Definition: d3d12.idl:904
D3D12_TEXTURE_ADDRESS_MODE
Definition: d3d12.idl:1329
@ D3D12_TEXTURE_ADDRESS_MODE_BORDER
Definition: d3d12.idl:1333
@ D3D12_TEXTURE_ADDRESS_MODE_WRAP
Definition: d3d12.idl:1330
@ D3D12_TEXTURE_ADDRESS_MODE_CLAMP
Definition: d3d12.idl:1332
@ D3D12_TEXTURE_ADDRESS_MODE_MIRROR
Definition: d3d12.idl:1331
@ D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE
Definition: d3d12.idl:1334
D3D12_SHADER_COMPONENT_MAPPING
Definition: d3d12.idl:1475
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1
Definition: d3d12.idl:1477
@ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0
Definition: d3d12.idl:1480
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3
Definition: d3d12.idl:1479
@ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1
Definition: d3d12.idl:1481
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0
Definition: d3d12.idl:1476
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2
Definition: d3d12.idl:1478
const UINT D3D12_PACKED_TILE
Definition: d3d12.idl:298
D3D12_FILTER_TYPE
Definition: d3d12.idl:1268
@ D3D12_FILTER_TYPE_LINEAR
Definition: d3d12.idl:1270
@ D3D12_FILTER_TYPE_POINT
Definition: d3d12.idl:1269
@ D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY
Definition: d3d12.idl:1682
@ D3D12_RTV_DIMENSION_TEXTURE3D
Definition: d3d12.idl:1683
@ D3D12_RTV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1679
@ D3D12_RTV_DIMENSION_TEXTURE2DMS
Definition: d3d12.idl:1681
@ D3D12_RTV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1680
@ D3D12_COMMAND_LIST_TYPE_DIRECT
Definition: d3d12.idl:2189
@ D3D12_MEMORY_POOL_UNKNOWN
Definition: d3d12.idl:797
@ D3D12_MEMORY_POOL_L1
Definition: d3d12.idl:799
D3D12_RESOURCE_DIMENSION
Definition: d3d12.idl:981
@ D3D12_RESOURCE_DIMENSION_BUFFER
Definition: d3d12.idl:983
@ D3D12_RESOURCE_DIMENSION_TEXTURE1D
Definition: d3d12.idl:984
@ D3D12_RESOURCE_DIMENSION_TEXTURE3D
Definition: d3d12.idl:986
@ D3D12_RESOURCE_DIMENSION_TEXTURE2D
Definition: d3d12.idl:985
D3D12_RESOURCE_FLAGS
Definition: d3d12.idl:998
@ D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS
Definition: d3d12.idl:1002
@ D3D12_RESOURCE_FLAG_NONE
Definition: d3d12.idl:999
@ D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL
Definition: d3d12.idl:1001
@ D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER
Definition: d3d12.idl:1004
@ D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE
Definition: d3d12.idl:1003
@ D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS
Definition: d3d12.idl:1005
@ D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET
Definition: d3d12.idl:1000
const UINT D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT
Definition: d3d12.idl:140
@ D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY
Definition: d3d12.idl:1761
@ D3D12_DSV_DIMENSION_TEXTURE2DMS
Definition: d3d12.idl:1760
@ D3D12_DSV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1758
@ D3D12_DSV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1759
@ D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE
Definition: d3d12.idl:1431
const UINT D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES
Definition: d3d12.idl:421
D3D12_BUFFER_UAV_FLAGS
Definition: d3d12.idl:1610
@ D3D12_BUFFER_UAV_FLAG_RAW
Definition: d3d12.idl:1612
D3D12_BUFFER_SRV_FLAGS
Definition: d3d12.idl:1468
@ D3D12_BUFFER_SRV_FLAG_RAW
Definition: d3d12.idl:1470
@ D3D12_UAV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1604
@ D3D12_UAV_DIMENSION_TEXTURE3D
Definition: d3d12.idl:1606
@ D3D12_UAV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1605
@ D3D12_UAV_DIMENSION_TEXTURE1D
Definition: d3d12.idl:1602
@ D3D12_UAV_DIMENSION_BUFFER
Definition: d3d12.idl:1601
D3D12_HEAP_FLAGS
Definition: d3d12.idl:812
@ D3D12_HEAP_FLAG_ALLOW_DISPLAY
Definition: d3d12.idl:816
@ D3D12_HEAP_FLAG_NONE
Definition: d3d12.idl:813
D3D12_FILTER
Definition: d3d12.idl:1228
@ D3D12_CPU_PAGE_PROPERTY_UNKNOWN
Definition: d3d12.idl:789
@ D3D12_CPU_PAGE_PROPERTY_WRITE_BACK
Definition: d3d12.idl:792
@ D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE
Definition: d3d12.idl:791
@ D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE
Definition: d3d12.idl:790
@ D3D12_TEXTURE_LAYOUT_UNKNOWN
Definition: d3d12.idl:991
@ D3D12_TEXTURE_LAYOUT_ROW_MAJOR
Definition: d3d12.idl:992
@ D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE
Definition: d3d12.idl:993
const UINT D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT
Definition: d3d12.idl:380
@ D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY
Definition: d3d12.idl:1460
@ D3D12_SRV_DIMENSION_TEXTURECUBE
Definition: d3d12.idl:1462
@ D3D12_SRV_DIMENSION_TEXTURE3D
Definition: d3d12.idl:1461
@ D3D12_SRV_DIMENSION_TEXTURECUBEARRAY
Definition: d3d12.idl:1463
@ D3D12_SRV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1458
@ D3D12_SRV_DIMENSION_TEXTURE2DMS
Definition: d3d12.idl:1459
@ D3D12_SRV_DIMENSION_BUFFER
Definition: d3d12.idl:1454
@ D3D12_SRV_DIMENSION_TEXTURE1D
Definition: d3d12.idl:1455
@ D3D12_SRV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1457
D3D12_ROOT_PARAMETER_TYPE
Definition: d3d12.idl:1176
@ D3D12_ROOT_PARAMETER_TYPE_UAV
Definition: d3d12.idl:1181
@ D3D12_QUERY_HEAP_TYPE_TIMESTAMP
Definition: d3d12.idl:3073
@ D3D12_QUERY_HEAP_TYPE_SO_STATISTICS
Definition: d3d12.idl:3075
@ D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS
Definition: d3d12.idl:3074
@ D3D12_QUERY_HEAP_TYPE_OCCLUSION
Definition: d3d12.idl:3072
@ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV
Definition: d3d12.idl:1421
@ D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER
Definition: d3d12.idl:1422
@ D3D12_DESCRIPTOR_HEAP_TYPE_RTV
Definition: d3d12.idl:1423
@ D3D12_DESCRIPTOR_HEAP_TYPE_DSV
Definition: d3d12.idl:1424
D3D12_COMPARISON_FUNC
Definition: d3d12.idl:1338
const UINT D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT
Definition: d3d12.idl:69
const UINT D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT
Definition: d3d12.idl:138
D3D12_HEAP_TYPE
Definition: d3d12.idl:780
@ D3D12_HEAP_TYPE_DEFAULT
Definition: d3d12.idl:781
@ D3D12_HEAP_TYPE_READBACK
Definition: d3d12.idl:783
@ D3D12_HEAP_TYPE_UPLOAD
Definition: d3d12.idl:782
@ D3D12_HEAP_TYPE_CUSTOM
Definition: d3d12.idl:784
UINT64 D3D12_GPU_VIRTUAL_ADDRESS
Definition: d3d12.idl:1443
range
Definition: d3dx9_private.h:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
size_t const element_size
Definition: debug_heap.cpp:510
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
DXGI_FORMAT dxgi_format
Definition: texture.c:51
#define CHAR_BIT
Definition: cabinet.h:45
GUID guid
Definition: version.c:147
int intptr_t
Definition: corecrt.h:176
unsigned int size_t
Definition: corecrt.h:203
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
#define PRIx64
Definition: inttypes.h:29
#define PRIu64
Definition: inttypes.h:28
#define UINT_MAX
Definition: limits.h:27
unsigned char uint8_t
Definition: stdint.h:33
static HRESULT hresult_from_vk_result(VkResult vr)
Definition: swapchain.c:1114
DXGI_FORMAT
Definition: dxgiformat.idl:22
@ DXGI_FORMAT_UNKNOWN
Definition: dxgiformat.idl:23
@ DXGI_FORMAT_A8_UNORM
Definition: dxgiformat.idl:88
@ DXGI_FORMAT_R32_TYPELESS
Definition: dxgiformat.idl:62
@ DXGI_FORMAT_R32_UINT
Definition: dxgiformat.idl:65
@ DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
Definition: dxgiformat.idl:116
@ DXGI_FORMAT_B8G8R8X8_UNORM
Definition: dxgiformat.idl:111
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLuint GLenum swizzle
Definition: glext.h:9511
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLuint components
Definition: glext.h:9620
GLintptr offset
Definition: glext.h:5920
GLuint sampler
Definition: glext.h:7283
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum mode
Definition: glext.h:6217
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
unsigned int UINT
Definition: sysinfo.c:13
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static BOOL is_null(jsval_t v)
Definition: jsval.h:185
#define resource
Definition: kernel32.h:9
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static ULONG ** element_count
Definition: exception.c:124
static int
Definition: resource.c:26
#define min(a, b)
Definition: monoChain.cc:55
#define uint32_t
Definition: nsiface.idl:61
#define uint64_t
Definition: nsiface.idl:62
short WCHAR
Definition: pedump.c:58
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
static unsigned __int64 next
Definition: rand_nt.c:6
#define offsetof(TYPE, MEMBER)
descriptor
Definition: scsi.h:3997
#define memset(x, y, z)
Definition: compat.h:39
void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2565
void * vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2495
HRESULT d3d12_device_add_descriptor_heap(struct d3d12_device *device, struct d3d12_descriptor_heap *heap)
Definition: device.c:5569
D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_allocator *allocator, size_t alignment, uint64_t size, void *ptr)
Definition: device.c:2424
struct d3d12_device * unsafe_impl_from_ID3D12Device9(ID3D12Device9 *iface)
Definition: device.c:5398
bool d3d12_device_is_uma(struct d3d12_device *device, bool *coherent)
Definition: device.c:3358
void d3d12_device_remove_descriptor_heap(struct d3d12_device *device, struct d3d12_descriptor_heap *heap)
Definition: device.c:5586
static ULONG d3d12_resource_incref(struct d3d12_resource *resource)
Definition: resource.c:1004
ULONG vkd3d_resource_decref(ID3D12Resource *resource)
Definition: resource.c:2323
static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resource2 *iface, void *dst_data, UINT dst_row_pitch, UINT dst_slice_pitch, UINT src_sub_resource, const D3D12_BOX *src_box)
Definition: resource.c:1602
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource2 *iface, const WCHAR *name)
Definition: resource.c:1352
static HRESULT STDMETHODCALLTYPE d3d12_heap_GetDevice(ID3D12Heap *iface, REFIID iid, void **device)
Definition: resource.c:405
static void * d3d12_resource_get_map_ptr(struct d3d12_resource *resource)
Definition: resource.c:1382
static struct d3d12_heap * impl_from_ID3D12Heap(ID3D12Heap *iface)
Definition: resource.c:281
static D3D12_RESOURCE_DESC *STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource2 *iface, D3D12_RESOURCE_DESC *resource_desc)
Definition: resource.c:1497
static HRESULT vkd3d_select_memory_type(struct d3d12_device *device, uint32_t memory_type_mask, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, unsigned int *type_index)
Definition: resource.c:39
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc)
Definition: resource.c:641
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_QueryInterface(ID3D12QueryHeap *iface, REFIID iid, void **out)
Definition: resource.c:4440
static void descriptor_writes_free_object_refs(struct descriptor_writes *writes, struct d3d12_device *device)
Definition: resource.c:2485
static ULONG d3d12_resource_decref(struct d3d12_resource *resource)
Definition: resource.c:1013
void d3d12_desc_create_cbv(struct d3d12_desc *descriptor, struct d3d12_device *device, const D3D12_CONSTANT_BUFFER_VIEW_DESC *desc)
Definition: resource.c:3140
static VkBorderColor vk_border_colour_from_d3d12(D3D12_STATIC_BORDER_COLOR colour)
Definition: resource.c:3692
static void vkd3d_desc_object_cache_push(struct vkd3d_desc_object_cache *cache, void *object)
Definition: resource.c:2365
static bool d3d12_resource_validate_heap_properties(const struct d3d12_resource *resource, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_RESOURCE_STATES initial_state)
Definition: resource.c:1938
void d3d12_dsv_desc_create_dsv(struct d3d12_dsv_desc *dsv_desc, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_DEPTH_STENCIL_VIEW_DESC *desc)
Definition: resource.c:3931
static unsigned int vkd3d_view_flags_from_d3d12_buffer_uav_flags(D3D12_BUFFER_UAV_FLAGS flags)
Definition: resource.c:3412
HRESULT d3d12_reserved_resource_create(struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
Definition: resource.c:2240
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource2 *iface, REFGUID guid, UINT *data_size, void *data)
Definition: resource.c:1322
static void vkd3d_create_texture_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3531
static bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *properties)
Definition: resource.c:27
static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource2 *iface, REFIID riid, void **object)
Definition: resource.c:1261
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_GetDevice(ID3D12QueryHeap *iface, REFIID iid, void **device)
Definition: resource.c:4536
static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource2 *iface)
Definition: resource.c:1285
static void vkd3d_create_null_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3421
static const struct ID3D12HeapVtbl d3d12_heap_vtbl
Definition: resource.c:425
static void vkd3d_create_buffer_srv(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
Definition: resource.c:3257
static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC1 *desc, const struct vkd3d_format *format)
Definition: resource.c:1815
static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device, struct d3d12_resource *resource, struct d3d12_heap *heap, uint64_t heap_offset)
Definition: resource.c:2147
void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_RENDER_TARGET_VIEW_DESC *desc)
Definition: resource.c:3835
static void d3d12_heap_resource_destroyed(struct d3d12_heap *heap)
Definition: resource.c:359
static void d3d12_rtv_desc_destroy(struct d3d12_rtv_desc *rtv, struct d3d12_device *device)
Definition: resource.c:3826
static HRESULT vkd3d_allocate_resource_memory(struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
Definition: resource.c:2096
static const struct ID3D12QueryHeapVtbl d3d12_query_heap_vtbl
Definition: resource.c:4545
void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_descriptor_heap *dst_heap, struct d3d12_device *device)
Definition: resource.c:2723
static VkMemoryPropertyFlags d3d12_heap_get_memory_property_flags(const struct d3d12_heap *heap)
Definition: resource.c:474
static void d3d12_resource_get_level_box(const struct d3d12_resource *resource, unsigned int level, D3D12_BOX *box)
Definition: resource.c:1060
static D3D12_DESCRIPTOR_HEAP_DESC *STDMETHODCALLTYPE d3d12_descriptor_heap_GetDesc(ID3D12DescriptorHeap *iface, D3D12_DESCRIPTOR_HEAP_DESC *desc)
Definition: resource.c:4165
uint64_t object_global_serial_id
Definition: resource.c:25
static HRESULT STDMETHODCALLTYPE d3d12_heap_QueryInterface(ID3D12Heap *iface, REFIID iid, void **object)
Definition: resource.c:286
static bool vkd3d_create_vk_buffer_view(struct d3d12_device *device, VkBuffer vk_buffer, const struct vkd3d_format *format, VkDeviceSize offset, VkDeviceSize range, VkBufferView *vk_view)
Definition: resource.c:2761
#define VKD3D_DESCRIPTOR_WRITE_BUFFER_SIZE
Definition: resource.c:2472
HRESULT d3d12_heap_create(struct d3d12_device *device, const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource, ID3D12ProtectedResourceSession *protected_session, struct d3d12_heap **heap)
Definition: resource.c:576
static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource2 *iface)
Definition: resource.c:1303
static D3D12_STATIC_BORDER_COLOR d3d12_static_border_colour(const float *colour)
Definition: resource.c:3753
static void vkd3d_create_buffer_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, struct d3d12_resource *counter_resource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3485
void d3d12_desc_flush_vk_heap_updates_locked(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device)
Definition: resource.c:2639
HRESULT vkd3d_create_image_resource(ID3D12Device *device, const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
Definition: resource.c:2264
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetPrivateDataInterface(ID3D12QueryHeap *iface, REFGUID guid, const IUnknown *data)
Definition: resource.c:4516
static VkSamplerMipmapMode vk_mipmap_mode_from_d3d12(D3D12_FILTER_TYPE type)
Definition: resource.c:3655
static HRESULT d3d12_descriptor_heap_init(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc)
Definition: resource.c:4339
static void descriptor_heap_write_atomic(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_device *device)
Definition: resource.c:2700
static struct vkd3d_cbuffer_desc * vkd3d_cbuffer_desc_create(struct d3d12_device *device)
Definition: resource.c:2390
static void d3d12_desc_destroy(struct d3d12_desc *descriptor, struct d3d12_device *device)
Definition: resource.c:2716
static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resource2 *iface, UINT dst_sub_resource, const D3D12_BOX *dst_box, const void *src_data, UINT src_row_pitch, UINT src_slice_pitch)
Definition: resource.c:1517
static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(ID3D12Resource2 *iface)
Definition: resource.c:1508
static VkImageAspectFlags vk_image_aspect_flags_from_d3d12_plane_slice(const struct vkd3d_format *format, unsigned int plane_slice)
Definition: resource.c:3281
static ULONG STDMETHODCALLTYPE d3d12_heap_Release(ID3D12Heap *iface)
Definition: resource.c:345
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_GetPrivateData(ID3D12QueryHeap *iface, REFGUID guid, UINT *data_size, void *data)
Definition: resource.c:4496
static bool vkd3d_is_linear_tiling_supported(const struct d3d12_device *device, VkImageCreateInfo *image_info)
Definition: resource.c:755
static HRESULT d3d12_resource_create(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
Definition: resource.c:2073
HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device)
Definition: resource.c:1850
#define VKD3D_NULL_VIEW_FORMAT
Definition: resource.c:23
static const struct ID3D12Resource2Vtbl d3d12_resource_vtbl
Definition: resource.c:1743
static void d3d12_dsv_desc_destroy(struct d3d12_dsv_desc *dsv, struct d3d12_device *device)
Definition: resource.c:3922
void vkd3d_destroy_null_resources(struct vkd3d_null_resources *null_resources, struct d3d12_device *device)
Definition: resource.c:4965
static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource2 *iface, UINT sub_resource, const D3D12_RANGE *written_range)
Definition: resource.c:1475
static void vk_component_mapping_from_d3d12(VkComponentMapping *components, unsigned int component_mapping)
Definition: resource.c:2939
static struct vkd3d_view * vkd3d_view_create(uint32_t magic, VkDescriptorType vk_descriptor_type, enum vkd3d_view_type type, struct d3d12_device *device)
Definition: resource.c:2404
static ULONG STDMETHODCALLTYPE d3d12_query_heap_Release(ID3D12QueryHeap *iface)
Definition: resource.c:4472
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D12Resource2 *iface, REFIID iid, void **session)
Definition: resource.c:1724
static void d3d12_validate_resource_flags(D3D12_RESOURCE_FLAGS flags)
Definition: resource.c:1778
static void d3d12_desc_mark_as_modified(struct d3d12_desc *dst, struct d3d12_descriptor_heap *descriptor_heap)
Definition: resource.c:2682
static void d3d12_resource_tile_info_cleanup(struct d3d12_resource *resource)
Definition: resource.c:978
static void vkd3d_texture_view_desc_normalise(struct vkd3d_texture_view_desc *desc, const D3D12_RESOURCE_DESC1 *resource_desc)
Definition: resource.c:3049
static void compute_image_subresource_size_in_tiles(const VkExtent3D *tile_extent, const struct D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx, struct vkd3d_tiled_region_extent *size)
Definition: resource.c:1071
static const struct ID3D12DescriptorHeapVtbl d3d12_descriptor_heap_vtbl
Definition: resource.c:4208
void d3d12_resource_get_tiling(struct d3d12_device *device, const struct d3d12_resource *resource, UINT *total_tile_count, D3D12_PACKED_MIP_INFO *packed_mip_info, D3D12_TILE_SHAPE *standard_tile_shape, UINT *subresource_tiling_count, UINT first_subresource_tiling, D3D12_SUBRESOURCE_TILING *subresource_tilings)
Definition: resource.c:1085
static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource2 *iface, UINT sub_resource, const D3D12_RANGE *read_range, void **data)
Definition: resource.c:1426
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetName(ID3D12QueryHeap *iface, const WCHAR *name)
Definition: resource.c:4526
static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC1 *desc, const struct vkd3d_format *format)
Definition: resource.c:1794
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource2 *iface, D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags)
Definition: resource.c:1687
static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc, struct d3d12_resource *resource, DXGI_FORMAT view_format)
Definition: resource.c:2996
static D3D12_RESOURCE_DESC1 *STDMETHODCALLTYPE d3d12_resource_GetDesc1(ID3D12Resource2 *iface, D3D12_RESOURCE_DESC1 *resource_desc)
Definition: resource.c:1732
static void d3d12_heap_destroy(struct d3d12_heap *heap)
Definition: resource.c:320
static VkComponentSwizzle vk_component_swizzle_from_d3d12(unsigned int component_mapping, unsigned int component_index)
Definition: resource.c:2913
static void d3d12_resource_flush(struct d3d12_resource *resource, uint64_t offset, uint64_t size)
Definition: resource.c:1412
static HRESULT vkd3d_create_image(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, struct d3d12_resource *resource, VkImage *vk_image)
Definition: resource.c:776
static void d3d12_resource_get_vk_range(struct d3d12_resource *resource, uint64_t offset, uint64_t size, VkMappedMemoryRange *vk_range)
Definition: resource.c:1388
ULONG vkd3d_resource_incref(ID3D12Resource *resource)
Definition: resource.c:2317
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource2 *iface, REFGUID guid, UINT data_size, const void *data)
Definition: resource.c:1332
static void d3d12_desc_write_vk_heap(struct d3d12_descriptor_heap *descriptor_heap, unsigned int dst_array_element, struct descriptor_writes *writes, void *object, struct d3d12_device *device)
Definition: resource.c:2552
void vkd3d_view_decref(void *view, struct d3d12_device *device)
Definition: resource.c:2453
static HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const VkMemoryRequirements *memory_requirements, const VkMemoryDedicatedAllocateInfo *dedicated_allocate_info, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type)
Definition: resource.c:114
HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, struct vkd3d_resource_allocation_info *allocation_info)
Definition: resource.c:942
struct d3d12_heap * unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface)
Definition: resource.c:442
static void vkd3d_view_destroy(struct vkd3d_view *view, struct d3d12_device *device)
Definition: resource.c:2426
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetPrivateData(ID3D12QueryHeap *iface, REFGUID guid, UINT data_size, const void *data)
Definition: resource.c:4506
bool vkd3d_create_raw_buffer_view(struct d3d12_device *device, D3D12_GPU_VIRTUAL_ADDRESS gpu_address, D3D12_ROOT_PARAMETER_TYPE parameter_type, VkBufferView *vk_buffer_view)
Definition: resource.c:3613
static VkDeviceSize vkd3d_get_required_texel_buffer_alignment(const struct d3d12_device *device, const struct vkd3d_format *format)
Definition: resource.c:2734
HRESULT vkd3d_create_buffer(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer)
Definition: resource.c:652
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource2 *iface, REFIID iid, void **device)
Definition: resource.c:1373
HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap)
Definition: resource.c:4366
static unsigned int vkd3d_view_flags_from_d3d12_buffer_srv_flags(D3D12_BUFFER_SRV_FLAGS flags)
Definition: resource.c:3184
static void d3d12_resource_destroy(struct d3d12_resource *resource, struct d3d12_device *device)
Definition: resource.c:983
HRESULT d3d12_committed_resource_create(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, ID3D12ProtectedResourceSession *protected_session, struct d3d12_resource **resource)
Definition: resource.c:2112
HRESULT vkd3d_create_static_sampler(struct d3d12_device *device, const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler)
Definition: resource.c:3814
static D3D12_CPU_DESCRIPTOR_HANDLE *STDMETHODCALLTYPE d3d12_descriptor_heap_GetCPUDescriptorHandleForHeapStart(ID3D12DescriptorHeap *iface, D3D12_CPU_DESCRIPTOR_HANDLE *descriptor)
Definition: resource.c:4176
static VkImageType vk_image_type_from_d3d12_resource_dimension(D3D12_RESOURCE_DIMENSION dimension)
Definition: resource.c:602
static struct d3d12_query_heap * impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface)
Definition: resource.c:4435
static HRESULT STDMETHODCALLTYPE d3d12_heap_GetPrivateData(ID3D12Heap *iface, REFGUID guid, UINT *data_size, void *data)
Definition: resource.c:365
enum vkd3d_vk_descriptor_set_index vk_descriptor_set_index_table[]
Definition: resource.c:4227
static void d3d12_desc_write_vk_heap_null_descriptor(struct d3d12_descriptor_heap *descriptor_heap, uint32_t dst_array_element, struct descriptor_writes *writes, struct d3d12_device *device)
Definition: resource.c:2493
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_QueryInterface(ID3D12DescriptorHeap *iface, REFIID riid, void **object)
Definition: resource.c:4013
#define VKD3D_VIEW_RAW_BUFFER
Definition: resource.c:2819
static VkSamplerAddressMode vk_address_mode_from_d3d12(const struct d3d12_device *device, D3D12_TEXTURE_ADDRESS_MODE mode)
Definition: resource.c:3669
static ULONG STDMETHODCALLTYPE d3d12_heap_AddRef(ID3D12Heap *iface)
Definition: resource.c:308
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_GetPrivateData(ID3D12DescriptorHeap *iface, REFGUID guid, UINT *data_size, void *data)
Definition: resource.c:4117
bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource)
Definition: resource.c:1029
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_SetPrivateDataInterface(ID3D12DescriptorHeap *iface, REFGUID guid, const IUnknown *data)
Definition: resource.c:4137
static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC1 *desc)
Definition: resource.c:734
static void d3d12_desc_replace(struct d3d12_desc *dst, void *view, struct d3d12_device *device)
Definition: resource.c:2466
static ULONG STDMETHODCALLTYPE d3d12_descriptor_heap_AddRef(ID3D12DescriptorHeap *iface)
Definition: resource.c:4035
static bool d3d12_resource_init_tiles(struct d3d12_resource *resource, struct d3d12_device *device)
Definition: resource.c:1144
bool vkd3d_create_buffer_view(struct d3d12_device *device, uint32_t magic, VkBuffer vk_buffer, const struct vkd3d_format *format, VkDeviceSize offset, VkDeviceSize size, struct vkd3d_view **view)
Definition: resource.c:2792
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_SetPrivateData(ID3D12DescriptorHeap *iface, REFGUID guid, UINT data_size, const void *data)
Definition: resource.c:4127
static void vkd3d_set_view_swizzle_for_format(VkComponentMapping *components, const struct vkd3d_format *format, bool allowed_swizzle)
Definition: resource.c:2857
void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, struct d3d12_resource *counter_resource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3589
static D3D12_GPU_DESCRIPTOR_HANDLE *STDMETHODCALLTYPE d3d12_descriptor_heap_GetGPUDescriptorHandleForHeapStart(ID3D12DescriptorHeap *iface, D3D12_GPU_DESCRIPTOR_HANDLE *descriptor)
Definition: resource.c:4188
static D3D12_HEAP_DESC *STDMETHODCALLTYPE d3d12_heap_GetDesc(ID3D12Heap *iface, D3D12_HEAP_DESC *desc)
Definition: resource.c:414
HRESULT d3d12_query_heap_create(struct d3d12_device *device, const D3D12_QUERY_HEAP_DESC *desc, struct d3d12_query_heap **heap)
Definition: resource.c:4568
static void vkd3d_create_null_srv(struct d3d12_desc *descriptor, struct d3d12_device *device, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
Definition: resource.c:3193
void d3d12_desc_create_srv(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
Definition: resource.c:3302
static const struct vkd3d_format_compatibility_list * vkd3d_get_format_compatibility_list(const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
Definition: resource.c:741
static HRESULT d3d12_descriptor_heap_vk_descriptor_sets_init(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc)
Definition: resource.c:4313
static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value)
Definition: resource.c:1971
static bool vkd3d_create_buffer_view_for_resource(struct d3d12_device *device, uint32_t magic, struct d3d12_resource *resource, DXGI_FORMAT view_format, unsigned int offset, unsigned int size, unsigned int structure_stride, unsigned int flags, struct vkd3d_view **view)
Definition: resource.c:2821
struct d3d12_resource * unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface)
Definition: resource.c:1770
bool vkd3d_create_texture_view(struct d3d12_device *device, uint32_t magic, VkImage vk_image, const struct vkd3d_texture_view_desc *desc, struct vkd3d_view **view)
Definition: resource.c:3082
static HRESULT STDMETHODCALLTYPE d3d12_heap_SetName(ID3D12Heap *iface, const WCHAR *name)
Definition: resource.c:395
static HRESULT d3d12_descriptor_heap_create_descriptor_set(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device, unsigned int set)
Definition: resource.c:4271
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource2 *iface, REFGUID guid, const IUnknown *data)
Definition: resource.c:1342
static ULONG STDMETHODCALLTYPE d3d12_query_heap_AddRef(ID3D12QueryHeap *iface)
Definition: resource.c:4462
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_GetDevice(ID3D12DescriptorHeap *iface, REFIID iid, void **device)
Definition: resource.c:4156
static HRESULT vkd3d_allocate_image_memory(struct d3d12_device *device, VkImage vk_image, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
Definition: resource.c:217
static VkFilter vk_filter_from_d3d12(D3D12_FILTER_TYPE type)
Definition: resource.c:3641
void d3d12_desc_write_atomic(struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_device *device)
Definition: resource.c:2710
static HRESULT d3d12_descriptor_heap_create_descriptor_pool(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc)
Definition: resource.c:4238
HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources, struct d3d12_device *device)
Definition: resource.c:4846
static void d3d12_resource_invalidate(struct d3d12_resource *resource, uint64_t offset, uint64_t size)
Definition: resource.c:1398
#define VKD3D_NULL_BUFFER_SIZE
Definition: resource.c:22
static HRESULT STDMETHODCALLTYPE d3d12_heap_SetPrivateDataInterface(ID3D12Heap *iface, REFGUID guid, const IUnknown *data)
Definition: resource.c:385
static struct d3d12_descriptor_heap * impl_from_ID3D12DescriptorHeap(ID3D12DescriptorHeap *iface)
Definition: resource.c:4008
static HRESULT vkd3d_init_null_resources_data(struct vkd3d_null_resources *null_resource, struct d3d12_device *device)
Definition: resource.c:4660
static HRESULT STDMETHODCALLTYPE d3d12_heap_SetPrivateData(ID3D12Heap *iface, REFGUID guid, UINT data_size, const void *data)
Definition: resource.c:375
static HRESULT d3d12_heap_init(struct d3d12_heap *heap, struct d3d12_device *device, const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource)
Definition: resource.c:479
static HRESULT validate_heap_desc(const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource)
Definition: resource.c:450
static void vk_component_mapping_compose(VkComponentMapping *dst, const VkComponentMapping *b)
Definition: resource.c:2986
VkSampleCountFlagBits vk_samples_from_sample_count(unsigned int sample_count)
Definition: resource.c:618
struct d3d12_query_heap * unsafe_impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface)
Definition: resource.c:4560
#define HEAD_INDEX_MASK
Definition: resource.c:2329
static ULONG STDMETHODCALLTYPE d3d12_descriptor_heap_Release(ID3D12DescriptorHeap *iface)
Definition: resource.c:4045
static VkComponentSwizzle swizzle_vk_component(const VkComponentMapping *components, VkComponentSwizzle component, VkComponentSwizzle swizzle)
Definition: resource.c:2948
HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_buffer, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
Definition: resource.c:155
void d3d12_desc_create_sampler(struct d3d12_desc *sampler, struct d3d12_device *device, const D3D12_SAMPLER_DESC *desc)
Definition: resource.c:3780
static void * vkd3d_desc_object_cache_get(struct vkd3d_desc_object_cache *cache)
Definition: resource.c:2335
static VkResult d3d12_create_sampler(struct d3d12_device *device, D3D12_FILTER filter, D3D12_TEXTURE_ADDRESS_MODE address_u, D3D12_TEXTURE_ADDRESS_MODE address_v, D3D12_TEXTURE_ADDRESS_MODE address_w, float mip_lod_bias, unsigned int max_anisotropy, D3D12_COMPARISON_FUNC comparison_func, D3D12_STATIC_BORDER_COLOR border_colour, float min_lod, float max_lod, VkSampler *vk_sampler)
Definition: resource.c:3708
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_SetName(ID3D12DescriptorHeap *iface, const WCHAR *name)
Definition: resource.c:4147
HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, uint64_t heap_offset, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
Definition: resource.c:2216
static bool d3d12_resource_validate_box(const struct d3d12_resource *resource, unsigned int sub_resource_idx, const D3D12_BOX *box)
Definition: resource.c:1034
enum VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op)
Definition: state.c:2764
HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int data_size, const void *data)
Definition: utils.c:1033
bool is_valid_resource_state(D3D12_RESOURCE_STATES state)
Definition: utils.c:590
const char * debug_d3d12_shader_component_mapping(unsigned int mapping)
Definition: utils.c:682
HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store, const GUID *tag, const IUnknown *object)
Definition: utils.c:1046
VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const char *name)
Definition: utils.c:1060
void vkd3d_format_copy_data(const struct vkd3d_format *format, const uint8_t *src, unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch, unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d)
Definition: utils.c:496
const struct vkd3d_format * vkd3d_get_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
Definition: utils.c:442
HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name)
Definition: utils.c:1077
const char * debug_d3d12_box(const D3D12_BOX *box)
Definition: utils.c:650
HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int *out_size, void *out)
Definition: utils.c:994
#define TRACE(s)
Definition: solgame.cpp:4
UINT right
Definition: d3d12.idl:661
UINT top
Definition: d3d12.idl:659
UINT left
Definition: d3d12.idl:658
UINT bottom
Definition: d3d12.idl:662
UINT front
Definition: d3d12.idl:660
UINT back
Definition: d3d12.idl:663
D3D12_HEAP_PROPERTIES Properties
Definition: d3d12.idl:835
D3D12_HEAP_FLAGS Flags
Definition: d3d12.idl:837
UINT64 SizeInBytes
Definition: d3d12.idl:834
UINT64 Alignment
Definition: d3d12.idl:836
D3D12_CPU_PAGE_PROPERTY CPUPageProperty
Definition: d3d12.idl:805
D3D12_HEAP_TYPE Type
Definition: d3d12.idl:804
D3D12_MEMORY_POOL MemoryPoolPreference
Definition: d3d12.idl:806
UINT NumTilesForPackedMips
Definition: d3d12.idl:898
UINT StartTileIndexInOverallResource
Definition: d3d12.idl:899
SIZE_T End
Definition: d3d12.idl:679
SIZE_T Begin
Definition: d3d12.idl:678
D3D12_RESOURCE_DIMENSION Dimension
Definition: d3d12.idl:1035
D3D12_RESOURCE_FLAGS Flags
Definition: d3d12.idl:1044
D3D12_TEXTURE_LAYOUT Layout
Definition: d3d12.idl:1043
DXGI_SAMPLE_DESC SampleDesc
Definition: d3d12.idl:1042
DXGI_FORMAT Format
Definition: d3d12.idl:1041
D3D12_MIP_REGION SamplerFeedbackMipRegion
Definition: d3d12.idl:1045
UINT16 DepthOrArraySize
Definition: d3d12.idl:1039
UINT StartTileIndexInOverallResource
Definition: d3d12.idl:862
UINT DepthInTexels
Definition: d3d12.idl:869
UINT WidthInTexels
Definition: d3d12.idl:867
UINT HeightInTexels
Definition: d3d12.idl:868
uint32_t queueFamilyIndexCount
Definition: vulkan.h:7608
const uint32_t * pQueueFamilyIndices
Definition: vulkan.h:7609
VkBufferCreateFlags flags
Definition: vulkan.h:7604
VkStructureType sType
Definition: vulkan.h:7602
const void * pNext
Definition: vulkan.h:7603
VkBufferUsageFlags usage
Definition: vulkan.h:7606
VkSharingMode sharingMode
Definition: vulkan.h:7607
const void * pNext
Definition: vulkan.h:7684
VkBufferViewCreateFlags flags
Definition: vulkan.h:7685
VkStructureType sType
Definition: vulkan.h:7683
VkStructureType sType
Definition: vulkan.h:7821
VkCommandBufferLevel level
Definition: vulkan.h:7824
const VkCommandBufferInheritanceInfo * pInheritanceInfo
Definition: vulkan.h:16042
VkStructureType sType
Definition: vulkan.h:16039
const void * pNext
Definition: vulkan.h:16040
VkCommandBufferUsageFlags flags
Definition: vulkan.h:16041
const void * pNext
Definition: vulkan.h:7873
VkStructureType sType
Definition: vulkan.h:7872
uint32_t queueFamilyIndex
Definition: vulkan.h:7875
VkCommandPoolCreateFlags flags
Definition: vulkan.h:7874
VkComponentSwizzle r
Definition: vulkan.h:7880
VkComponentSwizzle a
Definition: vulkan.h:7883
VkComponentSwizzle g
Definition: vulkan.h:7881
VkComponentSwizzle b
Definition: vulkan.h:7882
VkImageLayout imageLayout
Definition: vulkan.h:8266
VkStructureType sType
Definition: vulkan.h:16190
const VkDescriptorPoolSize * pPoolSizes
Definition: vulkan.h:16195
VkDescriptorPoolCreateFlags flags
Definition: vulkan.h:16192
uint32_t descriptorCount
Definition: vulkan.h:8280
VkDescriptorType type
Definition: vulkan.h:8279
VkStructureType sType
Definition: vulkan.h:8285
const VkDescriptorSetLayout * pSetLayouts
Definition: vulkan.h:8289
uint32_t depth
Definition: vulkan.h:8674
uint32_t height
Definition: vulkan.h:8673
uint32_t width
Definition: vulkan.h:8672
const void * pNext
Definition: vulkan.h:8731
VkFenceCreateFlags flags
Definition: vulkan.h:8732
VkStructureType sType
Definition: vulkan.h:8730
VkImageCreateFlags flags
Definition: vulkan.h:8974
VkSharingMode sharingMode
Definition: vulkan.h:8983
VkImageLayout initialLayout
Definition: vulkan.h:8986
uint32_t mipLevels
Definition: vulkan.h:8978
const void * pNext
Definition: vulkan.h:8973
const uint32_t * pQueueFamilyIndices
Definition: vulkan.h:8985
uint32_t arrayLayers
Definition: vulkan.h:8979
VkSampleCountFlagBits samples
Definition: vulkan.h:8980
VkExtent3D extent
Definition: vulkan.h:8977
VkFormat format
Definition: vulkan.h:8976
uint32_t queueFamilyIndexCount
Definition: vulkan.h:8984
VkImageType imageType
Definition: vulkan.h:8975
VkImageTiling tiling
Definition: vulkan.h:8981
VkStructureType sType
Definition: vulkan.h:8972
VkImageUsageFlags usage
Definition: vulkan.h:8982
const VkFormat * pViewFormats
Definition: vulkan.h:8994
VkStructureType sType
Definition: vulkan.h:8991
uint32_t maxArrayLayers
Definition: vulkan.h:9002
VkExtent3D maxExtent
Definition: vulkan.h:9000
VkSampleCountFlags sampleCounts
Definition: vulkan.h:9003
VkAccessFlags dstAccessMask
Definition: vulkan.h:16393
uint32_t dstQueueFamilyIndex
Definition: vulkan.h:16397
VkAccessFlags srcAccessMask
Definition: vulkan.h:16392
VkStructureType sType
Definition: vulkan.h:16390
VkImageLayout newLayout
Definition: vulkan.h:16395
const void * pNext
Definition: vulkan.h:16391
VkImageSubresourceRange subresourceRange
Definition: vulkan.h:16399
VkImageLayout oldLayout
Definition: vulkan.h:16394
uint32_t srcQueueFamilyIndex
Definition: vulkan.h:16396
uint32_t baseArrayLayer
Definition: vulkan.h:9076
VkImageAspectFlags aspectMask
Definition: vulkan.h:9073
uint32_t arrayLayer
Definition: vulkan.h:9051
VkImageAspectFlags aspectMask
Definition: vulkan.h:9049
uint32_t mipLevel
Definition: vulkan.h:9050
VkImageSubresourceRange subresourceRange
Definition: vulkan.h:9118
VkComponentMapping components
Definition: vulkan.h:9117
VkImageViewType viewType
Definition: vulkan.h:9115
VkStructureType sType
Definition: vulkan.h:9111
const void * pNext
Definition: vulkan.h:9112
VkImageViewCreateFlags flags
Definition: vulkan.h:9113
VkImageUsageFlags usage
Definition: vulkan.h:9149
VkStructureType sType
Definition: vulkan.h:9147
const void * pNext
Definition: vulkan.h:9334
VkStructureType sType
Definition: vulkan.h:9333
VkStructureType sType
Definition: vulkan.h:9351
uint32_t memoryTypeIndex
Definition: vulkan.h:9354
const void * pNext
Definition: vulkan.h:9352
VkStructureType sType
Definition: vulkan.h:9386
VkBool32 prefersDedicatedAllocation
Definition: vulkan.h:9397
VkStructureType sType
Definition: vulkan.h:9395
VkStructureType sType
Definition: vulkan.h:9465
uint32_t memoryTypeBits
Definition: vulkan.h:9460
VkMemoryPropertyFlags propertyFlags
Definition: vulkan.h:9474
VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]
Definition: vulkan.h:11320
VkQueryPipelineStatisticFlags pipelineStatistics
Definition: vulkan.h:13483
VkQueryPoolCreateFlags flags
Definition: vulkan.h:13480
const void * pNext
Definition: vulkan.h:13479
VkStructureType sType
Definition: vulkan.h:13478
VkQueryType queryType
Definition: vulkan.h:13481
VkBool32 unnormalizedCoordinates
Definition: vulkan.h:13870
VkSamplerAddressMode addressModeU
Definition: vulkan.h:13859
VkBool32 anisotropyEnable
Definition: vulkan.h:13863
VkBorderColor borderColor
Definition: vulkan.h:13869
const void * pNext
Definition: vulkan.h:13854
VkBool32 compareEnable
Definition: vulkan.h:13865
VkSamplerMipmapMode mipmapMode
Definition: vulkan.h:13858
VkFilter magFilter
Definition: vulkan.h:13856
VkFilter minFilter
Definition: vulkan.h:13857
VkSamplerAddressMode addressModeW
Definition: vulkan.h:13861
VkSamplerCreateFlags flags
Definition: vulkan.h:13855
VkCompareOp compareOp
Definition: vulkan.h:13866
VkStructureType sType
Definition: vulkan.h:13853
VkSamplerAddressMode addressModeV
Definition: vulkan.h:13860
VkImageAspectFlags aspectMask
Definition: vulkan.h:14059
VkSparseImageFormatProperties formatProperties
Definition: vulkan.h:14091
uint32_t waitSemaphoreCount
Definition: vulkan.h:14150
const VkPipelineStageFlags * pWaitDstStageMask
Definition: vulkan.h:14152
uint32_t commandBufferCount
Definition: vulkan.h:14153
const VkSemaphore * pWaitSemaphores
Definition: vulkan.h:14151
uint32_t signalSemaphoreCount
Definition: vulkan.h:14155
const VkCommandBuffer * pCommandBuffers
Definition: vulkan.h:14154
const void * pNext
Definition: vulkan.h:14149
const VkSemaphore * pSignalSemaphores
Definition: vulkan.h:14156
VkStructureType sType
Definition: vulkan.h:14148
const VkBufferView * pTexelBufferView
Definition: vulkan.h:15263
uint32_t dstArrayElement
Definition: vulkan.h:15258
VkStructureType sType
Definition: vulkan.h:15254
const VkDescriptorImageInfo * pImageInfo
Definition: vulkan.h:15261
const VkDescriptorBufferInfo * pBufferInfo
Definition: vulkan.h:15262
uint32_t descriptorCount
Definition: vulkan.h:15259
const void * pNext
Definition: vulkan.h:15255
uint32_t dstBinding
Definition: vulkan.h:15257
VkDescriptorType descriptorType
Definition: vulkan.h:15260
Definition: scsiwmi.h:51
Definition: palette.c:466
Definition: cache.c:41
void * object
struct d3d12_desc::@6032 s
struct vkd3d_mutex vk_sets_mutex
D3D12_DESCRIPTOR_HEAP_DESC desc
struct d3d12_descriptor_heap_vk_set vk_descriptor_sets[VKD3D_SET_INDEX_COUNT]
struct vkd3d_private_store private_store
ID3D12DescriptorHeap ID3D12DescriptorHeap_iface
struct d3d12_device * device
unsigned int volatile dirty_list_head
VkDescriptorPool vk_descriptor_pool
struct vkd3d_vk_device_procs vk_procs
unsigned int refcount
struct vkd3d_view * view
VkSampleCountFlagBits sample_count
unsigned int height
struct d3d12_resource * resource
const struct vkd3d_format * format
unsigned int layer_count
unsigned int refcount
ID3D12Heap ID3D12Heap_iface
unsigned int refcount
uint64_t availability_mask[]
struct d3d12_device * device
ID3D12QueryHeap ID3D12QueryHeap_iface
unsigned int refcount
union d3d12_resource::@6027 u
uint64_t heap_offset
D3D12_RESOURCE_STATES initial_state
D3D12_GPU_VIRTUAL_ADDRESS gpu_address
VkBuffer vk_buffer
struct vkd3d_view * view
VkSampleCountFlagBits sample_count
unsigned int height
unsigned int layer_count
const struct vkd3d_format * format
struct d3d12_resource * resource
void * held_refs[VKD3D_DESCRIPTOR_WRITE_BUFFER_SIZE]
Definition: resource.c:2480
VkDescriptorBufferInfo null_vk_cbv_info
Definition: resource.c:2476
unsigned int count
Definition: resource.c:2481
VkBufferView null_vk_buffer_view
Definition: resource.c:2477
VkDescriptorImageInfo vk_image_infos[VKD3D_DESCRIPTOR_WRITE_BUFFER_SIZE]
Definition: resource.c:2478
unsigned int held_ref_count
Definition: resource.c:2482
VkWriteDescriptorSet vk_descriptor_writes[VKD3D_DESCRIPTOR_WRITE_BUFFER_SIZE]
Definition: resource.c:2479
Definition: devices.h:37
Definition: filter.c:165
Definition: heap.c:86
char buffer[256]
Definition: notification.c:80
Definition: name.c:39
Definition: queue.c:179
enum view_type type
VkDescriptorBufferInfo vk_cbv_info
VkFormat vk_formats[VKD3D_MAX_COMPATIBLE_FORMAT_COUNT]
size_t block_height
size_t block_width
D3D12_RESOURCE_STATES present_state
Definition: vkd3d.h:371
D3D12_RESOURCE_DESC desc
Definition: vkd3d.h:346
enum vkd3d_structure_type type
Definition: vkd3d.h:339
VkDeviceMemory vk_buffer_memory
VkDeviceMemory vk_2d_image_memory
VkDeviceMemory vk_2d_storage_image_memory
VkDeviceMemory vk_storage_buffer_memory
VkQueue vk_queue
struct vkd3d_tiled_region_extent extent
VkImageUsageFlags usage
VkComponentMapping components
const struct vkd3d_format * format
VkImageAspectFlags vk_image_aspect
unsigned int miplevel_count
VkImageViewType view_type
VkPhysicalDeviceLimits device_limits
bool EXT_texel_buffer_alignment
VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT texel_buffer_alignment_properties
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
@ VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO
Definition: vkd3d.h:57
#define VKD3D_RESOURCE_PRESENT_STATE_TRANSITION
Definition: vkd3d.h:330
#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION
Definition: vkd3d.h:325
static void * vkd3d_atomic_exchange_ptr(void *volatile *x, void *val)
Definition: vkd3d_common.h:527
static const char * debugstr_hresult(HRESULT hr)
Definition: vkd3d_common.h:244
static uint64_t vkd3d_atomic_increment_u64(uint64_t volatile *x)
Definition: vkd3d_common.h:472
static unsigned int vkd3d_log2i(unsigned int x)
Definition: vkd3d_common.h:309
#define FIXME_ONCE
Definition: vkd3d_common.h:228
static void vkd3d_mutex_init(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:560
static void vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:584
static void vkd3d_mutex_lock(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:572
static uint32_t vkd3d_atomic_exchange_u32(uint32_t volatile *x, uint32_t val)
Definition: vkd3d_common.h:509
static void vkd3d_mutex_destroy(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:596
static uint32_t vkd3d_atomic_decrement_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:477
static bool vkd3d_atomic_compare_exchange_u32(uint32_t volatile *x, uint32_t expected, uint32_t val)
Definition: vkd3d_common.h:487
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
static uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:482
#define DIV_ROUND_UP(a, b)
Definition: vkd3d_common.h:45
#define STATIC_ASSERT(e)
Definition: vkd3d_common.h:47
static void * vkd3d_calloc(size_t count, size_t size)
Definition: vkd3d_memory.h:43
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52
static void * vkd3d_malloc(size_t size)
Definition: vkd3d_memory.h:28
#define VKD3D_DESCRIPTOR_MAGIC_SRV
Definition: vkd3d_private.h:48
static bool vkd3d_format_is_compressed(const struct vkd3d_format *format)
vkd3d_vk_descriptor_set_index
@ VKD3D_SET_INDEX_MUTABLE
@ VKD3D_SET_INDEX_STORAGE_IMAGE
@ VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER
@ VKD3D_SET_INDEX_SAMPLED_IMAGE
@ VKD3D_SET_INDEX_UNIFORM_BUFFER
@ VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER
@ VKD3D_SET_INDEX_SAMPLER
@ VKD3D_SET_INDEX_UAV_COUNTER
@ VKD3D_SET_INDEX_COUNT
@ VKD3D_FORMAT_TYPE_UINT
@ VKD3D_FORMAT_TYPE_TYPELESS
static void vkd3d_private_store_destroy(struct vkd3d_private_store *store)
static ULONG d3d12_device_release(struct d3d12_device *device)
static void d3d12_resource_desc1_from_desc(D3D12_RESOURCE_DESC1 *desc1, const D3D12_RESOURCE_DESC *desc)
static unsigned int d3d12_device_get_descriptor_handle_increment_size(struct d3d12_device *device, D3D12_DESCRIPTOR_HEAP_TYPE descriptor_type)
#define VKD3D_DESCRIPTOR_MAGIC_DSV
Definition: vkd3d_private.h:51
#define VKD3D_DESCRIPTOR_MAGIC_CBV
Definition: vkd3d_private.h:47
static enum vkd3d_vk_descriptor_set_index vkd3d_vk_descriptor_set_index_from_vk_descriptor_type(VkDescriptorType type)
static ULONG d3d12_device_add_ref(struct d3d12_device *device)
static unsigned int d3d12_resource_desc_get_sub_resource_count(const D3D12_RESOURCE_DESC1 *desc)
static HRESULT d3d12_device_query_interface(struct d3d12_device *device, REFIID iid, void **object)
static bool d3d12_box_is_empty(const D3D12_BOX *box)
static struct d3d12_resource * impl_from_ID3D12Resource2(ID3D12Resource2 *iface)
static unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
#define VKD3D_DESCRIPTOR_MAGIC_RTV
Definition: vkd3d_private.h:52
static bool d3d12_resource_is_buffer(const struct d3d12_resource *resource)
static void debug_ignored_node_mask(unsigned int mask)
#define VKD3D_RESOURCE_LINEAR_TILING
static HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store)
static unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOURCE_DESC1 *desc)
static size_t vkd3d_format_get_data_offset(const struct vkd3d_format *format, unsigned int row_pitch, unsigned int slice_pitch, unsigned int x, unsigned int y, unsigned int z)
static const struct vkd3d_format * vkd3d_format_from_d3d12_resource_desc(const struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, DXGI_FORMAT view_format)
#define VKD3D_RESOURCE_EXTERNAL
#define VKD3D_RESOURCE_DEDICATED_HEAP
static void * d3d12_desc_get_object_ref(const volatile struct d3d12_desc *src, struct d3d12_device *device)
static struct d3d12_resource * impl_from_ID3D12Resource(ID3D12Resource *iface)
static bool d3d12_resource_is_texture(const struct d3d12_resource *resource)
static unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
vkd3d_view_type
@ VKD3D_VIEW_TYPE_SAMPLER
@ VKD3D_VIEW_TYPE_IMAGE
@ VKD3D_VIEW_TYPE_BUFFER
#define VKD3D_DESCRIPTOR_MAGIC_UAV
Definition: vkd3d_private.h:49
static unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
#define VKD3D_RESOURCE_PUBLIC_FLAGS
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER
Definition: vkd3d_private.h:50
static struct d3d12_descriptor_heap * d3d12_desc_get_descriptor_heap(const struct d3d12_desc *descriptor)
void VKAPI_CALL vkGetBufferMemoryRequirements2KHR(VkDevice device, const VkBufferMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
void VKAPI_CALL vkGetImageMemoryRequirements2KHR(VkDevice device, const VkImageMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
VkFlags VkMemoryPropertyFlags
Definition: vulkan.h:1063
VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan.h:3456
@ VK_IMAGE_LAYOUT_PREINITIALIZED
Definition: vulkan.h:3459
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan.h:3451
@ VK_IMAGE_LAYOUT_GENERAL
Definition: vulkan.h:3452
@ VK_COMMAND_BUFFER_LEVEL_PRIMARY
Definition: vulkan.h:2140
#define VK_REMAINING_MIP_LEVELS
Definition: vulkan.h:50
@ VK_SHARING_MODE_CONCURRENT
Definition: vulkan.h:4922
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan.h:4921
@ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
Definition: vulkan.h:3772
@ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
Definition: vulkan.h:3770
@ VK_MEMORY_PROPERTY_HOST_CACHED_BIT
Definition: vulkan.h:3773
@ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
Definition: vulkan.h:3771
VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
VkFlags VkImageAspectFlags
Definition: vulkan.h:1043
VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool)
void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)
@ VK_IMAGE_VIEW_TYPE_1D
Definition: vulkan.h:3548
@ VK_IMAGE_VIEW_TYPE_2D_ARRAY
Definition: vulkan.h:3553
@ VK_IMAGE_VIEW_TYPE_1D_ARRAY
Definition: vulkan.h:3552
@ VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
Definition: vulkan.h:3554
@ VK_IMAGE_VIEW_TYPE_3D
Definition: vulkan.h:3550
@ VK_IMAGE_VIEW_TYPE_2D
Definition: vulkan.h:3549
@ VK_IMAGE_VIEW_TYPE_CUBE
Definition: vulkan.h:3551
uint64_t VkDeviceSize
Definition: vulkan.h:948
VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
@ VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
Definition: vulkan.h:3424
@ VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR
Definition: vulkan.h:3441
@ VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
Definition: vulkan.h:3423
@ VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT
Definition: vulkan.h:3421
@ VK_IMAGE_CREATE_SPARSE_BINDING_BIT
Definition: vulkan.h:3420
@ VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT
Definition: vulkan.h:2442
@ VK_IMAGE_TILING_OPTIMAL
Definition: vulkan.h:3495
@ VK_IMAGE_TILING_LINEAR
Definition: vulkan.h:3496
@ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
Definition: vulkan.h:2153
void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements)
void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges)
void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, VkSubresourceLayout *pLayout)
void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements)
VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers)
VkBorderColor
Definition: vulkan.h:1887
@ VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
Definition: vulkan.h:1892
@ VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
Definition: vulkan.h:1888
@ VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK
Definition: vulkan.h:1890
VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
@ VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT
Definition: vulkan.h:2339
@ VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT
Definition: vulkan.h:2337
@ VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT
Definition: vulkan.h:2338
@ VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT
Definition: vulkan.h:2341
VkSamplerMipmapMode
Definition: vulkan.h:4733
@ VK_SAMPLER_MIPMAP_MODE_NEAREST
Definition: vulkan.h:4734
@ VK_SAMPLER_MIPMAP_MODE_LINEAR
Definition: vulkan.h:4735
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan.h:3365
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan.h:3367
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan.h:3366
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:3511
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan.h:3512
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
Definition: vulkan.h:3515
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan.h:3514
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:3510
@ VK_IMAGE_USAGE_STORAGE_BIT
Definition: vulkan.h:3513
VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties)
VkSampleCountFlagBits
Definition: vulkan.h:4700
@ VK_SAMPLE_COUNT_8_BIT
Definition: vulkan.h:4704
@ VK_SAMPLE_COUNT_64_BIT
Definition: vulkan.h:4707
@ VK_SAMPLE_COUNT_32_BIT
Definition: vulkan.h:4706
@ VK_SAMPLE_COUNT_2_BIT
Definition: vulkan.h:4702
@ VK_SAMPLE_COUNT_1_BIT
Definition: vulkan.h:4701
@ VK_SAMPLE_COUNT_4_BIT
Definition: vulkan.h:4703
@ VK_SAMPLE_COUNT_16_BIT
Definition: vulkan.h:4705
@ VK_QUERY_TYPE_PIPELINE_STATISTICS
Definition: vulkan.h:4510
@ VK_QUERY_TYPE_OCCLUSION
Definition: vulkan.h:4509
@ VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT
Definition: vulkan.h:4513
@ VK_QUERY_TYPE_TIMESTAMP
Definition: vulkan.h:4511
VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout)
VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory)
VkComponentSwizzle
Definition: vulkan.h:2187
@ VK_COMPONENT_SWIZZLE_G
Definition: vulkan.h:2192
@ VK_COMPONENT_SWIZZLE_B
Definition: vulkan.h:2193
@ VK_COMPONENT_SWIZZLE_ONE
Definition: vulkan.h:2190
@ VK_COMPONENT_SWIZZLE_A
Definition: vulkan.h:2194
@ VK_COMPONENT_SWIZZLE_IDENTITY
Definition: vulkan.h:2188
@ VK_COMPONENT_SWIZZLE_R
Definition: vulkan.h:2191
@ VK_COMPONENT_SWIZZLE_ZERO
Definition: vulkan.h:2189
void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue *pColor, uint32_t rangeCount, const VkImageSubresourceRange *pRanges)
void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator)
#define VK_FALSE
Definition: vulkan.h:56
VkImageType
Definition: vulkan.h:3501
@ VK_IMAGE_TYPE_2D
Definition: vulkan.h:3503
@ VK_IMAGE_TYPE_3D
Definition: vulkan.h:3504
@ VK_IMAGE_TYPE_1D
Definition: vulkan.h:3502
#define VK_WHOLE_SIZE
Definition: vulkan.h:53
@ VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
Definition: vulkan.h:4466
@ VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4468
@ VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
Definition: vulkan.h:4465
@ VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4474
@ VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4472
@ VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4467
@ VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
Definition: vulkan.h:4469
@ VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
Definition: vulkan.h:4470
@ VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
Definition: vulkan.h:4473
@ VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
Definition: vulkan.h:4471
@ VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4475
@ VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
Definition: vulkan.h:1918
@ VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
Definition: vulkan.h:1917
@ VK_BUFFER_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:1916
@ VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT
Definition: vulkan.h:1923
@ VK_BUFFER_USAGE_INDEX_BUFFER_BIT
Definition: vulkan.h:1921
@ VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT
Definition: vulkan.h:1926
@ VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
Definition: vulkan.h:1919
@ VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT
Definition: vulkan.h:1927
@ VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT
Definition: vulkan.h:1924
@ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT
Definition: vulkan.h:1922
@ VK_BUFFER_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:1915
VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
VkFilter
Definition: vulkan.h:2806
@ VK_FILTER_NEAREST
Definition: vulkan.h:2807
@ VK_FILTER_LINEAR
Definition: vulkan.h:2808
void VKAPI_CALL vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements *pSparseMemoryRequirements)
VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
VkResult
Definition: vulkan.h:4639
@ VK_SUCCESS
Definition: vulkan.h:4672
@ VK_ERROR_FORMAT_NOT_SUPPORTED
Definition: vulkan.h:4661
VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler)
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan.h:1641
VkDescriptorType
Definition: vulkan.h:2463
@ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
Definition: vulkan.h:2469
@ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
Definition: vulkan.h:2466
@ VK_DESCRIPTOR_TYPE_SAMPLER
Definition: vulkan.h:2464
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan.h:2470
@ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
Definition: vulkan.h:2468
@ VK_DESCRIPTOR_TYPE_MUTABLE_EXT
Definition: vulkan.h:2478
@ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
Definition: vulkan.h:2467
@ VK_BUFFER_CREATE_SPARSE_BINDING_BIT
Definition: vulkan.h:1901
@ VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT
Definition: vulkan.h:1902
void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges)
VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
VkSamplerAddressMode
Definition: vulkan.h:4712
@ VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT
Definition: vulkan.h:4714
@ VK_SAMPLER_ADDRESS_MODE_REPEAT
Definition: vulkan.h:4713
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
Definition: vulkan.h:4715
@ VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE
Definition: vulkan.h:4717
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
Definition: vulkan.h:4716
#define VK_NULL_HANDLE
Definition: vulkan.h:861
VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView)
VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence)
void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool)
#define VK_REMAINING_ARRAY_LAYERS
Definition: vulkan.h:51
VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets)
void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
@ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
Definition: vulkan.h:4272
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
Definition: vulkan.h:4285
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan.h:4284
void VKAPI_CALL vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers)
VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool)
void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage)
void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pPropertyCount, VkSparseImageFormatProperties *pProperties)
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan.h:57
void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks *pAllocator)
@ VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2
Definition: vulkan.h:5226
@ VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2
Definition: vulkan.h:5229
@ VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS
Definition: vulkan.h:5204
@ VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR
Definition: vulkan.h:5913
@ VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO
Definition: vulkan.h:4977
@ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
Definition: vulkan.h:4995
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT
Definition: vulkan.h:5926
@ VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
Definition: vulkan.h:4976
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Definition: vulkan.h:4978
@ VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
Definition: vulkan.h:4975
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
Definition: vulkan.h:5004
@ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
Definition: vulkan.h:4999
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
Definition: vulkan.h:5006
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2
Definition: vulkan.h:5227
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO
Definition: vulkan.h:5198
@ VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO
Definition: vulkan.h:5205
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Definition: vulkan.h:4979
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
Definition: vulkan.h:4998
@ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
Definition: vulkan.h:4969
@ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
Definition: vulkan.h:4997
@ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
Definition: vulkan.h:4972
@ VK_STRUCTURE_TYPE_SUBMIT_INFO
Definition: vulkan.h:4968
@ VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE
Definition: vulkan.h:4970
@ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO
Definition: vulkan.h:5003
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
Definition: vulkan.h:5009
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
static size_t align(size_t addr, size_t alignment)
#define VK_CALL(f)
Definition: wined3d_vk.h:272
#define DXGI_ERROR_NOT_FOUND
Definition: winerror.h:7122
#define E_NOINTERFACE
Definition: winerror.h:3479