6

Looking into the vulkan.h i see this:

#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || .....
    #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
#else
    #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
#endif

Does anyone has an idea why the 64bits? For me it appears more reasonable to always use the first case of the ifdef

hiddenbit
  • 333
  • 1
  • 2
  • 11
  • 1
    "Always"? - According to the code shown, they are not. But what size would a pointer have on a non-64 bit platform? And what size does it have on the platforms used for the first cases? – too honest for this site Feb 23 '16 at 15:14
  • 2
    My question was based on the assumption that a 64bit platform has 64bit pointers – hiddenbit Feb 23 '16 at 15:23

1 Answers1

5

In the spec it explicitly says that the non-dispatchable handles must be 64 bits:

Non-dispatchable handle types are a 64-bit integer type whose meaning is implementation-dependent, and may encode object information directly in the handle rather than pointing to a software structure. Objects of a non-dispatchable type may not have unique handle values within a type or across types. If handle values are not unique, then destroying one such handle must not cause identical handles of other types to become invalid, and must not cause identical handles of the same type to become invalid if that handle value has been created more times than it has been destroyed.

ratchet freak
  • 47,288
  • 5
  • 68
  • 106
  • Thanks for the reference! It was simpler and more obvious than I thought. – hiddenbit Feb 23 '16 at 16:44
  • 2
    If that's the case, then why are the handles defined as pointers on 64-bit architecture, rather than as uint64_t's? After reading that paragraph, it seems to me more reasonable to always use the second part of the #ifdef. – Andrew Williamson Apr 19 '16 at 23:09
  • 1
    @AndrewWilliamson probably because C and C++ don't have strong typedefs so they use the pointer to help type-safety. – ratchet freak Apr 20 '16 at 00:03