vk/0.210.0: Switch to the new-style handle declarations
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 30 Nov 2015 18:31:44 +0000 (10:31 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 30 Nov 2015 18:58:02 +0000 (10:58 -0800)
include/vulkan/vk_ext_khr_device_swapchain.h
include/vulkan/vulkan.h
src/vulkan/anv_descriptor_set.c
src/vulkan/anv_device.c
src/vulkan/anv_meta.c
src/vulkan/anv_pipeline.c
src/vulkan/anv_private.h

index 3bf73c84a967087b5630f1ee0ef89090a6ff07f7..af95ff0cdfb8af4954161046f725dd0bd4fcd259 100644 (file)
@@ -41,7 +41,7 @@ extern "C"
 // ------------------------------------------------------------------------------------------------
 // Objects
 
-VK_DEFINE_NONDISP_HANDLE(VkSwapchainKHR);
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR);
 
 // ------------------------------------------------------------------------------------------------
 // Enumeration constants
index 03bcefea50a69ab1f6394d87d73a97c66d09fd35..fd898736fc5051531c6ca8e26fab0c05bb42940d 100644 (file)
@@ -44,46 +44,17 @@ extern "C" {
 #define VK_API_VERSION VK_MAKE_VERSION(0, 170, 2)
 
 
-#if defined(__cplusplus) && (_MSC_VER >= 1800 || __cplusplus >= 201103L)
-    #define VK_NULL_HANDLE nullptr
-#else
-    #define VK_NULL_HANDLE 0
-#endif
+#define VK_NULL_HANDLE 0
+
+
+
+#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
 
 
-#define VK_DEFINE_HANDLE(obj) typedef struct obj##_T* obj;
-
-
-#if defined(__cplusplus)
-    #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || __cplusplus >= 201103L)
-        // The bool operator only works if there are no implicit conversions from an obj to
-        // a bool-compatible type, which can then be used to unintentionally violate type safety.
-        // C++11 and above supports the "explicit" keyword on conversion operators to stop this
-        // from happening. Otherwise users of C++ below C++11 won't get direct access to evaluating
-        // the object handle as a bool in expressions like:
-        //     if (obj) vkDestroy(obj);
-        #define VK_NONDISP_HANDLE_OPERATOR_BOOL() explicit operator bool() const { return handle != 0; }
-        #define VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \
-            explicit obj(uint64_t x) : handle(x) { } \
-            obj(decltype(nullptr)) : handle(0) { }
-    #else
-        #define VK_NONDISP_HANDLE_OPERATOR_BOOL()
-        #define VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \
-            obj(uint64_t x) : handle(x) { }
-    #endif
-    #define VK_DEFINE_NONDISP_HANDLE(obj) \
-        struct obj { \
-            obj() : handle(0) { } \
-            VK_NONDISP_HANDLE_CONSTRUCTOR_FROM_UINT64(obj) \
-            obj& operator =(uint64_t x) { handle = x; return *this; } \
-            bool operator==(const obj& other) const { return handle == other.handle; } \
-            bool operator!=(const obj& other) const { return handle != other.handle; } \
-            bool operator!() const { return !handle; } \
-            VK_NONDISP_HANDLE_OPERATOR_BOOL() \
-            uint64_t handle; \
-        };
+#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
+        #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
 #else
-    #define VK_DEFINE_NONDISP_HANDLE(obj) typedef struct obj##_T { uint64_t handle; } obj;
+        #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
 #endif
         
 
@@ -98,27 +69,27 @@ VK_DEFINE_HANDLE(VkPhysicalDevice)
 VK_DEFINE_HANDLE(VkDevice)
 VK_DEFINE_HANDLE(VkQueue)
 VK_DEFINE_HANDLE(VkCmdBuffer)
-VK_DEFINE_NONDISP_HANDLE(VkFence)
-VK_DEFINE_NONDISP_HANDLE(VkDeviceMemory)
-VK_DEFINE_NONDISP_HANDLE(VkBuffer)
-VK_DEFINE_NONDISP_HANDLE(VkImage)
-VK_DEFINE_NONDISP_HANDLE(VkSemaphore)
-VK_DEFINE_NONDISP_HANDLE(VkEvent)
-VK_DEFINE_NONDISP_HANDLE(VkQueryPool)
-VK_DEFINE_NONDISP_HANDLE(VkBufferView)
-VK_DEFINE_NONDISP_HANDLE(VkImageView)
-VK_DEFINE_NONDISP_HANDLE(VkShaderModule)
-VK_DEFINE_NONDISP_HANDLE(VkShader)
-VK_DEFINE_NONDISP_HANDLE(VkPipelineCache)
-VK_DEFINE_NONDISP_HANDLE(VkPipelineLayout)
-VK_DEFINE_NONDISP_HANDLE(VkRenderPass)
-VK_DEFINE_NONDISP_HANDLE(VkPipeline)
-VK_DEFINE_NONDISP_HANDLE(VkDescriptorSetLayout)
-VK_DEFINE_NONDISP_HANDLE(VkSampler)
-VK_DEFINE_NONDISP_HANDLE(VkDescriptorPool)
-VK_DEFINE_NONDISP_HANDLE(VkDescriptorSet)
-VK_DEFINE_NONDISP_HANDLE(VkFramebuffer)
-VK_DEFINE_NONDISP_HANDLE(VkCmdPool)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShader)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCmdPool)
 
 #define VK_LOD_CLAMP_NONE                 1000.0f
 #define VK_REMAINING_MIP_LEVELS           (~0U)
index d518dfa34bacd0f7245d69e20380cdec585cf5eb..22041b540d6aa6d2e10ef8624ab10cdbedfc860c 100644 (file)
@@ -286,7 +286,7 @@ VkResult anv_CreateDescriptorPool(
     VkDescriptorPool*                           pDescriptorPool)
 {
    anv_finishme("VkDescriptorPool is a stub");
-   pDescriptorPool->handle = 1;
+   *pDescriptorPool = (VkDescriptorPool)1;
    return VK_SUCCESS;
 }
 
@@ -466,7 +466,7 @@ void anv_UpdateDescriptorSets(
       case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
       case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
          for (uint32_t j = 0; j < write->count; j++) {
-            assert(write->pDescriptors[j].bufferInfo.buffer.handle);
+            assert(write->pDescriptors[j].bufferInfo.buffer);
             ANV_FROM_HANDLE(anv_buffer, buffer,
                             write->pDescriptors[j].bufferInfo.buffer);
             assert(buffer);
index 94bc4f11f27aea931b83b18fb06ddb310f9501dd..aca082ac1b51b26e90896afdcdd91242c065c052 100644 (file)
@@ -1336,7 +1336,7 @@ VkResult anv_CreateSemaphore(
     const VkSemaphoreCreateInfo*                pCreateInfo,
     VkSemaphore*                                pSemaphore)
 {
-   pSemaphore->handle = 1;
+   *pSemaphore = (VkSemaphore)1;
    stub_return(VK_SUCCESS);
 }
 
index c9e46a9286e8f3bdb31595d24c81d02156fa3224..96792e9d6da420f2d91a2bce2b193b7148507b03 100644 (file)
@@ -335,7 +335,7 @@ anv_device_init_meta_blit_state(struct anv_device *device)
       }, {
          .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
          .stage = VK_SHADER_STAGE_FRAGMENT,
-         .shader = {0}, /* TEMPLATE VALUE! FILL ME IN! */
+         .shader = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
          .pSpecializationInfo = NULL
       },
    };
@@ -452,7 +452,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
                VkTexFilter blit_filter)
 {
    struct anv_device *device = cmd_buffer->device;
-   VkDescriptorPool dummy_desc_pool = { .handle = 1 };
+   VkDescriptorPool dummy_desc_pool = (VkDescriptorPool)1;
 
    struct blit_vb_data {
       float pos[2];
index cf4bf9f87a0f0a4deaf02485811acaf51653a2a6..a0606adaea6a3a50ce40f5ef66ede96705d9c0ac 100644 (file)
@@ -189,7 +189,7 @@ VkResult anv_CreatePipelineCache(
     const VkPipelineCacheCreateInfo*            pCreateInfo,
     VkPipelineCache*                            pPipelineCache)
 {
-   pPipelineCache->handle = 1;
+   *pPipelineCache = (VkPipelineCache)1;
 
    stub_return(VK_SUCCESS);
 }
index d208b2d74a0c76da12841329f0bc4cad1f26bfad..c99d4e0a59ec72f432b1057f890442e69a8f1f6a 100644 (file)
@@ -1537,13 +1537,13 @@ void anv_dump_image_to_ppm(struct anv_device *device,
    static inline struct __anv_type *                                       \
    __anv_type ## _from_handle(__VkType _handle)                            \
    {                                                                       \
-      return (struct __anv_type *) _handle.handle;                         \
+      return (struct __anv_type *)(uintptr_t) _handle;                     \
    }                                                                       \
                                                                            \
    static inline __VkType                                                  \
    __anv_type ## _to_handle(struct __anv_type *_obj)                       \
    {                                                                       \
-      return (__VkType) { .handle = (uint64_t) _obj };                     \
+      return (__VkType)(uintptr_t) _obj;                                   \
    }
 
 #define ANV_FROM_HANDLE(__anv_type, __name, __handle) \