return radv_lookup_entrypoint(pName);
}
+static void
+radv_wsi_set_memory_ownership(VkDevice _device,
+ VkDeviceMemory _mem,
+ VkBool32 ownership)
+{
+ RADV_FROM_HANDLE(radv_device, device, _device);
+ RADV_FROM_HANDLE(radv_device_memory, mem, _mem);
+
+ if (ownership)
+ radv_bo_list_add(device, mem->bo);
+ else
+ radv_bo_list_remove(device, mem->bo);
+}
+
VkResult
radv_init_wsi(struct radv_physical_device *physical_device)
{
- return wsi_device_init(&physical_device->wsi_device,
- radv_physical_device_to_handle(physical_device),
- radv_wsi_proc_addr,
- &physical_device->instance->alloc,
- physical_device->master_fd,
- &physical_device->instance->dri_options);
+ VkResult result = wsi_device_init(&physical_device->wsi_device,
+ radv_physical_device_to_handle(physical_device),
+ radv_wsi_proc_addr,
+ &physical_device->instance->alloc,
+ physical_device->master_fd,
+ &physical_device->instance->dri_options);
+ if (result != VK_SUCCESS)
+ return result;
+
+ physical_device->wsi_device.set_memory_ownership = radv_wsi_set_memory_ownership;
+ return VK_SUCCESS;
}
void
if (pAllocator)
alloc = pAllocator;
else
- alloc = &device->alloc;
+ alloc = &device->vk.alloc;
return wsi_common_create_swapchain(&device->physical_device->wsi_device,
radv_device_to_handle(device),
if (pAllocator)
alloc = pAllocator;
else
- alloc = &device->alloc;
+ alloc = &device->vk.alloc;
wsi_common_destroy_swapchain(_device, swapchain, alloc);
}
if (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR) {
if (fence) {
- if (fence->fence)
- device->ws->signal_fence(fence->fence);
- if (fence->temp_syncobj) {
- device->ws->signal_syncobj(device->ws, fence->temp_syncobj);
- } else if (fence->syncobj) {
- device->ws->signal_syncobj(device->ws, fence->syncobj);
+ struct radv_fence_part *part =
+ fence->temporary.kind != RADV_FENCE_NONE ?
+ &fence->temporary : &fence->permanent;
+
+ switch (part->kind) {
+ case RADV_FENCE_NONE:
+ break;
+ case RADV_FENCE_WINSYS:
+ device->ws->signal_fence(part->fence);
+ break;
+ case RADV_FENCE_SYNCOBJ:
+ device->ws->signal_syncobj(device->ws, part->syncobj, 0);
+ break;
+ default:
+ unreachable("Invalid WSI fence type");
}
}
if (semaphore) {
case RADV_SEMAPHORE_TIMELINE:
unreachable("WSI only allows binary semaphores.");
case RADV_SEMAPHORE_SYNCOBJ:
- device->ws->signal_syncobj(device->ws, part->syncobj);
+ device->ws->signal_syncobj(device->ws, part->syncobj, 0);
break;
}
}
return result;
}
-/* TODO: Improve the way to trigger capture (overlay, etc). */
-static void
-radv_handle_thread_trace(VkQueue _queue)
-{
- RADV_FROM_HANDLE(radv_queue, queue, _queue);
- static bool thread_trace_enabled = false;
- static uint64_t num_frames = 0;
-
- if (thread_trace_enabled) {
- struct radv_thread_trace thread_trace = {};
-
- radv_end_thread_trace(queue);
- thread_trace_enabled = false;
-
- /* TODO: Do something better than this whole sync. */
- radv_QueueWaitIdle(_queue);
-
- if (radv_get_thread_trace(queue, &thread_trace))
- radv_dump_thread_trace(queue->device, &thread_trace);
- } else {
- if (num_frames == queue->device->thread_trace_start_frame) {
- radv_begin_thread_trace(queue);
- assert(!thread_trace_enabled);
- thread_trace_enabled = true;
- }
- }
- num_frames++;
-}
-
VkResult radv_QueuePresentKHR(
VkQueue _queue,
const VkPresentInfoKHR* pPresentInfo)
{
RADV_FROM_HANDLE(radv_queue, queue, _queue);
- VkResult result;
-
- result = wsi_common_queue_present(&queue->device->physical_device->wsi_device,
- radv_device_to_handle(queue->device),
- _queue,
- queue->queue_family_index,
- pPresentInfo);
- if (result != VK_SUCCESS)
- return result;
-
- if (unlikely(queue->device->thread_trace_bo)) {
- radv_handle_thread_trace(_queue);
- }
-
- return VK_SUCCESS;
+ return wsi_common_queue_present(&queue->device->physical_device->wsi_device,
+ radv_device_to_handle(queue->device),
+ _queue,
+ queue->queue_family_index,
+ pPresentInfo);
}