const struct anv_common *common = ppMemBarriers[i];
switch (common->sType) {
case VK_STRUCTURE_TYPE_MEMORY_BARRIER: {
- const VkMemoryBarrier *barrier = (VkMemoryBarrier *)common;
+ ANV_COMMON_TO_STRUCT(VkMemoryBarrier, barrier, common);
out_flags |= barrier->outputMask;
in_flags |= barrier->inputMask;
break;
}
case VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: {
- const VkBufferMemoryBarrier *barrier = (VkBufferMemoryBarrier *)common;
+ ANV_COMMON_TO_STRUCT(VkBufferMemoryBarrier, barrier, common);
out_flags |= barrier->outputMask;
in_flags |= barrier->inputMask;
break;
}
case VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: {
- const VkImageMemoryBarrier *barrier = (VkImageMemoryBarrier *)common;
+ ANV_COMMON_TO_STRUCT(VkImageMemoryBarrier, barrier, common);
out_flags |= barrier->outputMask;
in_flags |= barrier->inputMask;
break;
uint32_t fenceCount,
const VkFence* pFences)
{
- struct anv_fence **fences = (struct anv_fence **) pFences;
-
- for (uint32_t i = 0; i < fenceCount; i++)
- fences[i]->ready = false;
+ for (uint32_t i = 0; i < fenceCount; i++) {
+ ANV_FROM_HANDLE(anv_fence, fence, pFences[i]);
+ fence->ready = false;
+ }
return VK_SUCCESS;
}
VkDeviceMemory* pMem,
VkImage* pImage)
{
- struct anv_device *device = (struct anv_device *) _device;
+ ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_device_memory *mem;
struct anv_image *image;
VkResult result;
ANV_DEFINE_HANDLE_CASTS(anv_instance, VkInstance)
ANV_DEFINE_HANDLE_CASTS(anv_physical_device, VkPhysicalDevice)
ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue)
+ANV_DEFINE_HANDLE_CASTS(anv_swap_chain, VkSwapChainWSI);
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_attachment_view, VkAttachmentView)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader, VkShader)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, VkShaderModule)
+#define ANV_DEFINE_STRUCT_CASTS(__anv_type, __VkType) \
+ \
+ static inline const __VkType * \
+ __anv_type ## _to_ ## __VkType(const struct __anv_type *__anv_obj) \
+ { \
+ return (const __VkType *) __anv_obj; \
+ }
+
+#define ANV_COMMON_TO_STRUCT(__VkType, __vk_name, __common_name) \
+ const __VkType *__vk_name = anv_common_to_ ## __VkType(__common_name)
+
+ANV_DEFINE_STRUCT_CASTS(anv_common, VkMemoryBarrier)
+ANV_DEFINE_STRUCT_CASTS(anv_common, VkBufferMemoryBarrier)
+ANV_DEFINE_STRUCT_CASTS(anv_common, VkImageMemoryBarrier)
+
#ifdef __cplusplus
}
#endif
(uint32_t []) { 0 });
xcb_discard_reply(chain->conn, cookie.sequence);
- *pSwapChain = (VkSwapChainWSI) chain;
+ *pSwapChain = anv_swap_chain_to_handle(chain);
return VK_SUCCESS;
}
VkResult anv_DestroySwapChainWSI(
- VkSwapChainWSI swapChain)
+ VkSwapChainWSI _chain)
{
- struct anv_swap_chain *chain = (struct anv_swap_chain *) swapChain;
- struct anv_device *device = chain->device;
+ ANV_FROM_HANDLE(anv_swap_chain, chain, _chain);
- anv_device_free(device, chain);
+ anv_device_free(chain->device, chain);
return VK_SUCCESS;
}
VkResult anv_GetSwapChainInfoWSI(
- VkSwapChainWSI swapChain,
+ VkSwapChainWSI _chain,
VkSwapChainInfoTypeWSI infoType,
size_t* pDataSize,
void* pData)
{
- struct anv_swap_chain *chain = (struct anv_swap_chain *) swapChain;
+ ANV_FROM_HANDLE(anv_swap_chain, chain, _chain);
+
VkSwapChainImageInfoWSI *images;
size_t size;