+
    KiR9  c                   s   R t ^ RIHt ^ RIHtHtHtHtHtH	t	H
t
HtHtHtHtHtHtHt ^ RIHt ]t^ tRt]t]t^ t^tRt^t]t]t^t]t ]t!]t"]t#]! RR4      t$R t%R t&R	 t'R
 t( ! R R]4      t) ! R R]4      t* ! R R]4      t+ ! R R]4      t, ! R R]4      t-]R R l4       t.]R 4       t/R t0]R 4       t1R t2]R 4       t3R t4R# )zQuery Vulkan capabilities)
namedtuple)CDLLPOINTER	Structurebyrefc_charc_char_pc_floatc_int32c_size_tc_uint8c_uint32c_uint64c_void_ppointer)cache_singlei   
DeviceInfozname api_versionc                s>    V ^,          V^,          ,          V,          # )z
VK_MAKE_VERSION macro logic for Python

https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#fundamentals-versionnum
 )majorminorpatchs   &&&A/usr/lib/python3.14/site-packages/lutris/util/graphics/vkquery.pyvk_make_versionr   9   s     RKERK(500    c                 s"    V ^,	          ^,          # )i   r   version   &r   vk_api_version_majorr   B   s    rMT!!r   c                 s"    V ^,	          R,          # )i   i  r   r   r   r   vk_api_version_minorr   F   s    rMU""r   c                 s    V R ,          # )i  r   r   r   r   vk_api_version_patchr   J   s    U?r   c                   sd   a a ] tR t^Nt oRtR]3R]3R]3R]3R]3R]3R]3.t	V 3R	 lt
R
tVtV ;t# )VkApplicationInfozPython shim for struct VkApplicationInfo

https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkApplicationInfo.html
sTypepNextpApplicationNameapplicationVersionZpEngineNameZengineVersion
apiVersionc                s   < \         SV `  4        \        V n        VP	                  4       V n        \        \        V!  4      V n        \        \        ^^ ^ 4      4      V n	        R# )   N)
super__init__"VK_STRUCTURE_TYPE_APPLICATION_INFOr   Zencoder!   r   r   r"   r#   )selfnamer   	__class__s   &&&r   r&   ZVkApplicationInfo.__init__`   sJ    7
 $"*?G+D"E"?1a#;<r   )r#   r"   r!   r   )__name__
__module____qualname____firstlineno____doc__VkStructureTyper   r   r   _fields_r&   __static_attributes____classdictcell____classcell__r*   Z__classdict__   @@r   r   r   N   sU      
/"	(	X&	x(	!	(#	x H= =r   r   c            	       sv   a a ] tR t^ht oRtR]3R]3R]3R]! ]	4      3R]
3R]3R]
3R	]3.tV 3R
 ltRtVtV ;t# )VkInstanceCreateInfozPython shim for struct VkInstanceCreateInfo

https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkInstanceCreateInfo.html
r   r    ZflagspApplicationInfoZenabledLayerCountZppEnabledLayerNamesZenabledExtensionCountZppEnabledExtensionNamesc                sZ   < \         SV `  4        \        V n        \	        V4      V n        R # N)r%   r&   &VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFOr   r   r8   )r(   app_infor*   s   &&r   r&   ZVkInstanceCreateInfo.__init__{   s"    ;
 ' 1r   )r8   r   )r+   r,   r-   r.   r/   r0   r   VkInstanceCreateFlagsr   r   r   r   r1   r&   r2   r3   r4   r5   r6   r   r7   r7   h   sd      
/"	(	'(	W%678	h'	)	 (+	"H-	H2 2r   r7   c                   s   ] tR t^t. R]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR	]3NR
]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR]3NR ]3NR!]3NR"]3NR#]3NR$]3NR%]3NR&]3NR']3NR(]3NR)]3NR*]3NR+]3NR,]3NR-]3NR.]3NR/]3NR0]3NR1]3NR2]3NR3]3NR4]3NR5]^,          3NR6]3NR7]^,          3NR8]3NR9]3NR:]3NR;]3NR<]3NR=]3NR>]3NR?]3NR@]^,          3NRA]^,          3NRB]3NRC]3NRD]3NRE]3NRF]3NRG]3NRH]3NRI]3NRJ]3NRK]3NRL]3NRM]3NRN]3NRO]3NRP]3NRQ]	3NRR]	3NRS]	3NRT]	3NRU]3NRV]	3NRW]	3NRX]	3NRY]	3NRZ]	3NR[]3NR\]
3NR]]3NR^]3NR_]3NR`]3NRa]3NRb]^,          3NRc]^,          3NRd]3NRe]3NRf]
3NRg]
3NRh]3NRi]3NRj]3NtRktRl# )mVkPhysicalDeviceLimitsZmaxImageDimension1DZmaxImageDimension2DZmaxImageDimension3DZmaxImageDimensionCubeZmaxImageArrayLayersZmaxTexelBufferElementsZmaxUniformBufferRangeZmaxStorageBufferRangeZmaxPushConstantsSizeZmaxMemoryAllocationCountZmaxSamplerAllocationCountZbufferImageGranularityZsparseAddressSpaceSizeZmaxBoundDescriptorSetsZmaxPerStageDescriptorSamplersZ#maxPerStageDescriptorUniformBuffersZ#maxPerStageDescriptorStorageBuffersZ"maxPerStageDescriptorSampledImagesZ"maxPerStageDescriptorStorageImagesZ%maxPerStageDescriptorInputAttachmentsZmaxPerStageResourcesZmaxDescriptorSetSamplersZmaxDescriptorSetUniformBuffersZ%maxDescriptorSetUniformBuffersDynamicZmaxDescriptorSetStorageBuffersZ%maxDescriptorSetStorageBuffersDynamicZmaxDescriptorSetSampledImagesZmaxDescriptorSetStorageImagesZ maxDescriptorSetInputAttachmentsZmaxVertexInputAttributesZmaxVertexInputBindingsZmaxVertexInputAttributeOffsetZmaxVertexInputBindingStrideZmaxVertexOutputComponentsZmaxTessellationGenerationLevelZmaxTessellationPatchSizeZ.maxTessellationControlPerVertexInputComponentsZ/maxTessellationControlPerVertexOutputComponentsZ.maxTessellationControlPerPatchOutputComponentsZ+maxTessellationControlTotalOutputComponentsZ(maxTessellationEvaluationInputComponentsZ)maxTessellationEvaluationOutputComponentsZmaxGeometryShaderInvocationsZmaxGeometryInputComponentsZmaxGeometryOutputComponentsZmaxGeometryOutputVerticesZ maxGeometryTotalOutputComponentsZmaxFragmentInputComponentsZmaxFragmentOutputAttachmentsZmaxFragmentDualSrcAttachmentsZ"maxFragmentCombinedOutputResourcesZmaxComputeSharedMemorySizeZmaxComputeWorkGroupCountZmaxComputeWorkGroupInvocationsZmaxComputeWorkGroupSizeZsubPixelPrecisionBitsZsubTexelPrecisionBitsZmipmapPrecisionBitsZmaxDrawIndexedIndexValueZmaxDrawIndirectCountZmaxSamplerLodBiasZmaxSamplerAnisotropyZmaxViewportsZmaxViewportDimensionsZviewportBoundsRangeZviewportSubPixelBitsZminMemoryMapAlignmentZminTexelBufferOffsetAlignmentZminUniformBufferOffsetAlignmentZminStorageBufferOffsetAlignmentZminTexelOffsetZmaxTexelOffsetZminTexelGatherOffsetZmaxTexelGatherOffsetZminInterpolationOffsetZmaxInterpolationOffsetZsubPixelInterpolationOffsetBitsZmaxFrameBufferWidthZmaxFrameBufferHeightZmaxFrameBufferLayersZframeBufferColorSampleCountsZframeBufferDepthSampleCountsZframeBufferStencilSampleCountsZ$frameBufferNoAttachmentsSampleCountsZmaxColorAttachmentsZsampledImageColorSampleCountsZsampledImageIntegerSampleCountsZsampledImageDepthSampleCountsZsampledImageStencilSampleCountsZstorageImageSampleCountsZmaxSampleMaskWordsZtimestampComputeAndGraphicsZtimestampPeriodZmaxClipDistancesZmaxCullDistancesZmaxCombinedClipAndCullDistancesZdiscreteQueuePrioritiesZpointSizeRangeZlineWidthRangeZpointSizeGranularityZlineWidthGranularityZstrictLinesZstandardSampleLocationsZ optimalBufferCopyOffsetAlignmentZ"optimalBufferCopyRowPitchAlignmentZnonCoherentAtomSizer   N)r+   r,   r-   r.   r   VkDeviceSizer   r	   r   VkSampleCountFlagsVkBool32r1   r2   r   r   r   r=   r=      s]   k	)k	)k 
)k 
!(+	k
 
)k 
"8,k 
!(+k 
!(+k 
 *k 
$X.k 
%h/k 
"<0k 
"<0k 
"8,k 
)(3k  
/9!k" 
/9#k$ 
.x8%k& 
.x8'k( 
1(;)k* 
 *+k, 
$X.-k. 
*84/k0 
1(;1k2 
*843k4 
1(;5k6 
)(37k8 
)(39k: 
,X6;k< 
$X.=k> 
"8,?k@ 
)(3AkB 
'1CkD 
%h/EkF 
*84GkH 
$X.IkJ 
:8DKkL 
;HEMkN 
:8DOkP 
7AQkR 
4X>SkT 
5h?UkV 
(2WkX 
&x0YkZ 
'1[k\ 
%h/]k^ 
,X6_k` 
&x0akb 
(2ckd 
)(3ekf 
.x8gkh 
&x0ikj 
$X\2kkl 
*84mkn 
#HqL1okp 
!(+qkr 
!(+skt 
)ukv 
$X.wkx 
 *ykz 
g&{k| 
 )}k~ 
"k@ 
!(Q,/AkB 
!,CkD 
 *EkF 
!(+GkH 
),7IkJ 
+L9KkL 
+L9MkN 
7#OkP 
8$QkR 
 )SkT 
 *UkV 
"7+WkX 
"7+YkZ 
+H5[k\ 
)]k^ 
 *_k` 
 *akb 
();<ckd 
();<ekf 
*+=>gkh 
01CDikj 
)kkl 
)*<=mkn 
+,>?okp 
)*<=qkr 
+,>?skt 
$%78ukv 
x(wkx 
'1ykz 
G${k| 
X&}k~ 
X&k@ 
+H5AkB 
#H-CkD 
7Q;'EkF 
7Q;'GkH 
 )IkJ 
 )KkL 
!MkN 
#H-OkP 
,\:QkR 
.|<SkT 
-UkHr   r=   c                   s8    ] tR t^tR]3R]3R]3R]3R]3.tRtR# ) VkPhysicalDeviceSparsePropertiesZresidencyStandard2DBlockShapeZ(residencyStandard2DMultisampleBlockShapeZresidencyStandard3DBlockShapeZresidencyAlignedMipSizeZresidencyNonResidentStrictr   N)r+   r,   r-   r.   r@   r1   r2   r   r   r   rA   rA      s1    	((3	3X>	((3	"H-	%x0Hr   rA   c            
       sl    ] tR t^tR]3R]3R]3R]3R]3R]],          3R]]	,          3R]
3R	]3.	tR
tR# )VkPhysicalDevicePropertiesr#   ZdriverVersionZvendorIDZdeviceID
deviceType
deviceNameZpipelineCacheUUIDZlimitsZsparsePropertiesr   N)r+   r,   r-   r.   r   VkPhysicalDeviceTyper    VK_MAX_PHYSICAL_DEVICE_NAME_SIZEr
   VK_UUID_SIZEr=   rA   r1   r2   r   r   r   rB   rB      s_    	x 	(#	X	X	+,	v @@A	g45	)*	=>
Hr   rB   c                s$    V ^8  d   QhR\         /# )i   Zreturn)Zbool)Zformats   "r   __annotate__rH   	  s     8 8T 8r   c                 s     \        4       p \        4       pT'       g   R# \        ^ 4      pT P	                  T\        T4      R4      pT\        8H  ;'       d    TP                  ^ 8  #   \         d     R# i ; i)zq
Returns True iff vulkan library can be loaded, initialized,
and reports at least one physical device available.
FN)_get_vulkanOSError_get_vk_instancer   vkEnumeratePhysicalDevicesr   
VK_SUCCESSvalue)vulkaninstance	dev_countresult       r   is_vulkan_supportedrT     sp      !HI..xy9I4PFZ77IOOa$77  s   
A' 'A65A6c                 s     \        4       p  T P                  p\        ^ 4      pT! \        T4      4      pT\        8X  d   TP                  # R#   \         d     R# i ; i  \         d    \	        ^^ ^ 4      u # i ; i)z
Queries libvulkan to get the API version; if this library is missing
it returns None. Returns an encoded Vulkan version integer; use
vk_api_version_major() and like methods to parse it.
N)	rI   rJ   vkEnumerateInstanceVersionZAttributeErrorr   r   r   rM   rN   )rO   Zenumerate_instance_versionr   rR   rS   r   get_vulkan_api_versionrV     s    (%+%F%F"
 qkG'g7F"j07==:d:  
  (q!Q''(s"   
A A  AA A;:A;c                 s    \        4       p \        4       pT'       g   . # \        ^ 4      pT P	                  T\        T4      R4      pT\        8w  g   TP                  ^ 8:  d   . # \        TP                  ,          ! 4       pT P	                  T\        T4      T4      pT\        8w  d   . # . pT F~  p\        4       pT P                  T\        T4      4       TP                  \        8w  g   K?  TP                  P                  R4      pTP                  \!        YP"                  4      4       K  	  \%        TR RR7      #   \         d    . u # i ; i)a/  
Returns a list of the physical devices known to Vulkan, represented as
(name, api_version) named-tuples and the api_version numbers are encoded, so
use vk_api_version_major() and friends to parse them. They are sorted so the
highest version device is first, and software rendering devices are omitted.
Nzutf-8c                 s    V P                   # r9   )api_version)Ztr   r   Z<lambda>Z!get_device_info.<locals>.<lambda>R  s    Q]]r   T)ZkeyZreverse)rI   rJ   rK   r   rL   r   rM   rN   VkPhysicalDevicerB   vkGetPhysicalDevicePropertiesrC   VK_PHYSICAL_DEVICE_TYPE_CPUrD   ZdecodeZappendr   r#   Zsorted)	rO   rP   rQ   rR   devicesZdevice_infoZphysical_deviceZ	dev_propsr)   s	            r   get_device_infor\   1  s#     !H	I..xy9I4PFy!3	)//14G..xy9I7SF	K".0	,,_eI>NO#>>''..w7Dz$0D0DEF # +#:DII1  	s   
D? ?EEc                 s    \        4       p V '       g   R# \        4       pV'       d   \        W^ ,          P                  4      # V # )zReturns the version tuple of the API version we expect
to have; it is the least of the Vulkan library API version, and
the best device's API version.N)rV   r\   ZminrW   )rW   r[   s     r   get_expected_api_versionr]   U  s8    
 )*KG;
 6 677r   c                 sr    V '       d/   \        V 4      p\        V 4      p\        V 4      pV: R V: R V: 2# R# )Z.z(none))r   r   r   )r   r   r   r   s   &   r   format_versionr^   f  s3    $W-$W-$W-"E511r   c                 s     \        4       p \        RRR7      p\        T4      p\	        4       pT P                  \        T4      ^ \        T4      4      pT\        8w  d   R# T#   \         d    . u # i ; i)zReturns our VKInstance, or None if it can't be obtained.

We've had user see crashes when destroying this, so we don't- we
allocate it on demand and keep it for the lifetime of Lutris.Zvkinfor   N)    r$   r_   )rI   rJ   r   r7   
VkInstancevkCreateInstancer   rM   )rO   r;   Zcreate_inforP   rR           r   rK   rK   p  sp     !9=H&x0K|H$$U;%7E(OLFO  	s   
A" "A21A2c                  s   \        R 4      p V P                  p\        Vn        \	        \
        4      \        \	        \        4      .Vn        V P                  p\        Vn        \        \	        \        4      \	        \        4      .Vn        V P                  pRVn        \        \	        \        4      .Vn        V P                  p\        Vn        \	        \        4      .Vn        V # )zlibvulkan.so.1N)r   ra   VkResultZrestyper   r7   r   r`   ZargtypesrL   r   rX   rY   rB   rU   )rO   ra   rL   rY   rU   rb   r   rI   rI     s    "#F
 ..'!()=!>'R\J] ^!'!B!B)1&+5wx7H'RbJc*d'$*$H$H!,0!).>Hb@c-d!*!'!B!B)1&+28+<*='Mr   Ni)5r/   Zcollectionsr    Zctypesr   r   r   r   r   r   r   r   r	   r
   r   r   r   r   Zlutris.utilr   rc   rM   ZVK_ERROR_INITIALIZATION_FAILEDr0   r@   r'   r:   rF   rG   r<   rE   rZ   r?   r`   rX   r>   r   r   r   r   r   r   r7   r=   rA   rB   rT   rV   r\   r]   r^   rK   rI   r   r   r   <module>rd      s@     "   " %
!# %& ")* &#&      
 &89
1"#=	 =429 22lY l^y   8 8" ; ;,!JH     $r   