-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue_families.py
65 lines (40 loc) · 1.54 KB
/
queue_families.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from config import *
class QueueFamilyIndices:
def __init__(self):
self.graphicsFamily = None
self.presentFamily = None
def is_complete(self):
return self.graphicsFamily is not None and self.presentFamily is not None
def find_queue_families(device, instance, surface, debug):
indices = QueueFamilyIndices()
surfaceSupport = vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceSupportKHR")
# VkQueueFamilyProperties
# {
# VkQueueFlags queueFlags;
# uint32_t queueCount;
# uint32_t timestampValidBits;
# VkExtent3D minImageTransferGranularity;
# }
# VkQueueFlagBits
# {
# VK_QUEUE_GRAPHICS_BIT = 0x00000001,
# VK_QUEUE_COMPUTE_BIT = 0x00000002,
# VK_QUEUE_TRANSFER_BIT = 0x00000004,
# VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
# }
# returns list of VkQueueFamilyProperties
queueFamilies = vkGetPhysicalDeviceQueueFamilyProperties(device)
if debug:
print(f"There are {len(queueFamilies)} queue families")
for i, queueFamily in enumerate(queueFamilies):
if queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT:
indices.graphicsFamily = i
if debug:
print(f"Queue Family {i} is can do graphics")
if surfaceSupport(device, i, surface):
indices.presentFamily = i
if debug:
print(f"Queue family {i} supports surface")
if indices.is_complete():
break
return indices