summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-07-09 18:35:22 -0700
committerJason Ekstrand <jason.ekstrand@intel.com>2015-07-09 18:40:54 -0700
commit7d24fab4ef1519b4ef523188b91e5257a7cd1482 (patch)
tree6dc07ba3587eab935228a7b018a6e8c4cc8e00dd
parent5c49730164e0607008d3f82336b1b5ea3c5f855a (diff)
downloadmesa-7d24fab4ef1519b4ef523188b91e5257a7cd1482.tar.gz
vk/private.h: Add a bunch of static inline casting functions
We will need these as soon as we turn on type saftey. We might as well define and start using them now rather than later.
-rw-r--r--src/vulkan/private.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/vulkan/private.h b/src/vulkan/private.h
index 0965b999a65..baa2e7f7901 100644
--- a/src/vulkan/private.h
+++ b/src/vulkan/private.h
@@ -945,8 +945,44 @@ anv_cmd_buffer_clear(struct anv_cmd_buffer *cmd_buffer,
void *
anv_lookup_entrypoint(const char *name);
+#define ANV_DEFINE_CASTS(__anv_type, __VkType) \
+static inline struct __anv_type * \
+__anv_type ## _from_handle(__VkType _handle) \
+{ \
+ return (struct __anv_type *) _handle; \
+} \
+ \
+static inline __VkType \
+__anv_type ## _to_handle(struct __anv_type *_obj) \
+{ \
+ return (__VkType) _obj; \
+}
+
+ANV_DEFINE_CASTS(anv_physical_device, VkPhysicalDevice)
+ANV_DEFINE_CASTS(anv_instance, VkInstance)
+ANV_DEFINE_CASTS(anv_queue, VkQueue)
+ANV_DEFINE_CASTS(anv_device, VkDevice)
+ANV_DEFINE_CASTS(anv_device_memory, VkDeviceMemory)
+ANV_DEFINE_CASTS(anv_dynamic_vp_state, VkDynamicVpState)
+ANV_DEFINE_CASTS(anv_dynamic_rs_state, VkDynamicRsState)
+ANV_DEFINE_CASTS(anv_dynamic_ds_state, VkDynamicDsState)
+ANV_DEFINE_CASTS(anv_dynamic_cb_state, VkDynamicCbState)
+ANV_DEFINE_CASTS(anv_descriptor_set_layout, VkDescriptorSetLayout)
+ANV_DEFINE_CASTS(anv_descriptor_set, VkDescriptorSet)
+ANV_DEFINE_CASTS(anv_pipeline_layout, VkPipelineLayout)
+ANV_DEFINE_CASTS(anv_buffer, VkBuffer)
+ANV_DEFINE_CASTS(anv_cmd_buffer, VkCmdBuffer)
+ANV_DEFINE_CASTS(anv_fence, VkFence)
+ANV_DEFINE_CASTS(anv_shader_module, VkShaderModule)
+ANV_DEFINE_CASTS(anv_shader, VkShader)
+ANV_DEFINE_CASTS(anv_pipeline, VkPipeline)
+ANV_DEFINE_CASTS(anv_image, VkImage)
+ANV_DEFINE_CASTS(anv_depth_stencil_view, VkDepthStencilView)
+ANV_DEFINE_CASTS(anv_framebuffer, VkFramebuffer)
+ANV_DEFINE_CASTS(anv_render_pass, VkRenderPass)
+
#define ANV_FROM_HANDLE(__anv_type, __name, __handle) \
- struct __anv_type *__name = (struct __anv_type *) __handle
+ struct __anv_type *__name = __anv_type ## _from_handle(__handle)
#ifdef __cplusplus
}