Commit d7f28aae by Jamie Madill Committed by Commit Bot

Vulkan: Pass CommandGraph when updating serials.

This is in preparation for storing a pointer to a shared resource use structure. Bug: angleproject:2464 Change-Id: I8f4ba1c71de6ad6a27ac06fc8012a0e94267cc16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1785988 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 8f2d41d1
...@@ -245,9 +245,9 @@ CommandGraphResource::CommandGraphResource(CommandGraphResourceType resourceType ...@@ -245,9 +245,9 @@ CommandGraphResource::CommandGraphResource(CommandGraphResourceType resourceType
CommandGraphResource::~CommandGraphResource() = default; CommandGraphResource::~CommandGraphResource() = default;
bool CommandGraphResource::isResourceInUse(ContextVk *context) const bool CommandGraphResource::isResourceInUse(ContextVk *contextVk) const
{ {
return context->isSerialInUse(mStoredQueueSerial); return contextVk->isSerialInUse(mStoredQueueSerial);
} }
void CommandGraphResource::resetQueueSerial() void CommandGraphResource::resetQueueSerial()
...@@ -260,7 +260,7 @@ void CommandGraphResource::resetQueueSerial() ...@@ -260,7 +260,7 @@ void CommandGraphResource::resetQueueSerial()
angle::Result CommandGraphResource::recordCommands(ContextVk *context, angle::Result CommandGraphResource::recordCommands(ContextVk *context,
CommandBuffer **commandBufferOut) CommandBuffer **commandBufferOut)
{ {
updateQueueSerial(context->getCurrentQueueSerial()); onGraphAccess(context->getCurrentQueueSerial(), context->getCommandGraph());
if (!hasChildlessWritingNode() || hasStartedRenderPass()) if (!hasChildlessWritingNode() || hasStartedRenderPass())
{ {
...@@ -306,17 +306,19 @@ angle::Result CommandGraphResource::beginRenderPass( ...@@ -306,17 +306,19 @@ angle::Result CommandGraphResource::beginRenderPass(
return mCurrentWritingNode->beginInsideRenderPassRecording(contextVk, commandBufferOut); return mCurrentWritingNode->beginInsideRenderPassRecording(contextVk, commandBufferOut);
} }
void CommandGraphResource::addWriteDependency(CommandGraphResource *writingResource) void CommandGraphResource::addWriteDependency(ContextVk *contextVk,
CommandGraphResource *writingResource)
{ {
CommandGraphNode *writingNode = writingResource->mCurrentWritingNode; CommandGraphNode *writingNode = writingResource->mCurrentWritingNode;
ASSERT(writingNode); ASSERT(writingNode);
onWriteImpl(writingNode, writingResource->getStoredQueueSerial()); onWriteImpl(contextVk, writingNode);
} }
void CommandGraphResource::addReadDependency(CommandGraphResource *readingResource) void CommandGraphResource::addReadDependency(ContextVk *contextVk,
CommandGraphResource *readingResource)
{ {
updateQueueSerial(readingResource->getStoredQueueSerial()); onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
CommandGraphNode *readingNode = readingResource->mCurrentWritingNode; CommandGraphNode *readingNode = readingResource->mCurrentWritingNode;
ASSERT(readingNode); ASSERT(readingNode);
...@@ -341,12 +343,12 @@ void CommandGraphResource::startNewCommands(ContextVk *contextVk) ...@@ -341,12 +343,12 @@ void CommandGraphResource::startNewCommands(ContextVk *contextVk)
CommandGraphNode *newCommands = CommandGraphNode *newCommands =
contextVk->getCommandGraph()->allocateNode(CommandGraphNodeFunction::Generic); contextVk->getCommandGraph()->allocateNode(CommandGraphNodeFunction::Generic);
newCommands->setDiagnosticInfo(mResourceType, reinterpret_cast<uintptr_t>(this)); newCommands->setDiagnosticInfo(mResourceType, reinterpret_cast<uintptr_t>(this));
onWriteImpl(newCommands, contextVk->getCurrentQueueSerial()); onWriteImpl(contextVk, newCommands);
} }
void CommandGraphResource::onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial) void CommandGraphResource::onWriteImpl(ContextVk *contextVk, CommandGraphNode *writingNode)
{ {
updateQueueSerial(currentSerial); onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
// Make sure any open reads and writes finish before we execute 'writingNode'. // Make sure any open reads and writes finish before we execute 'writingNode'.
if (!mCurrentReadingNodes.empty()) if (!mCurrentReadingNodes.empty())
......
...@@ -494,8 +494,9 @@ angle::Result ContextVk::setupDraw(const gl::Context *context, ...@@ -494,8 +494,9 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
mGraphicsDirtyBits |= mNewGraphicsCommandBufferDirtyBits; mGraphicsDirtyBits |= mNewGraphicsCommandBufferDirtyBits;
gl::Rectangle scissoredRenderArea = mDrawFramebuffer->getScissoredRenderArea(this); gl::Rectangle scissoredRenderArea = mDrawFramebuffer->getScissoredRenderArea(this);
if (!mDrawFramebuffer->appendToStartedRenderPass( if (!mDrawFramebuffer->appendToStartedRenderPass(mCurrentQueueSerial, &mCommandGraph,
getCurrentQueueSerial(), scissoredRenderArea, &mRenderPassCommandBuffer)) scissoredRenderArea,
&mRenderPassCommandBuffer))
{ {
ANGLE_TRY(mDrawFramebuffer->startNewRenderPass(this, scissoredRenderArea, ANGLE_TRY(mDrawFramebuffer->startNewRenderPass(this, scissoredRenderArea,
&mRenderPassCommandBuffer)); &mRenderPassCommandBuffer));
...@@ -739,7 +740,7 @@ angle::Result ContextVk::handleDirtyGraphicsVertexBuffers(const gl::Context *con ...@@ -739,7 +740,7 @@ angle::Result ContextVk::handleDirtyGraphicsVertexBuffers(const gl::Context *con
vk::BufferHelper *arrayBuffer = arrayBufferResources[attribIndex]; vk::BufferHelper *arrayBuffer = arrayBufferResources[attribIndex];
if (arrayBuffer) if (arrayBuffer)
{ {
arrayBuffer->onRead(framebuffer, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT); arrayBuffer->onRead(this, framebuffer, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT);
} }
} }
...@@ -757,7 +758,7 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte ...@@ -757,7 +758,7 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte
gl_vk::kIndexTypeMap[mCurrentDrawElementsType]); gl_vk::kIndexTypeMap[mCurrentDrawElementsType]);
vk::FramebufferHelper *framebuffer = mDrawFramebuffer->getFramebuffer(); vk::FramebufferHelper *framebuffer = mDrawFramebuffer->getFramebuffer();
elementArrayBuffer->onRead(framebuffer, VK_ACCESS_INDEX_READ_BIT); elementArrayBuffer->onRead(this, framebuffer, VK_ACCESS_INDEX_READ_BIT);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -2219,7 +2220,7 @@ angle::Result ContextVk::dispatchComputeIndirect(const gl::Context *context, GLi ...@@ -2219,7 +2220,7 @@ angle::Result ContextVk::dispatchComputeIndirect(const gl::Context *context, GLi
gl::Buffer *glBuffer = getState().getTargetBuffer(gl::BufferBinding::DispatchIndirect); gl::Buffer *glBuffer = getState().getTargetBuffer(gl::BufferBinding::DispatchIndirect);
vk::BufferHelper &buffer = vk::GetImpl(glBuffer)->getBuffer(); vk::BufferHelper &buffer = vk::GetImpl(glBuffer)->getBuffer();
buffer.onRead(&mDispatcher, VK_ACCESS_INDIRECT_COMMAND_READ_BIT); buffer.onRead(this, &mDispatcher, VK_ACCESS_INDIRECT_COMMAND_READ_BIT);
commandBuffer->dispatchIndirect(buffer.getBuffer(), indirect); commandBuffer->dispatchIndirect(buffer.getBuffer(), indirect);
...@@ -2526,7 +2527,7 @@ angle::Result ContextVk::updateActiveTextures(const gl::Context *context, ...@@ -2526,7 +2527,7 @@ angle::Result ContextVk::updateActiveTextures(const gl::Context *context,
image.changeLayout(aspectFlags, textureLayout, srcLayoutChange); image.changeLayout(aspectFlags, textureLayout, srcLayoutChange);
} }
image.addReadDependency(recorder); image.addReadDependency(this, recorder);
mActiveTextures[textureUnit].texture = textureVk; mActiveTextures[textureUnit].texture = textureVk;
mActiveTextures[textureUnit].sampler = samplerVk; mActiveTextures[textureUnit].sampler = samplerVk;
...@@ -2587,7 +2588,7 @@ angle::Result ContextVk::updateActiveImages(const gl::Context *context, ...@@ -2587,7 +2588,7 @@ angle::Result ContextVk::updateActiveImages(const gl::Context *context,
image->changeLayout(aspectFlags, imageLayout, layoutChange); image->changeLayout(aspectFlags, imageLayout, layoutChange);
} }
image->addWriteDependency(recorder); image->addWriteDependency(this, recorder);
mActiveImages[imageUnitIndex] = textureVk; mActiveImages[imageUnitIndex] = textureVk;
} }
......
...@@ -195,11 +195,12 @@ angle::Result FramebufferVk::invalidate(const gl::Context *context, ...@@ -195,11 +195,12 @@ angle::Result FramebufferVk::invalidate(const gl::Context *context,
size_t count, size_t count,
const GLenum *attachments) const GLenum *attachments)
{ {
mFramebuffer.updateQueueSerial(vk::GetImpl(context)->getCurrentQueueSerial()); ContextVk *contextVk = vk::GetImpl(context);
mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
if (mFramebuffer.valid() && mFramebuffer.hasStartedRenderPass()) if (mFramebuffer.valid() && mFramebuffer.hasStartedRenderPass())
{ {
invalidateImpl(vk::GetImpl(context), count, attachments); invalidateImpl(contextVk, count, attachments);
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -210,14 +211,15 @@ angle::Result FramebufferVk::invalidateSub(const gl::Context *context, ...@@ -210,14 +211,15 @@ angle::Result FramebufferVk::invalidateSub(const gl::Context *context,
const GLenum *attachments, const GLenum *attachments,
const gl::Rectangle &area) const gl::Rectangle &area)
{ {
mFramebuffer.updateQueueSerial(vk::GetImpl(context)->getCurrentQueueSerial()); ContextVk *contextVk = vk::GetImpl(context);
mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
// RenderPass' storeOp cannot be made conditional to a specific region, so we only apply this // RenderPass' storeOp cannot be made conditional to a specific region, so we only apply this
// hint if the requested area encompasses the render area. // hint if the requested area encompasses the render area.
if (mFramebuffer.valid() && mFramebuffer.hasStartedRenderPass() && if (mFramebuffer.valid() && mFramebuffer.hasStartedRenderPass() &&
area.encloses(mFramebuffer.getRenderPassRenderArea())) area.encloses(mFramebuffer.getRenderPassRenderArea()))
{ {
invalidateImpl(vk::GetImpl(context), count, attachments); invalidateImpl(contextVk, count, attachments);
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -261,7 +263,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -261,7 +263,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
mFramebuffer.updateQueueSerial(contextVk->getCurrentQueueSerial()); mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
// This function assumes that only enabled attachments are asked to be cleared. // This function assumes that only enabled attachments are asked to be cleared.
ASSERT((clearColorBuffers & mState.getEnabledDrawBuffers()) == clearColorBuffers); ASSERT((clearColorBuffers & mState.getEnabledDrawBuffers()) == clearColorBuffers);
...@@ -564,7 +566,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk, ...@@ -564,7 +566,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
ASSERT(colorBlit != (depthBlit || stencilBlit)); ASSERT(colorBlit != (depthBlit || stencilBlit));
vk::ImageHelper *srcImage = &readRenderTarget->getImage(); vk::ImageHelper *srcImage = &readRenderTarget->getImage();
vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer); vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(contextVk, &mFramebuffer);
VkImageAspectFlags imageAspectMask = srcImage->getAspectFlags(); VkImageAspectFlags imageAspectMask = srcImage->getAspectFlags();
VkImageAspectFlags blitAspectMask = imageAspectMask; VkImageAspectFlags blitAspectMask = imageAspectMask;
...@@ -589,7 +591,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk, ...@@ -589,7 +591,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
srcImage->addReadDependency(&mFramebuffer); srcImage->addReadDependency(contextVk, &mFramebuffer);
VkImageBlit blit = {}; VkImageBlit blit = {};
blit.srcSubresource.aspectMask = blitAspectMask; blit.srcSubresource.aspectMask = blitAspectMask;
...@@ -921,7 +923,7 @@ angle::Result FramebufferVk::resolveColorWithCommand(ContextVk *contextVk, ...@@ -921,7 +923,7 @@ angle::Result FramebufferVk::resolveColorWithCommand(ContextVk *contextVk,
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// Source's layout change should happen before rendering // Source's layout change should happen before rendering
srcImage->addReadDependency(&mFramebuffer); srcImage->addReadDependency(contextVk, &mFramebuffer);
VkImageResolve resolveRegion = {}; VkImageResolve resolveRegion = {};
resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
...@@ -943,7 +945,7 @@ angle::Result FramebufferVk::resolveColorWithCommand(ContextVk *contextVk, ...@@ -943,7 +945,7 @@ angle::Result FramebufferVk::resolveColorWithCommand(ContextVk *contextVk,
for (size_t colorIndexGL : mState.getEnabledDrawBuffers()) for (size_t colorIndexGL : mState.getEnabledDrawBuffers())
{ {
RenderTargetVk *drawRenderTarget = mRenderTargetCache.getColors()[colorIndexGL]; RenderTargetVk *drawRenderTarget = mRenderTargetCache.getColors()[colorIndexGL];
vk::ImageHelper *drawImage = drawRenderTarget->getImageForWrite(&mFramebuffer); vk::ImageHelper *drawImage = drawRenderTarget->getImageForWrite(contextVk, &mFramebuffer);
drawImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst, drawImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
commandBuffer); commandBuffer);
...@@ -1443,8 +1445,8 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk, ...@@ -1443,8 +1445,8 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// Note that although we're reading from the image, we need to update the layout below. // Note that although we're reading from the image, we need to update the layout below.
vk::ImageHelper *srcImage = vk::ImageHelper *srcImage = renderTarget->getImageForRead(
renderTarget->getImageForRead(&mFramebuffer, vk::ImageLayout::TransferSrc, commandBuffer); contextVk, &mFramebuffer, vk::ImageLayout::TransferSrc, commandBuffer);
const angle::Format *readFormat = &srcImage->getFormat().imageFormat(); const angle::Format *readFormat = &srcImage->getFormat().imageFormat();
...@@ -1483,7 +1485,8 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk, ...@@ -1483,7 +1485,8 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
contextVk, renderer->getMemoryProperties(), gl::Extents(area.width, area.height, 1), contextVk, renderer->getMemoryProperties(), gl::Extents(area.width, area.height, 1),
srcImage->getFormat(), srcImage->getFormat(),
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 1)); VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 1));
resolvedImage.get().updateQueueSerial(contextVk->getCurrentQueueSerial()); resolvedImage.get().onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
// Note: resolve only works on color images (not depth/stencil). // Note: resolve only works on color images (not depth/stencil).
// //
...@@ -1602,7 +1605,7 @@ void FramebufferVk::onScissorChange(ContextVk *contextVk) ...@@ -1602,7 +1605,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 // 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 // a render pass, the scissor is disabled and a draw call is issued to affect the whole
// framebuffer. // framebuffer.
mFramebuffer.updateQueueSerial(contextVk->getCurrentQueueSerial()); mFramebuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
if (mFramebuffer.hasStartedRenderPass() && if (mFramebuffer.hasStartedRenderPass() &&
!mFramebuffer.getRenderPassRenderArea().encloses(scissoredRenderArea)) !mFramebuffer.getRenderPassRenderArea().encloses(scissoredRenderArea))
{ {
......
...@@ -113,10 +113,11 @@ class FramebufferVk : public FramebufferImpl ...@@ -113,10 +113,11 @@ class FramebufferVk : public FramebufferImpl
// This will clear the current write operation if it is complete. // This will clear the current write operation if it is complete.
bool appendToStartedRenderPass(Serial currentQueueSerial, bool appendToStartedRenderPass(Serial currentQueueSerial,
vk::CommandGraph *graph,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut) vk::CommandBuffer **commandBufferOut)
{ {
return mFramebuffer.appendToStartedRenderPass(currentQueueSerial, renderArea, return mFramebuffer.appendToStartedRenderPass(currentQueueSerial, graph, renderArea,
commandBufferOut); commandBufferOut);
} }
......
...@@ -122,7 +122,7 @@ angle::Result OverlayVk::createFont(ContextVk *contextVk) ...@@ -122,7 +122,7 @@ angle::Result OverlayVk::createFont(ContextVk *contextVk)
vk::CommandBuffer *fontDataUpload; vk::CommandBuffer *fontDataUpload;
ANGLE_TRY(mFontImage.recordCommands(contextVk, &fontDataUpload)); ANGLE_TRY(mFontImage.recordCommands(contextVk, &fontDataUpload));
fontDataBuffer.get().onRead(&mFontImage, VK_ACCESS_TRANSFER_READ_BIT); fontDataBuffer.get().onRead(contextVk, &mFontImage, VK_ACCESS_TRANSFER_READ_BIT);
mFontImage.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst, mFontImage.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
fontDataUpload); fontDataUpload);
......
...@@ -1233,7 +1233,8 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk) ...@@ -1233,7 +1233,8 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk)
} }
else else
{ {
mEmptyBuffer.updateQueueSerial(contextVk->getCurrentQueueSerial()); mEmptyBuffer.onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle(); bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle();
} }
...@@ -1333,7 +1334,7 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk, ...@@ -1333,7 +1334,7 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk,
} }
else else
{ {
bufferHelper.onRead(recorder, VK_ACCESS_UNIFORM_READ_BIT); bufferHelper.onRead(contextVk, recorder, VK_ACCESS_UNIFORM_READ_BIT);
} }
++writeCount; ++writeCount;
...@@ -1398,7 +1399,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, ...@@ -1398,7 +1399,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
} }
// Bind the empty buffer to every array slot that's unused. // Bind the empty buffer to every array slot that's unused.
mEmptyBuffer.updateQueueSerial(contextVk->getCurrentQueueSerial()); mEmptyBuffer.onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
for (size_t binding : ~writtenBindings) for (size_t binding : ~writtenBindings)
{ {
VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding]; VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding];
......
...@@ -69,7 +69,7 @@ angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk, ...@@ -69,7 +69,7 @@ angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk,
commandBuffer); commandBuffer);
// Set up dependencies between the RT resource and the Framebuffer. // Set up dependencies between the RT resource and the Framebuffer.
mImage->addWriteDependency(framebufferVk); mImage->addWriteDependency(contextVk, framebufferVk);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -88,7 +88,7 @@ angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk, ...@@ -88,7 +88,7 @@ angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk,
mImage->changeLayout(aspectFlags, vk::ImageLayout::DepthStencilAttachment, commandBuffer); mImage->changeLayout(aspectFlags, vk::ImageLayout::DepthStencilAttachment, commandBuffer);
// Set up dependencies between the RT resource and the Framebuffer. // Set up dependencies between the RT resource and the Framebuffer.
mImage->addWriteDependency(framebufferVk); mImage->addWriteDependency(contextVk, framebufferVk);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -142,7 +142,8 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, const vk::Imag ...@@ -142,7 +142,8 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, const vk::Imag
mCubeImageFetchView = nullptr; mCubeImageFetchView = nullptr;
} }
vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readingResource, vk::ImageHelper *RenderTargetVk::getImageForRead(ContextVk *contextVk,
vk::CommandGraphResource *readingResource,
vk::ImageLayout layout, vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer) vk::CommandBuffer *commandBuffer)
{ {
...@@ -163,17 +164,18 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi ...@@ -163,17 +164,18 @@ vk::ImageHelper *RenderTargetVk::getImageForRead(vk::CommandGraphResource *readi
// I.e. the transition should happen on a node generated from mImage itself. // I.e. the transition should happen on a node generated from mImage itself.
// However, this needs context to be available here, or all call sites changed // However, this needs context to be available here, or all call sites changed
// to perform the layout transition and set the dependency. // to perform the layout transition and set the dependency.
mImage->addWriteDependency(readingResource); mImage->addWriteDependency(contextVk, readingResource);
mImage->changeLayout(mImage->getAspectFlags(), layout, commandBuffer); mImage->changeLayout(mImage->getAspectFlags(), layout, commandBuffer);
return mImage; return mImage;
} }
vk::ImageHelper *RenderTargetVk::getImageForWrite(vk::CommandGraphResource *writingResource) const vk::ImageHelper *RenderTargetVk::getImageForWrite(ContextVk *contextVk,
vk::CommandGraphResource *writingResource) const
{ {
ASSERT(mImage && mImage->valid()); ASSERT(mImage && mImage->valid());
mImage->addWriteDependency(writingResource); mImage->addWriteDependency(contextVk, writingResource);
return mImage; return mImage;
} }
......
...@@ -62,10 +62,12 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget ...@@ -62,10 +62,12 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
const vk::ImageHelper &getImage() const; const vk::ImageHelper &getImage() const;
// getImageForRead will also transition the resource to the given layout. // getImageForRead will also transition the resource to the given layout.
vk::ImageHelper *getImageForRead(vk::CommandGraphResource *readingResource, vk::ImageHelper *getImageForRead(ContextVk *contextVk,
vk::CommandGraphResource *readingResource,
vk::ImageLayout layout, vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
vk::ImageHelper *getImageForWrite(vk::CommandGraphResource *writingResource) const; vk::ImageHelper *getImageForWrite(ContextVk *contextVk,
vk::CommandGraphResource *writingResource) const;
const vk::ImageView *getDrawImageView() const; const vk::ImageView *getDrawImageView() const;
const vk::ImageView *getReadImageView() const; const vk::ImageView *getReadImageView() const;
......
...@@ -1053,7 +1053,7 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk, ...@@ -1053,7 +1053,7 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
multisampledTransition); multisampledTransition);
// Setup graph dependency between the swapchain image and the multisampled one. // Setup graph dependency between the swapchain image and the multisampled one.
image.image.addReadDependency(&mColorImageMS); image.image.addReadDependency(contextVk, &mColorImageMS);
VkImageResolve resolveRegion = {}; VkImageResolve resolveRegion = {};
resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
......
...@@ -593,7 +593,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -593,7 +593,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
commandBuffer); commandBuffer);
// Source's layout change should happen before the copy // Source's layout change should happen before the copy
srcImage->addReadDependency(mImage); srcImage->addReadDependency(contextVk, mImage);
VkImageSubresourceLayers destSubresource = srcSubresource; VkImageSubresourceLayers destSubresource = srcSubresource;
destSubresource.mipLevel = level; destSubresource.mipLevel = level;
...@@ -628,7 +628,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk, ...@@ -628,7 +628,7 @@ angle::Result TextureVk::copySubImageImplWithTransfer(ContextVk *contextVk,
commandBuffer); commandBuffer);
// Source's layout change should happen before the copy // Source's layout change should happen before the copy
srcImage->addReadDependency(stagingImage.get()); srcImage->addReadDependency(contextVk, stagingImage.get());
VkImageSubresourceLayers destSubresource = srcSubresource; VkImageSubresourceLayers destSubresource = srcSubresource;
destSubresource.mipLevel = 0; destSubresource.mipLevel = 0;
...@@ -1217,7 +1217,7 @@ angle::Result TextureVk::init3DRenderTargets(ContextVk *contextVk) ...@@ -1217,7 +1217,7 @@ angle::Result TextureVk::init3DRenderTargets(ContextVk *contextVk)
if (!m3DRenderTargets.empty()) if (!m3DRenderTargets.empty())
return angle::Result::Continue; return angle::Result::Continue;
uint32_t layerCount = GetImageLayerCountForView(*mImage); uint32_t layerCount = GetImageLayerCountForView(*mImage);
const gl::ImageDesc &baseLevelDesc = mState.getBaseLevelDesc(); const gl::ImageDesc &baseLevelDesc = mState.getBaseLevelDesc();
mLayerFetchImageView.resize(layerCount); mLayerFetchImageView.resize(layerCount);
......
...@@ -237,7 +237,7 @@ void TransformFeedbackVk::onBeginOrEnd(const gl::Context *context) ...@@ -237,7 +237,7 @@ void TransformFeedbackVk::onBeginOrEnd(const gl::Context *context)
FramebufferVk *framebufferVk = vk::GetImpl(context->getState().getDrawFramebuffer()); FramebufferVk *framebufferVk = vk::GetImpl(context->getState().getDrawFramebuffer());
vk::FramebufferHelper *framebuffer = framebufferVk->getFramebuffer(); vk::FramebufferHelper *framebuffer = framebufferVk->getFramebuffer();
framebuffer->updateQueueSerial(contextVk->getCurrentQueueSerial()); framebuffer->onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
if (framebuffer->hasStartedRenderPass()) if (framebuffer->hasStartedRenderPass())
{ {
framebuffer->finishCurrentCommands(contextVk); framebuffer->finishCurrentCommands(contextVk);
......
...@@ -956,7 +956,8 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk, ...@@ -956,7 +956,8 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(contextVk->getCurrentQueueSerial(), if (!framebuffer->appendToStartedRenderPass(contextVk->getCurrentQueueSerial(),
scissoredRenderArea, &commandBuffer)) contextVk->getCommandGraph(), scissoredRenderArea,
&commandBuffer))
{ {
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, scissoredRenderArea, &commandBuffer)); ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, scissoredRenderArea, &commandBuffer));
} }
...@@ -1184,14 +1185,15 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk, ...@@ -1184,14 +1185,15 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
} }
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
if (!framebuffer->appendToStartedRenderPass(contextVk->getCurrentQueueSerial(), params.blitArea, if (!framebuffer->appendToStartedRenderPass(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph(), params.blitArea,
&commandBuffer)) &commandBuffer))
{ {
ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, params.blitArea, &commandBuffer)); ANGLE_TRY(framebuffer->startNewRenderPass(contextVk, params.blitArea, &commandBuffer));
} }
// Source's layout change should happen before rendering // Source's layout change should happen before rendering
src->addReadDependency(framebuffer->getFramebuffer()); src->addReadDependency(contextVk, framebuffer->getFramebuffer());
VkDescriptorImageInfo imageInfos[2] = {}; VkDescriptorImageInfo imageInfos[2] = {};
...@@ -1295,7 +1297,8 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, ...@@ -1295,7 +1297,8 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
ANGLE_TRY( ANGLE_TRY(
blitBuffer.get().init(contextVk, blitBufferInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)); blitBuffer.get().init(contextVk, blitBufferInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
blitBuffer.get().updateQueueSerial(contextVk->getCurrentQueueSerial()); blitBuffer.get().onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
BlitResolveStencilNoExportShaderParams shaderParams; BlitResolveStencilNoExportShaderParams shaderParams;
if (isResolve) if (isResolve)
...@@ -1338,7 +1341,7 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, ...@@ -1338,7 +1341,7 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
ANGLE_TRY(framebuffer->getFramebuffer()->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(framebuffer->getFramebuffer()->recordCommands(contextVk, &commandBuffer));
src->addReadDependency(framebuffer->getFramebuffer()); src->addReadDependency(contextVk, framebuffer->getFramebuffer());
// Blit/resolve stencil into the buffer. // Blit/resolve stencil into the buffer.
VkDescriptorImageInfo imageInfo = {}; VkDescriptorImageInfo imageInfo = {};
...@@ -1524,7 +1527,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk, ...@@ -1524,7 +1527,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
startRenderPass(contextVk, dest, destView, renderPassDesc, renderArea, &commandBuffer)); startRenderPass(contextVk, dest, destView, renderPassDesc, renderArea, &commandBuffer));
// Source's layout change should happen before rendering // Source's layout change should happen before rendering
src->addReadDependency(dest); src->addReadDependency(contextVk, dest);
VkDescriptorImageInfo imageInfo = {}; VkDescriptorImageInfo imageInfo = {};
imageInfo.imageView = srcView->getHandle(); imageInfo.imageView = srcView->getHandle();
...@@ -1590,7 +1593,7 @@ angle::Result UtilsVk::cullOverlayWidgets(ContextVk *contextVk, ...@@ -1590,7 +1593,7 @@ angle::Result UtilsVk::cullOverlayWidgets(ContextVk *contextVk,
dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ComputeShaderWrite, dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ComputeShaderWrite,
commandBuffer); commandBuffer);
enabledWidgetsBuffer->onRead(dest, VK_ACCESS_SHADER_READ_BIT); enabledWidgetsBuffer->onRead(contextVk, dest, VK_ACCESS_SHADER_READ_BIT);
VkDescriptorImageInfo imageInfo = {}; VkDescriptorImageInfo imageInfo = {};
imageInfo.imageView = destView->getHandle(); imageInfo.imageView = destView->getHandle();
...@@ -1665,10 +1668,10 @@ angle::Result UtilsVk::drawOverlay(ContextVk *contextVk, ...@@ -1665,10 +1668,10 @@ angle::Result UtilsVk::drawOverlay(ContextVk *contextVk,
dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ComputeShaderWrite, dest->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ComputeShaderWrite,
commandBuffer); commandBuffer);
culledWidgets->addReadDependency(dest); culledWidgets->addReadDependency(contextVk, dest);
font->addReadDependency(dest); font->addReadDependency(contextVk, dest);
textWidgetsBuffer->onRead(dest, VK_ACCESS_SHADER_READ_BIT); textWidgetsBuffer->onRead(contextVk, dest, VK_ACCESS_SHADER_READ_BIT);
graphWidgetsBuffer->onRead(dest, VK_ACCESS_SHADER_READ_BIT); graphWidgetsBuffer->onRead(contextVk, dest, VK_ACCESS_SHADER_READ_BIT);
VkDescriptorImageInfo imageInfos[3] = {}; VkDescriptorImageInfo imageInfos[3] = {};
imageInfos[0].imageView = destView->getHandle(); imageInfos[0].imageView = destView->getHandle();
......
...@@ -354,7 +354,8 @@ angle::Result DynamicBuffer::allocate(ContextVk *contextVk, ...@@ -354,7 +354,8 @@ angle::Result DynamicBuffer::allocate(ContextVk *contextVk,
{ {
ANGLE_TRY(flush(contextVk)); ANGLE_TRY(flush(contextVk));
mBuffer->unmap(contextVk->getDevice()); mBuffer->unmap(contextVk->getDevice());
mBuffer->updateQueueSerial(contextVk->getCurrentQueueSerial()); mBuffer->onGraphAccess(contextVk->getCurrentQueueSerial(),
contextVk->getCommandGraph());
mInFlightBuffers.push_back(mBuffer); mInFlightBuffers.push_back(mBuffer);
mBuffer = nullptr; mBuffer = nullptr;
...@@ -494,7 +495,7 @@ void DynamicBuffer::release(ContextVk *contextVk) ...@@ -494,7 +495,7 @@ void DynamicBuffer::release(ContextVk *contextVk)
// The buffers may not have been recording commands, but they could be used to store data so // 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 // 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. // by the CPU currently never gets a chance to have its serial set.
mBuffer->updateQueueSerial(contextVk->getCurrentQueueSerial()); mBuffer->onGraphAccess(contextVk->getCurrentQueueSerial(), contextVk->getCommandGraph());
mBuffer->release(contextVk); mBuffer->release(contextVk);
delete mBuffer; delete mBuffer;
mBuffer = nullptr; mBuffer = nullptr;
...@@ -2610,7 +2611,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk, ...@@ -2610,7 +2611,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
update.image.image->changeLayout(aspectFlags, vk::ImageLayout::TransferSrc, update.image.image->changeLayout(aspectFlags, vk::ImageLayout::TransferSrc,
commandBuffer); commandBuffer);
update.image.image->addReadDependency(this); update.image.image->addReadDependency(contextVk, this);
commandBuffer->copyImage(update.image.image->getImage(), commandBuffer->copyImage(update.image.image->getImage(),
update.image.image->getCurrentLayout(), mImage, update.image.image->getCurrentLayout(), mImage,
......
...@@ -460,9 +460,9 @@ class BufferHelper final : public CommandGraphResource ...@@ -460,9 +460,9 @@ class BufferHelper final : public CommandGraphResource
// made for dependencies to non-buffer resources, as only one of two resources participating in // made for dependencies to non-buffer resources, as only one of two resources participating in
// the dependency would require a memory barrier. Note that onWrite takes read access flags // the dependency would require a memory barrier. Note that onWrite takes read access flags
// too, as output buffers could be read as well. // too, as output buffers could be read as well.
void onRead(CommandGraphResource *reader, VkAccessFlags readAccessType) void onRead(ContextVk *contextVk, CommandGraphResource *reader, VkAccessFlags readAccessType)
{ {
addReadDependency(reader); addReadDependency(contextVk, reader);
onReadAccess(reader, readAccessType); onReadAccess(reader, readAccessType);
} }
void onWrite(ContextVk *contextVk, void onWrite(ContextVk *contextVk,
...@@ -470,7 +470,7 @@ class BufferHelper final : public CommandGraphResource ...@@ -470,7 +470,7 @@ class BufferHelper final : public CommandGraphResource
VkAccessFlags readAccessType, VkAccessFlags readAccessType,
VkAccessFlags writeAccessType) VkAccessFlags writeAccessType)
{ {
addWriteDependency(writer); addWriteDependency(contextVk, writer);
onWriteAccess(contextVk, readAccessType, writeAccessType); onWriteAccess(contextVk, readAccessType, writeAccessType);
} }
// Helper for setting a graph dependency between two buffers. This is a specialized function as // Helper for setting a graph dependency between two buffers. This is a specialized function as
...@@ -481,7 +481,7 @@ class BufferHelper final : public CommandGraphResource ...@@ -481,7 +481,7 @@ class BufferHelper final : public CommandGraphResource
VkAccessFlags readAccessType, VkAccessFlags readAccessType,
VkAccessFlags writeAccessType) VkAccessFlags writeAccessType)
{ {
addReadDependency(reader); addReadDependency(contextVk, reader);
onReadAccess(reader, readAccessType); onReadAccess(reader, readAccessType);
reader->onWriteAccess(contextVk, 0, writeAccessType); reader->onWriteAccess(contextVk, 0, writeAccessType);
} }
......
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