X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Famd%2Fvulkan%2Fradv_wsi.c;h=0c9c8593783069556c57ded512e1c59b60d1bf5e;hb=55d8022878fd11093c861a6386734f88454f21b1;hp=66a8d002f857a9eb31b7266f2dd1f4d069da1abd;hpb=d555794f3032594dbef3623052103900138d2356;p=mesa.git diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index 66a8d002f85..0c9c8593783 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -35,15 +35,34 @@ radv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) 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 @@ -167,7 +186,7 @@ VkResult radv_CreateSwapchainKHR( 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), @@ -187,7 +206,7 @@ void radv_DestroySwapchainKHR( if (pAllocator) alloc = pAllocator; else - alloc = &device->alloc; + alloc = &device->vk.alloc; wsi_common_destroy_swapchain(_device, swapchain, alloc); } @@ -240,12 +259,21 @@ VkResult radv_AcquireNextImage2KHR( 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) { @@ -261,7 +289,7 @@ VkResult radv_AcquireNextImage2KHR( 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; } } @@ -269,55 +297,16 @@ VkResult radv_AcquireNextImage2KHR( 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); }