#pragma once #include #include #include #include #include #define VK_NO_PROTOTYPES #include // Helper function to get the size of a struct given a VkStructureType // Hand written, must be updated to include any used struct. inline size_t get_pnext_chain_struct_size(VkStructureType type) { switch (type) { case (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES): return sizeof(VkPhysicalDeviceDescriptorIndexingFeatures); case (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES): return sizeof(VkPhysicalDeviceVulkan11Features); case (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES): return sizeof(VkPhysicalDeviceVulkan12Features); default: assert(false && "Must update get_pnext_chain_struct_size(VkStructureType type) to add type!"); } return 0; } struct VulkanMock { uint32_t api_version = VK_API_VERSION_1_3; std::vector instance_extensions; std::vector instance_layers; std::vector> per_layer_instance_extension_properties; std::vector> per_layer_device_extension_properties; void add_layer(VkLayerProperties layer_properties, std::vector layer_instance_extensions, std::vector layer_device_extensions) { instance_layers.push_back(layer_properties); per_layer_instance_extension_properties.push_back(layer_instance_extensions); per_layer_instance_extension_properties.push_back(layer_device_extensions); } struct SurfaceDetails { VkSurfaceCapabilitiesKHR capabilities{}; std::vector surface_formats; std::vector present_modes; }; std::vector surface_handles; std::vector surface_details; VkSurfaceKHR get_new_surface(SurfaceDetails details) { size_t new_index = 0x123456789AB + surface_handles.size(); surface_handles.push_back(reinterpret_cast(new_index)); surface_details.push_back(details); return surface_handles.back(); } struct PhysicalDeviceDetails { VkPhysicalDeviceProperties properties{}; VkPhysicalDeviceFeatures features{}; VkPhysicalDeviceMemoryProperties memory_properties{}; std::vector extensions; std::vector queue_family_properties; std::vector> features_pNextChain; std::vector created_devices; template void add_features_pNext_struct(T t) { T* new_type = new T(); *new_type = t; features_pNextChain.emplace_back(reinterpret_cast(new_type)); } }; std::vector physical_device_handles; std::vector physical_devices_details; void add_physical_device(PhysicalDeviceDetails details) { size_t new_index = 0x001122334455 + physical_device_handles.size(); physical_device_handles.push_back(reinterpret_cast(new_index)); physical_devices_details.emplace_back(std::move(details)); } }; #if !defined(EXPORT_MACRO) #if defined(WIN32) #define EXPORT_MACRO __declspec(dllexport) #else #define EXPORT_MACRO #endif #endif EXPORT_MACRO VulkanMock& get_vulkan_mock();