LCOV - code coverage report
Current view: top level - xenolith/backend/vk - XLVkInfo.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 3 100.0 %
Date: 2024-05-12 00:16:13 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**
       2             : Copyright (c) 2021 Roman Katuntsev <sbkarr@stappler.org>
       3             : Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       4             : 
       5             : Permission is hereby granted, free of charge, to any person obtaining a copy
       6             : of this software and associated documentation files (the "Software"), to deal
       7             : in the Software without restriction, including without limitation the rights
       8             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       9             : copies of the Software, and to permit persons to whom the Software is
      10             : furnished to do so, subject to the following conditions:
      11             : 
      12             : The above copyright notice and this permission notice shall be included in
      13             : all copies or substantial portions of the Software.
      14             : 
      15             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      18             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      20             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      21             : THE SOFTWARE.
      22             : **/
      23             : 
      24             : #ifndef XENOLITH_BACKEND_VK_XLVKINFO_H_
      25             : #define XENOLITH_BACKEND_VK_XLVKINFO_H_
      26             : 
      27             : #include "XLVk.h"
      28             : 
      29             : namespace STAPPLER_VERSIONIZED stappler::xenolith::vk {
      30             : 
      31             : struct DeviceInfo {
      32             :         struct Features {
      33             :                 static Features getRequired();
      34             :                 static Features getOptional();
      35             : 
      36             : #ifdef VK_ENABLE_BETA_EXTENSIONS
      37             :                 VkPhysicalDevicePortabilitySubsetFeaturesKHR devicePortability = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR, nullptr };
      38             : #endif
      39             :                 VkPhysicalDevice16BitStorageFeaturesKHR device16bitStorage = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR, nullptr };
      40             :                 VkPhysicalDevice8BitStorageFeaturesKHR device8bitStorage = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR, nullptr };
      41             :                 VkPhysicalDeviceShaderFloat16Int8FeaturesKHR deviceShaderFloat16Int8 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR, nullptr };
      42             :                 VkPhysicalDeviceDescriptorIndexingFeaturesEXT deviceDescriptorIndexing = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT, nullptr };
      43             :                 VkPhysicalDeviceBufferDeviceAddressFeaturesKHR deviceBufferDeviceAddress = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR, nullptr };
      44             : 
      45             : #if VK_VERSION_1_3
      46             :                 VkPhysicalDeviceVulkan13Features device13 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, nullptr };
      47             : #endif
      48             :                 VkPhysicalDeviceVulkan12Features device12 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, nullptr };
      49             :                 VkPhysicalDeviceVulkan11Features device11 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, nullptr };
      50             :                 VkPhysicalDeviceFeatures2KHR device10 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR, nullptr };
      51             :                 ExtensionFlags flags = ExtensionFlags::None;
      52             : 
      53             :                 bool canEnable(const Features &, uint32_t version) const;
      54             : 
      55             :                 // enables all features, that enabled in f
      56             :                 void enableFromFeatures(const Features &);
      57             : 
      58             :                 // disables all features, that disabled in f
      59             :                 void disableFromFeatures(const Features &f);
      60             : 
      61             :                 void updateFrom13();
      62             :                 void updateFrom12();
      63             :                 void updateTo12(bool updateFlags = false);
      64             : 
      65             :                 void clear();
      66             : 
      67             :                 Features();
      68             :                 Features(const Features &);
      69             :                 Features &operator=(const Features &);
      70             :         };
      71             : 
      72             :         struct Properties {
      73             : #ifdef VK_ENABLE_BETA_EXTENSIONS
      74             :                 VkPhysicalDevicePortabilitySubsetPropertiesKHR devicePortability = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR, nullptr };
      75             : #endif
      76             :                 VkPhysicalDeviceDescriptorIndexingPropertiesEXT deviceDescriptorIndexing = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT, nullptr };
      77             :                 VkPhysicalDeviceMaintenance3PropertiesKHR deviceMaintenance3 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES_KHR, nullptr };
      78             :                 VkPhysicalDeviceProperties2KHR device10 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR, nullptr };
      79             : 
      80             :                 Properties();
      81             :                 Properties(const Properties &);
      82             :                 Properties &operator=(const Properties &);
      83             :         };
      84             : 
      85             :         struct QueueFamilyInfo {
      86             :                 QueueOperations ops = QueueOperations::None;
      87             :                 uint32_t index = 0;
      88             :                 uint32_t count = 0;
      89             :                 uint32_t used = 0;
      90             :                 VkExtent3D minImageTransferGranularity;
      91             :                 uint32_t presentSurfaceMask;
      92             :         };
      93             : 
      94             :         VkPhysicalDevice device = VK_NULL_HANDLE;
      95             :         QueueFamilyInfo graphicsFamily;
      96             :         QueueFamilyInfo presentFamily;
      97             :         QueueFamilyInfo transferFamily;
      98             :         QueueFamilyInfo computeFamily;
      99             : 
     100             :         Vector<StringView> optionalExtensions;
     101             :         Vector<StringView> promotedExtensions;
     102             :         Vector<String> availableExtensions;
     103             : 
     104             :         Properties properties;
     105             :         Features features;
     106             : 
     107             :         bool requiredExtensionsExists = false;
     108             :         bool requiredFeaturesExists = false;
     109             : 
     110             :         DeviceInfo();
     111             :         DeviceInfo(VkPhysicalDevice, QueueFamilyInfo, QueueFamilyInfo, QueueFamilyInfo, QueueFamilyInfo,
     112             :                         Vector<StringView> &&, Vector<StringView> &&);
     113         100 :         DeviceInfo(const DeviceInfo &) = default;
     114             :         DeviceInfo &operator=(const DeviceInfo &) = default;
     115         126 :         DeviceInfo(DeviceInfo &&) = default;
     116          42 :         DeviceInfo &operator=(DeviceInfo &&) = default;
     117             : 
     118             :         bool supportsPresentation() const;
     119             : 
     120             :         String description() const;
     121             : };
     122             : 
     123             : }
     124             : 
     125             : #endif /* XENOLITH_BACKEND_VK_XLVKINFO_H_ */

Generated by: LCOV version 1.14