Hash :
e339f91c
Author :
Date :
2025-03-21T10:22:59
Vulkan: Split asyncCommandBufferResetAndGarbageCleanup into two Right now this one feature flag controls garbage clean up and command buffer reset. If this is enabled, we are seeing command buffer reset some times runs on small core and some times gets blocked by mutex lock inside vulkan driver. This could take quite long while main rendering thread is blocked by ANGLE's CommandPoolAccess lock. This CL splits this feature flag into two separate feature flag: asyncGarbageCleanup controls garbage clean up in the async thread or not. asyncCommandBufferReset controls commandBuffer.reset in the async thread or not. This CL also disables commandBuffer.reset in async thread only on ARM given there is no data shows other GPUs suffer form the same problem. Bug: angleproject:378718508 Change-Id: Ice87b5b91568a0a95e0064da2b70243516ff6753 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6381893 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// PersistentCommandPool.h:
// Defines the class interface for PersistentCommandBuffer
//
#ifndef LIBANGLE_RENDERER_VULKAN_PERSISTENTCOMMANDPOOL_H_
#define LIBANGLE_RENDERER_VULKAN_PERSISTENTCOMMANDPOOL_H_
#include <vector>
#include "libANGLE/renderer/vulkan/vk_utils.h"
#include "libANGLE/renderer/vulkan/vk_wrapper.h"
namespace rx
{
namespace vk
{
// When command buffer gets collected, we have the option to call reset right away, or we can defer
// the reset call until the command buffer is going to be recycled for use again by allocate call.
enum class WhenToResetCommandBuffer
{
Now,
Defer,
};
class PersistentCommandPool final
{
public:
PersistentCommandPool();
~PersistentCommandPool();
void destroy(VkDevice device);
angle::Result init(ErrorContext *context,
ProtectionType protectionType,
uint32_t queueFamilyIndex);
angle::Result allocate(ErrorContext *context, PrimaryCommandBuffer *commandBufferOut);
angle::Result collect(ErrorContext *context,
PrimaryCommandBuffer &&buffer,
WhenToResetCommandBuffer whenToReset);
bool valid() const { return mCommandPool.valid(); }
private:
angle::Result allocateCommandBuffer(ErrorContext *context);
// command buffers that are free and ready to use
std::deque<PrimaryCommandBuffer> mFreeBuffers;
// command buffers that are free but needs reset before use
std::deque<PrimaryCommandBuffer> mFreeBuffersNeedReset;
CommandPool mCommandPool;
static const int kInitBufferNum = 2;
};
} // namespace vk
} // namespace rx
#endif