Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

145 řádky
5.8 KiB

  1. unit uvkuPhysicalDevice;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TVkSparseImageFormatPropertiesArr = array of TVkSparseImageFormatProperties;
  10. TvkuPhysicalDevice = class(TObject)
  11. private type
  12. TPropertyFlag = (
  13. pfFeatures,
  14. pfProperties,
  15. pfMemoryProperties
  16. );
  17. TPropertyFlags = set of TPropertyFlag;
  18. private
  19. fHandle: VkPhysicalDevice;
  20. fCached: TPropertyFlags;
  21. fFeatures: TVkPhysicalDeviceFeatures;
  22. fProperties: TVkPhysicalDeviceProperties;
  23. fMemoryProperties: TVkPhysicalDeviceMemoryProperties;
  24. fFormatProperties: array[TVkFormat] of PVkFormatProperties;
  25. function GetFeatures: TVkPhysicalDeviceFeatures;
  26. function GetProperties: TVkPhysicalDeviceProperties;
  27. function GetMemoryProperties: TVkPhysicalDeviceMemoryProperties;
  28. function GetQueueFamilyPropertyCount: Integer;
  29. function GetQueueFamilyProperties(const aIndex: Integer): TVkQueueFamilyProperties;
  30. function GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties;
  31. public
  32. property Handle: VkPhysicalDevice read fHandle;
  33. property Features: TVkPhysicalDeviceFeatures read GetFeatures;
  34. property Properties: TVkPhysicalDeviceProperties read GetProperties;
  35. property MemoryProperties: TVkPhysicalDeviceMemoryProperties read GetMemoryProperties;
  36. property QueueFamilyPropertyCount: Integer read GetQueueFamilyPropertyCount;
  37. property QueueFamilyProperties[const aIndex: Integer]: TVkQueueFamilyProperties read GetQueueFamilyProperties;
  38. property FormatProperties[const aFormat: TVkFormat]: TVkFormatProperties read GetFormatProperties;
  39. function GetImageFormatProperties(
  40. const aFormat: TVkFormat;
  41. const aImageType: TVkImageType;
  42. const aTiling: TVkImageTiling;
  43. const aUsage: VkImageUsageFlags;
  44. const aFlags: VkImageCreateFlags): TVkImageFormatProperties;
  45. function GetSparseImageFormatProperties(
  46. const aFormat: TVkFormat;
  47. const aImageType: TVkImageType;
  48. const aSamples: TVkSampleCountFlagBits;
  49. const aUsage: VkImageUsageFlags;
  50. const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr;
  51. constructor Create(const aHandle: VkPhysicalDevice);
  52. end;
  53. implementation
  54. uses
  55. uvkuUtils;
  56. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  57. //TvkuPhysicalDevice/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  58. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  59. function TvkuPhysicalDevice.GetFeatures: TVkPhysicalDeviceFeatures;
  60. begin
  61. if not (pfFeatures in fCached) then begin
  62. vkGetPhysicalDeviceFeatures(fHandle, @fFeatures);
  63. Include(fCached, pfFeatures);
  64. end;
  65. result := fFeatures;
  66. end;
  67. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  68. function TvkuPhysicalDevice.GetProperties: TVkPhysicalDeviceProperties;
  69. begin
  70. if not (pfProperties in fCached) then begin
  71. vkGetPhysicalDeviceProperties(fHandle, @fProperties);
  72. Include(fCached, pfProperties);
  73. end;
  74. result := fProperties;
  75. end;
  76. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  77. function TvkuPhysicalDevice.GetMemoryProperties: TVkPhysicalDeviceMemoryProperties;
  78. begin
  79. if not (pfMemoryProperties in fCached) then begin
  80. vkGetPhysicalDeviceMemoryProperties(fHandle, @fMemoryProperties);
  81. Include(fCached, pfMemoryProperties);
  82. end;
  83. result := fMemoryProperties;
  84. end;
  85. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  86. function TvkuPhysicalDevice.GetQueueFamilyPropertyCount: Integer;
  87. begin
  88. end;
  89. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  90. function TvkuPhysicalDevice.GetQueueFamilyProperties(const aIndex: Integer): TVkQueueFamilyProperties;
  91. begin
  92. end;
  93. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  94. function TvkuPhysicalDevice.GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties;
  95. begin
  96. end;
  97. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  98. function TvkuPhysicalDevice.GetImageFormatProperties(const aFormat: TVkFormat; const aImageType: TVkImageType;
  99. const aTiling: TVkImageTiling; const aUsage: VkImageUsageFlags; const aFlags: VkImageCreateFlags): TVkImageFormatProperties;
  100. begin
  101. end;
  102. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  103. function TvkuPhysicalDevice.GetSparseImageFormatProperties(const aFormat: TVkFormat; const aImageType: TVkImageType;
  104. const aSamples: TVkSampleCountFlagBits; const aUsage: VkImageUsageFlags; const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr;
  105. begin
  106. end;
  107. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  108. constructor TvkuPhysicalDevice.Create(const aHandle: VkPhysicalDevice);
  109. begin
  110. if not Assigned(aHandle) then
  111. raise TvkuException.Create('invalid physical device handle');
  112. inherited Create;
  113. fHandle := aHandle;
  114. end;
  115. end.