From 39c28af57526b5d22033fbe767bf2e51dd9505e4 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Tue, 10 Jan 2023 18:20:18 +0100 Subject: [PATCH] Create device --- src/device_handles.rs | 42 ++ src/dummy_functions.rs | 354 -------------- src/instance_handles.rs | 72 +++ src/layer_device_dispatch_table.rs | 667 --------------------------- src/layer_instance_dispatch_table.rs | 175 ------- src/lib.rs | 134 +++--- src/structs.rs | 6 + 7 files changed, 172 insertions(+), 1278 deletions(-) create mode 100644 src/device_handles.rs delete mode 100644 src/dummy_functions.rs create mode 100644 src/instance_handles.rs delete mode 100644 src/layer_device_dispatch_table.rs delete mode 100644 src/layer_instance_dispatch_table.rs diff --git a/src/device_handles.rs b/src/device_handles.rs new file mode 100644 index 0000000..efb588a --- /dev/null +++ b/src/device_handles.rs @@ -0,0 +1,42 @@ +use crate::instance_handles::instance_fns; +use vulkan_sys::prelude::*; + +static mut DEVICE_FN_HANDLES: Option = None; + +pub fn device_fns() -> &'static VkDeviceHandles { + unsafe { DEVICE_FN_HANDLES.as_ref().unwrap() } +} + +pub fn set_device_fns(handles: VkDeviceHandles) { + unsafe { DEVICE_FN_HANDLES = Some(handles) }; +} + +pub struct VkDeviceHandles { + pub device: VkDevice, + + pub device_functions: DeviceFunctions, + pub device_wsi_functions: DeviceWSIFunctions, + pub maintenance3_functions: Maintenance3Functions, + + pub acceleration_structure_functions: AccelerationStructureFunctions, + pub ray_tracing_pipeline_functions: RayTracingPipelineFunctions, + + pub deferred_operation_functions: DeferredOperationsFunctions, +} + +impl VkDeviceHandles { + pub fn new(device: VkDevice) -> Self { + let instance = &instance_fns().instance_functions; + + Self { + device, + + device_functions: DeviceFunctions::new(instance, device), + device_wsi_functions: DeviceWSIFunctions::new(instance, device), + maintenance3_functions: Maintenance3Functions::new(instance, device), + acceleration_structure_functions: AccelerationStructureFunctions::new(instance, device), + ray_tracing_pipeline_functions: RayTracingPipelineFunctions::new(instance, device), + deferred_operation_functions: DeferredOperationsFunctions::new(instance, device), + } + } +} diff --git a/src/dummy_functions.rs b/src/dummy_functions.rs deleted file mode 100644 index 652e436..0000000 --- a/src/dummy_functions.rs +++ /dev/null @@ -1,354 +0,0 @@ -#![allow(non_camel_case_types)] - -use vulkan_sys::prelude::*; - -// instance -pub type PFN_GetPhysicalDeviceProcAddr = PFN_vkVoidFunction; -pub type PFN_vkEnumerateDeviceLayerProperties = PFN_vkVoidFunction; -pub type PFN_vkEnumerateInstanceVersion = PFN_vkVoidFunction; -pub type PFN_vkEnumeratePhysicalDeviceGroups = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceFeatures2 = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceProperties2 = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceFormatProperties2 = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceImageFormatProperties2 = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalBufferProperties = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalFenceProperties = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalSemaphoreProperties = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceToolProperties = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDevicePresentRectanglesKHR = PFN_vkVoidFunction; -pub type PFN_vkEnumeratePhysicalDeviceGroupsKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR = PFN_vkVoidFunction; -pub type PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceDisplayProperties2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetDisplayModeProperties2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetDisplayPlaneCapabilities2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR = PFN_vkVoidFunction; -pub type PFN_vkDebugReportMessageEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT = PFN_vkVoidFunction; -pub type PFN_vkSubmitDebugUtilsMessageEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceToolPropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = PFN_vkVoidFunction; -pub type PFN_vkCreateHeadlessSurfaceEXT = PFN_vkVoidFunction; -pub type PFN_vkAcquireDrmDisplayEXT = PFN_vkVoidFunction; -pub type PFN_vkGetDrmDisplayEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceSurfaceFormats2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetPhysicalDeviceQueueFamilyProperties2 = PFN_vkVoidFunction; - -// device -pub type PFN_vkGetDeviceMemoryCommitment = PFN_vkVoidFunction; -pub type PFN_vkQueueBindSparse = PFN_vkVoidFunction; -pub type PFN_vkGetFenceStatus = PFN_vkVoidFunction; -pub type PFN_vkGetRenderAreaGranularity = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceGroupPeerMemoryFeatures = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDeviceMask = PFN_vkVoidFunction; -pub type PFN_vkCmdDispatchBase = PFN_vkVoidFunction; -pub type PFN_vkGetImageSparseMemoryRequirements2 = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceQueue2 = PFN_vkVoidFunction; -pub type PFN_vkCreateSamplerYcbcrConversion = PFN_vkVoidFunction; -pub type PFN_vkDestroySamplerYcbcrConversion = PFN_vkVoidFunction; -pub type PFN_vkCreateDescriptorUpdateTemplate = PFN_vkVoidFunction; -pub type PFN_vkDestroyDescriptorUpdateTemplate = PFN_vkVoidFunction; -pub type PFN_vkUpdateDescriptorSetWithTemplate = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndirectCount = PFN_vkVoidFunction; -pub type PFN_vkCreateRenderPass2 = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndexedIndirectCount = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginRenderPass2 = PFN_vkVoidFunction; -pub type PFN_vkCmdNextSubpass2 = PFN_vkVoidFunction; -pub type PFN_vkCmdEndRenderPass2 = PFN_vkVoidFunction; -pub type PFN_vkResetQueryPool = PFN_vkVoidFunction; -pub type PFN_vkGetSemaphoreCounterValue = PFN_vkVoidFunction; -pub type PFN_vkWaitSemaphores = PFN_vkVoidFunction; -pub type PFN_vkSignalSemaphore = PFN_vkVoidFunction; -pub type PFN_vkGetBufferOpaqueCaptureAddress = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceMemoryOpaqueCaptureAddress = PFN_vkVoidFunction; -pub type PFN_vkCreatePrivateDataSlot = PFN_vkVoidFunction; -pub type PFN_vkDestroyPrivateDataSlot = PFN_vkVoidFunction; -pub type PFN_vkSetPrivateData = PFN_vkVoidFunction; -pub type PFN_vkGetPrivateData = PFN_vkVoidFunction; -pub type PFN_vkCmdSetEvent2 = PFN_vkVoidFunction; -pub type PFN_vkCmdResetEvent2 = PFN_vkVoidFunction; -pub type PFN_vkCmdWaitEvents2 = PFN_vkVoidFunction; -pub type PFN_vkCmdPipelineBarrier2 = PFN_vkVoidFunction; -pub type PFN_vkCmdWriteTimestamp2 = PFN_vkVoidFunction; -pub type PFN_vkQueueSubmit2 = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyBuffer2 = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyImage2 = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyBufferToImage2 = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyImageToBuffer2 = PFN_vkVoidFunction; -pub type PFN_vkCmdBlitImage2 = PFN_vkVoidFunction; -pub type PFN_vkCmdResolveImage2 = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginRendering = PFN_vkVoidFunction; -pub type PFN_vkCmdEndRendering = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCullMode = PFN_vkVoidFunction; -pub type PFN_vkCmdSetFrontFace = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPrimitiveTopology = PFN_vkVoidFunction; -pub type PFN_vkCmdSetViewportWithCount = PFN_vkVoidFunction; -pub type PFN_vkCmdSetScissorWithCount = PFN_vkVoidFunction; -pub type PFN_vkCmdBindVertexBuffers2 = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthTestEnable = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthWriteEnable = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthCompareOp = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthBoundsTestEnable = PFN_vkVoidFunction; -pub type PFN_vkCmdSetStencilTestEnable = PFN_vkVoidFunction; -pub type PFN_vkCmdSetStencilOp = PFN_vkVoidFunction; -pub type PFN_vkCmdSetRasterizerDiscardEnable = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthBiasEnable = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPrimitiveRestartEnable = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceBufferMemoryRequirements = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceImageMemoryRequirements = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceImageSparseMemoryRequirements = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceGroupPresentCapabilitiesKHR = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceGroupSurfacePresentModesKHR = PFN_vkVoidFunction; -pub type PFN_vkAcquireNextImage2KHR = PFN_vkVoidFunction; -pub type PFN_vkCreateSharedSwapchainsKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginRenderingKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdEndRenderingKHR = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDeviceMaskKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdDispatchBaseKHR = PFN_vkVoidFunction; -pub type PFN_vkTrimCommandPoolKHR = PFN_vkVoidFunction; -pub type PFN_vkGetMemoryFdKHR = PFN_vkVoidFunction; -pub type PFN_vkGetMemoryFdPropertiesKHR = PFN_vkVoidFunction; -pub type PFN_vkImportSemaphoreFdKHR = PFN_vkVoidFunction; -pub type PFN_vkGetSemaphoreFdKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdPushDescriptorSetKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdPushDescriptorSetWithTemplateKHR = PFN_vkVoidFunction; -pub type PFN_vkCreateDescriptorUpdateTemplateKHR = PFN_vkVoidFunction; -pub type PFN_vkDestroyDescriptorUpdateTemplateKHR = PFN_vkVoidFunction; -pub type PFN_vkUpdateDescriptorSetWithTemplateKHR = PFN_vkVoidFunction; -pub type PFN_vkCreateRenderPass2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginRenderPass2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdNextSubpass2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdEndRenderPass2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetSwapchainStatusKHR = PFN_vkVoidFunction; -pub type PFN_vkImportFenceFdKHR = PFN_vkVoidFunction; -pub type PFN_vkGetFenceFdKHR = PFN_vkVoidFunction; -pub type PFN_vkAcquireProfilingLockKHR = PFN_vkVoidFunction; -pub type PFN_vkReleaseProfilingLockKHR = PFN_vkVoidFunction; -pub type PFN_vkGetImageMemoryRequirements2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetBufferMemoryRequirements2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetImageSparseMemoryRequirements2KHR = PFN_vkVoidFunction; -pub type PFN_vkDestroySamplerYcbcrConversionKHR = PFN_vkVoidFunction; -pub type PFN_vkCreateSamplerYcbcrConversionKHR = PFN_vkVoidFunction; -pub type PFN_vkBindBufferMemory2KHR = PFN_vkVoidFunction; -pub type PFN_vkBindImageMemory2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetDescriptorSetLayoutSupportKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndirectCountKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndexedIndirectCountKHR = PFN_vkVoidFunction; -pub type PFN_vkGetSemaphoreCounterValueKHR = PFN_vkVoidFunction; -pub type PFN_vkWaitSemaphoresKHR = PFN_vkVoidFunction; -pub type PFN_vkSignalSemaphoreKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdSetFragmentShadingRateKHR = PFN_vkVoidFunction; -pub type PFN_vkWaitForPresentKHR = PFN_vkVoidFunction; -pub type PFN_vkGetBufferDeviceAddressKHR = PFN_vkVoidFunction; -pub type PFN_vkGetBufferOpaqueCaptureAddressKHR = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPipelineExecutablePropertiesKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPipelineExecutableStatisticsKHR = PFN_vkVoidFunction; -pub type PFN_vkGetPipelineExecutableInternalRepresentationsKHR = PFN_vkVoidFunction; -pub type PFN_vkCmdSetEvent2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdResetEvent2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdWaitEvents2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdPipelineBarrier2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdWriteTimestamp2KHR = PFN_vkVoidFunction; -pub type PFN_vkQueueSubmit2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdWriteBufferMarker2AMD = PFN_vkVoidFunction; -pub type PFN_vkGetQueueCheckpointData2NV = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyBuffer2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyImage2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyBufferToImage2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyImageToBuffer2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdResolveImage2KHR = PFN_vkVoidFunction; -pub type PFN_vkCmdTraceRaysIndirect2KHR = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceBufferMemoryRequirementsKHR = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceImageMemoryRequirementsKHR = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceImageSparseMemoryRequirementsKHR = PFN_vkVoidFunction; -pub type PFN_vkDebugMarkerSetObjectTagEXT = PFN_vkVoidFunction; -pub type PFN_vkDebugMarkerSetObjectNameEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDebugMarkerBeginEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDebugMarkerEndEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDebugMarkerInsertEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBindTransformFeedbackBuffersEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginTransformFeedbackEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdEndTransformFeedbackEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginQueryIndexedEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdEndQueryIndexedEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndirectByteCountEXT = PFN_vkVoidFunction; -pub type PFN_vkCreateCuModuleNVX = PFN_vkVoidFunction; -pub type PFN_vkCreateCuFunctionNVX = PFN_vkVoidFunction; -pub type PFN_vkDestroyCuModuleNVX = PFN_vkVoidFunction; -pub type PFN_vkDestroyCuFunctionNVX = PFN_vkVoidFunction; -pub type PFN_vkCmdCuLaunchKernelNVX = PFN_vkVoidFunction; -pub type PFN_vkGetImageViewHandleNVX = PFN_vkVoidFunction; -pub type PFN_vkGetImageViewAddressNVX = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndirectCountAMD = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawIndexedIndirectCountAMD = PFN_vkVoidFunction; -pub type PFN_vkGetShaderInfoAMD = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginConditionalRenderingEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdEndConditionalRenderingEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetViewportWScalingNV = PFN_vkVoidFunction; -pub type PFN_vkDisplayPowerControlEXT = PFN_vkVoidFunction; -pub type PFN_vkRegisterDeviceEventEXT = PFN_vkVoidFunction; -pub type PFN_vkRegisterDisplayEventEXT = PFN_vkVoidFunction; -pub type PFN_vkGetSwapchainCounterEXT = PFN_vkVoidFunction; -pub type PFN_vkGetRefreshCycleDurationGOOGLE = PFN_vkVoidFunction; -pub type PFN_vkGetPastPresentationTimingGOOGLE = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDiscardRectangleEXT = PFN_vkVoidFunction; -pub type PFN_vkSetHdrMetadataEXT = PFN_vkVoidFunction; -pub type PFN_vkSetDebugUtilsObjectNameEXT = PFN_vkVoidFunction; -pub type PFN_vkSetDebugUtilsObjectTagEXT = PFN_vkVoidFunction; -pub type PFN_vkQueueBeginDebugUtilsLabelEXT = PFN_vkVoidFunction; -pub type PFN_vkQueueEndDebugUtilsLabelEXT = PFN_vkVoidFunction; -pub type PFN_vkQueueInsertDebugUtilsLabelEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBeginDebugUtilsLabelEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdEndDebugUtilsLabelEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdInsertDebugUtilsLabelEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetSampleLocationsEXT = PFN_vkVoidFunction; -pub type PFN_vkGetImageDrmFormatModifierPropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkCreateValidationCacheEXT = PFN_vkVoidFunction; -pub type PFN_vkDestroyValidationCacheEXT = PFN_vkVoidFunction; -pub type PFN_vkMergeValidationCachesEXT = PFN_vkVoidFunction; -pub type PFN_vkGetValidationCacheDataEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBindShadingRateImageNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetViewportShadingRatePaletteNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCoarseSampleOrderNV = PFN_vkVoidFunction; -pub type PFN_vkCreateAccelerationStructureNV = PFN_vkVoidFunction; -pub type PFN_vkDestroyAccelerationStructureNV = PFN_vkVoidFunction; -pub type PFN_vkGetAccelerationStructureMemoryRequirementsNV = PFN_vkVoidFunction; -pub type PFN_vkBindAccelerationStructureMemoryNV = PFN_vkVoidFunction; -pub type PFN_vkCmdBuildAccelerationStructureNV = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyAccelerationStructureNV = PFN_vkVoidFunction; -pub type PFN_vkCmdTraceRaysNV = PFN_vkVoidFunction; -pub type PFN_vkCreateRayTracingPipelinesNV = PFN_vkVoidFunction; -pub type PFN_vkGetRayTracingShaderGroupHandlesNV = PFN_vkVoidFunction; -pub type PFN_vkGetAccelerationStructureHandleNV = PFN_vkVoidFunction; -pub type PFN_vkCmdWriteAccelerationStructuresPropertiesNV = PFN_vkVoidFunction; -pub type PFN_vkCompileDeferredNV = PFN_vkVoidFunction; -pub type PFN_vkGetMemoryHostPointerPropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdWriteBufferMarkerAMD = PFN_vkVoidFunction; -pub type PFN_vkGetCalibratedTimestampsEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMeshTasksNV = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMeshTasksIndirectNV = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMeshTasksIndirectCountNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetExclusiveScissorNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCheckpointNV = PFN_vkVoidFunction; -pub type PFN_vkGetQueueCheckpointDataNV = PFN_vkVoidFunction; -pub type PFN_vkInitializePerformanceApiINTEL = PFN_vkVoidFunction; -pub type PFN_vkUninitializePerformanceApiINTEL = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPerformanceMarkerINTEL = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPerformanceStreamMarkerINTEL = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPerformanceOverrideINTEL = PFN_vkVoidFunction; -pub type PFN_vkAcquirePerformanceConfigurationINTEL = PFN_vkVoidFunction; -pub type PFN_vkQueueSetPerformanceConfigurationINTEL = PFN_vkVoidFunction; -pub type PFN_vkGetPerformanceParameterINTEL = PFN_vkVoidFunction; -pub type PFN_vkSetLocalDimmingAMD = PFN_vkVoidFunction; -pub type PFN_vkGetBufferDeviceAddressEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetLineStippleEXT = PFN_vkVoidFunction; -pub type PFN_vkResetQueryPoolEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCullModeEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPrimitiveTopologyEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetViewportWithCountEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetScissorWithCountEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBindVertexBuffers2EXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthTestEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthWriteEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthCompareOpEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthBoundsTestEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetStencilTestEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetStencilOpEXT = PFN_vkVoidFunction; -pub type PFN_vkGetGeneratedCommandsMemoryRequirementsNV = PFN_vkVoidFunction; -pub type PFN_vkCmdPreprocessGeneratedCommandsNV = PFN_vkVoidFunction; -pub type PFN_vkCmdExecuteGeneratedCommandsNV = PFN_vkVoidFunction; -pub type PFN_vkCmdBindPipelineShaderGroupNV = PFN_vkVoidFunction; -pub type PFN_vkCreateIndirectCommandsLayoutNV = PFN_vkVoidFunction; -pub type PFN_vkDestroyIndirectCommandsLayoutNV = PFN_vkVoidFunction; -pub type PFN_vkCreatePrivateDataSlotEXT = PFN_vkVoidFunction; -pub type PFN_vkDestroyPrivateDataSlotEXT = PFN_vkVoidFunction; -pub type PFN_vkSetPrivateDataEXT = PFN_vkVoidFunction; -pub type PFN_vkGetPrivateDataEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetFragmentShadingRateEnumNV = PFN_vkVoidFunction; -pub type PFN_vkGetImageSubresourceLayout2EXT = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceFaultInfoEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetVertexInputEXT = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = PFN_vkVoidFunction; -pub type PFN_vkCmdSubpassShadingHUAWEI = PFN_vkVoidFunction; -pub type PFN_vkCmdBindInvocationMaskHUAWEI = PFN_vkVoidFunction; -pub type PFN_vkGetMemoryRemoteAddressNV = PFN_vkVoidFunction; -pub type PFN_vkGetPipelinePropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPatchControlPointsEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetRasterizerDiscardEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthBiasEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetLogicOpEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPrimitiveRestartEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetColorWriteEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMultiEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMultiIndexedEXT = PFN_vkVoidFunction; -pub type PFN_vkCreateMicromapEXT = PFN_vkVoidFunction; -pub type PFN_vkDestroyMicromapEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBuildMicromapsEXT = PFN_vkVoidFunction; -pub type PFN_vkBuildMicromapsEXT = PFN_vkVoidFunction; -pub type PFN_vkCopyMicromapEXT = PFN_vkVoidFunction; -pub type PFN_vkCopyMicromapToMemoryEXT = PFN_vkVoidFunction; -pub type PFN_vkCopyMemoryToMicromapEXT = PFN_vkVoidFunction; -pub type PFN_vkWriteMicromapsPropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyMicromapEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyMicromapToMemoryEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdCopyMemoryToMicromapEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdWriteMicromapsPropertiesEXT = PFN_vkVoidFunction; -pub type PFN_vkGetDeviceMicromapCompatibilityEXT = PFN_vkVoidFunction; -pub type PFN_vkGetMicromapBuildSizesEXT = PFN_vkVoidFunction; -pub type PFN_vkSetDeviceMemoryPriorityEXT = PFN_vkVoidFunction; -pub type PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE = PFN_vkVoidFunction; -pub type PFN_vkGetDescriptorSetHostMappingVALVE = PFN_vkVoidFunction; -pub type PFN_vkCmdSetTessellationDomainOriginEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthClampEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetPolygonModeEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetRasterizationSamplesEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetSampleMaskEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetAlphaToCoverageEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetAlphaToOneEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetLogicOpEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetColorBlendEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetColorBlendEquationEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetColorWriteMaskEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetRasterizationStreamEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetConservativeRasterizationModeEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthClipEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetSampleLocationsEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetColorBlendAdvancedEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetProvokingVertexModeEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetLineRasterizationModeEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetLineStippleEnableEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetDepthClipNegativeOneToOneEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetViewportWScalingEnableNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCoverageModulationModeNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCoverageModulationTableEnableNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCoverageModulationTableNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetShadingRateImageEnableNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetRepresentativeFragmentTestEnableNV = PFN_vkVoidFunction; -pub type PFN_vkCmdSetCoverageReductionModeNV = PFN_vkVoidFunction; -pub type PFN_vkGetShaderModuleIdentifierEXT = PFN_vkVoidFunction; -pub type PFN_vkGetShaderModuleCreateInfoIdentifierEXT = PFN_vkVoidFunction; -pub type PFN_vkCreateOpticalFlowSessionNV = PFN_vkVoidFunction; -pub type PFN_vkDestroyOpticalFlowSessionNV = PFN_vkVoidFunction; -pub type PFN_vkBindOpticalFlowSessionImageNV = PFN_vkVoidFunction; -pub type PFN_vkCmdOpticalFlowExecuteNV = PFN_vkVoidFunction; -pub type PFN_vkGetFramebufferTilePropertiesQCOM = PFN_vkVoidFunction; -pub type PFN_vkGetDynamicRenderingTilePropertiesQCOM = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMeshTasksEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMeshTasksIndirectEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdDrawMeshTasksIndirectCountEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdSetFrontFaceEXT = PFN_vkVoidFunction; -pub type PFN_vkCmdBlitImage2KHR = PFN_vkVoidFunction; diff --git a/src/instance_handles.rs b/src/instance_handles.rs new file mode 100644 index 0000000..2035a3b --- /dev/null +++ b/src/instance_handles.rs @@ -0,0 +1,72 @@ +use vulkan_sys::prelude::*; + +static mut INSTANCE_FN_HANDLES: Option = None; + +pub fn instance_fns() -> &'static VkInstanceHandles { + unsafe { INSTANCE_FN_HANDLES.as_ref().unwrap() } +} + +pub fn set_instance_fns(handles: VkInstanceHandles) { + unsafe { INSTANCE_FN_HANDLES = Some(handles) }; +} + +pub struct VkInstanceHandles { + pub instance: VkInstance, + + pub static_functions: StaticFunctions, + pub entry_functions: EntryFunctions, + + pub instance_functions: InstanceFunctions, + pub instance_wsi_functions: InstanceWSIFunctions, + pub physical_device_properties2_functions: PhysicalDeviceProperties2Functions, + pub debug_report_callback_functions: DebugReportCallbackFunctions, + pub debug_utils_messenger_functions: DebugUtilsMessengerFunctions, +} + +impl VkInstanceHandles { + pub fn load_instance( + static_functions: StaticFunctions, + entry_functions: EntryFunctions, + instance: VkInstance, + ) -> Self { + Self { + instance_functions: InstanceFunctions::new(&static_functions, instance), + instance_wsi_functions: InstanceWSIFunctions::new(&static_functions, instance), + physical_device_properties2_functions: PhysicalDeviceProperties2Functions::new( + &static_functions, + instance, + ), + debug_report_callback_functions: DebugReportCallbackFunctions::new( + &static_functions, + instance, + ), + debug_utils_messenger_functions: DebugUtilsMessengerFunctions::new( + &static_functions, + instance, + ), + + instance, + static_functions, + entry_functions, + } + } +} + +macro_rules! cmp_vk_fn { + ($name:ident, {$([$fns:ident, $fn_name:ident],)*}) => { + match $name { + $( + stringify!($fn_name) => return unsafe { + mem::transmute( + instance_fns() + .$fns + .$fn_name, + ) + }, + )* + + _ => () + } + + } +} diff --git a/src/layer_device_dispatch_table.rs b/src/layer_device_dispatch_table.rs deleted file mode 100644 index af17736..0000000 --- a/src/layer_device_dispatch_table.rs +++ /dev/null @@ -1,667 +0,0 @@ -#![allow(non_snake_case)] - -use vulkan_sys::prelude::*; - -use crate::dummy_functions::*; - -#[derive(Clone, Default)] -// Device function pointer dispatch table -pub struct VkLayerDispatchTable { - // ---- Core 1_0 commands - pub GetDeviceProcAddr: Option, - pub DestroyDevice: Option, - pub GetDeviceQueue: Option, - pub QueueSubmit: Option, - pub QueueWaitIdle: Option, - pub DeviceWaitIdle: Option, - pub AllocateMemory: Option, - pub FreeMemory: Option, - pub MapMemory: Option, - pub UnmapMemory: Option, - pub FlushMappedMemoryRanges: Option, - pub InvalidateMappedMemoryRanges: Option, - pub GetDeviceMemoryCommitment: Option, - pub BindBufferMemory: Option, - pub BindImageMemory: Option, - pub GetBufferMemoryRequirements: Option, - pub GetImageMemoryRequirements: Option, - pub GetImageSparseMemoryRequirements: Option, - pub QueueBindSparse: Option, - pub CreateFence: Option, - pub DestroyFence: Option, - pub ResetFences: Option, - pub GetFenceStatus: Option, - pub WaitForFences: Option, - pub CreateSemaphore: Option, - pub DestroySemaphore: Option, - pub CreateEvent: Option, - pub DestroyEvent: Option, - pub GetEventStatus: Option, - pub SetEvent: Option, - pub ResetEvent: Option, - pub CreateQueryPool: Option, - pub DestroyQueryPool: Option, - pub GetQueryPoolResults: Option, - pub CreateBuffer: Option, - pub DestroyBuffer: Option, - pub CreateBufferView: Option, - pub DestroyBufferView: Option, - pub CreateImage: Option, - pub DestroyImage: Option, - pub GetImageSubresourceLayout: Option, - pub CreateImageView: Option, - pub DestroyImageView: Option, - pub CreateShaderModule: Option, - pub DestroyShaderModule: Option, - pub CreatePipelineCache: Option, - pub DestroyPipelineCache: Option, - pub GetPipelineCacheData: Option, - pub MergePipelineCaches: Option, - pub CreateGraphicsPipelines: Option, - pub CreateComputePipelines: Option, - pub DestroyPipeline: Option, - pub CreatePipelineLayout: Option, - pub DestroyPipelineLayout: Option, - pub CreateSampler: Option, - pub DestroySampler: Option, - pub CreateDescriptorSetLayout: Option, - pub DestroyDescriptorSetLayout: Option, - pub CreateDescriptorPool: Option, - pub DestroyDescriptorPool: Option, - pub ResetDescriptorPool: Option, - pub AllocateDescriptorSets: Option, - pub FreeDescriptorSets: Option, - pub UpdateDescriptorSets: Option, - pub CreateFramebuffer: Option, - pub DestroyFramebuffer: Option, - pub CreateRenderPass: Option, - pub DestroyRenderPass: Option, - pub GetRenderAreaGranularity: Option, - pub CreateCommandPool: Option, - pub DestroyCommandPool: Option, - pub ResetCommandPool: Option, - pub AllocateCommandBuffers: Option, - pub FreeCommandBuffers: Option, - pub BeginCommandBuffer: Option, - pub EndCommandBuffer: Option, - pub ResetCommandBuffer: Option, - pub CmdBindPipeline: Option, - pub CmdSetViewport: Option, - pub CmdSetScissor: Option, - pub CmdSetLineWidth: Option, - pub CmdSetDepthBias: Option, - pub CmdSetBlendConstants: Option, - pub CmdSetDepthBounds: Option, - pub CmdSetStencilCompareMask: Option, - pub CmdSetStencilWriteMask: Option, - pub CmdSetStencilReference: Option, - pub CmdBindDescriptorSets: Option, - pub CmdBindIndexBuffer: Option, - pub CmdBindVertexBuffers: Option, - pub CmdDraw: Option, - pub CmdDrawIndexed: Option, - pub CmdDrawIndirect: Option, - pub CmdDrawIndexedIndirect: Option, - pub CmdDispatch: Option, - pub CmdDispatchIndirect: Option, - pub CmdCopyBuffer: Option, - pub CmdCopyImage: Option, - pub CmdBlitImage: Option, - pub CmdCopyBufferToImage: Option, - pub CmdCopyImageToBuffer: Option, - pub CmdUpdateBuffer: Option, - pub CmdFillBuffer: Option, - pub CmdClearColorImage: Option, - pub CmdClearDepthStencilImage: Option, - pub CmdClearAttachments: Option, - pub CmdResolveImage: Option, - pub CmdSetEvent: Option, - pub CmdResetEvent: Option, - pub CmdWaitEvents: Option, - pub CmdPipelineBarrier: Option, - pub CmdBeginQuery: Option, - pub CmdEndQuery: Option, - pub CmdResetQueryPool: Option, - pub CmdWriteTimestamp: Option, - pub CmdCopyQueryPoolResults: Option, - pub CmdPushConstants: Option, - pub CmdBeginRenderPass: Option, - pub CmdNextSubpass: Option, - pub CmdEndRenderPass: Option, - pub CmdExecuteCommands: Option, - - // ---- Core 1_1 commands - pub BindBufferMemory2: Option, - pub BindImageMemory2: Option, - pub GetDeviceGroupPeerMemoryFeatures: Option, - pub CmdSetDeviceMask: Option, - pub CmdDispatchBase: Option, - pub GetImageMemoryRequirements2: Option, - pub GetBufferMemoryRequirements2: Option, - pub GetImageSparseMemoryRequirements2: Option, - pub TrimCommandPool: Option, - pub GetDeviceQueue2: Option, - pub CreateSamplerYcbcrConversion: Option, - pub DestroySamplerYcbcrConversion: Option, - pub CreateDescriptorUpdateTemplate: Option, - pub DestroyDescriptorUpdateTemplate: Option, - pub UpdateDescriptorSetWithTemplate: Option, - pub GetDescriptorSetLayoutSupport: Option, - - // ---- Core 1_2 commands - pub CmdDrawIndirectCount: Option, - pub CmdDrawIndexedIndirectCount: Option, - pub CreateRenderPass2: Option, - pub CmdBeginRenderPass2: Option, - pub CmdNextSubpass2: Option, - pub CmdEndRenderPass2: Option, - pub ResetQueryPool: Option, - pub GetSemaphoreCounterValue: Option, - pub WaitSemaphores: Option, - pub SignalSemaphore: Option, - pub GetBufferDeviceAddress: Option, - pub GetBufferOpaqueCaptureAddress: Option, - pub GetDeviceMemoryOpaqueCaptureAddress: Option, - - // ---- Core 1_3 commands - pub CreatePrivateDataSlot: Option, - pub DestroyPrivateDataSlot: Option, - pub SetPrivateData: Option, - pub GetPrivateData: Option, - pub CmdSetEvent2: Option, - pub CmdResetEvent2: Option, - pub CmdWaitEvents2: Option, - pub CmdPipelineBarrier2: Option, - pub CmdWriteTimestamp2: Option, - pub QueueSubmit2: Option, - pub CmdCopyBuffer2: Option, - pub CmdCopyImage2: Option, - pub CmdCopyBufferToImage2: Option, - pub CmdCopyImageToBuffer2: Option, - pub CmdBlitImage2: Option, - pub CmdResolveImage2: Option, - pub CmdBeginRendering: Option, - pub CmdEndRendering: Option, - pub CmdSetCullMode: Option, - pub CmdSetFrontFace: Option, - pub CmdSetPrimitiveTopology: Option, - pub CmdSetViewportWithCount: Option, - pub CmdSetScissorWithCount: Option, - pub CmdBindVertexBuffers2: Option, - pub CmdSetDepthTestEnable: Option, - pub CmdSetDepthWriteEnable: Option, - pub CmdSetDepthCompareOp: Option, - pub CmdSetDepthBoundsTestEnable: Option, - pub CmdSetStencilTestEnable: Option, - pub CmdSetStencilOp: Option, - pub CmdSetRasterizerDiscardEnable: Option, - pub CmdSetDepthBiasEnable: Option, - pub CmdSetPrimitiveRestartEnable: Option, - pub GetDeviceBufferMemoryRequirements: Option, - pub GetDeviceImageMemoryRequirements: Option, - pub GetDeviceImageSparseMemoryRequirements: - Option, - - // ---- VK_KHR_swapchain extension commands - pub CreateSwapchainKHR: Option, - pub DestroySwapchainKHR: Option, - pub GetSwapchainImagesKHR: Option, - pub AcquireNextImageKHR: Option, - pub QueuePresentKHR: Option, - pub GetDeviceGroupPresentCapabilitiesKHR: Option, - pub GetDeviceGroupSurfacePresentModesKHR: Option, - pub AcquireNextImage2KHR: Option, - - // ---- VK_KHR_display_swapchain extension commands - pub CreateSharedSwapchainsKHR: Option, - - // ---- VK_KHR_dynamic_rendering extension commands - pub CmdBeginRenderingKHR: Option, - pub CmdEndRenderingKHR: Option, - - // ---- VK_KHR_device_group extension commands - pub GetDeviceGroupPeerMemoryFeaturesKHR: Option, - pub CmdSetDeviceMaskKHR: Option, - pub CmdDispatchBaseKHR: Option, - - // ---- VK_KHR_maintenance1 extension commands - pub TrimCommandPoolKHR: Option, - - // ---- VK_KHR_external_memory_fd extension commands - pub GetMemoryFdKHR: Option, - pub GetMemoryFdPropertiesKHR: Option, - - // ---- VK_KHR_external_semaphore_fd extension commands - pub ImportSemaphoreFdKHR: Option, - pub GetSemaphoreFdKHR: Option, - - // ---- VK_KHR_push_descriptor extension commands - pub CmdPushDescriptorSetKHR: Option, - pub CmdPushDescriptorSetWithTemplateKHR: Option, - - // ---- VK_KHR_descriptor_update_template extension commands - pub CreateDescriptorUpdateTemplateKHR: Option, - pub DestroyDescriptorUpdateTemplateKHR: Option, - pub UpdateDescriptorSetWithTemplateKHR: Option, - - // ---- VK_KHR_create_renderpass2 extension commands - pub CreateRenderPass2KHR: Option, - pub CmdBeginRenderPass2KHR: Option, - pub CmdNextSubpass2KHR: Option, - pub CmdEndRenderPass2KHR: Option, - - // ---- VK_KHR_shared_presentable_image extension commands - pub GetSwapchainStatusKHR: Option, - - // ---- VK_KHR_external_fence_fd extension commands - pub ImportFenceFdKHR: Option, - pub GetFenceFdKHR: Option, - - // ---- VK_KHR_performance_query extension commands - pub AcquireProfilingLockKHR: Option, - pub ReleaseProfilingLockKHR: Option, - - // ---- VK_KHR_get_memory_requirements2 extension commands - pub GetImageMemoryRequirements2KHR: Option, - pub GetBufferMemoryRequirements2KHR: Option, - pub GetImageSparseMemoryRequirements2KHR: Option, - - // ---- VK_KHR_sampler_ycbcr_conversion extension commands - pub CreateSamplerYcbcrConversionKHR: Option, - pub DestroySamplerYcbcrConversionKHR: Option, - - // ---- VK_KHR_bind_memory2 extension commands - pub BindBufferMemory2KHR: Option, - pub BindImageMemory2KHR: Option, - - // ---- VK_KHR_maintenance3 extension commands - pub GetDescriptorSetLayoutSupportKHR: Option, - - // ---- VK_KHR_draw_indirect_count extension commands - pub CmdDrawIndirectCountKHR: Option, - pub CmdDrawIndexedIndirectCountKHR: Option, - - // ---- VK_KHR_timeline_semaphore extension commands - pub GetSemaphoreCounterValueKHR: Option, - pub WaitSemaphoresKHR: Option, - pub SignalSemaphoreKHR: Option, - - // ---- VK_KHR_fragment_shading_rate extension commands - pub CmdSetFragmentShadingRateKHR: Option, - - // ---- VK_KHR_present_wait extension commands - pub WaitForPresentKHR: Option, - - // ---- VK_KHR_buffer_device_address extension commands - pub GetBufferDeviceAddressKHR: Option, - pub GetBufferOpaqueCaptureAddressKHR: Option, - pub GetDeviceMemoryOpaqueCaptureAddressKHR: - Option, - - // ---- VK_KHR_deferred_host_operations extension commands - pub CreateDeferredOperationKHR: Option, - pub DestroyDeferredOperationKHR: Option, - pub GetDeferredOperationMaxConcurrencyKHR: Option, - pub GetDeferredOperationResultKHR: Option, - pub DeferredOperationJoinKHR: Option, - - // ---- VK_KHR_pipeline_executable_properties extension commands - pub GetPipelineExecutablePropertiesKHR: Option, - pub GetPipelineExecutableStatisticsKHR: Option, - pub GetPipelineExecutableInternalRepresentationsKHR: - Option, - - // ---- VK_KHR_synchronization2 extension commands - pub CmdSetEvent2KHR: Option, - pub CmdResetEvent2KHR: Option, - pub CmdWaitEvents2KHR: Option, - pub CmdPipelineBarrier2KHR: Option, - pub CmdWriteTimestamp2KHR: Option, - pub QueueSubmit2KHR: Option, - pub CmdWriteBufferMarker2AMD: Option, - pub GetQueueCheckpointData2NV: Option, - - // ---- VK_KHR_copy_commands2 extension commands - pub CmdCopyBuffer2KHR: Option, - pub CmdCopyImage2KHR: Option, - pub CmdCopyBufferToImage2KHR: Option, - pub CmdCopyImageToBuffer2KHR: Option, - pub CmdBlitImage2KHR: Option, - pub CmdResolveImage2KHR: Option, - - // ---- VK_KHR_ray_tracing_maintenance1 extension commands - pub CmdTraceRaysIndirect2KHR: Option, - - // ---- VK_KHR_maintenance4 extension commands - pub GetDeviceBufferMemoryRequirementsKHR: Option, - pub GetDeviceImageMemoryRequirementsKHR: Option, - pub GetDeviceImageSparseMemoryRequirementsKHR: - Option, - - // ---- VK_EXT_debug_marker extension commands - pub DebugMarkerSetObjectTagEXT: Option, - pub DebugMarkerSetObjectNameEXT: Option, - pub CmdDebugMarkerBeginEXT: Option, - pub CmdDebugMarkerEndEXT: Option, - pub CmdDebugMarkerInsertEXT: Option, - - // ---- VK_EXT_transform_feedback extension commands - pub CmdBindTransformFeedbackBuffersEXT: Option, - pub CmdBeginTransformFeedbackEXT: Option, - pub CmdEndTransformFeedbackEXT: Option, - pub CmdBeginQueryIndexedEXT: Option, - pub CmdEndQueryIndexedEXT: Option, - pub CmdDrawIndirectByteCountEXT: Option, - - // ---- VK_NVX_binary_import extension commands - pub CreateCuModuleNVX: Option, - pub CreateCuFunctionNVX: Option, - pub DestroyCuModuleNVX: Option, - pub DestroyCuFunctionNVX: Option, - pub CmdCuLaunchKernelNVX: Option, - - // ---- VK_NVX_image_view_handle extension commands - pub GetImageViewHandleNVX: Option, - pub GetImageViewAddressNVX: Option, - - // ---- VK_AMD_draw_indirect_count extension commands - pub CmdDrawIndirectCountAMD: Option, - pub CmdDrawIndexedIndirectCountAMD: Option, - - // ---- VK_AMD_shader_info extension commands - pub GetShaderInfoAMD: Option, - - // ---- VK_EXT_conditional_rendering extension commands - pub CmdBeginConditionalRenderingEXT: Option, - pub CmdEndConditionalRenderingEXT: Option, - - // ---- VK_NV_clip_space_w_scaling extension commands - pub CmdSetViewportWScalingNV: Option, - - // ---- VK_EXT_display_control extension commands - pub DisplayPowerControlEXT: Option, - pub RegisterDeviceEventEXT: Option, - pub RegisterDisplayEventEXT: Option, - pub GetSwapchainCounterEXT: Option, - - // ---- VK_GOOGLE_display_timing extension commands - pub GetRefreshCycleDurationGOOGLE: Option, - pub GetPastPresentationTimingGOOGLE: Option, - - // ---- VK_EXT_discard_rectangles extension commands - pub CmdSetDiscardRectangleEXT: Option, - - // ---- VK_EXT_hdr_metadata extension commands - pub SetHdrMetadataEXT: Option, - - // ---- VK_EXT_debug_utils extension commands - pub SetDebugUtilsObjectNameEXT: Option, - pub SetDebugUtilsObjectTagEXT: Option, - pub QueueBeginDebugUtilsLabelEXT: Option, - pub QueueEndDebugUtilsLabelEXT: Option, - pub QueueInsertDebugUtilsLabelEXT: Option, - pub CmdBeginDebugUtilsLabelEXT: Option, - pub CmdEndDebugUtilsLabelEXT: Option, - pub CmdInsertDebugUtilsLabelEXT: Option, - - // ---- VK_EXT_sample_locations extension commands - pub CmdSetSampleLocationsEXT: Option, - - // ---- VK_EXT_image_drm_format_modifier extension commands - pub GetImageDrmFormatModifierPropertiesEXT: - Option, - - // ---- VK_EXT_validation_cache extension commands - pub CreateValidationCacheEXT: Option, - pub DestroyValidationCacheEXT: Option, - pub MergeValidationCachesEXT: Option, - pub GetValidationCacheDataEXT: Option, - - // ---- VK_NV_shading_rate_image extension commands - pub CmdBindShadingRateImageNV: Option, - pub CmdSetViewportShadingRatePaletteNV: Option, - pub CmdSetCoarseSampleOrderNV: Option, - - // ---- VK_NV_ray_tracing extension commands - pub CreateAccelerationStructureNV: Option, - pub DestroyAccelerationStructureNV: Option, - pub GetAccelerationStructureMemoryRequirementsNV: - Option, - pub BindAccelerationStructureMemoryNV: Option, - pub CmdBuildAccelerationStructureNV: Option, - pub CmdCopyAccelerationStructureNV: Option, - pub CmdTraceRaysNV: Option, - pub CreateRayTracingPipelinesNV: Option, - pub GetRayTracingShaderGroupHandlesKHR: Option, - pub GetRayTracingShaderGroupHandlesNV: Option, - pub GetAccelerationStructureHandleNV: Option, - pub CmdWriteAccelerationStructuresPropertiesNV: - Option, - pub CompileDeferredNV: Option, - - // ---- VK_EXT_external_memory_host extension commands - pub GetMemoryHostPointerPropertiesEXT: Option, - - // ---- VK_AMD_buffer_marker extension commands - pub CmdWriteBufferMarkerAMD: Option, - - // ---- VK_EXT_calibrated_timestamps extension commands - pub GetCalibratedTimestampsEXT: Option, - - // ---- VK_NV_mesh_shader extension commands - pub CmdDrawMeshTasksNV: Option, - pub CmdDrawMeshTasksIndirectNV: Option, - pub CmdDrawMeshTasksIndirectCountNV: Option, - - // ---- VK_NV_scissor_exclusive extension commands - pub CmdSetExclusiveScissorNV: Option, - - // ---- VK_NV_device_diagnostic_checkpoints extension commands - pub CmdSetCheckpointNV: Option, - pub GetQueueCheckpointDataNV: Option, - - // ---- VK_INTEL_performance_query extension commands - pub InitializePerformanceApiINTEL: Option, - pub UninitializePerformanceApiINTEL: Option, - pub CmdSetPerformanceMarkerINTEL: Option, - pub CmdSetPerformanceStreamMarkerINTEL: Option, - pub CmdSetPerformanceOverrideINTEL: Option, - pub AcquirePerformanceConfigurationINTEL: Option, - pub QueueSetPerformanceConfigurationINTEL: Option, - pub GetPerformanceParameterINTEL: Option, - - // ---- VK_AMD_display_native_hdr extension commands - pub SetLocalDimmingAMD: Option, - - // ---- VK_EXT_buffer_device_address extension commands - pub GetBufferDeviceAddressEXT: Option, - - // ---- VK_EXT_line_rasterization extension commands - pub CmdSetLineStippleEXT: Option, - - // ---- VK_EXT_host_query_reset extension commands - pub ResetQueryPoolEXT: Option, - - // ---- VK_EXT_extended_dynamic_state extension commands - pub CmdSetCullModeEXT: Option, - pub CmdSetFrontFaceEXT: Option, - pub CmdSetPrimitiveTopologyEXT: Option, - pub CmdSetViewportWithCountEXT: Option, - pub CmdSetScissorWithCountEXT: Option, - pub CmdBindVertexBuffers2EXT: Option, - pub CmdSetDepthTestEnableEXT: Option, - pub CmdSetDepthWriteEnableEXT: Option, - pub CmdSetDepthCompareOpEXT: Option, - pub CmdSetDepthBoundsTestEnableEXT: Option, - pub CmdSetStencilTestEnableEXT: Option, - pub CmdSetStencilOpEXT: Option, - - // ---- VK_NV_device_generated_commands extension commands - pub GetGeneratedCommandsMemoryRequirementsNV: - Option, - pub CmdPreprocessGeneratedCommandsNV: Option, - pub CmdExecuteGeneratedCommandsNV: Option, - pub CmdBindPipelineShaderGroupNV: Option, - pub CreateIndirectCommandsLayoutNV: Option, - pub DestroyIndirectCommandsLayoutNV: Option, - - // ---- VK_EXT_private_data extension commands - pub CreatePrivateDataSlotEXT: Option, - pub DestroyPrivateDataSlotEXT: Option, - pub SetPrivateDataEXT: Option, - pub GetPrivateDataEXT: Option, - - // ---- VK_NV_fragment_shading_rate_enums extension commands - pub CmdSetFragmentShadingRateEnumNV: Option, - - // ---- VK_EXT_image_compression_control extension commands - pub GetImageSubresourceLayout2EXT: Option, - - // ---- VK_EXT_device_fault extension commands - pub GetDeviceFaultInfoEXT: Option, - - // ---- VK_EXT_vertex_input_dynamic_state extension commands - pub CmdSetVertexInputEXT: Option, - - // ---- VK_HUAWEI_subpass_shading extension commands - pub GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI: - Option, - pub CmdSubpassShadingHUAWEI: Option, - - // ---- VK_HUAWEI_invocation_mask extension commands - pub CmdBindInvocationMaskHUAWEI: Option, - - // ---- VK_NV_external_memory_rdma extension commands - pub GetMemoryRemoteAddressNV: Option, - - // ---- VK_EXT_pipeline_properties extension commands - pub GetPipelinePropertiesEXT: Option, - - // ---- VK_EXT_extended_dynamic_state2 extension commands - pub CmdSetPatchControlPointsEXT: Option, - pub CmdSetRasterizerDiscardEnableEXT: Option, - pub CmdSetDepthBiasEnableEXT: Option, - pub CmdSetLogicOpEXT: Option, - pub CmdSetPrimitiveRestartEnableEXT: Option, - - // ---- VK_EXT_color_write_enable extension commands - pub CmdSetColorWriteEnableEXT: Option, - - // ---- VK_EXT_multi_draw extension commands - pub CmdDrawMultiEXT: Option, - pub CmdDrawMultiIndexedEXT: Option, - - // ---- VK_EXT_opacity_micromap extension commands - pub CreateMicromapEXT: Option, - pub DestroyMicromapEXT: Option, - pub CmdBuildMicromapsEXT: Option, - pub BuildMicromapsEXT: Option, - pub CopyMicromapEXT: Option, - pub CopyMicromapToMemoryEXT: Option, - pub CopyMemoryToMicromapEXT: Option, - pub WriteMicromapsPropertiesEXT: Option, - pub CmdCopyMicromapEXT: Option, - pub CmdCopyMicromapToMemoryEXT: Option, - pub CmdCopyMemoryToMicromapEXT: Option, - pub CmdWriteMicromapsPropertiesEXT: Option, - pub GetDeviceMicromapCompatibilityEXT: Option, - pub GetMicromapBuildSizesEXT: Option, - - // ---- VK_EXT_pageable_device_local_memory extension commands - pub SetDeviceMemoryPriorityEXT: Option, - - // ---- VK_VALVE_descriptor_set_host_mapping extension commands - pub GetDescriptorSetLayoutHostMappingInfoVALVE: - Option, - pub GetDescriptorSetHostMappingVALVE: Option, - - // ---- VK_EXT_extended_dynamic_state3 extension commands - pub CmdSetTessellationDomainOriginEXT: Option, - pub CmdSetDepthClampEnableEXT: Option, - pub CmdSetPolygonModeEXT: Option, - pub CmdSetRasterizationSamplesEXT: Option, - pub CmdSetSampleMaskEXT: Option, - pub CmdSetAlphaToCoverageEnableEXT: Option, - pub CmdSetAlphaToOneEnableEXT: Option, - pub CmdSetLogicOpEnableEXT: Option, - pub CmdSetColorBlendEnableEXT: Option, - pub CmdSetColorBlendEquationEXT: Option, - pub CmdSetColorWriteMaskEXT: Option, - pub CmdSetRasterizationStreamEXT: Option, - pub CmdSetConservativeRasterizationModeEXT: - Option, - pub CmdSetExtraPrimitiveOverestimationSizeEXT: - Option, - pub CmdSetDepthClipEnableEXT: Option, - pub CmdSetSampleLocationsEnableEXT: Option, - pub CmdSetColorBlendAdvancedEXT: Option, - pub CmdSetProvokingVertexModeEXT: Option, - pub CmdSetLineRasterizationModeEXT: Option, - pub CmdSetLineStippleEnableEXT: Option, - pub CmdSetDepthClipNegativeOneToOneEXT: Option, - pub CmdSetViewportWScalingEnableNV: Option, - pub CmdSetViewportSwizzleNV: Option, - pub CmdSetCoverageToColorEnableNV: Option, - pub CmdSetCoverageToColorLocationNV: Option, - pub CmdSetCoverageModulationModeNV: Option, - pub CmdSetCoverageModulationTableEnableNV: Option, - pub CmdSetCoverageModulationTableNV: Option, - pub CmdSetShadingRateImageEnableNV: Option, - pub CmdSetRepresentativeFragmentTestEnableNV: - Option, - pub CmdSetCoverageReductionModeNV: Option, - - // ---- VK_EXT_shader_module_identifier extension commands - pub GetShaderModuleIdentifierEXT: Option, - pub GetShaderModuleCreateInfoIdentifierEXT: - Option, - - // ---- VK_NV_optical_flow extension commands - pub CreateOpticalFlowSessionNV: Option, - pub DestroyOpticalFlowSessionNV: Option, - pub BindOpticalFlowSessionImageNV: Option, - pub CmdOpticalFlowExecuteNV: Option, - - // ---- VK_QCOM_tile_properties extension commands - pub GetFramebufferTilePropertiesQCOM: Option, - pub GetDynamicRenderingTilePropertiesQCOM: Option, - - // ---- VK_KHR_acceleration_structure extension commands - pub CreateAccelerationStructureKHR: Option, - pub DestroyAccelerationStructureKHR: Option, - pub CmdBuildAccelerationStructuresKHR: Option, - pub CmdBuildAccelerationStructuresIndirectKHR: - Option, - pub BuildAccelerationStructuresKHR: Option, - pub CopyAccelerationStructureKHR: Option, - pub CopyAccelerationStructureToMemoryKHR: Option, - pub CopyMemoryToAccelerationStructureKHR: Option, - pub WriteAccelerationStructuresPropertiesKHR: - Option, - pub CmdCopyAccelerationStructureKHR: Option, - pub CmdCopyAccelerationStructureToMemoryKHR: - Option, - pub CmdCopyMemoryToAccelerationStructureKHR: - Option, - pub GetAccelerationStructureDeviceAddressKHR: - Option, - pub CmdWriteAccelerationStructuresPropertiesKHR: - Option, - pub GetDeviceAccelerationStructureCompatibilityKHR: - Option, - pub GetAccelerationStructureBuildSizesKHR: Option, - - // ---- VK_KHR_ray_tracing_pipeline extension commands - pub CmdTraceRaysKHR: Option, - pub CreateRayTracingPipelinesKHR: Option, - pub GetRayTracingCaptureReplayShaderGroupHandlesKHR: - Option, - pub CmdTraceRaysIndirectKHR: Option, - pub GetRayTracingShaderGroupStackSizeKHR: Option, - pub CmdSetRayTracingPipelineStackSizeKHR: Option, - - // ---- VK_EXT_mesh_shader extension commands - pub CmdDrawMeshTasksEXT: Option, - pub CmdDrawMeshTasksIndirectEXT: Option, - pub CmdDrawMeshTasksIndirectCountEXT: Option, -} diff --git a/src/layer_instance_dispatch_table.rs b/src/layer_instance_dispatch_table.rs deleted file mode 100644 index 1d194d0..0000000 --- a/src/layer_instance_dispatch_table.rs +++ /dev/null @@ -1,175 +0,0 @@ -#![allow(non_snake_case)] - -use vulkan_sys::prelude::*; - -use crate::dummy_functions::*; - -#[derive(Clone, Default)] -pub struct VkLayerInstanceDispatchTable { - // Manually add in GetPhysicalDeviceProcAddr entry - pub GetPhysicalDeviceProcAddr: Option, - - // ---- Core 1_0 commands - pub CreateInstance: Option, - pub DestroyInstance: Option, - pub EnumeratePhysicalDevices: Option, - pub GetPhysicalDeviceFeatures: Option, - pub GetPhysicalDeviceFormatProperties: Option, - pub GetPhysicalDeviceImageFormatProperties: - Option, - pub GetPhysicalDeviceProperties: Option, - pub GetPhysicalDeviceQueueFamilyProperties: - Option, - pub GetPhysicalDeviceMemoryProperties: Option, - pub GetInstanceProcAddr: Option, - pub CreateDevice: Option, - pub EnumerateInstanceExtensionProperties: Option, - pub EnumerateDeviceExtensionProperties: Option, - pub EnumerateInstanceLayerProperties: Option, - pub EnumerateDeviceLayerProperties: Option, - pub GetPhysicalDeviceSparseImageFormatProperties: - Option, - - // ---- Core 1_1 commands - pub EnumerateInstanceVersion: Option, - pub EnumeratePhysicalDeviceGroups: Option, - pub GetPhysicalDeviceFeatures2: Option, - pub GetPhysicalDeviceProperties2: Option, - pub GetPhysicalDeviceFormatProperties2: Option, - pub GetPhysicalDeviceImageFormatProperties2: - Option, - pub GetPhysicalDeviceQueueFamilyProperties2: - Option, - pub GetPhysicalDeviceMemoryProperties2: Option, - pub GetPhysicalDeviceSparseImageFormatProperties2: - Option, - pub GetPhysicalDeviceExternalBufferProperties: - Option, - pub GetPhysicalDeviceExternalFenceProperties: - Option, - pub GetPhysicalDeviceExternalSemaphoreProperties: - Option, - - // ---- Core 1_3 commands - pub GetPhysicalDeviceToolProperties: Option, - - // ---- VK_KHR_surface extension commands - pub DestroySurfaceKHR: Option, - pub GetPhysicalDeviceSurfaceSupportKHR: Option, - pub GetPhysicalDeviceSurfaceCapabilitiesKHR: - Option, - pub GetPhysicalDeviceSurfaceFormatsKHR: Option, - pub GetPhysicalDeviceSurfacePresentModesKHR: - Option, - - // ---- VK_KHR_swapchain extension commands - pub GetPhysicalDevicePresentRectanglesKHR: Option, - - // ---- VK_KHR_display extension commands - pub GetPhysicalDeviceDisplayPropertiesKHR: Option, - pub GetPhysicalDeviceDisplayPlanePropertiesKHR: - Option, - pub GetDisplayPlaneSupportedDisplaysKHR: Option, - pub GetDisplayModePropertiesKHR: Option, - pub CreateDisplayModeKHR: Option, - pub GetDisplayPlaneCapabilitiesKHR: Option, - pub CreateDisplayPlaneSurfaceKHR: Option, - - // ---- VK_KHR_get_physical_device_properties2 extension commands - pub GetPhysicalDeviceFeatures2KHR: Option, - pub GetPhysicalDeviceProperties2KHR: Option, - pub GetPhysicalDeviceFormatProperties2KHR: Option, - pub GetPhysicalDeviceImageFormatProperties2KHR: - Option, - pub GetPhysicalDeviceQueueFamilyProperties2KHR: - Option, - pub GetPhysicalDeviceMemoryProperties2KHR: Option, - pub GetPhysicalDeviceSparseImageFormatProperties2KHR: - Option, - - // ---- VK_KHR_device_group_creation extension commands - pub EnumeratePhysicalDeviceGroupsKHR: Option, - - // ---- VK_KHR_external_memory_capabilities extension commands - pub GetPhysicalDeviceExternalBufferPropertiesKHR: - Option, - - // ---- VK_KHR_external_semaphore_capabilities extension commands - pub GetPhysicalDeviceExternalSemaphorePropertiesKHR: - Option, - - // ---- VK_KHR_external_fence_capabilities extension commands - pub GetPhysicalDeviceExternalFencePropertiesKHR: - Option, - - // ---- VK_KHR_performance_query extension commands - pub EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR: - Option, - pub GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR: - Option, - - // ---- VK_KHR_get_surface_capabilities2 extension commands - pub GetPhysicalDeviceSurfaceCapabilities2KHR: - Option, - pub GetPhysicalDeviceSurfaceFormats2KHR: Option, - - // ---- VK_KHR_get_display_properties2 extension commands - pub GetPhysicalDeviceDisplayProperties2KHR: - Option, - pub GetPhysicalDeviceDisplayPlaneProperties2KHR: - Option, - pub GetDisplayModeProperties2KHR: Option, - pub GetDisplayPlaneCapabilities2KHR: Option, - - // ---- VK_KHR_fragment_shading_rate extension commands - pub GetPhysicalDeviceFragmentShadingRatesKHR: - Option, - - // ---- VK_EXT_debug_report extension commands - pub CreateDebugReportCallbackEXT: Option, - pub DestroyDebugReportCallbackEXT: Option, - pub DebugReportMessageEXT: Option, - - // ---- VK_NV_external_memory_capabilities extension commands - pub GetPhysicalDeviceExternalImageFormatPropertiesNV: - Option, - - // ---- VK_EXT_display_surface_counter extension commands - pub GetPhysicalDeviceSurfaceCapabilities2EXT: - Option, - - // ---- VK_EXT_debug_utils extension commands - pub CreateDebugUtilsMessengerEXT: Option, - pub DestroyDebugUtilsMessengerEXT: Option, - pub SubmitDebugUtilsMessageEXT: Option, - - // ---- VK_EXT_sample_locations extension commands - pub GetPhysicalDeviceMultisamplePropertiesEXT: - Option, - - // ---- VK_EXT_calibrated_timestamps extension commands - pub GetPhysicalDeviceCalibrateableTimeDomainsEXT: - Option, - - // ---- VK_EXT_tooling_info extension commands - pub GetPhysicalDeviceToolPropertiesEXT: Option, - - // ---- VK_NV_cooperative_matrix extension commands - pub GetPhysicalDeviceCooperativeMatrixPropertiesNV: - Option, - - // ---- VK_NV_coverage_reduction_mode extension commands - pub GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV: - Option, - - // ---- VK_EXT_headless_surface extension commands - pub CreateHeadlessSurfaceEXT: Option, - - // ---- VK_EXT_acquire_drm_display extension commands - pub AcquireDrmDisplayEXT: Option, - pub GetDrmDisplayEXT: Option, - - // ---- VK_NV_optical_flow extension commands - pub GetPhysicalDeviceOpticalFlowImageFormatsNV: - Option, -} diff --git a/src/lib.rs b/src/lib.rs index 4eba5af..46d2a88 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,85 +1,18 @@ -pub mod dummy_functions; pub mod enums; -pub mod layer_device_dispatch_table; -pub mod layer_instance_dispatch_table; pub mod structs; -use std::{ - fs::OpenOptions, - io::Write, - mem::{self}, - os::raw::c_char, - ptr, -}; +#[macro_use] +mod instance_handles; +mod device_handles; +use std::{fs::OpenOptions, io::Write, mem, os::raw::c_char, ptr}; + +use device_handles::*; use enums::*; +use instance_handles::*; use structs::*; use vulkan_sys::prelude::*; -static mut INSTANCE_FN_HANDLES: Option = None; - -fn instance_fns() -> &'static VkFunctionHandles { - unsafe { INSTANCE_FN_HANDLES.as_ref().unwrap() } -} - -pub struct VkFunctionHandles { - pub static_functions: StaticFunctions, - pub entry_functions: EntryFunctions, - - pub instance_functions: InstanceFunctions, - pub instance_wsi_functions: InstanceWSIFunctions, - pub physical_device_properties2_functions: PhysicalDeviceProperties2Functions, - pub debug_report_callback_functions: DebugReportCallbackFunctions, - pub debug_utils_messenger_functions: DebugUtilsMessengerFunctions, -} - -impl VkFunctionHandles { - pub fn load_instance( - static_functions: StaticFunctions, - entry_functions: EntryFunctions, - instance: VkInstance, - ) -> Self { - Self { - instance_functions: InstanceFunctions::new(&static_functions, instance), - instance_wsi_functions: InstanceWSIFunctions::new(&static_functions, instance), - physical_device_properties2_functions: PhysicalDeviceProperties2Functions::new( - &static_functions, - instance, - ), - debug_report_callback_functions: DebugReportCallbackFunctions::new( - &static_functions, - instance, - ), - debug_utils_messenger_functions: DebugUtilsMessengerFunctions::new( - &static_functions, - instance, - ), - - static_functions, - entry_functions, - } - } -} - -macro_rules! cmp_vk_fn { - ($name:ident, {$([$fns:ident, $fn_name:ident],)*}) => { - match $name { - $( - stringify!($fn_name) => return unsafe { - mem::transmute( - instance_fns() - .$fns - .$fn_name, - ) - }, - )* - - _ => () - } - - } -} - #[no_mangle] #[allow(non_snake_case)] pub extern "C" fn vkNegotiateLoaderLayerInterfaceVersion( @@ -105,7 +38,7 @@ pub extern "C" fn vkNegotiateLoaderLayerInterfaceVersion( #[no_mangle] extern "system" fn get_device_proc_addr( - device: VkDevice, + _device: VkDevice, function_name: *const c_char, ) -> PFN_vkVoidFunction { write_log("-> vulkan layer device proc addr"); @@ -115,7 +48,7 @@ extern "system" fn get_device_proc_addr( #[no_mangle] extern "system" fn get_instance_proc_addr( - instance: VkInstance, + _instance: VkInstance, function_name: *const c_char, ) -> PFN_vkVoidFunction { write_log("-> vulkan layer instance proc addr"); @@ -204,7 +137,7 @@ extern "system" fn create_instance( ) { Some(info) => info, None => { - write_log("chain info not found."); + write_log("instance chain info not found."); return VK_ERROR_LAYER_NOT_PRESENT; } }; @@ -221,12 +154,13 @@ extern "system" fn create_instance( let result = unsafe { entry_functions.vkCreateInstance(create_info, allocator, instance) }; if result != VK_SUCCESS { return result; - } + }; - let function_handles = - VkFunctionHandles::load_instance(static_functions, entry_functions, unsafe { *instance }); - - unsafe { INSTANCE_FN_HANDLES = Some(function_handles) }; + set_instance_fns(VkInstanceHandles::load_instance( + static_functions, + entry_functions, + unsafe { *instance }, + )); write_log("-> successfully created instance."); @@ -235,6 +169,12 @@ extern "system" fn create_instance( extern "system" fn destroy_instance(instance: VkInstance, allocator: *const VkAllocationCallbacks) { write_log(" ================== vulkan layer destroy instance =================="); + + unsafe { + instance_fns() + .instance_functions + .vkDestroyInstance(instance, allocator) + }; } extern "system" fn create_device( @@ -245,11 +185,41 @@ extern "system" fn create_device( ) -> VkResult { write_log(" ================== vulkan layer create device =================="); + let chain_info = + match VkLayerDeviceCreateInfo::get_chain_info(unsafe { &*create_info }, VK_LAYER_LINK_INFO) + { + Some(info) => info, + None => { + write_log("device chain info not found."); + return VK_ERROR_LAYER_NOT_PRESENT; + } + }; + + chain_info.advance_layer_info(); + let instance = instance_fns(); + let result = unsafe { + instance + .instance_functions + .vkCreateDevice(physical_device, create_info, allocator, device) + }; + + if result != VK_SUCCESS { + return result; + } + + set_device_fns(VkDeviceHandles::new(unsafe { *device })); + VK_SUCCESS } extern "system" fn destroy_device(device: VkDevice, allocator: *const VkAllocationCallbacks) { write_log(" ================== vulkan layer destroy device =================="); + + unsafe { + device_fns() + .device_functions + .vkDestroyDevice(device, allocator) + } } fn write_log(msg: impl ToString) { diff --git a/src/structs.rs b/src/structs.rs index bd4caf3..4262bc7 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -159,6 +159,12 @@ impl VkLayerDeviceCreateInfo { debug_assert!(self.function == VK_LAYER_LINK_INFO); unsafe { &*self.u.layer_info } } + + pub fn advance_layer_info(&mut self) { + debug_assert!(self.function == VK_LAYER_LINK_INFO); + + unsafe { self.u.layer_info = (*self.u.layer_info).next } + } } impl Drop for VkLayerDeviceCreateInfo {