Closed Ka-lua closed 8 years ago
It will still produce errors on 32-bit platforms.
Non-dispatchable handles are pointers on 64-bit targets but 64-bit integers on 32-bit systems, and since D makes comparing pointers and integers a type error, such a comparison will not compile on 32-bit targets.
Since the null handle is always zero (on any sane implementation) you can just use the handles as booleans - i.e. if(handle)
and if(!handle)
, and use SomeHandle.init
if you really need a null handle value. But unfortunately, it's not possible to implement VK_NULL_HANDLE
100% correctly in D.
Didn't face that problem till now, but on 32-bit windows:
VkDevice device = VK_NULL_HANDLE;
works with
enum VK_NULL_HANDLE = null;
but not with
enum VK_NULL_HANDLE = 0;
VkDevice
is a dispatchable handle and thus always a pointer. Try it with, say, a VkFence
.
There's unfortunately no good solution for this that works in all cases. I'm honestly considering removing VK_NULL_HANDLE
(or at least deprecating it with a message) since it can hide issues in 64-bit systems.
Please change the defintion to
enum VK_NULL_HANDLE = null;
in vkdgen.py, line 60 (was = 0 before), so that we don't get type errors when doing tests like
physicalDevice == VK_NULL_HANDLE
.