def _setup_memory_info(self):
        ctx = self.engine
        api, physical_device = ctx.api, ctx.physical_device

        props = hvk.physical_device_memory_properties(api, physical_device)
        types = props.memory_types[:props.memory_type_count]
        heaps = props.memory_heaps[:props.memory_heap_count]

        self.memory_info["memory_types"] = types
        self.memory_info["memory_heaps"] = heaps
Exemple #2
0
def find_memory_type(heap_flags, type_flags):
    F, type_flags = IntFlag, hvk.MemoryPropertyFlag(type_flags)

    props = hvk.physical_device_memory_properties(api, physical_device)
    types = props.memory_types[:props.memory_type_count]
    heaps = props.memory_heaps[:props.memory_heap_count]

    # Find the memory heap that satisfy heap_flags
    heap_indices = tuple(i for i, h in enumerate(heaps)
                         if F(heap_flags) in F(h.flags))
    if heap_indices is None:
        return

    # Find a memory type in the selected heaps that satisfy type_flags
    type_index = None
    for i, memory_type in enumerate(types):
        heap_matches = memory_type.heap_index in heap_indices
        type_flags_matches = type_flags in hvk.MemoryPropertyFlag(
            memory_type.property_flags)
        if heap_matches and type_flags_matches:
            type_index = i
            break

    return type_index