Commit 441b72f0 by Jamie Madill Committed by Commit Bot

Vulkan: Make ContextVk own ResourceUseList.

This moves the resource use tracking functionality out of CommandGraph. Making the list a separate class helps the implementation avoid tricky circular include problems. Bug: angleproject:4029 Change-Id: I3288fc685b21e949f12b0796109a2b7bb117c249 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2002931Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 82f2cf31
......@@ -379,8 +379,7 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
VkBufferCopy copyRegion = {stagingBufferOffset, offset, size};
ANGLE_TRY(mBuffer.copyFromBuffer(contextVk, mStagingBuffer.getCurrentBuffer()->getBuffer(),
VK_ACCESS_HOST_WRITE_BIT, copyRegion));
mStagingBuffer.getCurrentBuffer()->onGraphAccess(
&contextVk->getCommandGraph()->getResourceUseList());
mStagingBuffer.getCurrentBuffer()->onGraphAccess(&contextVk->getResourceUseList());
}
else
{
......
......@@ -326,7 +326,7 @@ angle::Result CommandGraphResource::recordCommands(ContextVk *contextVk,
}
// Store reference to usage in graph.
contextVk->getCommandGraph()->getResourceUseList().add(mUse);
contextVk->getResourceUseList().add(mUse);
return angle::Result::Continue;
}
......@@ -366,7 +366,7 @@ void CommandGraphResource::addWriteDependency(ContextVk *contextVk,
void CommandGraphResource::addReadDependency(ContextVk *contextVk,
CommandGraphResource *readingResource)
{
onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
onGraphAccess(&contextVk->getResourceUseList());
CommandGraphNode *readingNode = readingResource->mCurrentWritingNode;
ASSERT(readingNode);
......@@ -396,7 +396,7 @@ void CommandGraphResource::startNewCommands(ContextVk *contextVk)
void CommandGraphResource::onWriteImpl(ContextVk *contextVk, CommandGraphNode *writingNode)
{
onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
onGraphAccess(&contextVk->getResourceUseList());
// Make sure any open reads and writes finish before we execute 'writingNode'.
if (!mCurrentReadingNodes.empty())
......@@ -1007,8 +1007,6 @@ angle::Result CommandGraph::submitCommands(ContextVk *context,
dumpGraphDotFile(std::cout);
}
mResourceUseList.releaseResourceUsesAndUpdateSerials(serial);
std::vector<CommandGraphNode *> nodeStack;
VkCommandBufferBeginInfo beginInfo = {};
......
......@@ -588,8 +588,6 @@ class CommandGraph final : angle::NonCopyable
// External memory synchronization:
void syncExternalMemory();
ResourceUseList &getResourceUseList() { return mResourceUseList; }
private:
CommandGraphNode *allocateBarrierNode(CommandGraphNodeFunction function,
CommandGraphResourceType resourceType,
......@@ -605,8 +603,6 @@ class CommandGraph final : angle::NonCopyable
bool mEnableGraphDiagnostics;
angle::PoolAllocator *mPoolAllocator;
ResourceUseList mResourceUseList;
// A set of nodes (eventually) exist that act as barriers to guarantee submission order. For
// example, a glMemoryBarrier() calls would lead to such a barrier or beginning and ending a
// query. This is because the graph can reorder operations if it sees fit. Let's call a barrier
......
......@@ -642,7 +642,7 @@ void ContextVk::onDestroy(const gl::Context *context)
mCommandQueue.destroy(device);
mCommandGraph.getResourceUseList().releaseResourceUses();
mResourceUseList.releaseResourceUses();
mUtils.destroy(device);
......@@ -803,8 +803,7 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
mGraphicsDirtyBits |= mNewGraphicsCommandBufferDirtyBits;
gl::Rectangle scissoredRenderArea = mDrawFramebuffer->getScissoredRenderArea(this);
if (!mDrawFramebuffer->appendToStartedRenderPass(&mCommandGraph.getResourceUseList(),
scissoredRenderArea,
if (!mDrawFramebuffer->appendToStartedRenderPass(&mResourceUseList, scissoredRenderArea,
&mRenderPassCommandBuffer))
{
ANGLE_TRY(mDrawFramebuffer->startNewRenderPass(this, scissoredRenderArea,
......@@ -1316,8 +1315,9 @@ angle::Result ContextVk::flushCommandGraph(vk::PrimaryCommandBuffer *commandBatc
}
mIsAnyHostVisibleBufferWritten = false;
return mCommandGraph.submitCommands(this, getCurrentQueueSerial(), &mRenderPassCache,
commandBatch);
Serial serial = getCurrentQueueSerial();
mResourceUseList.releaseResourceUsesAndUpdateSerials(serial);
return mCommandGraph.submitCommands(this, serial, &mRenderPassCache, commandBatch);
}
angle::Result ContextVk::synchronizeCpuGpuTime()
......@@ -3128,13 +3128,13 @@ angle::Result ContextVk::updateActiveTextures(const gl::Context *context,
{
samplerVk = nullptr;
samplerSerial = kZeroSerial;
textureVk->onSamplerGraphAccess(&mCommandGraph.getResourceUseList());
textureVk->onSamplerGraphAccess(&mResourceUseList);
}
else
{
samplerVk = vk::GetImpl(sampler);
samplerSerial = samplerVk->getSerial();
samplerVk->onSamplerGraphAccess(&mCommandGraph.getResourceUseList());
samplerVk->onSamplerGraphAccess(&mResourceUseList);
}
vk::ImageHelper &image = textureVk->getImage();
......@@ -3160,7 +3160,7 @@ angle::Result ContextVk::updateActiveTextures(const gl::Context *context,
image.changeLayout(aspectFlags, textureLayout, srcLayoutChange);
}
textureVk->onImageViewGraphAccess(&mCommandGraph.getResourceUseList());
textureVk->onImageViewGraphAccess(&mResourceUseList);
image.addReadDependency(this, recorder);
mActiveTextures[textureUnit].texture = textureVk;
......
......@@ -422,6 +422,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
const gl::OverlayType *getOverlay() const { return mState.getOverlay(); }
vk::ResourceUseList &getResourceUseList() { return mResourceUseList; }
private:
// Dirty bits.
enum DirtyBitType : size_t
......@@ -809,6 +811,9 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
SerialFactory mTextureSerialFactory;
gl::State::DirtyBits mPipelineDirtyBitsMask;
// List of all resources currently being used by this ContextVk's recorded commands.
vk::ResourceUseList mResourceUseList;
};
} // namespace rx
......
......@@ -162,7 +162,7 @@ angle::Result FramebufferVk::invalidate(const gl::Context *context,
const GLenum *attachments)
{
ContextVk *contextVk = vk::GetImpl(context);
mFramebuffer.onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mFramebuffer.onGraphAccess(&contextVk->getResourceUseList());
if (mFramebuffer.valid() && mFramebuffer.hasStartedRenderPass())
{
......@@ -178,7 +178,7 @@ angle::Result FramebufferVk::invalidateSub(const gl::Context *context,
const gl::Rectangle &area)
{
ContextVk *contextVk = vk::GetImpl(context);
mFramebuffer.onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mFramebuffer.onGraphAccess(&contextVk->getResourceUseList());
// RenderPass' storeOp cannot be made conditional to a specific region, so we only apply this
// hint if the requested area encompasses the render area.
......
......@@ -1248,7 +1248,7 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk)
}
else
{
mEmptyBuffer.onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mEmptyBuffer.onGraphAccess(&contextVk->getResourceUseList());
bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle();
mDescriptorBuffersCache.emplace_back(&mEmptyBuffer);
}
......@@ -1416,7 +1416,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
}
// Bind the empty buffer to every array slot that's unused.
mEmptyBuffer.onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mEmptyBuffer.onGraphAccess(&contextVk->getResourceUseList());
for (size_t binding : ~writtenBindings)
{
VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding];
......@@ -1779,7 +1779,7 @@ angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk,
for (vk::BufferHelper *buffer : mDescriptorBuffersCache)
{
buffer->onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
buffer->onGraphAccess(&contextVk->getResourceUseList());
}
return angle::Result::Continue;
......
......@@ -184,6 +184,6 @@ angle::Result RenderTargetVk::flushStagedUpdates(ContextVk *contextVk)
void RenderTargetVk::onImageViewGraphAccess(ContextVk *contextVk) const
{
mImageViews->onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mImageViews->onGraphAccess(&contextVk->getResourceUseList());
}
} // namespace rx
......@@ -54,7 +54,7 @@ angle::Result SyncHelper::initialize(ContextVk *contextVk)
CommandGraph *commandGraph = contextVk->getCommandGraph();
commandGraph->setFenceSync(mEvent);
commandGraph->getResourceUseList().add(mUse);
contextVk->getResourceUseList().add(mUse);
return angle::Result::Continue;
}
......@@ -107,7 +107,7 @@ void SyncHelper::serverWait(ContextVk *contextVk)
{
CommandGraph *commandGraph = contextVk->getCommandGraph();
commandGraph->waitFenceSync(mEvent);
commandGraph->getResourceUseList().add(mUse);
contextVk->getResourceUseList().add(mUse);
}
angle::Result SyncHelper::getStatus(Context *context, bool *signaled)
......
......@@ -1176,7 +1176,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context)
// Release the origin image and recreate it with new mipmap counts.
releaseImage(contextVk);
mImage->onResourceRecreated(&contextVk->getCommandGraph()->getResourceUseList());
mImage->onResourceRecreated(&contextVk->getResourceUseList());
ANGLE_TRY(ensureImageInitialized(contextVk, ImageMipLevels::FullMipChain));
}
......@@ -1345,7 +1345,7 @@ angle::Result TextureVk::changeLevels(ContextVk *contextVk,
// recreated with the correct number of mip levels, base level, and max level.
releaseImage(contextVk);
mImage->onResourceRecreated(&contextVk->getCommandGraph()->getResourceUseList());
mImage->onResourceRecreated(&contextVk->getResourceUseList());
return angle::Result::Continue;
}
......@@ -1597,7 +1597,7 @@ const vk::ImageView &TextureVk::getReadImageViewAndRecordUse(ContextVk *contextV
{
ASSERT(mImage->valid());
mImageViews.onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mImageViews.onGraphAccess(&contextVk->getResourceUseList());
if (mState.isStencilMode() && mImageViews.hasStencilReadImageView())
{
......@@ -1611,7 +1611,7 @@ const vk::ImageView &TextureVk::getFetchImageViewAndRecordUse(ContextVk *context
{
ASSERT(mImage->valid());
mImageViews.onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
mImageViews.onGraphAccess(&contextVk->getResourceUseList());
// We don't currently support fetch for depth/stencil cube map textures.
ASSERT(!mImageViews.hasStencilReadImageView() || !mImageViews.hasFetchImageView());
......
......@@ -1206,7 +1206,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
const gl::Rectangle &scissoredRenderArea = params.clearArea;
vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(&contextVk->getCommandGraph()->getResourceUseList(),
if (!framebuffer->appendToStartedRenderPass(&contextVk->getResourceUseList(),
scissoredRenderArea, &commandBuffer))
{
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, scissoredRenderArea, &commandBuffer));
......@@ -1435,8 +1435,8 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
}
vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(&contextVk->getCommandGraph()->getResourceUseList(),
params.blitArea, &commandBuffer))
if (!framebuffer->appendToStartedRenderPass(&contextVk->getResourceUseList(), params.blitArea,
&commandBuffer))
{
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, params.blitArea, &commandBuffer));
}
......@@ -1546,7 +1546,7 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
ANGLE_TRY(
blitBuffer.get().init(contextVk, blitBufferInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
blitBuffer.get().onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
blitBuffer.get().onGraphAccess(&contextVk->getResourceUseList());
BlitResolveStencilNoExportShaderParams shaderParams;
if (isResolve)
......
......@@ -2904,7 +2904,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
BufferHelper *currentBuffer = bufferUpdate.bufferHelper;
ASSERT(currentBuffer && currentBuffer->valid());
currentBuffer->onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
currentBuffer->onGraphAccess(&contextVk->getResourceUseList());
commandBuffer->copyBufferToImage(currentBuffer->getBuffer().getHandle(), mImage,
getCurrentLayout(), 1, &update.buffer.copyRegion);
......@@ -3204,7 +3204,7 @@ angle::Result ImageHelper::readPixels(ContextVk *contextVk,
ANGLE_TRY(resolvedImage.get().init2DStaging(
contextVk, renderer->getMemoryProperties(), gl::Extents(area.width, area.height, 1),
*mFormat, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 1));
resolvedImage.get().onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
resolvedImage.get().onGraphAccess(&contextVk->getResourceUseList());
// Note: resolve only works on color images (not depth/stencil).
//
......@@ -3483,7 +3483,7 @@ angle::Result ImageViewHelper::getLevelDrawImageView(ContextVk *contextVk,
uint32_t layer,
const ImageView **imageViewOut)
{
onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
onGraphAccess(&contextVk->getResourceUseList());
// TODO(http://anglebug.com/4008): Possibly incorrect level count.
ImageView *imageView = GetLevelImageView(&mLevelDrawImageViews, level, 1);
......@@ -3508,7 +3508,7 @@ angle::Result ImageViewHelper::getLevelLayerDrawImageView(ContextVk *contextVk,
ASSERT(image.valid());
ASSERT(!image.getFormat().actualImageFormat().isBlock);
onGraphAccess(&contextVk->getCommandGraph()->getResourceUseList());
onGraphAccess(&contextVk->getResourceUseList());
uint32_t layerCount = GetImageLayerCountForView(image);
......
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