Hash :
c75bd915
Author :
Date :
2024-12-10T23:01:44
Vulkan: Remove asyncCommandQueue It's been years and it never showed an advantage. In the meantime, performance without this feature seems close to native drivers (i.e. the feature has lost its appeal) and it's frequently a source of complication and bugs. Bug: angleproject:42262955 Bug: angleproject:42265241 Bug: angleproject:42265934 Bug: angleproject:42265368 Bug: angleproject:42265738 Bug: angleproject:42266015 Bug: angleproject:377503738 Bug: angleproject:42265678 Bug: angleproject:173004081 Change-Id: Id8d7588fdbc397c28c1dd18aafa1f64cbe77806f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6084760 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: mohan maiya <m.maiya@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
//
// Copyright 2022 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.
//
// AllocatorHelperRing:
// Manages the ring buffer allocators used in the command buffers.
//
#ifndef LIBANGLE_RENDERER_VULKAN_ALLOCATORHELPERRING_H_
#define LIBANGLE_RENDERER_VULKAN_ALLOCATORHELPERRING_H_
#include "common/RingBufferAllocator.h"
#include "common/vulkan/vk_headers.h"
#include "libANGLE/renderer/vulkan/vk_command_buffer_utils.h"
#include "libANGLE/renderer/vulkan/vk_wrapper.h"
namespace rx
{
namespace vk
{
namespace priv
{
class SecondaryCommandBuffer;
} // namespace priv
using SharedCommandMemoryAllocator = angle::SharedRingBufferAllocator;
using RingBufferAllocator = angle::RingBufferAllocator;
// Used in CommandBufferHelperCommon
class SharedCommandBlockAllocator
{
public:
SharedCommandBlockAllocator() : mAllocator(nullptr), mAllocSharedCP(nullptr) {}
void resetAllocator();
bool hasAllocatorLinks() const { return mAllocator || mAllocSharedCP; }
void init() {}
void attachAllocator(SharedCommandMemoryAllocator *allocator);
SharedCommandMemoryAllocator *detachAllocator(bool isCommandBufferEmpty);
SharedCommandMemoryAllocator *getAllocator() { return mAllocator; }
private:
// Using a ring buffer allocator for less memory overhead (observed with the async queue
// ex-feature)
SharedCommandMemoryAllocator *mAllocator;
angle::SharedRingBufferAllocatorCheckPoint *mAllocSharedCP;
angle::RingBufferAllocatorCheckPoint mAllocReleaseCP;
};
// Used in SecondaryCommandBuffer
class SharedCommandBlockPool final : angle::RingBufferAllocateListener
{
public:
SharedCommandBlockPool()
: mLastCommandBlock(nullptr), mFinishedCommandSize(0), mCommandBuffer(nullptr)
{}
static constexpr size_t kCommandHeaderSize = 4;
using CommandHeaderIDType = uint16_t;
// Make sure the size of command header ID type is less than total command header size.
static_assert(sizeof(CommandHeaderIDType) < kCommandHeaderSize, "Check size of CommandHeader");
void setCommandBuffer(priv::SecondaryCommandBuffer *commandBuffer)
{
mCommandBuffer = commandBuffer;
}
void resetCommandBuffer() { mCommandBuffer = nullptr; }
void reset(CommandBufferCommandTracker *commandBufferTracker)
{
mLastCommandBlock = nullptr;
mFinishedCommandSize = 0;
if (mAllocator.valid())
{
mAllocator.release(mAllocator.getReleaseCheckPoint());
pushNewCommandBlock(mAllocator.allocate(0));
}
}
angle::Result initialize(SharedCommandMemoryAllocator *allocator)
{
return angle::Result::Continue;
}
// Always valid (even if allocator is detached).
bool valid() const { return true; }
bool empty() const { return getCommandSize() == 0; }
void getMemoryUsageStats(size_t *usedMemoryOut, size_t *allocatedMemoryOut) const;
void terminateLastCommandBlock()
{
if (mLastCommandBlock)
{
ASSERT(mAllocator.valid());
ASSERT(mAllocator.getPointer() >= mLastCommandBlock);
ASSERT(mAllocator.getFragmentSize() >= kCommandHeaderSize);
reinterpret_cast<CommandHeaderIDType &>(*(mAllocator.getPointer())) = 0;
}
}
// Initialize the SecondaryCommandBuffer by setting the allocator it will use
void attachAllocator(SharedCommandMemoryAllocator *source);
void detachAllocator(SharedCommandMemoryAllocator *destination);
void onNewVariableSizedCommand(const size_t requiredSize,
const size_t allocationSize,
uint8_t **headerOut)
{
*headerOut = allocateCommand(allocationSize);
}
void onNewCommand(const size_t requiredSize, const size_t allocationSize, uint8_t **headerOut)
{
*headerOut = allocateCommand(allocationSize);
}
private:
uint8_t *allocateCommand(size_t allocationSize)
{
ASSERT(mLastCommandBlock);
return mAllocator.allocate(static_cast<uint32_t>(allocationSize));
}
// The following is used to give the size of the command buffer in bytes
uint32_t getCommandSize() const
{
uint32_t result = mFinishedCommandSize;
if (mLastCommandBlock)
{
ASSERT(mAllocator.valid());
ASSERT(mAllocator.getPointer() >= mLastCommandBlock);
result += static_cast<uint32_t>(mAllocator.getPointer() - mLastCommandBlock);
}
return result;
}
void pushNewCommandBlock(uint8_t *block);
void finishLastCommandBlock();
// Functions derived from RingBufferAllocateListener
virtual void onRingBufferNewFragment() override;
virtual void onRingBufferFragmentEnd() override;
// Using a ring buffer allocator for less memory overhead (observed with the async queue
// ex-feature)
RingBufferAllocator mAllocator;
uint8_t *mLastCommandBlock;
uint32_t mFinishedCommandSize;
// Points to the parent command buffer.
priv::SecondaryCommandBuffer *mCommandBuffer;
};
} // namespace vk
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_ALLOCATORHELPERRING_H_