Skip to content

Commit

Permalink
Revert "[Dr-Dc] Use single vma for both gr context."
Browse files Browse the repository at this point in the history
This reverts commit a239309.

Reason for revert: crbug.com/1357591

Original change's description:
> [Dr-Dc] Use single vma for both gr context.
>
> Currently both gpu main thread and drdc thread have its own gr context
> and each context has its own instance of vma. Hence 2 vma instance are
> logging same histograms - Skia.VulkanMemoryAllocator.AmountAllocated.
>
> This CL updates DrDc aka CompositorGpuThread gr context to use same vulkan memory allocator used for gpu main thread gr context.
>
> Bug: 1356427
> Change-Id: I4240f282611c64d5d9b7bc851e29baf4a72cbff3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3855740
> Reviewed-by: Peng Huang <penghuang@chromium.org>
> Auto-Submit: vikas soni <vikassoni@chromium.org>
> Commit-Queue: vikas soni <vikassoni@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1039419}

Bug: 1356427, 1357591
Change-Id: I00ec56c98d21d117dbf5a527f3efe9e884c4ad83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3862878
Commit-Queue: vikas soni <vikassoni@chromium.org>
Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1040713}
  • Loading branch information
vikaschromie authored and Chromium LUCI CQ committed Aug 30, 2022
1 parent bbfa099 commit 8ac38aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ std::unique_ptr<CompositorGpuThread> CompositorGpuThread::Create(
device_queue->GetVulkanPhysicalDevice(),
device_queue->GetVulkanDevice(), device_queue->GetVulkanQueue(),
device_queue->GetVulkanQueueIndex(), device_queue->enabled_extensions(),
device_queue->enabled_device_features_2(),
device_queue->vma_allocator());
device_queue->enabled_device_features_2());
vulkan_context_provider =
VulkanInProcessContextProvider::CreateForCompositorGpuThread(
vulkan_implementation, std::move(compositor_thread_device_queue),
Expand Down Expand Up @@ -227,7 +226,6 @@ void CompositorGpuThread::HandleMemoryPressure(
// Context should be current for cache/memory cleanup.
if (shared_context_state_ &&
shared_context_state_->MakeCurrent(nullptr, /*needs_gl=*/true)) {
LOG(ERROR) << "vikas: purging drdc context";
shared_context_state_->PurgeMemory(memory_pressure_level);
}
}
Expand Down
29 changes: 8 additions & 21 deletions gpu/vulkan/vulkan_device_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ bool VulkanDeviceQueue::Initialize(
DCHECK_EQ(static_cast<VkDevice>(VK_NULL_HANDLE), owned_vk_device_);
DCHECK_EQ(static_cast<VkDevice>(VK_NULL_HANDLE), vk_device_);
DCHECK_EQ(static_cast<VkQueue>(VK_NULL_HANDLE), vk_queue_);
DCHECK_EQ(static_cast<VmaAllocator>(VK_NULL_HANDLE), owned_vma_allocator_);
DCHECK_EQ(static_cast<VmaAllocator>(VK_NULL_HANDLE), vma_allocator_);

if (VK_NULL_HANDLE == vk_instance_)
return false;
Expand Down Expand Up @@ -304,9 +302,7 @@ bool VulkanDeviceQueue::Initialize(
VK_MAX_MEMORY_HEAPS,
heap_memory_limit ? heap_memory_limit : VK_WHOLE_SIZE);
vma::CreateAllocator(vk_physical_device_, vk_device_, vk_instance_,
heap_size_limit.data(), &owned_vma_allocator_);
vma_allocator_ = owned_vma_allocator_;

heap_size_limit.data(), &vma_allocator_);
cleanup_helper_ = std::make_unique<VulkanFenceHelper>(this);

allow_protected_memory_ = allow_protected_memory;
Expand All @@ -322,19 +318,15 @@ bool VulkanDeviceQueue::InitCommon(VkPhysicalDevice vk_physical_device,
DCHECK_EQ(static_cast<VkDevice>(VK_NULL_HANDLE), owned_vk_device_);
DCHECK_EQ(static_cast<VkDevice>(VK_NULL_HANDLE), vk_device_);
DCHECK_EQ(static_cast<VkQueue>(VK_NULL_HANDLE), vk_queue_);
DCHECK_EQ(static_cast<VmaAllocator>(VK_NULL_HANDLE), owned_vma_allocator_);

vk_physical_device_ = vk_physical_device;
vk_device_ = vk_device;
vk_queue_ = vk_queue;
vk_queue_index_ = vk_queue_index;
enabled_extensions_ = std::move(enabled_extensions);

if (vma_allocator_ == VK_NULL_HANDLE) {
vma::CreateAllocator(vk_physical_device_, vk_device_, vk_instance_, nullptr,
&owned_vma_allocator_);
vma_allocator_ = owned_vma_allocator_;
}
vma::CreateAllocator(vk_physical_device_, vk_device_, vk_instance_, nullptr,
&vma_allocator_);

cleanup_helper_ = std::make_unique<VulkanFenceHelper>(this);
return true;
Expand Down Expand Up @@ -399,8 +391,7 @@ bool VulkanDeviceQueue::InitializeForCompositorGpuThread(
VkQueue vk_queue,
uint32_t vk_queue_index,
gfx::ExtensionSet enabled_extensions,
const VkPhysicalDeviceFeatures2& vk_physical_device_features2,
VmaAllocator vma_allocator) {
const VkPhysicalDeviceFeatures2& vk_physical_device_features2) {
// Currently VulkanDeviceQueue for drdc thread(aka CompositorGpuThread) uses
// the same vulkan queue as the gpu main thread. Now since both gpu main and
// drdc threads would be accessing/submitting work to the same queue, all the
Expand All @@ -416,9 +407,6 @@ bool VulkanDeviceQueue::InitializeForCompositorGpuThread(
GetVulkanFunctionPointers()->per_queue_lock_map[vk_queue] =
std::make_unique<base::Lock>();
enabled_device_features_2_ = vk_physical_device_features2;

// Note that CompositorGpuThread uses same vma allocator as gpu main thread.
vma_allocator_ = vma_allocator;
return InitCommon(vk_physical_device, vk_device, vk_queue, vk_queue_index,
enabled_extensions);
}
Expand All @@ -429,12 +417,12 @@ void VulkanDeviceQueue::Destroy() {
cleanup_helper_.reset();
}

if (owned_vma_allocator_ != VK_NULL_HANDLE) {
vma::DestroyAllocator(owned_vma_allocator_);
owned_vma_allocator_ = VK_NULL_HANDLE;
if (vma_allocator_ != VK_NULL_HANDLE) {
vma::DestroyAllocator(vma_allocator_);
vma_allocator_ = VK_NULL_HANDLE;
}

if (owned_vk_device_ != VK_NULL_HANDLE) {
if (VK_NULL_HANDLE != owned_vk_device_) {
vkDestroyDevice(owned_vk_device_, nullptr);
owned_vk_device_ = VK_NULL_HANDLE;

Expand All @@ -451,7 +439,6 @@ void VulkanDeviceQueue::Destroy() {
vk_queue_ = VK_NULL_HANDLE;
vk_queue_index_ = 0;
vk_physical_device_ = VK_NULL_HANDLE;
vma_allocator_ = VK_NULL_HANDLE;
}

std::unique_ptr<VulkanCommandPool> VulkanDeviceQueue::CreateCommandPool() {
Expand Down
4 changes: 1 addition & 3 deletions gpu/vulkan/vulkan_device_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class COMPONENT_EXPORT(VULKAN) VulkanDeviceQueue {
VkQueue vk_queue,
uint32_t vk_queue_index,
gfx::ExtensionSet enabled_extensions,
const VkPhysicalDeviceFeatures2& vk_physical_device_features2,
VmaAllocator vma_allocator);
const VkPhysicalDeviceFeatures2& vk_physical_device_features2);

const gfx::ExtensionSet& enabled_extensions() const {
return enabled_extensions_;
Expand Down Expand Up @@ -147,7 +146,6 @@ class COMPONENT_EXPORT(VULKAN) VulkanDeviceQueue {
uint32_t vk_queue_index_ = 0;
VkInstance vk_instance_ = VK_NULL_HANDLE;
raw_ptr<VulkanInstance> instance_ = nullptr;
VmaAllocator owned_vma_allocator_ = VK_NULL_HANDLE;
VmaAllocator vma_allocator_ = VK_NULL_HANDLE;
std::unique_ptr<VulkanFenceHelper> cleanup_helper_;
VkPhysicalDeviceFeatures2 enabled_device_features_2_{
Expand Down

0 comments on commit 8ac38aa

Please sign in to comment.