Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

506 linhas
28 KiB

  1. unit uvkuUtils;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuException = class(Exception);
  10. TvkuErrorException = class(TvkuException)
  11. private
  12. fError: TVkResult;
  13. public
  14. property Error: TVkResult read fError;
  15. constructor Create(const msg: string; const aError: TVkResult);
  16. end;
  17. TvkuInvalidFuncPtrException = class(TvkuException)
  18. private
  19. fExtensionName: String;
  20. fFunctionName: String;
  21. fExtentionName: String;
  22. public
  23. property FunctionName: String read fFunctionName;
  24. property ExtensionName: String read fExtensionName;
  25. constructor Create(const aFunctionName: String; const aExtensionName: String = '');
  26. end;
  27. function vkuMakeString(const aFeatures: TVkPhysicalDeviceFeatures; const aSeperator: String = sLineBreak): String;
  28. function vkuMakeString(const aProperties: TVkPhysicalDeviceProperties; const aPrintLimits, aPrintSparseProps: Boolean): String;
  29. function vkuMakeString(const aMemoryProperties: TVkPhysicalDeviceMemoryProperties): String;
  30. function vkuGetMemoryTypeIndex(
  31. const aMemoryProperties: TVkPhysicalDeviceMemoryProperties;
  32. aMemoryTypeBits: VkUint32;
  33. const aProperty: TVkMemoryPropertyFlagBit): VkUint32;
  34. implementation
  35. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  36. //TvkuErrorException//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  37. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  38. constructor TvkuErrorException.Create(const msg: string; const aError: TVkResult);
  39. begin
  40. inherited Create(msg);
  41. fError := aError;
  42. end;
  43. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. //TvkuInvalidFuncPtrException////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  45. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  46. constructor TvkuInvalidFuncPtrException.Create(const aFunctionName: String; const aExtensionName: String);
  47. var s: String;
  48. begin
  49. fFunctionName := aFunctionName;
  50. fExtensionName := aExtensionName;
  51. s := 'did you load the vulkan core commands?';
  52. if (aExtensionName <> '') then
  53. s := 'did you enabled/load the ' + fExtensionName + ' extension?';
  54. inherited Create('invalid function pointer: ' + fFunctionName + '; ' + s);
  55. end;
  56. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  57. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  58. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  59. function vkuMakeString(const aFeatures: TVkPhysicalDeviceFeatures; const aSeperator: String): String;
  60. procedure AddToResult(const b: VkBool32; const aName: String);
  61. begin
  62. if (b = 0) then
  63. exit;
  64. if (result <> '') then
  65. result := result + aSeperator;
  66. result := result + aName;
  67. end;
  68. begin
  69. result := '';
  70. AddToResult(aFeatures.robustBufferAccess, 'RobustBufferAccess');
  71. AddToResult(aFeatures.fullDrawIndexUint32, 'FullDrawIndexUint32');
  72. AddToResult(aFeatures.imageCubeArray, 'ImageCubeArray');
  73. AddToResult(aFeatures.independentBlend, 'IndependentBlend');
  74. AddToResult(aFeatures.geometryShader, 'GeometryShader');
  75. AddToResult(aFeatures.tessellationShader, 'TessellationShader');
  76. AddToResult(aFeatures.sampleRateShading, 'SampleRateShading');
  77. AddToResult(aFeatures.dualSrcBlend, 'DualSrcBlend');
  78. AddToResult(aFeatures.logicOp, 'LogicOp');
  79. AddToResult(aFeatures.multiDrawIndirect, 'MultiDrawIndirect');
  80. AddToResult(aFeatures.drawIndirectFirstInstance, 'DrawIndirectFirstInstance');
  81. AddToResult(aFeatures.depthClamp, 'DepthClamp');
  82. AddToResult(aFeatures.depthBiasClamp, 'DepthBiasClamp');
  83. AddToResult(aFeatures.fillModeNonSolid, 'FillModeNonSolid');
  84. AddToResult(aFeatures.depthBounds, 'DepthBounds');
  85. AddToResult(aFeatures.wideLines, 'WideLines');
  86. AddToResult(aFeatures.largePoints, 'LargePoints');
  87. AddToResult(aFeatures.alphaToOne, 'AlphaToOne');
  88. AddToResult(aFeatures.multiViewport, 'MultiViewport');
  89. AddToResult(aFeatures.samplerAnisotropy, 'SamplerAnisotropy');
  90. AddToResult(aFeatures.textureCompressionETC2, 'TextureCompressionETC2');
  91. AddToResult(aFeatures.textureCompressionASTC_LDR, 'TextureCompressionASTC_LDR');
  92. AddToResult(aFeatures.textureCompressionBC, 'TextureCompressionBC');
  93. AddToResult(aFeatures.occlusionQueryPrecise, 'OcclusionQueryPrecise');
  94. AddToResult(aFeatures.pipelineStatisticsQuery, 'PipelineStatisticsQuery');
  95. AddToResult(aFeatures.vertexPipelineStoresAndAtomics, 'VertexPipelineStoresAndAtomics');
  96. AddToResult(aFeatures.fragmentStoresAndAtomics, 'FragmentStoresAndAtomics');
  97. AddToResult(aFeatures.shaderTessellationAndGeometryPointSize, 'ShaderTessellationAndGeometryPointSize');
  98. AddToResult(aFeatures.shaderImageGatherExtended, 'ShaderImageGatherExtended');
  99. AddToResult(aFeatures.shaderStorageImageExtendedFormats, 'ShaderStorageImageExtendedFormats');
  100. AddToResult(aFeatures.shaderStorageImageMultisample, 'ShaderStorageImageMultisample');
  101. AddToResult(aFeatures.shaderStorageImageReadWithoutFormat, 'ShaderStorageImageReadWithoutFormat');
  102. AddToResult(aFeatures.shaderStorageImageWriteWithoutFormat, 'ShaderStorageImageWriteWithoutFormat');
  103. AddToResult(aFeatures.shaderUniformBufferArrayDynamicIndexing, 'ShaderUniformBufferArrayDynamicIndexing');
  104. AddToResult(aFeatures.shaderSampledImageArrayDynamicIndexing, 'ShaderSampledImageArrayDynamicIndexing');
  105. AddToResult(aFeatures.shaderStorageBufferArrayDynamicIndexing, 'ShaderStorageBufferArrayDynamicIndexing');
  106. AddToResult(aFeatures.shaderStorageImageArrayDynamicIndexing, 'ShaderStorageImageArrayDynamicIndexing');
  107. AddToResult(aFeatures.shaderClipDistance, 'ShaderClipDistance');
  108. AddToResult(aFeatures.shaderCullDistance, 'ShaderCullDistance');
  109. AddToResult(aFeatures.shaderFloat64, 'ShaderFloat64');
  110. AddToResult(aFeatures.shaderInt64, 'ShaderInt64');
  111. AddToResult(aFeatures.shaderInt16, 'ShaderInt16');
  112. AddToResult(aFeatures.shaderResourceResidency, 'ShaderResourceResidency');
  113. AddToResult(aFeatures.shaderResourceMinLod, 'ShaderResourceMinLod');
  114. AddToResult(aFeatures.sparseBinding, 'SparseBinding');
  115. AddToResult(aFeatures.sparseResidencyBuffer, 'SparseResidencyBuffer');
  116. AddToResult(aFeatures.sparseResidencyImage2D, 'SparseResidencyImage2D');
  117. AddToResult(aFeatures.sparseResidencyImage3D, 'SparseResidencyImage3D');
  118. AddToResult(aFeatures.sparseResidency2Samples, 'SparseResidency2Samples');
  119. AddToResult(aFeatures.sparseResidency4Samples, 'SparseResidency4Samples');
  120. AddToResult(aFeatures.sparseResidency8Samples, 'SparseResidency8Samples');
  121. AddToResult(aFeatures.sparseResidency16Samples, 'SparseResidency16Samples');
  122. AddToResult(aFeatures.sparseResidencyAliased, 'SparseResidencyAliased');
  123. AddToResult(aFeatures.variableMultisampleRate, 'VariableMultisampleRate');
  124. AddToResult(aFeatures.inheritedQueries, 'InheritedQueries');
  125. end;
  126. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  127. function vkuMakeString(const aProperties: TVkPhysicalDeviceProperties; const aPrintLimits,
  128. aPrintSparseProps: Boolean): String;
  129. function UUIDtoStr: String;
  130. var i: Integer;
  131. begin
  132. result := '';
  133. for i := low(aProperties.pipelineCacheUUID) to High(aProperties.pipelineCacheUUID) do begin
  134. if (result <> '') then
  135. result := result + ':';
  136. result := result + IntToHex(aProperties.pipelineCacheUUID[i], 2);
  137. end;
  138. end;
  139. function toString(const i: Int64): String;
  140. begin
  141. result := IntToStr(i);
  142. end;
  143. function toString(const e: Extended): String;
  144. begin
  145. result := Format('%.3f', [e]);
  146. end;
  147. function toString(const arr: array of VkUint32): String;
  148. var i: Integer;
  149. begin
  150. result := '';
  151. for i := low(arr) to high(arr) do begin
  152. if (i <> low(arr)) then
  153. result := result + '; ';
  154. result := result + toString(arr[i]);
  155. end;
  156. end;
  157. function toString(const arr: array of VkFloat): String;
  158. var i: Integer;
  159. begin
  160. result := '';
  161. for i := low(arr) to high(arr) do begin
  162. if (i <> low(arr)) then
  163. result := result + '; ';
  164. result := result + toString(arr[i]);
  165. end;
  166. end;
  167. function toString(const aType: TVkPhysicalDeviceType): String;
  168. begin
  169. case aType of
  170. VK_PHYSICAL_DEVICE_TYPE_OTHER: result := 'Other';
  171. VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: result := 'IntegratedGPU';
  172. VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: result := 'DiscreteGPU';
  173. VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: result := 'VirtualGPU';
  174. VK_PHYSICAL_DEVICE_TYPE_CPU: result := 'CPU';
  175. else
  176. result := 'Unknown';
  177. end;
  178. end;
  179. function toString(const aChar: PVkChar): String;
  180. begin
  181. result := String(aChar);
  182. end;
  183. begin
  184. result := Format(
  185. 'ApiVersion: %x (v%d.%d.%d)' + sLineBreak +
  186. 'DriverVersion: %s' + sLineBreak +
  187. 'VendorID: %s' + sLineBreak +
  188. 'DeviceID: %s' + sLineBreak +
  189. 'DeviceType: %s' + sLineBreak +
  190. 'deviceName: %s' + sLineBreak +
  191. 'PipelineCacheUUID: %s' + sLineBreak
  192. ,[
  193. aProperties.apiVersion, vkGetVersionMajor(aProperties.apiVersion), vkGetVersionMinor(aProperties.apiVersion), vkgetVersionPatch(aProperties.apiVersion),
  194. toString(aProperties.driverVersion),
  195. toString(aProperties.vendorID),
  196. toString(aProperties.deviceID),
  197. toString(aProperties.deviceType),
  198. toString(@aProperties.deviceName[0]),
  199. UUIDtoStr
  200. ]);
  201. if aPrintLimits then begin
  202. result := result + Format(
  203. 'Limits:' + sLineBreak +
  204. ' MaxImageDimension1D: %s' + sLineBreak +
  205. ' MaxImageDimension2D: %s' + sLineBreak +
  206. ' MaxImageDimension3D: %s' + sLineBreak +
  207. ' MaxImageDimensionCube: %s' + sLineBreak +
  208. ' MaxImageArrayLayers: %s' + sLineBreak +
  209. ' MaxTexelBufferElements: %s' + sLineBreak +
  210. ' MaxUniformBufferRange: %s' + sLineBreak +
  211. ' MaxStorageBufferRange: %s' + sLineBreak +
  212. ' MaxPushConstantsSize: %s' + sLineBreak +
  213. ' MaxMemoryAllocationCount: %s' + sLineBreak +
  214. ' MaxSamplerAllocationCount: %s' + sLineBreak +
  215. ' BufferImageGranularity: %s' + sLineBreak +
  216. ' SparseAddressSpaceSize: %s' + sLineBreak +
  217. ' MaxBoundDescriptorSets: %s' + sLineBreak +
  218. ' MaxPerStageDescriptorSamplers: %s' + sLineBreak +
  219. ' MaxPerStageDescriptorUniformBuffers: %s' + sLineBreak +
  220. ' MaxPerStageDescriptorStorageBuffers: %s' + sLineBreak +
  221. ' MaxPerStageDescriptorSampledImages: %s' + sLineBreak +
  222. ' MaxPerStageDescriptorStorageImages: %s' + sLineBreak +
  223. ' MaxPerStageDescriptorInputAttachments: %s' + sLineBreak +
  224. ' MaxPerStageResources: %s' + sLineBreak +
  225. ' MaxDescriptorSetSamplers: %s' + sLineBreak +
  226. ' MaxDescriptorSetUniformBuffers: %s' + sLineBreak +
  227. ' MaxDescriptorSetUniformBuffersDynamic: %s' + sLineBreak +
  228. ' MaxDescriptorSetStorageBuffers: %s' + sLineBreak +
  229. ' MaxDescriptorSetStorageBuffersDynamic: %s' + sLineBreak +
  230. ' MaxDescriptorSetSampledImages: %s' + sLineBreak +
  231. ' MaxDescriptorSetStorageImages: %s' + sLineBreak +
  232. ' MaxDescriptorSetInputAttachments: %s' + sLineBreak +
  233. ' MaxVertexInputAttributes: %s' + sLineBreak +
  234. ' MaxVertexInputBindings: %s' + sLineBreak +
  235. ' MaxVertexInputAttributeOffset: %s' + sLineBreak +
  236. ' MaxVertexInputBindingStride: %s' + sLineBreak +
  237. ' MaxVertexOutputComponents: %s' + sLineBreak +
  238. ' MaxTessellationGenerationLevel: %s' + sLineBreak +
  239. ' MaxTessellationPatchSize: %s' + sLineBreak +
  240. ' MaxTessellationControlPerVertexInputComponents: %s' + sLineBreak +
  241. ' MaxTessellationControlPerVertexOutputComponents: %s' + sLineBreak +
  242. ' MaxTessellationControlPerPatchOutputComponents: %s' + sLineBreak +
  243. ' MaxTessellationControlTotalOutputComponents: %s' + sLineBreak +
  244. ' MaxTessellationEvaluationInputComponents: %s' + sLineBreak +
  245. ' MaxTessellationEvaluationOutputComponents: %s' + sLineBreak +
  246. ' MaxGeometryShaderInvocations: %s' + sLineBreak +
  247. ' MaxGeometryInputComponents: %s' + sLineBreak +
  248. ' MaxGeometryOutputComponents: %s' + sLineBreak +
  249. ' MaxGeometryOutputVertices: %s' + sLineBreak +
  250. ' MaxGeometryTotalOutputComponents: %s' + sLineBreak +
  251. ' MaxFragmentInputComponents: %s' + sLineBreak +
  252. ' MaxFragmentOutputAttachments: %s' + sLineBreak +
  253. ' MaxFragmentDualSrcAttachments: %s' + sLineBreak +
  254. ' MaxFragmentCombinedOutputResources: %s' + sLineBreak +
  255. ' MaxComputeSharedMemorySize: %s' + sLineBreak +
  256. ' MaxComputeWorkGroupCount: %s' + sLineBreak +
  257. ' MaxComputeWorkGroupInvocations: %s' + sLineBreak +
  258. ' MaxComputeWorkGroupSize: %s' + sLineBreak +
  259. ' SubPixelPrecisionBits: %s' + sLineBreak +
  260. ' SubTexelPrecisionBits: %s' + sLineBreak +
  261. ' MipmapPrecisionBits: %s' + sLineBreak +
  262. ' MaxDrawIndexedIndexValue: %s' + sLineBreak +
  263. ' MaxDrawIndirectCount: %s' + sLineBreak +
  264. ' MaxSamplerLodBias: %s' + sLineBreak +
  265. ' MaxSamplerAnisotropy: %s' + sLineBreak +
  266. ' MaxViewports: %s' + sLineBreak +
  267. ' MaxViewportDimensions: %s' + sLineBreak +
  268. ' ViewportBoundsRange: %s' + sLineBreak +
  269. ' ViewportSubPixelBits: %s' + sLineBreak +
  270. ' MinMemoryMapAlignment: %s' + sLineBreak +
  271. ' MinTexelBufferOffsetAlignment: %s' + sLineBreak +
  272. ' MinUniformBufferOffsetAlignment: %s' + sLineBreak +
  273. ' MinStorageBufferOffsetAlignment: %s' + sLineBreak +
  274. ' MinTexelOffset: %s' + sLineBreak +
  275. ' MaxTexelOffset: %s' + sLineBreak +
  276. ' MinTexelGatherOffset: %s' + sLineBreak +
  277. ' MaxTexelGatherOffset: %s' + sLineBreak +
  278. ' MinInterpolationOffset: %s' + sLineBreak +
  279. ' MaxInterpolationOffset: %s' + sLineBreak +
  280. ' SubPixelInterpolationOffsetBits: %s' + sLineBreak +
  281. ' MaxFramebufferWidth: %s' + sLineBreak +
  282. ' MaxFramebufferHeight: %s' + sLineBreak +
  283. ' MaxFramebufferLayers: %s' + sLineBreak +
  284. ' FramebufferColorSampleCounts: %s' + sLineBreak +
  285. ' FramebufferDepthSampleCounts: %s' + sLineBreak +
  286. ' FramebufferStencilSampleCounts: %s' + sLineBreak +
  287. ' FramebufferNoAttachmentsSampleCounts: %s' + sLineBreak +
  288. ' MaxColorAttachments: %s' + sLineBreak +
  289. ' SampledImageColorSampleCounts: %s' + sLineBreak +
  290. ' SampledImageIntegerSampleCounts: %s' + sLineBreak +
  291. ' SampledImageDepthSampleCounts: %s' + sLineBreak +
  292. ' SampledImageStencilSampleCounts: %s' + sLineBreak +
  293. ' StorageImageSampleCounts: %s' + sLineBreak +
  294. ' MaxSampleMaskWords: %s' + sLineBreak +
  295. ' TimestampComputeAndGraphics: %s' + sLineBreak +
  296. ' TimestampPeriod: %s' + sLineBreak +
  297. ' MaxClipDistances: %s' + sLineBreak +
  298. ' MaxCullDistances: %s' + sLineBreak +
  299. ' MaxCombinedClipAndCullDistances: %s' + sLineBreak +
  300. ' DiscreteQueuePriorities: %s' + sLineBreak +
  301. ' PointSizeRange: %s' + sLineBreak +
  302. ' LineWidthRange: %s' + sLineBreak +
  303. ' PointSizeGranularity: %s' + sLineBreak +
  304. ' LineWidthGranularity: %s' + sLineBreak +
  305. ' StrictLines: %s' + sLineBreak +
  306. ' StandardSampleLocations: %s' + sLineBreak +
  307. ' OptimalBufferCopyOffsetAlignment: %s' + sLineBreak +
  308. ' OptimalBufferCopyRowPitchAlignment: %s' + sLineBreak +
  309. ' NonCoherentAtomSize: %s' + sLineBreak
  310. ,[
  311. toString(aProperties.limits.maxImageDimension1D),
  312. toString(aProperties.limits.maxImageDimension2D),
  313. toString(aProperties.limits.maxImageDimension3D),
  314. toString(aProperties.limits.maxImageDimensionCube),
  315. toString(aProperties.limits.maxImageArrayLayers),
  316. toString(aProperties.limits.maxTexelBufferElements),
  317. toString(aProperties.limits.maxUniformBufferRange),
  318. toString(aProperties.limits.maxStorageBufferRange),
  319. toString(aProperties.limits.maxPushConstantsSize),
  320. toString(aProperties.limits.maxMemoryAllocationCount),
  321. toString(aProperties.limits.maxSamplerAllocationCount),
  322. toString(aProperties.limits.bufferImageGranularity),
  323. toString(aProperties.limits.sparseAddressSpaceSize),
  324. toString(aProperties.limits.maxBoundDescriptorSets),
  325. toString(aProperties.limits.maxPerStageDescriptorSamplers),
  326. toString(aProperties.limits.maxPerStageDescriptorUniformBuffers),
  327. toString(aProperties.limits.maxPerStageDescriptorStorageBuffers),
  328. toString(aProperties.limits.maxPerStageDescriptorSampledImages),
  329. toString(aProperties.limits.maxPerStageDescriptorStorageImages),
  330. toString(aProperties.limits.maxPerStageDescriptorInputAttachments),
  331. toString(aProperties.limits.maxPerStageResources),
  332. toString(aProperties.limits.maxDescriptorSetSamplers),
  333. toString(aProperties.limits.maxDescriptorSetUniformBuffers),
  334. toString(aProperties.limits.maxDescriptorSetUniformBuffersDynamic),
  335. toString(aProperties.limits.maxDescriptorSetStorageBuffers),
  336. toString(aProperties.limits.maxDescriptorSetStorageBuffersDynamic),
  337. toString(aProperties.limits.maxDescriptorSetSampledImages),
  338. toString(aProperties.limits.maxDescriptorSetStorageImages),
  339. toString(aProperties.limits.maxDescriptorSetInputAttachments),
  340. toString(aProperties.limits.maxVertexInputAttributes),
  341. toString(aProperties.limits.maxVertexInputBindings),
  342. toString(aProperties.limits.maxVertexInputAttributeOffset),
  343. toString(aProperties.limits.maxVertexInputBindingStride),
  344. toString(aProperties.limits.maxVertexOutputComponents),
  345. toString(aProperties.limits.maxTessellationGenerationLevel),
  346. toString(aProperties.limits.maxTessellationPatchSize),
  347. toString(aProperties.limits.maxTessellationControlPerVertexInputComponents),
  348. toString(aProperties.limits.maxTessellationControlPerVertexOutputComponents),
  349. toString(aProperties.limits.maxTessellationControlPerPatchOutputComponents),
  350. toString(aProperties.limits.maxTessellationControlTotalOutputComponents),
  351. toString(aProperties.limits.maxTessellationEvaluationInputComponents),
  352. toString(aProperties.limits.maxTessellationEvaluationOutputComponents),
  353. toString(aProperties.limits.maxGeometryShaderInvocations),
  354. toString(aProperties.limits.maxGeometryInputComponents),
  355. toString(aProperties.limits.maxGeometryOutputComponents),
  356. toString(aProperties.limits.maxGeometryOutputVertices),
  357. toString(aProperties.limits.maxGeometryTotalOutputComponents),
  358. toString(aProperties.limits.maxFragmentInputComponents),
  359. toString(aProperties.limits.maxFragmentOutputAttachments),
  360. toString(aProperties.limits.maxFragmentDualSrcAttachments),
  361. toString(aProperties.limits.maxFragmentCombinedOutputResources),
  362. toString(aProperties.limits.maxComputeSharedMemorySize),
  363. toString(aProperties.limits.maxComputeWorkGroupCount),
  364. toString(aProperties.limits.maxComputeWorkGroupInvocations),
  365. toString(aProperties.limits.maxComputeWorkGroupSize),
  366. toString(aProperties.limits.subPixelPrecisionBits),
  367. toString(aProperties.limits.subTexelPrecisionBits),
  368. toString(aProperties.limits.mipmapPrecisionBits),
  369. toString(aProperties.limits.maxDrawIndexedIndexValue),
  370. toString(aProperties.limits.maxDrawIndirectCount),
  371. toString(aProperties.limits.maxSamplerLodBias),
  372. toString(aProperties.limits.maxSamplerAnisotropy),
  373. toString(aProperties.limits.maxViewports),
  374. toString(aProperties.limits.maxViewportDimensions),
  375. toString(aProperties.limits.viewportBoundsRange),
  376. toString(aProperties.limits.viewportSubPixelBits),
  377. toString(aProperties.limits.minMemoryMapAlignment),
  378. toString(aProperties.limits.minTexelBufferOffsetAlignment),
  379. toString(aProperties.limits.minUniformBufferOffsetAlignment),
  380. toString(aProperties.limits.minStorageBufferOffsetAlignment),
  381. toString(aProperties.limits.minTexelOffset),
  382. toString(aProperties.limits.maxTexelOffset),
  383. toString(aProperties.limits.minTexelGatherOffset),
  384. toString(aProperties.limits.maxTexelGatherOffset),
  385. toString(aProperties.limits.minInterpolationOffset),
  386. toString(aProperties.limits.maxInterpolationOffset),
  387. toString(aProperties.limits.subPixelInterpolationOffsetBits),
  388. toString(aProperties.limits.maxFramebufferWidth),
  389. toString(aProperties.limits.maxFramebufferHeight),
  390. toString(aProperties.limits.maxFramebufferLayers),
  391. toString(PVkUint32(@aProperties.limits.framebufferColorSampleCounts)^),
  392. toString(PVkUint32(@aProperties.limits.framebufferDepthSampleCounts)^),
  393. toString(PVkUint32(@aProperties.limits.framebufferStencilSampleCounts)^),
  394. toString(PVkUint32(@aProperties.limits.framebufferNoAttachmentsSampleCounts)^),
  395. toString(aProperties.limits.maxColorAttachments),
  396. toString(PVkUint32(@aProperties.limits.sampledImageColorSampleCounts)^),
  397. toString(PVkUint32(@aProperties.limits.sampledImageIntegerSampleCounts)^),
  398. toString(PVkUint32(@aProperties.limits.sampledImageDepthSampleCounts)^),
  399. toString(PVkUint32(@aProperties.limits.sampledImageStencilSampleCounts)^),
  400. toString(PVkUint32(@aProperties.limits.storageImageSampleCounts)^),
  401. toString(aProperties.limits.maxSampleMaskWords),
  402. toString(aProperties.limits.timestampComputeAndGraphics),
  403. toString(aProperties.limits.timestampPeriod),
  404. toString(aProperties.limits.maxClipDistances),
  405. toString(aProperties.limits.maxCullDistances),
  406. toString(aProperties.limits.maxCombinedClipAndCullDistances),
  407. toString(aProperties.limits.discreteQueuePriorities),
  408. toString(aProperties.limits.pointSizeRange),
  409. toString(aProperties.limits.lineWidthRange),
  410. toString(aProperties.limits.pointSizeGranularity),
  411. toString(aProperties.limits.lineWidthGranularity),
  412. toString(aProperties.limits.strictLines),
  413. toString(aProperties.limits.standardSampleLocations),
  414. toString(aProperties.limits.optimalBufferCopyOffsetAlignment),
  415. toString(aProperties.limits.optimalBufferCopyRowPitchAlignment),
  416. toString(aProperties.limits.nonCoherentAtomSize)
  417. ]);
  418. end;
  419. if aPrintSparseProps then begin
  420. result := result + Format(
  421. 'SparseProperties:' + sLineBreak +
  422. ' ResidencyStandard2DBlockShape: %s' + sLineBreak +
  423. ' ResidencyStandard2DMultisampleBlockShape: %s' + sLineBreak +
  424. ' ResidencyStandard3DBlockShape: %s' + sLineBreak +
  425. ' ResidencyAlignedMipSize: %s' + sLineBreak +
  426. ' ResidencyNonResidentStrict: %s' + sLineBreak,
  427. [
  428. toString(aProperties.sparseProperties.residencyStandard2DBlockShape),
  429. toString(aProperties.sparseProperties.residencyStandard2DMultisampleBlockShape),
  430. toString(aProperties.sparseProperties.residencyStandard3DBlockShape),
  431. toString(aProperties.sparseProperties.residencyAlignedMipSize),
  432. toString(aProperties.sparseProperties.residencyNonResidentStrict)
  433. ]);
  434. end;
  435. end;
  436. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  437. function vkuMakeString(const aMemoryProperties: TVkPhysicalDeviceMemoryProperties): String;
  438. var i: Integer;
  439. begin
  440. result := 'Types:' + sLineBreak;
  441. for i := 0 to aMemoryProperties.memoryTypeCount-1 do begin
  442. result := result + Format(
  443. ' Type %d:' + sLineBreak +
  444. ' PropertyFlags: 0x%.16X' + sLineBreak +
  445. ' HeapIndex: %d (0x%2:.16X)' + sLineBreak,
  446. [i, PVkUint32(@aMemoryProperties.memoryTypes[i].propertyFlags)^, aMemoryProperties.memoryTypes[i].heapIndex]);
  447. end;
  448. result := result + 'Heaps:' + sLineBreak;
  449. for i := 0 to aMemoryProperties.memoryHeapCount-1 do begin
  450. result := result + Format(
  451. ' Heap %d:' + sLineBreak +
  452. ' Size: %d (0x%1:.16X)' + sLineBreak +
  453. ' Flags: 0x%.16X' + sLineBreak,
  454. [i, aMemoryProperties.memoryHeaps[i].size, PVkUint32(@aMemoryProperties.memoryHeaps[i].flags)^]);
  455. end;
  456. end;
  457. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  458. function vkuGetMemoryTypeIndex(
  459. const aMemoryProperties: TVkPhysicalDeviceMemoryProperties;
  460. aMemoryTypeBits: VkUint32;
  461. const aProperty: TVkMemoryPropertyFlagBit): VkUint32;
  462. var
  463. i: Integer;
  464. begin
  465. result := 0;
  466. for i := 0 to VK_MAX_MEMORY_TYPES-1 do begin
  467. if ((aMemoryTypeBits and 1) = 1) and
  468. (aProperty in aMemoryProperties.memoryTypes[i].propertyFlags) then
  469. begin
  470. result := i;
  471. break;
  472. end;
  473. aMemoryTypeBits := aMemoryTypeBits shr 1;
  474. end;
  475. end;
  476. end.