Commit b540da89 by Jamie Madill Committed by Commit Bot

Vulkan: Use ResourceUse to track object lifetime.

With the new resource tracking scheme the CommandGraph, tracking a "Context serial" aka "current" serial is no longer necessary for CommandGraphResources. Serial tracking has been moved to the shared ResourceUse struct that gets updated on a command submission. Thus we don't need to store the serial as a current separate piece of info in BufferHelper/ImageHelper. Will lead to further redesign for the multi-threading support for Vulkan. Bug: angleproject:2464 Change-Id: I1ae4bcc27fcfb93422b4ab4c9682a458e482f295 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1785990 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 01f7e545
......@@ -222,7 +222,7 @@ angle::Result BufferVk::mapRangeImpl(ContextVk *contextVk,
ANGLE_TRY(contextVk->flushImpl(nullptr));
}
// Make sure the GPU is done with the buffer.
ANGLE_TRY(contextVk->finishToSerial(mBuffer.getStoredQueueSerial()));
ANGLE_TRY(contextVk->finishToSerial(mBuffer.getLatestSerial()));
ASSERT(!mBuffer.isResourceInUse(contextVk));
}
......@@ -319,7 +319,7 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
VK_ACCESS_HOST_WRITE_BIT, copyRegion));
// Immediately release staging buffer. We should probably be using a DynamicBuffer here.
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &stagingBuffer);
contextVk->addGarbage(&stagingBuffer);
}
else
{
......
......@@ -255,17 +255,10 @@ bool CommandGraphResource::isResourceInUse(ContextVk *contextVk) const
return mUse.getCounter() > 1 || contextVk->isSerialInUse(mUse.getSerial());
}
void CommandGraphResource::resetQueueSerial()
{
mCurrentWritingNode = nullptr;
mCurrentReadingNodes.clear();
mUse.resetSerial();
}
angle::Result CommandGraphResource::recordCommands(ContextVk *context,
CommandBuffer **commandBufferOut)
{
onGraphAccess(context->getCurrentQueueSerial(), context->getCommandGraph());
onGraphAccess(context->getCommandGraph());
if (!hasChildlessWritingNode() || hasStartedRenderPass())
{
......@@ -323,7 +316,7 @@ void CommandGraphResource::addWriteDependency(ContextVk *contextVk,
void CommandGraphResource::addReadDependency(ContextVk *contextVk,
CommandGraphResource *readingResource)
{
onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
onGraphAccess(contextVk->getCommandGraph());
CommandGraphNode *readingNode = readingResource->mCurrentWritingNode;
ASSERT(readingNode);
......@@ -353,7 +346,7 @@ void CommandGraphResource::startNewCommands(ContextVk *contextVk)
void CommandGraphResource::onWriteImpl(ContextVk *contextVk, CommandGraphNode *writingNode)
{
onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
onGraphAccess(contextVk->getCommandGraph());
// Make sure any open reads and writes finish before we execute 'writingNode'.
if (!mCurrentReadingNodes.empty())
......
......@@ -339,19 +339,6 @@ class SharedResourceUse final : angle::NonCopyable
return mUse->serial;
}
ANGLE_INLINE void updateSerial(Serial serial)
{
ASSERT(valid());
ASSERT(mUse->serial < serial);
mUse->serial = serial;
}
ANGLE_INLINE void resetSerial()
{
ASSERT(valid());
mUse->serial = Serial();
}
ANGLE_INLINE uint32_t getCounter() const
{
ASSERT(valid());
......@@ -376,9 +363,8 @@ class CommandGraphResource : angle::NonCopyable
// Returns true if the resource is in use by the renderer.
bool isResourceInUse(ContextVk *contextVk) const;
// Get the current queue serial for this resource. Used to release resources, and for
// queries, to know if the queue they are submitted on has finished execution.
Serial getStoredQueueSerial() const { return mUse.getSerial(); }
Serial getLatestSerial() const { return mUse.getSerial(); }
// Sets up dependency relations. 'this' resource is the resource being written to.
void addWriteDependency(ContextVk *contextVk, CommandGraphResource *writingResource);
......@@ -388,12 +374,7 @@ class CommandGraphResource : angle::NonCopyable
// Updates the in-use serial tracked for this resource. Will clear dependencies if the resource
// was not used in this set of command nodes.
// TODO(jmadill): Remove serial once migrated. http://angelbug.com/2464
void onGraphAccess(Serial serial, CommandGraph *commandGraph);
// Reset the current queue serial for this resource. Will clear dependencies if the resource
// was not used in this set of command nodes.
void resetQueueSerial();
void onGraphAccess(CommandGraph *commandGraph);
// Allocates a write node via getNewWriteNode and returns a started command buffer.
// The started command buffer will render outside of a RenderPass.
......@@ -415,8 +396,7 @@ class CommandGraphResource : angle::NonCopyable
// Checks if we're in a RenderPass that encompasses renderArea, returning true if so. Updates
// serial internally. Returns the started command buffer in commandBufferOut.
bool appendToStartedRenderPass(Serial serial,
CommandGraph *graph,
bool appendToStartedRenderPass(CommandGraph *graph,
const gl::Rectangle &renderArea,
CommandBuffer **commandBufferOut);
......@@ -601,25 +581,24 @@ ANGLE_INLINE bool CommandGraphResource::hasStartedRenderPass() const
return hasChildlessWritingNode() && mCurrentWritingNode->getInsideRenderPassCommands()->valid();
}
ANGLE_INLINE void CommandGraphResource::onGraphAccess(Serial serial, CommandGraph *commandGraph)
ANGLE_INLINE void CommandGraphResource::onGraphAccess(CommandGraph *commandGraph)
{
// Store reference to usage in graph.
commandGraph->onResourceUse(mUse);
if (serial > mUse.getSerial())
// Clear dependencies if this is a new access. The minimum counter value is 1.
if (mUse.getCounter() == 1)
{
mCurrentWritingNode = nullptr;
mCurrentReadingNodes.clear();
mUse.updateSerial(serial);
}
// Store reference to usage in graph.
commandGraph->onResourceUse(mUse);
}
ANGLE_INLINE bool CommandGraphResource::appendToStartedRenderPass(Serial serial,
CommandGraph *graph,
ANGLE_INLINE bool CommandGraphResource::appendToStartedRenderPass(CommandGraph *graph,
const gl::Rectangle &renderArea,
CommandBuffer **commandBufferOut)
{
onGraphAccess(serial, graph);
onGraphAccess(graph);
if (hasStartedRenderPass())
{
if (mCurrentWritingNode->getRenderPassRenderArea().encloses(renderArea))
......
......@@ -496,8 +496,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
mGraphicsDirtyBits |= mNewGraphicsCommandBufferDirtyBits;
gl::Rectangle scissoredRenderArea = mDrawFramebuffer->getScissoredRenderArea(this);
if (!mDrawFramebuffer->appendToStartedRenderPass(mCurrentQueueSerial, &mCommandGraph,
scissoredRenderArea,
if (!mDrawFramebuffer->appendToStartedRenderPass(&mCommandGraph, scissoredRenderArea,
&mRenderPassCommandBuffer))
{
ANGLE_TRY(mDrawFramebuffer->startNewRenderPass(this, scissoredRenderArea,
......@@ -2988,7 +2987,7 @@ void ContextVk::waitForSwapchainImageIfNecessary()
if (waitSemaphore.valid())
{
addWaitSemaphore(waitSemaphore.getHandle());
releaseObject(getCurrentQueueSerial(), &waitSemaphore);
addGarbage(&waitSemaphore);
}
}
}
......
......@@ -269,16 +269,9 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
bool isSerialInUse(Serial serial) const;
template <typename T>
void releaseObject(Serial resourceSerial, T *object)
void addGarbage(T *object)
{
if (!isSerialInUse(resourceSerial))
{
object->destroy(getDevice());
}
else
{
object->dumpResources(resourceSerial, &mGarbage);
}
object->dumpResources(mCurrentQueueSerial, &mGarbage);
}
// Check to see which batches have finished completion (forward progress for
......
......@@ -196,7 +196,7 @@ angle::Result FramebufferVk::invalidate(const gl::Context *context,
const GLenum *attachments)
{
ContextVk *contextVk = vk::GetImpl(context);
mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mFramebuffer.onGraphAccess(contextVk->getCommandGraph());
if (mFramebuffer.valid() && mFramebuffer.hasStartedRenderPass())
{
......@@ -212,7 +212,7 @@ angle::Result FramebufferVk::invalidateSub(const gl::Context *context,
const gl::Rectangle &area)
{
ContextVk *contextVk = vk::GetImpl(context);
mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mFramebuffer.onGraphAccess(contextVk->getCommandGraph());
// RenderPass' storeOp cannot be made conditional to a specific region, so we only apply this
// hint if the requested area encompasses the render area.
......@@ -263,7 +263,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
return angle::Result::Continue;
}
mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mFramebuffer.onGraphAccess(contextVk->getCommandGraph());
// This function assumes that only enabled attachments are asked to be cleared.
ASSERT((clearColorBuffers & mState.getEnabledDrawBuffers()) == clearColorBuffers);
......@@ -899,8 +899,8 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
vk::ImageView depthViewObject = depthView.release();
vk::ImageView stencilViewObject = stencilView.release();
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &depthViewObject);
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &stencilViewObject);
contextVk->addGarbage(&depthViewObject);
contextVk->addGarbage(&stencilViewObject);
}
}
......@@ -1485,8 +1485,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
contextVk, renderer->getMemoryProperties(), gl::Extents(area.width, area.height, 1),
srcImage->getFormat(),
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 1));
resolvedImage.get().onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
resolvedImage.get().onGraphAccess(contextVk->getCommandGraph());
// Note: resolve only works on color images (not depth/stencil).
//
......@@ -1605,7 +1604,7 @@ void FramebufferVk::onScissorChange(ContextVk *contextVk)
// is too small, we need to start a new one. The latter can happen if a scissored clear starts
// a render pass, the scissor is disabled and a draw call is issued to affect the whole
// framebuffer.
mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mFramebuffer.onGraphAccess(contextVk->getCommandGraph());
if (mFramebuffer.hasStartedRenderPass() &&
!mFramebuffer.getRenderPassRenderArea().encloses(scissoredRenderArea))
{
......
......@@ -112,13 +112,11 @@ class FramebufferVk : public FramebufferImpl
RenderTargetVk *getColorReadRenderTarget() const;
// This will clear the current write operation if it is complete.
bool appendToStartedRenderPass(Serial currentQueueSerial,
vk::CommandGraph *graph,
bool appendToStartedRenderPass(vk::CommandGraph *graph,
const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut)
{
return mFramebuffer.appendToStartedRenderPass(currentQueueSerial, graph, renderArea,
commandBufferOut);
return mFramebuffer.appendToStartedRenderPass(graph, renderArea, commandBufferOut);
}
vk::FramebufferHelper *getFramebuffer() { return &mFramebuffer; }
......
......@@ -151,9 +151,8 @@ angle::Result OverlayVk::cullWidgets(ContextVk *contextVk)
RendererVk *rendererVk = contextVk->getRenderer();
// Release old culledWidgets image
Serial currentSerial = contextVk->getCurrentQueueSerial();
contextVk->releaseObject(currentSerial, &mCulledWidgets);
contextVk->releaseObject(currentSerial, &mCulledWidgetsView);
contextVk->addGarbage(&mCulledWidgets);
contextVk->addGarbage(&mCulledWidgetsView);
// Create a buffer to contain coordinates of enabled text and graph widgets. This buffer will
// be used to perform tiled culling and can be discarded immediately after.
......
......@@ -1233,8 +1233,7 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk)
}
else
{
mEmptyBuffer.onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
mEmptyBuffer.onGraphAccess(contextVk->getCommandGraph());
bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle();
}
......@@ -1399,7 +1398,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
}
// Bind the empty buffer to every array slot that's unused.
mEmptyBuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mEmptyBuffer.onGraphAccess(contextVk->getCommandGraph());
for (size_t binding : ~writtenBindings)
{
VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding];
......
......@@ -233,8 +233,8 @@ void RenderbufferVk::releaseImage(ContextVk *contextVk)
mImage = nullptr;
}
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mImageView);
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mCubeImageFetchView);
contextVk->addGarbage(&mImageView);
contextVk->addGarbage(&mCubeImageFetchView);
}
} // namespace rx
......@@ -23,7 +23,7 @@ SamplerVk::~SamplerVk() = default;
void SamplerVk::onDestroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mSampler);
contextVk->addGarbage(&mSampler);
}
const vk::Sampler &SamplerVk::getSampler() const
......@@ -43,7 +43,7 @@ angle::Result SamplerVk::syncState(const gl::Context *context, const bool dirty)
{
return angle::Result::Continue;
}
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mSampler);
contextVk->addGarbage(&mSampler);
}
const gl::Extensions &extensions = renderer->getNativeExtensions();
......
......@@ -22,7 +22,7 @@ SemaphoreVk::~SemaphoreVk() = default;
void SemaphoreVk::onDestroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mSemaphore);
contextVk->addGarbage(&mSemaphore);
}
angle::Result SemaphoreVk::importFd(gl::Context *context, gl::HandleType handleType, GLint fd)
......
......@@ -896,36 +896,32 @@ void WindowSurfaceVk::releaseSwapchainImages(ContextVk *contextVk)
{
if (mDepthStencilImage.valid())
{
Serial depthStencilSerial = mDepthStencilImage.getStoredQueueSerial();
mDepthStencilImage.releaseImage(contextVk);
mDepthStencilImage.releaseStagingBuffer(contextVk);
if (mDepthStencilImageView.valid())
{
contextVk->releaseObject(depthStencilSerial, &mDepthStencilImageView);
contextVk->addGarbage(&mDepthStencilImageView);
}
}
if (mColorImageMS.valid())
{
Serial serial = mColorImageMS.getStoredQueueSerial();
mColorImageMS.releaseImage(contextVk);
mColorImageMS.releaseStagingBuffer(contextVk);
contextVk->releaseObject(serial, &mColorImageViewMS);
contextVk->releaseObject(serial, &mFramebufferMS);
contextVk->addGarbage(&mColorImageViewMS);
contextVk->addGarbage(&mFramebufferMS);
}
for (SwapchainImage &swapchainImage : mSwapchainImages)
{
Serial imageSerial = swapchainImage.image.getStoredQueueSerial();
// We don't own the swapchain image handles, so we just remove our reference to it.
swapchainImage.image.resetImageWeakReference();
swapchainImage.image.destroy(contextVk->getDevice());
contextVk->releaseObject(imageSerial, &swapchainImage.imageView);
contextVk->releaseObject(imageSerial, &swapchainImage.framebuffer);
contextVk->addGarbage(&swapchainImage.imageView);
contextVk->addGarbage(&swapchainImage.framebuffer);
// present history must have already been taken care of.
for (ImagePresentHistory &presentHistory : swapchainImage.presentHistory)
......@@ -1230,17 +1226,6 @@ VkResult WindowSurfaceVk::nextSwapchainImage(vk::Context *context)
SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex];
// This swap chain image is new, reset any dependency information it has.
//
// When the Vulkan backend is multithreading, different contexts can have very different current
// serials. If a surface is rendered to by multiple contexts in different frames, the last
// context to write a particular swap chain image has no bearing on the current context writing
// to that image.
//
// Clear the image's queue serial because it's possible that it appears to be in the future to
// the next context that writes to the image.
image.image.resetQueueSerial();
// Update RenderTarget pointers to this swapchain image if not multisampling. Note: a possible
// optimization is to defer the |vkAcquireNextImageKHR| call itself to |present()| if
// multisampling, as the swapchain image is essentially unused until then.
......
......@@ -25,7 +25,7 @@ void FenceSyncVk::onDestroy(ContextVk *contextVk)
{
if (mEvent.valid())
{
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mEvent);
contextVk->addGarbage(&mEvent);
}
for (vk::Shared<vk::Fence> &fence : mFences)
......
......@@ -83,13 +83,13 @@ bool HasBothDepthAndStencilAspects(VkImageAspectFlags aspectFlags)
TextureVk::TextureVkViews::TextureVkViews() {}
TextureVk::TextureVkViews::~TextureVkViews() {}
void TextureVk::TextureVkViews::release(ContextVk *contextVk, Serial currentSerial)
void TextureVk::TextureVkViews::release(ContextVk *contextVk)
{
contextVk->releaseObject(currentSerial, &mDrawBaseLevelImageView);
contextVk->releaseObject(currentSerial, &mReadBaseLevelImageView);
contextVk->releaseObject(currentSerial, &mReadMipmapImageView);
contextVk->releaseObject(currentSerial, &mFetchBaseLevelImageView);
contextVk->releaseObject(currentSerial, &mFetchMipmapImageView);
contextVk->addGarbage(&mDrawBaseLevelImageView);
contextVk->addGarbage(&mReadBaseLevelImageView);
contextVk->addGarbage(&mReadMipmapImageView);
contextVk->addGarbage(&mFetchBaseLevelImageView);
contextVk->addGarbage(&mFetchMipmapImageView);
}
angle::Result TextureVk::generateMipmapLevelsWithCPU(ContextVk *contextVk,
......@@ -159,7 +159,7 @@ void TextureVk::onDestroy(const gl::Context *context)
ContextVk *contextVk = vk::GetImpl(context);
releaseAndDeleteImage(contextVk);
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mSampler);
contextVk->addGarbage(&mSampler);
}
angle::Result TextureVk::setImage(const gl::Context *context,
......@@ -660,9 +660,8 @@ angle::Result TextureVk::copySubImageImplWithDraw(ContextVk *contextVk,
vk::ImageHelper *srcImage,
const vk::ImageView *srcView)
{
RendererVk *renderer = contextVk->getRenderer();
UtilsVk &utilsVk = contextVk->getUtils();
Serial currentQueueSerial = contextVk->getCurrentQueueSerial();
RendererVk *renderer = contextVk->getRenderer();
UtilsVk &utilsVk = contextVk->getUtils();
UtilsVk::CopyImageParameters params;
params.srcOffset[0] = sourceArea.x;
......@@ -731,7 +730,7 @@ angle::Result TextureVk::copySubImageImplWithDraw(ContextVk *contextVk,
// Queue the resource for cleanup as soon as the copy above is finished. There's no
// need to keep it around.
contextVk->releaseObject(currentQueueSerial, &stagingView);
contextVk->addGarbage(&stagingView);
}
// Stage the copy for when the image storage is actually created.
......@@ -1294,7 +1293,7 @@ angle::Result TextureVk::syncState(const gl::Context *context,
RendererVk *renderer = contextVk->getRenderer();
if (mSampler.valid())
{
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mSampler);
contextVk->addGarbage(&mSampler);
}
if (dirtyBits.test(gl::Texture::DIRTY_BIT_SWIZZLE_RED) ||
......@@ -1695,35 +1694,32 @@ void TextureVk::releaseImage(ContextVk *contextVk)
void TextureVk::releaseImageViews(ContextVk *contextVk)
{
Serial currentSerial = contextVk->getCurrentQueueSerial();
mDefaultViews.release(contextVk, currentSerial);
mStencilViews.release(contextVk, currentSerial);
mDefaultViews.release(contextVk);
mStencilViews.release(contextVk);
for (vk::ImageViewVector &layerViews : mLayerLevelDrawImageViews)
{
for (vk::ImageView &imageView : layerViews)
{
contextVk->releaseObject(currentSerial, &imageView);
contextVk->addGarbage(&imageView);
}
}
mLayerLevelDrawImageViews.clear();
for (vk::ImageView &imageView : mLayerFetchImageView)
{
contextVk->releaseObject(currentSerial, &imageView);
contextVk->addGarbage(&imageView);
}
mLayerFetchImageView.clear();
for (vk::ImageView &imageView : mLevelStorageImageViews)
{
contextVk->releaseObject(currentSerial, &imageView);
contextVk->addGarbage(&imageView);
}
mLevelStorageImageViews.clear();
for (vk::ImageViewVector &layerViews : mLayerLevelStorageImageViews)
{
for (vk::ImageView &imageView : layerViews)
{
contextVk->releaseObject(currentSerial, &imageView);
contextVk->addGarbage(&imageView);
}
}
mLayerLevelStorageImageViews.clear();
......
......@@ -184,7 +184,8 @@ class TextureVk : public TextureImpl
TextureVkViews();
~TextureVkViews();
void release(ContextVk *contextVk, Serial currentSerial);
void release(ContextVk *contextVk);
vk::ImageView mDrawBaseLevelImageView;
vk::ImageView mReadBaseLevelImageView;
vk::ImageView mReadMipmapImageView;
......
......@@ -237,7 +237,7 @@ void TransformFeedbackVk::onBeginOrEnd(const gl::Context *context)
FramebufferVk *framebufferVk = vk::GetImpl(context->getState().getDrawFramebuffer());
vk::FramebufferHelper *framebuffer = framebufferVk->getFramebuffer();
framebuffer->onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
framebuffer->onGraphAccess(contextVk->getCommandGraph());
if (framebuffer->hasStartedRenderPass())
{
framebuffer->finishCurrentCommands(contextVk);
......
......@@ -941,7 +941,7 @@ angle::Result UtilsVk::startRenderPass(ContextVk *contextVk,
ANGLE_TRY(image->beginRenderPass(contextVk, framebuffer, renderArea, renderPassDesc,
renderPassAttachmentOps, clearValues, commandBufferOut));
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &framebuffer);
contextVk->addGarbage(&framebuffer);
return angle::Result::Continue;
}
......@@ -955,8 +955,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
const gl::Rectangle &scissoredRenderArea = params.clearArea;
vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph(), scissoredRenderArea,
if (!framebuffer->appendToStartedRenderPass(contextVk->getCommandGraph(), scissoredRenderArea,
&commandBuffer))
{
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, scissoredRenderArea, &commandBuffer));
......@@ -1185,8 +1184,7 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
}
vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph(), params.blitArea,
if (!framebuffer->appendToStartedRenderPass(contextVk->getCommandGraph(), params.blitArea,
&commandBuffer))
{
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, params.blitArea, &commandBuffer));
......@@ -1297,8 +1295,7 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
ANGLE_TRY(
blitBuffer.get().init(contextVk, blitBufferInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
blitBuffer.get().onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
blitBuffer.get().onGraphAccess(contextVk->getCommandGraph());
BlitResolveStencilNoExportShaderParams shaderParams;
if (isResolve)
......
......@@ -1690,7 +1690,7 @@ void GraphicsPipelineCache::release(ContextVk *context)
for (auto &item : mPayload)
{
vk::PipelineHelper &pipeline = item.second;
context->releaseObject(pipeline.getSerial(), &pipeline.getPipeline());
context->addGarbage(&pipeline.getPipeline());
}
mPayload.clear();
......
......@@ -354,8 +354,7 @@ angle::Result DynamicBuffer::allocate(ContextVk *contextVk,
{
ANGLE_TRY(flush(contextVk));
mBuffer->unmap(contextVk->getDevice());
mBuffer->onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
mBuffer->onGraphAccess(contextVk->getCommandGraph());
mInFlightBuffers.push_back(mBuffer);
mBuffer = nullptr;
......@@ -495,7 +494,7 @@ void DynamicBuffer::release(ContextVk *contextVk)
// The buffers may not have been recording commands, but they could be used to store data so
// they should live until at most this frame. For example a vertex buffer filled entirely
// by the CPU currently never gets a chance to have its serial set.
mBuffer->onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mBuffer->onGraphAccess(contextVk->getCommandGraph());
mBuffer->release(contextVk);
delete mBuffer;
mBuffer = nullptr;
......@@ -645,7 +644,7 @@ void DescriptorPoolHelper::destroy(VkDevice device)
void DescriptorPoolHelper::release(ContextVk *contextVk)
{
contextVk->releaseObject(contextVk->getCurrentQueueSerial(), &mDescriptorPool);
contextVk->addGarbage(&mDescriptorPool);
}
angle::Result DescriptorPoolHelper::allocateSets(ContextVk *contextVk,
......@@ -1306,9 +1305,9 @@ void BufferHelper::release(ContextVk *contextVk)
mSize = 0;
mViewFormat = nullptr;
contextVk->releaseObject(getStoredQueueSerial(), &mBuffer);
contextVk->releaseObject(getStoredQueueSerial(), &mBufferView);
contextVk->releaseObject(getStoredQueueSerial(), &mDeviceMemory);
contextVk->addGarbage(&mBuffer);
contextVk->addGarbage(&mBufferView);
contextVk->addGarbage(&mDeviceMemory);
}
void BufferHelper::release(DisplayVk *display, std::vector<GarbageObjectBase> *garbageQueue)
......@@ -1568,8 +1567,8 @@ angle::Result ImageHelper::initExternal(Context *context,
void ImageHelper::releaseImage(ContextVk *contextVk)
{
contextVk->releaseObject(getStoredQueueSerial(), &mImage);
contextVk->releaseObject(getStoredQueueSerial(), &mDeviceMemory);
contextVk->addGarbage(&mImage);
contextVk->addGarbage(&mDeviceMemory);
}
void ImageHelper::releaseImage(DisplayVk *display, std::vector<GarbageObjectBase> *garbageQueue)
......@@ -2730,7 +2729,7 @@ angle::Result FramebufferHelper::init(ContextVk *contextVk,
void FramebufferHelper::release(ContextVk *contextVk)
{
contextVk->releaseObject(getStoredQueueSerial(), &mFramebuffer);
contextVk->addGarbage(&mFramebuffer);
}
// FramebufferHelper implementation.
......@@ -2762,7 +2761,7 @@ void ShaderProgramHelper::destroy(VkDevice device)
void ShaderProgramHelper::release(ContextVk *contextVk)
{
mGraphicsPipelines.release(contextVk);
contextVk->releaseObject(mComputePipeline.getSerial(), &mComputePipeline.get());
contextVk->addGarbage(&mComputePipeline.get());
for (BindingPointer<ShaderAndSerial> &shader : mShaders)
{
shader.reset();
......
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