Skip to content

Commit

Permalink
fix(Vulkan): always respect noautovalidity property. Close LWJGL#702
Browse files Browse the repository at this point in the history
Not happy with this fix, since it's obviously wrong in a few places
(e.g. the first three VkAllocationCallbacks function pointers).

LWJGL uses the "optional" property to mark parameters/members as
nullable, but it is missing in cases like the one reported with LWJGL#702.
However, "noautovalidity" is consistent and LWJGL now interprets it
literally and does not perform any kind of validation, including
nullability. This may be reverted if the Vulkan-Docs situation changes
in the future.
  • Loading branch information
Spasi committed Dec 20, 2021
1 parent 45d33b9 commit 3eb2b82
Show file tree
Hide file tree
Showing 50 changed files with 70 additions and 367 deletions.
1 change: 1 addition & 0 deletions doc/notes/3.3.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This build includes the following changes:
#### Fixes

- vma: Fixed nullability of `VmaVirtualAllocationCreateInfo::pUserData` member.
- Vulkan: All `noautovalidity` parameters/members are now regarded as nullable. (#702)

#### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ public static int nglfwCreateWindowSurface(long instance, long window, long allo
long __functionAddress = Functions.CreateWindowSurface;
if (CHECKS) {
check(window);
if (allocator != NULL) { VkAllocationCallbacks.validate(allocator); }
}
return invokePPPPI(instance, window, allocator, surface, __functionAddress);
}
Expand Down Expand Up @@ -337,7 +336,6 @@ public static int glfwCreateWindowSurface(VkInstance instance, @NativeType("GLFW
if (CHECKS) {
check(window);
check(surface, 1);
if (allocator != null) { VkAllocationCallbacks.validate(allocator.address()); }
}
return invokePPPPI(instance.address(), window, memAddressSafe(allocator), surface, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,6 @@ public static void vmaDestroyImage(@NativeType("VmaAllocator") long allocator, @
public static int vmaCreateVirtualBlock(@NativeType("VmaVirtualBlockCreateInfo const *") VmaVirtualBlockCreateInfo pCreateInfo, @NativeType("VmaVirtualBlock *") PointerBuffer pVirtualBlock) {
if (CHECKS) {
check(pVirtualBlock, 1);
VmaVirtualBlockCreateInfo.validate(pCreateInfo.address());
}
return nvmaCreateVirtualBlock(pCreateInfo.address(), memAddress(pVirtualBlock));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,6 @@ public static VmaAllocatorCreateInfo calloc(MemoryStack stack) {
public static void validate(long struct) {
check(memGetAddress(struct + VmaAllocatorCreateInfo.PHYSICALDEVICE));
check(memGetAddress(struct + VmaAllocatorCreateInfo.DEVICE));
long pAllocationCallbacks = memGetAddress(struct + VmaAllocatorCreateInfo.PALLOCATIONCALLBACKS);
if (pAllocationCallbacks != NULL) {
VkAllocationCallbacks.validate(pAllocationCallbacks);
}
long pVulkanFunctions = memGetAddress(struct + VmaAllocatorCreateInfo.PVULKANFUNCTIONS);
check(pVulkanFunctions);
VmaVulkanFunctions.validate(pVulkanFunctions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,6 @@ public static VmaVirtualBlockCreateInfo.Buffer calloc(int capacity, MemoryStack
/** Unsafe version of {@link #pAllocationCallbacks(VkAllocationCallbacks) pAllocationCallbacks}. */
public static void npAllocationCallbacks(long struct, @Nullable VkAllocationCallbacks value) { memPutAddress(struct + VmaVirtualBlockCreateInfo.PALLOCATIONCALLBACKS, memAddressSafe(value)); }

/**
* Validates pointer members that should not be {@code NULL}.
*
* @param struct the struct to validate
*/
public static void validate(long struct) {
long pAllocationCallbacks = memGetAddress(struct + VmaVirtualBlockCreateInfo.PALLOCATIONCALLBACKS);
if (pAllocationCallbacks != NULL) {
VkAllocationCallbacks.validate(pAllocationCallbacks);
}
}

// -----------------------------------

/** An array of {@link VmaVirtualBlockCreateInfo} structs. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ public static int nvkCreateDebugReportCallbackEXT(VkInstance instance, long pCre
if (CHECKS) {
check(__functionAddress);
VkDebugReportCallbackCreateInfoEXT.validate(pCreateInfo);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(instance.address(), pCreateInfo, pAllocator, pCallback, __functionAddress);
}
Expand Down Expand Up @@ -352,7 +351,6 @@ public static void nvkDestroyDebugReportCallbackEXT(VkInstance instance, long ca
long __functionAddress = instance.getCapabilities().vkDestroyDebugReportCallbackEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(instance.address(), callback, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -542,7 +540,6 @@ public static int vkCreateDebugReportCallbackEXT(VkInstance instance, @NativeTyp
check(__functionAddress);
check(pCallback, 1);
VkDebugReportCallbackCreateInfoEXT.validate(pCreateInfo.address());
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(instance.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pCallback, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ public static int nvkCreateDebugUtilsMessengerEXT(VkInstance instance, long pCre
if (CHECKS) {
check(__functionAddress);
VkDebugUtilsMessengerCreateInfoEXT.validate(pCreateInfo);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(instance.address(), pCreateInfo, pAllocator, pMessenger, __functionAddress);
}
Expand Down Expand Up @@ -885,7 +884,6 @@ public static void nvkDestroyDebugUtilsMessengerEXT(VkInstance instance, long me
long __functionAddress = instance.getCapabilities().vkDestroyDebugUtilsMessengerEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(instance.address(), messenger, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -1006,7 +1004,6 @@ public static int vkCreateDebugUtilsMessengerEXT(VkInstance instance, @NativeTyp
check(__functionAddress);
check(pMessenger, 1);
VkDebugUtilsMessengerCreateInfoEXT.validate(pCreateInfo.address());
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(instance.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pMessenger, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public static int nvkRegisterDeviceEventEXT(VkDevice device, long pDeviceEventIn
long __functionAddress = device.getCapabilities().vkRegisterDeviceEventEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(device.address(), pDeviceEventInfo, pAllocator, pFence, __functionAddress);
}
Expand Down Expand Up @@ -269,7 +268,6 @@ public static int nvkRegisterDisplayEventEXT(VkDevice device, long display, long
long __functionAddress = device.getCapabilities().vkRegisterDisplayEventEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPJPPPI(device.address(), display, pDisplayEventInfo, pAllocator, pFence, __functionAddress);
}
Expand Down Expand Up @@ -411,7 +409,6 @@ public static int vkRegisterDeviceEventEXT(VkDevice device, @NativeType("VkDevic
if (CHECKS) {
check(__functionAddress);
check(pFence, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(device.address(), pDeviceEventInfo.address(), memAddressSafe(pAllocator), pFence, __functionAddress);
}
Expand All @@ -423,7 +420,6 @@ public static int vkRegisterDisplayEventEXT(VkDevice device, @NativeType("VkDisp
if (CHECKS) {
check(__functionAddress);
check(pFence, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPJPPPI(device.address(), display, pDisplayEventInfo.address(), memAddressSafe(pAllocator), pFence, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public static int nvkCreateHeadlessSurfaceEXT(VkInstance instance, long pCreateI
long __functionAddress = instance.getCapabilities().vkCreateHeadlessSurfaceEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(instance.address(), pCreateInfo, pAllocator, pSurface, __functionAddress);
}
Expand Down Expand Up @@ -145,7 +144,6 @@ public static int vkCreateHeadlessSurfaceEXT(VkInstance instance, @NativeType("V
if (CHECKS) {
check(__functionAddress);
check(pSurface, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(instance.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pSurface, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public static int nvkCreateMetalSurfaceEXT(VkInstance instance, long pCreateInfo
long __functionAddress = instance.getCapabilities().vkCreateMetalSurfaceEXT;
if (CHECKS) {
check(__functionAddress);
VkMetalSurfaceCreateInfoEXT.validate(pCreateInfo);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(instance.address(), pCreateInfo, pAllocator, pSurface, __functionAddress);
}
Expand Down Expand Up @@ -143,8 +141,6 @@ public static int vkCreateMetalSurfaceEXT(VkInstance instance, @NativeType("VkMe
if (CHECKS) {
check(__functionAddress);
check(pSurface, 1);
VkMetalSurfaceCreateInfoEXT.validate(pCreateInfo.address());
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(instance.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pSurface, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public static int nvkCreatePrivateDataSlotEXT(VkDevice device, long pCreateInfo,
long __functionAddress = device.getCapabilities().vkCreatePrivateDataSlotEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(device.address(), pCreateInfo, pAllocator, pPrivateDataSlot, __functionAddress);
}
Expand Down Expand Up @@ -170,7 +169,6 @@ public static void nvkDestroyPrivateDataSlotEXT(VkDevice device, long privateDat
long __functionAddress = device.getCapabilities().vkDestroyPrivateDataSlotEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(device.address(), privateDataSlot, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -352,7 +350,6 @@ public static int vkCreatePrivateDataSlotEXT(VkDevice device, @NativeType("VkPri
if (CHECKS) {
check(__functionAddress);
check(pPrivateDataSlot, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(device.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pPrivateDataSlot, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public static int nvkCreateValidationCacheEXT(VkDevice device, long pCreateInfo,
if (CHECKS) {
check(__functionAddress);
VkValidationCacheCreateInfoEXT.validate(pCreateInfo);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(device.address(), pCreateInfo, pAllocator, pValidationCache, __functionAddress);
}
Expand Down Expand Up @@ -188,7 +187,6 @@ public static void nvkDestroyValidationCacheEXT(VkDevice device, long validation
long __functionAddress = device.getCapabilities().vkDestroyValidationCacheEXT;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(device.address(), validationCache, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -425,7 +423,6 @@ public static int vkCreateValidationCacheEXT(VkDevice device, @NativeType("VkVal
check(__functionAddress);
check(pValidationCache, 1);
VkValidationCacheCreateInfoEXT.validate(pCreateInfo.address());
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(device.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pValidationCache, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ public static int nvkCreateAccelerationStructureKHR(VkDevice device, long pCreat
long __functionAddress = device.getCapabilities().vkCreateAccelerationStructureKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(device.address(), pCreateInfo, pAllocator, pAccelerationStructure, __functionAddress);
}
Expand Down Expand Up @@ -503,7 +502,6 @@ public static void nvkDestroyAccelerationStructureKHR(VkDevice device, long acce
long __functionAddress = device.getCapabilities().vkDestroyAccelerationStructureKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(device.address(), accelerationStructure, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -1891,7 +1889,6 @@ public static int vkCreateAccelerationStructureKHR(VkDevice device, @NativeType(
if (CHECKS) {
check(__functionAddress);
check(pAccelerationStructure, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(device.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pAccelerationStructure, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public static int nvkCreateRenderPass2KHR(VkDevice device, long pCreateInfo, lon
if (CHECKS) {
check(__functionAddress);
VkRenderPassCreateInfo2.validate(pCreateInfo);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(device.address(), pCreateInfo, pAllocator, pRenderPass, __functionAddress);
}
Expand Down Expand Up @@ -214,7 +213,6 @@ public static int vkCreateRenderPass2KHR(VkDevice device, @NativeType("VkRenderP
check(__functionAddress);
check(pRenderPass, 1);
VkRenderPassCreateInfo2.validate(pCreateInfo.address());
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(device.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pRenderPass, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public static int nvkCreateDeferredOperationKHR(VkDevice device, long pAllocator
long __functionAddress = device.getCapabilities().vkCreateDeferredOperationKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPI(device.address(), pAllocator, pDeferredOperation, __functionAddress);
}
Expand Down Expand Up @@ -272,7 +271,6 @@ public static void nvkDestroyDeferredOperationKHR(VkDevice device, long operatio
long __functionAddress = device.getCapabilities().vkDestroyDeferredOperationKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(device.address(), operation, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -504,7 +502,6 @@ public static int vkCreateDeferredOperationKHR(VkDevice device, @Nullable @Nativ
if (CHECKS) {
check(__functionAddress);
check(pDeferredOperation, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPI(device.address(), memAddressSafe(pAllocator), pDeferredOperation, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public static int nvkCreateDescriptorUpdateTemplateKHR(VkDevice device, long pCr
if (CHECKS) {
check(__functionAddress);
VkDescriptorUpdateTemplateCreateInfo.validate(pCreateInfo);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(device.address(), pCreateInfo, pAllocator, pDescriptorUpdateTemplate, __functionAddress);
}
Expand Down Expand Up @@ -131,7 +130,6 @@ public static void nvkDestroyDescriptorUpdateTemplateKHR(VkDevice device, long d
long __functionAddress = device.getCapabilities().vkDestroyDescriptorUpdateTemplateKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
callPJPV(device.address(), descriptorUpdateTemplate, pAllocator, __functionAddress);
}
Expand Down Expand Up @@ -161,7 +159,6 @@ public static void vkUpdateDescriptorSetWithTemplateKHR(VkDevice device, @Native
long __functionAddress = device.getCapabilities().vkUpdateDescriptorSetWithTemplateKHR;
if (CHECKS) {
check(__functionAddress);
check(pData);
}
callPJJPV(device.address(), descriptorSet, descriptorUpdateTemplate, pData, __functionAddress);
}
Expand Down Expand Up @@ -271,7 +268,6 @@ public static void vkCmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer command
long __functionAddress = commandBuffer.getCapabilities().vkCmdPushDescriptorSetWithTemplateKHR;
if (CHECKS) {
check(__functionAddress);
check(pData);
}
callPJJPV(commandBuffer.address(), descriptorUpdateTemplate, layout, set, pData, __functionAddress);
}
Expand All @@ -284,7 +280,6 @@ public static int vkCreateDescriptorUpdateTemplateKHR(VkDevice device, @NativeTy
check(__functionAddress);
check(pDescriptorUpdateTemplate, 1);
VkDescriptorUpdateTemplateCreateInfo.validate(pCreateInfo.address());
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(device.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pDescriptorUpdateTemplate, __functionAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ public static int nvkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, long
long __functionAddress = physicalDevice.getCapabilities().vkCreateDisplayModeKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPJPPPI(physicalDevice.address(), display, pCreateInfo, pAllocator, pMode, __functionAddress);
}
Expand Down Expand Up @@ -573,7 +572,6 @@ public static int nvkCreateDisplayPlaneSurfaceKHR(VkInstance instance, long pCre
long __functionAddress = instance.getCapabilities().vkCreateDisplayPlaneSurfaceKHR;
if (CHECKS) {
check(__functionAddress);
if (pAllocator != NULL) { VkAllocationCallbacks.validate(pAllocator); }
}
return callPPPPI(instance.address(), pCreateInfo, pAllocator, pSurface, __functionAddress);
}
Expand Down Expand Up @@ -687,7 +685,6 @@ public static int vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, @Nativ
if (CHECKS) {
check(__functionAddress);
check(pMode, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPJPPPI(physicalDevice.address(), display, pCreateInfo.address(), memAddressSafe(pAllocator), pMode, __functionAddress);
}
Expand All @@ -699,7 +696,6 @@ public static int vkCreateDisplayPlaneSurfaceKHR(VkInstance instance, @NativeTyp
if (CHECKS) {
check(__functionAddress);
check(pSurface, 1);
if (pAllocator != null) { VkAllocationCallbacks.validate(pAllocator.address()); }
}
return callPPPPI(instance.address(), pCreateInfo.address(), memAddressSafe(pAllocator), pSurface, __functionAddress);
}
Expand Down
Loading

0 comments on commit 3eb2b82

Please sign in to comment.