ReactOS 0.4.17-dev-923-g4c9a150
command.c
Go to the documentation of this file.
1/*
2 * Copyright 2016 Józef Kucia for CodeWeavers
3 * Copyright 2016 Henri Verbeet for CodeWeavers
4 * Copyright 2021 Conor McCarthy for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "vkd3d_private.h"
22#include <math.h>
23
24static void d3d12_fence_incref(struct d3d12_fence *fence);
25static void d3d12_fence_decref(struct d3d12_fence *fence);
26static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkFence vk_fence, bool on_cpu);
27static void d3d12_fence_signal_timeline_semaphore(struct d3d12_fence *fence, uint64_t timeline_value);
28static HRESULT d3d12_command_queue_signal(struct d3d12_command_queue *command_queue,
29 struct d3d12_fence *fence, uint64_t value);
31static HRESULT d3d12_command_queue_flush_ops(struct d3d12_command_queue *queue, bool *flushed_any);
33
35 uint32_t family_index, const VkQueueFamilyProperties *properties, struct vkd3d_queue **queue)
36{
37 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
38 struct vkd3d_queue *object;
39
40 if (!(object = vkd3d_malloc(sizeof(*object))))
41 return E_OUTOFMEMORY;
42
43 vkd3d_mutex_init(&object->mutex);
44
45 object->completed_sequence_number = 0;
46 object->submitted_sequence_number = 0;
47
48 object->vk_family_index = family_index;
49 object->vk_queue_flags = properties->queueFlags;
50 object->timestamp_bits = properties->timestampValidBits;
51
52 object->semaphores = NULL;
53 object->semaphores_size = 0;
54 object->semaphore_count = 0;
55
56 memset(object->old_vk_semaphores, 0, sizeof(object->old_vk_semaphores));
57
58 VK_CALL(vkGetDeviceQueue(device->vk_device, family_index, 0, &object->vk_queue));
59
60 TRACE("Created queue %p for queue family index %u.\n", object, family_index);
61
62 *queue = object;
63
64 return S_OK;
65}
66
68{
69 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
70 unsigned int i;
71
72 vkd3d_mutex_lock(&queue->mutex);
73
74 for (i = 0; i < queue->semaphore_count; ++i)
75 VK_CALL(vkDestroySemaphore(device->vk_device, queue->semaphores[i].vk_semaphore, NULL));
76
77 vkd3d_free(queue->semaphores);
78
79 for (i = 0; i < ARRAY_SIZE(queue->old_vk_semaphores); ++i)
80 {
81 if (queue->old_vk_semaphores[i])
82 VK_CALL(vkDestroySemaphore(device->vk_device, queue->old_vk_semaphores[i], NULL));
83 }
84
86
89}
90
92{
93 TRACE("queue %p.\n", queue);
94
95 vkd3d_mutex_lock(&queue->mutex);
96
97 VKD3D_ASSERT(queue->vk_queue);
98 return queue->vk_queue;
99}
100
102{
103 TRACE("queue %p.\n", queue);
104
105 vkd3d_mutex_unlock(&queue->mutex);
106}
107
109 const struct vkd3d_vk_device_procs *vk_procs)
110{
111 VkQueue vk_queue;
112 VkResult vr;
113
114 if ((vk_queue = vkd3d_queue_acquire(queue)))
115 {
116 vr = VK_CALL(vkQueueWaitIdle(vk_queue));
118
119 if (vr < 0)
120 WARN("Failed to wait for queue, vr %d.\n", vr);
121 }
122 else
123 {
124 ERR("Failed to acquire queue %p.\n", queue);
126 }
127
128 return vr;
129}
130
132 uint64_t sequence_number, struct d3d12_device *device)
133{
134 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
135 unsigned int destroyed_semaphore_count = 0;
136 uint64_t completed_sequence_number;
137 VkSemaphore vk_semaphore;
138 unsigned int i, j;
139
140 vkd3d_mutex_lock(&queue->mutex);
141
142 completed_sequence_number = queue->completed_sequence_number;
143 queue->completed_sequence_number = max(sequence_number, queue->completed_sequence_number);
144
145 TRACE("Queue %p sequence number %"PRIu64" -> %"PRIu64".\n",
146 queue, completed_sequence_number, queue->completed_sequence_number);
147
148 for (i = 0; i < queue->semaphore_count; ++i)
149 {
150 if (queue->semaphores[i].sequence_number > queue->completed_sequence_number)
151 break;
152
153 vk_semaphore = queue->semaphores[i].vk_semaphore;
154
155 /* Try to store the Vulkan semaphore for reuse. */
156 for (j = 0; j < ARRAY_SIZE(queue->old_vk_semaphores); ++j)
157 {
158 if (queue->old_vk_semaphores[j] == VK_NULL_HANDLE)
159 {
160 queue->old_vk_semaphores[j] = vk_semaphore;
161 vk_semaphore = VK_NULL_HANDLE;
162 break;
163 }
164 }
165
166 if (!vk_semaphore)
167 continue;
168
169 VK_CALL(vkDestroySemaphore(device->vk_device, vk_semaphore, NULL));
170 ++destroyed_semaphore_count;
171 }
172 if (i > 0)
173 {
174 queue->semaphore_count -= i;
175 memmove(queue->semaphores, &queue->semaphores[i], queue->semaphore_count * sizeof(*queue->semaphores));
176 }
177
178 if (destroyed_semaphore_count)
179 TRACE("Destroyed %u Vulkan semaphores.\n", destroyed_semaphore_count);
180
181 vkd3d_mutex_unlock(&queue->mutex);
182}
183
185{
186 unsigned int i;
187
188 WARN("Resetting sequence number for queue %p.\n", queue);
189
190 queue->completed_sequence_number = 0;
191 queue->submitted_sequence_number = 1;
192
193 for (i = 0; i < queue->semaphore_count; ++i)
194 queue->semaphores[i].sequence_number = queue->submitted_sequence_number;
195
196 return queue->submitted_sequence_number;
197}
198
200 struct d3d12_device *device, VkSemaphore *vk_semaphore)
201{
202 const struct vkd3d_vk_device_procs *vk_procs;
203 VkSemaphoreCreateInfo semaphore_info;
204 unsigned int i;
205 VkResult vr;
206
207 *vk_semaphore = VK_NULL_HANDLE;
208
209 for (i = 0; i < ARRAY_SIZE(queue->old_vk_semaphores); ++i)
210 {
211 if ((*vk_semaphore = queue->old_vk_semaphores[i]))
212 {
213 queue->old_vk_semaphores[i] = VK_NULL_HANDLE;
214 break;
215 }
216 }
217
218 if (*vk_semaphore)
219 return VK_SUCCESS;
220
221 vk_procs = &device->vk_procs;
222
224 semaphore_info.pNext = NULL;
225 semaphore_info.flags = 0;
226 if ((vr = VK_CALL(vkCreateSemaphore(device->vk_device, &semaphore_info, NULL, vk_semaphore))) < 0)
227 {
228 WARN("Failed to create Vulkan semaphore, vr %d.\n", vr);
229 *vk_semaphore = VK_NULL_HANDLE;
230 }
231
232 return vr;
233}
234
235/* Fence worker thread */
237 VkFence vk_fence, struct d3d12_fence *fence, uint64_t value,
238 struct vkd3d_queue *queue, uint64_t queue_sequence_number)
239{
240 struct vkd3d_waiting_fence *waiting_fence;
241
242 TRACE("worker %p, fence %p, value %#"PRIx64".\n", worker, fence, value);
243
244 vkd3d_mutex_lock(&worker->mutex);
245
246 if (!vkd3d_array_reserve((void **)&worker->fences, &worker->fences_size,
247 worker->fence_count + 1, sizeof(*worker->fences)))
248 {
249 ERR("Failed to add GPU fence.\n");
250 vkd3d_mutex_unlock(&worker->mutex);
251 return E_OUTOFMEMORY;
252 }
253
254 waiting_fence = &worker->fences[worker->fence_count++];
255 waiting_fence->fence = fence;
256 waiting_fence->value = value;
257 waiting_fence->u.vk_fence = vk_fence;
259
261
262 vkd3d_cond_signal(&worker->cond);
263 vkd3d_mutex_unlock(&worker->mutex);
264
265 return S_OK;
266}
267
269 const struct vkd3d_waiting_fence *waiting_fence)
270{
271 const struct d3d12_device *device = worker->device;
272 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
274 VkResult vr;
275
277 wait_info.pNext = NULL;
278 wait_info.flags = 0;
279 wait_info.semaphoreCount = 1;
280 wait_info.pSemaphores = &waiting_fence->u.vk_semaphore;
281 wait_info.pValues = &waiting_fence->value;
282
283 vr = VK_CALL(vkWaitSemaphoresKHR(device->vk_device, &wait_info, ~(uint64_t)0));
284 if (vr == VK_TIMEOUT)
285 return;
286 if (vr != VK_SUCCESS)
287 {
288 ERR("Failed to wait for Vulkan timeline semaphore, vr %d.\n", vr);
289 return;
290 }
291
292 TRACE("Signaling fence %p value %#"PRIx64".\n", waiting_fence->fence, waiting_fence->value);
293 d3d12_fence_signal_timeline_semaphore(waiting_fence->fence, waiting_fence->value);
294
295 d3d12_fence_decref(waiting_fence->fence);
296}
297
299 const struct vkd3d_waiting_fence *waiting_fence)
300{
301 struct d3d12_device *device = worker->device;
302 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
303 HRESULT hr;
304 int vr;
305
306 vr = VK_CALL(vkWaitForFences(device->vk_device, 1, &waiting_fence->u.vk_fence, VK_FALSE, ~(uint64_t)0));
307 if (vr == VK_TIMEOUT)
308 return;
309 if (vr != VK_SUCCESS)
310 {
311 ERR("Failed to wait for Vulkan fence, vr %d.\n", vr);
312 return;
313 }
314
315 TRACE("Signaling fence %p value %#"PRIx64".\n", waiting_fence->fence, waiting_fence->value);
316 if (FAILED(hr = d3d12_fence_signal(waiting_fence->fence, waiting_fence->value, waiting_fence->u.vk_fence, false)))
317 ERR("Failed to signal d3d12 fence, hr %s.\n", debugstr_hresult(hr));
318
319 d3d12_fence_decref(waiting_fence->fence);
320
322}
323
324static void *vkd3d_fence_worker_main(void *arg)
325{
326 size_t old_fences_size, cur_fences_size = 0, cur_fence_count = 0;
327 struct vkd3d_waiting_fence *old_fences, *cur_fences = NULL;
328 struct vkd3d_fence_worker *worker = arg;
329 unsigned int i;
330
331 vkd3d_set_thread_name("vkd3d_fence");
332
333 for (;;)
334 {
335 vkd3d_mutex_lock(&worker->mutex);
336
337 if (!worker->fence_count && !worker->should_exit)
338 vkd3d_cond_wait(&worker->cond, &worker->mutex);
339
340 if (worker->should_exit)
341 {
342 vkd3d_mutex_unlock(&worker->mutex);
343 break;
344 }
345
346 old_fences_size = cur_fences_size;
347 old_fences = cur_fences;
348
349 cur_fence_count = worker->fence_count;
350 cur_fences_size = worker->fences_size;
351 cur_fences = worker->fences;
352
353 worker->fence_count = 0;
354 worker->fences_size = old_fences_size;
355 worker->fences = old_fences;
356
357 vkd3d_mutex_unlock(&worker->mutex);
358
359 for (i = 0; i < cur_fence_count; ++i)
360 worker->wait_for_gpu_fence(worker, &cur_fences[i]);
361 }
362
363 vkd3d_free(cur_fences);
364 return NULL;
365}
366
368 struct vkd3d_queue *queue, struct d3d12_device *device)
369{
370 HRESULT hr;
371
372 TRACE("worker %p.\n", worker);
373
374 worker->should_exit = false;
375 worker->queue = queue;
376 worker->device = device;
377
378 worker->fence_count = 0;
379 worker->fences = NULL;
380 worker->fences_size = 0;
381
382 worker->wait_for_gpu_fence = device->vk_info.KHR_timeline_semaphore
384
385 vkd3d_mutex_init(&worker->mutex);
386
387 vkd3d_cond_init(&worker->cond);
388
389 if (FAILED(hr = vkd3d_create_thread(device->vkd3d_instance,
390 vkd3d_fence_worker_main, worker, &worker->thread)))
391 {
392 vkd3d_mutex_destroy(&worker->mutex);
393 vkd3d_cond_destroy(&worker->cond);
394 }
395
396 return hr;
397}
398
400 struct d3d12_device *device)
401{
402 HRESULT hr;
403
404 TRACE("worker %p.\n", worker);
405
406 vkd3d_mutex_lock(&worker->mutex);
407
408 worker->should_exit = true;
409 vkd3d_cond_signal(&worker->cond);
410
411 vkd3d_mutex_unlock(&worker->mutex);
412
413 if (FAILED(hr = vkd3d_join_thread(device->vkd3d_instance, &worker->thread)))
414 return hr;
415
416 vkd3d_mutex_destroy(&worker->mutex);
417 vkd3d_cond_destroy(&worker->cond);
418
419 vkd3d_free(worker->fences);
420
421 return S_OK;
422}
423
425 const struct d3d12_root_signature *root_signature, unsigned int index)
426{
427 VKD3D_ASSERT(index < root_signature->parameter_count);
428 return &root_signature->parameters[index];
429}
430
432 const struct d3d12_root_signature *root_signature, unsigned int index)
433{
434 const struct d3d12_root_parameter *p = root_signature_get_parameter(root_signature, index);
436 return &p->u.descriptor_table;
437}
438
440 const struct d3d12_root_signature *root_signature, unsigned int index)
441{
442 const struct d3d12_root_parameter *p = root_signature_get_parameter(root_signature, index);
444 return &p->u.constant;
445}
446
448 const struct d3d12_root_signature *root_signature, unsigned int index)
449{
450 const struct d3d12_root_parameter *p = root_signature_get_parameter(root_signature, index);
452 || p->parameter_type == D3D12_ROOT_PARAMETER_TYPE_SRV
453 || p->parameter_type == D3D12_ROOT_PARAMETER_TYPE_UAV);
454 return p;
455}
456
457/* ID3D12Fence */
459{
460 return CONTAINING_RECORD(iface, struct d3d12_fence, ID3D12Fence1_iface);
461}
462
463static VkResult d3d12_fence_create_vk_fence(struct d3d12_fence *fence, VkFence *vk_fence)
464{
465 const struct vkd3d_vk_device_procs *vk_procs;
466 struct d3d12_device *device = fence->device;
467 VkFenceCreateInfo fence_info;
468 unsigned int i;
469 VkResult vr;
470
471 *vk_fence = VK_NULL_HANDLE;
472
473 vkd3d_mutex_lock(&fence->mutex);
474
475 for (i = 0; i < ARRAY_SIZE(fence->old_vk_fences); ++i)
476 {
477 if ((*vk_fence = fence->old_vk_fences[i]))
478 {
480 break;
481 }
482 }
483
484 vkd3d_mutex_unlock(&fence->mutex);
485
486 if (*vk_fence)
487 return VK_SUCCESS;
488
489 vk_procs = &device->vk_procs;
490
492 fence_info.pNext = NULL;
493 fence_info.flags = 0;
494 if ((vr = VK_CALL(vkCreateFence(device->vk_device, &fence_info, NULL, vk_fence))) < 0)
495 {
496 WARN("Failed to create Vulkan fence, vr %d.\n", vr);
497 *vk_fence = VK_NULL_HANDLE;
498 }
499
500 return vr;
501}
502
504 bool destroy_all)
505{
506 struct d3d12_device *device = fence->device;
507 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
509 unsigned int i, semaphore_count;
510
511 semaphore_count = fence->semaphore_count;
512 if (!destroy_all && semaphore_count < VKD3D_MAX_VK_SYNC_OBJECTS)
513 return;
514
515 i = 0;
516 while (i < fence->semaphore_count)
517 {
518 if (!destroy_all && fence->semaphore_count < VKD3D_MAX_VK_SYNC_OBJECTS)
519 break;
520
521 current = &fence->semaphores[i];
522 /* The semaphore doesn't have a pending signal operation if the fence
523 * was signaled. */
524 if ((current->u.binary.vk_fence || current->u.binary.is_acquired) && !destroy_all)
525 {
526 ++i;
527 continue;
528 }
529
530 if (current->u.binary.vk_fence)
531 WARN("Destroying potentially pending semaphore.\n");
532 VKD3D_ASSERT(!current->u.binary.is_acquired);
533
534 VK_CALL(vkDestroySemaphore(device->vk_device, current->u.binary.vk_semaphore, NULL));
535 fence->semaphores[i] = fence->semaphores[--fence->semaphore_count];
536 }
537
538 if (semaphore_count != fence->semaphore_count)
539 TRACE("Destroyed %u Vulkan semaphores.\n", semaphore_count - fence->semaphore_count);
540}
541
543{
544 const struct vkd3d_vk_device_procs *vk_procs;
545 struct d3d12_device *device = fence->device;
546 unsigned int i;
547
548 vkd3d_mutex_lock(&fence->mutex);
549
550 vk_procs = &device->vk_procs;
551
552 for (i = 0; i < ARRAY_SIZE(fence->old_vk_fences); ++i)
553 {
554 if (fence->old_vk_fences[i])
555 VK_CALL(vkDestroyFence(device->vk_device, fence->old_vk_fences[i], NULL));
557 }
558
561
562 vkd3d_mutex_unlock(&fence->mutex);
563}
564
566 uint64_t value, uint64_t *completed_value)
567{
570 uint64_t semaphore_value;
571 unsigned int i;
572
573 TRACE("fence %p, value %#"PRIx64".\n", fence, value);
574
575 semaphore = NULL;
576 semaphore_value = ~(uint64_t)0;
577
578 for (i = 0; i < fence->semaphore_count; ++i)
579 {
580 current = &fence->semaphores[i];
581 /* Prefer a semaphore with the smallest value. */
582 if (!current->u.binary.is_acquired && current->value >= value && semaphore_value >= current->value)
583 {
585 semaphore_value = current->value;
586 }
587 if (semaphore_value == value)
588 break;
589 }
590
591 if (semaphore)
592 semaphore->u.binary.is_acquired = true;
593
594 *completed_value = fence->value;
595
596 return semaphore;
597}
598
600{
601 vkd3d_mutex_lock(&fence->mutex);
602
603 VKD3D_ASSERT(semaphore->u.binary.is_acquired);
604
605 *semaphore = fence->semaphores[--fence->semaphore_count];
606
607 vkd3d_mutex_unlock(&fence->mutex);
608}
609
611{
612 vkd3d_mutex_lock(&fence->mutex);
613
614 VKD3D_ASSERT(semaphore->u.binary.is_acquired);
615 semaphore->u.binary.is_acquired = false;
616
617 vkd3d_mutex_unlock(&fence->mutex);
618}
619
621{
622 uint64_t new_max_pending_value;
623 unsigned int i;
624
625 for (i = 0, new_max_pending_value = 0; i < fence->semaphore_count; ++i)
626 new_max_pending_value = max(fence->semaphores[i].value, new_max_pending_value);
627
628 fence->max_pending_value = max(fence->value, new_max_pending_value);
629}
630
632{
633 vkd3d_mutex_lock(&fence->mutex);
634
636
637 vkd3d_mutex_unlock(&fence->mutex);
638
639 return S_OK;
640}
641
643{
644 struct d3d12_device *device = command_queue->device;
645 HRESULT hr = S_OK;
646
647 vkd3d_mutex_lock(&device->blocked_queues_mutex);
648
649 if (device->blocked_queue_count < ARRAY_SIZE(device->blocked_queues))
650 {
651 device->blocked_queues[device->blocked_queue_count++] = command_queue;
652 }
653 else
654 {
655 WARN("Failed to add blocked command queue %p to device %p.\n", command_queue, device);
656 hr = E_FAIL;
657 }
658
659 vkd3d_mutex_unlock(&device->blocked_queues_mutex);
660 return hr;
661}
662
664{
666 unsigned int i, blocked_queue_count;
667 HRESULT hr = S_OK;
668
669 *flushed_any = false;
670
671 vkd3d_mutex_lock(&device->blocked_queues_mutex);
672
673 /* Flush any ops unblocked by a new pending value. These cannot be
674 * flushed while holding blocked_queue_mutex, so move the queue
675 * pointers to a local array. */
676 blocked_queue_count = device->blocked_queue_count;
677 memcpy(blocked_queues, device->blocked_queues, blocked_queue_count * sizeof(blocked_queues[0]));
678 device->blocked_queue_count = 0;
679
680 vkd3d_mutex_unlock(&device->blocked_queues_mutex);
681
682 for (i = 0; i < blocked_queue_count; ++i)
683 {
684 HRESULT new_hr;
685
686 new_hr = d3d12_command_queue_flush_ops(blocked_queues[i], flushed_any);
687
688 if (SUCCEEDED(hr))
689 hr = new_hr;
690 }
691
692 return hr;
693}
694
696{
697 bool flushed_any;
698 HRESULT hr;
699
700 /* Executing an op on one queue may unblock another, so repeat until nothing is flushed. */
701 do
702 {
704 return hr;
705 }
706 while (flushed_any);
707
708 return S_OK;
709}
710
711static HRESULT d3d12_fence_add_vk_semaphore(struct d3d12_fence *fence, VkSemaphore vk_semaphore,
712 VkFence vk_fence, uint64_t value, const struct vkd3d_queue *signalling_queue)
713{
715
716 TRACE("fence %p, value %#"PRIx64".\n", fence, value);
717
718 vkd3d_mutex_lock(&fence->mutex);
719
721
722 if (!vkd3d_array_reserve((void**)&fence->semaphores, &fence->semaphores_size,
723 fence->semaphore_count + 1, sizeof(*fence->semaphores)))
724 {
725 ERR("Failed to add semaphore.\n");
726 vkd3d_mutex_unlock(&fence->mutex);
727 return E_OUTOFMEMORY;
728 }
729
730 semaphore = &fence->semaphores[fence->semaphore_count++];
731 semaphore->value = value;
732 semaphore->u.binary.vk_semaphore = vk_semaphore;
733 semaphore->u.binary.vk_fence = vk_fence;
734 semaphore->u.binary.is_acquired = false;
735 semaphore->signalling_queue = signalling_queue;
736
738
739 vkd3d_mutex_unlock(&fence->mutex);
740
742}
743
745{
746 struct d3d12_device *device = fence->device;
747 bool signal_null_event_cond = false;
748 unsigned int i, j;
749
750 for (i = 0, j = 0; i < fence->event_count; ++i)
751 {
752 struct vkd3d_waiting_event *current = &fence->events[i];
753
754 if (current->value <= fence->value)
755 {
756 if (current->event)
757 {
758 device->signal_event(current->event);
759 }
760 else
761 {
762 *current->latch = true;
763 signal_null_event_cond = true;
764 }
765 }
766 else
767 {
768 if (i != j)
769 fence->events[j] = *current;
770 ++j;
771 }
772 }
773
774 fence->event_count = j;
775
776 if (signal_null_event_cond)
778}
779
780static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkFence vk_fence, bool on_cpu)
781{
782 struct d3d12_device *device = fence->device;
784 unsigned int i;
785
786 vkd3d_mutex_lock(&fence->mutex);
787
788 fence->value = value;
789
791
792 if (vk_fence)
793 {
794 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
795
796 for (i = 0; i < fence->semaphore_count; ++i)
797 {
798 current = &fence->semaphores[i];
799 if (current->u.binary.vk_fence == vk_fence)
800 current->u.binary.vk_fence = VK_NULL_HANDLE;
801 }
802
803 for (i = 0; i < ARRAY_SIZE(fence->old_vk_fences); ++i)
804 {
805 if (fence->old_vk_fences[i] == VK_NULL_HANDLE)
806 {
807 fence->old_vk_fences[i] = vk_fence;
808 VK_CALL(vkResetFences(device->vk_device, 1, &vk_fence));
809 vk_fence = VK_NULL_HANDLE;
810 break;
811 }
812 }
813 if (vk_fence)
814 VK_CALL(vkDestroyFence(device->vk_device, vk_fence, NULL));
815 }
816
818
819 vkd3d_mutex_unlock(&fence->mutex);
820
822}
823
825 const struct vkd3d_queue *signalling_queue)
826{
828
829 vkd3d_mutex_lock(&fence->mutex);
830
831 if (!vkd3d_array_reserve((void **)&fence->semaphores, &fence->semaphores_size,
832 fence->semaphore_count + 1, sizeof(*fence->semaphores)))
833 {
834 return 0;
835 }
836
837 semaphore = &fence->semaphores[fence->semaphore_count++];
838 semaphore->value = virtual_value;
839 semaphore->u.timeline_value = ++fence->pending_timeline_value;
840 semaphore->signalling_queue = signalling_queue;
841
842 vkd3d_mutex_unlock(&fence->mutex);
843
844 return fence->pending_timeline_value;
845}
846
848{
849 uint64_t target_timeline_value = UINT64_MAX;
850 unsigned int i;
851
852 /* Find the smallest physical value which is at least the virtual value. */
853 for (i = 0; i < fence->semaphore_count; ++i)
854 {
855 if (virtual_value <= fence->semaphores[i].value)
856 target_timeline_value = min(target_timeline_value, fence->semaphores[i].u.timeline_value);
857 }
858
859 /* No timeline value will be found if it was already signaled on the GPU and handled in
860 * the worker thread. A wait must still be emitted as a barrier against command re-ordering. */
861 return (target_timeline_value == UINT64_MAX) ? 0 : target_timeline_value;
862}
863
865{
866 bool did_signal;
867 unsigned int i;
868
869 vkd3d_mutex_lock(&fence->mutex);
870
871 /* With multiple fence workers, it is possible that signal calls are out of
872 * order. The physical value itself is monotonic, but we need to make sure
873 * that all signals happen in correct order if there are fence rewinds.
874 * We don't expect the loop to run more than once, but there might be
875 * extreme edge cases where we signal 2 or more. */
876 while (fence->timeline_value < timeline_value)
877 {
878 ++fence->timeline_value;
879 did_signal = false;
880
881 for (i = 0; i < fence->semaphore_count; ++i)
882 {
883 if (fence->timeline_value == fence->semaphores[i].u.timeline_value)
884 {
885 fence->value = fence->semaphores[i].value;
887 fence->semaphores[i] = fence->semaphores[--fence->semaphore_count];
888 did_signal = true;
889 break;
890 }
891 }
892
893 if (!did_signal)
894 FIXME("Did not signal a virtual value.\n");
895 }
896
897 /* If a rewind remains queued, the virtual value deleted above may be
898 * greater than any pending value, so update the max pending value. */
900
901 vkd3d_mutex_unlock(&fence->mutex);
902}
903
905 REFIID riid, void **object)
906{
907 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
908
909 if (IsEqualGUID(riid, &IID_ID3D12Fence1)
910 || IsEqualGUID(riid, &IID_ID3D12Fence)
911 || IsEqualGUID(riid, &IID_ID3D12Pageable)
912 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
913 || IsEqualGUID(riid, &IID_ID3D12Object)
915 {
916 ID3D12Fence1_AddRef(iface);
917 *object = iface;
918 return S_OK;
919 }
920
921 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
922
923 *object = NULL;
924 return E_NOINTERFACE;
925}
926
928{
929 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
930 unsigned int refcount = vkd3d_atomic_increment_u32(&fence->refcount);
931
932 TRACE("%p increasing refcount to %u.\n", fence, refcount);
933
934 return refcount;
935}
936
937static void d3d12_fence_incref(struct d3d12_fence *fence)
938{
940}
941
943{
944 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
945 unsigned int refcount = vkd3d_atomic_decrement_u32(&fence->refcount);
946
947 TRACE("%p decreasing refcount to %u.\n", fence, refcount);
948
949 if (!refcount)
950 d3d12_fence_decref(fence);
951
952 return refcount;
953}
954
955static void d3d12_fence_decref(struct d3d12_fence *fence)
956{
957 struct d3d12_device *device;
958
960 return;
961
962 device = fence->device;
963
965
967
968 vkd3d_free(fence->events);
969 vkd3d_free(fence->semaphores);
970 vkd3d_mutex_destroy(&fence->mutex);
972 vkd3d_free(fence);
973
975}
976
978 REFGUID guid, UINT *data_size, void *data)
979{
980 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
981
982 TRACE("iface %p, guid %s, data_size %p, data %p.\n",
983 iface, debugstr_guid(guid), data_size, data);
984
985 return vkd3d_get_private_data(&fence->private_store, guid, data_size, data);
986}
987
989 REFGUID guid, UINT data_size, const void *data)
990{
991 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
992
993 TRACE("iface %p, guid %s, data_size %u, data %p.\n",
994 iface, debugstr_guid(guid), data_size, data);
995
996 return vkd3d_set_private_data(&fence->private_store, guid, data_size, data);
997}
998
1000 REFGUID guid, const IUnknown *data)
1001{
1002 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1003
1004 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
1005
1007}
1008
1010{
1011 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1012
1013 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, fence->device->wchar_size));
1014
1015 return name ? S_OK : E_INVALIDARG;
1016}
1017
1019{
1020 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1021
1022 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
1023
1024 return d3d12_device_query_interface(fence->device, iid, device);
1025}
1026
1028{
1029 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1030 uint64_t completed_value;
1031
1032 TRACE("iface %p.\n", iface);
1033
1034 vkd3d_mutex_lock(&fence->mutex);
1035 completed_value = fence->value;
1036 vkd3d_mutex_unlock(&fence->mutex);
1037 return completed_value;
1038}
1039
1042{
1043 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1044 unsigned int i;
1045 bool latch = false;
1046
1047 TRACE("iface %p, value %#"PRIx64", event %p.\n", iface, value, event);
1048
1049 vkd3d_mutex_lock(&fence->mutex);
1050
1051 if (value <= fence->value)
1052 {
1053 if (event)
1054 fence->device->signal_event(event);
1055 vkd3d_mutex_unlock(&fence->mutex);
1056 return S_OK;
1057 }
1058
1059 for (i = 0; i < fence->event_count; ++i)
1060 {
1061 struct vkd3d_waiting_event *current = &fence->events[i];
1062 if (current->value == value && current->event == event)
1063 {
1064 WARN("Event completion for (%p, %#"PRIx64") is already in the list.\n",
1065 event, value);
1066 vkd3d_mutex_unlock(&fence->mutex);
1067 return S_OK;
1068 }
1069 }
1070
1071 if (!vkd3d_array_reserve((void **)&fence->events, &fence->events_size,
1072 fence->event_count + 1, sizeof(*fence->events)))
1073 {
1074 WARN("Failed to add event.\n");
1075 vkd3d_mutex_unlock(&fence->mutex);
1076 return E_OUTOFMEMORY;
1077 }
1078
1079 fence->events[fence->event_count].value = value;
1080 fence->events[fence->event_count].event = event;
1081 fence->events[fence->event_count].latch = &latch;
1082 ++fence->event_count;
1083
1084 /* If event is NULL, we need to block until the fence value completes.
1085 * Implement this in a uniform way where we pretend we have a dummy event.
1086 * A NULL fence->events[].event means that we should set latch to true
1087 * and signal a condition variable instead of calling external signal_event callback. */
1088 if (!event)
1089 {
1090 while (!latch)
1091 vkd3d_cond_wait(&fence->null_event_cond, &fence->mutex);
1092 }
1093
1094 vkd3d_mutex_unlock(&fence->mutex);
1095 return S_OK;
1096}
1097
1099{
1100 vkd3d_mutex_lock(&fence->mutex);
1101
1102 fence->value = value;
1105
1106 vkd3d_mutex_unlock(&fence->mutex);
1107
1109}
1110
1112{
1113 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1114
1115 TRACE("iface %p, value %#"PRIx64".\n", iface, value);
1116
1117 if (fence->timeline_semaphore)
1119 return d3d12_fence_signal(fence, value, VK_NULL_HANDLE, true);
1120}
1121
1123{
1124 struct d3d12_fence *fence = impl_from_ID3D12Fence1(iface);
1125
1126 TRACE("iface %p.\n", iface);
1127
1128 return fence->flags;
1129}
1130
1131static const struct ID3D12Fence1Vtbl d3d12_fence_vtbl =
1132{
1133 /* IUnknown methods */
1137 /* ID3D12Object methods */
1142 /* ID3D12DeviceChild methods */
1144 /* ID3D12Fence methods */
1148 /* ID3D12Fence1 methods */
1150};
1151
1153{
1154 ID3D12Fence1 *iface1;
1155
1156 if (!(iface1 = (ID3D12Fence1 *)iface))
1157 return NULL;
1158 VKD3D_ASSERT(iface1->lpVtbl == &d3d12_fence_vtbl);
1159 return impl_from_ID3D12Fence1(iface1);
1160}
1161
1163 UINT64 initial_value, D3D12_FENCE_FLAGS flags)
1164{
1165 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1166 VkResult vr;
1167 HRESULT hr;
1168
1169 fence->ID3D12Fence1_iface.lpVtbl = &d3d12_fence_vtbl;
1170 fence->internal_refcount = 1;
1171 fence->refcount = 1;
1172
1173 fence->value = initial_value;
1174 fence->max_pending_value = initial_value;
1175
1176 vkd3d_mutex_init(&fence->mutex);
1177
1179
1180 if ((fence->flags = flags))
1181 FIXME("Ignoring flags %#x.\n", flags);
1182
1183 fence->events = NULL;
1184 fence->events_size = 0;
1185 fence->event_count = 0;
1186
1188 fence->timeline_value = 0;
1189 fence->pending_timeline_value = 0;
1190 if (device->vk_info.KHR_timeline_semaphore && (vr = vkd3d_create_timeline_semaphore(device, 0,
1191 &fence->timeline_semaphore)) < 0)
1192 {
1193 WARN("Failed to create timeline semaphore, vr %d.\n", vr);
1195 goto fail_destroy_null_cond;
1196 }
1197
1198 fence->semaphores = NULL;
1199 fence->semaphores_size = 0;
1200 fence->semaphore_count = 0;
1201
1202 memset(fence->old_vk_fences, 0, sizeof(fence->old_vk_fences));
1203
1205 {
1206 goto fail_destroy_timeline_semaphore;
1207 }
1208
1210
1211 return S_OK;
1212
1213fail_destroy_timeline_semaphore:
1215fail_destroy_null_cond:
1217 vkd3d_mutex_destroy(&fence->mutex);
1218
1219 return hr;
1220}
1221
1223 uint64_t initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence)
1224{
1225 struct d3d12_fence *object;
1226
1227 if (!(object = vkd3d_malloc(sizeof(*object))))
1228 return E_OUTOFMEMORY;
1229
1230 d3d12_fence_init(object, device, initial_value, flags);
1231
1232 TRACE("Created fence %p.\n", object);
1233
1234 *fence = object;
1235
1236 return S_OK;
1237}
1238
1240 VkSemaphore *timeline_semaphore)
1241{
1242 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1245
1247 info.pNext = &type_info;
1248 info.flags = 0;
1249
1251 type_info.pNext = NULL;
1253 type_info.initialValue = initial_value;
1254
1255 return VK_CALL(vkCreateSemaphore(device->vk_device, &info, NULL, timeline_semaphore));
1256}
1257
1258/* Command buffers */
1260 const char *message, ...)
1261{
1262 va_list args;
1263
1265 WARN("Command list %p is invalid: \"%s\".\n", list, vkd3d_dbg_vsprintf(message, args));
1266 va_end(args);
1267
1268 list->is_valid = false;
1269}
1270
1272{
1273 struct d3d12_device *device = list->device;
1274 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1275 VkCommandBufferBeginInfo begin_info;
1276 VkResult vr;
1277
1279 begin_info.pNext = NULL;
1280 begin_info.flags = 0;
1281 begin_info.pInheritanceInfo = NULL;
1282
1283 if ((vr = VK_CALL(vkBeginCommandBuffer(list->vk_command_buffer, &begin_info))) < 0)
1284 {
1285 WARN("Failed to begin command buffer, vr %d.\n", vr);
1286 return hresult_from_vk_result(vr);
1287 }
1288
1289 list->is_recording = true;
1290 list->is_valid = true;
1291
1292 return S_OK;
1293}
1294
1296 struct d3d12_command_list *list)
1297{
1298 struct d3d12_device *device = allocator->device;
1299 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1300 VkCommandBufferAllocateInfo command_buffer_info;
1301 VkResult vr;
1302 HRESULT hr;
1303
1304 TRACE("allocator %p, list %p.\n", allocator, list);
1305
1306 if (allocator->current_command_list)
1307 {
1308 WARN("Command allocator is already in use.\n");
1309 return E_INVALIDARG;
1310 }
1311
1313 command_buffer_info.pNext = NULL;
1314 command_buffer_info.commandPool = allocator->vk_command_pool;
1315 command_buffer_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
1316 command_buffer_info.commandBufferCount = 1;
1317
1318 if ((vr = VK_CALL(vkAllocateCommandBuffers(device->vk_device, &command_buffer_info,
1319 &list->vk_command_buffer))) < 0)
1320 {
1321 WARN("Failed to allocate Vulkan command buffer, vr %d.\n", vr);
1322 return hresult_from_vk_result(vr);
1323 }
1324
1325 list->vk_queue_flags = allocator->vk_queue_flags;
1326
1328 {
1329 VK_CALL(vkFreeCommandBuffers(device->vk_device, allocator->vk_command_pool,
1330 1, &list->vk_command_buffer));
1331 return hr;
1332 }
1333
1334 if (!vkd3d_array_reserve((void **)&allocator->command_buffers, &allocator->command_buffers_size,
1335 allocator->command_buffer_count + 1, sizeof(*allocator->command_buffers)))
1336 {
1337 WARN("Failed to add command buffer.\n");
1338 VK_CALL(vkFreeCommandBuffers(device->vk_device, allocator->vk_command_pool,
1339 1, &list->vk_command_buffer));
1340 return E_OUTOFMEMORY;
1341 }
1342 allocator->command_buffers[allocator->command_buffer_count++] = list->vk_command_buffer;
1343
1344 allocator->current_command_list = list;
1345
1346 return S_OK;
1347}
1348
1350 const struct d3d12_command_list *list)
1351{
1352 if (allocator->current_command_list == list)
1353 allocator->current_command_list = NULL;
1354}
1355
1357{
1358 if (!vkd3d_array_reserve((void **)&allocator->passes, &allocator->passes_size,
1359 allocator->pass_count + 1, sizeof(*allocator->passes)))
1360 return false;
1361
1362 allocator->passes[allocator->pass_count++] = pass;
1363
1364 return true;
1365}
1366
1368 VkFramebuffer framebuffer)
1369{
1370 if (!vkd3d_array_reserve((void **)&allocator->framebuffers, &allocator->framebuffers_size,
1371 allocator->framebuffer_count + 1, sizeof(*allocator->framebuffers)))
1372 return false;
1373
1374 allocator->framebuffers[allocator->framebuffer_count++] = framebuffer;
1375
1376 return true;
1377}
1378
1380 VkDescriptorPool pool)
1381{
1382 if (!vkd3d_array_reserve((void **)&allocator->descriptor_pools, &allocator->descriptor_pools_size,
1383 allocator->descriptor_pool_count + 1, sizeof(*allocator->descriptor_pools)))
1384 return false;
1385
1386 allocator->descriptor_pools[allocator->descriptor_pool_count++] = pool;
1387
1388 return true;
1389}
1390
1392 struct vkd3d_view *view)
1393{
1394 if (!vkd3d_array_reserve((void **)&allocator->views, &allocator->views_size,
1395 allocator->view_count + 1, sizeof(*allocator->views)))
1396 return false;
1397
1399 allocator->views[allocator->view_count++] = view;
1400
1401 return true;
1402}
1403
1405 VkBufferView view)
1406{
1407 if (!vkd3d_array_reserve((void **)&allocator->buffer_views, &allocator->buffer_views_size,
1408 allocator->buffer_view_count + 1, sizeof(*allocator->buffer_views)))
1409 return false;
1410
1411 allocator->buffer_views[allocator->buffer_view_count++] = view;
1412
1413 return true;
1414}
1415
1417 const struct vkd3d_buffer *buffer)
1418{
1419 if (!vkd3d_array_reserve((void **)&allocator->transfer_buffers, &allocator->transfer_buffers_size,
1420 allocator->transfer_buffer_count + 1, sizeof(*allocator->transfer_buffers)))
1421 return false;
1422
1423 allocator->transfer_buffers[allocator->transfer_buffer_count++] = *buffer;
1424
1425 return true;
1426}
1427
1430{
1431 struct d3d12_device *device = allocator->device;
1432 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1433 struct VkDescriptorPoolCreateInfo pool_desc;
1434 VkDevice vk_device = device->vk_device;
1435 VkDescriptorPool vk_pool;
1436 VkResult vr;
1437
1438 if (allocator->free_descriptor_pool_count > 0)
1439 {
1440 vk_pool = allocator->free_descriptor_pools[allocator->free_descriptor_pool_count - 1];
1441 allocator->free_descriptor_pools[allocator->free_descriptor_pool_count - 1] = VK_NULL_HANDLE;
1442 --allocator->free_descriptor_pool_count;
1443 }
1444 else
1445 {
1447 pool_desc.pNext = NULL;
1448 pool_desc.flags = 0;
1449 pool_desc.maxSets = 512;
1450 pool_desc.poolSizeCount = device->vk_pool_count;
1451 pool_desc.pPoolSizes = device->vk_pool_sizes;
1452 if ((vr = VK_CALL(vkCreateDescriptorPool(vk_device, &pool_desc, NULL, &vk_pool))) < 0)
1453 {
1454 ERR("Failed to create descriptor pool, vr %d.\n", vr);
1455 return VK_NULL_HANDLE;
1456 }
1457 }
1458
1460 {
1461 ERR("Failed to add descriptor pool.\n");
1462 VK_CALL(vkDestroyDescriptorPool(vk_device, vk_pool, NULL));
1463 return VK_NULL_HANDLE;
1464 }
1465
1466 return vk_pool;
1467}
1468
1470 struct d3d12_command_allocator *allocator, VkDescriptorSetLayout vk_set_layout,
1471 unsigned int variable_binding_size, bool unbounded)
1472{
1473 struct d3d12_device *device = allocator->device;
1474 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1476 struct VkDescriptorSetAllocateInfo set_desc;
1477 VkDevice vk_device = device->vk_device;
1478 VkDescriptorSet vk_descriptor_set;
1479 VkResult vr;
1480
1481 if (!allocator->vk_descriptor_pool)
1483 if (!allocator->vk_descriptor_pool)
1484 return VK_NULL_HANDLE;
1485
1487 set_desc.pNext = NULL;
1488 set_desc.descriptorPool = allocator->vk_descriptor_pool;
1489 set_desc.descriptorSetCount = 1;
1490 set_desc.pSetLayouts = &vk_set_layout;
1491 if (unbounded)
1492 {
1493 set_desc.pNext = &set_size;
1495 set_size.pNext = NULL;
1496 set_size.descriptorSetCount = 1;
1497 set_size.pDescriptorCounts = &variable_binding_size;
1498 }
1499 if ((vr = VK_CALL(vkAllocateDescriptorSets(vk_device, &set_desc, &vk_descriptor_set))) >= 0)
1500 return vk_descriptor_set;
1501
1502 allocator->vk_descriptor_pool = VK_NULL_HANDLE;
1505 if (!allocator->vk_descriptor_pool)
1506 {
1507 ERR("Failed to allocate descriptor set, vr %d.\n", vr);
1508 return VK_NULL_HANDLE;
1509 }
1510
1511 set_desc.descriptorPool = allocator->vk_descriptor_pool;
1512 if ((vr = VK_CALL(vkAllocateDescriptorSets(vk_device, &set_desc, &vk_descriptor_set))) < 0)
1513 {
1514 FIXME("Failed to allocate descriptor set from a new pool, vr %d.\n", vr);
1515 return VK_NULL_HANDLE;
1516 }
1517
1518 return vk_descriptor_set;
1519}
1520
1522{
1523 TRACE("list %p.\n", list);
1524
1525 list->allocator = NULL;
1526 list->vk_command_buffer = VK_NULL_HANDLE;
1527}
1528
1530{
1531 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1532
1533 VK_CALL(vkFreeMemory(device->vk_device, buffer->vk_memory, NULL));
1534 VK_CALL(vkDestroyBuffer(device->vk_device, buffer->vk_buffer, NULL));
1535}
1536
1538 bool keep_reusable_resources)
1539{
1540 struct d3d12_device *device = allocator->device;
1541 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1542 unsigned int i, j;
1543
1544 allocator->vk_descriptor_pool = VK_NULL_HANDLE;
1545
1546 if (keep_reusable_resources)
1547 {
1548 if (vkd3d_array_reserve((void **)&allocator->free_descriptor_pools,
1549 &allocator->free_descriptor_pools_size,
1550 allocator->free_descriptor_pool_count + allocator->descriptor_pool_count,
1551 sizeof(*allocator->free_descriptor_pools)))
1552 {
1553 for (i = 0, j = allocator->free_descriptor_pool_count; i < allocator->descriptor_pool_count; ++i, ++j)
1554 {
1555 VK_CALL(vkResetDescriptorPool(device->vk_device, allocator->descriptor_pools[i], 0));
1556 allocator->free_descriptor_pools[j] = allocator->descriptor_pools[i];
1557 }
1558 allocator->free_descriptor_pool_count += allocator->descriptor_pool_count;
1559 allocator->descriptor_pool_count = 0;
1560 }
1561 }
1562 else
1563 {
1564 for (i = 0; i < allocator->free_descriptor_pool_count; ++i)
1565 {
1566 VK_CALL(vkDestroyDescriptorPool(device->vk_device, allocator->free_descriptor_pools[i], NULL));
1567 }
1568 allocator->free_descriptor_pool_count = 0;
1569 }
1570
1571 for (i = 0; i < allocator->transfer_buffer_count; ++i)
1572 {
1573 vkd3d_buffer_destroy(&allocator->transfer_buffers[i], device);
1574 }
1575 allocator->transfer_buffer_count = 0;
1576
1577 for (i = 0; i < allocator->buffer_view_count; ++i)
1578 {
1579 VK_CALL(vkDestroyBufferView(device->vk_device, allocator->buffer_views[i], NULL));
1580 }
1581 allocator->buffer_view_count = 0;
1582
1583 for (i = 0; i < allocator->view_count; ++i)
1584 {
1586 }
1587 allocator->view_count = 0;
1588
1589 for (i = 0; i < allocator->descriptor_pool_count; ++i)
1590 {
1591 VK_CALL(vkDestroyDescriptorPool(device->vk_device, allocator->descriptor_pools[i], NULL));
1592 }
1593 allocator->descriptor_pool_count = 0;
1594
1595 for (i = 0; i < allocator->framebuffer_count; ++i)
1596 {
1597 VK_CALL(vkDestroyFramebuffer(device->vk_device, allocator->framebuffers[i], NULL));
1598 }
1599 allocator->framebuffer_count = 0;
1600
1601 for (i = 0; i < allocator->pass_count; ++i)
1602 {
1603 VK_CALL(vkDestroyRenderPass(device->vk_device, allocator->passes[i], NULL));
1604 }
1605 allocator->pass_count = 0;
1606}
1607
1608/* ID3D12CommandAllocator */
1610{
1612}
1613
1615 REFIID riid, void **object)
1616{
1617 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
1618
1619 if (IsEqualGUID(riid, &IID_ID3D12CommandAllocator)
1620 || IsEqualGUID(riid, &IID_ID3D12Pageable)
1621 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
1622 || IsEqualGUID(riid, &IID_ID3D12Object)
1624 {
1625 ID3D12CommandAllocator_AddRef(iface);
1626 *object = iface;
1627 return S_OK;
1628 }
1629
1630 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
1631
1632 *object = NULL;
1633 return E_NOINTERFACE;
1634}
1635
1637{
1639 unsigned int refcount = vkd3d_atomic_increment_u32(&allocator->refcount);
1640
1641 TRACE("%p increasing refcount to %u.\n", allocator, refcount);
1642
1643 return refcount;
1644}
1645
1647{
1649 unsigned int refcount = vkd3d_atomic_decrement_u32(&allocator->refcount);
1650
1651 TRACE("%p decreasing refcount to %u.\n", allocator, refcount);
1652
1653 if (!refcount)
1654 {
1655 struct d3d12_device *device = allocator->device;
1656 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1657
1658 vkd3d_private_store_destroy(&allocator->private_store);
1659
1660 if (allocator->current_command_list)
1662
1664 vkd3d_free(allocator->transfer_buffers);
1665 vkd3d_free(allocator->buffer_views);
1666 vkd3d_free(allocator->views);
1667 vkd3d_free(allocator->descriptor_pools);
1668 vkd3d_free(allocator->free_descriptor_pools);
1669 vkd3d_free(allocator->framebuffers);
1670 vkd3d_free(allocator->passes);
1671
1672 /* All command buffers are implicitly freed when a pool is destroyed. */
1673 vkd3d_free(allocator->command_buffers);
1674 VK_CALL(vkDestroyCommandPool(device->vk_device, allocator->vk_command_pool, NULL));
1675
1677
1679 }
1680
1681 return refcount;
1682}
1683
1685 REFGUID guid, UINT *data_size, void *data)
1686{
1688
1689 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
1690
1691 return vkd3d_get_private_data(&allocator->private_store, guid, data_size, data);
1692}
1693
1695 REFGUID guid, UINT data_size, const void *data)
1696{
1698
1699 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
1700
1701 return vkd3d_set_private_data(&allocator->private_store, guid, data_size, data);
1702}
1703
1705 REFGUID guid, const IUnknown *data)
1706{
1708
1709 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
1710
1711 return vkd3d_set_private_data_interface(&allocator->private_store, guid, data);
1712}
1713
1715{
1717
1718 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, allocator->device->wchar_size));
1719
1720 return vkd3d_set_vk_object_name(allocator->device, (uint64_t)allocator->vk_command_pool,
1722}
1723
1725{
1727
1728 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
1729
1730 return d3d12_device_query_interface(allocator->device, iid, device);
1731}
1732
1734{
1736 const struct vkd3d_vk_device_procs *vk_procs;
1737 struct d3d12_command_list *list;
1738 struct d3d12_device *device;
1739 VkResult vr;
1740
1741 TRACE("iface %p.\n", iface);
1742
1743 if ((list = allocator->current_command_list))
1744 {
1745 if (list->is_recording)
1746 {
1747 WARN("A command list using this allocator is in the recording state.\n");
1748 return E_FAIL;
1749 }
1750
1751 TRACE("Resetting command list %p.\n", list);
1752 }
1753
1754 device = allocator->device;
1755 vk_procs = &device->vk_procs;
1756
1758 if (allocator->command_buffer_count)
1759 {
1760 VK_CALL(vkFreeCommandBuffers(device->vk_device, allocator->vk_command_pool,
1761 allocator->command_buffer_count, allocator->command_buffers));
1762 allocator->command_buffer_count = 0;
1763 }
1764
1765 /* The intent here is to recycle memory, so do not use RELEASE_RESOURCES_BIT here. */
1766 if ((vr = VK_CALL(vkResetCommandPool(device->vk_device, allocator->vk_command_pool, 0))))
1767 {
1768 WARN("Resetting command pool failed, vr %d.\n", vr);
1769 return hresult_from_vk_result(vr);
1770 }
1771
1772 return S_OK;
1773}
1774
1775static const struct ID3D12CommandAllocatorVtbl d3d12_command_allocator_vtbl =
1776{
1777 /* IUnknown methods */
1781 /* ID3D12Object methods */
1786 /* ID3D12DeviceChild methods */
1788 /* ID3D12CommandAllocator methods */
1790};
1791
1793{
1794 if (!iface)
1795 return NULL;
1796 VKD3D_ASSERT(iface->lpVtbl == &d3d12_command_allocator_vtbl);
1798}
1799
1802{
1803 switch (type)
1804 {
1806 return device->direct_queue;
1808 return device->compute_queue;
1810 return device->copy_queue;
1811 default:
1812 FIXME("Unhandled command list type %#x.\n", type);
1813 return NULL;
1814 }
1815}
1816
1819{
1820 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1821 VkCommandPoolCreateInfo command_pool_info;
1822 struct vkd3d_queue *queue;
1823 VkResult vr;
1824 HRESULT hr;
1825
1826 if (FAILED(hr = vkd3d_private_store_init(&allocator->private_store)))
1827 return hr;
1828
1830 queue = device->direct_queue;
1831
1832 allocator->ID3D12CommandAllocator_iface.lpVtbl = &d3d12_command_allocator_vtbl;
1833 allocator->refcount = 1;
1834
1835 allocator->type = type;
1836 allocator->vk_queue_flags = queue->vk_queue_flags;
1837
1839 command_pool_info.pNext = NULL;
1840 /* Do not use RESET_COMMAND_BUFFER_BIT. This allows the CommandPool to be a D3D12-style command pool.
1841 * Memory is owned by the pool and CommandBuffers become lightweight handles,
1842 * assuming a half-decent driver implementation. */
1843 command_pool_info.flags = 0;
1844 command_pool_info.queueFamilyIndex = queue->vk_family_index;
1845
1846 if ((vr = VK_CALL(vkCreateCommandPool(device->vk_device, &command_pool_info, NULL,
1847 &allocator->vk_command_pool))) < 0)
1848 {
1849 WARN("Failed to create Vulkan command pool, vr %d.\n", vr);
1850 vkd3d_private_store_destroy(&allocator->private_store);
1851 return hresult_from_vk_result(vr);
1852 }
1853
1854 allocator->vk_descriptor_pool = VK_NULL_HANDLE;
1855
1856 allocator->free_descriptor_pools = NULL;
1857 allocator->free_descriptor_pools_size = 0;
1858 allocator->free_descriptor_pool_count = 0;
1859
1860 allocator->passes = NULL;
1861 allocator->passes_size = 0;
1862 allocator->pass_count = 0;
1863
1864 allocator->framebuffers = NULL;
1865 allocator->framebuffers_size = 0;
1866 allocator->framebuffer_count = 0;
1867
1868 allocator->descriptor_pools = NULL;
1869 allocator->descriptor_pools_size = 0;
1870 allocator->descriptor_pool_count = 0;
1871
1872 allocator->views = NULL;
1873 allocator->views_size = 0;
1874 allocator->view_count = 0;
1875
1876 allocator->buffer_views = NULL;
1877 allocator->buffer_views_size = 0;
1878 allocator->buffer_view_count = 0;
1879
1880 allocator->transfer_buffers = NULL;
1881 allocator->transfer_buffers_size = 0;
1882 allocator->transfer_buffer_count = 0;
1883
1884 allocator->command_buffers = NULL;
1885 allocator->command_buffers_size = 0;
1886 allocator->command_buffer_count = 0;
1887
1888 allocator->current_command_list = NULL;
1889
1891
1892 return S_OK;
1893}
1894
1897{
1899 HRESULT hr;
1900
1902 {
1903 WARN("Invalid type %#x.\n", type);
1904 return E_INVALIDARG;
1905 }
1906
1907 if (!(object = vkd3d_malloc(sizeof(*object))))
1908 return E_OUTOFMEMORY;
1909
1911 {
1912 vkd3d_free(object);
1913 return hr;
1914 }
1915
1916 TRACE("Created command allocator %p.\n", object);
1917
1918 *allocator = object;
1919
1920 return S_OK;
1921}
1922
1924{
1925 vkd3d_atomic_increment_u32(&signature->internal_refcount);
1926}
1927
1929{
1930 unsigned int refcount = vkd3d_atomic_decrement_u32(&signature->internal_refcount);
1931
1932 if (!refcount)
1933 {
1934 struct d3d12_device *device = signature->device;
1935
1936 vkd3d_private_store_destroy(&signature->private_store);
1937
1938 vkd3d_free((void *)signature->desc.pArgumentDescs);
1940
1942 }
1943}
1944
1945/* ID3D12CommandList */
1947{
1949}
1950
1952{
1953 list->current_framebuffer = VK_NULL_HANDLE;
1954}
1955
1957{
1958 list->current_pipeline = VK_NULL_HANDLE;
1959}
1960
1962{
1963 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
1964
1965 if (list->xfb_enabled)
1966 {
1967 VK_CALL(vkCmdEndTransformFeedbackEXT(list->vk_command_buffer, 0, ARRAY_SIZE(list->so_counter_buffers),
1968 list->so_counter_buffers, list->so_counter_buffer_offsets));
1969 }
1970
1971 if (list->current_render_pass)
1972 VK_CALL(vkCmdEndRenderPass(list->vk_command_buffer));
1973
1974 list->current_render_pass = VK_NULL_HANDLE;
1975
1976 if (list->xfb_enabled)
1977 {
1978 VkMemoryBarrier vk_barrier;
1979
1980 /* We need a barrier between pause and resume. */
1982 vk_barrier.pNext = NULL;
1985 VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer,
1987 1, &vk_barrier, 0, NULL, 0, NULL));
1988
1989 list->xfb_enabled = false;
1990 }
1991}
1992
1994{
1996}
1997
2000{
2001 if (state && state->uav_counters.binding_count)
2002 {
2003 enum vkd3d_pipeline_bind_point bind_point = (enum vkd3d_pipeline_bind_point)state->vk_bind_point;
2004 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
2005
2006 vkd3d_array_reserve((void **)&bindings->vk_uav_counter_views, &bindings->vk_uav_counter_views_size,
2007 state->uav_counters.binding_count, sizeof(*bindings->vk_uav_counter_views));
2008 memset(bindings->vk_uav_counter_views, 0,
2009 state->uav_counters.binding_count * sizeof(*bindings->vk_uav_counter_views));
2010 bindings->uav_counters_dirty = true;
2011 }
2012}
2013
2015 enum vkd3d_pipeline_bind_point bind_point)
2016{
2017 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
2018
2019 if (!bindings->root_signature)
2020 return;
2021
2022 bindings->descriptor_set_count = 0;
2023 bindings->descriptor_table_dirty_mask = bindings->descriptor_table_active_mask & bindings->root_signature->descriptor_table_mask;
2024 bindings->push_descriptor_dirty_mask = bindings->push_descriptor_active_mask & bindings->root_signature->push_descriptor_mask;
2025 bindings->cbv_srv_uav_heap_id = 0;
2026 bindings->sampler_heap_id = 0;
2027}
2028
2029static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state, unsigned int stencil_state,
2030 const struct d3d12_resource *resource, VkQueueFlags vk_queue_flags, const struct vkd3d_vulkan_info *vk_info,
2031 VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags, VkImageLayout *image_layout,
2032 struct d3d12_device *device)
2033{
2034 bool is_swapchain_image = resource && (resource->flags & VKD3D_RESOURCE_PRESENT_STATE_TRANSITION);
2035 VkPipelineStageFlags queue_shader_stages = 0;
2036
2037 if (vk_queue_flags & VK_QUEUE_GRAPHICS_BIT)
2038 {
2039 queue_shader_stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
2041 if (device->vk_info.geometry_shaders)
2042 queue_shader_stages |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
2043 if (device->vk_info.tessellation_shaders)
2046 }
2047 if (vk_queue_flags & VK_QUEUE_COMPUTE_BIT)
2048 queue_shader_stages |= VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
2049
2050 switch (state)
2051 {
2052 case D3D12_RESOURCE_STATE_COMMON: /* D3D12_RESOURCE_STATE_PRESENT */
2053 /* The COMMON state is used for ownership transfer between
2054 * DIRECT/COMPUTE and COPY queues. Additionally, a texture has to
2055 * be in the COMMON state to be accessed by CPU. Moreover,
2056 * resources can be implicitly promoted to other states out of the
2057 * COMMON state, and the resource state can decay to the COMMON
2058 * state when GPU finishes execution of a command list. */
2059 if (is_swapchain_image)
2060 {
2061 if (resource->present_state != D3D12_RESOURCE_STATE_PRESENT)
2063 resource, vk_queue_flags, vk_info, access_mask, stage_flags, image_layout, device);
2064
2065 *access_mask = VK_ACCESS_MEMORY_READ_BIT;
2067 if (image_layout)
2068 *image_layout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
2069 return true;
2070 }
2071
2073 *stage_flags = VK_PIPELINE_STAGE_HOST_BIT;
2074 if (image_layout)
2075 *image_layout = VK_IMAGE_LAYOUT_GENERAL;
2076 return true;
2077
2078 /* Handle write states. */
2083 if (image_layout)
2085 return true;
2086
2089 *stage_flags = queue_shader_stages;
2090 if (image_layout)
2091 *image_layout = VK_IMAGE_LAYOUT_GENERAL;
2092 return true;
2093
2099 if (image_layout)
2100 {
2101 if (!stencil_state || (stencil_state & D3D12_RESOURCE_STATE_DEPTH_WRITE))
2103 else
2105 }
2106 return true;
2107
2110 *access_mask = VK_ACCESS_TRANSFER_WRITE_BIT;
2111 *stage_flags = VK_PIPELINE_STAGE_TRANSFER_BIT;
2112 if (image_layout)
2114 return true;
2115
2122 if (image_layout)
2123 *image_layout = VK_IMAGE_LAYOUT_UNDEFINED;
2124 return true;
2125
2126 /* Set the Vulkan image layout for read-only states. */
2132 *access_mask = 0;
2133 *stage_flags = 0;
2134 if (image_layout)
2135 {
2136 if (stencil_state & D3D12_RESOURCE_STATE_DEPTH_WRITE)
2137 {
2140 }
2141 else
2142 {
2144 }
2145 }
2146 break;
2147
2151 *access_mask = 0;
2152 *stage_flags = 0;
2153 if (image_layout)
2155 break;
2156
2159 *access_mask = 0;
2160 *stage_flags = 0;
2161 if (image_layout)
2163 break;
2164
2165 default:
2166 *access_mask = 0;
2167 *stage_flags = 0;
2168 if (image_layout)
2169 *image_layout = VK_IMAGE_LAYOUT_GENERAL;
2170 break;
2171 }
2172
2173 /* Handle read-only states. */
2175
2177 {
2181 | queue_shader_stages;
2182 state &= ~D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
2183 }
2184
2186 {
2187 *access_mask |= VK_ACCESS_INDEX_READ_BIT;
2188 *stage_flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
2189 state &= ~D3D12_RESOURCE_STATE_INDEX_BUFFER;
2190 }
2191
2193 {
2197 state &= ~D3D12_RESOURCE_STATE_DEPTH_READ;
2198 }
2199
2201 {
2202 *access_mask |= VK_ACCESS_SHADER_READ_BIT;
2203 *stage_flags |= (queue_shader_stages & ~VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
2204 state &= ~D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
2205 }
2207 {
2208 *access_mask |= VK_ACCESS_SHADER_READ_BIT;
2210 state &= ~D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
2211 }
2212
2213 if (state & D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT) /* D3D12_RESOURCE_STATE_PREDICATION */
2214 {
2217 if (vk_info->EXT_conditional_rendering)
2218 {
2221 }
2222 state &= ~D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
2223 }
2224
2226 {
2227 *access_mask |= VK_ACCESS_TRANSFER_READ_BIT;
2228 *stage_flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
2230 }
2231
2232 if (state)
2233 {
2234 WARN("Invalid resource state %#x.\n", state);
2235 return false;
2236 }
2237 return true;
2238}
2239
2241 struct d3d12_resource *resource)
2242{
2243 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
2244 const struct vkd3d_vulkan_info *vk_info = &list->device->vk_info;
2245 VkPipelineStageFlags src_stage_mask, dst_stage_mask;
2246 VkImageMemoryBarrier barrier;
2247
2249
2251 barrier.pNext = NULL;
2252
2253 /* vkQueueSubmit() defines a memory dependency with prior host writes. */
2254 src_stage_mask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
2255 barrier.srcAccessMask = 0;
2258
2260 resource, list->vk_queue_flags, vk_info, &barrier.dstAccessMask,
2261 &dst_stage_mask, &barrier.newLayout, list->device))
2262 {
2263 FIXME("Unhandled state %#x.\n", resource->initial_state);
2264 return;
2265 }
2266
2269 barrier.image = resource->u.vk_image;
2270 barrier.subresourceRange.aspectMask = resource->format->vk_aspect_mask;
2271 barrier.subresourceRange.baseMipLevel = 0;
2273 barrier.subresourceRange.baseArrayLayer = 0;
2275
2276 TRACE("Initial state %#x transition for resource %p (old layout %#x, new layout %#x).\n",
2277 resource->initial_state, resource, barrier.oldLayout, barrier.newLayout);
2278
2279 VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer, src_stage_mask, dst_stage_mask, 0,
2280 0, NULL, 0, NULL, 1, &barrier));
2281}
2282
2284 struct d3d12_resource *resource)
2285{
2287 {
2289
2291 resource->flags &= ~VKD3D_RESOURCE_INITIAL_STATE_TRANSITION;
2292 }
2293}
2294
2296 REFIID iid, void **object)
2297{
2298 TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
2299
2300 if (IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList6)
2301 || IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList5)
2302 || IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList4)
2303 || IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList3)
2304 || IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList2)
2305 || IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList1)
2306 || IsEqualGUID(iid, &IID_ID3D12GraphicsCommandList)
2307 || IsEqualGUID(iid, &IID_ID3D12CommandList)
2308 || IsEqualGUID(iid, &IID_ID3D12DeviceChild)
2309 || IsEqualGUID(iid, &IID_ID3D12Object)
2310 || IsEqualGUID(iid, &IID_IUnknown))
2311 {
2312 ID3D12GraphicsCommandList6_AddRef(iface);
2313 *object = iface;
2314 return S_OK;
2315 }
2316
2317 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
2318
2319 *object = NULL;
2320 return E_NOINTERFACE;
2321}
2322
2324{
2326 unsigned int refcount = vkd3d_atomic_increment_u32(&list->refcount);
2327
2328 TRACE("%p increasing refcount to %u.\n", list, refcount);
2329
2330 return refcount;
2331}
2332
2334{
2336}
2337
2339{
2341 unsigned int refcount = vkd3d_atomic_decrement_u32(&list->refcount);
2342
2343 TRACE("%p decreasing refcount to %u.\n", list, refcount);
2344
2345 if (!refcount)
2346 {
2347 struct d3d12_device *device = list->device;
2348
2349 vkd3d_private_store_destroy(&list->private_store);
2350
2351 /* When command pool is destroyed, all command buffers are implicitly freed. */
2352 if (list->allocator)
2354
2357
2359
2361 }
2362
2363 return refcount;
2364}
2365
2367 REFGUID guid, UINT *data_size, void *data)
2368{
2370
2371 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2372
2373 return vkd3d_get_private_data(&list->private_store, guid, data_size, data);
2374}
2375
2377 REFGUID guid, UINT data_size, const void *data)
2378{
2380
2381 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
2382
2383 return vkd3d_set_private_data(&list->private_store, guid, data_size, data);
2384}
2385
2387 REFGUID guid, const IUnknown *data)
2388{
2390
2391 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
2392
2393 return vkd3d_set_private_data_interface(&list->private_store, guid, data);
2394}
2395
2397{
2399
2400 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, list->device->wchar_size));
2401
2402 return name ? S_OK : E_INVALIDARG;
2403}
2404
2406 REFIID iid, void **device)
2407{
2409
2410 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
2411
2412 return d3d12_device_query_interface(list->device, iid, device);
2413}
2414
2416{
2418
2419 TRACE("iface %p.\n", iface);
2420
2421 return list->type;
2422}
2423
2425{
2427 const struct vkd3d_vk_device_procs *vk_procs;
2428 VkResult vr;
2429
2430 TRACE("iface %p.\n", iface);
2431
2432 if (!list->is_recording)
2433 {
2434 WARN("Command list is not in the recording state.\n");
2435 return E_FAIL;
2436 }
2437
2438 vk_procs = &list->device->vk_procs;
2439
2441 if (list->is_predicated)
2442 VK_CALL(vkCmdEndConditionalRenderingEXT(list->vk_command_buffer));
2443
2444 if ((vr = VK_CALL(vkEndCommandBuffer(list->vk_command_buffer))) < 0)
2445 {
2446 WARN("Failed to end command buffer, vr %d.\n", vr);
2447 return hresult_from_vk_result(vr);
2448 }
2449
2450 if (list->allocator)
2451 {
2453 list->allocator = NULL;
2454 }
2455
2456 list->is_recording = false;
2457 list->has_depth_bounds = false;
2458
2459 if (!list->is_valid)
2460 {
2461 WARN("Error occurred during command list recording.\n");
2462 return E_INVALIDARG;
2463 }
2464
2465 return S_OK;
2466}
2467
2469 ID3D12PipelineState *initial_pipeline_state)
2470{
2471 ID3D12GraphicsCommandList6 *iface = &list->ID3D12GraphicsCommandList6_iface;
2472
2473 memset(list->strides, 0, sizeof(list->strides));
2474 list->primitive_topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
2475
2476 list->index_buffer_format = DXGI_FORMAT_UNKNOWN;
2477
2478 memset(list->rtvs, 0, sizeof(list->rtvs));
2479 list->dsv = VK_NULL_HANDLE;
2480 list->dsv_format = VK_FORMAT_UNDEFINED;
2481 list->fb_width = 0;
2482 list->fb_height = 0;
2483 list->fb_layer_count = 0;
2484
2485 list->xfb_enabled = false;
2486 list->has_depth_bounds = false;
2487 list->is_predicated = false;
2488
2489 list->current_framebuffer = VK_NULL_HANDLE;
2490 list->current_pipeline = VK_NULL_HANDLE;
2491 list->pso_render_pass = VK_NULL_HANDLE;
2492 list->current_render_pass = VK_NULL_HANDLE;
2493
2496 memset(list->pipeline_bindings, 0, sizeof(list->pipeline_bindings));
2498 list->pipeline_bindings[VKD3D_PIPELINE_BIND_POINT_COMPUTE].vk_bind_point = VK_PIPELINE_BIND_POINT_COMPUTE;
2499
2500 list->state = NULL;
2501
2502 memset(list->so_counter_buffers, 0, sizeof(list->so_counter_buffers));
2503 memset(list->so_counter_buffer_offsets, 0, sizeof(list->so_counter_buffer_offsets));
2504
2505 list->descriptor_heap_count = 0;
2506
2507 ID3D12GraphicsCommandList6_SetPipelineState(iface, initial_pipeline_state);
2508}
2509
2511 ID3D12CommandAllocator *allocator, ID3D12PipelineState *initial_pipeline_state)
2512{
2515 HRESULT hr;
2516
2517 TRACE("iface %p, allocator %p, initial_pipeline_state %p.\n",
2518 iface, allocator, initial_pipeline_state);
2519
2520 if (!allocator_impl)
2521 {
2522 WARN("Command allocator is NULL.\n");
2523 return E_INVALIDARG;
2524 }
2525
2526 if (list->is_recording)
2527 {
2528 WARN("Command list is in the recording state.\n");
2529 return E_FAIL;
2530 }
2531
2533 {
2534 list->allocator = allocator_impl;
2535 d3d12_command_list_reset_state(list, initial_pipeline_state);
2536 }
2537
2538 return hr;
2539}
2540
2542 ID3D12PipelineState *pipeline_state)
2543{
2544 FIXME("iface %p, pipeline_state %p stub!\n", iface, pipeline_state);
2545}
2546
2548{
2549 struct d3d12_graphics_pipeline_state *graphics;
2550
2552 graphics = &list->state->u.graphics;
2553
2554 return graphics->dsv_format || (d3d12_pipeline_state_has_unknown_dsv_format(list->state) && list->dsv_format);
2555}
2556
2558 uint32_t *width, uint32_t *height, uint32_t *layer_count)
2559{
2560 struct d3d12_graphics_pipeline_state *graphics = &list->state->u.graphics;
2561 struct d3d12_device *device = list->device;
2562
2564 {
2565 *width = list->fb_width;
2566 *height = list->fb_height;
2567 if (layer_count)
2568 *layer_count = list->fb_layer_count;
2569 }
2570 else
2571 {
2572 *width = device->vk_info.device_limits.maxFramebufferWidth;
2573 *height = device->vk_info.device_limits.maxFramebufferHeight;
2574 if (layer_count)
2575 *layer_count = 1;
2576 }
2577}
2578
2580{
2581 struct d3d12_device *device = list->device;
2582 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2583 VkImageView views[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1];
2584 struct d3d12_graphics_pipeline_state *graphics;
2585 struct VkFramebufferCreateInfo fb_desc;
2586 VkFramebuffer vk_framebuffer;
2587 unsigned int view_count;
2588 unsigned int i;
2589 VkResult vr;
2590
2591 if (list->current_framebuffer != VK_NULL_HANDLE)
2592 return true;
2593
2594 graphics = &list->state->u.graphics;
2595
2596 for (i = 0, view_count = 0; i < graphics->rt_count; ++i)
2597 {
2598 if (graphics->null_attachment_mask & (1u << i))
2599 {
2600 if (list->rtvs[i])
2601 WARN("Expected NULL RTV for attachment %u.\n", i);
2602 continue;
2603 }
2604
2605 if (!list->rtvs[i])
2606 {
2607 FIXME("Invalid RTV for attachment %u.\n", i);
2608 return false;
2609 }
2610
2611 views[view_count++] = list->rtvs[i];
2612 }
2613
2615 {
2616 if (!(views[view_count++] = list->dsv))
2617 {
2618 FIXME("Invalid DSV.\n");
2619 return false;
2620 }
2621 }
2622
2624 fb_desc.pNext = NULL;
2625 fb_desc.flags = 0;
2626 fb_desc.renderPass = list->pso_render_pass;
2627 fb_desc.attachmentCount = view_count;
2628 fb_desc.pAttachments = views;
2629 d3d12_command_list_get_fb_extent(list, &fb_desc.width, &fb_desc.height, &fb_desc.layers);
2630 if ((vr = VK_CALL(vkCreateFramebuffer(device->vk_device, &fb_desc, NULL, &vk_framebuffer))) < 0)
2631 {
2632 WARN("Failed to create Vulkan framebuffer, vr %d.\n", vr);
2633 return false;
2634 }
2635
2636 if (!d3d12_command_allocator_add_framebuffer(list->allocator, vk_framebuffer))
2637 {
2638 WARN("Failed to add framebuffer.\n");
2639 VK_CALL(vkDestroyFramebuffer(device->vk_device, vk_framebuffer, NULL));
2640 return false;
2641 }
2642
2643 list->current_framebuffer = vk_framebuffer;
2644
2645 return true;
2646}
2647
2649{
2650 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
2651
2652 vkd3d_cond_signal(&list->device->worker_cond);
2653
2654 if (list->current_pipeline != VK_NULL_HANDLE)
2655 return true;
2656
2658 {
2659 WARN("Pipeline state %p is not a compute pipeline.\n", list->state);
2660 return false;
2661 }
2662
2663 VK_CALL(vkCmdBindPipeline(list->vk_command_buffer, list->state->vk_bind_point, list->state->u.compute.vk_pipeline));
2664 list->current_pipeline = list->state->u.compute.vk_pipeline;
2665
2666 return true;
2667}
2668
2670{
2671 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
2672 VkRenderPass vk_render_pass;
2673 VkPipeline vk_pipeline;
2674
2675 vkd3d_cond_signal(&list->device->worker_cond);
2676
2677 if (list->current_pipeline != VK_NULL_HANDLE)
2678 return true;
2679
2681 {
2682 WARN("Pipeline state %p is not a graphics pipeline.\n", list->state);
2683 return false;
2684 }
2685
2686 if (!(vk_pipeline = d3d12_pipeline_state_get_or_create_pipeline(list->state,
2687 list->primitive_topology, list->strides, list->dsv_format, &vk_render_pass)))
2688 return false;
2689
2690 /* The render pass cache ensures that we use the same Vulkan render pass
2691 * object for compatible render passes. */
2692 if (list->pso_render_pass != vk_render_pass)
2693 {
2694 list->pso_render_pass = vk_render_pass;
2697 }
2698
2699 VK_CALL(vkCmdBindPipeline(list->vk_command_buffer, list->state->vk_bind_point, vk_pipeline));
2700 list->current_pipeline = vk_pipeline;
2701
2702 return true;
2703}
2704
2706 enum vkd3d_pipeline_bind_point bind_point)
2707{
2708 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
2709 unsigned int variable_binding_size, unbounded_offset, table_index, heap_size, i;
2710 const struct d3d12_root_signature *root_signature = bindings->root_signature;
2711 const struct d3d12_descriptor_set_layout *layout;
2712 const struct d3d12_desc *base_descriptor;
2713 VkDescriptorSet vk_descriptor_set;
2714
2715 if (bindings->descriptor_set_count && !bindings->in_use)
2716 return;
2717
2718 /* We cannot modify bound descriptor sets. We need a new descriptor set if
2719 * we are about to update resource bindings.
2720 *
2721 * The Vulkan spec says:
2722 *
2723 * "The descriptor set contents bound by a call to
2724 * vkCmdBindDescriptorSets may be consumed during host execution of the
2725 * command, or during shader execution of the resulting draws, or any
2726 * time in between. Thus, the contents must not be altered (overwritten
2727 * by an update command, or freed) between when the command is recorded
2728 * and when the command completes executing on the queue."
2729 */
2730 bindings->descriptor_set_count = 0;
2731 for (i = root_signature->main_set; i < root_signature->vk_set_count; ++i)
2732 {
2733 layout = &root_signature->descriptor_set_layouts[i];
2734 unbounded_offset = layout->unbounded_offset;
2735 table_index = layout->table_index;
2736 variable_binding_size = 0;
2737
2738 if (unbounded_offset != UINT_MAX
2739 /* Descriptors may not be set, eg. WoW. */
2740 && (base_descriptor = bindings->descriptor_tables[table_index]))
2741 {
2742 heap_size = d3d12_desc_heap_range_size(base_descriptor);
2743
2744 if (heap_size < unbounded_offset)
2745 WARN("Descriptor heap size %u is less than the offset %u of an unbounded range in table %u, "
2746 "vk set %u.\n", heap_size, unbounded_offset, table_index, i);
2747 else
2748 variable_binding_size = heap_size - unbounded_offset;
2749 }
2750
2751 vk_descriptor_set = d3d12_command_allocator_allocate_descriptor_set(list->allocator,
2752 layout->vk_layout, variable_binding_size, unbounded_offset != UINT_MAX);
2753 bindings->descriptor_sets[bindings->descriptor_set_count++] = vk_descriptor_set;
2754 }
2755
2756 bindings->in_use = false;
2757
2759 bindings->push_descriptor_dirty_mask |= bindings->push_descriptor_active_mask & root_signature->push_descriptor_mask;
2760}
2761
2763 VkDescriptorImageInfo *vk_image_info, const struct d3d12_desc *descriptor,
2764 const struct d3d12_root_descriptor_table_range *range, VkDescriptorSet *vk_descriptor_sets,
2765 unsigned int index, bool use_array)
2766{
2767 uint32_t descriptor_range_magic = range->descriptor_magic;
2768 union d3d12_desc_object u = descriptor->s.u;
2769 uint32_t vk_binding = range->binding;
2770 VkDescriptorType vk_descriptor_type;
2771 uint32_t set = range->set;
2772
2773 if (!u.header || u.header->magic != descriptor_range_magic)
2774 return false;
2775
2776 vk_descriptor_type = u.header->vk_descriptor_type;
2777
2778 vk_descriptor_write->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2779 vk_descriptor_write->pNext = NULL;
2780 vk_descriptor_write->dstSet = vk_descriptor_sets[set];
2781 vk_descriptor_write->dstBinding = use_array ? vk_binding : vk_binding + index;
2782 vk_descriptor_write->dstArrayElement = use_array ? index : 0;
2783 vk_descriptor_write->descriptorCount = 1;
2784 vk_descriptor_write->descriptorType = vk_descriptor_type;
2785 vk_descriptor_write->pImageInfo = NULL;
2786 vk_descriptor_write->pBufferInfo = NULL;
2787 vk_descriptor_write->pTexelBufferView = NULL;
2788
2789 switch (u.header->magic)
2790 {
2792 vk_descriptor_write->pBufferInfo = &u.cb_desc->vk_cbv_info;
2793 break;
2794
2797 /* We use separate bindings for buffer and texture SRVs/UAVs.
2798 * See d3d12_root_signature_init(). For unbounded ranges the
2799 * descriptors exist in two consecutive sets, otherwise they occur
2800 * as consecutive ranges within a set. */
2801 if (vk_descriptor_type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
2802 || vk_descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)
2803 {
2804 vk_descriptor_write->pTexelBufferView = &u.view->v.u.vk_buffer_view;
2805 break;
2806 }
2807
2808 if (range->descriptor_count == UINT_MAX)
2809 {
2810 vk_descriptor_write->dstSet = vk_descriptor_sets[set + 1];
2811 vk_descriptor_write->dstBinding = 0;
2812 }
2813 else
2814 {
2815 vk_descriptor_write->dstBinding += use_array ? 1 : range->descriptor_count;
2816 }
2817
2818 vk_image_info->sampler = VK_NULL_HANDLE;
2819 vk_image_info->imageView = u.view->v.u.vk_image_view;
2820 vk_image_info->imageLayout = u.header->magic == VKD3D_DESCRIPTOR_MAGIC_SRV
2822
2823 vk_descriptor_write->pImageInfo = vk_image_info;
2824 break;
2825
2827 vk_image_info->sampler = u.view->v.u.vk_sampler;
2828 vk_image_info->imageView = VK_NULL_HANDLE;
2829 vk_image_info->imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
2830
2831 vk_descriptor_write->pImageInfo = vk_image_info;
2832 break;
2833
2834 default:
2835 ERR("Invalid descriptor %#x.\n", u.header->magic);
2836 return false;
2837 }
2838
2839 return true;
2840}
2841
2843 enum vkd3d_pipeline_bind_point bind_point, unsigned int index, struct d3d12_desc *base_descriptor)
2844{
2845 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
2846 struct VkWriteDescriptorSet descriptor_writes[24], *current_descriptor_write;
2847 const struct d3d12_root_signature *root_signature = bindings->root_signature;
2848 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
2849 struct VkDescriptorImageInfo image_infos[24], *current_image_info;
2850 const struct d3d12_root_descriptor_table *descriptor_table;
2851 const struct d3d12_pipeline_state *state = list->state;
2853 VkDevice vk_device = list->device->vk_device;
2854 unsigned int i, j, k, descriptor_count;
2855 struct d3d12_desc *descriptor;
2856 unsigned int write_count = 0;
2857 bool unbounded = false;
2858
2859 descriptor_table = root_signature_get_descriptor_table(root_signature, index);
2860
2861 current_descriptor_write = descriptor_writes;
2862 current_image_info = image_infos;
2863 for (i = 0; i < descriptor_table->range_count; ++i)
2864 {
2865 range = &descriptor_table->ranges[i];
2866
2867 /* The first unbounded range of each type is written until the heap end is reached. Do not repeat. */
2868 if (unbounded && i && range->type == descriptor_table->ranges[i - 1].type)
2869 continue;
2870
2871 descriptor = base_descriptor + range->offset;
2872
2873 descriptor_count = range->descriptor_count;
2874 if ((unbounded = descriptor_count == UINT_MAX))
2875 {
2876 descriptor_count = d3d12_desc_heap_range_size(descriptor);
2877
2878 if (descriptor_count > range->vk_binding_count)
2879 {
2880 ERR("Heap descriptor count %u exceeds maximum Vulkan count %u. Reducing to the Vulkan maximum.\n",
2881 descriptor_count, range->vk_binding_count);
2882 descriptor_count = range->vk_binding_count;
2883 }
2884 }
2885
2886 for (j = 0; j < descriptor_count; ++j, ++descriptor)
2887 {
2888 unsigned int register_idx = range->base_register_idx + j;
2889 union d3d12_desc_object u = descriptor->s.u;
2890 VkBufferView vk_counter_view;
2891
2892 vk_counter_view = (u.header && u.header->magic == VKD3D_DESCRIPTOR_MAGIC_UAV)
2893 ? u.view->v.vk_counter_view : VK_NULL_HANDLE;
2894
2895 /* Track UAV counters. */
2896 if (range->descriptor_magic == VKD3D_DESCRIPTOR_MAGIC_UAV)
2897 {
2898 for (k = 0; k < state->uav_counters.binding_count; ++k)
2899 {
2900 if (state->uav_counters.bindings[k].register_space == range->register_space
2901 && state->uav_counters.bindings[k].register_index == register_idx)
2902 {
2903 if (bindings->vk_uav_counter_views[k] != vk_counter_view)
2904 bindings->uav_counters_dirty = true;
2905 bindings->vk_uav_counter_views[k] = vk_counter_view;
2906 break;
2907 }
2908 }
2909 }
2910
2911 /* Not all descriptors are necessarily populated if the range is unbounded. */
2912 if (!u.header)
2913 continue;
2914
2915 if (!vk_write_descriptor_set_from_d3d12_desc(current_descriptor_write, current_image_info,
2916 descriptor, range, bindings->descriptor_sets, j, root_signature->use_descriptor_arrays))
2917 continue;
2918
2919 ++write_count;
2920 ++current_descriptor_write;
2921 ++current_image_info;
2922
2923 if (write_count == ARRAY_SIZE(descriptor_writes))
2924 {
2925 VK_CALL(vkUpdateDescriptorSets(vk_device, write_count, descriptor_writes, 0, NULL));
2926 write_count = 0;
2927 current_descriptor_write = descriptor_writes;
2928 current_image_info = image_infos;
2929 }
2930 }
2931 }
2932
2933 VK_CALL(vkUpdateDescriptorSets(vk_device, write_count, descriptor_writes, 0, NULL));
2934}
2935
2937 const struct d3d12_root_parameter *root_parameter, VkDescriptorSet vk_descriptor_set,
2938 VkBufferView *vk_buffer_view, const VkDescriptorBufferInfo *vk_buffer_info)
2939{
2940 const struct d3d12_root_descriptor *root_descriptor;
2941
2942 switch (root_parameter->parameter_type)
2943 {
2946 break;
2949 break;
2952 break;
2953 default:
2954 ERR("Invalid root descriptor %#x.\n", root_parameter->parameter_type);
2955 return false;
2956 }
2957
2958 root_descriptor = &root_parameter->u.descriptor;
2959
2960 vk_descriptor_write->sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2961 vk_descriptor_write->pNext = NULL;
2962 vk_descriptor_write->dstSet = vk_descriptor_set;
2963 vk_descriptor_write->dstBinding = root_descriptor->binding;
2964 vk_descriptor_write->dstArrayElement = 0;
2965 vk_descriptor_write->descriptorCount = 1;
2966 vk_descriptor_write->pImageInfo = NULL;
2967 vk_descriptor_write->pBufferInfo = vk_buffer_info;
2968 vk_descriptor_write->pTexelBufferView = vk_buffer_view;
2969
2970 return true;
2971}
2972
2974 enum vkd3d_pipeline_bind_point bind_point)
2975{
2976 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
2978 VkDescriptorBufferInfo buffer_infos[ARRAY_SIZE(bindings->push_descriptors)] = {0};
2979 const struct d3d12_root_signature *root_signature = bindings->root_signature;
2980 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
2981 const struct d3d12_root_parameter *root_parameter;
2982 struct vkd3d_push_descriptor *push_descriptor;
2983 struct d3d12_device *device = list->device;
2984 VkDescriptorBufferInfo *vk_buffer_info;
2985 unsigned int i, descriptor_count = 0;
2986 VkBufferView *vk_buffer_view;
2987
2988 if (!bindings->push_descriptor_dirty_mask)
2989 return;
2990
2991 for (i = 0; i < ARRAY_SIZE(bindings->push_descriptors); ++i)
2992 {
2993 if (!(bindings->push_descriptor_dirty_mask & (1u << i)))
2994 continue;
2995
2996 root_parameter = root_signature_get_root_descriptor(root_signature, i);
2997 push_descriptor = &bindings->push_descriptors[i];
2998
2999 if (root_parameter->parameter_type == D3D12_ROOT_PARAMETER_TYPE_CBV)
3000 {
3001 vk_buffer_view = NULL;
3002 vk_buffer_info = &buffer_infos[descriptor_count];
3003 vk_buffer_info->buffer = push_descriptor->u.cbv.vk_buffer;
3004 vk_buffer_info->offset = push_descriptor->u.cbv.offset;
3005 vk_buffer_info->range = VK_WHOLE_SIZE;
3006 }
3007 else
3008 {
3009 vk_buffer_view = &push_descriptor->u.vk_buffer_view;
3010 vk_buffer_info = NULL;
3011 }
3012
3014 root_parameter, bindings->descriptor_sets[0], vk_buffer_view, vk_buffer_info))
3015 continue;
3016
3017 ++descriptor_count;
3018 }
3019
3020 VK_CALL(vkUpdateDescriptorSets(device->vk_device, descriptor_count, descriptor_writes, 0, NULL));
3021 bindings->push_descriptor_dirty_mask = 0;
3022}
3023
3025 enum vkd3d_pipeline_bind_point bind_point)
3026{
3027 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
3028 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3029 const struct d3d12_pipeline_state *state = list->state;
3030 VkDevice vk_device = list->device->vk_device;
3031 VkWriteDescriptorSet *vk_descriptor_writes;
3032 VkDescriptorSet vk_descriptor_set;
3033 unsigned int uav_counter_count;
3034 unsigned int i;
3035
3036 if (!state || !bindings->uav_counters_dirty)
3037 return;
3038
3039 uav_counter_count = state->uav_counters.binding_count;
3040 if (!(vk_descriptor_writes = vkd3d_calloc(uav_counter_count, sizeof(*vk_descriptor_writes))))
3041 return;
3042 if (!(vk_descriptor_set = d3d12_command_allocator_allocate_descriptor_set(
3043 list->allocator, state->uav_counters.vk_set_layout, 0, false)))
3044 goto done;
3045
3046 for (i = 0; i < uav_counter_count; ++i)
3047 {
3048 const struct vkd3d_shader_uav_counter_binding *uav_counter = &state->uav_counters.bindings[i];
3049 const VkBufferView *vk_uav_counter_views = bindings->vk_uav_counter_views;
3050
3051 VKD3D_ASSERT(vk_uav_counter_views[i]);
3052
3053 vk_descriptor_writes[i].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
3054 vk_descriptor_writes[i].pNext = NULL;
3055 vk_descriptor_writes[i].dstSet = vk_descriptor_set;
3056 vk_descriptor_writes[i].dstBinding = uav_counter->binding.binding;
3057 vk_descriptor_writes[i].dstArrayElement = 0;
3058 vk_descriptor_writes[i].descriptorCount = 1;
3060 vk_descriptor_writes[i].pImageInfo = NULL;
3061 vk_descriptor_writes[i].pBufferInfo = NULL;
3062 vk_descriptor_writes[i].pTexelBufferView = &vk_uav_counter_views[i];
3063 }
3064
3065 VK_CALL(vkUpdateDescriptorSets(vk_device, uav_counter_count, vk_descriptor_writes, 0, NULL));
3066
3067 VK_CALL(vkCmdBindDescriptorSets(list->vk_command_buffer, bindings->vk_bind_point,
3068 state->uav_counters.vk_pipeline_layout, state->uav_counters.set_index, 1, &vk_descriptor_set, 0, NULL));
3069
3070 bindings->uav_counters_dirty = false;
3071
3072done:
3073 vkd3d_free(vk_descriptor_writes);
3074}
3075
3077 enum vkd3d_pipeline_bind_point bind_point)
3078{
3079 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
3080 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3081 const struct d3d12_root_signature *rs = bindings->root_signature;
3082 struct d3d12_desc *base_descriptor;
3083 unsigned int i;
3084
3085 if (!rs || !rs->vk_set_count)
3086 return;
3087
3090
3091 for (i = 0; i < ARRAY_SIZE(bindings->descriptor_tables); ++i)
3092 {
3093 if (bindings->descriptor_table_dirty_mask & ((uint64_t)1 << i))
3094 {
3095 if ((base_descriptor = bindings->descriptor_tables[i]))
3096 d3d12_command_list_update_descriptor_table(list, bind_point, i, base_descriptor);
3097 else
3098 WARN("Descriptor table %u is not set.\n", i);
3099 }
3100 }
3101 bindings->descriptor_table_dirty_mask = 0;
3102
3104
3105 if (bindings->descriptor_set_count)
3106 {
3107 VK_CALL(vkCmdBindDescriptorSets(list->vk_command_buffer, bindings->vk_bind_point,
3108 rs->vk_pipeline_layout, rs->main_set, bindings->descriptor_set_count, bindings->descriptor_sets,
3109 0, NULL));
3110 bindings->in_use = true;
3111 }
3112
3114}
3115
3117 struct vkd3d_pipeline_bindings *bindings, unsigned int index,
3118 struct d3d12_descriptor_heap **cbv_srv_uav_heap, struct d3d12_descriptor_heap **sampler_heap)
3119{
3121 const struct d3d12_desc *desc;
3122 unsigned int offset;
3123
3124 if (!(desc = bindings->descriptor_tables[index]))
3125 return 0;
3126
3127 /* AMD, Nvidia and Intel drivers on Windows work if SetDescriptorHeaps()
3128 * is not called, so we bind heaps from the tables instead. No NULL check is
3129 * needed here because it's checked when descriptor tables are set. */
3131 offset = desc->index;
3132
3134 {
3135 if (*cbv_srv_uav_heap)
3136 {
3137 if (heap == *cbv_srv_uav_heap)
3138 return offset;
3139 /* This occurs occasionally in Rise of the Tomb Raider apparently due to a race
3140 * condition (one of several), but adding a mutex for table updates has no effect. */
3141 WARN("List %p uses descriptors from more than one CBV/SRV/UAV heap.\n", list);
3142 }
3143 *cbv_srv_uav_heap = heap;
3144 }
3145 else
3146 {
3147 if (*sampler_heap)
3148 {
3149 if (heap == *sampler_heap)
3150 return offset;
3151 WARN("List %p uses descriptors from more than one sampler heap.\n", list);
3152 }
3153 *sampler_heap = heap;
3154 }
3155
3156 return offset;
3157}
3158
3160 struct vkd3d_pipeline_bindings *bindings, struct d3d12_descriptor_heap **cbv_srv_uav_heap,
3161 struct d3d12_descriptor_heap **sampler_heap)
3162{
3163 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3164 const struct d3d12_root_signature *rs = bindings->root_signature;
3165 unsigned int offsets[D3D12_MAX_ROOT_COST];
3166 unsigned int i, j;
3167
3168 for (i = 0, j = 0; i < ARRAY_SIZE(bindings->descriptor_tables); ++i)
3169 {
3170 if (!(rs->descriptor_table_mask & ((uint64_t)1 << i)))
3171 continue;
3173 cbv_srv_uav_heap, sampler_heap);
3174 }
3175 if (j)
3176 {
3178 rs->descriptor_table_offset, j * sizeof(uint32_t), offsets));
3179 }
3180}
3181
3182static bool contains_heap(struct d3d12_descriptor_heap **heap_array, unsigned int count,
3183 const struct d3d12_descriptor_heap *query)
3184{
3185 unsigned int i;
3186
3187 for (i = 0; i < count; ++i)
3188 if (heap_array[i] == query)
3189 return true;
3190 return false;
3191}
3192
3194{
3195 struct d3d12_device *device = list->device;
3196 unsigned int i;
3197
3198 for (i = 0; i < list->descriptor_heap_count; ++i)
3199 {
3200 vkd3d_mutex_lock(&list->descriptor_heaps[i]->vk_sets_mutex);
3202 vkd3d_mutex_unlock(&list->descriptor_heaps[i]->vk_sets_mutex);
3203 }
3204}
3205
3207{
3208 if (!list->device->use_vk_heaps)
3209 return;
3210
3211 if (!contains_heap(list->descriptor_heaps, list->descriptor_heap_count, heap))
3212 {
3213 if (list->descriptor_heap_count == ARRAY_SIZE(list->descriptor_heaps))
3214 {
3215 /* Descriptors can be written after binding. */
3216 FIXME("Flushing descriptor updates while list %p is not closed.\n", list);
3217 vkd3d_mutex_lock(&heap->vk_sets_mutex);
3219 vkd3d_mutex_unlock(&heap->vk_sets_mutex);
3220 return;
3221 }
3222 list->descriptor_heaps[list->descriptor_heap_count++] = heap;
3223 }
3224}
3225
3227 enum vkd3d_pipeline_bind_point bind_point, struct d3d12_descriptor_heap *heap)
3228{
3229 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
3230 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3231 const struct d3d12_root_signature *rs = bindings->root_signature;
3233
3234 if (!heap)
3235 return;
3236
3238 {
3239 if (heap->serial_id == bindings->cbv_srv_uav_heap_id)
3240 return;
3241 bindings->cbv_srv_uav_heap_id = heap->serial_id;
3242 }
3243 else
3244 {
3245 if (heap->serial_id == bindings->sampler_heap_id)
3246 return;
3247 bindings->sampler_heap_id = heap->serial_id;
3248 }
3249
3250 vkd3d_mutex_lock(&heap->vk_sets_mutex);
3251
3252 for (set = 0; set < ARRAY_SIZE(heap->vk_descriptor_sets); ++set)
3253 {
3254 VkDescriptorSet vk_descriptor_set = heap->vk_descriptor_sets[set].vk_set;
3255
3256 /* Null vk_set_layout means set 0 uses mutable descriptors, and this set is unused. */
3257 if (!vk_descriptor_set || !list->device->vk_descriptor_heap_layouts[set].vk_set_layout)
3258 continue;
3259
3260 VK_CALL(vkCmdBindDescriptorSets(list->vk_command_buffer, bindings->vk_bind_point, rs->vk_pipeline_layout,
3261 rs->vk_set_count + set, 1, &vk_descriptor_set, 0, NULL));
3262 }
3263
3264 vkd3d_mutex_unlock(&heap->vk_sets_mutex);
3265}
3266
3268 enum vkd3d_pipeline_bind_point bind_point)
3269{
3270 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
3271 struct d3d12_descriptor_heap *cbv_srv_uav_heap = NULL, *sampler_heap = NULL;
3272 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3273 const struct d3d12_root_signature *rs = bindings->root_signature;
3274
3275 if (!rs)
3276 return;
3277
3280 if (bindings->descriptor_table_dirty_mask)
3281 d3d12_command_list_update_descriptor_tables(list, bindings, &cbv_srv_uav_heap, &sampler_heap);
3282 bindings->descriptor_table_dirty_mask = 0;
3283
3285
3286 if (bindings->descriptor_set_count)
3287 {
3288 VK_CALL(vkCmdBindDescriptorSets(list->vk_command_buffer, bindings->vk_bind_point, rs->vk_pipeline_layout,
3289 rs->main_set, bindings->descriptor_set_count, bindings->descriptor_sets, 0, NULL));
3290 bindings->in_use = true;
3291 }
3292
3293 d3d12_command_list_bind_descriptor_heap(list, bind_point, cbv_srv_uav_heap);
3294 d3d12_command_list_bind_descriptor_heap(list, bind_point, sampler_heap);
3295}
3296
3298 enum vkd3d_pipeline_bind_point bind_point)
3299{
3300 if (list->device->use_vk_heaps)
3302 else
3304}
3305
3307{
3309
3311 return false;
3312
3314
3315 return true;
3316}
3317
3319{
3320 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3321 struct d3d12_graphics_pipeline_state *graphics;
3322 struct VkRenderPassBeginInfo begin_desc;
3323 VkRenderPass vk_render_pass;
3324
3326 return false;
3328 return false;
3329
3331
3332 if (list->current_render_pass != VK_NULL_HANDLE)
3333 return true;
3334
3335 vk_render_pass = list->pso_render_pass;
3336 VKD3D_ASSERT(vk_render_pass);
3337
3339 begin_desc.pNext = NULL;
3340 begin_desc.renderPass = vk_render_pass;
3341 begin_desc.framebuffer = list->current_framebuffer;
3342 begin_desc.renderArea.offset.x = 0;
3343 begin_desc.renderArea.offset.y = 0;
3345 &begin_desc.renderArea.extent.width, &begin_desc.renderArea.extent.height, NULL);
3346 begin_desc.clearValueCount = 0;
3347 begin_desc.pClearValues = NULL;
3348 VK_CALL(vkCmdBeginRenderPass(list->vk_command_buffer, &begin_desc, VK_SUBPASS_CONTENTS_INLINE));
3349
3350 list->current_render_pass = vk_render_pass;
3351
3352 graphics = &list->state->u.graphics;
3353 if (graphics->xfb_enabled)
3354 {
3355 VK_CALL(vkCmdBeginTransformFeedbackEXT(list->vk_command_buffer, 0, ARRAY_SIZE(list->so_counter_buffers),
3356 list->so_counter_buffers, list->so_counter_buffer_offsets));
3357
3358 list->xfb_enabled = true;
3359 }
3360
3361 if (graphics->ds_desc.depthBoundsTestEnable && !list->has_depth_bounds)
3362 {
3363 list->has_depth_bounds = true;
3364 VK_CALL(vkCmdSetDepthBounds(list->vk_command_buffer, 0.0f, 1.0f));
3365 }
3366
3367 return true;
3368}
3369
3371{
3372 struct d3d12_graphics_pipeline_state *graphics = &list->state->u.graphics;
3373
3374 /* In Vulkan, the strip cut value is derived from the index buffer format. */
3375 switch (graphics->index_buffer_strip_cut_value)
3376 {
3378 if (list->index_buffer_format != DXGI_FORMAT_R16_UINT)
3379 {
3380 FIXME_ONCE("Strip cut value 0xffff is not supported with index buffer format %#x.\n",
3381 list->index_buffer_format);
3382 }
3383 break;
3384
3386 if (list->index_buffer_format != DXGI_FORMAT_R32_UINT)
3387 {
3388 FIXME_ONCE("Strip cut value 0xffffffff is not supported with index buffer format %#x.\n",
3389 list->index_buffer_format);
3390 }
3391 break;
3392
3393 default:
3394 break;
3395 }
3396}
3397
3399 UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location,
3400 UINT start_instance_location)
3401{
3403 const struct vkd3d_vk_device_procs *vk_procs;
3404
3405 TRACE("iface %p, vertex_count_per_instance %u, instance_count %u, "
3406 "start_vertex_location %u, start_instance_location %u.\n",
3407 iface, vertex_count_per_instance, instance_count,
3408 start_vertex_location, start_instance_location);
3409
3410 vk_procs = &list->device->vk_procs;
3411
3413 {
3414 WARN("Failed to begin render pass, ignoring draw call.\n");
3415 return;
3416 }
3417
3418 VK_CALL(vkCmdDraw(list->vk_command_buffer, vertex_count_per_instance,
3419 instance_count, start_vertex_location, start_instance_location));
3420}
3421
3423 UINT index_count_per_instance, UINT instance_count, UINT start_vertex_location,
3424 INT base_vertex_location, UINT start_instance_location)
3425{
3427 const struct vkd3d_vk_device_procs *vk_procs;
3428
3429 TRACE("iface %p, index_count_per_instance %u, instance_count %u, start_vertex_location %u, "
3430 "base_vertex_location %d, start_instance_location %u.\n",
3431 iface, index_count_per_instance, instance_count, start_vertex_location,
3432 base_vertex_location, start_instance_location);
3433
3435 {
3436 WARN("Failed to begin render pass, ignoring draw call.\n");
3437 return;
3438 }
3439
3440 vk_procs = &list->device->vk_procs;
3441
3443
3444 VK_CALL(vkCmdDrawIndexed(list->vk_command_buffer, index_count_per_instance,
3445 instance_count, start_vertex_location, base_vertex_location, start_instance_location));
3446}
3447
3449 UINT x, UINT y, UINT z)
3450{
3452 const struct vkd3d_vk_device_procs *vk_procs;
3453
3454 TRACE("iface %p, x %u, y %u, z %u.\n", iface, x, y, z);
3455
3457 {
3458 WARN("Failed to update compute state, ignoring dispatch.\n");
3459 return;
3460 }
3461
3462 vk_procs = &list->device->vk_procs;
3463
3464 VK_CALL(vkCmdDispatch(list->vk_command_buffer, x, y, z));
3465}
3466
3468 ID3D12Resource *dst, UINT64 dst_offset, ID3D12Resource *src, UINT64 src_offset, UINT64 byte_count)
3469{
3471 struct d3d12_resource *dst_resource, *src_resource;
3472 const struct vkd3d_vk_device_procs *vk_procs;
3473 VkBufferCopy buffer_copy;
3474
3475 TRACE("iface %p, dst_resource %p, dst_offset %#"PRIx64", src_resource %p, "
3476 "src_offset %#"PRIx64", byte_count %#"PRIx64".\n",
3477 iface, dst, dst_offset, src, src_offset, byte_count);
3478
3479 vk_procs = &list->device->vk_procs;
3480
3481 dst_resource = unsafe_impl_from_ID3D12Resource(dst);
3483 src_resource = unsafe_impl_from_ID3D12Resource(src);
3485
3488
3490
3491 buffer_copy.srcOffset = src_offset;
3492 buffer_copy.dstOffset = dst_offset;
3493 buffer_copy.size = byte_count;
3494
3495 VK_CALL(vkCmdCopyBuffer(list->vk_command_buffer,
3496 src_resource->u.vk_buffer, dst_resource->u.vk_buffer, 1, &buffer_copy));
3497}
3498
3500 const struct vkd3d_format *format, unsigned int sub_resource_idx, unsigned int miplevel_count)
3501{
3502 subresource->aspectMask = format->vk_aspect_mask;
3503 subresource->mipLevel = sub_resource_idx % miplevel_count;
3504 subresource->baseArrayLayer = sub_resource_idx / miplevel_count;
3505 subresource->layerCount = 1;
3506}
3507
3509 const D3D12_RESOURCE_DESC1 *resource_desc, unsigned int miplevel_idx)
3510{
3511 extent->width = d3d12_resource_desc_get_width(resource_desc, miplevel_idx);
3512 extent->height = d3d12_resource_desc_get_height(resource_desc, miplevel_idx);
3513 extent->depth = d3d12_resource_desc_get_depth(resource_desc, miplevel_idx);
3514}
3515
3517 const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx,
3518 const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *format,
3519 const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
3520{
3521 copy->bufferOffset = footprint->Offset;
3522 if (src_box)
3523 {
3524 VkDeviceSize row_count = footprint->Footprint.Height / format->block_height;
3525 copy->bufferOffset += vkd3d_format_get_data_offset(format, footprint->Footprint.RowPitch,
3526 row_count * footprint->Footprint.RowPitch, src_box->left, src_box->top, src_box->front);
3527 }
3528 copy->bufferRowLength = footprint->Footprint.RowPitch /
3529 (format->byte_count * format->block_byte_count) * format->block_width;
3530 copy->bufferImageHeight = footprint->Footprint.Height;
3532 format, sub_resource_idx, image_desc->MipLevels);
3533 copy->imageOffset.x = dst_x;
3534 copy->imageOffset.y = dst_y;
3535 copy->imageOffset.z = dst_z;
3536
3537 vk_extent_3d_from_d3d12_miplevel(&copy->imageExtent, image_desc,
3538 copy->imageSubresource.mipLevel);
3539 copy->imageExtent.width -= copy->imageOffset.x;
3540 copy->imageExtent.height -= copy->imageOffset.y;
3541 copy->imageExtent.depth -= copy->imageOffset.z;
3542
3543 if (src_box)
3544 {
3545 copy->imageExtent.width = min(copy->imageExtent.width, src_box->right - src_box->left);
3546 copy->imageExtent.height = min(copy->imageExtent.height, src_box->bottom - src_box->top);
3547 copy->imageExtent.depth = min(copy->imageExtent.depth, src_box->back - src_box->front);
3548 }
3549 else
3550 {
3551 copy->imageExtent.width = min(copy->imageExtent.width, footprint->Footprint.Width);
3552 copy->imageExtent.height = min(copy->imageExtent.height, footprint->Footprint.Height);
3553 copy->imageExtent.depth = min(copy->imageExtent.depth, footprint->Footprint.Depth);
3554 }
3555}
3556
3558 const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx,
3559 const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *format,
3560 const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
3561{
3562 VkDeviceSize row_count = footprint->Footprint.Height / format->block_height;
3563
3564 copy->bufferOffset = footprint->Offset + vkd3d_format_get_data_offset(format,
3565 footprint->Footprint.RowPitch, row_count * footprint->Footprint.RowPitch, dst_x, dst_y, dst_z);
3566 copy->bufferRowLength = footprint->Footprint.RowPitch /
3567 (format->byte_count * format->block_byte_count) * format->block_width;
3568 copy->bufferImageHeight = footprint->Footprint.Height;
3570 format, sub_resource_idx, image_desc->MipLevels);
3571 copy->imageOffset.x = src_box ? src_box->left : 0;
3572 copy->imageOffset.y = src_box ? src_box->top : 0;
3573 copy->imageOffset.z = src_box ? src_box->front : 0;
3574 if (src_box)
3575 {
3576 copy->imageExtent.width = src_box->right - src_box->left;
3577 copy->imageExtent.height = src_box->bottom - src_box->top;
3578 copy->imageExtent.depth = src_box->back - src_box->front;
3579 }
3580 else
3581 {
3582 unsigned int miplevel = copy->imageSubresource.mipLevel;
3583 vk_extent_3d_from_d3d12_miplevel(&copy->imageExtent, image_desc, miplevel);
3584 }
3585}
3586
3588 unsigned int src_sub_resource_idx, unsigned int dst_sub_resource_idx,
3589 const D3D12_RESOURCE_DESC1 *src_desc, const D3D12_RESOURCE_DESC1 *dst_desc,
3590 const struct vkd3d_format *src_format, const struct vkd3d_format *dst_format,
3591 const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
3592{
3594 src_format, src_sub_resource_idx, src_desc->MipLevels);
3595 image_copy->srcOffset.x = src_box ? src_box->left : 0;
3596 image_copy->srcOffset.y = src_box ? src_box->top : 0;
3597 image_copy->srcOffset.z = src_box ? src_box->front : 0;
3599 dst_format, dst_sub_resource_idx, dst_desc->MipLevels);
3600 image_copy->dstOffset.x = dst_x;
3601 image_copy->dstOffset.y = dst_y;
3602 image_copy->dstOffset.z = dst_z;
3603 if (src_box)
3604 {
3605 image_copy->extent.width = src_box->right - src_box->left;
3606 image_copy->extent.height = src_box->bottom - src_box->top;
3607 image_copy->extent.depth = src_box->back - src_box->front;
3608 }
3609 else
3610 {
3611 unsigned int miplevel = image_copy->srcSubresource.mipLevel;
3612 vk_extent_3d_from_d3d12_miplevel(&image_copy->extent, src_desc, miplevel);
3613 }
3614}
3615
3618{
3619 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3620 struct d3d12_device *device = list->device;
3621 D3D12_HEAP_PROPERTIES heap_properties;
3622 D3D12_RESOURCE_DESC1 buffer_desc;
3623 HRESULT hr;
3624
3625 memset(&heap_properties, 0, sizeof(heap_properties));
3626 heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
3627
3629 buffer_desc.Alignment = 0;
3630 buffer_desc.Width = size;
3631 buffer_desc.Height = 1;
3632 buffer_desc.DepthOrArraySize = 1;
3633 buffer_desc.MipLevels = 1;
3634 buffer_desc.Format = DXGI_FORMAT_UNKNOWN;
3635 buffer_desc.SampleDesc.Count = 1;
3636 buffer_desc.SampleDesc.Quality = 0;
3639
3640 if (FAILED(hr = vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
3641 &buffer_desc, &buffer->vk_buffer)))
3642 return hr;
3644 &heap_properties, D3D12_HEAP_FLAG_NONE, &buffer->vk_memory, NULL, NULL)))
3645 {
3646 VK_CALL(vkDestroyBuffer(device->vk_device, buffer->vk_buffer, NULL));
3647 return hr;
3648 }
3649
3651 {
3652 ERR("Failed to add transfer buffer.\n");
3654 return E_OUTOFMEMORY;
3655 }
3656
3657 return S_OK;
3658}
3659
3660/* In Vulkan, each depth/stencil format is only compatible with itself.
3661 * This means that we are not allowed to copy texture regions directly between
3662 * depth/stencil and color formats.
3663 *
3664 * FIXME: Implement color <-> depth/stencil blits in shaders.
3665 */
3667 struct d3d12_resource *dst_resource, unsigned int dst_sub_resource_idx,
3668 const struct vkd3d_format *dst_format, struct d3d12_resource *src_resource,
3669 unsigned int src_sub_resource_idx, const struct vkd3d_format *src_format, unsigned int layer_count)
3670{
3671 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
3672 const D3D12_RESOURCE_DESC1 *dst_desc = &dst_resource->desc;
3673 const D3D12_RESOURCE_DESC1 *src_desc = &src_resource->desc;
3674 unsigned int dst_miplevel_idx, src_miplevel_idx;
3675 struct vkd3d_buffer transfer_buffer;
3676 VkBufferImageCopy buffer_image_copy;
3677 VkBufferMemoryBarrier vk_barrier;
3679 HRESULT hr;
3680
3681 WARN("Copying incompatible texture formats %#x, %#x -> %#x, %#x.\n",
3682 src_format->dxgi_format, src_format->vk_format,
3683 dst_format->dxgi_format, dst_format->vk_format);
3684
3689 VKD3D_ASSERT(dst_format->byte_count == src_format->byte_count);
3690
3691 buffer_image_copy.bufferOffset = 0;
3692 buffer_image_copy.bufferRowLength = 0;
3693 buffer_image_copy.bufferImageHeight = 0;
3694 vk_image_subresource_layers_from_d3d12(&buffer_image_copy.imageSubresource,
3695 src_format, src_sub_resource_idx, src_desc->MipLevels);
3696 buffer_image_copy.imageSubresource.layerCount = layer_count;
3697 src_miplevel_idx = buffer_image_copy.imageSubresource.mipLevel;
3698 buffer_image_copy.imageOffset.x = 0;
3699 buffer_image_copy.imageOffset.y = 0;
3700 buffer_image_copy.imageOffset.z = 0;
3701 vk_extent_3d_from_d3d12_miplevel(&buffer_image_copy.imageExtent, src_desc, src_miplevel_idx);
3702
3703 buffer_size = src_format->byte_count * buffer_image_copy.imageExtent.width *
3704 buffer_image_copy.imageExtent.height * buffer_image_copy.imageExtent.depth * layer_count;
3706 {
3707 ERR("Failed to allocate transfer buffer, hr %s.\n", debugstr_hresult(hr));
3708 return;
3709 }
3710
3711 VK_CALL(vkCmdCopyImageToBuffer(list->vk_command_buffer,
3713 transfer_buffer.vk_buffer, 1, &buffer_image_copy));
3714
3716 vk_barrier.pNext = NULL;
3721 vk_barrier.buffer = transfer_buffer.vk_buffer;
3722 vk_barrier.offset = 0;
3723 vk_barrier.size = VK_WHOLE_SIZE;
3724 VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer,
3726 0, NULL, 1, &vk_barrier, 0, NULL));
3727
3728 vk_image_subresource_layers_from_d3d12(&buffer_image_copy.imageSubresource,
3729 dst_format, dst_sub_resource_idx, dst_desc->MipLevels);
3730 buffer_image_copy.imageSubresource.layerCount = layer_count;
3731 dst_miplevel_idx = buffer_image_copy.imageSubresource.mipLevel;
3732
3733 VKD3D_ASSERT(d3d12_resource_desc_get_width(src_desc, src_miplevel_idx) ==
3734 d3d12_resource_desc_get_width(dst_desc, dst_miplevel_idx));
3735 VKD3D_ASSERT(d3d12_resource_desc_get_height(src_desc, src_miplevel_idx) ==
3736 d3d12_resource_desc_get_height(dst_desc, dst_miplevel_idx));
3737 VKD3D_ASSERT(d3d12_resource_desc_get_depth(src_desc, src_miplevel_idx) ==
3738 d3d12_resource_desc_get_depth(dst_desc, dst_miplevel_idx));
3739
3740 VK_CALL(vkCmdCopyBufferToImage(list->vk_command_buffer,
3741 transfer_buffer.vk_buffer, dst_resource->u.vk_image,
3742 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &buffer_image_copy));
3743}
3744
3746{
3747 return box->right > box->left
3748 && box->bottom > box->top
3749 && box->back > box->front;
3750}
3751
3753 const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z,
3754 const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box)
3755{
3757 struct d3d12_resource *dst_resource, *src_resource;
3758 const struct vkd3d_format *src_format, *dst_format;
3759 const struct vkd3d_vk_device_procs *vk_procs;
3760 VkBufferImageCopy buffer_image_copy;
3761 VkImageCopy image_copy;
3762
3763 TRACE("iface %p, dst %p, dst_x %u, dst_y %u, dst_z %u, src %p, src_box %p.\n",
3764 iface, dst, dst_x, dst_y, dst_z, src, src_box);
3765
3766 if (src_box && !validate_d3d12_box(src_box))
3767 {
3768 WARN("Empty box %s.\n", debug_d3d12_box(src_box));
3769 return;
3770 }
3771
3772 vk_procs = &list->device->vk_procs;
3773
3774 dst_resource = unsafe_impl_from_ID3D12Resource(dst->pResource);
3775 src_resource = unsafe_impl_from_ID3D12Resource(src->pResource);
3776
3779
3781
3784 {
3787
3789 &src_resource->desc, dst->u.PlacedFootprint.Footprint.Format)))
3790 {
3791 WARN("Invalid format %#x.\n", dst->u.PlacedFootprint.Footprint.Format);
3792 return;
3793 }
3794
3795 if (dst_format->is_emulated)
3796 {
3797 FIXME("Format %#x is not supported yet.\n", dst_format->dxgi_format);
3798 return;
3799 }
3800
3801 if ((dst_format->vk_aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT)
3802 && (dst_format->vk_aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT))
3803 FIXME("Depth-stencil format %#x not fully supported yet.\n", dst_format->dxgi_format);
3804
3805 vk_image_buffer_copy_from_d3d12(&buffer_image_copy, &dst->u.PlacedFootprint,
3806 src->u.SubresourceIndex, &src_resource->desc, dst_format, src_box, dst_x, dst_y, dst_z);
3807 VK_CALL(vkCmdCopyImageToBuffer(list->vk_command_buffer,
3809 dst_resource->u.vk_buffer, 1, &buffer_image_copy));
3810 }
3813 {
3816
3817 if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device,
3818 &dst_resource->desc, src->u.PlacedFootprint.Footprint.Format)))
3819 {
3820 WARN("Invalid format %#x.\n", src->u.PlacedFootprint.Footprint.Format);
3821 return;
3822 }
3823
3824 if (src_format->is_emulated)
3825 {
3826 FIXME("Format %#x is not supported yet.\n", src_format->dxgi_format);
3827 return;
3828 }
3829
3830 if ((src_format->vk_aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT)
3832 FIXME("Depth-stencil format %#x not fully supported yet.\n", src_format->dxgi_format);
3833
3834 vk_buffer_image_copy_from_d3d12(&buffer_image_copy, &src->u.PlacedFootprint,
3835 dst->u.SubresourceIndex, &dst_resource->desc, src_format, src_box, dst_x, dst_y, dst_z);
3836 VK_CALL(vkCmdCopyBufferToImage(list->vk_command_buffer,
3837 src_resource->u.vk_buffer, dst_resource->u.vk_image,
3838 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &buffer_image_copy));
3839 }
3842 {
3845
3846 dst_format = dst_resource->format;
3847 src_format = src_resource->format;
3848
3849 if ((dst_format->vk_aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT)
3850 && (dst_format->vk_aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT))
3851 FIXME("Depth-stencil format %#x not fully supported yet.\n", dst_format->dxgi_format);
3852 if ((src_format->vk_aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT)
3854 FIXME("Depth-stencil format %#x not fully supported yet.\n", src_format->dxgi_format);
3855
3856 if (dst_format->vk_aspect_mask != src_format->vk_aspect_mask)
3857 {
3859 dst_resource, dst->u.SubresourceIndex, dst_format,
3860 src_resource, src->u.SubresourceIndex, src_format, 1);
3861 return;
3862 }
3863
3864 vk_image_copy_from_d3d12(&image_copy, src->u.SubresourceIndex, dst->u.SubresourceIndex,
3865 &src_resource->desc, &dst_resource->desc, src_format, dst_format,
3866 src_box, dst_x, dst_y, dst_z);
3867 VK_CALL(vkCmdCopyImage(list->vk_command_buffer, src_resource->u.vk_image,
3869 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &image_copy));
3870 }
3871 else
3872 {
3873 FIXME("Copy type %#x -> %#x not implemented.\n", src->Type, dst->Type);
3874 }
3875}
3876
3879{
3881 struct d3d12_resource *dst_resource, *src_resource;
3882 const struct vkd3d_format *dst_format, *src_format;
3883 const struct vkd3d_vk_device_procs *vk_procs;
3884 VkBufferCopy vk_buffer_copy;
3885 VkImageCopy vk_image_copy;
3886 unsigned int layer_count;
3887 unsigned int i;
3888
3889 TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst, src);
3890
3891 vk_procs = &list->device->vk_procs;
3892
3893 dst_resource = unsafe_impl_from_ID3D12Resource(dst);
3894 src_resource = unsafe_impl_from_ID3D12Resource(src);
3895
3898
3900
3901 if (d3d12_resource_is_buffer(dst_resource))
3902 {
3904 VKD3D_ASSERT(src_resource->desc.Width == dst_resource->desc.Width);
3905
3906 vk_buffer_copy.srcOffset = 0;
3907 vk_buffer_copy.dstOffset = 0;
3908 vk_buffer_copy.size = dst_resource->desc.Width;
3909 VK_CALL(vkCmdCopyBuffer(list->vk_command_buffer,
3910 src_resource->u.vk_buffer, dst_resource->u.vk_buffer, 1, &vk_buffer_copy));
3911 }
3912 else
3913 {
3914 layer_count = d3d12_resource_desc_get_layer_count(&dst_resource->desc);
3915 dst_format = dst_resource->format;
3916 src_format = src_resource->format;
3917
3920 VKD3D_ASSERT(dst_resource->desc.MipLevels == src_resource->desc.MipLevels);
3921 VKD3D_ASSERT(layer_count == d3d12_resource_desc_get_layer_count(&src_resource->desc));
3922
3923 if (src_format->vk_aspect_mask != dst_format->vk_aspect_mask)
3924 {
3925 for (i = 0; i < dst_resource->desc.MipLevels; ++i)
3926 {
3928 dst_resource, i, dst_format,
3929 src_resource, i, src_format, layer_count);
3930 }
3931 return;
3932 }
3933
3934 for (i = 0; i < dst_resource->desc.MipLevels; ++i)
3935 {
3936 vk_image_copy_from_d3d12(&vk_image_copy, i, i, &src_resource->desc, &dst_resource->desc,
3937 src_format, dst_format, NULL, 0, 0, 0);
3938 vk_image_copy.dstSubresource.layerCount = layer_count;
3939 vk_image_copy.srcSubresource.layerCount = layer_count;
3940 VK_CALL(vkCmdCopyImage(list->vk_command_buffer, src_resource->u.vk_image,
3942 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &vk_image_copy));
3943 }
3944 }
3945}
3946
3948 ID3D12Resource *tiled_resource, const D3D12_TILED_RESOURCE_COORDINATE *tile_region_start_coordinate,
3949 const D3D12_TILE_REGION_SIZE *tile_region_size, ID3D12Resource *buffer, UINT64 buffer_offset,
3951{
3952 FIXME("iface %p, tiled_resource %p, tile_region_start_coordinate %p, tile_region_size %p, "
3953 "buffer %p, buffer_offset %#"PRIx64", flags %#x stub!\n",
3954 iface, tiled_resource, tile_region_start_coordinate, tile_region_size,
3955 buffer, buffer_offset, flags);
3956}
3957
3959 ID3D12Resource *dst, UINT dst_sub_resource_idx,
3960 ID3D12Resource *src, UINT src_sub_resource_idx, DXGI_FORMAT format)
3961{
3963 const struct vkd3d_format *src_format, *dst_format, *vk_format;
3964 struct d3d12_resource *dst_resource, *src_resource;
3965 const struct vkd3d_vk_device_procs *vk_procs;
3966 const struct d3d12_device *device;
3967 VkImageResolve vk_image_resolve;
3968
3969 TRACE("iface %p, dst_resource %p, dst_sub_resource_idx %u, src_resource %p, src_sub_resource_idx %u, "
3970 "format %#x.\n", iface, dst, dst_sub_resource_idx, src, src_sub_resource_idx, format);
3971
3972 device = list->device;
3973 vk_procs = &device->vk_procs;
3974
3975 dst_resource = unsafe_impl_from_ID3D12Resource(dst);
3976 src_resource = unsafe_impl_from_ID3D12Resource(src);
3977
3980
3983
3985
3986 dst_format = dst_resource->format;
3987 src_format = src_resource->format;
3988
3990 {
3991 if (!(vk_format = vkd3d_format_from_d3d12_resource_desc(device, &dst_resource->desc, format)))
3992 {
3993 WARN("Invalid format %#x.\n", format);
3994 return;
3995 }
3996 if (dst_format->vk_format != src_format->vk_format || dst_format->vk_format != vk_format->vk_format)
3997 {
3998 FIXME("Not implemented for typeless resources.\n");
3999 return;
4000 }
4001 }
4002
4003 /* Resolve of depth/stencil images is not supported in Vulkan. */
4006 {
4007 FIXME("Resolve of depth/stencil images is not implemented yet.\n");
4008 return;
4009 }
4010
4012 src_format, src_sub_resource_idx, src_resource->desc.MipLevels);
4013 memset(&vk_image_resolve.srcOffset, 0, sizeof(vk_image_resolve.srcOffset));
4015 dst_format, dst_sub_resource_idx, dst_resource->desc.MipLevels);
4016 memset(&vk_image_resolve.dstOffset, 0, sizeof(vk_image_resolve.dstOffset));
4017 vk_extent_3d_from_d3d12_miplevel(&vk_image_resolve.extent,
4018 &dst_resource->desc, vk_image_resolve.dstSubresource.mipLevel);
4019
4020 VK_CALL(vkCmdResolveImage(list->vk_command_buffer, src_resource->u.vk_image,
4022 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &vk_image_resolve));
4023}
4024
4026 D3D12_PRIMITIVE_TOPOLOGY topology)
4027{
4029
4030 TRACE("iface %p, topology %#x.\n", iface, topology);
4031
4032 if (list->primitive_topology == topology)
4033 return;
4034
4035 list->primitive_topology = topology;
4037}
4038
4040 UINT viewport_count, const D3D12_VIEWPORT *viewports)
4041{
4044 const struct vkd3d_vk_device_procs *vk_procs;
4045 unsigned int i;
4046
4047 TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports);
4048
4049 if (viewport_count > ARRAY_SIZE(vk_viewports))
4050 {
4051 FIXME("Viewport count %u > D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE.\n", viewport_count);
4052 viewport_count = ARRAY_SIZE(vk_viewports);
4053 }
4054
4055 for (i = 0; i < viewport_count; ++i)
4056 {
4057 vk_viewports[i].x = viewports[i].TopLeftX;
4058 vk_viewports[i].y = viewports[i].TopLeftY + viewports[i].Height;
4059 vk_viewports[i].width = viewports[i].Width;
4060 vk_viewports[i].height = -viewports[i].Height;
4061 vk_viewports[i].minDepth = viewports[i].MinDepth;
4062 vk_viewports[i].maxDepth = viewports[i].MaxDepth;
4063
4064 if (vk_viewports[i].width <= 0.0f)
4065 {
4066 /* Vulkan does not support width <= 0 */
4067 FIXME_ONCE("Setting invalid viewport %u to zero height.\n", i);
4068 vk_viewports[i].width = 1.0f;
4069 vk_viewports[i].height = 0.0f;
4070 }
4071 }
4072
4073 vk_procs = &list->device->vk_procs;
4074 VK_CALL(vkCmdSetViewport(list->vk_command_buffer, 0, viewport_count, vk_viewports));
4075}
4076
4078 UINT rect_count, const D3D12_RECT *rects)
4079{
4082 const struct vkd3d_vk_device_procs *vk_procs;
4083 unsigned int i;
4084
4085 TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
4086
4087 if (rect_count > ARRAY_SIZE(vk_rects))
4088 {
4089 FIXME("Rect count %u > D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE.\n", rect_count);
4090 rect_count = ARRAY_SIZE(vk_rects);
4091 }
4092
4093 for (i = 0; i < rect_count; ++i)
4094 {
4095 vk_rects[i].offset.x = rects[i].left;
4096 vk_rects[i].offset.y = rects[i].top;
4097 vk_rects[i].extent.width = rects[i].right - rects[i].left;
4098 vk_rects[i].extent.height = rects[i].bottom - rects[i].top;
4099 }
4100
4101 vk_procs = &list->device->vk_procs;
4102 VK_CALL(vkCmdSetScissor(list->vk_command_buffer, 0, rect_count, vk_rects));
4103}
4104
4106 const FLOAT blend_factor[4])
4107{
4109 const struct vkd3d_vk_device_procs *vk_procs;
4110
4111 TRACE("iface %p, blend_factor %p.\n", iface, blend_factor);
4112
4113 vk_procs = &list->device->vk_procs;
4114 VK_CALL(vkCmdSetBlendConstants(list->vk_command_buffer, blend_factor));
4115}
4116
4118 UINT stencil_ref)
4119{
4121 const struct vkd3d_vk_device_procs *vk_procs;
4122
4123 TRACE("iface %p, stencil_ref %u.\n", iface, stencil_ref);
4124
4125 vk_procs = &list->device->vk_procs;
4126 VK_CALL(vkCmdSetStencilReference(list->vk_command_buffer, VK_STENCIL_FRONT_AND_BACK, stencil_ref));
4127}
4128
4130 ID3D12PipelineState *pipeline_state)
4131{
4134
4135 TRACE("iface %p, pipeline_state %p.\n", iface, pipeline_state);
4136
4137 if (list->state == state)
4138 return;
4139
4142
4143 list->state = state;
4144}
4145
4146static bool is_ds_multiplanar_resolvable(unsigned int first_state, unsigned int second_state)
4147{
4148 /* Only combinations of depth/stencil read/write are supported. */
4149 return first_state == second_state
4152}
4153
4155 unsigned int i, unsigned int barrier_count, unsigned int sub_resource_count)
4156{
4157 unsigned int sub_resource_idx = barriers[i].u.Transition.Subresource;
4158 unsigned int j;
4159
4160 for (j = i + 1; j < barrier_count; ++j)
4161 {
4163 && barriers[j].u.Transition.pResource == barriers[i].u.Transition.pResource
4164 && sub_resource_idx % sub_resource_count == barriers[j].u.Transition.Subresource % sub_resource_count)
4165 {
4166 /* Second barrier must be for a different plane. */
4167 if (barriers[j].u.Transition.Subresource == sub_resource_idx)
4168 return 0;
4169
4170 /* Validate the second barrier and check if the combination of two states is supported. */
4171 if (!is_valid_resource_state(barriers[j].u.Transition.StateBefore)
4172 || !is_ds_multiplanar_resolvable(barriers[i].u.Transition.StateBefore, barriers[j].u.Transition.StateBefore)
4173 || !is_valid_resource_state(barriers[j].u.Transition.StateAfter)
4174 || !is_ds_multiplanar_resolvable(barriers[i].u.Transition.StateAfter, barriers[j].u.Transition.StateAfter)
4175 || barriers[j].u.Transition.Subresource >= sub_resource_count * 2u)
4176 return 0;
4177
4178 return j;
4179 }
4180 }
4181 return 0;
4182}
4183
4185 UINT barrier_count, const D3D12_RESOURCE_BARRIER *barriers)
4186{
4188 bool have_aliasing_barriers = false, have_split_barriers = false;
4189 const struct vkd3d_vk_device_procs *vk_procs;
4190 const struct vkd3d_vulkan_info *vk_info;
4191 bool *multiplanar_handled = NULL;
4192 unsigned int i;
4193
4194 TRACE("iface %p, barrier_count %u, barriers %p.\n", iface, barrier_count, barriers);
4195
4196 vk_procs = &list->device->vk_procs;
4197 vk_info = &list->device->vk_info;
4198
4200
4201 for (i = 0; i < barrier_count; ++i)
4202 {
4203 unsigned int sub_resource_idx = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
4204 VkPipelineStageFlags src_stage_mask = 0, dst_stage_mask = 0;
4205 VkAccessFlags src_access_mask = 0, dst_access_mask = 0;
4206 const D3D12_RESOURCE_BARRIER *current = &barriers[i];
4207 VkImageLayout layout_before, layout_after;
4208 struct d3d12_resource *resource;
4209
4210 have_split_barriers = have_split_barriers
4213
4215 continue;
4216
4217 switch (current->Type)
4218 {
4220 {
4221 unsigned int state_before, state_after, stencil_state_before = 0, stencil_state_after = 0;
4222 const D3D12_RESOURCE_TRANSITION_BARRIER *transition = &current->u.Transition;
4223
4224 if (!is_valid_resource_state(transition->StateBefore))
4225 {
4227 "Invalid StateBefore %#x (barrier %u).", transition->StateBefore, i);
4228 continue;
4229 }
4230 if (!is_valid_resource_state(transition->StateAfter))
4231 {
4233 "Invalid StateAfter %#x (barrier %u).", transition->StateAfter, i);
4234 continue;
4235 }
4236
4238 {
4239 d3d12_command_list_mark_as_invalid(list, "A resource pointer is NULL.");
4240 continue;
4241 }
4242
4243 if (multiplanar_handled && multiplanar_handled[i])
4244 continue;
4245
4246 state_before = transition->StateBefore;
4247 state_after = transition->StateAfter;
4248
4249 sub_resource_idx = transition->Subresource;
4250
4251 if (sub_resource_idx != D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES
4253 {
4254 unsigned int sub_resource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
4255 unsigned int j = d3d12_find_ds_multiplanar_transition(barriers, i, barrier_count, sub_resource_count);
4256 if (j && (multiplanar_handled || (multiplanar_handled = vkd3d_calloc(barrier_count, sizeof(*multiplanar_handled)))))
4257 {
4258 multiplanar_handled[j] = true;
4259 if (sub_resource_idx >= sub_resource_count)
4260 {
4261 sub_resource_idx -= sub_resource_count;
4262 /* The stencil barrier is at i, depth at j. */
4263 state_before = barriers[j].u.Transition.StateBefore;
4264 state_after = barriers[j].u.Transition.StateAfter;
4265 stencil_state_before = transition->StateBefore;
4266 stencil_state_after = transition->StateAfter;
4267 }
4268 else
4269 {
4270 /* Depth at i, stencil at j. */
4271 stencil_state_before = barriers[j].u.Transition.StateBefore;
4272 stencil_state_after = barriers[j].u.Transition.StateAfter;
4273 }
4274 }
4275 else if (sub_resource_idx >= sub_resource_count)
4276 {
4277 FIXME_ONCE("Unhandled sub-resource idx %u.\n", sub_resource_idx);
4278 continue;
4279 }
4280 }
4281
4282 if (!vk_barrier_parameters_from_d3d12_resource_state(state_before, stencil_state_before,
4283 resource, list->vk_queue_flags, vk_info, &src_access_mask,
4284 &src_stage_mask, &layout_before, list->device))
4285 {
4286 FIXME("Unhandled state %#x.\n", state_before);
4287 continue;
4288 }
4289 if (!vk_barrier_parameters_from_d3d12_resource_state(state_after, stencil_state_after,
4290 resource, list->vk_queue_flags, vk_info, &dst_access_mask,
4291 &dst_stage_mask, &layout_after, list->device))
4292 {
4293 FIXME("Unhandled state %#x.\n", state_after);
4294 continue;
4295 }
4296
4297 TRACE("Transition barrier (resource %p, subresource %#x, before %#x, after %#x).\n",
4298 resource, transition->Subresource, transition->StateBefore, transition->StateAfter);
4299 break;
4300 }
4301
4303 {
4304 const D3D12_RESOURCE_UAV_BARRIER *uav = &current->u.UAV;
4305 VkPipelineStageFlags stage_mask;
4306 VkImageLayout image_layout;
4307 VkAccessFlags access_mask;
4308
4311 resource, list->vk_queue_flags, vk_info, &access_mask,
4312 &stage_mask, &image_layout, list->device);
4313 src_access_mask = dst_access_mask = access_mask;
4314 src_stage_mask = dst_stage_mask = stage_mask;
4315 layout_before = layout_after = image_layout;
4316
4317 TRACE("UAV barrier (resource %p).\n", resource);
4318 break;
4319 }
4320
4322 have_aliasing_barriers = true;
4323 continue;
4324 default:
4325 WARN("Invalid barrier type %#x.\n", current->Type);
4326 continue;
4327 }
4328
4329 if (resource)
4331
4332 if (!resource)
4333 {
4334 VkMemoryBarrier vk_barrier;
4335
4337 vk_barrier.pNext = NULL;
4338 vk_barrier.srcAccessMask = src_access_mask;
4339 vk_barrier.dstAccessMask = dst_access_mask;
4340
4341 VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer, src_stage_mask, dst_stage_mask, 0,
4342 1, &vk_barrier, 0, NULL, 0, NULL));
4343 }
4345 {
4346 VkBufferMemoryBarrier vk_barrier;
4347
4349 vk_barrier.pNext = NULL;
4350 vk_barrier.srcAccessMask = src_access_mask;
4351 vk_barrier.dstAccessMask = dst_access_mask;
4354 vk_barrier.buffer = resource->u.vk_buffer;
4355 vk_barrier.offset = 0;
4356 vk_barrier.size = VK_WHOLE_SIZE;
4357
4358 VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer, src_stage_mask, dst_stage_mask, 0,
4359 0, NULL, 1, &vk_barrier, 0, NULL));
4360 }
4361 else
4362 {
4363 VkImageMemoryBarrier vk_barrier;
4364
4366 vk_barrier.pNext = NULL;
4367 vk_barrier.srcAccessMask = src_access_mask;
4368 vk_barrier.dstAccessMask = dst_access_mask;
4369 vk_barrier.oldLayout = layout_before;
4370 vk_barrier.newLayout = layout_after;
4373 vk_barrier.image = resource->u.vk_image;
4374
4375 vk_barrier.subresourceRange.aspectMask = resource->format->vk_aspect_mask;
4376 if (sub_resource_idx == D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES)
4377 {
4378 vk_barrier.subresourceRange.baseMipLevel = 0;
4380 vk_barrier.subresourceRange.baseArrayLayer = 0;
4382 }
4383 else
4384 {
4385 /* FIXME: Some formats in D3D12 are planar. Each plane is a separate sub-resource. */
4386 if (sub_resource_idx >= d3d12_resource_desc_get_sub_resource_count(&resource->desc))
4387 {
4388 FIXME_ONCE("Unhandled sub-resource idx %u.\n", sub_resource_idx);
4389 continue;
4390 }
4391
4392 vk_barrier.subresourceRange.baseMipLevel = sub_resource_idx % resource->desc.MipLevels;
4393 vk_barrier.subresourceRange.levelCount = 1;
4394 vk_barrier.subresourceRange.baseArrayLayer = sub_resource_idx / resource->desc.MipLevels;
4395 vk_barrier.subresourceRange.layerCount = 1;
4396 }
4397
4398 VK_CALL(vkCmdPipelineBarrier(list->vk_command_buffer, src_stage_mask, dst_stage_mask, 0,
4399 0, NULL, 0, NULL, 1, &vk_barrier));
4400 }
4401 }
4402
4403 vkd3d_free(multiplanar_handled);
4404
4405 if (have_aliasing_barriers)
4406 FIXME_ONCE("Aliasing barriers not implemented yet.\n");
4407
4408 /* Vulkan doesn't support split barriers. */
4409 if (have_split_barriers)
4410 WARN("Issuing split barrier(s) on D3D12_RESOURCE_BARRIER_FLAG_END_ONLY.\n");
4411}
4412
4414 ID3D12GraphicsCommandList *command_list)
4415{
4416 FIXME("iface %p, command_list %p stub!\n", iface, command_list);
4417}
4418
4420 UINT heap_count, ID3D12DescriptorHeap *const *heaps)
4421{
4422 TRACE("iface %p, heap_count %u, heaps %p.\n", iface, heap_count, heaps);
4423
4424 /* Our current implementation does not need this method.
4425 * In Windows it doesn't need to be called at all for correct operation, and
4426 * at least on AMD the wrong heaps can be set here and tests still succeed.
4427 *
4428 * It could be used to validate descriptor tables but we do not have an
4429 * equivalent of the D3D12 Debug Layer. */
4430}
4431
4433 enum vkd3d_pipeline_bind_point bind_point, const struct d3d12_root_signature *root_signature)
4434{
4435 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
4436
4437 if (bindings->root_signature == root_signature)
4438 return;
4439
4440 bindings->root_signature = root_signature;
4441
4443}
4444
4447{
4449
4450 TRACE("iface %p, root_signature %p.\n", iface, root_signature);
4451
4453 unsafe_impl_from_ID3D12RootSignature(root_signature));
4454}
4455
4457 ID3D12RootSignature *root_signature)
4458{
4460
4461 TRACE("iface %p, root_signature %p.\n", iface, root_signature);
4462
4464 unsafe_impl_from_ID3D12RootSignature(root_signature));
4465}
4466
4468 enum vkd3d_pipeline_bind_point bind_point, unsigned int index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
4469{
4470 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
4471 const struct d3d12_root_signature *root_signature = bindings->root_signature;
4472 struct d3d12_descriptor_heap *descriptor_heap;
4473 struct d3d12_desc *desc;
4474
4476
4478 desc = d3d12_desc_from_gpu_handle(base_descriptor);
4479
4480 if (bindings->descriptor_tables[index] == desc)
4481 return;
4482
4483 descriptor_heap = d3d12_desc_get_descriptor_heap(desc);
4484 if (!(descriptor_heap->desc.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE))
4485 {
4486 /* GetGPUDescriptorHandleForHeapStart() returns a null handle in this case,
4487 * but a CPU handle could be passed. */
4488 WARN("Descriptor heap %p is not shader visible.\n", descriptor_heap);
4489 return;
4490 }
4491 command_list_add_descriptor_heap(list, descriptor_heap);
4492
4493 bindings->descriptor_tables[index] = desc;
4494 bindings->descriptor_table_dirty_mask |= (uint64_t)1 << index;
4495 bindings->descriptor_table_active_mask |= (uint64_t)1 << index;
4496}
4497
4499 UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
4500{
4502
4503 TRACE("iface %p, root_parameter_index %u, base_descriptor %s.\n",
4504 iface, root_parameter_index, debug_gpu_handle(base_descriptor));
4505
4507 root_parameter_index, base_descriptor);
4508}
4509
4511 UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
4512{
4514
4515 TRACE("iface %p, root_parameter_index %u, base_descriptor %s.\n",
4516 iface, root_parameter_index, debug_gpu_handle(base_descriptor));
4517
4519 root_parameter_index, base_descriptor);
4520}
4521
4523 enum vkd3d_pipeline_bind_point bind_point, unsigned int index, unsigned int offset,
4524 unsigned int count, const void *data)
4525{
4526 const struct d3d12_root_signature *root_signature = list->pipeline_bindings[bind_point].root_signature;
4527 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
4528 const struct d3d12_root_constant *c;
4529
4530 c = root_signature_get_32bit_constants(root_signature, index);
4531 VK_CALL(vkCmdPushConstants(list->vk_command_buffer, root_signature->vk_pipeline_layout,
4532 c->stage_flags, c->offset + offset * sizeof(uint32_t), count * sizeof(uint32_t), data));
4533}
4534
4536 UINT root_parameter_index, UINT data, UINT dst_offset)
4537{
4539
4540 TRACE("iface %p, root_parameter_index %u, data 0x%08x, dst_offset %u.\n",
4541 iface, root_parameter_index, data, dst_offset);
4542
4544 root_parameter_index, dst_offset, 1, &data);
4545}
4546
4548 UINT root_parameter_index, UINT data, UINT dst_offset)
4549{
4551
4552 TRACE("iface %p, root_parameter_index %u, data 0x%08x, dst_offset %u.\n",
4553 iface, root_parameter_index, data, dst_offset);
4554
4556 root_parameter_index, dst_offset, 1, &data);
4557}
4558
4560 UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset)
4561{
4563
4564 TRACE("iface %p, root_parameter_index %u, constant_count %u, data %p, dst_offset %u.\n",
4565 iface, root_parameter_index, constant_count, data, dst_offset);
4566
4568 root_parameter_index, dst_offset, constant_count, data);
4569}
4570
4572 UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset)
4573{
4575
4576 TRACE("iface %p, root_parameter_index %u, constant_count %u, data %p, dst_offset %u.\n",
4577 iface, root_parameter_index, constant_count, data, dst_offset);
4578
4580 root_parameter_index, dst_offset, constant_count, data);
4581}
4582
4584 enum vkd3d_pipeline_bind_point bind_point, unsigned int index, D3D12_GPU_VIRTUAL_ADDRESS gpu_address)
4585{
4586 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
4587 const struct d3d12_root_signature *root_signature = bindings->root_signature;
4588 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
4589 const struct vkd3d_vulkan_info *vk_info = &list->device->vk_info;
4590 const struct d3d12_root_parameter *root_parameter;
4591 struct VkWriteDescriptorSet descriptor_write;
4592 struct VkDescriptorBufferInfo buffer_info;
4593 struct d3d12_resource *resource;
4594
4595 root_parameter = root_signature_get_root_descriptor(root_signature, index);
4597
4598 if (gpu_address)
4599 {
4600 resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, gpu_address);
4601 buffer_info.buffer = resource->u.vk_buffer;
4602 buffer_info.offset = gpu_address - resource->gpu_address;
4603 buffer_info.range = resource->desc.Width - buffer_info.offset;
4604 buffer_info.range = min(buffer_info.range, vk_info->device_limits.maxUniformBufferRange);
4605 }
4606 else
4607 {
4608 buffer_info.buffer = list->device->null_resources.vk_buffer;
4609 buffer_info.offset = 0;
4610 buffer_info.range = VK_WHOLE_SIZE;
4611 }
4612
4613 if (vk_info->KHR_push_descriptor)
4614 {
4616 root_parameter, VK_NULL_HANDLE, NULL, &buffer_info);
4617 VK_CALL(vkCmdPushDescriptorSetKHR(list->vk_command_buffer, bindings->vk_bind_point,
4618 root_signature->vk_pipeline_layout, 0, 1, &descriptor_write));
4619 }
4620 else
4621 {
4624 root_parameter, bindings->descriptor_sets[0], NULL, &buffer_info);
4625 VK_CALL(vkUpdateDescriptorSets(list->device->vk_device, 1, &descriptor_write, 0, NULL));
4626
4628 bindings->push_descriptors[index].u.cbv.vk_buffer = buffer_info.buffer;
4629 bindings->push_descriptors[index].u.cbv.offset = buffer_info.offset;
4630 bindings->push_descriptor_dirty_mask |= 1u << index;
4631 bindings->push_descriptor_active_mask |= 1u << index;
4632 }
4633}
4634
4637{
4639
4640 TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n",
4641 iface, root_parameter_index, address);
4642
4644}
4645
4648{
4650
4651 TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n",
4652 iface, root_parameter_index, address);
4653
4655}
4656
4658 enum vkd3d_pipeline_bind_point bind_point, unsigned int index, D3D12_GPU_VIRTUAL_ADDRESS gpu_address)
4659{
4660 struct vkd3d_pipeline_bindings *bindings = &list->pipeline_bindings[bind_point];
4661 const struct d3d12_root_signature *root_signature = bindings->root_signature;
4662 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
4663 const struct vkd3d_vulkan_info *vk_info = &list->device->vk_info;
4664 const struct d3d12_root_parameter *root_parameter;
4665 struct VkWriteDescriptorSet descriptor_write;
4666 VkDevice vk_device = list->device->vk_device;
4667 VkBufferView vk_buffer_view;
4668
4669 root_parameter = root_signature_get_root_descriptor(root_signature, index);
4671
4672 /* FIXME: Re-use buffer views. */
4673 if (!vkd3d_create_raw_buffer_view(list->device, gpu_address, root_parameter->parameter_type, &vk_buffer_view))
4674 {
4675 ERR("Failed to create buffer view.\n");
4676 return;
4677 }
4678
4679 if (vk_buffer_view && !(d3d12_command_allocator_add_buffer_view(list->allocator, vk_buffer_view)))
4680 {
4681 ERR("Failed to add buffer view.\n");
4682 VK_CALL(vkDestroyBufferView(vk_device, vk_buffer_view, NULL));
4683 return;
4684 }
4685
4686 if (vk_info->KHR_push_descriptor)
4687 {
4689 root_parameter, VK_NULL_HANDLE, &vk_buffer_view, NULL);
4690 VK_CALL(vkCmdPushDescriptorSetKHR(list->vk_command_buffer, bindings->vk_bind_point,
4691 root_signature->vk_pipeline_layout, 0, 1, &descriptor_write));
4692 }
4693 else
4694 {
4697 root_parameter, bindings->descriptor_sets[0], &vk_buffer_view, NULL);
4698 VK_CALL(vkUpdateDescriptorSets(list->device->vk_device, 1, &descriptor_write, 0, NULL));
4699
4701 bindings->push_descriptors[index].u.vk_buffer_view = vk_buffer_view;
4702 bindings->push_descriptor_dirty_mask |= 1u << index;
4703 bindings->push_descriptor_active_mask |= 1u << index;
4704 }
4705}
4706
4709{
4711
4712 TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n",
4713 iface, root_parameter_index, address);
4714
4716 root_parameter_index, address);
4717}
4718
4721{
4723
4724 TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n",
4725 iface, root_parameter_index, address);
4726
4728 root_parameter_index, address);
4729}
4730
4733{
4735
4736 TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n",
4737 iface, root_parameter_index, address);
4738
4740 root_parameter_index, address);
4741}
4742
4745{
4747
4748 TRACE("iface %p, root_parameter_index %u, address %#"PRIx64".\n",
4749 iface, root_parameter_index, address);
4750
4752 root_parameter_index, address);
4753}
4754
4757{
4759 const struct vkd3d_vk_device_procs *vk_procs;
4760 struct d3d12_resource *resource;
4761 enum VkIndexType index_type;
4762
4763 TRACE("iface %p, view %p.\n", iface, view);
4764
4765 if (!view)
4766 {
4767 WARN("Ignoring NULL index buffer view.\n");
4768 return;
4769 }
4770 if (!view->BufferLocation)
4771 {
4772 WARN("Ignoring index buffer location 0.\n");
4773 return;
4774 }
4775
4776 vk_procs = &list->device->vk_procs;
4777
4778 switch (view->Format)
4779 {
4781 index_type = VK_INDEX_TYPE_UINT16;
4782 break;
4784 index_type = VK_INDEX_TYPE_UINT32;
4785 break;
4786 default:
4787 WARN("Invalid index format %#x.\n", view->Format);
4788 return;
4789 }
4790
4791 list->index_buffer_format = view->Format;
4792
4793 resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, view->BufferLocation);
4794 VK_CALL(vkCmdBindIndexBuffer(list->vk_command_buffer, resource->u.vk_buffer,
4795 view->BufferLocation - resource->gpu_address, index_type));
4796}
4797
4799 UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views)
4800{
4802 const struct vkd3d_null_resources *null_resources;
4803 struct vkd3d_gpu_va_allocator *gpu_va_allocator;
4805 const struct vkd3d_vk_device_procs *vk_procs;
4806 VkBuffer buffers[ARRAY_SIZE(list->strides)];
4807 struct d3d12_device *device = list->device;
4808 unsigned int i, stride, max_view_count;
4809 struct d3d12_resource *resource;
4810 bool invalidate = false;
4811
4812 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
4813
4814 vk_procs = &device->vk_procs;
4815 null_resources = &device->null_resources;
4816 gpu_va_allocator = &device->gpu_va_allocator;
4817
4818 if (!vkd3d_bound_range(start_slot, view_count, ARRAY_SIZE(list->strides)))
4819 {
4820 WARN("Invalid start slot %u / view count %u.\n", start_slot, view_count);
4821 return;
4822 }
4823
4824 max_view_count = device->vk_info.device_limits.maxVertexInputBindings;
4825 if (start_slot < max_view_count)
4826 max_view_count -= start_slot;
4827 else
4828 max_view_count = 0;
4829
4830 /* Although simply skipping unsupported binding slots isn't especially
4831 * likely to work well in the general case, applications sometimes
4832 * explicitly set all 32 vertex buffer bindings slots supported by
4833 * Direct3D 12, with unused slots set to NULL. "Spider-Man Remastered" is
4834 * an example of such an application. */
4835 if (view_count > max_view_count)
4836 {
4837 for (i = max_view_count; i < view_count; ++i)
4838 {
4839 if (views && views[i].BufferLocation)
4840 WARN("Ignoring unsupported vertex buffer slot %u.\n", start_slot + i);
4841 }
4842 view_count = max_view_count;
4843 }
4844
4845 for (i = 0; i < view_count; ++i)
4846 {
4847 if (views && views[i].BufferLocation)
4848 {
4849 resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferLocation);
4850 buffers[i] = resource->u.vk_buffer;
4851 offsets[i] = views[i].BufferLocation - resource->gpu_address;
4852 stride = views[i].StrideInBytes;
4853 }
4854 else
4855 {
4856 buffers[i] = null_resources->vk_buffer;
4857 offsets[i] = 0;
4858 stride = 0;
4859 }
4860
4861 invalidate |= list->strides[start_slot + i] != stride;
4862 list->strides[start_slot + i] = stride;
4863 }
4864
4865 if (view_count)
4866 VK_CALL(vkCmdBindVertexBuffers(list->vk_command_buffer, start_slot, view_count, buffers, offsets));
4867
4868 if (invalidate)
4870}
4871
4873 UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views)
4874{
4876 VkDeviceSize offsets[ARRAY_SIZE(list->so_counter_buffers)];
4877 VkDeviceSize sizes[ARRAY_SIZE(list->so_counter_buffers)];
4878 VkBuffer buffers[ARRAY_SIZE(list->so_counter_buffers)];
4879 struct vkd3d_gpu_va_allocator *gpu_va_allocator;
4880 const struct vkd3d_vk_device_procs *vk_procs;
4881 struct d3d12_resource *resource;
4882 unsigned int i, first, count;
4883
4884 TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views);
4885
4887
4888 if (!list->device->vk_info.EXT_transform_feedback)
4889 {
4890 FIXME("Transform feedback is not supported by Vulkan implementation.\n");
4891 return;
4892 }
4893
4894 if (!vkd3d_bound_range(start_slot, view_count, ARRAY_SIZE(buffers)))
4895 {
4896 WARN("Invalid start slot %u / view count %u.\n", start_slot, view_count);
4897 return;
4898 }
4899
4900 vk_procs = &list->device->vk_procs;
4901 gpu_va_allocator = &list->device->gpu_va_allocator;
4902
4903 count = 0;
4904 first = start_slot;
4905 for (i = 0; i < view_count; ++i)
4906 {
4907 if (views[i].BufferLocation && views[i].SizeInBytes)
4908 {
4909 resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferLocation);
4910 buffers[count] = resource->u.vk_buffer;
4911 offsets[count] = views[i].BufferLocation - resource->gpu_address;
4912 sizes[count] = views[i].SizeInBytes;
4913
4914 resource = vkd3d_gpu_va_allocator_dereference(gpu_va_allocator, views[i].BufferFilledSizeLocation);
4915 list->so_counter_buffers[start_slot + i] = resource->u.vk_buffer;
4916 list->so_counter_buffer_offsets[start_slot + i] = views[i].BufferFilledSizeLocation - resource->gpu_address;
4917 ++count;
4918 }
4919 else
4920 {
4921 if (count)
4923 count = 0;
4924 first = start_slot + i + 1;
4925
4926 list->so_counter_buffers[start_slot + i] = VK_NULL_HANDLE;
4927 list->so_counter_buffer_offsets[start_slot + i] = 0;
4928
4929 WARN("Trying to unbind transform feedback buffer %u. Ignoring.\n", start_slot + i);
4930 }
4931 }
4932
4933 if (count)
4935}
4936
4938 UINT render_target_descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE *render_target_descriptors,
4939 BOOL single_descriptor_handle, const D3D12_CPU_DESCRIPTOR_HANDLE *depth_stencil_descriptor)
4940{
4942 const struct d3d12_rtv_desc *rtv_desc;
4943 const struct d3d12_dsv_desc *dsv_desc;
4944 VkFormat prev_dsv_format;
4945 struct vkd3d_view *view;
4946 unsigned int i;
4947
4948 TRACE("iface %p, render_target_descriptor_count %u, render_target_descriptors %p, "
4949 "single_descriptor_handle %#x, depth_stencil_descriptor %p.\n",
4950 iface, render_target_descriptor_count, render_target_descriptors,
4951 single_descriptor_handle, depth_stencil_descriptor);
4952
4953 if (render_target_descriptor_count > ARRAY_SIZE(list->rtvs))
4954 {
4955 WARN("Descriptor count %u > %zu, ignoring extra descriptors.\n",
4956 render_target_descriptor_count, ARRAY_SIZE(list->rtvs));
4957 render_target_descriptor_count = ARRAY_SIZE(list->rtvs);
4958 }
4959
4960 list->fb_width = 0;
4961 list->fb_height = 0;
4962 list->fb_layer_count = 0;
4963 for (i = 0; i < render_target_descriptor_count; ++i)
4964 {
4965 if (single_descriptor_handle)
4966 {
4967 if ((rtv_desc = d3d12_rtv_desc_from_cpu_handle(*render_target_descriptors)))
4968 rtv_desc += i;
4969 }
4970 else
4971 {
4972 rtv_desc = d3d12_rtv_desc_from_cpu_handle(render_target_descriptors[i]);
4973 }
4974
4975 if (!rtv_desc || !rtv_desc->resource)
4976 {
4977 WARN("RTV descriptor %u is not initialized.\n", i);
4978 list->rtvs[i] = VK_NULL_HANDLE;
4979 continue;
4980 }
4981
4983
4984 /* In D3D12 CPU descriptors are consumed when a command is recorded. */
4985 view = rtv_desc->view;
4986 if (!d3d12_command_allocator_add_view(list->allocator, view))
4987 {
4988 WARN("Failed to add view.\n");
4989 }
4990
4991 list->rtvs[i] = view->v.u.vk_image_view;
4992 list->fb_width = max(list->fb_width, rtv_desc->width);
4993 list->fb_height = max(list->fb_height, rtv_desc->height);
4994 list->fb_layer_count = max(list->fb_layer_count, rtv_desc->layer_count);
4995 }
4996
4997 prev_dsv_format = list->dsv_format;
4998 list->dsv = VK_NULL_HANDLE;
4999 list->dsv_format = VK_FORMAT_UNDEFINED;
5000 if (depth_stencil_descriptor)
5001 {
5002 if ((dsv_desc = d3d12_dsv_desc_from_cpu_handle(*depth_stencil_descriptor))
5003 && dsv_desc->resource)
5004 {
5006
5007 /* In D3D12 CPU descriptors are consumed when a command is recorded. */
5008 view = dsv_desc->view;
5009 if (!d3d12_command_allocator_add_view(list->allocator, view))
5010 {
5011 WARN("Failed to add view.\n");
5012 list->dsv = VK_NULL_HANDLE;
5013 }
5014
5015 list->dsv = view->v.u.vk_image_view;
5016 list->fb_width = max(list->fb_width, dsv_desc->width);
5017 list->fb_height = max(list->fb_height, dsv_desc->height);
5018 list->fb_layer_count = max(list->fb_layer_count, dsv_desc->layer_count);
5019 list->dsv_format = dsv_desc->format->vk_format;
5020 }
5021 else
5022 {
5023 WARN("DSV descriptor is not initialized.\n");
5024 }
5025 }
5026
5027 if (prev_dsv_format != list->dsv_format && d3d12_pipeline_state_has_unknown_dsv_format(list->state))
5029
5032}
5033
5035 const struct VkAttachmentDescription *attachment_desc,
5036 const struct VkAttachmentReference *color_reference, const struct VkAttachmentReference *ds_reference,
5037 struct vkd3d_view *view, size_t width, size_t height, unsigned int layer_count,
5038 const union VkClearValue *clear_value, unsigned int rect_count, const D3D12_RECT *rects)
5039{
5040 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
5041 struct VkSubpassDescription sub_pass_desc;
5042 struct VkRenderPassCreateInfo pass_desc;
5043 struct VkRenderPassBeginInfo begin_desc;
5044 struct VkFramebufferCreateInfo fb_desc;
5045 VkFramebuffer vk_framebuffer;
5046 VkRenderPass vk_render_pass;
5047 D3D12_RECT full_rect;
5048 unsigned int i;
5049 VkResult vr;
5050
5052
5053 if (!rect_count)
5054 {
5055 full_rect.top = 0;
5056 full_rect.left = 0;
5057 full_rect.bottom = height;
5058 full_rect.right = width;
5059
5060 rect_count = 1;
5061 rects = &full_rect;
5062 }
5063
5064 sub_pass_desc.flags = 0;
5066 sub_pass_desc.inputAttachmentCount = 0;
5067 sub_pass_desc.pInputAttachments = NULL;
5068 sub_pass_desc.colorAttachmentCount = !!color_reference;
5069 sub_pass_desc.pColorAttachments = color_reference;
5070 sub_pass_desc.pResolveAttachments = NULL;
5071 sub_pass_desc.pDepthStencilAttachment = ds_reference;
5072 sub_pass_desc.preserveAttachmentCount = 0;
5073 sub_pass_desc.pPreserveAttachments = NULL;
5074
5076 pass_desc.pNext = NULL;
5077 pass_desc.flags = 0;
5078 pass_desc.attachmentCount = 1;
5079 pass_desc.pAttachments = attachment_desc;
5080 pass_desc.subpassCount = 1;
5081 pass_desc.pSubpasses = &sub_pass_desc;
5082 pass_desc.dependencyCount = 0;
5083 pass_desc.pDependencies = NULL;
5084 if ((vr = VK_CALL(vkCreateRenderPass(list->device->vk_device, &pass_desc, NULL, &vk_render_pass))) < 0)
5085 {
5086 WARN("Failed to create Vulkan render pass, vr %d.\n", vr);
5087 return;
5088 }
5089
5090 if (!d3d12_command_allocator_add_render_pass(list->allocator, vk_render_pass))
5091 {
5092 WARN("Failed to add render pass.\n");
5093 VK_CALL(vkDestroyRenderPass(list->device->vk_device, vk_render_pass, NULL));
5094 return;
5095 }
5096
5097 if (!d3d12_command_allocator_add_view(list->allocator, view))
5098 {
5099 WARN("Failed to add view.\n");
5100 }
5101
5103 fb_desc.pNext = NULL;
5104 fb_desc.flags = 0;
5105 fb_desc.renderPass = vk_render_pass;
5106 fb_desc.attachmentCount = 1;
5107 fb_desc.pAttachments = &view->v.u.vk_image_view;
5108 fb_desc.width = width;
5109 fb_desc.height = height;
5110 fb_desc.layers = layer_count;
5111 if ((vr = VK_CALL(vkCreateFramebuffer(list->device->vk_device, &fb_desc, NULL, &vk_framebuffer))) < 0)
5112 {
5113 WARN("Failed to create Vulkan framebuffer, vr %d.\n", vr);
5114 return;
5115 }
5116
5117 if (!d3d12_command_allocator_add_framebuffer(list->allocator, vk_framebuffer))
5118 {
5119 WARN("Failed to add framebuffer.\n");
5120 VK_CALL(vkDestroyFramebuffer(list->device->vk_device, vk_framebuffer, NULL));
5121 return;
5122 }
5123
5125 begin_desc.pNext = NULL;
5126 begin_desc.renderPass = vk_render_pass;
5127 begin_desc.framebuffer = vk_framebuffer;
5128 begin_desc.clearValueCount = 1;
5129 begin_desc.pClearValues = clear_value;
5130
5131 for (i = 0; i < rect_count; ++i)
5132 {
5133 begin_desc.renderArea.offset.x = rects[i].left;
5134 begin_desc.renderArea.offset.y = rects[i].top;
5135 begin_desc.renderArea.extent.width = rects[i].right - rects[i].left;
5136 begin_desc.renderArea.extent.height = rects[i].bottom - rects[i].top;
5137 VK_CALL(vkCmdBeginRenderPass(list->vk_command_buffer, &begin_desc, VK_SUBPASS_CONTENTS_INLINE));
5138 VK_CALL(vkCmdEndRenderPass(list->vk_command_buffer));
5139 }
5140}
5141
5144 UINT rect_count, const D3D12_RECT *rects)
5145{
5146 const union VkClearValue clear_value = {.depthStencil = {depth, stencil}};
5148 const struct d3d12_dsv_desc *dsv_desc = d3d12_dsv_desc_from_cpu_handle(dsv);
5149 struct VkAttachmentDescription attachment_desc;
5150 struct VkAttachmentReference ds_reference;
5151
5152 TRACE("iface %p, dsv %s, flags %#x, depth %.8e, stencil 0x%02x, rect_count %u, rects %p.\n",
5153 iface, debug_cpu_handle(dsv), flags, depth, stencil, rect_count, rects);
5154
5156
5157 attachment_desc.flags = 0;
5158 attachment_desc.format = dsv_desc->format->vk_format;
5159 attachment_desc.samples = dsv_desc->sample_count;
5161 {
5162 attachment_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5163 attachment_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5164 }
5165 else
5166 {
5167 attachment_desc.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
5168 attachment_desc.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
5169 }
5171 {
5174 }
5175 else
5176 {
5179 }
5182
5183 ds_reference.attachment = 0;
5185
5186 d3d12_command_list_clear(list, &attachment_desc, NULL, &ds_reference,
5187 dsv_desc->view, dsv_desc->width, dsv_desc->height, dsv_desc->layer_count,
5188 &clear_value, rect_count, rects);
5189}
5190
5192 D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects)
5193{
5195 const struct d3d12_rtv_desc *rtv_desc = d3d12_rtv_desc_from_cpu_handle(rtv);
5196 struct VkAttachmentDescription attachment_desc;
5197 struct VkAttachmentReference color_reference;
5198 VkClearValue clear_value;
5199
5200 TRACE("iface %p, rtv %s, color %p, rect_count %u, rects %p.\n",
5201 iface, debug_cpu_handle(rtv), color, rect_count, rects);
5202
5204
5205 attachment_desc.flags = 0;
5206 attachment_desc.format = rtv_desc->format->vk_format;
5207 attachment_desc.samples = rtv_desc->sample_count;
5208 attachment_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
5209 attachment_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
5214
5215 color_reference.attachment = 0;
5217
5218 if (rtv_desc->format->type == VKD3D_FORMAT_TYPE_UINT)
5219 {
5220 clear_value.color.uint32[0] = max(0, color[0]);
5221 clear_value.color.uint32[1] = max(0, color[1]);
5222 clear_value.color.uint32[2] = max(0, color[2]);
5223 clear_value.color.uint32[3] = max(0, color[3]);
5224 }
5225 else if (rtv_desc->format->type == VKD3D_FORMAT_TYPE_SINT)
5226 {
5227 clear_value.color.int32[0] = color[0];
5228 clear_value.color.int32[1] = color[1];
5229 clear_value.color.int32[2] = color[2];
5230 clear_value.color.int32[3] = color[3];
5231 }
5232 else
5233 {
5234 clear_value.color.float32[0] = color[0];
5235 clear_value.color.float32[1] = color[1];
5236 clear_value.color.float32[2] = color[2];
5237 clear_value.color.float32[3] = color[3];
5238 }
5239
5240 d3d12_command_list_clear(list, &attachment_desc, &color_reference, NULL,
5241 rtv_desc->view, rtv_desc->width, rtv_desc->height, rtv_desc->layer_count,
5242 &clear_value, rect_count, rects);
5243}
5244
5246{
5247 VkDescriptorSetLayout vk_set_layout;
5248 VkPipelineLayout vk_pipeline_layout;
5249 VkPipeline vk_pipeline;
5251};
5252
5254 enum vkd3d_format_type format_type, struct vkd3d_uav_clear_pipeline *info)
5255{
5257
5258 pipelines = format_type == VKD3D_FORMAT_TYPE_UINT ? &state->pipelines_uint : &state->pipelines_float;
5259 info->vk_set_layout = state->vk_set_layout_buffer;
5260 info->vk_pipeline_layout = state->vk_pipeline_layout_buffer;
5261 info->vk_pipeline = pipelines->buffer;
5262 info->group_size = (VkExtent3D){128, 1, 1};
5263}
5264
5266 VkImageViewType image_view_type, enum vkd3d_format_type format_type, struct vkd3d_uav_clear_pipeline *info)
5267{
5269
5270 pipelines = format_type == VKD3D_FORMAT_TYPE_UINT ? &state->pipelines_uint : &state->pipelines_float;
5271 info->vk_set_layout = state->vk_set_layout_image;
5272 info->vk_pipeline_layout = state->vk_pipeline_layout_image;
5273
5274 switch (image_view_type)
5275 {
5277 info->vk_pipeline = pipelines->image_1d;
5278 info->group_size = (VkExtent3D){64, 1, 1};
5279 break;
5280
5282 info->vk_pipeline = pipelines->image_1d_array;
5283 info->group_size = (VkExtent3D){64, 1, 1};
5284 break;
5285
5287 info->vk_pipeline = pipelines->image_2d;
5288 info->group_size = (VkExtent3D){8, 8, 1};
5289 break;
5290
5292 info->vk_pipeline = pipelines->image_2d_array;
5293 info->group_size = (VkExtent3D){8, 8, 1};
5294 break;
5295
5297 info->vk_pipeline = pipelines->image_3d;
5298 info->group_size = (VkExtent3D){8, 8, 1};
5299 break;
5300
5301 default:
5302 ERR("Unhandled view type %#x.\n", image_view_type);
5303 info->vk_pipeline = VK_NULL_HANDLE;
5304 info->group_size = (VkExtent3D){0, 0, 0};
5305 break;
5306 }
5307}
5308
5310 struct d3d12_resource *resource, struct vkd3d_view *descriptor, const VkClearColorValue *clear_colour,
5311 unsigned int rect_count, const D3D12_RECT *rects)
5312{
5313 const VkPhysicalDeviceLimits *device_limits = &list->device->vk_info.device_limits;
5314 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
5315 unsigned int i, miplevel_idx, layer_count;
5316 struct vkd3d_uav_clear_pipeline pipeline;
5317 struct vkd3d_uav_clear_args clear_args;
5318 const struct vkd3d_resource_view *view;
5319 uint32_t count_x, count_y, count_z;
5320 VkDescriptorImageInfo image_info;
5321 D3D12_RECT full_rect, curr_rect;
5322 VkWriteDescriptorSet write_set;
5323
5326
5330
5332 WARN("Failed to add view.\n");
5333 view = &descriptor->v;
5334
5335 clear_args.colour = *clear_colour;
5336
5338 write_set.pNext = NULL;
5339 write_set.dstBinding = 0;
5340 write_set.dstArrayElement = 0;
5341 write_set.descriptorCount = 1;
5342
5344 {
5346 write_set.pImageInfo = NULL;
5347 write_set.pBufferInfo = NULL;
5348 write_set.pTexelBufferView = &view->u.vk_buffer_view;
5349
5350 miplevel_idx = 0;
5351 layer_count = 1;
5352 vkd3d_uav_clear_state_get_buffer_pipeline(&list->device->uav_clear_state,
5353 view->format->type, &pipeline);
5354 }
5355 else
5356 {
5357 image_info.sampler = VK_NULL_HANDLE;
5358 image_info.imageView = view->u.vk_image_view;
5360
5362 write_set.pImageInfo = &image_info;
5363 write_set.pBufferInfo = NULL;
5364 write_set.pTexelBufferView = NULL;
5365
5366 miplevel_idx = view->info.texture.miplevel_idx;
5367 layer_count = view->info.texture.vk_view_type == VK_IMAGE_VIEW_TYPE_3D
5369 : view->info.texture.layer_count;
5370 vkd3d_uav_clear_state_get_image_pipeline(&list->device->uav_clear_state,
5371 view->info.texture.vk_view_type, view->format->type, &pipeline);
5372 }
5373
5374 if (!(write_set.dstSet = d3d12_command_allocator_allocate_descriptor_set(
5375 list->allocator, pipeline.vk_set_layout, 0, false)))
5376 {
5377 ERR("Failed to allocate descriptor set.\n");
5378 return;
5379 }
5380
5381 VK_CALL(vkUpdateDescriptorSets(list->device->vk_device, 1, &write_set, 0, NULL));
5382
5383 full_rect.left = 0;
5385 full_rect.top = 0;
5387
5388 if (!rect_count)
5389 {
5390 rects = &full_rect;
5391 rect_count = 1;
5392 }
5393
5395
5397 pipeline.vk_pipeline_layout, 0, 1, &write_set.dstSet, 0, NULL));
5398
5399 for (i = 0; i < rect_count; ++i)
5400 {
5401 /* Clamp to the actual resource region and skip empty rectangles. */
5402 curr_rect.left = max(rects[i].left, full_rect.left);
5403 curr_rect.top = max(rects[i].top, full_rect.top);
5404 curr_rect.right = min(rects[i].right, full_rect.right);
5405 curr_rect.bottom = min(rects[i].bottom, full_rect.bottom);
5406
5407 if (curr_rect.left >= curr_rect.right || curr_rect.top >= curr_rect.bottom)
5408 continue;
5409
5410 clear_args.offset.y = curr_rect.top;
5411 clear_args.extent.height = curr_rect.bottom - curr_rect.top;
5412
5413 count_y = vkd3d_compute_workgroup_count(clear_args.extent.height, pipeline.group_size.height);
5415 if (count_y > device_limits->maxComputeWorkGroupCount[1])
5416 FIXME("Group Y count %u exceeds max %u.\n", count_y, device_limits->maxComputeWorkGroupCount[1]);
5417 if (count_z > device_limits->maxComputeWorkGroupCount[2])
5418 FIXME("Group Z count %u exceeds max %u.\n", count_z, device_limits->maxComputeWorkGroupCount[2]);
5419
5420 do
5421 {
5422 clear_args.offset.x = curr_rect.left;
5423 clear_args.extent.width = curr_rect.right - curr_rect.left;
5424
5425 count_x = vkd3d_compute_workgroup_count(clear_args.extent.width, pipeline.group_size.width);
5426 count_x = min(count_x, device_limits->maxComputeWorkGroupCount[0]);
5427
5428 VK_CALL(vkCmdPushConstants(list->vk_command_buffer, pipeline.vk_pipeline_layout,
5429 VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(clear_args), &clear_args));
5430
5431 VK_CALL(vkCmdDispatch(list->vk_command_buffer, count_x, count_y, count_z));
5432
5433 curr_rect.left += count_x * pipeline.group_size.width;
5434 }
5435 while (curr_rect.right > curr_rect.left);
5436 }
5437}
5438
5441{
5442 switch (dxgi_format)
5443 {
5445 colour->uint32[0] = (colour->uint32[0] & 0x7ff)
5446 | ((colour->uint32[1] & 0x7ff) << 11)
5447 | ((colour->uint32[2] & 0x3ff) << 22);
5449
5451 colour->uint32[0] = (colour->uint32[2] & 0x1f)
5452 | ((colour->uint32[1] & 0x3f) << 5)
5453 | ((colour->uint32[0] & 0x1f) << 11);
5455
5457 colour->uint32[0] = (colour->uint32[2] & 0x1f)
5458 | ((colour->uint32[1] & 0x1f) << 5)
5459 | ((colour->uint32[0] & 0x1f) << 10)
5460 | ((colour->uint32[3] & 0x1) << 15);
5462
5464 colour->uint32[0] = (colour->uint32[2] & 0xf)
5465 | ((colour->uint32[1] & 0xf) << 4)
5466 | ((colour->uint32[0] & 0xf) << 8)
5467 | ((colour->uint32[3] & 0xf) << 12);
5469
5470 default:
5471 return NULL;
5472 }
5473}
5474
5476 struct d3d12_resource *resource, VkClearColorValue *colour)
5477{
5478 struct vkd3d_texture_view_desc view_desc;
5479 const struct vkd3d_format *uint_format;
5480 struct vkd3d_view *uint_view;
5481
5482 if (!(uint_format = vkd3d_find_uint_format(device, view->format->dxgi_format))
5483 && !(uint_format = vkd3d_fixup_clear_uav_uint_colour(device, view->format->dxgi_format, colour)))
5484 {
5485 ERR("Unhandled format %#x.\n", view->format->dxgi_format);
5486 return NULL;
5487 }
5488
5490 {
5492 uint_format, view->info.buffer.offset, view->info.buffer.size, &uint_view))
5493 {
5494 ERR("Failed to create buffer view.\n");
5495 return NULL;
5496 }
5497
5498 return uint_view;
5499 }
5500
5501 memset(&view_desc, 0, sizeof(view_desc));
5502 view_desc.view_type = view->info.texture.vk_view_type;
5503 view_desc.format = uint_format;
5504 view_desc.miplevel_idx = view->info.texture.miplevel_idx;
5505 view_desc.miplevel_count = 1;
5506 view_desc.layer_idx = view->info.texture.layer_idx;
5507 view_desc.layer_count = view->info.texture.layer_count;
5510
5512 resource->u.vk_image, &view_desc, &uint_view))
5513 {
5514 ERR("Failed to create image view.\n");
5515 return NULL;
5516 }
5517
5518 return uint_view;
5519}
5520
5523 const UINT values[4], UINT rect_count, const D3D12_RECT *rects)
5524{
5526 struct vkd3d_view *descriptor, *uint_view = NULL;
5527 struct d3d12_device *device = list->device;
5528 const struct vkd3d_resource_view *view;
5529 struct d3d12_resource *resource_impl;
5530 VkClearColorValue colour;
5531
5532 TRACE("iface %p, gpu_handle %s, cpu_handle %s, resource %p, values %p, rect_count %u, rects %p.\n",
5533 iface, debug_gpu_handle(gpu_handle), debug_cpu_handle(cpu_handle), resource, values, rect_count, rects);
5534
5536 if (!(descriptor = d3d12_desc_from_cpu_handle(cpu_handle)->s.u.view))
5537 return;
5538 view = &descriptor->v;
5539 memcpy(colour.uint32, values, sizeof(colour.uint32));
5540
5541 if (view->format->type != VKD3D_FORMAT_TYPE_UINT
5542 && !(descriptor = uint_view = create_uint_view(device, view, resource_impl, &colour)))
5543 {
5544 ERR("Failed to create UINT view.\n");
5545 return;
5546 }
5547
5548 d3d12_command_list_clear_uav(list, resource_impl, descriptor, &colour, rect_count, rects);
5549
5550 if (uint_view)
5551 vkd3d_view_decref(uint_view, device);
5552}
5553
5556 const float values[4], UINT rect_count, const D3D12_RECT *rects)
5557{
5559 struct vkd3d_view *descriptor, *uint_view = NULL;
5560 struct d3d12_device *device = list->device;
5561 const struct vkd3d_resource_view *view;
5562 struct d3d12_resource *resource_impl;
5563 VkClearColorValue colour;
5564
5565 TRACE("iface %p, gpu_handle %s, cpu_handle %s, resource %p, values %p, rect_count %u, rects %p.\n",
5566 iface, debug_gpu_handle(gpu_handle), debug_cpu_handle(cpu_handle), resource, values, rect_count, rects);
5567
5569 if (!(descriptor = d3d12_desc_from_cpu_handle(cpu_handle)->s.u.view))
5570 return;
5571 view = &descriptor->v;
5572 memcpy(colour.float32, values, sizeof(colour.float32));
5573
5574 if (view->format->type == VKD3D_FORMAT_TYPE_SINT
5575 && !(descriptor = uint_view = create_uint_view(device, view, resource_impl, &colour)))
5576 {
5577 ERR("Failed to create UINT view.\n");
5578 return;
5579 }
5580
5581 d3d12_command_list_clear_uav(list, resource_impl, descriptor, &colour, rect_count, rects);
5582
5583 if (uint_view)
5584 vkd3d_view_decref(uint_view, device);
5585}
5586
5589{
5590 FIXME_ONCE("iface %p, resource %p, region %p stub!\n", iface, resource, region);
5591}
5592
5595{
5598 const struct vkd3d_vk_device_procs *vk_procs;
5600
5601 TRACE("iface %p, heap %p, type %#x, index %u.\n", iface, heap, type, index);
5602
5603 vk_procs = &list->device->vk_procs;
5604
5606
5607 VK_CALL(vkCmdResetQueryPool(list->vk_command_buffer, query_heap->vk_query_pool, index, 1));
5608
5611
5613 {
5614 unsigned int stream_index = type - D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0;
5615 VK_CALL(vkCmdBeginQueryIndexedEXT(list->vk_command_buffer,
5616 query_heap->vk_query_pool, index, flags, stream_index));
5617 return;
5618 }
5619
5620 VK_CALL(vkCmdBeginQuery(list->vk_command_buffer, query_heap->vk_query_pool, index, flags));
5621}
5622
5625{
5628 const struct vkd3d_vk_device_procs *vk_procs;
5629
5630 TRACE("iface %p, heap %p, type %#x, index %u.\n", iface, heap, type, index);
5631
5632 vk_procs = &list->device->vk_procs;
5633
5635
5637
5639 {
5640 VK_CALL(vkCmdResetQueryPool(list->vk_command_buffer, query_heap->vk_query_pool, index, 1));
5641 VK_CALL(vkCmdWriteTimestamp(list->vk_command_buffer,
5643 return;
5644 }
5645
5647 {
5648 unsigned int stream_index = type - D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0;
5649 VK_CALL(vkCmdEndQueryIndexedEXT(list->vk_command_buffer,
5650 query_heap->vk_query_pool, index, stream_index));
5651 return;
5652 }
5653
5654 VK_CALL(vkCmdEndQuery(list->vk_command_buffer, query_heap->vk_query_pool, index));
5655}
5656
5658{
5661
5663 return sizeof(D3D12_QUERY_DATA_SO_STATISTICS);
5664
5665 return sizeof(uint64_t);
5666}
5667
5669 ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count,
5670 ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset)
5671{
5672 const struct d3d12_query_heap *query_heap = unsafe_impl_from_ID3D12QueryHeap(heap);
5675 const struct vkd3d_vk_device_procs *vk_procs;
5676 unsigned int i, first, count;
5678
5679 TRACE("iface %p, heap %p, type %#x, start_index %u, query_count %u, "
5680 "dst_buffer %p, aligned_dst_buffer_offset %#"PRIx64".\n",
5681 iface, heap, type, start_index, query_count,
5682 dst_buffer, aligned_dst_buffer_offset);
5683
5684 vk_procs = &list->device->vk_procs;
5685
5686 /* Vulkan is less strict than D3D12 here. Vulkan implementations are free
5687 * to return any non-zero result for binary occlusion with at least one
5688 * sample passing, while D3D12 guarantees that the result is 1 then.
5689 *
5690 * For example, the Nvidia binary blob drivers on Linux seem to always
5691 * count precisely, even when it was signalled that non-precise is enough.
5692 */
5694 FIXME_ONCE("D3D12 guarantees binary occlusion queries result in only 0 and 1.\n");
5695
5697 {
5698 WARN("Destination resource is not a buffer.\n");
5699 return;
5700 }
5701
5703
5705
5706 count = 0;
5707 first = start_index;
5708 offset = aligned_dst_buffer_offset;
5709 for (i = 0; i < query_count; ++i)
5710 {
5711 if (d3d12_query_heap_is_result_available(query_heap, start_index + i))
5712 {
5713 ++count;
5714 }
5715 else
5716 {
5717 if (count)
5718 {
5719 VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
5720 query_heap->vk_query_pool, first, count, buffer->u.vk_buffer,
5722 }
5723 count = 0;
5724 first = start_index + i;
5725 offset = aligned_dst_buffer_offset + i * stride;
5726
5727 /* We cannot copy query results if a query was not issued:
5728 *
5729 * "If the query does not become available in a finite amount of
5730 * time (e.g. due to not issuing a query since the last reset),
5731 * a VK_ERROR_DEVICE_LOST error may occur."
5732 */
5733 VK_CALL(vkCmdFillBuffer(list->vk_command_buffer,
5734 buffer->u.vk_buffer, offset, stride, 0x00000000));
5735
5736 ++first;
5737 offset += stride;
5738 }
5739 }
5740
5741 if (count)
5742 {
5743 VK_CALL(vkCmdCopyQueryPoolResults(list->vk_command_buffer,
5744 query_heap->vk_query_pool, first, count, buffer->u.vk_buffer,
5746 }
5747}
5748
5751{
5754 const struct vkd3d_vulkan_info *vk_info = &list->device->vk_info;
5755 const struct vkd3d_vk_device_procs *vk_procs;
5756
5757 TRACE("iface %p, buffer %p, aligned_buffer_offset %#"PRIx64", operation %#x.\n",
5758 iface, buffer, aligned_buffer_offset, operation);
5759
5760 if (!vk_info->EXT_conditional_rendering)
5761 {
5762 FIXME("Vulkan conditional rendering extension not present. Conditional rendering not supported.\n");
5763 return;
5764 }
5765
5766 vk_procs = &list->device->vk_procs;
5767
5768 /* FIXME: Add support for conditional rendering in render passes. */
5770
5771 if (resource)
5772 {
5774
5775 if (aligned_buffer_offset & (sizeof(uint64_t) - 1))
5776 {
5777 WARN("Unaligned predicate argument buffer offset %#"PRIx64".\n", aligned_buffer_offset);
5778 return;
5779 }
5780
5782 {
5783 WARN("Predicate arguments must be stored in a buffer resource.\n");
5784 return;
5785 }
5786
5787 FIXME_ONCE("Predication doesn't support clear and copy commands, "
5788 "and predication values are treated as 32-bit values.\n");
5789
5791 cond_info.pNext = NULL;
5792 cond_info.buffer = resource->u.vk_buffer;
5793 cond_info.offset = aligned_buffer_offset;
5794 switch (operation)
5795 {
5797 cond_info.flags = 0;
5798 break;
5799
5802 break;
5803
5804 default:
5805 FIXME("Unhandled predication operation %#x.\n", operation);
5806 return;
5807 }
5808
5809 if (list->is_predicated)
5810 VK_CALL(vkCmdEndConditionalRenderingEXT(list->vk_command_buffer));
5811 VK_CALL(vkCmdBeginConditionalRenderingEXT(list->vk_command_buffer, &cond_info));
5812 list->is_predicated = true;
5813 }
5814 else if (list->is_predicated)
5815 {
5816 VK_CALL(vkCmdEndConditionalRenderingEXT(list->vk_command_buffer));
5817 list->is_predicated = false;
5818 }
5819}
5820
5822 UINT metadata, const void *data, UINT size)
5823{
5824 FIXME("iface %p, metadata %#x, data %p, size %u stub!\n", iface, metadata, data, size);
5825}
5826
5828 UINT metadata, const void *data, UINT size)
5829{
5830 FIXME("iface %p, metadata %#x, data %p, size %u stub!\n", iface, metadata, data, size);
5831}
5832
5834{
5835 FIXME("iface %p stub!\n", iface);
5836}
5837
5841
5843 ID3D12CommandSignature *command_signature, UINT max_command_count, ID3D12Resource *arg_buffer,
5844 UINT64 arg_buffer_offset, ID3D12Resource *count_buffer, UINT64 count_buffer_offset)
5845{
5846 struct d3d12_command_signature *sig_impl = unsafe_impl_from_ID3D12CommandSignature(command_signature);
5847 struct d3d12_resource *count_impl = unsafe_impl_from_ID3D12Resource(count_buffer);
5848 struct d3d12_resource *arg_impl = unsafe_impl_from_ID3D12Resource(arg_buffer);
5850 const D3D12_COMMAND_SIGNATURE_DESC *signature_desc;
5851 const struct vkd3d_vk_device_procs *vk_procs;
5852 unsigned int i;
5853
5854 TRACE("iface %p, command_signature %p, max_command_count %u, arg_buffer %p, "
5855 "arg_buffer_offset %#"PRIx64", count_buffer %p, count_buffer_offset %#"PRIx64".\n",
5856 iface, command_signature, max_command_count, arg_buffer, arg_buffer_offset,
5857 count_buffer, count_buffer_offset);
5858
5859 vk_procs = &list->device->vk_procs;
5860
5861 if (count_buffer && !list->device->vk_info.KHR_draw_indirect_count)
5862 {
5863 FIXME("Count buffers not supported by Vulkan implementation.\n");
5864 return;
5865 }
5866
5868
5869 signature_desc = &sig_impl->desc;
5870 for (i = 0; i < signature_desc->NumArgumentDescs; ++i)
5871 {
5872 const D3D12_INDIRECT_ARGUMENT_DESC *arg_desc = &signature_desc->pArgumentDescs[i];
5873
5874 switch (arg_desc->Type)
5875 {
5878 {
5879 WARN("Failed to begin render pass, ignoring draw.\n");
5880 break;
5881 }
5882
5883 if (count_buffer)
5884 {
5885 VK_CALL(vkCmdDrawIndirectCountKHR(list->vk_command_buffer, arg_impl->u.vk_buffer,
5886 arg_buffer_offset, count_impl->u.vk_buffer, count_buffer_offset,
5887 max_command_count, signature_desc->ByteStride));
5888 }
5889 else
5890 {
5891 VK_CALL(vkCmdDrawIndirect(list->vk_command_buffer, arg_impl->u.vk_buffer,
5892 arg_buffer_offset, max_command_count, signature_desc->ByteStride));
5893 }
5894 break;
5895
5898 {
5899 WARN("Failed to begin render pass, ignoring draw.\n");
5900 break;
5901 }
5902
5904
5905 if (count_buffer)
5906 {
5907 VK_CALL(vkCmdDrawIndexedIndirectCountKHR(list->vk_command_buffer, arg_impl->u.vk_buffer,
5908 arg_buffer_offset, count_impl->u.vk_buffer, count_buffer_offset,
5909 max_command_count, signature_desc->ByteStride));
5910 }
5911 else
5912 {
5913 VK_CALL(vkCmdDrawIndexedIndirect(list->vk_command_buffer, arg_impl->u.vk_buffer,
5914 arg_buffer_offset, max_command_count, signature_desc->ByteStride));
5915 }
5916 break;
5917
5919 if (max_command_count != 1)
5920 FIXME("Ignoring command count %u.\n", max_command_count);
5921
5922 if (count_buffer)
5923 {
5924 FIXME("Count buffers not supported for indirect dispatch.\n");
5925 break;
5926 }
5927
5929 {
5930 WARN("Failed to update compute state, ignoring dispatch.\n");
5932 return;
5933 }
5934
5935 VK_CALL(vkCmdDispatchIndirect(list->vk_command_buffer,
5936 arg_impl->u.vk_buffer, arg_buffer_offset));
5937 break;
5938
5939 default:
5940 FIXME("Ignoring unhandled argument type %#x.\n", arg_desc->Type);
5941 break;
5942 }
5943 }
5944
5946}
5947
5949 ID3D12Resource *dst_buffer, UINT64 dst_offset,
5950 ID3D12Resource *src_buffer, UINT64 src_offset,
5951 UINT dependent_resource_count, ID3D12Resource * const *dependent_resources,
5952 const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges)
5953{
5954 FIXME("iface %p, dst_resource %p, dst_offset %#"PRIx64", src_resource %p, "
5955 "src_offset %#"PRIx64", dependent_resource_count %u, "
5956 "dependent_resources %p, dependent_sub_resource_ranges %p stub!\n",
5957 iface, dst_buffer, dst_offset, src_buffer, src_offset,
5958 dependent_resource_count, dependent_resources, dependent_sub_resource_ranges);
5959}
5960
5962 ID3D12Resource *dst_buffer, UINT64 dst_offset,
5963 ID3D12Resource *src_buffer, UINT64 src_offset,
5964 UINT dependent_resource_count, ID3D12Resource * const *dependent_resources,
5965 const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges)
5966{
5967 FIXME("iface %p, dst_resource %p, dst_offset %#"PRIx64", src_resource %p, "
5968 "src_offset %#"PRIx64", dependent_resource_count %u, "
5969 "dependent_resources %p, dependent_sub_resource_ranges %p stub!\n",
5970 iface, dst_buffer, dst_offset, src_buffer, src_offset,
5971 dependent_resource_count, dependent_resources, dependent_sub_resource_ranges);
5972}
5973
5975 FLOAT min, FLOAT max)
5976{
5978 const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
5979
5980 TRACE("iface %p, min %.8e, max %.8e.\n", iface, min, max);
5981
5982 if (isnan(max))
5983 max = 0.0f;
5984 if (isnan(min))
5985 min = 0.0f;
5986
5987 if (!list->device->vk_info.EXT_depth_range_unrestricted && (min < 0.0f || min > 1.0f || max < 0.0f || max > 1.0f))
5988 {
5989 WARN("VK_EXT_depth_range_unrestricted was not found, clamping depth bounds to 0.0 and 1.0.\n");
5990 max = vkd3d_clamp(max, 0.0f, 1.0f);
5991 min = vkd3d_clamp(min, 0.0f, 1.0f);
5992 }
5993
5994 list->has_depth_bounds = true;
5995 VK_CALL(vkCmdSetDepthBounds(list->vk_command_buffer, min, max));
5996}
5997
5999 UINT sample_count, UINT pixel_count, D3D12_SAMPLE_POSITION *sample_positions)
6000{
6001 FIXME("iface %p, sample_count %u, pixel_count %u, sample_positions %p stub!\n",
6002 iface, sample_count, pixel_count, sample_positions);
6003}
6004
6006 ID3D12Resource *dst_resource, UINT dst_sub_resource_idx, UINT dst_x, UINT dst_y,
6007 ID3D12Resource *src_resource, UINT src_sub_resource_idx,
6009{
6010 FIXME("iface %p, dst_resource %p, dst_sub_resource_idx %u, "
6011 "dst_x %u, dst_y %u, src_resource %p, src_sub_resource_idx %u, "
6012 "src_rect %p, format %#x, mode %#x stub!\n",
6013 iface, dst_resource, dst_sub_resource_idx, dst_x, dst_y,
6014 src_resource, src_sub_resource_idx, src_rect, format, mode);
6015}
6016
6018{
6019 FIXME("iface %p, mask %#x stub!\n", iface, mask);
6020}
6021
6025{
6027 struct d3d12_resource *resource;
6028 unsigned int i;
6029
6030 FIXME("iface %p, count %u, parameters %p, modes %p stub!\n", iface, count, parameters, modes);
6031
6032 for (i = 0; i < count; ++i)
6033 {
6034 resource = vkd3d_gpu_va_allocator_dereference(&list->device->gpu_va_allocator, parameters[i].Dest);
6036 }
6037}
6038
6040 ID3D12ProtectedResourceSession *protected_session)
6041{
6042 FIXME("iface %p, protected_session %p stub!\n", iface, protected_session);
6043}
6044
6046 UINT count, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *render_targets,
6048{
6049 FIXME("iface %p, count %u, render_targets %p, depth_stencil %p, flags %#x stub!\n", iface,
6050 count, render_targets, depth_stencil, flags);
6051}
6052
6054{
6055 FIXME("iface %p stub!\n", iface);
6056}
6057
6059 ID3D12MetaCommand *meta_command, const void *parameters_data, SIZE_T data_size_in_bytes)
6060{
6061 FIXME("iface %p, meta_command %p, parameters_data %p, data_size_in_bytes %"PRIuPTR" stub!\n", iface,
6062 meta_command, parameters_data, (uintptr_t)data_size_in_bytes);
6063}
6064
6066 ID3D12MetaCommand *meta_command, const void *parameters_data, SIZE_T data_size_in_bytes)
6067{
6068 FIXME("iface %p, meta_command %p, parameters_data %p, data_size_in_bytes %"PRIuPTR" stub!\n", iface,
6069 meta_command, parameters_data, (uintptr_t)data_size_in_bytes);
6070}
6071
6075{
6076 FIXME("iface %p, desc %p, count %u, postbuild_info_descs %p stub!\n", iface, desc, count, postbuild_info_descs);
6077}
6078
6081 UINT structures_count, const D3D12_GPU_VIRTUAL_ADDRESS *src_structure_data)
6082{
6083 FIXME("iface %p, desc %p, structures_count %u, src_structure_data %p stub!\n",
6084 iface, desc, structures_count, src_structure_data);
6085}
6086
6088 D3D12_GPU_VIRTUAL_ADDRESS dst_structure_data, D3D12_GPU_VIRTUAL_ADDRESS src_structure_data,
6090{
6091 FIXME("iface %p, dst_structure_data %#"PRIx64", src_structure_data %#"PRIx64", mode %u stub!\n",
6092 iface, dst_structure_data, src_structure_data, mode);
6093}
6094
6096 ID3D12StateObject *state_object)
6097{
6098 FIXME("iface %p, state_object %p stub!\n", iface, state_object);
6099}
6100
6103{
6104 FIXME("iface %p, desc %p stub!\n", iface, desc);
6105}
6106
6109{
6110 FIXME("iface %p, rate %#x, combiners %p stub!\n", iface, rate, combiners);
6111}
6112
6114 ID3D12Resource *rate_image)
6115{
6116 FIXME("iface %p, rate_image %p stub!\n", iface, rate_image);
6117}
6118
6120{
6121 FIXME("iface %p, x %u, y %u, z %u stub!\n", iface, x, y, z);
6122}
6123
6124static const struct ID3D12GraphicsCommandList6Vtbl d3d12_command_list_vtbl =
6125{
6126 /* IUnknown methods */
6130 /* ID3D12Object methods */
6135 /* ID3D12DeviceChild methods */
6137 /* ID3D12CommandList methods */
6139 /* ID3D12GraphicsCommandList methods */
6191 /* ID3D12GraphicsCommandList1 methods */
6198 /* ID3D12GraphicsCommandList2 methods */
6200 /* ID3D12GraphicsCommandList3 methods */
6202 /* ID3D12GraphicsCommandList4 methods */
6212 /* ID3D12GraphicsCommandList5 methods */
6215 /* ID3D12GraphicsCommandList6 methods */
6217};
6218
6219static struct d3d12_command_list *unsafe_impl_from_ID3D12CommandList(ID3D12CommandList *iface)
6220{
6221 if (!iface)
6222 return NULL;
6223 VKD3D_ASSERT(iface->lpVtbl == (struct ID3D12CommandListVtbl *)&d3d12_command_list_vtbl);
6225}
6226
6229 ID3D12PipelineState *initial_pipeline_state)
6230{
6231 HRESULT hr;
6232
6233 list->ID3D12GraphicsCommandList6_iface.lpVtbl = &d3d12_command_list_vtbl;
6234 list->refcount = 1;
6235
6236 list->type = type;
6237
6238 if (FAILED(hr = vkd3d_private_store_init(&list->private_store)))
6239 return hr;
6240
6241 d3d12_device_add_ref(list->device = device);
6242
6243 list->allocator = allocator;
6244
6245 list->descriptor_heap_count = 0;
6246
6248 {
6249 list->pipeline_bindings[VKD3D_PIPELINE_BIND_POINT_GRAPHICS].vk_uav_counter_views = NULL;
6250 list->pipeline_bindings[VKD3D_PIPELINE_BIND_POINT_COMPUTE].vk_uav_counter_views = NULL;
6251 d3d12_command_list_reset_state(list, initial_pipeline_state);
6252 }
6253 else
6254 {
6255 vkd3d_private_store_destroy(&list->private_store);
6257 }
6258
6259 return hr;
6260}
6261
6263 UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface,
6264 ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list)
6265{
6267 struct d3d12_command_list *object;
6268 HRESULT hr;
6269
6270 if (!(allocator = unsafe_impl_from_ID3D12CommandAllocator(allocator_iface)))
6271 {
6272 WARN("Command allocator is NULL.\n");
6273 return E_INVALIDARG;
6274 }
6275
6276 if (allocator->type != type)
6277 {
6278 WARN("Command list types do not match (allocator %#x, list %#x).\n",
6279 allocator->type, type);
6280 return E_INVALIDARG;
6281 }
6282
6283 debug_ignored_node_mask(node_mask);
6284
6285 if (!(object = vkd3d_malloc(sizeof(*object))))
6286 return E_OUTOFMEMORY;
6287
6288 if (FAILED(hr = d3d12_command_list_init(object, device, type, allocator, initial_pipeline_state)))
6289 {
6290 vkd3d_free(object);
6291 return hr;
6292 }
6293
6294 TRACE("Created command list %p.\n", object);
6295
6296 *list = object;
6297
6298 return S_OK;
6299}
6300
6301/* ID3D12CommandQueue */
6302static inline struct d3d12_command_queue *impl_from_ID3D12CommandQueue(ID3D12CommandQueue *iface)
6303{
6305}
6306
6308 REFIID riid, void **object)
6309{
6310 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
6311
6312 if (IsEqualGUID(riid, &IID_ID3D12CommandQueue)
6313 || IsEqualGUID(riid, &IID_ID3D12Pageable)
6314 || IsEqualGUID(riid, &IID_ID3D12DeviceChild)
6315 || IsEqualGUID(riid, &IID_ID3D12Object)
6317 {
6318 ID3D12CommandQueue_AddRef(iface);
6319 *object = iface;
6320 return S_OK;
6321 }
6322
6323 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
6324
6325 *object = NULL;
6326 return E_NOINTERFACE;
6327}
6328
6329static ULONG STDMETHODCALLTYPE d3d12_command_queue_AddRef(ID3D12CommandQueue *iface)
6330{
6331 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6332 unsigned int refcount = vkd3d_atomic_increment_u32(&command_queue->refcount);
6333
6334 TRACE("%p increasing refcount to %u.\n", command_queue, refcount);
6335
6336 return refcount;
6337}
6338
6340{
6341 switch (op->opcode)
6342 {
6343 case VKD3D_CS_OP_WAIT:
6344 d3d12_fence_decref(op->u.wait.fence);
6345 break;
6346
6347 case VKD3D_CS_OP_SIGNAL:
6348 d3d12_fence_decref(op->u.signal.fence);
6349 break;
6350
6352 vkd3d_free(op->u.execute.buffers);
6353 break;
6354
6357 break;
6358 }
6359}
6360
6362{
6363 unsigned int i;
6364
6365 for (i = 0; i < array->count; ++i)
6367
6368 vkd3d_free(array->ops);
6369}
6370
6371static ULONG STDMETHODCALLTYPE d3d12_command_queue_Release(ID3D12CommandQueue *iface)
6372{
6373 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6374 unsigned int refcount = vkd3d_atomic_decrement_u32(&command_queue->refcount);
6375
6376 TRACE("%p decreasing refcount to %u.\n", command_queue, refcount);
6377
6378 if (!refcount)
6379 {
6380 struct d3d12_device *device = command_queue->device;
6381
6383
6384 vkd3d_mutex_destroy(&command_queue->op_mutex);
6387
6389
6390 vkd3d_free(command_queue);
6391
6393 }
6394
6395 return refcount;
6396}
6397
6399 REFGUID guid, UINT *data_size, void *data)
6400{
6401 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6402
6403 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
6404
6405 return vkd3d_get_private_data(&command_queue->private_store, guid, data_size, data);
6406}
6407
6409 REFGUID guid, UINT data_size, const void *data)
6410{
6411 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6412
6413 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
6414
6415 return vkd3d_set_private_data(&command_queue->private_store, guid, data_size, data);
6416}
6417
6419 REFGUID guid, const IUnknown *data)
6420{
6421 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6422
6423 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
6424
6425 return vkd3d_set_private_data_interface(&command_queue->private_store, guid, data);
6426}
6427
6428static HRESULT STDMETHODCALLTYPE d3d12_command_queue_SetName(ID3D12CommandQueue *iface, const WCHAR *name)
6429{
6430 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6431 VkQueue vk_queue;
6432 HRESULT hr;
6433
6434 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, command_queue->device->wchar_size));
6435
6436 if (!(vk_queue = vkd3d_queue_acquire(command_queue->vkd3d_queue)))
6437 {
6438 ERR("Failed to acquire queue %p.\n", command_queue->vkd3d_queue);
6439 return E_FAIL;
6440 }
6441
6442 hr = vkd3d_set_vk_object_name(command_queue->device, (uint64_t)(uintptr_t)vk_queue,
6444 vkd3d_queue_release(command_queue->vkd3d_queue);
6445 return hr;
6446}
6447
6448static HRESULT STDMETHODCALLTYPE d3d12_command_queue_GetDevice(ID3D12CommandQueue *iface, REFIID iid, void **device)
6449{
6450 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6451
6452 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
6453
6454 return d3d12_device_query_interface(command_queue->device, iid, device);
6455}
6456
6458{
6459 if (!vkd3d_array_reserve((void **)&array->ops, &array->size, array->count + 1, sizeof(*array->ops)))
6460 return NULL;
6461
6462 return &array->ops[array->count++];
6463}
6464
6465static bool clone_array_parameter(void **dst, const void *src, size_t elem_size, unsigned int count)
6466{
6467 void *buffer;
6468
6469 *dst = NULL;
6470 if (src)
6471 {
6472 if (!(buffer = vkd3d_calloc(count, elem_size)))
6473 return false;
6474 memcpy(buffer, src, count * elem_size);
6475 *dst = buffer;
6476 }
6477 return true;
6478}
6479
6481{
6482 vkd3d_free(update_mappings->region_start_coordinates);
6483 vkd3d_free(update_mappings->region_sizes);
6484 vkd3d_free(update_mappings->range_flags);
6485 vkd3d_free(update_mappings->heap_range_offsets);
6486 vkd3d_free(update_mappings->range_tile_counts);
6487}
6488
6489static void STDMETHODCALLTYPE d3d12_command_queue_UpdateTileMappings(ID3D12CommandQueue *iface,
6490 ID3D12Resource *resource, UINT region_count,
6491 const D3D12_TILED_RESOURCE_COORDINATE *region_start_coordinates, const D3D12_TILE_REGION_SIZE *region_sizes,
6492 ID3D12Heap *heap, UINT range_count, const D3D12_TILE_RANGE_FLAGS *range_flags,
6493 const UINT *heap_range_offsets, const UINT *range_tile_counts, D3D12_TILE_MAPPING_FLAGS flags)
6494{
6496 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6497 struct d3d12_heap *heap_impl = unsafe_impl_from_ID3D12Heap(heap);
6498 struct vkd3d_cs_update_mappings update_mappings = {0};
6499 struct vkd3d_cs_op_data *op;
6500
6501 TRACE("iface %p, resource %p, region_count %u, region_start_coordinates %p, "
6502 "region_sizes %p, heap %p, range_count %u, range_flags %p, heap_range_offsets %p, "
6503 "range_tile_counts %p, flags %#x.\n",
6504 iface, resource, region_count, region_start_coordinates, region_sizes, heap, range_count,
6505 range_flags, heap_range_offsets, range_tile_counts, flags);
6506
6507 if (!region_count || !range_count)
6508 return;
6509
6510 if (!command_queue->supports_sparse_binding)
6511 {
6512 FIXME("Command queue %p does not support sparse binding.\n", command_queue);
6513 return;
6514 }
6515
6516 if (!resource_impl->tiles.subresource_count)
6517 {
6518 WARN("Resource %p is not a tiled resource.\n", resource_impl);
6519 return;
6520 }
6521
6522 if (region_count > 1 && !region_start_coordinates)
6523 {
6524 WARN("Region start coordinates must not be NULL when region count is > 1.\n");
6525 return;
6526 }
6527
6528 if (range_count > 1 && !range_tile_counts)
6529 {
6530 WARN("Range tile counts must not be NULL when range count is > 1.\n");
6531 return;
6532 }
6533
6534 update_mappings.resource = resource_impl;
6535 update_mappings.heap = heap_impl;
6536 if (!clone_array_parameter((void **)&update_mappings.region_start_coordinates,
6537 region_start_coordinates, sizeof(*region_start_coordinates), region_count))
6538 {
6539 ERR("Failed to allocate region start coordinates.\n");
6540 return;
6541 }
6542 if (!clone_array_parameter((void **)&update_mappings.region_sizes,
6543 region_sizes, sizeof(*region_sizes), region_count))
6544 {
6545 ERR("Failed to allocate region sizes.\n");
6546 goto free_clones;
6547 }
6548 if (!clone_array_parameter((void **)&update_mappings.range_flags,
6549 range_flags, sizeof(*range_flags), range_count))
6550 {
6551 ERR("Failed to allocate range flags.\n");
6552 goto free_clones;
6553 }
6554 if (!clone_array_parameter((void **)&update_mappings.heap_range_offsets,
6555 heap_range_offsets, sizeof(*heap_range_offsets), range_count))
6556 {
6557 ERR("Failed to allocate heap range offsets.\n");
6558 goto free_clones;
6559 }
6560 if (!clone_array_parameter((void **)&update_mappings.range_tile_counts,
6561 range_tile_counts, sizeof(*range_tile_counts), range_count))
6562 {
6563 ERR("Failed to allocate range tile counts.\n");
6564 goto free_clones;
6565 }
6566 update_mappings.region_count = region_count;
6567 update_mappings.range_count = range_count;
6568 update_mappings.flags = flags;
6569
6570 vkd3d_mutex_lock(&command_queue->op_mutex);
6571
6572 if (!(op = d3d12_command_queue_op_array_require_space(&command_queue->op_queue)))
6573 {
6574 ERR("Failed to add op.\n");
6575 goto unlock_mutex;
6576 }
6577
6579 op->u.update_mappings = update_mappings;
6580
6581 d3d12_command_queue_submit_locked(command_queue);
6582
6583 vkd3d_mutex_unlock(&command_queue->op_mutex);
6584 return;
6585
6586unlock_mutex:
6587 vkd3d_mutex_unlock(&command_queue->op_mutex);
6588free_clones:
6590}
6591
6592static void STDMETHODCALLTYPE d3d12_command_queue_CopyTileMappings(ID3D12CommandQueue *iface,
6593 ID3D12Resource *dst_resource,
6594 const D3D12_TILED_RESOURCE_COORDINATE *dst_region_start_coordinate,
6595 ID3D12Resource *src_resource,
6596 const D3D12_TILED_RESOURCE_COORDINATE *src_region_start_coordinate,
6597 const D3D12_TILE_REGION_SIZE *region_size,
6599{
6600 struct d3d12_resource *dst_resource_impl = impl_from_ID3D12Resource(dst_resource);
6601 struct d3d12_resource *src_resource_impl = impl_from_ID3D12Resource(src_resource);
6602 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6603 struct vkd3d_cs_op_data *op;
6604
6605 TRACE("iface %p, dst_resource %p, dst_region_start_coordinate %p, "
6606 "src_resource %p, src_region_start_coordinate %p, region_size %p, flags %#x.\n",
6607 iface, dst_resource, dst_region_start_coordinate, src_resource,
6608 src_region_start_coordinate, region_size, flags);
6609
6610 vkd3d_mutex_lock(&command_queue->op_mutex);
6611
6612 if (!(op = d3d12_command_queue_op_array_require_space(&command_queue->op_queue)))
6613 {
6614 ERR("Failed to add op.\n");
6615 goto unlock_mutex;
6616 }
6617 op->opcode = VKD3D_CS_OP_COPY_MAPPINGS;
6618 op->u.copy_mappings.dst_resource = dst_resource_impl;
6619 op->u.copy_mappings.src_resource = src_resource_impl;
6620 op->u.copy_mappings.dst_region_start_coordinate = *dst_region_start_coordinate;
6621 op->u.copy_mappings.src_region_start_coordinate = *src_region_start_coordinate;
6622 op->u.copy_mappings.region_size = *region_size;
6623 op->u.copy_mappings.flags = flags;
6624
6625 d3d12_command_queue_submit_locked(command_queue);
6626
6627unlock_mutex:
6628 vkd3d_mutex_unlock(&command_queue->op_mutex);
6629}
6630
6631static void d3d12_command_queue_execute(struct d3d12_command_queue *command_queue,
6632 VkCommandBuffer *buffers, unsigned int count)
6633{
6634 const struct vkd3d_vk_device_procs *vk_procs = &command_queue->device->vk_procs;
6635 struct vkd3d_queue *vkd3d_queue = command_queue->vkd3d_queue;
6636 VkSubmitInfo submit_desc;
6637 VkQueue vk_queue;
6638 VkResult vr;
6639
6640 memset(&submit_desc, 0, sizeof(submit_desc));
6641
6643 {
6644 ERR("Failed to acquire queue %p.\n", vkd3d_queue);
6645 return;
6646 }
6647
6649 submit_desc.commandBufferCount = count;
6650 submit_desc.pCommandBuffers = buffers;
6651
6652 if ((vr = VK_CALL(vkQueueSubmit(vk_queue, 1, &submit_desc, VK_NULL_HANDLE))) < 0)
6653 ERR("Failed to submit queue(s), vr %d.\n", vr);
6654
6656}
6657
6659{
6660 bool flushed_any = false;
6661 HRESULT hr;
6662
6663 if (queue->op_queue.count == 1 && !queue->is_flushing)
6664 {
6666 ERR("Failed to flush queue, hr %s.\n", debugstr_hresult(hr));
6667 }
6668}
6669
6671 UINT command_list_count, ID3D12CommandList * const *command_lists)
6672{
6673 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6674 struct d3d12_command_list *cmd_list;
6675 struct vkd3d_cs_op_data *op;
6676 VkCommandBuffer *buffers;
6677 unsigned int i;
6678
6679 TRACE("iface %p, command_list_count %u, command_lists %p.\n",
6680 iface, command_list_count, command_lists);
6681
6682 if (!command_list_count)
6683 return;
6684
6685 if (!(buffers = vkd3d_calloc(command_list_count, sizeof(*buffers))))
6686 {
6687 ERR("Failed to allocate command buffer array.\n");
6688 return;
6689 }
6690
6691 for (i = 0; i < command_list_count; ++i)
6692 {
6693 cmd_list = unsafe_impl_from_ID3D12CommandList(command_lists[i]);
6694
6695 if (cmd_list->is_recording)
6696 {
6698 "Command list %p is in recording state.", command_lists[i]);
6700 return;
6701 }
6702
6704
6705 buffers[i] = cmd_list->vk_command_buffer;
6706 }
6707
6708 vkd3d_mutex_lock(&command_queue->op_mutex);
6709
6710 if (!(op = d3d12_command_queue_op_array_require_space(&command_queue->op_queue)))
6711 {
6712 ERR("Failed to add op.\n");
6713 goto done;
6714 }
6715 op->opcode = VKD3D_CS_OP_EXECUTE;
6716 op->u.execute.buffers = buffers;
6717 op->u.execute.buffer_count = command_list_count;
6718
6719 d3d12_command_queue_submit_locked(command_queue);
6720
6721done:
6722 vkd3d_mutex_unlock(&command_queue->op_mutex);
6723 return;
6724}
6725
6726static void STDMETHODCALLTYPE d3d12_command_queue_SetMarker(ID3D12CommandQueue *iface,
6727 UINT metadata, const void *data, UINT size)
6728{
6729 FIXME("iface %p, metadata %#x, data %p, size %u stub!\n",
6730 iface, metadata, data, size);
6731}
6732
6733static void STDMETHODCALLTYPE d3d12_command_queue_BeginEvent(ID3D12CommandQueue *iface,
6734 UINT metadata, const void *data, UINT size)
6735{
6736 FIXME("iface %p, metadata %#x, data %p, size %u stub!\n",
6737 iface, metadata, data, size);
6738}
6739
6740static void STDMETHODCALLTYPE d3d12_command_queue_EndEvent(ID3D12CommandQueue *iface)
6741{
6742 FIXME("iface %p stub!\n", iface);
6743}
6744
6745static HRESULT vkd3d_enqueue_timeline_semaphore(struct vkd3d_fence_worker *worker, VkSemaphore vk_semaphore,
6746 struct d3d12_fence *fence, uint64_t value, struct vkd3d_queue *queue)
6747{
6748 struct vkd3d_waiting_fence *waiting_fence;
6749
6750 TRACE("worker %p, fence %p, value %#"PRIx64".\n", worker, fence, value);
6751
6752 vkd3d_mutex_lock(&worker->mutex);
6753
6754 if (!vkd3d_array_reserve((void **)&worker->fences, &worker->fences_size,
6755 worker->fence_count + 1, sizeof(*worker->fences)))
6756 {
6757 ERR("Failed to add GPU timeline semaphore.\n");
6758 vkd3d_mutex_unlock(&worker->mutex);
6759 return E_OUTOFMEMORY;
6760 }
6761
6762 waiting_fence = &worker->fences[worker->fence_count++];
6763 waiting_fence->fence = fence;
6764 waiting_fence->value = value;
6765 waiting_fence->u.vk_semaphore = vk_semaphore;
6766
6768
6769 vkd3d_cond_signal(&worker->cond);
6770 vkd3d_mutex_unlock(&worker->mutex);
6771
6772 return S_OK;
6773}
6774
6776 ID3D12Fence *fence_iface, UINT64 value)
6777{
6778 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
6779 struct d3d12_fence *fence = unsafe_impl_from_ID3D12Fence(fence_iface);
6780 struct vkd3d_cs_op_data *op;
6781 HRESULT hr = S_OK;
6782
6783 TRACE("iface %p, fence %p, value %#"PRIx64".\n", iface, fence_iface, value);
6784
6785 vkd3d_mutex_lock(&command_queue->op_mutex);
6786
6787 if (!(op = d3d12_command_queue_op_array_require_space(&command_queue->op_queue)))
6788 {
6789 ERR("Failed to add op.\n");
6790 hr = E_OUTOFMEMORY;
6791 goto done;
6792 }
6793 op->opcode = VKD3D_CS_OP_SIGNAL;
6794 op->u.signal.fence = fence;
6795 op->u.signal.value = value;
6796
6797 d3d12_fence_incref(fence);
6798
6799 d3d12_command_queue_submit_locked(command_queue);
6800
6801done:
6802 vkd3d_mutex_unlock(&command_queue->op_mutex);
6803 return hr;
6804}
6805
6807 struct d3d12_fence *fence, uint64_t value)
6808{
6809 VkTimelineSemaphoreSubmitInfoKHR timeline_submit_info;
6810 const struct vkd3d_vk_device_procs *vk_procs;
6811 VkSemaphore vk_semaphore = VK_NULL_HANDLE;
6812 VkFence vk_fence = VK_NULL_HANDLE;
6813 struct vkd3d_queue *vkd3d_queue;
6815 uint64_t timeline_value = 0;
6816 struct d3d12_device *device;
6817 VkSubmitInfo submit_info;
6818 VkQueue vk_queue;
6819 VkResult vr;
6820 HRESULT hr;
6821
6822 device = command_queue->device;
6823 vk_procs = &device->vk_procs;
6824 vkd3d_queue = command_queue->vkd3d_queue;
6825
6826 if (device->vk_info.KHR_timeline_semaphore)
6827 {
6828 if (!(timeline_value = d3d12_fence_add_pending_timeline_signal(fence, value, vkd3d_queue)))
6829 {
6830 ERR("Failed to add pending signal.\n");
6831 return E_OUTOFMEMORY;
6832 }
6833
6834 vk_semaphore = fence->timeline_semaphore;
6835 VKD3D_ASSERT(vk_semaphore);
6836 }
6837 else
6838 {
6839 if ((vr = d3d12_fence_create_vk_fence(fence, &vk_fence)) < 0)
6840 {
6841 WARN("Failed to create Vulkan fence, vr %d.\n", vr);
6842 goto fail_vkresult;
6843 }
6844 }
6845
6846 if (!(vk_queue = vkd3d_queue_acquire(vkd3d_queue)))
6847 {
6848 ERR("Failed to acquire queue %p.\n", vkd3d_queue);
6849 hr = E_FAIL;
6850 goto fail;
6851 }
6852
6853 if (!device->vk_info.KHR_timeline_semaphore && (vr = vkd3d_queue_create_vk_semaphore_locked(vkd3d_queue,
6854 device, &vk_semaphore)) < 0)
6855 {
6856 ERR("Failed to create Vulkan semaphore, vr %d.\n", vr);
6857 vk_semaphore = VK_NULL_HANDLE;
6858 }
6859
6861 submit_info.pNext = NULL;
6862 submit_info.waitSemaphoreCount = 0;
6863 submit_info.pWaitSemaphores = NULL;
6864 submit_info.pWaitDstStageMask = NULL;
6865 submit_info.commandBufferCount = 0;
6866 submit_info.pCommandBuffers = NULL;
6867 submit_info.signalSemaphoreCount = vk_semaphore ? 1 : 0;
6868 submit_info.pSignalSemaphores = &vk_semaphore;
6869
6870 if (device->vk_info.KHR_timeline_semaphore)
6871 {
6873 timeline_submit_info.pNext = NULL;
6874 timeline_submit_info.pSignalSemaphoreValues = &timeline_value;
6875 timeline_submit_info.signalSemaphoreValueCount = submit_info.signalSemaphoreCount;
6876 timeline_submit_info.waitSemaphoreValueCount = 0;
6877 timeline_submit_info.pWaitSemaphoreValues = NULL;
6878 submit_info.pNext = &timeline_submit_info;
6879 }
6880
6881 vr = VK_CALL(vkQueueSubmit(vk_queue, 1, &submit_info, vk_fence));
6882 if (!device->vk_info.KHR_timeline_semaphore && vr >= 0)
6883 {
6884 sequence_number = ++vkd3d_queue->submitted_sequence_number;
6885
6886 /* We don't expect to overrun the 64-bit counter, but we handle it gracefully anyway. */
6887 if (!sequence_number)
6889 }
6890
6892
6893 if (vr < 0)
6894 {
6895 WARN("Failed to submit signal operation, vr %d.\n", vr);
6896 goto fail_vkresult;
6897 }
6898
6899 if (device->vk_info.KHR_timeline_semaphore)
6900 {
6902 return hr;
6903
6905 return hr;
6906
6907 vk_semaphore = fence->timeline_semaphore;
6908 VKD3D_ASSERT(vk_semaphore);
6909
6910 return vkd3d_enqueue_timeline_semaphore(&command_queue->fence_worker,
6911 vk_semaphore, fence, timeline_value, vkd3d_queue);
6912 }
6913
6914 if (vk_semaphore && SUCCEEDED(hr = d3d12_fence_add_vk_semaphore(fence, vk_semaphore, vk_fence, value, vkd3d_queue)))
6915 vk_semaphore = VK_NULL_HANDLE;
6916
6917 vr = VK_CALL(vkGetFenceStatus(device->vk_device, vk_fence));
6918 if (vr == VK_NOT_READY)
6919 {
6920 if (SUCCEEDED(hr = vkd3d_enqueue_gpu_fence(&command_queue->fence_worker,
6921 vk_fence, fence, value, vkd3d_queue, sequence_number)))
6922 {
6923 vk_fence = VK_NULL_HANDLE;
6924 }
6925 }
6926 else if (vr == VK_SUCCESS)
6927 {
6928 TRACE("Already signaled %p, value %#"PRIx64".\n", fence, value);
6929 hr = d3d12_fence_signal(fence, value, vk_fence, false);
6930 vk_fence = VK_NULL_HANDLE;
6932 }
6933 else
6934 {
6935 FIXME("Failed to get fence status, vr %d.\n", vr);
6937 }
6938
6939 if (vk_fence || vk_semaphore)
6940 {
6941 /* In case of an unexpected failure, try to safely destroy Vulkan objects. */
6943 goto fail;
6944 }
6945
6946 return hr;
6947
6948fail_vkresult:
6950fail:
6951 VK_CALL(vkDestroyFence(device->vk_device, vk_fence, NULL));
6952 if (!device->vk_info.KHR_timeline_semaphore)
6953 VK_CALL(vkDestroySemaphore(device->vk_device, vk_semaphore, NULL));
6954 return hr;
6955}
6956
6958 struct d3d12_fence *fence, uint64_t value)
6959{
6960 static const VkPipelineStageFlags wait_stage_mask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
6961 const struct vkd3d_vk_device_procs *vk_procs;
6963 uint64_t completed_value = 0;
6964 struct vkd3d_queue *queue;
6965 VkSubmitInfo submit_info;
6966 VkQueue vk_queue;
6967 VkResult vr;
6968 HRESULT hr;
6969
6970 vk_procs = &command_queue->device->vk_procs;
6971 queue = command_queue->vkd3d_queue;
6972
6973 semaphore = d3d12_fence_acquire_vk_semaphore_locked(fence, value, &completed_value);
6974
6975 vkd3d_mutex_unlock(&fence->mutex);
6976
6977 if (!semaphore && completed_value >= value)
6978 {
6979 /* We don't get a Vulkan semaphore if the fence was signaled on CPU. */
6980 TRACE("Already signaled %p, value %#"PRIx64".\n", fence, completed_value);
6981 return S_OK;
6982 }
6983
6985 {
6986 ERR("Failed to acquire queue %p.\n", queue);
6987 hr = E_FAIL;
6988 goto fail;
6989 }
6990
6991 if (!semaphore)
6992 {
6993 if (command_queue->last_waited_fence == fence && command_queue->last_waited_fence_value >= value)
6994 {
6995 WARN("Already waited on fence %p, value %#"PRIx64".\n", fence, value);
6996 }
6997 else
6998 {
6999 WARN("Failed to acquire Vulkan semaphore for fence %p, value %#"PRIx64
7000 ", completed value %#"PRIx64".\n", fence, value, completed_value);
7001 }
7002
7004 return S_OK;
7005 }
7006
7008 submit_info.pNext = NULL;
7009 submit_info.waitSemaphoreCount = 1;
7010 submit_info.pWaitSemaphores = &semaphore->u.binary.vk_semaphore;
7011 submit_info.pWaitDstStageMask = &wait_stage_mask;
7012 submit_info.commandBufferCount = 0;
7013 submit_info.pCommandBuffers = NULL;
7014 submit_info.signalSemaphoreCount = 0;
7015 submit_info.pSignalSemaphores = NULL;
7016
7017 if (!vkd3d_array_reserve((void **)&queue->semaphores, &queue->semaphores_size,
7018 queue->semaphore_count + 1, sizeof(*queue->semaphores)))
7019 {
7020 ERR("Failed to allocate memory for semaphore.\n");
7022 hr = E_OUTOFMEMORY;
7023 goto fail;
7024 }
7025
7026 if ((vr = VK_CALL(vkQueueSubmit(vk_queue, 1, &submit_info, VK_NULL_HANDLE))) >= 0)
7027 {
7028 queue->semaphores[queue->semaphore_count].vk_semaphore = semaphore->u.binary.vk_semaphore;
7029 queue->semaphores[queue->semaphore_count].sequence_number = queue->submitted_sequence_number + 1;
7030 ++queue->semaphore_count;
7031
7032 command_queue->last_waited_fence = fence;
7033 command_queue->last_waited_fence_value = value;
7034 }
7035
7037
7038 if (vr < 0)
7039 {
7040 WARN("Failed to submit wait operation, vr %d.\n", vr);
7042 goto fail;
7043 }
7044
7046 return S_OK;
7047
7048fail:
7050 return hr;
7051}
7052
7054 struct d3d12_fence *fence, uint64_t value)
7055{
7056 static const VkPipelineStageFlags wait_stage_mask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
7057 VkTimelineSemaphoreSubmitInfoKHR timeline_submit_info;
7058 const struct vkd3d_vk_device_procs *vk_procs;
7059 struct vkd3d_queue *queue;
7060 VkSubmitInfo submit_info;
7061 uint64_t wait_value;
7062 VkQueue vk_queue;
7063 VkResult vr;
7064
7065 vk_procs = &command_queue->device->vk_procs;
7066 queue = command_queue->vkd3d_queue;
7067
7068 if (!command_queue->device->vk_info.KHR_timeline_semaphore)
7069 return d3d12_command_queue_wait_binary_semaphore_locked(command_queue, fence, value);
7070
7072
7073 /* We can unlock the fence here. The queue semaphore will not be signalled to signal_value
7074 * until we have submitted, so the semaphore cannot be destroyed before the call to vkQueueSubmit. */
7075 vkd3d_mutex_unlock(&fence->mutex);
7076
7079 timeline_submit_info.pNext = NULL;
7080 timeline_submit_info.waitSemaphoreValueCount = 1;
7081 timeline_submit_info.pWaitSemaphoreValues = &wait_value;
7082 timeline_submit_info.signalSemaphoreValueCount = 0;
7083 timeline_submit_info.pSignalSemaphoreValues = NULL;
7084
7086 submit_info.pNext = &timeline_submit_info;
7087 submit_info.waitSemaphoreCount = 1;
7088 submit_info.pWaitSemaphores = &fence->timeline_semaphore;
7089 submit_info.pWaitDstStageMask = &wait_stage_mask;
7090 submit_info.commandBufferCount = 0;
7091 submit_info.pCommandBuffers = NULL;
7092 submit_info.signalSemaphoreCount = 0;
7093 submit_info.pSignalSemaphores = NULL;
7094
7096 {
7097 ERR("Failed to acquire queue %p.\n", queue);
7098 return E_FAIL;
7099 }
7100
7101 vr = VK_CALL(vkQueueSubmit(vk_queue, 1, &submit_info, VK_NULL_HANDLE));
7102
7104
7105 if (vr < 0)
7106 {
7107 WARN("Failed to submit wait operation, vr %d.\n", vr);
7108 return hresult_from_vk_result(vr);
7109 }
7110
7111 return S_OK;
7112}
7113
7114static HRESULT STDMETHODCALLTYPE d3d12_command_queue_Wait(ID3D12CommandQueue *iface,
7115 ID3D12Fence *fence_iface, UINT64 value)
7116{
7117 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
7118 struct d3d12_fence *fence = unsafe_impl_from_ID3D12Fence(fence_iface);
7119 struct vkd3d_cs_op_data *op;
7120 HRESULT hr = S_OK;
7121
7122 TRACE("iface %p, fence %p, value %#"PRIx64".\n", iface, fence_iface, value);
7123
7124 vkd3d_mutex_lock(&command_queue->op_mutex);
7125
7126 if (!(op = d3d12_command_queue_op_array_require_space(&command_queue->op_queue)))
7127 {
7128 ERR("Failed to add op.\n");
7129 hr = E_OUTOFMEMORY;
7130 goto done;
7131 }
7132 op->opcode = VKD3D_CS_OP_WAIT;
7133 op->u.wait.fence = fence;
7134 op->u.wait.value = value;
7135
7136 d3d12_fence_incref(fence);
7137
7138 d3d12_command_queue_submit_locked(command_queue);
7139
7140done:
7141 vkd3d_mutex_unlock(&command_queue->op_mutex);
7142 return hr;
7143}
7144
7147{
7148 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
7149 struct d3d12_device *device = command_queue->device;
7150
7151 TRACE("iface %p, frequency %p.\n", iface, frequency);
7152
7153 if (!command_queue->vkd3d_queue->timestamp_bits)
7154 {
7155 WARN("Timestamp queries not supported.\n");
7156 return E_FAIL;
7157 }
7158
7159 *frequency = 1000000000 / device->vk_info.device_limits.timestampPeriod;
7160
7161 return S_OK;
7162}
7163
7164#define NANOSECONDS_IN_A_SECOND 1000000000
7165
7167 UINT64 *gpu_timestamp, UINT64 *cpu_timestamp)
7168{
7169 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
7170 struct d3d12_device *device = command_queue->device;
7171 const struct vkd3d_vk_device_procs *vk_procs;
7173 uint64_t timestamps[2];
7174 uint64_t deviations[2];
7175 VkResult vr;
7176
7177 TRACE("iface %p, gpu_timestamp %p, cpu_timestamp %p.\n",
7178 iface, gpu_timestamp, cpu_timestamp);
7179
7180 if (!command_queue->vkd3d_queue->timestamp_bits)
7181 {
7182 WARN("Timestamp queries not supported.\n");
7183 return E_FAIL;
7184 }
7185
7186 if (!gpu_timestamp || !cpu_timestamp)
7187 return E_INVALIDARG;
7188
7189 if (!device->vk_info.EXT_calibrated_timestamps || device->vk_host_time_domain == -1)
7190 {
7191 WARN(!device->vk_info.EXT_calibrated_timestamps
7192 ? "VK_EXT_calibrated_timestamps was not found. Setting timestamps to zero.\n"
7193 : "Device and/or host time domain is not available. Setting timestamps to zero.\n");
7194 *gpu_timestamp = 0;
7195 *cpu_timestamp = 0;
7196 return S_OK;
7197 }
7198
7199 vk_procs = &device->vk_procs;
7200
7202 infos[0].pNext = NULL;
7205 infos[1].pNext = NULL;
7206 infos[1].timeDomain = device->vk_host_time_domain;
7207
7208 if ((vr = VK_CALL(vkGetCalibratedTimestampsEXT(command_queue->device->vk_device,
7209 ARRAY_SIZE(infos), infos, timestamps, deviations))) < 0)
7210 {
7211 WARN("Failed to get calibrated timestamps, vr %d.\n", vr);
7212 return E_FAIL;
7213 }
7214
7215 if (infos[1].timeDomain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT
7216 || infos[1].timeDomain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT)
7217 {
7218 /* Convert monotonic clock to match Wine's RtlQueryPerformanceFrequency(). */
7219 timestamps[1] /= NANOSECONDS_IN_A_SECOND / device->vkd3d_instance->host_ticks_per_second;
7220 }
7221
7222 *gpu_timestamp = timestamps[0];
7223 *cpu_timestamp = timestamps[1];
7224
7225 return S_OK;
7226}
7227
7230{
7231 struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
7232
7233 TRACE("iface %p, desc %p.\n", iface, desc);
7234
7235 *desc = command_queue->desc;
7236 return desc;
7237}
7238
7239static const struct ID3D12CommandQueueVtbl d3d12_command_queue_vtbl =
7240{
7241 /* IUnknown methods */
7245 /* ID3D12Object methods */
7250 /* ID3D12DeviceChild methods */
7252 /* ID3D12CommandQueue methods */
7264};
7265
7267{
7269
7270 array = queue->op_queue;
7271 queue->op_queue = queue->aux_op_queue;
7272 queue->aux_op_queue = array;
7273}
7274
7276 size_t count, const struct vkd3d_cs_op_data *new_ops)
7277{
7278 if (!vkd3d_array_reserve((void **)&array->ops, &array->size, array->count + count, sizeof(*array->ops)))
7279 {
7280 ERR("Cannot reserve memory for %zu new ops.\n", count);
7281 return false;
7282 }
7283
7284 memcpy(&array->ops[array->count], new_ops, count * sizeof(*array->ops));
7285 array->count += count;
7286
7287 return true;
7288}
7289
7291 unsigned int done_count)
7292{
7293 queue->aux_op_queue.count -= done_count;
7294 memmove(queue->aux_op_queue.ops, &queue->aux_op_queue.ops[done_count],
7295 queue->aux_op_queue.count * sizeof(*queue->aux_op_queue.ops));
7296}
7297
7299{
7301
7302 d3d12_command_queue_op_array_append(&queue->op_queue, queue->aux_op_queue.count, queue->aux_op_queue.ops);
7303
7304 queue->aux_op_queue.count = 0;
7305 queue->is_flushing = false;
7306
7308}
7309
7311{
7312 HRESULT hr;
7313
7314 vkd3d_mutex_lock(&queue->op_mutex);
7315
7316 /* This function may be re-entered when invoking
7317 * d3d12_command_queue_signal(). The first call is responsible
7318 * for re-adding the queue to the flush list. */
7319 if (queue->is_flushing)
7320 {
7321 vkd3d_mutex_unlock(&queue->op_mutex);
7322 return S_OK;
7323 }
7324
7326
7327 vkd3d_mutex_unlock(&queue->op_mutex);
7328
7329 return hr;
7330}
7331
7332/* flushed_any is initialised by the caller. */
7334{
7335 struct vkd3d_cs_op_data *op;
7336 struct d3d12_fence *fence;
7337 unsigned int i;
7338
7339 queue->is_flushing = true;
7340
7341 VKD3D_ASSERT(queue->aux_op_queue.count == 0);
7342
7343 while (queue->op_queue.count != 0)
7344 {
7346
7347 vkd3d_mutex_unlock(&queue->op_mutex);
7348
7349 for (i = 0; i < queue->aux_op_queue.count; ++i)
7350 {
7351 op = &queue->aux_op_queue.ops[i];
7352 switch (op->opcode)
7353 {
7354 case VKD3D_CS_OP_WAIT:
7355 fence = op->u.wait.fence;
7356 vkd3d_mutex_lock(&fence->mutex);
7357 if (op->u.wait.value > fence->max_pending_value)
7358 {
7359 vkd3d_mutex_unlock(&fence->mutex);
7361 vkd3d_mutex_lock(&queue->op_mutex);
7363 }
7364 d3d12_command_queue_wait_locked(queue, fence, op->u.wait.value);
7365 break;
7366
7367 case VKD3D_CS_OP_SIGNAL:
7368 d3d12_command_queue_signal(queue, op->u.signal.fence, op->u.signal.value);
7369 break;
7370
7372 d3d12_command_queue_execute(queue, op->u.execute.buffers, op->u.execute.buffer_count);
7373 break;
7374
7376 FIXME("Tiled resource binding is not supported yet.\n");
7377 update_mappings_cleanup(&op->u.update_mappings);
7378 break;
7379
7381 FIXME("Tiled resource mapping copying is not supported yet.\n");
7382 break;
7383
7384 default:
7386 }
7387
7389
7390 *flushed_any |= true;
7391 }
7392
7393 queue->aux_op_queue.count = 0;
7394
7395 vkd3d_mutex_lock(&queue->op_mutex);
7396 }
7397
7398 queue->is_flushing = false;
7399
7400 return S_OK;
7401}
7402
7404{
7405 array->ops = NULL;
7406 array->count = 0;
7407 array->size = 0;
7408}
7409
7412{
7413 HRESULT hr;
7414
7415 queue->ID3D12CommandQueue_iface.lpVtbl = &d3d12_command_queue_vtbl;
7416 queue->refcount = 1;
7417
7418 queue->desc = *desc;
7419 if (!queue->desc.NodeMask)
7420 queue->desc.NodeMask = 0x1;
7421
7422 if (!(queue->vkd3d_queue = d3d12_device_get_vkd3d_queue(device, desc->Type)))
7423 return E_NOTIMPL;
7424
7425 queue->last_waited_fence = NULL;
7426 queue->last_waited_fence_value = 0;
7427
7429 queue->is_flushing = false;
7430
7432
7434 {
7435 FIXME("Global realtime priority is not implemented.\n");
7436 return E_NOTIMPL;
7437 }
7438
7439 if (desc->Priority)
7440 FIXME("Ignoring priority %#x.\n", desc->Priority);
7441 if (desc->Flags)
7442 FIXME("Ignoring flags %#x.\n", desc->Flags);
7443
7444 if (FAILED(hr = vkd3d_private_store_init(&queue->private_store)))
7445 return hr;
7446
7447 vkd3d_mutex_init(&queue->op_mutex);
7448
7449 if (FAILED(hr = vkd3d_fence_worker_start(&queue->fence_worker, queue->vkd3d_queue, device)))
7450 goto fail_destroy_op_mutex;
7451
7452 queue->supports_sparse_binding = !!(queue->vkd3d_queue->vk_queue_flags & VK_QUEUE_SPARSE_BINDING_BIT);
7453
7455
7456 return S_OK;
7457
7458fail_destroy_op_mutex:
7459 vkd3d_mutex_destroy(&queue->op_mutex);
7460 vkd3d_private_store_destroy(&queue->private_store);
7461 return hr;
7462}
7463
7466{
7468 HRESULT hr;
7469
7470 if (!(object = vkd3d_malloc(sizeof(*object))))
7471 return E_OUTOFMEMORY;
7472
7473 if (FAILED(hr = d3d12_command_queue_init(object, device, desc)))
7474 {
7475 vkd3d_free(object);
7476 return hr;
7477 }
7478
7479 TRACE("Created command queue %p.\n", object);
7480
7481 *queue = object;
7482
7483 return S_OK;
7484}
7485
7487{
7489
7490 return d3d12_queue->vkd3d_queue->vk_family_index;
7491}
7492
7493VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue)
7494{
7496 VkQueue vk_queue = vkd3d_queue_acquire(d3d12_queue->vkd3d_queue);
7497
7498 if (d3d12_queue->op_queue.count)
7499 WARN("Acquired command queue %p with %zu remaining ops.\n", d3d12_queue, d3d12_queue->op_queue.count);
7500 else if (d3d12_queue->is_flushing)
7501 WARN("Acquired command queue %p which is flushing.\n", d3d12_queue);
7502
7503 return vk_queue;
7504}
7505
7506void vkd3d_release_vk_queue(ID3D12CommandQueue *queue)
7507{
7509
7510 return vkd3d_queue_release(d3d12_queue->vkd3d_queue);
7511}
7512
7513/* ID3D12CommandSignature */
7515{
7517}
7518
7520 REFIID iid, void **out)
7521{
7522 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
7523
7524 if (IsEqualGUID(iid, &IID_ID3D12CommandSignature)
7525 || IsEqualGUID(iid, &IID_ID3D12Pageable)
7526 || IsEqualGUID(iid, &IID_ID3D12DeviceChild)
7527 || IsEqualGUID(iid, &IID_ID3D12Object)
7528 || IsEqualGUID(iid, &IID_IUnknown))
7529 {
7530 ID3D12CommandSignature_AddRef(iface);
7531 *out = iface;
7532 return S_OK;
7533 }
7534
7535 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
7536
7537 *out = NULL;
7538 return E_NOINTERFACE;
7539}
7540
7542{
7544 unsigned int refcount = vkd3d_atomic_increment_u32(&signature->refcount);
7545
7546 TRACE("%p increasing refcount to %u.\n", signature, refcount);
7547
7548 return refcount;
7549}
7550
7552{
7554 unsigned int refcount = vkd3d_atomic_decrement_u32(&signature->refcount);
7555
7556 TRACE("%p decreasing refcount to %u.\n", signature, refcount);
7557
7558 if (!refcount)
7560
7561 return refcount;
7562}
7563
7565 REFGUID guid, UINT *data_size, void *data)
7566{
7568
7569 TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
7570
7571 return vkd3d_get_private_data(&signature->private_store, guid, data_size, data);
7572}
7573
7575 REFGUID guid, UINT data_size, const void *data)
7576{
7578
7579 TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
7580
7581 return vkd3d_set_private_data(&signature->private_store, guid, data_size, data);
7582}
7583
7585 REFGUID guid, const IUnknown *data)
7586{
7588
7589 TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
7590
7591 return vkd3d_set_private_data_interface(&signature->private_store, guid, data);
7592}
7593
7595{
7597
7598 TRACE("iface %p, name %s.\n", iface, debugstr_w(name, signature->device->wchar_size));
7599
7600 return name ? S_OK : E_INVALIDARG;
7601}
7602
7604{
7606
7607 TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
7608
7609 return d3d12_device_query_interface(signature->device, iid, device);
7610}
7611
7612static const struct ID3D12CommandSignatureVtbl d3d12_command_signature_vtbl =
7613{
7614 /* IUnknown methods */
7618 /* ID3D12Object methods */
7623 /* ID3D12DeviceChild methods */
7625};
7626
7628{
7629 if (!iface)
7630 return NULL;
7631 VKD3D_ASSERT(iface->lpVtbl == &d3d12_command_signature_vtbl);
7633}
7634
7637{
7639 unsigned int i;
7640 HRESULT hr;
7641
7642 for (i = 0; i < desc->NumArgumentDescs; ++i)
7643 {
7644 const D3D12_INDIRECT_ARGUMENT_DESC *argument_desc = &desc->pArgumentDescs[i];
7645 switch (argument_desc->Type)
7646 {
7650 if (i != desc->NumArgumentDescs - 1)
7651 {
7652 WARN("Draw/dispatch must be the last element of a command signature.\n");
7653 return E_INVALIDARG;
7654 }
7655 break;
7656 default:
7657 break;
7658 }
7659 }
7660
7661 if (!(object = vkd3d_malloc(sizeof(*object))))
7662 return E_OUTOFMEMORY;
7663
7664 object->ID3D12CommandSignature_iface.lpVtbl = &d3d12_command_signature_vtbl;
7665 object->refcount = 1;
7666 object->internal_refcount = 1;
7667
7668 object->desc = *desc;
7669 if (!(object->desc.pArgumentDescs = vkd3d_calloc(desc->NumArgumentDescs, sizeof(*desc->pArgumentDescs))))
7670 {
7671 vkd3d_free(object);
7672 return E_OUTOFMEMORY;
7673 }
7674 memcpy((void *)object->desc.pArgumentDescs, desc->pArgumentDescs,
7675 desc->NumArgumentDescs * sizeof(*desc->pArgumentDescs));
7676
7677 if (FAILED(hr = vkd3d_private_store_init(&object->private_store)))
7678 {
7679 vkd3d_free((void *)object->desc.pArgumentDescs);
7680 vkd3d_free(object);
7681 return hr;
7682 }
7683
7685
7686 TRACE("Created command signature %p.\n", object);
7687
7688 *signature = object;
7689
7690 return S_OK;
7691}
Type
Definition: Type.h:7
unsigned char UINT8
Definition: actypes.h:128
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
static int state
Definition: maze.c:121
unsigned int rate
Definition: audiorecord.c:87
operation
Definition: copy.c:29
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
static void set_size(float size)
Definition: wordpad.c:316
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#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: list.h:39
Definition: _set.h:50
set(const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Definition: _set.h:89
static void STDMETHODCALLTYPE d3d12_command_list_SetPipelineState1(ID3D12GraphicsCommandList6 *iface, ID3D12StateObject *state_object)
Definition: command.c:6095
static void STDMETHODCALLTYPE d3d12_command_list_InitializeMetaCommand(ID3D12GraphicsCommandList6 *iface, ID3D12MetaCommand *meta_command, const void *parameters_data, SIZE_T data_size_in_bytes)
Definition: command.c:6058
static void d3d12_command_list_invalidate_root_parameters(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:2014
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_SetName(ID3D12CommandAllocator *iface, const WCHAR *name)
Definition: command.c:1714
static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12GraphicsCommandList6 *iface, UINT render_target_descriptor_count, const D3D12_CPU_DESCRIPTOR_HANDLE *render_target_descriptors, BOOL single_descriptor_handle, const D3D12_CPU_DESCRIPTOR_HANDLE *depth_stencil_descriptor)
Definition: command.c:4937
static const struct d3d12_root_descriptor_table * root_signature_get_descriptor_table(const struct d3d12_root_signature *root_signature, unsigned int index)
Definition: command.c:431
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewFloat(ID3D12GraphicsCommandList6 *iface, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource, const float values[4], UINT rect_count, const D3D12_RECT *rects)
Definition: command.c:5554
static void d3d12_command_list_invalidate_current_pipeline(struct d3d12_command_list *list)
Definition: command.c:1956
static struct vkd3d_signaled_semaphore * d3d12_fence_acquire_vk_semaphore_locked(struct d3d12_fence *fence, uint64_t value, uint64_t *completed_value)
Definition: command.c:565
static void STDMETHODCALLTYPE d3d12_command_list_BeginQuery(ID3D12GraphicsCommandList6 *iface, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index)
Definition: command.c:5593
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_SetName(ID3D12CommandQueue *iface, const WCHAR *name)
Definition: command.c:6428
static bool d3d12_command_list_has_depth_stencil_view(struct d3d12_command_list *list)
Definition: command.c:2547
static unsigned int d3d12_find_ds_multiplanar_transition(const D3D12_RESOURCE_BARRIER *barriers, unsigned int i, unsigned int barrier_count, unsigned int sub_resource_count)
Definition: command.c:4154
void vkd3d_queue_destroy(struct vkd3d_queue *queue, struct d3d12_device *device)
Definition: command.c:67
static HRESULT STDMETHODCALLTYPE d3d12_command_list_Reset(ID3D12GraphicsCommandList6 *iface, ID3D12CommandAllocator *allocator, ID3D12PipelineState *initial_pipeline_state)
Definition: command.c:2510
static HRESULT d3d12_fence_update_pending_value(struct d3d12_fence *fence)
Definition: command.c:631
static D3D12_COMMAND_LIST_TYPE STDMETHODCALLTYPE d3d12_command_list_GetType(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:2415
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_QueryInterface(ID3D12CommandQueue *iface, REFIID riid, void **object)
Definition: command.c:6307
static bool vk_write_descriptor_set_from_d3d12_desc(VkWriteDescriptorSet *vk_descriptor_write, VkDescriptorImageInfo *vk_image_info, const struct d3d12_desc *descriptor, const struct d3d12_root_descriptor_table_range *range, VkDescriptorSet *vk_descriptor_sets, unsigned int index, bool use_array)
Definition: command.c:2762
static ULONG STDMETHODCALLTYPE d3d12_command_allocator_Release(ID3D12CommandAllocator *iface)
Definition: command.c:1646
static uint64_t d3d12_fence_get_timeline_wait_value_locked(struct d3d12_fence *fence, uint64_t virtual_value)
Definition: command.c:847
static HRESULT d3d12_command_queue_signal(struct d3d12_command_queue *command_queue, struct d3d12_fence *fence, uint64_t value)
Definition: command.c:6806
static const struct ID3D12Fence1Vtbl d3d12_fence_vtbl
Definition: command.c:1131
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRoot32BitConstant(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, UINT data, UINT dst_offset)
Definition: command.c:4535
static HRESULT STDMETHODCALLTYPE d3d12_command_list_QueryInterface(ID3D12GraphicsCommandList6 *iface, REFIID iid, void **object)
Definition: command.c:2295
static struct d3d12_fence * impl_from_ID3D12Fence1(ID3D12Fence1 *iface)
Definition: command.c:458
static bool vk_write_descriptor_set_from_root_descriptor(VkWriteDescriptorSet *vk_descriptor_write, const struct d3d12_root_parameter *root_parameter, VkDescriptorSet vk_descriptor_set, VkBufferView *vk_buffer_view, const VkDescriptorBufferInfo *vk_buffer_info)
Definition: command.c:2936
static void d3d12_command_list_prepare_descriptors(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:2705
VkResult vkd3d_create_timeline_semaphore(const struct d3d12_device *device, uint64_t initial_value, VkSemaphore *timeline_semaphore)
Definition: command.c:1239
static void d3d12_command_list_update_descriptor_table(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, unsigned int index, struct d3d12_desc *base_descriptor)
Definition: command.c:2842
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootConstantBufferView(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: command.c:4635
static void STDMETHODCALLTYPE d3d12_command_list_CopyTiles(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *tiled_resource, const D3D12_TILED_RESOURCE_COORDINATE *tile_region_start_coordinate, const D3D12_TILE_REGION_SIZE *tile_region_size, ID3D12Resource *buffer, UINT64 buffer_offset, D3D12_TILE_COPY_FLAGS flags)
Definition: command.c:3947
static bool d3d12_command_allocator_add_buffer_view(struct d3d12_command_allocator *allocator, VkBufferView view)
Definition: command.c:1404
static void STDMETHODCALLTYPE d3d12_command_list_SetPredication(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *buffer, UINT64 aligned_buffer_offset, D3D12_PREDICATION_OP operation)
Definition: command.c:5749
static const struct d3d12_root_parameter * root_signature_get_parameter(const struct d3d12_root_signature *root_signature, unsigned int index)
Definition: command.c:424
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_GetClockCalibration(ID3D12CommandQueue *iface, UINT64 *gpu_timestamp, UINT64 *cpu_timestamp)
Definition: command.c:7166
static uint64_t vkd3d_queue_reset_sequence_number_locked(struct vkd3d_queue *queue)
Definition: command.c:184
static HRESULT d3d12_fence_add_vk_semaphore(struct d3d12_fence *fence, VkSemaphore vk_semaphore, VkFence vk_fence, uint64_t value, const struct vkd3d_queue *signalling_queue)
Definition: command.c:711
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_Wait(ID3D12CommandQueue *iface, ID3D12Fence *fence_iface, UINT64 value)
Definition: command.c:7114
static HRESULT d3d12_fence_signal(struct d3d12_fence *fence, uint64_t value, VkFence vk_fence, bool on_cpu)
Definition: command.c:780
static void vkd3d_uav_clear_state_get_image_pipeline(const struct vkd3d_uav_clear_state *state, VkImageViewType image_view_type, enum vkd3d_format_type format_type, struct vkd3d_uav_clear_pipeline *info)
Definition: command.c:5265
static void d3d12_command_list_invalidate_current_framebuffer(struct d3d12_command_list *list)
Definition: command.c:1951
static void d3d12_command_list_update_push_descriptors(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:2973
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteMetaCommand(ID3D12GraphicsCommandList6 *iface, ID3D12MetaCommand *meta_command, const void *parameters_data, SIZE_T data_size_in_bytes)
Definition: command.c:6065
static void STDMETHODCALLTYPE d3d12_command_list_IASetVertexBuffers(ID3D12GraphicsCommandList6 *iface, UINT start_slot, UINT view_count, const D3D12_VERTEX_BUFFER_VIEW *views)
Definition: command.c:4798
static void d3d12_command_queue_op_array_destroy(struct d3d12_command_queue_op_array *array)
Definition: command.c:6361
static void d3d12_command_list_update_heap_descriptors(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:3267
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_SetName(ID3D12CommandSignature *iface, const WCHAR *name)
Definition: command.c:7594
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_Reset(ID3D12CommandAllocator *iface)
Definition: command.c:1733
static struct vkd3d_cs_op_data * d3d12_command_queue_op_array_require_space(struct d3d12_command_queue_op_array *array)
Definition: command.c:6457
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetName(ID3D12GraphicsCommandList6 *iface, const WCHAR *name)
Definition: command.c:2396
static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresource(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *dst, UINT dst_sub_resource_idx, ID3D12Resource *src, UINT src_sub_resource_idx, DXGI_FORMAT format)
Definition: command.c:3958
static void STDMETHODCALLTYPE d3d12_command_list_DrawIndexedInstanced(ID3D12GraphicsCommandList6 *iface, UINT index_count_per_instance, UINT instance_count, UINT start_vertex_location, INT base_vertex_location, UINT start_instance_location)
Definition: command.c:3422
static void STDMETHODCALLTYPE d3d12_command_list_RSSetScissorRects(ID3D12GraphicsCommandList6 *iface, UINT rect_count, const D3D12_RECT *rects)
Definition: command.c:4077
static void STDMETHODCALLTYPE d3d12_command_list_SetMarker(ID3D12GraphicsCommandList6 *iface, UINT metadata, const void *data, UINT size)
Definition: command.c:5821
static void d3d12_command_list_update_descriptors(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:3297
static void STDMETHODCALLTYPE d3d12_command_list_SetDescriptorHeaps(ID3D12GraphicsCommandList6 *iface, UINT heap_count, ID3D12DescriptorHeap *const *heaps)
Definition: command.c:4419
static unsigned int d3d12_command_list_bind_descriptor_table(struct d3d12_command_list *list, struct vkd3d_pipeline_bindings *bindings, unsigned int index, struct d3d12_descriptor_heap **cbv_srv_uav_heap, struct d3d12_descriptor_heap **sampler_heap)
Definition: command.c:3116
static void d3d12_fence_incref(struct d3d12_fence *fence)
Definition: command.c:937
static void STDMETHODCALLTYPE d3d12_command_list_DispatchMesh(ID3D12GraphicsCommandList6 *iface, UINT x, UINT y, UINT z)
Definition: command.c:6119
static const struct vkd3d_format * vkd3d_fixup_clear_uav_uint_colour(struct d3d12_device *device, DXGI_FORMAT dxgi_format, VkClearColorValue *colour)
Definition: command.c:5439
static HRESULT STDMETHODCALLTYPE d3d12_fence_SetPrivateDataInterface(ID3D12Fence1 *iface, REFGUID guid, const IUnknown *data)
Definition: command.c:999
static void STDMETHODCALLTYPE d3d12_command_list_EndQuery(ID3D12GraphicsCommandList6 *iface, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT index)
Definition: command.c:5623
static void d3d12_command_list_set_root_descriptor(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, unsigned int index, D3D12_GPU_VIRTUAL_ADDRESS gpu_address)
Definition: command.c:4657
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_GetDevice(ID3D12CommandSignature *iface, REFIID iid, void **device)
Definition: command.c:7603
static void STDMETHODCALLTYPE d3d12_command_list_ResolveSubresourceRegion(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *dst_resource, UINT dst_sub_resource_idx, UINT dst_x, UINT dst_y, ID3D12Resource *src_resource, UINT src_sub_resource_idx, D3D12_RECT *src_rect, DXGI_FORMAT format, D3D12_RESOLVE_MODE mode)
Definition: command.c:6005
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateDataInterface(ID3D12GraphicsCommandList6 *iface, REFGUID guid, const IUnknown *data)
Definition: command.c:2386
static struct d3d12_fence * unsafe_impl_from_ID3D12Fence(ID3D12Fence *iface)
Definition: command.c:1152
#define NANOSECONDS_IN_A_SECOND
Definition: command.c:7164
static bool d3d12_command_allocator_add_transfer_buffer(struct d3d12_command_allocator *allocator, const struct vkd3d_buffer *buffer)
Definition: command.c:1416
static void STDMETHODCALLTYPE d3d12_command_list_SetViewInstanceMask(ID3D12GraphicsCommandList6 *iface, UINT mask)
Definition: command.c:6017
static void command_list_add_descriptor_heap(struct d3d12_command_list *list, struct d3d12_descriptor_heap *heap)
Definition: command.c:3206
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRoot32BitConstant(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, UINT data, UINT dst_offset)
Definition: command.c:4547
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_GetPrivateData(ID3D12CommandQueue *iface, REFGUID guid, UINT *data_size, void *data)
Definition: command.c:6398
static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12GraphicsCommandList6 *iface, const D3D12_TEXTURE_COPY_LOCATION *dst, UINT dst_x, UINT dst_y, UINT dst_z, const D3D12_TEXTURE_COPY_LOCATION *src, const D3D12_BOX *src_box)
Definition: command.c:3752
static HRESULT d3d12_device_flush_blocked_queues_once(struct d3d12_device *device, bool *flushed_any)
Definition: command.c:663
static void vkd3d_wait_for_gpu_timeline_semaphore(struct vkd3d_fence_worker *worker, const struct vkd3d_waiting_fence *waiting_fence)
Definition: command.c:268
static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12_command_list *list, struct d3d12_resource *resource)
Definition: command.c:2240
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_SetPrivateDataInterface(ID3D12CommandAllocator *iface, REFGUID guid, const IUnknown *data)
Definition: command.c:1704
static HRESULT d3d12_fence_signal_cpu_timeline_semaphore(struct d3d12_fence *fence, uint64_t value)
Definition: command.c:1098
static ULONG STDMETHODCALLTYPE d3d12_command_queue_Release(ID3D12CommandQueue *iface)
Definition: command.c:6371
static void vkd3d_uav_clear_state_get_buffer_pipeline(const struct vkd3d_uav_clear_state *state, enum vkd3d_format_type format_type, struct vkd3d_uav_clear_pipeline *info)
Definition: command.c:5253
static void d3d12_command_list_set_root_signature(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, const struct d3d12_root_signature *root_signature)
Definition: command.c:4432
static HRESULT STDMETHODCALLTYPE d3d12_fence_SetName(ID3D12Fence1 *iface, const WCHAR *name)
Definition: command.c:1009
static const struct ID3D12GraphicsCommandList6Vtbl d3d12_command_list_vtbl
Definition: command.c:6124
static HRESULT vkd3d_fence_worker_start(struct vkd3d_fence_worker *worker, struct vkd3d_queue *queue, struct d3d12_device *device)
Definition: command.c:367
static void STDMETHODCALLTYPE d3d12_command_list_RSSetShadingRateImage(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *rate_image)
Definition: command.c:6113
static void d3d12_fence_signal_external_events_locked(struct d3d12_fence *fence)
Definition: command.c:744
static HRESULT d3d12_command_queue_wait_binary_semaphore_locked(struct d3d12_command_queue *command_queue, struct d3d12_fence *fence, uint64_t value)
Definition: command.c:6957
static void d3d12_command_allocator_free_resources(struct d3d12_command_allocator *allocator, bool keep_reusable_resources)
Definition: command.c:1537
static void STDMETHODCALLTYPE d3d12_command_list_DrawInstanced(ID3D12GraphicsCommandList6 *iface, UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location, UINT start_instance_location)
Definition: command.c:3398
static void STDMETHODCALLTYPE d3d12_command_list_AtomicCopyBufferUINT64(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT dependent_resource_count, ID3D12Resource *const *dependent_resources, const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges)
Definition: command.c:5961
static void STDMETHODCALLTYPE d3d12_command_queue_EndEvent(ID3D12CommandQueue *iface)
Definition: command.c:6740
HRESULT d3d12_fence_create(struct d3d12_device *device, uint64_t initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence)
Definition: command.c:1222
static bool vk_barrier_parameters_from_d3d12_resource_state(unsigned int state, unsigned int stencil_state, const struct d3d12_resource *resource, VkQueueFlags vk_queue_flags, const struct vkd3d_vulkan_info *vk_info, VkAccessFlags *access_mask, VkPipelineStageFlags *stage_flags, VkImageLayout *image_layout, struct d3d12_device *device)
Definition: command.c:2029
static void d3d12_command_list_get_fb_extent(struct d3d12_command_list *list, uint32_t *width, uint32_t *height, uint32_t *layer_count)
Definition: command.c:2557
static void d3d12_command_list_update_descriptor_tables(struct d3d12_command_list *list, struct vkd3d_pipeline_bindings *bindings, struct d3d12_descriptor_heap **cbv_srv_uav_heap, struct d3d12_descriptor_heap **sampler_heap)
Definition: command.c:3159
static bool clone_array_parameter(void **dst, const void *src, size_t elem_size, unsigned int count)
Definition: command.c:6465
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootDescriptorTable(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
Definition: command.c:4510
static const struct ID3D12CommandSignatureVtbl d3d12_command_signature_vtbl
Definition: command.c:7612
static void STDMETHODCALLTYPE d3d12_command_list_RSSetViewports(ID3D12GraphicsCommandList6 *iface, UINT viewport_count, const D3D12_VIEWPORT *viewports)
Definition: command.c:4039
static void vkd3d_pipeline_bindings_cleanup(struct vkd3d_pipeline_bindings *bindings)
Definition: command.c:2333
static HRESULT d3d12_command_list_init(struct d3d12_command_list *list, struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator *allocator, ID3D12PipelineState *initial_pipeline_state)
Definition: command.c:6227
static const struct ID3D12CommandAllocatorVtbl d3d12_command_allocator_vtbl
Definition: command.c:1775
static void d3d12_fence_remove_vk_semaphore(struct d3d12_fence *fence, struct vkd3d_signaled_semaphore *semaphore)
Definition: command.c:599
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_QueryInterface(ID3D12CommandAllocator *iface, REFIID riid, void **object)
Definition: command.c:1614
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_GetPrivateData(ID3D12CommandAllocator *iface, REFGUID guid, UINT *data_size, void *data)
Definition: command.c:1684
static HRESULT d3d12_command_list_begin_command_buffer(struct d3d12_command_list *list)
Definition: command.c:1271
static bool validate_d3d12_box(const D3D12_BOX *box)
Definition: command.c:3745
static const struct d3d12_root_constant * root_signature_get_32bit_constants(const struct d3d12_root_signature *root_signature, unsigned int index)
Definition: command.c:439
static ULONG STDMETHODCALLTYPE d3d12_fence_Release(ID3D12Fence1 *iface)
Definition: command.c:942
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_SetPrivateData(ID3D12CommandAllocator *iface, REFGUID guid, UINT data_size, const void *data)
Definition: command.c:1694
static HRESULT d3d12_command_queue_fixup_after_flush_locked(struct d3d12_command_queue *queue)
Definition: command.c:7298
static ULONG STDMETHODCALLTYPE d3d12_command_list_AddRef(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:2323
static ULONG STDMETHODCALLTYPE d3d12_command_signature_AddRef(ID3D12CommandSignature *iface)
Definition: command.c:7541
static void STDMETHODCALLTYPE d3d12_command_list_ClearDepthStencilView(ID3D12GraphicsCommandList6 *iface, D3D12_CPU_DESCRIPTOR_HANDLE dsv, D3D12_CLEAR_FLAGS flags, float depth, UINT8 stencil, UINT rect_count, const D3D12_RECT *rects)
Definition: command.c:5142
static void d3d12_command_list_copy_incompatible_texture_region(struct d3d12_command_list *list, struct d3d12_resource *dst_resource, unsigned int dst_sub_resource_idx, const struct vkd3d_format *dst_format, struct d3d12_resource *src_resource, unsigned int src_sub_resource_idx, const struct vkd3d_format *src_format, unsigned int layer_count)
Definition: command.c:3666
static void d3d12_command_queue_swap_queues(struct d3d12_command_queue *queue)
Definition: command.c:7266
static bool contains_heap(struct d3d12_descriptor_heap **heap_array, unsigned int count, const struct d3d12_descriptor_heap *query)
Definition: command.c:3182
static HRESULT d3d12_command_queue_init(struct d3d12_command_queue *queue, struct d3d12_device *device, const D3D12_COMMAND_QUEUE_DESC *desc)
Definition: command.c:7410
static D3D12_FENCE_FLAGS STDMETHODCALLTYPE d3d12_fence_GetCreationFlags(ID3D12Fence1 *iface)
Definition: command.c:1122
static void STDMETHODCALLTYPE d3d12_command_list_IASetIndexBuffer(ID3D12GraphicsCommandList6 *iface, const D3D12_INDEX_BUFFER_VIEW *view)
Definition: command.c:4755
static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence1 *iface, UINT64 value, HANDLE event)
Definition: command.c:1040
static void d3d12_command_queue_delete_aux_ops(struct d3d12_command_queue *queue, unsigned int done_count)
Definition: command.c:7290
static bool d3d12_command_allocator_add_descriptor_pool(struct d3d12_command_allocator *allocator, VkDescriptorPool pool)
Definition: command.c:1379
static struct d3d12_command_allocator * impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface)
Definition: command.c:1609
static VkDescriptorPool d3d12_command_allocator_allocate_descriptor_pool(struct d3d12_command_allocator *allocator)
Definition: command.c:1428
static void vkd3d_queue_update_sequence_number(struct vkd3d_queue *queue, uint64_t sequence_number, struct d3d12_device *device)
Definition: command.c:131
static void d3d12_command_list_reset_state(struct d3d12_command_list *list, ID3D12PipelineState *initial_pipeline_state)
Definition: command.c:2468
HRESULT d3d12_command_list_create(struct d3d12_device *device, UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface, ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list)
Definition: command.c:6262
static uint64_t d3d12_fence_add_pending_timeline_signal(struct d3d12_fence *fence, uint64_t virtual_value, const struct vkd3d_queue *signalling_queue)
Definition: command.c:824
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_SetPrivateDataInterface(ID3D12CommandSignature *iface, REFGUID guid, const IUnknown *data)
Definition: command.c:7584
static void d3d12_command_list_end_current_render_pass(struct d3d12_command_list *list)
Definition: command.c:1961
static struct d3d12_command_allocator * unsafe_impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface)
Definition: command.c:1792
static void vk_extent_3d_from_d3d12_miplevel(VkExtent3D *extent, const D3D12_RESOURCE_DESC1 *resource_desc, unsigned int miplevel_idx)
Definition: command.c:3508
static struct d3d12_command_list * impl_from_ID3D12GraphicsCommandList6(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:1946
static void update_mappings_cleanup(struct vkd3d_cs_update_mappings *update_mappings)
Definition: command.c:6480
static D3D12_COMMAND_QUEUE_DESC *STDMETHODCALLTYPE d3d12_command_queue_GetDesc(ID3D12CommandQueue *iface, D3D12_COMMAND_QUEUE_DESC *desc)
Definition: command.c:7228
static void STDMETHODCALLTYPE d3d12_command_list_EndRenderPass(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:6053
static void STDMETHODCALLTYPE d3d12_command_list_AtomicCopyBufferUINT(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *dst_buffer, UINT64 dst_offset, ID3D12Resource *src_buffer, UINT64 src_offset, UINT dependent_resource_count, ID3D12Resource *const *dependent_resources, const D3D12_SUBRESOURCE_RANGE_UINT64 *dependent_sub_resource_ranges)
Definition: command.c:5948
static void command_list_flush_vk_heap_updates(struct d3d12_command_list *list)
Definition: command.c:3193
static bool d3d12_command_list_begin_render_pass(struct d3d12_command_list *list)
Definition: command.c:3318
static void STDMETHODCALLTYPE d3d12_command_list_BuildRaytracingAccelerationStructure(ID3D12GraphicsCommandList6 *iface, const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *desc, UINT count, const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *postbuild_info_descs)
Definition: command.c:6072
static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy, const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx, const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *format, const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
Definition: command.c:3516
static void d3d12_fence_garbage_collect_vk_semaphores_locked(struct d3d12_fence *fence, bool destroy_all)
Definition: command.c:503
static void d3d12_fence_destroy_vk_objects(struct d3d12_fence *fence)
Definition: command.c:542
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_GetPrivateData(ID3D12CommandSignature *iface, REFGUID guid, UINT *data_size, void *data)
Definition: command.c:7564
static size_t get_query_stride(D3D12_QUERY_TYPE type)
Definition: command.c:5657
static ULONG STDMETHODCALLTYPE d3d12_command_list_Release(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:2338
struct d3d12_command_signature * unsafe_impl_from_ID3D12CommandSignature(ID3D12CommandSignature *iface)
Definition: command.c:7627
static HRESULT d3d12_command_allocator_init(struct d3d12_command_allocator *allocator, struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type)
Definition: command.c:1817
void vkd3d_release_vk_queue(ID3D12CommandQueue *queue)
Definition: command.c:7506
VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue)
Definition: command.c:7493
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRoot32BitConstants(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset)
Definition: command.c:4559
static bool d3d12_command_list_update_compute_pipeline(struct d3d12_command_list *list)
Definition: command.c:2648
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteBundle(ID3D12GraphicsCommandList6 *iface, ID3D12GraphicsCommandList *command_list)
Definition: command.c:4413
static HRESULT d3d12_command_queue_wait_locked(struct d3d12_command_queue *command_queue, struct d3d12_fence *fence, uint64_t value)
Definition: command.c:7053
static void d3d12_command_list_invalidate_bindings(struct d3d12_command_list *list, struct d3d12_pipeline_state *state)
Definition: command.c:1998
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootUnorderedAccessView(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: command.c:4731
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_QueryInterface(ID3D12CommandSignature *iface, REFIID iid, void **out)
Definition: command.c:7519
static const struct ID3D12CommandQueueVtbl d3d12_command_queue_vtbl
Definition: command.c:7239
static bool d3d12_command_allocator_add_render_pass(struct d3d12_command_allocator *allocator, VkRenderPass pass)
Definition: command.c:1356
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootShaderResourceView(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: command.c:4707
static void d3d12_command_signature_decref(struct d3d12_command_signature *signature)
Definition: command.c:1928
HRESULT d3d12_command_allocator_create(struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator **allocator)
Definition: command.c:1895
static void vk_image_subresource_layers_from_d3d12(VkImageSubresourceLayers *subresource, const struct vkd3d_format *format, unsigned int sub_resource_idx, unsigned int miplevel_count)
Definition: command.c:3499
static void STDMETHODCALLTYPE d3d12_command_list_OMSetDepthBounds(ID3D12GraphicsCommandList6 *iface, FLOAT min, FLOAT max)
Definition: command.c:5974
static void STDMETHODCALLTYPE d3d12_command_list_SetPipelineState(ID3D12GraphicsCommandList6 *iface, ID3D12PipelineState *pipeline_state)
Definition: command.c:4129
static void STDMETHODCALLTYPE d3d12_command_list_IASetPrimitiveTopology(ID3D12GraphicsCommandList6 *iface, D3D12_PRIMITIVE_TOPOLOGY topology)
Definition: command.c:4025
static HRESULT d3d12_command_queue_flush_ops(struct d3d12_command_queue *queue, bool *flushed_any)
Definition: command.c:7310
static VkResult vkd3d_queue_create_vk_semaphore_locked(struct vkd3d_queue *queue, struct d3d12_device *device, VkSemaphore *vk_semaphore)
Definition: command.c:199
static void STDMETHODCALLTYPE d3d12_command_queue_ExecuteCommandLists(ID3D12CommandQueue *iface, UINT command_list_count, ID3D12CommandList *const *command_lists)
Definition: command.c:6670
static HRESULT STDMETHODCALLTYPE d3d12_fence_GetDevice(ID3D12Fence1 *iface, REFIID iid, void **device)
Definition: command.c:1018
static HRESULT STDMETHODCALLTYPE d3d12_fence_SetPrivateData(ID3D12Fence1 *iface, REFGUID guid, UINT data_size, const void *data)
Definition: command.c:988
static bool d3d12_command_list_update_compute_state(struct d3d12_command_list *list)
Definition: command.c:3306
static struct d3d12_command_list * unsafe_impl_from_ID3D12CommandList(ID3D12CommandList *iface)
Definition: command.c:6219
static HRESULT d3d12_command_queue_record_as_blocked(struct d3d12_command_queue *command_queue)
Definition: command.c:642
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_GetDevice(ID3D12CommandAllocator *iface, REFIID iid, void **device)
Definition: command.c:1724
static void d3d12_command_list_update_uav_counter_descriptors(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:3024
static void STDMETHODCALLTYPE d3d12_command_list_CopyBufferRegion(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *dst, UINT64 dst_offset, ID3D12Resource *src, UINT64 src_offset, UINT64 byte_count)
Definition: command.c:3467
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_GetTimestampFrequency(ID3D12CommandQueue *iface, UINT64 *frequency)
Definition: command.c:7145
static void STDMETHODCALLTYPE d3d12_command_list_WriteBufferImmediate(ID3D12GraphicsCommandList6 *iface, UINT count, const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *parameters, const D3D12_WRITEBUFFERIMMEDIATE_MODE *modes)
Definition: command.c:6022
static HRESULT STDMETHODCALLTYPE d3d12_command_list_GetDevice(ID3D12GraphicsCommandList6 *iface, REFIID iid, void **device)
Definition: command.c:2405
static struct d3d12_command_signature * impl_from_ID3D12CommandSignature(ID3D12CommandSignature *iface)
Definition: command.c:7514
static void STDMETHODCALLTYPE d3d12_command_queue_UpdateTileMappings(ID3D12CommandQueue *iface, ID3D12Resource *resource, UINT region_count, const D3D12_TILED_RESOURCE_COORDINATE *region_start_coordinates, const D3D12_TILE_REGION_SIZE *region_sizes, ID3D12Heap *heap, UINT range_count, const D3D12_TILE_RANGE_FLAGS *range_flags, const UINT *heap_range_offsets, const UINT *range_tile_counts, D3D12_TILE_MAPPING_FLAGS flags)
Definition: command.c:6489
static void vk_image_buffer_copy_from_d3d12(VkBufferImageCopy *copy, const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx, const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *format, const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
Definition: command.c:3557
static void STDMETHODCALLTYPE d3d12_command_list_CopyResource(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *dst, ID3D12Resource *src)
Definition: command.c:3877
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID3D12GraphicsCommandList6 *iface, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, ID3D12Resource *resource, const UINT values[4], UINT rect_count, const D3D12_RECT *rects)
Definition: command.c:5521
static ULONG STDMETHODCALLTYPE d3d12_command_signature_Release(ID3D12CommandSignature *iface)
Definition: command.c:7551
static void STDMETHODCALLTYPE d3d12_command_list_ResourceBarrier(ID3D12GraphicsCommandList6 *iface, UINT barrier_count, const D3D12_RESOURCE_BARRIER *barriers)
Definition: command.c:4184
static void STDMETHODCALLTYPE d3d12_command_list_SOSetTargets(ID3D12GraphicsCommandList6 *iface, UINT start_slot, UINT view_count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW *views)
Definition: command.c:4872
static void STDMETHODCALLTYPE d3d12_command_queue_CopyTileMappings(ID3D12CommandQueue *iface, ID3D12Resource *dst_resource, const D3D12_TILED_RESOURCE_COORDINATE *dst_region_start_coordinate, ID3D12Resource *src_resource, const D3D12_TILED_RESOURCE_COORDINATE *src_region_start_coordinate, const D3D12_TILE_REGION_SIZE *region_size, D3D12_TILE_MAPPING_FLAGS flags)
Definition: command.c:6592
static HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker, struct d3d12_device *device)
Definition: command.c:399
static void d3d12_command_allocator_remove_command_list(struct d3d12_command_allocator *allocator, const struct d3d12_command_list *list)
Definition: command.c:1349
void vkd3d_queue_release(struct vkd3d_queue *queue)
Definition: command.c:101
static bool d3d12_command_list_update_graphics_pipeline(struct d3d12_command_list *list)
Definition: command.c:2669
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootConstantBufferView(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: command.c:4646
static void STDMETHODCALLTYPE d3d12_command_list_OMSetStencilRef(ID3D12GraphicsCommandList6 *iface, UINT stencil_ref)
Definition: command.c:4117
static void d3d12_fence_update_pending_value_locked(struct d3d12_fence *fence)
Definition: command.c:620
static void d3d12_command_list_set_root_cbv(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, unsigned int index, D3D12_GPU_VIRTUAL_ADDRESS gpu_address)
Definition: command.c:4583
static void d3d12_fence_decref(struct d3d12_fence *fence)
Definition: command.c:955
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootSignature(ID3D12GraphicsCommandList6 *iface, ID3D12RootSignature *root_signature)
Definition: command.c:4445
static UINT64 STDMETHODCALLTYPE d3d12_fence_GetCompletedValue(ID3D12Fence1 *iface)
Definition: command.c:1027
static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView(ID3D12GraphicsCommandList6 *iface, D3D12_CPU_DESCRIPTOR_HANDLE rtv, const FLOAT color[4], UINT rect_count, const D3D12_RECT *rects)
Definition: command.c:5191
static HRESULT d3d12_device_flush_blocked_queues(struct d3d12_device *device)
Definition: command.c:695
static void d3d12_command_list_mark_as_invalid(struct d3d12_command_list *list, const char *message,...)
Definition: command.c:1259
static struct d3d12_command_queue * impl_from_ID3D12CommandQueue(ID3D12CommandQueue *iface)
Definition: command.c:6302
static ULONG STDMETHODCALLTYPE d3d12_fence_AddRef(ID3D12Fence1 *iface)
Definition: command.c:927
static void d3d12_command_signature_incref(struct d3d12_command_signature *signature)
Definition: command.c:1923
static void d3d12_command_list_set_descriptor_table(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, unsigned int index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
Definition: command.c:4467
static void STDMETHODCALLTYPE d3d12_command_list_OMSetBlendFactor(ID3D12GraphicsCommandList6 *iface, const FLOAT blend_factor[4])
Definition: command.c:4105
static void STDMETHODCALLTYPE d3d12_command_list_DispatchRays(ID3D12GraphicsCommandList6 *iface, const D3D12_DISPATCH_RAYS_DESC *desc)
Definition: command.c:6101
static void STDMETHODCALLTYPE d3d12_command_list_BeginEvent(ID3D12GraphicsCommandList6 *iface, UINT metadata, const void *data, UINT size)
Definition: command.c:5827
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_SetPrivateData(ID3D12CommandSignature *iface, REFGUID guid, UINT data_size, const void *data)
Definition: command.c:7574
static void STDMETHODCALLTYPE d3d12_command_list_SetComputeRootDescriptorTable(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_DESCRIPTOR_HANDLE base_descriptor)
Definition: command.c:4498
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateData(ID3D12GraphicsCommandList6 *iface, REFGUID guid, UINT data_size, const void *data)
Definition: command.c:2376
static void STDMETHODCALLTYPE d3d12_command_list_CopyRaytracingAccelerationStructure(ID3D12GraphicsCommandList6 *iface, D3D12_GPU_VIRTUAL_ADDRESS dst_structure_data, D3D12_GPU_VIRTUAL_ADDRESS src_structure_data, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE mode)
Definition: command.c:6087
static HRESULT vkd3d_enqueue_gpu_fence(struct vkd3d_fence_worker *worker, VkFence vk_fence, struct d3d12_fence *fence, uint64_t value, struct vkd3d_queue *queue, uint64_t queue_sequence_number)
Definition: command.c:236
static void d3d12_command_queue_op_array_init(struct d3d12_command_queue_op_array *array)
Definition: command.c:7403
uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue)
Definition: command.c:7486
static HRESULT STDMETHODCALLTYPE d3d12_command_list_GetPrivateData(ID3D12GraphicsCommandList6 *iface, REFGUID guid, UINT *data_size, void *data)
Definition: command.c:2366
static void d3d12_command_list_update_virtual_descriptors(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point)
Definition: command.c:3076
static void * vkd3d_fence_worker_main(void *arg)
Definition: command.c:324
static void d3d12_fence_release_vk_semaphore(struct d3d12_fence *fence, struct vkd3d_signaled_semaphore *semaphore)
Definition: command.c:610
static bool is_ds_multiplanar_resolvable(unsigned int first_state, unsigned int second_state)
Definition: command.c:4146
static void d3d12_command_list_track_resource_usage(struct d3d12_command_list *list, struct d3d12_resource *resource)
Definition: command.c:2283
static void vkd3d_buffer_destroy(struct vkd3d_buffer *buffer, struct d3d12_device *device)
Definition: command.c:1529
static void d3d12_command_list_set_root_constants(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, unsigned int index, unsigned int offset, unsigned int count, const void *data)
Definition: command.c:4522
static void d3d12_command_list_check_index_buffer_strip_cut_value(struct d3d12_command_list *list)
Definition: command.c:3370
static void d3d12_command_queue_destroy_op(struct vkd3d_cs_op_data *op)
Definition: command.c:6339
static HRESULT d3d12_command_allocator_allocate_command_buffer(struct d3d12_command_allocator *allocator, struct d3d12_command_list *list)
Definition: command.c:1295
struct vkd3d_queue * d3d12_device_get_vkd3d_queue(struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type)
Definition: command.c:1800
static void STDMETHODCALLTYPE d3d12_command_list_RSSetShadingRate(ID3D12GraphicsCommandList6 *iface, D3D12_SHADING_RATE rate, const D3D12_SHADING_RATE_COMBINER *combiners)
Definition: command.c:6107
static void STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCommandList6 *iface, ID3D12PipelineState *pipeline_state)
Definition: command.c:2541
static struct vkd3d_view * create_uint_view(struct d3d12_device *device, const struct vkd3d_resource_view *view, struct d3d12_resource *resource, VkClearColorValue *colour)
Definition: command.c:5475
static ULONG STDMETHODCALLTYPE d3d12_command_allocator_AddRef(ID3D12CommandAllocator *iface)
Definition: command.c:1636
static void STDMETHODCALLTYPE d3d12_command_list_EndEvent(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:5833
static void d3d12_command_list_allocator_destroyed(struct d3d12_command_list *list)
Definition: command.c:1521
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootSignature(ID3D12GraphicsCommandList6 *iface, ID3D12RootSignature *root_signature)
Definition: command.c:4456
HRESULT d3d12_command_queue_create(struct d3d12_device *device, const D3D12_COMMAND_QUEUE_DESC *desc, struct d3d12_command_queue **queue)
Definition: command.c:7464
static void d3d12_fence_signal_timeline_semaphore(struct d3d12_fence *fence, uint64_t timeline_value)
Definition: command.c:864
static VkDescriptorSet d3d12_command_allocator_allocate_descriptor_set(struct d3d12_command_allocator *allocator, VkDescriptorSetLayout vk_set_layout, unsigned int variable_binding_size, bool unbounded)
Definition: command.c:1469
HRESULT vkd3d_queue_create(struct d3d12_device *device, uint32_t family_index, const VkQueueFamilyProperties *properties, struct vkd3d_queue **queue)
Definition: command.c:34
static VkResult vkd3d_queue_wait_idle(struct vkd3d_queue *queue, const struct vkd3d_vk_device_procs *vk_procs)
Definition: command.c:108
static void d3d12_command_queue_execute(struct d3d12_command_queue *command_queue, VkCommandBuffer *buffers, unsigned int count)
Definition: command.c:6631
static void d3d12_command_queue_submit_locked(struct d3d12_command_queue *queue)
Definition: command.c:6658
static HRESULT STDMETHODCALLTYPE d3d12_command_list_Close(ID3D12GraphicsCommandList6 *iface)
Definition: command.c:2424
static bool d3d12_command_allocator_add_view(struct d3d12_command_allocator *allocator, struct vkd3d_view *view)
Definition: command.c:1391
static void STDMETHODCALLTYPE d3d12_command_list_Dispatch(ID3D12GraphicsCommandList6 *iface, UINT x, UINT y, UINT z)
Definition: command.c:3448
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_Signal(ID3D12CommandQueue *iface, ID3D12Fence *fence_iface, UINT64 value)
Definition: command.c:6775
static void vk_image_copy_from_d3d12(VkImageCopy *image_copy, unsigned int src_sub_resource_idx, unsigned int dst_sub_resource_idx, const D3D12_RESOURCE_DESC1 *src_desc, const D3D12_RESOURCE_DESC1 *dst_desc, const struct vkd3d_format *src_format, const struct vkd3d_format *dst_format, const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
Definition: command.c:3587
static const struct d3d12_root_parameter * root_signature_get_root_descriptor(const struct d3d12_root_signature *root_signature, unsigned int index)
Definition: command.c:447
static HRESULT d3d12_command_list_allocate_transfer_buffer(struct d3d12_command_list *list, VkDeviceSize size, struct vkd3d_buffer *buffer)
Definition: command.c:3616
static void STDMETHODCALLTYPE d3d12_command_list_EmitRaytracingAccelerationStructurePostbuildInfo(ID3D12GraphicsCommandList6 *iface, const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *desc, UINT structures_count, const D3D12_GPU_VIRTUAL_ADDRESS *src_structure_data)
Definition: command.c:6079
static void d3d12_command_list_clear(struct d3d12_command_list *list, const struct VkAttachmentDescription *attachment_desc, const struct VkAttachmentReference *color_reference, const struct VkAttachmentReference *ds_reference, struct vkd3d_view *view, size_t width, size_t height, unsigned int layer_count, const union VkClearValue *clear_value, unsigned int rect_count, const D3D12_RECT *rects)
Definition: command.c:5034
static HRESULT STDMETHODCALLTYPE d3d12_fence_QueryInterface(ID3D12Fence1 *iface, REFIID riid, void **object)
Definition: command.c:904
static void STDMETHODCALLTYPE d3d12_command_list_SetSamplePositions(ID3D12GraphicsCommandList6 *iface, UINT sample_count, UINT pixel_count, D3D12_SAMPLE_POSITION *sample_positions)
Definition: command.c:5998
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_SetPrivateDataInterface(ID3D12CommandQueue *iface, REFGUID guid, const IUnknown *data)
Definition: command.c:6418
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRoot32BitConstants(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, UINT constant_count, const void *data, UINT dst_offset)
Definition: command.c:4571
VkQueue vkd3d_queue_acquire(struct vkd3d_queue *queue)
Definition: command.c:91
static ULONG STDMETHODCALLTYPE d3d12_command_queue_AddRef(ID3D12CommandQueue *iface)
Definition: command.c:6329
static HRESULT STDMETHODCALLTYPE d3d12_fence_Signal(ID3D12Fence1 *iface, UINT64 value)
Definition: command.c:1111
static void d3d12_command_list_bind_descriptor_heap(struct d3d12_command_list *list, enum vkd3d_pipeline_bind_point bind_point, struct d3d12_descriptor_heap *heap)
Definition: command.c:3226
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteIndirect(ID3D12GraphicsCommandList6 *iface, ID3D12CommandSignature *command_signature, UINT max_command_count, ID3D12Resource *arg_buffer, UINT64 arg_buffer_offset, ID3D12Resource *count_buffer, UINT64 count_buffer_offset)
Definition: command.c:5842
static HRESULT STDMETHODCALLTYPE d3d12_fence_GetPrivateData(ID3D12Fence1 *iface, REFGUID guid, UINT *data_size, void *data)
Definition: command.c:977
static HRESULT d3d12_fence_init(struct d3d12_fence *fence, struct d3d12_device *device, UINT64 initial_value, D3D12_FENCE_FLAGS flags)
Definition: command.c:1162
static void STDMETHODCALLTYPE d3d12_command_list_ResolveQueryData(ID3D12GraphicsCommandList6 *iface, ID3D12QueryHeap *heap, D3D12_QUERY_TYPE type, UINT start_index, UINT query_count, ID3D12Resource *dst_buffer, UINT64 aligned_dst_buffer_offset)
Definition: command.c:5668
static HRESULT vkd3d_enqueue_timeline_semaphore(struct vkd3d_fence_worker *worker, VkSemaphore vk_semaphore, struct d3d12_fence *fence, uint64_t value, struct vkd3d_queue *queue)
Definition: command.c:6745
static void STDMETHODCALLTYPE d3d12_command_queue_SetMarker(ID3D12CommandQueue *iface, UINT metadata, const void *data, UINT size)
Definition: command.c:6726
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootUnorderedAccessView(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: command.c:4743
static void STDMETHODCALLTYPE d3d12_command_list_SetGraphicsRootShaderResourceView(ID3D12GraphicsCommandList6 *iface, UINT root_parameter_index, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: command.c:4719
static void d3d12_command_list_invalidate_current_render_pass(struct d3d12_command_list *list)
Definition: command.c:1993
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_GetDevice(ID3D12CommandQueue *iface, REFIID iid, void **device)
Definition: command.c:6448
static void STDMETHODCALLTYPE d3d12_command_list_SetProtectedResourceSession(ID3D12GraphicsCommandList6 *iface, ID3D12ProtectedResourceSession *protected_session)
Definition: command.c:6039
static bool d3d12_command_allocator_add_framebuffer(struct d3d12_command_allocator *allocator, VkFramebuffer framebuffer)
Definition: command.c:1367
static HRESULT d3d12_command_queue_flush_ops_locked(struct d3d12_command_queue *queue, bool *flushed_any)
Definition: command.c:7333
static void STDMETHODCALLTYPE d3d12_command_queue_BeginEvent(ID3D12CommandQueue *iface, UINT metadata, const void *data, UINT size)
Definition: command.c:6733
static void d3d12_command_list_clear_uav(struct d3d12_command_list *list, struct d3d12_resource *resource, struct vkd3d_view *descriptor, const VkClearColorValue *clear_colour, unsigned int rect_count, const D3D12_RECT *rects)
Definition: command.c:5309
static void STDMETHODCALLTYPE d3d12_command_list_BeginRenderPass(ID3D12GraphicsCommandList6 *iface, UINT count, const D3D12_RENDER_PASS_RENDER_TARGET_DESC *render_targets, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *depth_stencil, D3D12_RENDER_PASS_FLAGS flags)
Definition: command.c:6045
static bool d3d12_command_list_update_current_framebuffer(struct d3d12_command_list *list)
Definition: command.c:2579
static void vkd3d_wait_for_gpu_fence(struct vkd3d_fence_worker *worker, const struct vkd3d_waiting_fence *waiting_fence)
Definition: command.c:298
static void STDMETHODCALLTYPE d3d12_command_list_DiscardResource(ID3D12GraphicsCommandList6 *iface, ID3D12Resource *resource, const D3D12_DISCARD_REGION *region)
Definition: command.c:5587
static bool d3d12_command_queue_op_array_append(struct d3d12_command_queue_op_array *array, size_t count, const struct vkd3d_cs_op_data *new_ops)
Definition: command.c:7275
static VkResult d3d12_fence_create_vk_fence(struct d3d12_fence *fence, VkFence *vk_fence)
Definition: command.c:463
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_SetPrivateData(ID3D12CommandQueue *iface, REFGUID guid, UINT data_size, const void *data)
Definition: command.c:6408
HRESULT d3d12_command_signature_create(struct d3d12_device *device, const D3D12_COMMAND_SIGNATURE_DESC *desc, struct d3d12_command_signature **signature)
Definition: command.c:7635
struct __type_info type_info
D3D12_RENDER_PASS_FLAGS
Definition: d3d12.idl:4615
D3D12_RESOLVE_MODE
Definition: d3d12.idl:1049
D3D12_WRITEBUFFERIMMEDIATE_MODE
Definition: d3d12.idl:556
const UINT D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE
Definition: d3d12.idl:434
@ D3D12_RESOURCE_STATE_RESOLVE_DEST
Definition: d3d12.idl:917
@ D3D12_RESOURCE_STATE_INDEX_BUFFER
Definition: d3d12.idl:906
@ D3D12_RESOURCE_STATE_COPY_DEST
Definition: d3d12.idl:915
@ D3D12_RESOURCE_STATE_RENDER_TARGET
Definition: d3d12.idl:907
@ D3D12_RESOURCE_STATE_COPY_SOURCE
Definition: d3d12.idl:916
@ D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
Definition: d3d12.idl:912
@ D3D12_RESOURCE_STATE_UNORDERED_ACCESS
Definition: d3d12.idl:908
@ D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT
Definition: d3d12.idl:914
@ D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE
Definition: d3d12.idl:911
@ D3D12_RESOURCE_STATE_DEPTH_WRITE
Definition: d3d12.idl:909
@ D3D12_RESOURCE_STATE_DEPTH_READ
Definition: d3d12.idl:910
@ D3D12_RESOURCE_STATE_STREAM_OUT
Definition: d3d12.idl:913
@ D3D12_RESOURCE_STATE_COMMON
Definition: d3d12.idl:904
@ D3D12_RESOURCE_STATE_RESOLVE_SOURCE
Definition: d3d12.idl:918
@ D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
Definition: d3d12.idl:905
@ D3D12_RESOURCE_STATE_PRESENT
Definition: d3d12.idl:923
D3D12_PREDICATION_OP
Definition: d3d12.idl:2755
@ D3D12_PREDICATION_OP_NOT_EQUAL_ZERO
Definition: d3d12.idl:2757
@ D3D12_PREDICATION_OP_EQUAL_ZERO
Definition: d3d12.idl:2756
@ D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY
Definition: d3d12.idl:944
@ D3D12_RESOURCE_BARRIER_FLAG_END_ONLY
Definition: d3d12.idl:945
const UINT D3D12_MAX_ROOT_COST
Definition: d3d12.idl:280
D3D12_COMMAND_LIST_TYPE
Definition: d3d12.idl:2188
@ D3D12_COMMAND_LIST_TYPE_COPY
Definition: d3d12.idl:2192
@ D3D12_COMMAND_LIST_TYPE_DIRECT
Definition: d3d12.idl:2189
@ D3D12_COMMAND_LIST_TYPE_COMPUTE
Definition: d3d12.idl:2191
D3D12_DISPATCH_RAYS_DESC
Definition: d3d12.idl:4645
D3D12_TILE_MAPPING_FLAGS
Definition: d3d12.idl:3014
D3D12_SHADING_RATE_COMBINER
Definition: d3d12.idl:5055
@ D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME
Definition: d3d12.idl:2202
@ D3D12_RESOURCE_DIMENSION_BUFFER
Definition: d3d12.idl:983
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE
Definition: d3d12.idl:3867
@ D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL
Definition: d3d12.idl:1001
@ D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE
Definition: d3d12.idl:1003
D3D12_SHADING_RATE
Definition: d3d12.idl:5044
D3D12_CLEAR_FLAGS
Definition: d3d12.idl:2687
@ D3D12_CLEAR_FLAG_STENCIL
Definition: d3d12.idl:2689
@ D3D12_CLEAR_FLAG_DEPTH
Definition: d3d12.idl:2688
@ D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE
Definition: d3d12.idl:1431
D3D12_QUERY_TYPE
Definition: d3d12.idl:2702
@ D3D12_QUERY_TYPE_OCCLUSION
Definition: d3d12.idl:2703
@ D3D12_QUERY_TYPE_SO_STATISTICS_STREAM3
Definition: d3d12.idl:2710
@ D3D12_QUERY_TYPE_BINARY_OCCLUSION
Definition: d3d12.idl:2704
@ D3D12_QUERY_TYPE_TIMESTAMP
Definition: d3d12.idl:2705
@ D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0
Definition: d3d12.idl:2707
@ D3D12_QUERY_TYPE_PIPELINE_STATISTICS
Definition: d3d12.idl:2706
@ D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT
Definition: d3d12.idl:1067
@ D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX
Definition: d3d12.idl:1066
@ D3D12_HEAP_FLAG_NONE
Definition: d3d12.idl:813
const UINT D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT
Definition: d3d12.idl:378
@ D3D12_TEXTURE_LAYOUT_ROW_MAJOR
Definition: d3d12.idl:992
@ D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH
Definition: d3d12.idl:3092
@ D3D12_INDIRECT_ARGUMENT_TYPE_DRAW
Definition: d3d12.idl:3090
@ D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED
Definition: d3d12.idl:3091
@ D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE
Definition: d3d12.idl:1177
@ D3D12_ROOT_PARAMETER_TYPE_SRV
Definition: d3d12.idl:1180
@ D3D12_ROOT_PARAMETER_TYPE_UAV
Definition: d3d12.idl:1181
@ D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS
Definition: d3d12.idl:1178
@ D3D12_ROOT_PARAMETER_TYPE_CBV
Definition: d3d12.idl:1179
@ D3D12_RESOURCE_BARRIER_TYPE_UAV
Definition: d3d12.idl:938
@ D3D12_RESOURCE_BARRIER_TYPE_TRANSITION
Definition: d3d12.idl:936
@ D3D12_RESOURCE_BARRIER_TYPE_ALIASING
Definition: d3d12.idl:937
@ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV
Definition: d3d12.idl:1421
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF
Definition: d3d12.idl:2061
@ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF
Definition: d3d12.idl:2062
@ D3D12_HEAP_TYPE_DEFAULT
Definition: d3d12.idl:781
const UINT D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES
Definition: d3d12.idl:366
UINT64 D3D12_GPU_VIRTUAL_ADDRESS
Definition: d3d12.idl:1443
D3D_PRIMITIVE_TOPOLOGY
Definition: d3dcommon.idl:384
@ D3D_PRIMITIVE_TOPOLOGY_POINTLIST
Definition: d3dcommon.idl:386
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
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
UINT op
Definition: effect.c:235
GUID guid
Definition: version.c:147
unsigned int uintptr_t
Definition: corecrt.h:185
#define PRIuPTR
Definition: inttypes.h:226
#define PRIx64
Definition: inttypes.h:29
#define PRIu64
Definition: inttypes.h:28
#define UINT_MAX
Definition: limits.h:27
#define isnan(x)
Definition: math.h:360
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
#define UINT64_MAX
Definition: stdint.h:86
char * va_list
Definition: vadefs.h:50
static HRESULT hresult_from_vk_result(VkResult vr)
Definition: swapchain.c:1114
DXGI_FORMAT
Definition: dxgiformat.idl:22
@ DXGI_FORMAT_R16_UINT
Definition: dxgiformat.idl:80
@ DXGI_FORMAT_UNKNOWN
Definition: dxgiformat.idl:23
@ DXGI_FORMAT_R11G11B10_FLOAT
Definition: dxgiformat.idl:49
@ DXGI_FORMAT_R32_UINT
Definition: dxgiformat.idl:65
@ DXGI_FORMAT_B4G4R4A4_UNORM
Definition: dxgiformat.idl:138
@ DXGI_FORMAT_B5G6R5_UNORM
Definition: dxgiformat.idl:108
@ DXGI_FORMAT_B5G5R5A1_UNORM
Definition: dxgiformat.idl:109
static void depth_stencil(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: ffp_gl.c:766
unsigned int BOOL
Definition: ntddk_ex.h:94
static const FxOffsetAndName offsets[]
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizei stride
Definition: glext.h:5848
GLuint address
Definition: glext.h:9393
GLenum src
Definition: glext.h:6340
const GLuint * pipelines
Definition: glext.h:7624
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint color
Definition: glext.h:6243
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLenum GLint GLuint mask
Definition: glext.h:6028
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLenum mode
Definition: glext.h:6217
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
GLbitfield flags
Definition: glext.h:7161
GLint GLint bottom
Definition: glext.h:7726
const GLint * first
Definition: glext.h:5794
GLuint framebuffer
Definition: glext.h:6995
GLfloat GLfloat p
Definition: glext.h:8902
const GLuint * buffers
Definition: glext.h:5916
GLint GLfloat GLint stencil
Definition: glext.h:6260
GLdouble GLdouble z
Definition: glext.h:5874
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
#define c
Definition: ke_i.h:80
#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
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
struct task_struct * current
Definition: linux.c:32
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
UINT constant_count
Definition: shader.c:5886
static const char * dst_format
Definition: dib.c:1339
static HANDLE semaphore
Definition: loader.c:2947
static LARGE_INTEGER * frequency
Definition: time.c:38
static BYTE parameters[]
Definition: asn.c:558
#define min(a, b)
Definition: monoChain.cc:55
static const struct @662 sizes[]
int k
Definition: mpi.c:3369
#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
#define list
Definition: rosglue.h:35
descriptor
Definition: scsi.h:3997
#define memset(x, y, z)
Definition: compat.h:39
void d3d12_device_mark_as_removed(struct d3d12_device *device, HRESULT reason, const char *message,...)
Definition: device.c:5556
void * vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2495
HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_handle *thread)
Definition: device.c:5663
HRESULT vkd3d_create_thread(struct vkd3d_instance *instance, PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread)
Definition: device.c:5620
void d3d12_desc_flush_vk_heap_updates_locked(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device)
Definition: resource.c:2639
void vkd3d_view_decref(void *view, struct d3d12_device *device)
Definition: resource.c:2453
struct d3d12_heap * unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface)
Definition: resource.c:442
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
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
bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource)
Definition: resource.c:1029
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
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
struct d3d12_query_heap * unsafe_impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface)
Definition: resource.c:4560
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
struct d3d12_root_signature * unsafe_impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
Definition: state.c:193
VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_state *state, D3D12_PRIMITIVE_TOPOLOGY topology, const uint32_t *strides, VkFormat dsv_format, VkRenderPass *vk_render_pass)
Definition: state.c:3827
struct d3d12_pipeline_state * unsafe_impl_from_ID3D12PipelineState(ID3D12PipelineState *iface)
Definition: state.c:2242
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
HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store, const GUID *tag, const IUnknown *object)
Definition: utils.c:1046
bool is_write_resource_state(D3D12_RESOURCE_STATES state)
Definition: utils.c:575
const struct vkd3d_format * vkd3d_get_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
Definition: utils.c:442
const char * debug_gpu_handle(D3D12_GPU_DESCRIPTOR_HANDLE handle)
Definition: utils.c:691
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
const struct vkd3d_format * vkd3d_find_uint_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
Definition: utils.c:465
const char * debug_cpu_handle(D3D12_CPU_DESCRIPTOR_HANDLE handle)
Definition: utils.c:645
HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store, const GUID *tag, unsigned int *out_size, void *out)
Definition: utils.c:994
#define args
Definition: format.c:66
#define TRACE(s)
Definition: solgame.cpp:4
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
@ unbounded
Definition: strnlen.cpp:29
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
const D3D12_INDIRECT_ARGUMENT_DESC * pArgumentDescs
Definition: d3d12.idl:3137
D3D12_DESCRIPTOR_HEAP_FLAGS Flags
Definition: d3d12.idl:1439
D3D12_HEAP_TYPE Type
Definition: d3d12.idl:804
D3D12_INDIRECT_ARGUMENT_TYPE Type
Definition: d3d12.idl:3105
D3D12_SUBRESOURCE_FOOTPRINT Footprint
Definition: d3d12.idl:1082
D3D12_RESOURCE_TRANSITION_BARRIER Transition
Definition: d3d12.idl:974
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
UINT16 DepthOrArraySize
Definition: d3d12.idl:1039
D3D12_RESOURCE_STATES StateBefore
Definition: d3d12.idl:953
ID3D12Resource * pResource
Definition: d3d12.idl:951
D3D12_RESOURCE_STATES StateAfter
Definition: d3d12.idl:954
ID3D12Resource * pResource
Definition: d3d12.idl:965
D3D12_GPU_VIRTUAL_ADDRESS BufferFilledSizeLocation
Definition: d3d12.idl:2683
D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
Definition: d3d12.idl:2681
D3D12_GPU_VIRTUAL_ADDRESS BufferLocation
Definition: d3d12.idl:2674
FLOAT Height
Definition: d3d12.idl:671
FLOAT MaxDepth
Definition: d3d12.idl:673
FLOAT TopLeftX
Definition: d3d12.idl:668
FLOAT Width
Definition: d3d12.idl:670
FLOAT TopLeftY
Definition: d3d12.idl:669
FLOAT MinDepth
Definition: d3d12.idl:672
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
VkAttachmentLoadOp loadOp
Definition: vulkan.h:7355
VkAttachmentStoreOp stencilStoreOp
Definition: vulkan.h:7358
VkSampleCountFlagBits samples
Definition: vulkan.h:7354
VkAttachmentDescriptionFlags flags
Definition: vulkan.h:7352
VkAttachmentStoreOp storeOp
Definition: vulkan.h:7356
VkImageLayout initialLayout
Definition: vulkan.h:7359
VkImageLayout finalLayout
Definition: vulkan.h:7360
VkAttachmentLoadOp stencilLoadOp
Definition: vulkan.h:7357
uint32_t attachment
Definition: vulkan.h:7390
VkImageLayout layout
Definition: vulkan.h:7391
VkAccessFlags srcAccessMask
Definition: vulkan.h:7632
VkAccessFlags dstAccessMask
Definition: vulkan.h:7633
uint32_t srcQueueFamilyIndex
Definition: vulkan.h:7634
const void * pNext
Definition: vulkan.h:7631
VkStructureType sType
Definition: vulkan.h:7630
uint32_t dstQueueFamilyIndex
Definition: vulkan.h:7635
VkStructureType sType
Definition: vulkan.h:7694
VkTimeDomainKHR timeDomain
Definition: vulkan.h:7696
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
VkConditionalRenderingFlagsEXT flags
Definition: vulkan.h:7901
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
VkStructureType sType
Definition: vulkan.h:8285
const VkDescriptorSetLayout * pSetLayouts
Definition: vulkan.h:8289
uint32_t width
Definition: vulkan.h:8666
uint32_t height
Definition: vulkan.h:8667
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
const VkImageView * pAttachments
Definition: vulkan.h:8821
VkStructureType sType
Definition: vulkan.h:8816
VkFramebufferCreateFlags flags
Definition: vulkan.h:8818
const void * pNext
Definition: vulkan.h:8817
uint32_t attachmentCount
Definition: vulkan.h:8820
VkExtent3D extent
Definition: vulkan.h:16373
VkOffset3D srcOffset
Definition: vulkan.h:16370
VkImageSubresourceLayers srcSubresource
Definition: vulkan.h:16369
VkImageSubresourceLayers dstSubresource
Definition: vulkan.h:16371
VkOffset3D dstOffset
Definition: vulkan.h:16372
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
VkImageSubresourceLayers dstSubresource
Definition: vulkan.h:16423
VkOffset3D srcOffset
Definition: vulkan.h:16422
VkImageSubresourceLayers srcSubresource
Definition: vulkan.h:16421
VkExtent3D extent
Definition: vulkan.h:16425
VkOffset3D dstOffset
Definition: vulkan.h:16424
VkImageAspectFlags aspectMask
Definition: vulkan.h:9065
uint32_t baseArrayLayer
Definition: vulkan.h:9076
VkImageAspectFlags aspectMask
Definition: vulkan.h:9073
VkStructureType sType
Definition: vulkan.h:9359
const void * pNext
Definition: vulkan.h:9360
VkAccessFlags dstAccessMask
Definition: vulkan.h:9362
VkAccessFlags srcAccessMask
Definition: vulkan.h:9361
int32_t x
Definition: vulkan.h:9573
int32_t y
Definition: vulkan.h:9574
int32_t x
Definition: vulkan.h:9579
int32_t y
Definition: vulkan.h:9580
int32_t z
Definition: vulkan.h:9581
uint32_t maxUniformBufferRange
Definition: vulkan.h:11068
uint32_t maxComputeWorkGroupCount[3]
Definition: vulkan.h:11114
uint32_t timestampValidBits
Definition: vulkan.h:13538
VkQueueFlags queueFlags
Definition: vulkan.h:13536
VkExtent2D extent
Definition: vulkan.h:13605
VkOffset2D offset
Definition: vulkan.h:13604
const void * pNext
Definition: vulkan.h:13643
const VkClearValue * pClearValues
Definition: vulkan.h:13648
VkStructureType sType
Definition: vulkan.h:13642
uint32_t clearValueCount
Definition: vulkan.h:13647
uint32_t attachmentCount
Definition: vulkan.h:16759
VkStructureType sType
Definition: vulkan.h:16756
const VkSubpassDescription * pSubpasses
Definition: vulkan.h:16762
const void * pNext
Definition: vulkan.h:16757
const VkSubpassDependency * pDependencies
Definition: vulkan.h:16764
const VkAttachmentDescription * pAttachments
Definition: vulkan.h:16760
VkRenderPassCreateFlags flags
Definition: vulkan.h:16758
uint32_t dependencyCount
Definition: vulkan.h:16763
VkStructureType sType
Definition: vulkan.h:13937
VkSemaphoreCreateFlags flags
Definition: vulkan.h:13939
const void * pNext
Definition: vulkan.h:13938
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 VkAttachmentReference * pDepthStencilAttachment
Definition: vulkan.h:14216
VkSubpassDescriptionFlags flags
Definition: vulkan.h:14209
uint32_t inputAttachmentCount
Definition: vulkan.h:14211
const VkAttachmentReference * pResolveAttachments
Definition: vulkan.h:14215
const uint32_t * pPreserveAttachments
Definition: vulkan.h:14218
const VkAttachmentReference * pInputAttachments
Definition: vulkan.h:14212
uint32_t colorAttachmentCount
Definition: vulkan.h:14213
const VkAttachmentReference * pColorAttachments
Definition: vulkan.h:14214
VkPipelineBindPoint pipelineBindPoint
Definition: vulkan.h:14210
uint32_t preserveAttachmentCount
Definition: vulkan.h:14217
const uint64_t * pWaitSemaphoreValues
Definition: vulkan.h:14454
const uint64_t * pSignalSemaphoreValues
Definition: vulkan.h:14456
float y
Definition: vulkan.h:15222
float maxDepth
Definition: vulkan.h:15226
float x
Definition: vulkan.h:15221
float width
Definition: vulkan.h:15223
float height
Definition: vulkan.h:15224
float minDepth
Definition: vulkan.h:15225
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: match.c:390
Definition: undname.c:54
Definition: palette.c:466
ID3D12CommandAllocator ID3D12CommandAllocator_iface
ID3D12GraphicsCommandList6 ID3D12GraphicsCommandList6_iface
unsigned int refcount
VkCommandBuffer vk_command_buffer
struct d3d12_command_allocator * allocator
struct vkd3d_private_store private_store
D3D12_COMMAND_QUEUE_DESC desc
const struct d3d12_fence * last_waited_fence
ID3D12CommandQueue ID3D12CommandQueue_iface
struct d3d12_command_queue_op_array op_queue
struct vkd3d_mutex op_mutex
unsigned int refcount
struct d3d12_device * device
uint64_t last_waited_fence_value
struct d3d12_command_queue_op_array aux_op_queue
struct vkd3d_queue * vkd3d_queue
struct vkd3d_fence_worker fence_worker
ID3D12CommandSignature ID3D12CommandSignature_iface
D3D12_COMMAND_SIGNATURE_DESC desc
D3D12_DESCRIPTOR_HEAP_DESC desc
VkDescriptorSetLayout vk_layout
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
uint64_t pending_timeline_value
struct vkd3d_signaled_semaphore * semaphores
struct vkd3d_mutex mutex
uint64_t timeline_value
struct vkd3d_cond null_event_cond
unsigned int internal_refcount
struct d3d12_fence::vkd3d_waiting_event * events
D3D12_FENCE_FLAGS flags
size_t event_count
uint64_t value
size_t events_size
ID3D12Fence1 ID3D12Fence1_iface
struct vkd3d_private_store private_store
unsigned int semaphore_count
unsigned int refcount
VkFence old_vk_fences[VKD3D_MAX_VK_SYNC_OBJECTS]
struct d3d12_device * device
VkSemaphore timeline_semaphore
size_t semaphores_size
uint64_t max_pending_value
VkPipelineDepthStencilStateCreateInfo ds_desc
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE index_buffer_strip_cut_value
VkQueryPool vk_query_pool
union d3d12_resource::@6027 u
struct d3d12_resource_tile_info tiles
D3D12_GPU_VIRTUAL_ADDRESS gpu_address
const struct vkd3d_format * format
D3D12_RESOURCE_DESC1 desc
VkBuffer vk_buffer
struct d3d12_root_descriptor_table_range * ranges
union d3d12_root_parameter::@6033 u
struct d3d12_root_descriptor descriptor
D3D12_ROOT_PARAMETER_TYPE parameter_type
uint64_t descriptor_table_mask
uint32_t push_descriptor_mask
struct d3d12_descriptor_set_layout descriptor_set_layouts[VKD3D_MAX_DESCRIPTOR_SETS]
unsigned int descriptor_table_offset
struct d3d12_root_parameter * parameters
VkPipelineLayout vk_pipeline_layout
struct vkd3d_view * view
VkSampleCountFlagBits sample_count
unsigned int height
unsigned int layer_count
const struct vkd3d_format * format
struct d3d12_resource * resource
Definition: devices.h:37
Definition: filter.c:185
Definition: heap.c:86
char buffer[256]
Definition: notification.c:80
Definition: tftpd.h:60
Definition: name.c:39
Definition: queue.c:179
const struct queue_ops * ops
Definition: queue.c:181
enum view_type type
VkBuffer vk_buffer
struct vkd3d_cs_update_mappings update_mappings
struct vkd3d_queue * queue
void(* wait_for_gpu_fence)(struct vkd3d_fence_worker *worker, const struct vkd3d_waiting_fence *enqueued_fence)
struct vkd3d_waiting_fence * fences
struct vkd3d_mutex mutex
struct vkd3d_cond cond
struct d3d12_device * device
union vkd3d_thread_handle thread
VkFormat vk_format
enum vkd3d_format_type type
DXGI_FORMAT dxgi_format
VkImageAspectFlags vk_aspect_mask
struct vkd3d_push_descriptor push_descriptors[D3D12_MAX_ROOT_COST/2]
const struct d3d12_root_signature * root_signature
struct d3d12_desc * descriptor_tables[D3D12_MAX_ROOT_COST]
uint32_t push_descriptor_active_mask
VkBufferView * vk_uav_counter_views
VkDescriptorSet descriptor_sets[VKD3D_MAX_DESCRIPTOR_SETS]
uint64_t descriptor_table_dirty_mask
uint64_t descriptor_table_active_mask
VkPipelineBindPoint vk_bind_point
struct vkd3d_push_descriptor::@6035::@6036 cbv
VkBufferView vk_buffer_view
union vkd3d_push_descriptor::@6035 u
VkQueue vk_queue
uint64_t sequence_number
uint64_t submitted_sequence_number
unsigned int layer_count
unsigned int miplevel_idx
struct vkd3d_shader_descriptor_binding binding
const struct vkd3d_queue * signalling_queue
VkImageUsageFlags usage
const struct vkd3d_format * format
VkImageAspectFlags vk_image_aspect
unsigned int miplevel_count
VkImageViewType view_type
VkClearColorValue colour
VkDescriptorSetLayout vk_set_layout
Definition: command.c:5247
VkPipelineLayout vk_pipeline_layout
Definition: command.c:5248
VkPipeline vk_pipeline
Definition: command.c:5249
VkPhysicalDeviceLimits device_limits
bool EXT_conditional_rendering
union vkd3d_waiting_fence::@6023 u
struct d3d12_fence * fence
VkSemaphore vk_semaphore
uint64_t queue_sequence_number
#define max(a, b)
Definition: svc.c:63
static void invalidate()
float FLOAT
Definition: typedefs.h:69
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
pass
Definition: typegen.h:25
float float32[4]
Definition: vulkan.h:7718
uint32_t uint32[4]
Definition: vulkan.h:7720
VkClearDepthStencilValue depthStencil
Definition: vulkan.h:7732
Definition: pdh_main.c:64
#define VKD3D_RESOURCE_PRESENT_STATE_TRANSITION
Definition: vkd3d.h:330
#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION
Definition: vkd3d.h:325
static const char * debugstr_hresult(HRESULT hr)
Definition: vkd3d_common.h:244
static bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
Definition: vkd3d_common.h:360
static void vkd3d_cond_init(struct vkd3d_cond *cond)
Definition: vkd3d_common.h:617
#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
void vkd3d_set_thread_name(const char *name)
Definition: debug.c:405
static void vkd3d_cond_broadcast(struct vkd3d_cond *cond)
Definition: vkd3d_common.h:641
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 void vkd3d_cond_destroy(struct vkd3d_cond *cond)
Definition: vkd3d_common.h:666
#define vkd3d_unreachable()
Definition: vkd3d_common.h:119
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
const char const char * vkd3d_dbg_vsprintf(const char *fmt, va_list args)
Definition: debug.c:134
#define vkd3d_clamp(value, lower, upper)
Definition: vkd3d_common.h:65
static uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:482
#define STATIC_ASSERT(e)
Definition: vkd3d_common.h:47
static void vkd3d_cond_wait(struct vkd3d_cond *cond, struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:653
static void vkd3d_cond_signal(struct vkd3d_cond *cond)
Definition: vkd3d_common.h:629
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
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22
#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_format_type
@ VKD3D_FORMAT_TYPE_SINT
@ VKD3D_FORMAT_TYPE_UINT
@ VKD3D_FORMAT_TYPE_TYPELESS
static unsigned int d3d12_desc_heap_range_size(const struct d3d12_desc *descriptor)
static void vkd3d_private_store_destroy(struct vkd3d_private_store *store)
static struct d3d12_rtv_desc * d3d12_rtv_desc_from_cpu_handle(D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
vkd3d_pipeline_bind_point
@ VKD3D_PIPELINE_BIND_POINT_GRAPHICS
@ VKD3D_PIPELINE_BIND_POINT_COMPUTE
static ULONG d3d12_device_release(struct d3d12_device *device)
#define VKD3D_DESCRIPTOR_MAGIC_CBV
Definition: vkd3d_private.h:47
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_query_heap_is_result_available(const struct d3d12_query_heap *heap, unsigned int query_index)
static unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
static bool d3d12_resource_is_buffer(const struct d3d12_resource *resource)
#define VKD3D_MAX_DEVICE_BLOCKED_QUEUES
Definition: vkd3d_private.h:59
static bool d3d12_pipeline_state_is_graphics(const struct d3d12_pipeline_state *state)
static void debug_ignored_node_mask(unsigned int mask)
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 struct d3d12_desc * d3d12_desc_from_cpu_handle(D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
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)
static struct d3d12_desc * d3d12_desc_from_gpu_handle(D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle)
static bool d3d12_pipeline_state_is_compute(const struct d3d12_pipeline_state *state)
static bool vkd3d_view_incref(void *desc)
static bool d3d12_pipeline_state_has_unknown_dsv_format(struct d3d12_pipeline_state *state)
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)
#define VKD3D_MAX_VK_SYNC_OBJECTS
Definition: vkd3d_private.h:58
#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)
static void d3d12_query_heap_mark_result_as_available(struct d3d12_query_heap *heap, unsigned int query_index)
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER
Definition: vkd3d_private.h:50
static unsigned int vkd3d_compute_workgroup_count(unsigned int thread_count, unsigned int workgroup_size)
static struct d3d12_dsv_desc * d3d12_dsv_desc_from_cpu_handle(D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
@ VKD3D_CS_OP_UPDATE_MAPPINGS
@ VKD3D_CS_OP_SIGNAL
@ VKD3D_CS_OP_WAIT
@ VKD3D_CS_OP_EXECUTE
@ VKD3D_CS_OP_COPY_MAPPINGS
static struct d3d12_descriptor_heap * d3d12_desc_get_descriptor_heap(const struct d3d12_desc *descriptor)
void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
VkFlags VkPipelineStageFlags
Definition: vulkan.h:1101
@ VK_QUERY_CONTROL_PRECISE_BIT
Definition: vulkan.h:4459
VkImageLayout
Definition: vulkan.h:3450
@ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
Definition: vulkan.h:3457
@ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
Definition: vulkan.h:3460
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3454
@ VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL
Definition: vulkan.h:3465
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan.h:3456
@ VK_IMAGE_LAYOUT_PREINITIALIZED
Definition: vulkan.h:3459
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3453
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
Definition: vulkan.h:3455
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan.h:3451
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan.h:3458
@ VK_IMAGE_LAYOUT_GENERAL
Definition: vulkan.h:3452
@ VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3464
void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query)
@ VK_COMMAND_BUFFER_LEVEL_PRIMARY
Definition: vulkan.h:2140
void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy *pRegions)
VkIndexType
Definition: vulkan.h:3559
@ VK_INDEX_TYPE_UINT16
Definition: vulkan.h:3560
@ VK_INDEX_TYPE_UINT32
Definition: vulkan.h:3561
void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator)
#define VK_REMAINING_MIP_LEVELS
Definition: vulkan.h:50
@ VK_SHADER_STAGE_COMPUTE_BIT
Definition: vulkan.h:4880
@ VK_SHADER_STAGE_ALL
Definition: vulkan.h:4899
void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets)
VkFlags VkAccessFlags
Definition: vulkan.h:957
VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports)
void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents)
VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
VkFlags VkQueueFlags
Definition: vulkan.h:1116
@ VK_TIME_DOMAIN_DEVICE_EXT
Definition: vulkan.h:6183
@ VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT
Definition: vulkan.h:6185
@ VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT
Definition: vulkan.h:6184
VkImageViewType
Definition: vulkan.h:3547
@ 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_3D
Definition: vulkan.h:3550
@ VK_IMAGE_VIEW_TYPE_2D
Definition: vulkan.h:3549
void VKAPI_CALL vkCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes)
uint64_t VkDeviceSize
Definition: vulkan.h:948
void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
VkResult VKAPI_CALL vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps, uint64_t *pMaxDeviation)
@ VK_PIPELINE_BIND_POINT_GRAPHICS
Definition: vulkan.h:4068
@ VK_PIPELINE_BIND_POINT_COMPUTE
Definition: vulkan.h:4069
void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
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)
VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence)
void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers)
VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
@ VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT
Definition: vulkan.h:2354
@ VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT
Definition: vulkan.h:2333
void VKAPI_CALL vkCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride)
void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator)
@ 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_STORAGE_BIT
Definition: vulkan.h:3513
VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer)
VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout)
void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds)
void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions)
void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
VkFlags VkQueryControlFlags
Definition: vulkan.h:1112
void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions)
void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
void VKAPI_CALL vkCmdEndQueryIndexedEXT(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, uint32_t index)
void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset)
#define VK_FALSE
Definition: vulkan.h:56
void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions)
void VKAPI_CALL vkCmdEndConditionalRenderingEXT(VkCommandBuffer commandBuffer)
@ VK_STENCIL_FRONT_AND_BACK
Definition: vulkan.h:4945
void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)
VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore)
@ VK_SEMAPHORE_TYPE_TIMELINE_KHR
Definition: vulkan.h:4805
void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *pValues)
VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags)
void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors)
#define VK_WHOLE_SIZE
Definition: vulkan.h:53
VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
@ VK_QUEUE_SPARSE_BINDING_BIT
Definition: vulkan.h:4534
@ VK_QUEUE_COMPUTE_BIT
Definition: vulkan.h:4532
@ VK_QUEUE_GRAPHICS_BIT
Definition: vulkan.h:4531
VkResult
Definition: vulkan.h:4639
@ VK_SUCCESS
Definition: vulkan.h:4672
@ VK_ERROR_OUT_OF_POOL_MEMORY_KHR
Definition: vulkan.h:4686
@ VK_ERROR_OUT_OF_HOST_MEMORY
Definition: vulkan.h:4671
@ VK_TIMEOUT
Definition: vulkan.h:4674
@ VK_ERROR_FRAGMENTED_POOL
Definition: vulkan.h:4660
@ VK_NOT_READY
Definition: vulkan.h:4673
@ VK_ACCESS_HOST_READ_BIT
Definition: vulkan.h:1642
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
Definition: vulkan.h:1639
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan.h:1641
@ VK_ACCESS_HOST_WRITE_BIT
Definition: vulkan.h:1643
@ VK_ACCESS_MEMORY_READ_BIT
Definition: vulkan.h:1644
@ VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
Definition: vulkan.h:1631
@ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
Definition: vulkan.h:1637
@ VK_ACCESS_INDIRECT_COMMAND_READ_BIT
Definition: vulkan.h:1629
@ VK_ACCESS_TRANSFER_READ_BIT
Definition: vulkan.h:1640
@ VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT
Definition: vulkan.h:1655
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
Definition: vulkan.h:1638
@ VK_ACCESS_SHADER_WRITE_BIT
Definition: vulkan.h:1635
@ VK_ACCESS_SHADER_READ_BIT
Definition: vulkan.h:1634
@ VK_ACCESS_UNIFORM_READ_BIT
Definition: vulkan.h:1632
@ VK_ACCESS_INDEX_READ_BIT
Definition: vulkan.h:1630
@ VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT
Definition: vulkan.h:1649
@ VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT
Definition: vulkan.h:1656
@ VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT
Definition: vulkan.h:1654
@ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
Definition: vulkan.h:1636
VkDescriptorType
Definition: vulkan.h:2463
@ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
Definition: vulkan.h:2469
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan.h:2470
@ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
Definition: vulkan.h:2468
@ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
Definition: vulkan.h:2467
void VKAPI_CALL vkCmdBeginQueryIndexedEXT(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags, uint32_t index)
void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkWaitSemaphoresKHR(VkDevice device, const VkSemaphoreWaitInfo *pWaitInfo, uint64_t timeout)
VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences)
void VKAPI_CALL vkCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites)
void VKAPI_CALL vkCmdBeginConditionalRenderingEXT(VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT *pConditionalRenderingBegin)
void VKAPI_CALL vkCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, uint32_t counterBufferCount, const VkBuffer *pCounterBuffers, const VkDeviceSize *pCounterBufferOffsets)
#define VK_NULL_HANDLE
Definition: vulkan.h:861
void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions)
VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence)
void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
VkFormat
Definition: vulkan.h:2815
@ VK_FORMAT_UNDEFINED
Definition: vulkan.h:2816
@ VK_SUBPASS_CONTENTS_INLINE
Definition: vulkan.h:6094
@ VK_ATTACHMENT_LOAD_OP_CLEAR
Definition: vulkan.h:1772
@ VK_ATTACHMENT_LOAD_OP_DONT_CARE
Definition: vulkan.h:1773
void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
@ VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT
Definition: vulkan.h:2241
VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool)
void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
@ VK_ATTACHMENT_STORE_OP_DONT_CARE
Definition: vulkan.h:1783
@ VK_ATTACHMENT_STORE_OP_STORE
Definition: vulkan.h:1782
#define VK_REMAINING_ARRAY_LAYERS
Definition: vulkan.h:51
VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
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_GEOMETRY_SHADER_BIT
Definition: vulkan.h:4278
@ VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
Definition: vulkan.h:4274
@ VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
Definition: vulkan.h:4283
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
Definition: vulkan.h:4279
@ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
Definition: vulkan.h:4272
@ VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
Definition: vulkan.h:4277
@ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
Definition: vulkan.h:4282
@ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
Definition: vulkan.h:4281
@ VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT
Definition: vulkan.h:4290
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
Definition: vulkan.h:4288
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
Definition: vulkan.h:4285
@ VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
Definition: vulkan.h:4273
@ VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
Definition: vulkan.h:4275
@ VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
Definition: vulkan.h:4276
@ VK_PIPELINE_STAGE_HOST_BIT
Definition: vulkan.h:4286
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan.h:4284
@ VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
Definition: vulkan.h:4280
@ VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT
Definition: vulkan.h:4296
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)
void VKAPI_CALL vkCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, uint32_t counterBufferCount, const VkBuffer *pCounterBuffers, const VkDeviceSize *pCounterBufferOffsets)
@ VK_QUERY_RESULT_64_BIT
Definition: vulkan.h:4490
@ VK_QUERY_RESULT_WAIT_BIT
Definition: vulkan.h:4491
void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets)
VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool)
void VKAPI_CALL vkCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride)
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan.h:57
@ VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT
Definition: vulkan.h:5158
@ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
Definition: vulkan.h:4973
@ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
Definition: vulkan.h:5001
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT
Definition: vulkan.h:5926
@ VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR
Definition: vulkan.h:5949
@ 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_RENDER_PASS_CREATE_INFO
Definition: vulkan.h:5002
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
Definition: vulkan.h:4998
@ VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR
Definition: vulkan.h:5950
@ VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO_KHR
Definition: vulkan.h:5951
@ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
Definition: vulkan.h:4997
@ VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT
Definition: vulkan.h:5934
@ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
Definition: vulkan.h:4972
@ VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
Definition: vulkan.h:5007
@ VK_STRUCTURE_TYPE_MEMORY_BARRIER
Definition: vulkan.h:5010
@ VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER
Definition: vulkan.h:5008
@ VK_STRUCTURE_TYPE_SUBMIT_INFO
Definition: vulkan.h:4968
@ 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
void * arg
Definition: msvc.h:10
#define VK_CALL(f)
Definition: wined3d_vk.h:272
#define E_NOINTERFACE
Definition: winerror.h:3479
#define DXGI_ERROR_INVALID_CALL
Definition: winerror.h:7120