X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fintel%2Fvulkan%2Fanv_wsi.c;h=3b4877a3abbe15088d654b86a909f78edba327a3;hb=fcdefa7e479541a92f02b1933f58439e0fd03a1f;hp=ba07bcef8b38ea7f7877c92e70d7822167cac682;hpb=f2e0f5c3c44967da8a10ac363ab667e07ea03c28;p=mesa.git diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c index ba07bcef8b3..3b4877a3abb 100644 --- a/src/intel/vulkan/anv_wsi.c +++ b/src/intel/vulkan/anv_wsi.c @@ -33,11 +33,46 @@ anv_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) return anv_lookup_entrypoint(&physical_device->info, pName); } -static uint64_t -anv_wsi_image_get_modifier(VkImage _image) +static void +anv_wsi_signal_semaphore_for_memory(VkDevice _device, + VkSemaphore _semaphore, + VkDeviceMemory _memory) { - ANV_FROM_HANDLE(anv_image, image, _image); - return image->drm_format_mod; + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_semaphore, semaphore, _semaphore); + ANV_FROM_HANDLE(anv_device_memory, memory, _memory); + + /* Put a BO semaphore with the image BO in the temporary. For BO binary + * semaphores, we always set EXEC_OBJECT_WRITE so this creates a WaR + * hazard with the display engine's read to ensure that no one writes to + * the image before the read is complete. + */ + anv_semaphore_reset_temporary(device, semaphore); + + struct anv_semaphore_impl *impl = &semaphore->temporary; + impl->type = ANV_SEMAPHORE_TYPE_WSI_BO; + impl->bo = anv_bo_ref(memory->bo); +} + +static void +anv_wsi_signal_fence_for_memory(VkDevice _device, + VkFence _fence, + VkDeviceMemory _memory) +{ + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_fence, fence, _fence); + ANV_FROM_HANDLE(anv_device_memory, memory, _memory); + + /* Put a BO fence with the image BO in the temporary. For BO fences, we + * always just wait until the BO isn't busy and reads from the BO should + * count as busy. + */ + anv_fence_reset_temporary(device, fence); + + struct anv_fence_impl *impl = &fence->temporary; + impl->type = ANV_FENCE_TYPE_WSI_BO; + impl->bo.bo = anv_bo_ref(memory->bo); + impl->bo.state = ANV_BO_FENCE_STATE_SUBMITTED; } VkResult @@ -50,12 +85,15 @@ anv_init_wsi(struct anv_physical_device *physical_device) anv_wsi_proc_addr, &physical_device->instance->alloc, physical_device->master_fd, - NULL); + &physical_device->instance->dri_options); if (result != VK_SUCCESS) return result; physical_device->wsi_device.supports_modifiers = true; - physical_device->wsi_device.image_get_modifier = anv_wsi_image_get_modifier; + physical_device->wsi_device.signal_semaphore_for_memory = + anv_wsi_signal_semaphore_for_memory; + physical_device->wsi_device.signal_fence_for_memory = + anv_wsi_signal_fence_for_memory; return VK_SUCCESS; } @@ -175,13 +213,13 @@ VkResult anv_CreateSwapchainKHR( VkSwapchainKHR* pSwapchain) { ANV_FROM_HANDLE(anv_device, device, _device); - struct wsi_device *wsi_device = &device->instance->physicalDevice.wsi_device; + struct wsi_device *wsi_device = &device->physical->wsi_device; const VkAllocationCallbacks *alloc; if (pAllocator) alloc = pAllocator; else - alloc = &device->alloc; + alloc = &device->vk.alloc; return wsi_common_create_swapchain(wsi_device, _device, pCreateInfo, alloc, pSwapchain); @@ -198,7 +236,7 @@ void anv_DestroySwapchainKHR( if (pAllocator) alloc = pAllocator; else - alloc = &device->alloc; + alloc = &device->vk.alloc; wsi_common_destroy_swapchain(_device, swapchain, alloc); } @@ -240,22 +278,9 @@ VkResult anv_AcquireNextImage2KHR( uint32_t* pImageIndex) { ANV_FROM_HANDLE(anv_device, device, _device); - struct anv_physical_device *pdevice = &device->instance->physicalDevice; - - VkResult result = wsi_common_acquire_next_image2(&pdevice->wsi_device, - _device, - pAcquireInfo, - pImageIndex); - - /* Thanks to implicit sync, the image is ready immediately. However, we - * should wait for the current GPU state to finish. - */ - if (pAcquireInfo->fence != VK_NULL_HANDLE) { - anv_QueueSubmit(anv_queue_to_handle(&device->queue), 0, NULL, - pAcquireInfo->fence); - } - return result; + return wsi_common_acquire_next_image2(&device->physical->wsi_device, + _device, pAcquireInfo, pImageIndex); } VkResult anv_QueuePresentKHR( @@ -263,10 +288,8 @@ VkResult anv_QueuePresentKHR( const VkPresentInfoKHR* pPresentInfo) { ANV_FROM_HANDLE(anv_queue, queue, _queue); - struct anv_physical_device *pdevice = - &queue->device->instance->physicalDevice; - return wsi_common_queue_present(&pdevice->wsi_device, + return wsi_common_queue_present(&queue->device->physical->wsi_device, anv_device_to_handle(queue->device), _queue, 0, pPresentInfo);