Commit bdc79361 by Charlie Lao Committed by Commit Bot

Vulkan: No need to add current buffer into mResourceUseList

This is follow up to https://chromium-review.googlesource.com/c/angle/angle/+/2288325. There is no need to add current buffer to mResourceUseList for the per context dynamic buffers. These dynamic buffers always shut down after we call finishImpl. Bug: b/160777679 Change-Id: I013cb3c30b4d31804cee13ce9e42da381fd1ae1b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2300208 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarIan Elliott <ianelliott@google.com>
parent cd5489ad
...@@ -286,7 +286,7 @@ EventName GetTraceEventName(const char *title, uint32_t counter) ...@@ -286,7 +286,7 @@ EventName GetTraceEventName(const char *title, uint32_t counter)
} // anonymous namespace } // anonymous namespace
ContextVk::DriverUniformsDescriptorSet::DriverUniformsDescriptorSet() ContextVk::DriverUniformsDescriptorSet::DriverUniformsDescriptorSet()
: descriptorSet(VK_NULL_HANDLE), dynamicOffset(0), referenced(false) : descriptorSet(VK_NULL_HANDLE), dynamicOffset(0)
{} {}
ContextVk::DriverUniformsDescriptorSet::~DriverUniformsDescriptorSet() = default; ContextVk::DriverUniformsDescriptorSet::~DriverUniformsDescriptorSet() = default;
...@@ -935,9 +935,6 @@ angle::Result ContextVk::setupDraw(const gl::Context *context, ...@@ -935,9 +935,6 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
DirtyBits dirtyBitMask, DirtyBits dirtyBitMask,
vk::CommandBuffer **commandBufferOut) vk::CommandBuffer **commandBufferOut)
{ {
// Mark it as been used so that we will add current buffer to mResourceUseList
mDriverUniforms[PipelineType::Graphics].referenced = true;
// Set any dirty bits that depend on draw call parameters or other objects. // Set any dirty bits that depend on draw call parameters or other objects.
if (mode != mCurrentDrawMode) if (mode != mCurrentDrawMode)
{ {
...@@ -1199,9 +1196,6 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context, ...@@ -1199,9 +1196,6 @@ angle::Result ContextVk::setupLineLoopDraw(const gl::Context *context,
angle::Result ContextVk::setupDispatch(const gl::Context *context, angle::Result ContextVk::setupDispatch(const gl::Context *context,
vk::CommandBuffer **commandBufferOut) vk::CommandBuffer **commandBufferOut)
{ {
// Mark it as been used so that we will add current buffer to mResourceUseList
mDriverUniforms[PipelineType::Compute].referenced = true;
// |setupDispatch| and |setupDraw| are special in that they flush dirty bits. Therefore they // |setupDispatch| and |setupDraw| are special in that they flush dirty bits. Therefore they
// don't use the same APIs to record commands as the functions outside ContextVk. // don't use the same APIs to record commands as the functions outside ContextVk.
// The following ensures prior commands are flushed before we start processing dirty bits. // The following ensures prior commands are flushed before we start processing dirty bits.
...@@ -3693,7 +3687,10 @@ angle::Result ContextVk::allocateDriverUniforms(size_t driverUniformsSize, ...@@ -3693,7 +3687,10 @@ angle::Result ContextVk::allocateDriverUniforms(size_t driverUniformsSize,
uint8_t **ptrOut, uint8_t **ptrOut,
bool *newBufferOut) bool *newBufferOut)
{ {
// Allocate a new region in the dynamic buffer. // Allocate a new region in the dynamic buffer. The allocate call may put buffer into dynamic
// buffer's mInflightBuffers. During command submission time, these inflight buffers are added
// into context's mResourceUseList which will ensure they get tagged with queue serial number
// before moving them into the free list.
VkDeviceSize offset; VkDeviceSize offset;
ANGLE_TRY(driverUniforms->dynamicBuffer.allocate(this, driverUniformsSize, ptrOut, bufferOut, ANGLE_TRY(driverUniforms->dynamicBuffer.allocate(this, driverUniformsSize, ptrOut, bufferOut,
&offset, newBufferOut)); &offset, newBufferOut));
...@@ -3943,23 +3940,12 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore) ...@@ -3943,23 +3940,12 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
ANGLE_TRY(flushOutsideRenderPassCommands()); ANGLE_TRY(flushOutsideRenderPassCommands());
// We must add the per context dynamic buffers into mResourceUseList before submission so that // We must add the per context dynamic buffers into mResourceUseList before submission so that
// they get retained properly until GPU completes // they get retained properly until GPU completes. We do not add current buffer into
// mResourceUseList since they never get reused or freed until context gets destroyed, at which
// time we always wait for GPU to finish before destroying the dynamic buffers.
for (DriverUniformsDescriptorSet &driverUniform : mDriverUniforms) for (DriverUniformsDescriptorSet &driverUniform : mDriverUniforms)
{ {
driverUniform.dynamicBuffer.releaseInFlightBuffersToResourceUseList(this); driverUniform.dynamicBuffer.releaseInFlightBuffersToResourceUseList(this);
if (driverUniform.referenced)
{
// We always have to retain the current buffer. Even if data has not changed, current
// buffer may still be referenced by this command buffer.
vk::BufferHelper *currentBuffer = driverUniform.dynamicBuffer.getCurrentBuffer();
if (currentBuffer)
{
currentBuffer->retain(&mResourceUseList);
}
driverUniform.referenced = false;
}
} }
if (mRenderer->getFeatures().enableCommandProcessingThread.enabled) if (mRenderer->getFeatures().enableCommandProcessingThread.enabled)
......
...@@ -617,7 +617,6 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -617,7 +617,6 @@ class ContextVk : public ContextImpl, public vk::Context
vk::DynamicBuffer dynamicBuffer; vk::DynamicBuffer dynamicBuffer;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
uint32_t dynamicOffset; uint32_t dynamicOffset;
bool referenced; // True if it has been used by current submission
vk::BindingPointer<vk::DescriptorSetLayout> descriptorSetLayout; vk::BindingPointer<vk::DescriptorSetLayout> descriptorSetLayout;
vk::RefCountedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment