From 19f0a9b58210de2f0fb736b56050e2de86e40f6a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 9 Jul 2015 20:32:44 -0700 Subject: [PATCH] vk/query.c: Use the casting functions --- src/vulkan/private.h | 1 + src/vulkan/query.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 635ec287712..ef4b183056e 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -981,6 +981,7 @@ ANV_DEFINE_CASTS(anv_sampler, VkSampler) ANV_DEFINE_CASTS(anv_depth_stencil_view, VkDepthStencilView) ANV_DEFINE_CASTS(anv_framebuffer, VkFramebuffer) ANV_DEFINE_CASTS(anv_render_pass, VkRenderPass) +ANV_DEFINE_CASTS(anv_query_pool, VkQueryPool) #define ANV_FROM_HANDLE(__anv_type, __name, __handle) \ struct __anv_type *__name = __anv_type ## _from_handle(__handle) diff --git a/src/vulkan/query.c b/src/vulkan/query.c index 759f76c8f59..2c68e30eeee 100644 --- a/src/vulkan/query.c +++ b/src/vulkan/query.c @@ -61,13 +61,13 @@ VkResult anv_CreateQueryPool( const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool) { - struct anv_device *device = (struct anv_device *) _device; + ANV_FROM_HANDLE(anv_device, device, _device); struct anv_query_pool *pool; VkResult result; size_t size; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO); - + switch (pCreateInfo->queryType) { case VK_QUERY_TYPE_OCCLUSION: break; @@ -92,7 +92,7 @@ VkResult anv_CreateQueryPool( pool->bo.map = anv_gem_mmap(device, pool->bo.gem_handle, 0, size); - *pQueryPool = (VkQueryPool) pool; + *pQueryPool = anv_query_pool_to_handle(pool); return VK_SUCCESS; @@ -111,8 +111,8 @@ VkResult anv_GetQueryPoolResults( void* pData, VkQueryResultFlags flags) { - struct anv_device *device = (struct anv_device *) _device; - struct anv_query_pool *pool = (struct anv_query_pool *) queryPool; + ANV_FROM_HANDLE(anv_device, device, _device); + ANV_FROM_HANDLE(anv_query_pool, pool, queryPool); struct anv_query_pool_slot *slot = pool->bo.map; int64_t timeout = INT64_MAX; uint32_t *dst32 = pData; @@ -172,8 +172,8 @@ void anv_CmdBeginQuery( uint32_t slot, VkQueryControlFlags flags) { - struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer; - struct anv_query_pool *pool = (struct anv_query_pool *) queryPool; + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_query_pool, pool, queryPool); switch (pool->type) { case VK_QUERY_TYPE_OCCLUSION: @@ -192,8 +192,8 @@ void anv_CmdEndQuery( VkQueryPool queryPool, uint32_t slot) { - struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer; - struct anv_query_pool *pool = (struct anv_query_pool *) queryPool; + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_query_pool, pool, queryPool); switch (pool->type) { case VK_QUERY_TYPE_OCCLUSION: @@ -224,8 +224,8 @@ void anv_CmdWriteTimestamp( VkBuffer destBuffer, VkDeviceSize destOffset) { - struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer; - struct anv_buffer *buffer = (struct anv_buffer *) destBuffer; + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_buffer, buffer, destBuffer); struct anv_bo *bo = buffer->bo; switch (timestampType) { @@ -305,9 +305,9 @@ void anv_CmdCopyQueryPoolResults( VkDeviceSize destStride, VkQueryResultFlags flags) { - struct anv_cmd_buffer *cmd_buffer = (struct anv_cmd_buffer *) cmdBuffer; - struct anv_query_pool *pool = (struct anv_query_pool *) queryPool; - struct anv_buffer *buffer = (struct anv_buffer *) destBuffer; + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); + ANV_FROM_HANDLE(anv_query_pool, pool, queryPool); + ANV_FROM_HANDLE(anv_buffer, buffer, destBuffer); uint32_t slot_offset, dst_offset; if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) { -- 2.30.2