aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaiyi Li <kaiyili@google.com>2022-09-29 18:05:26 -0700
committerKaiyi Li <kaiyili@google.com>2022-09-30 16:30:29 -0700
commit2757923cdab085f4ae6a8d31a0b30b6ff6141414 (patch)
tree4a87c6cded180f27be84d6369da883200e1e62ad
parent66a62760f6b5305df0e6db1a9d06bc5306c03242 (diff)
downloadgoldfish-opengl-2757923cdab085f4ae6a8d31a0b30b6ff6141414.tar.gz
Reformat HostVisibleMemoryVirtualization files
clang-format -i --style=file system/vulkan_enc/HostVisibleMemoryVirtualization.cpp system/vulkan_enc/HostVisibleMemoryVirtualization.h Change-Id: I7c851e40b8b0e46a8b459e3a241f093a074d0999
-rw-r--r--.clang-format2
-rw-r--r--system/vulkan_enc/HostVisibleMemoryVirtualization.cpp26
-rw-r--r--system/vulkan_enc/HostVisibleMemoryVirtualization.h34
3 files changed, 30 insertions, 32 deletions
diff --git a/.clang-format b/.clang-format
index b45f833c..6777e0d4 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,4 +1,5 @@
BasedOnStyle: Google
+IndentWidth: 4
ColumnLimit: 100
IncludeCategories:
- Regex: '^(<(gtest|gmock))'
@@ -6,6 +7,7 @@ IncludeCategories:
FixNamespaceComments: true
PointerAlignment: Left
DerivePointerAlignment: false
+AllowShortBlocksOnASingleLine: Empty
# Ensure proper formatting of macros such as GOLDFISH_VK_LIST_DISPATCHABLE_HANDLE_TYPES
StatementMacros: ["f"]
diff --git a/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp b/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp
index 939c306f..d3c4e028 100644
--- a/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp
+++ b/system/vulkan_enc/HostVisibleMemoryVirtualization.cpp
@@ -35,43 +35,37 @@ bool isHostVisible(const VkPhysicalDeviceMemoryProperties* memoryProps, uint32_t
CoherentMemory::CoherentMemory(VirtGpuBlobMappingPtr blobMapping, uint64_t size, VkDevice device,
VkDeviceMemory memory)
: mSize(size), mBlobMapping(blobMapping), mDevice(device), mMemory(memory) {
- mAllocator = std::make_unique<android::base::guest::SubAllocator>(blobMapping->asRawPtr(),
- mSize, 4096);
+ mAllocator =
+ std::make_unique<android::base::guest::SubAllocator>(blobMapping->asRawPtr(), mSize, 4096);
}
CoherentMemory::CoherentMemory(GoldfishAddressSpaceBlockPtr block, uint64_t gpuAddr, uint64_t size,
VkDevice device, VkDeviceMemory memory)
: mSize(size), mBlock(block), mDevice(device), mMemory(memory) {
void* address = block->mmap(gpuAddr);
- mAllocator = std::make_unique<android::base::guest::SubAllocator>(address, mSize,
- kLargestPageSize);
+ mAllocator =
+ std::make_unique<android::base::guest::SubAllocator>(address, mSize, kLargestPageSize);
}
-CoherentMemory::~CoherentMemory()
-{
+CoherentMemory::~CoherentMemory() {
ResourceTracker::getThreadLocalEncoder()->vkFreeMemorySyncGOOGLE(mDevice, mMemory, nullptr,
false);
}
-VkDeviceMemory CoherentMemory::getDeviceMemory() const
-{
- return mMemory;
-}
+VkDeviceMemory CoherentMemory::getDeviceMemory() const { return mMemory; }
-bool CoherentMemory::subAllocate(uint64_t size, uint8_t **ptr, uint64_t& offset) {
+bool CoherentMemory::subAllocate(uint64_t size, uint8_t** ptr, uint64_t& offset) {
auto address = mAllocator->alloc(size);
- if (!address)
- return false;
+ if (!address) return false;
*ptr = (uint8_t*)address;
offset = mAllocator->getOffset(address);
return true;
}
-bool CoherentMemory::release(uint8_t *ptr)
-{
+bool CoherentMemory::release(uint8_t* ptr) {
mAllocator->free(ptr);
return true;
}
-} // namespace goldfish_vk
+} // namespace goldfish_vk
diff --git a/system/vulkan_enc/HostVisibleMemoryVirtualization.h b/system/vulkan_enc/HostVisibleMemoryVirtualization.h
index 383ea81a..6ec9427e 100644
--- a/system/vulkan_enc/HostVisibleMemoryVirtualization.h
+++ b/system/vulkan_enc/HostVisibleMemoryVirtualization.h
@@ -15,42 +15,44 @@
#pragma once
#include <vulkan/vulkan.h>
-#include "goldfish_address_space.h"
+
#include "android/base/AndroidSubAllocator.h"
+#include "goldfish_address_space.h"
constexpr uint64_t kMegaBtye = 1048576;
// This needs to be a power of 2 that is at least the min alignment needed
// in HostVisibleMemoryVirtualization.cpp.
-// Some Windows drivers require a 64KB alignment for suballocated memory (b:152769369) for YUV images.
+// Some Windows drivers require a 64KB alignment for suballocated memory (b:152769369) for YUV
+// images.
constexpr uint64_t kLargestPageSize = 65536;
-constexpr uint64_t kDefaultHostMemBlockSize = 16 * kMegaBtye; // 16 mb
-constexpr uint64_t kHostVisibleHeapSize = 512 * kMegaBtye; // 512 mb
+constexpr uint64_t kDefaultHostMemBlockSize = 16 * kMegaBtye; // 16 mb
+constexpr uint64_t kHostVisibleHeapSize = 512 * kMegaBtye; // 512 mb
#include "VirtGpu.h"
namespace goldfish_vk {
-bool isHostVisible(const VkPhysicalDeviceMemoryProperties *memoryProps, uint32_t index);
+bool isHostVisible(const VkPhysicalDeviceMemoryProperties* memoryProps, uint32_t index);
using GoldfishAddressSpaceBlockPtr = std::shared_ptr<GoldfishAddressSpaceBlock>;
using SubAllocatorPtr = std::unique_ptr<android::base::guest::SubAllocator>;
class CoherentMemory {
- public:
- CoherentMemory(VirtGpuBlobMappingPtr blobMapping, uint64_t size, VkDevice device,
- VkDeviceMemory memory);
- CoherentMemory(GoldfishAddressSpaceBlockPtr block, uint64_t gpuAddr, uint64_t size,
- VkDevice device, VkDeviceMemory memory);
- ~CoherentMemory();
+ public:
+ CoherentMemory(VirtGpuBlobMappingPtr blobMapping, uint64_t size, VkDevice device,
+ VkDeviceMemory memory);
+ CoherentMemory(GoldfishAddressSpaceBlockPtr block, uint64_t gpuAddr, uint64_t size,
+ VkDevice device, VkDeviceMemory memory);
+ ~CoherentMemory();
- VkDeviceMemory getDeviceMemory() const;
+ VkDeviceMemory getDeviceMemory() const;
- bool subAllocate(uint64_t size, uint8_t** ptr, uint64_t& offset);
- bool release(uint8_t* ptr);
+ bool subAllocate(uint64_t size, uint8_t** ptr, uint64_t& offset);
+ bool release(uint8_t* ptr);
- private:
+ private:
CoherentMemory(CoherentMemory const&);
void operator=(CoherentMemory const&);
@@ -64,4 +66,4 @@ class CoherentMemory {
using CoherentMemoryPtr = std::shared_ptr<CoherentMemory>;
-} // namespace goldfish_vk
+} // namespace goldfish_vk