diff options
author | Gurchetan Singh <gurchetansingh@chromium.org> | 2022-07-25 15:17:41 -0700 |
---|---|---|
committer | Gurchetan Singh <gurchetansingh@google.com> | 2022-07-25 15:18:40 -0700 |
commit | a88a3107ef980abf958a450d13bb37754253af2a (patch) | |
tree | ae638cc771a47fc68a6a905e7c99f27da4c4fb99 | |
parent | 50941d0f0ed49593b69b58cc03ae83943ddc5aad (diff) | |
download | goldfish-opengl-a88a3107ef980abf958a450d13bb37754253af2a.tar.gz |
goldfish-opengl: nuke virtual heap
Integrated GPUs typically only hvae one heap of generic system
memory which is host visible
When virtualizing, gfxstream creates a fake device local heap and
host visible heap.
The idea is the gfxstream suballocates the host visible heap, which
requires occasional mappings of host memory into the guest. By
presenting a fake device local heap, we avoid the suballocations.
However, that method has the downside that a vkCmdCopyBuffer is
needed from the the host visible heap (when used) to the fake device
local heap memory. The guest not aware it's a fake heap. That
also has higher potential memory costs.
It's unclear which affect will be larger, and it could be app
specific. With Zink + gfxbench, and there wasn't any
major FPS differences. For example,
gl2_offscreen run | With patch (FPS) | Without patch (FPS)
--------------------------------------------------------
1 82.83 78.81
2 83.68 79.23
3 80.05 79.58
4 79.65 79.88
5 82.16 77.23
ANGLE hasn't been tested.
Ideally, we'd get rid of the fake virtual heap and not suballocate.
We can typically defer mapping the memory into the guest too.
This change goes in that direction.
BUG=233803018
TEST=run ./deqp-vk.memory* + gfxbench on iGPU
Change-Id: I95ebd4779c221649a6273806f8fb03e61ed97031
-rw-r--r-- | system/vulkan_enc/HostVisibleMemoryVirtualization.cpp | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp b/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp index 2c9df77e..dd817ad9 100644 --- a/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp +++ b/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp @@ -65,74 +65,6 @@ void initHostVisibleMemoryVirtualizationInfo( // by default, to be edited later. info_out->memoryTypeIndexMappingToHost[i] = i; info_out->memoryTypeIndexMappingFromHost[i] = i; - - info_out->memoryTypeBitsShouldAdvertiseBoth[i] = false; - - const auto& type = memoryProperties->memoryTypes[i]; - - if (type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { - uint32_t heapIndex = type.heapIndex; - - auto& guestMemoryType = - info_out->guestMemoryProperties.memoryTypes[i]; - - auto& newVirtualMemoryType = - info_out->guestMemoryProperties.memoryTypes[firstFreeTypeIndex]; - - auto& newVirtualMemoryHeap = - info_out->guestMemoryProperties.memoryHeaps[firstFreeHeapIndex]; - - // Remove all references to host visible in the guest memory type at - // index i, while transferring them to the new virtual memory type. - newVirtualMemoryType = type; - - // Set this memory type to have a separate heap. - newVirtualMemoryType.heapIndex = firstFreeHeapIndex; - - newVirtualMemoryType.propertyFlags = - type.propertyFlags & - ~(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); - - guestMemoryType.propertyFlags = - type.propertyFlags & \ - ~(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | - VK_MEMORY_PROPERTY_HOST_CACHED_BIT); - - // In the corresponding new memory heap, copy the information over, - // remove device local flags, and resize it based on what is - // supported by the PCI device. - newVirtualMemoryHeap = - memoryProperties->memoryHeaps[heapIndex]; - newVirtualMemoryHeap.flags = - newVirtualMemoryHeap.flags & - ~(VK_MEMORY_HEAP_DEVICE_LOCAL_BIT); - - // TODO: Figure out how to support bigger sizes - newVirtualMemoryHeap.size = VIRTUAL_HOST_VISIBLE_HEAP_SIZE; - - info_out->memoryTypeIndexMappingToHost[firstFreeTypeIndex] = i; - info_out->memoryTypeIndexMappingFromHost[i] = firstFreeTypeIndex; - - // Was the original memory type also a device local type? If so, - // advertise both types in resulting type bits. - info_out->memoryTypeBitsShouldAdvertiseBoth[i] = - type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT || - type.propertyFlags == 0; - - ++firstFreeTypeIndex; - - // Explicitly only create one new heap. - // ++firstFreeHeapIndex; - } - } - - info_out->guestMemoryProperties.memoryTypeCount = firstFreeTypeIndex; - info_out->guestMemoryProperties.memoryHeapCount = firstFreeHeapIndex + 1; - - for (uint32_t i = info_out->guestMemoryProperties.memoryTypeCount; i < VK_MAX_MEMORY_TYPES; ++i) { - memset(&info_out->guestMemoryProperties.memoryTypes[i], - 0x0, sizeof(VkMemoryType)); } } |