From badbf0c94a6444c2a62994dc8a5c0ebb3d4be678 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Wed, 15 Jul 2015 15:33:12 -0700 Subject: [PATCH] vk/x11: Remove raw casts The raw casts in the WSI functions will break the build when the type-safety changes arrive. --- src/vulkan/x11.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/vulkan/x11.c b/src/vulkan/x11.c index d1eaab3bf46..73a7e2fc8ac 100644 --- a/src/vulkan/x11.c +++ b/src/vulkan/x11.c @@ -88,7 +88,8 @@ VkResult anv_CreateSwapChainWSI( const VkSwapChainCreateInfoWSI* pCreateInfo, VkSwapChainWSI* pSwapChain) { - struct anv_device *device = (struct anv_device *) _device; + ANV_FROM_HANDLE(anv_device, device, _device); + struct anv_swap_chain *chain; xcb_void_cookie_t cookie; VkResult result; @@ -110,11 +111,13 @@ VkResult anv_CreateSwapChainWSI( chain->extent = pCreateInfo->imageExtent; for (uint32_t i = 0; i < chain->count; i++) { + VkDeviceMemory memory_h; + VkImage image_h; struct anv_image *image; struct anv_surface *surface; struct anv_device_memory *memory; - anv_image_create((VkDevice) device, + anv_image_create(_device, &(struct anv_image_create_info) { .force_tile_mode = true, .tile_mode = XMAJOR, @@ -136,21 +139,23 @@ VkResult anv_CreateSwapChainWSI( .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, .flags = 0, }}, - (VkImage *) &image); + &image_h); + image = anv_image_from_handle(image_h); surface = &image->primary_surface; - anv_AllocMemory((VkDevice) device, + anv_AllocMemory(_device, &(VkMemoryAllocInfo) { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO, .allocationSize = image->size, .memoryTypeIndex = 0, }, - (VkDeviceMemory *) &memory); + &memory_h); + + memory = anv_device_memory_from_handle(memory_h); - anv_BindImageMemory(VK_NULL_HANDLE, - anv_image_to_handle(image), - anv_device_memory_to_handle(memory), 0); + anv_BindImageMemory(VK_NULL_HANDLE, anv_image_to_handle(image), + memory_h, 0); ret = anv_gem_set_tiling(device, memory->bo.gem_handle, surface->stride, I915_TILING_X); @@ -241,8 +246,8 @@ VkResult anv_GetSwapChainInfoWSI( images = pData; for (uint32_t i = 0; i < chain->count; i++) { - images[i].image = (VkImage) chain->images[i].image; - images[i].memory = (VkDeviceMemory) chain->images[i].memory; + images[i].image = anv_image_to_handle(chain->images[i].image); + images[i].memory = anv_device_memory_to_handle(chain->images[i].memory); } return VK_SUCCESS; @@ -256,7 +261,8 @@ VkResult anv_QueuePresentWSI( VkQueue queue_, const VkPresentInfoWSI* pPresentInfo) { - struct anv_image *image = (struct anv_image *) pPresentInfo->image; + ANV_FROM_HANDLE(anv_image, image, pPresentInfo->image); + struct anv_swap_chain *chain = image->swap_chain; xcb_void_cookie_t cookie; xcb_pixmap_t pixmap; @@ -268,7 +274,7 @@ VkResult anv_QueuePresentWSI( pixmap = XCB_NONE; for (uint32_t i = 0; i < chain->count; i++) { - if ((VkImage) chain->images[i].image == pPresentInfo->image) { + if (image == chain->images[i].image) { pixmap = chain->images[i].pixmap; break; } -- 2.30.2