Revert "Vulkan: Flush descriptor set updates during flush*Commands()"

This reverts commit 02b73c2fd7.

Reason for revert: Causes test to crash on Linux/Intel: anglebug.com/6591

Original change's description:
> Vulkan: Flush descriptor set updates during flush*Commands()
>
> The intent of this CL is to reduce the number of descriptor set updates
> by delaying the work until all of the GLES commands that could trigger a
> re-update have been performed and the command stream is being flushed.
> To achieve this, flushDescriptorSetUpdates() is being moved from
> setupDraw()/setupDispatch() to
> flushRenderPassCommands()/flushOutsideRPCommands().
>
> This change also exposed an issue where the BufferView handles were not
> being preserved until flushDescriptorSetUpdates() was called. To resolve
> this, flushDescriptorSetUpdates() is also being called during
> BufferViewHelper::release() before the BufferView memory is released.
>
> Bug: angleproject:5706
> Change-Id: I61e19af9c0fac891aa2115d72391459b80d22f19
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939385
> Reviewed-by: Charlie Lao <cclao@google.com>
> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
> Reviewed-by: Jamie Madill <jmadill@chromium.org>
> Commit-Queue: Tim Van Patten <timvp@google.com>

Bug: angleproject:5706
Bug: angleproject:6591
Change-Id: I9d1ee3fcb3d1aebc86e60896e0065cab847a92b4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3233901
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi 2021-10-20 15:02:45 +00:00 коммит произвёл Angle LUCI CQ
Родитель d8c18ac6d8
Коммит 420e77a64e
5 изменённых файлов: 27 добавлений и 14 удалений

Просмотреть файл

@ -347,7 +347,7 @@ constexpr ContextVk::DirtyBits ContextVk::kResourcesAndDescSetDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kXfbBuffersAndDescSetDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kDriverUniformsAndBindingDirtyBits;
void ContextVk::flushDescriptorSetUpdates()
ANGLE_INLINE void ContextVk::flushDescriptorSetUpdates()
{
if (mWriteDescriptorSets.empty())
{
@ -371,6 +371,17 @@ ANGLE_INLINE void ContextVk::onRenderPassFinished()
mGraphicsDirtyBits.set(DIRTY_BIT_RENDER_PASS);
}
// ContextVk::ScopedDescriptorSetUpdates implementation.
class ContextVk::ScopedDescriptorSetUpdates final : angle::NonCopyable
{
public:
ANGLE_INLINE ScopedDescriptorSetUpdates(ContextVk *contextVk) : mContextVk(contextVk) {}
ANGLE_INLINE ~ScopedDescriptorSetUpdates() { mContextVk->flushDescriptorSetUpdates(); }
private:
ContextVk *mContextVk;
};
ContextVk::DriverUniformsDescriptorSet::DriverUniformsDescriptorSet()
: descriptorSet(VK_NULL_HANDLE), dynamicOffset(0)
{}
@ -840,6 +851,10 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
mGraphicsDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS);
}
// Create a local object to ensure we flush the descriptor updates to device when we leave this
// function
ScopedDescriptorSetUpdates descriptorSetUpdates(this);
if (mProgram && mProgram->dirtyUniforms())
{
ANGLE_TRY(mProgram->updateUniforms(this));
@ -1081,6 +1096,10 @@ angle::Result ContextVk::setupDispatch(const gl::Context *context)
// TODO: Remove this and fix tests. http://anglebug.com/5070
ANGLE_TRY(flushOutsideRenderPassCommands());
// Create a local object to ensure we flush the descriptor updates to device when we leave this
// function
ScopedDescriptorSetUpdates descriptorSetUpdates(this);
if (mProgram && mProgram->dirtyUniforms())
{
ANGLE_TRY(mProgram->updateUniforms(this));
@ -5702,7 +5721,6 @@ angle::Result ContextVk::flushCommandsAndEndRenderPassImpl()
ANGLE_TRY(getRenderPassWithOps(mRenderPassCommands->getRenderPassDesc(),
mRenderPassCommands->getAttachmentOps(), &renderPass));
flushDescriptorSetUpdates();
ANGLE_TRY(mRenderer->flushRenderPassCommands(this, hasProtectedContent(), *renderPass,
&mRenderPassCommands));
@ -5852,7 +5870,6 @@ angle::Result ContextVk::flushOutsideRenderPassCommands()
mOutsideRenderPassCommands->addCommandDiagnostics(this);
}
flushDescriptorSetUpdates();
ANGLE_TRY(mRenderer->flushOutsideRPCommands(this, hasProtectedContent(),
&mOutsideRenderPassCommands));

Просмотреть файл

@ -636,8 +636,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
angle::Result handleGraphicsEventLog(GraphicsEventCmdBuf queryEventType);
void flushDescriptorSetUpdates();
private:
// Dirty bits.
enum DirtyBitType : size_t
@ -914,6 +912,7 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
angle::Result flushCommandsAndEndRenderPassImpl();
angle::Result flushDirtyGraphicsRenderPass(DirtyBits::Iterator *dirtyBitsIterator,
DirtyBits dirtyBitMask);
void flushDescriptorSetUpdates();
void onRenderPassFinished();

Просмотреть файл

@ -1467,7 +1467,7 @@ void TextureVk::releaseAndDeleteImageAndViews(ContextVk *contextVk)
mImageCreateFlags = 0;
SafeDelete(mImage);
}
mBufferViews.release(contextVk);
mBufferViews.release(contextVk->getRenderer());
mRedefinedLevels.reset();
}
@ -2539,7 +2539,7 @@ angle::Result TextureVk::syncState(const gl::Context *context,
const VkDeviceSize offset = bufferBinding.getOffset();
const VkDeviceSize size = gl::GetBoundBufferAvailableSize(bufferBinding);
mBufferViews.release(contextVk);
mBufferViews.release(renderer);
mBufferViews.init(renderer, offset, size);
return angle::Result::Continue;
}

Просмотреть файл

@ -8205,10 +8205,8 @@ void BufferViewHelper::init(RendererVk *renderer, VkDeviceSize offset, VkDeviceS
}
}
void BufferViewHelper::release(ContextVk *contextVk)
void BufferViewHelper::release(RendererVk *renderer)
{
contextVk->flushDescriptorSetUpdates();
std::vector<GarbageObject> garbage;
for (auto &formatAndView : mViews)
@ -8221,14 +8219,13 @@ void BufferViewHelper::release(ContextVk *contextVk)
if (!garbage.empty())
{
RendererVk *rendererVk = contextVk->getRenderer();
rendererVk->collectGarbage(std::move(mUse), std::move(garbage));
renderer->collectGarbage(std::move(mUse), std::move(garbage));
// Ensure the resource use is always valid.
mUse.init();
// Update image view serial.
mViewSerial = rendererVk->getResourceSerialFactory().generateImageOrBufferViewSerial();
mViewSerial = renderer->getResourceSerialFactory().generateImageOrBufferViewSerial();
}
mViews.clear();

Просмотреть файл

@ -2505,7 +2505,7 @@ class BufferViewHelper final : public Resource
~BufferViewHelper() override;
void init(RendererVk *renderer, VkDeviceSize offset, VkDeviceSize size);
void release(ContextVk *contextVk);
void release(RendererVk *renderer);
void destroy(VkDevice device);
angle::Result getView(ContextVk *contextVk,