vn_object_base_init(&mem->base, VK_OBJECT_TYPE_DEVICE_MEMORY, &dev->base);
mem->size = size;
- mem->type = dev->physical_device->memory_properties.memoryProperties
- .memoryTypes[mem_type_index];
+ mem->type =
+ dev->physical_device->memory_properties.memoryTypes[mem_type_index];
mem_handle = vn_device_memory_to_handle(mem);
result = vn_call_vkAllocateMemory(
VkDevice device = vn_device_to_handle(dev);
VkDeviceMemory memory = vn_device_memory_to_handle(mem);
const VkPhysicalDeviceMemoryProperties *mem_props =
- &dev->physical_device->memory_properties.memoryProperties;
+ &dev->physical_device->memory_properties;
VkMemoryPropertyFlags mem_flags =
mem_props->memoryTypes[alloc_info->memoryTypeIndex].propertyFlags;
struct vn_renderer_bo *bo;
vn_object_base_init(&mem->base, VK_OBJECT_TYPE_DEVICE_MEMORY, &dev->base);
mem->size = pAllocateInfo->allocationSize;
- mem->type = dev->physical_device->memory_properties.memoryProperties
+ mem->type = dev->physical_device->memory_properties
.memoryTypes[pAllocateInfo->memoryTypeIndex];
mem->is_import = import_ahb_info || import_fd_info;
mem->is_external = mem->is_import || export_info;
struct vn_physical_device *physical_dev)
{
struct vn_instance *instance = physical_dev->instance;
- VkPhysicalDeviceMemoryProperties2 *props2 =
- &physical_dev->memory_properties;
- VkPhysicalDeviceMemoryProperties *props1 = &props2->memoryProperties;
-
- props2->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
-
+ VkPhysicalDeviceMemoryProperties2 props2 = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2,
+ };
vn_call_vkGetPhysicalDeviceMemoryProperties2(
- instance, vn_physical_device_to_handle(physical_dev), props2);
+ instance, vn_physical_device_to_handle(physical_dev), &props2);
+
+ physical_dev->memory_properties = props2.memoryProperties;
/* Kernel makes every mapping coherent. If a memory type is truly
* incoherent, it's better to remove the host-visible flag than silently
*/
uint32_t coherent_uncached = VK_MAX_MEMORY_TYPES;
uint32_t incoherent_cached = VK_MAX_MEMORY_TYPES;
-
- for (uint32_t i = 0; i < props1->memoryTypeCount; i++) {
- const VkMemoryPropertyFlags flags =
- props1->memoryTypes[i].propertyFlags;
+ VkPhysicalDeviceMemoryProperties *props = &physical_dev->memory_properties;
+ for (uint32_t i = 0; i < props->memoryTypeCount; i++) {
+ const VkMemoryPropertyFlags flags = props->memoryTypes[i].propertyFlags;
const bool coherent = flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
const bool cached = flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
if (coherent && cached) {
}
}
- for (uint32_t i = 0; i < props1->memoryTypeCount; i++) {
- VkMemoryType *type = &props1->memoryTypes[i];
+ for (uint32_t i = 0; i < props->memoryTypeCount; i++) {
+ VkMemoryType *type = &props->memoryTypes[i];
if (i == incoherent_cached) {
/* Only get here if no coherent+cached type is available, and the
* spec guarantees that there is at least one coherent type, so it
* must be coherent+uncached, hence the index is always valid.
*/
- assert(coherent_uncached < props1->memoryTypeCount);
- type->heapIndex = props1->memoryTypes[coherent_uncached].heapIndex;
+ assert(coherent_uncached < props->memoryTypeCount);
+ type->heapIndex = props->memoryTypes[coherent_uncached].heapIndex;
} else if (!(type->propertyFlags &
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
type->propertyFlags &= ~(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
* our cached version. Our cached version may differ from the server's
* version due to workarounds.
*/
- pMemoryProperties->memoryProperties =
- physical_dev->memory_properties.memoryProperties;
+ pMemoryProperties->memoryProperties = physical_dev->memory_properties;
}
void