Commit c58458e6 by Jamie Madill Committed by Commit Bot

Vulkan: Remove CommandGraph code.

Also updates relevant comments to no longer refer to a graph. Bug: angleproject:4029 Change-Id: Ic29716e9ae4926870f902947d49d8fee7af98662 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057804 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 519163ee
......@@ -222,14 +222,6 @@ struct FeaturesVk : FeatureSetBase
"VkDevice supports the VK_EXT_swapchain_colorspace extension", &members,
"http://anglebug.com/2514"};
// Whether to use ANGLE's deferred command graph. http://anglebug.com/4029
Feature commandGraph = {
"command_graph",
FeatureCategory::VulkanFeatures,
"Use ANGLE's Vulkan deferred command graph.",
&members,
};
// Whether the VkDevice supports the VK_EXT_external_memory_host extension, on which the
// ANGLE_iosurface_client_buffer extension can be layered.
Feature supportsExternalMemoryHost = {
......
......@@ -208,31 +208,9 @@ angle::Result BufferVk::copySubData(const gl::Context *context,
vk::CommandBuffer *commandBuffer = nullptr;
if (contextVk->commandGraphEnabled())
{
// Handle self-dependency especially.
if (sourceBuffer->mBuffer.getBuffer().getHandle() == mBuffer.getBuffer().getHandle())
{
// We set the TRANSFER_READ_BIT to be conservative.
mBuffer.onSelfReadWrite(contextVk,
VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT);
ANGLE_TRY(mBuffer.recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(mBuffer.recordCommands(contextVk, &commandBuffer));
sourceBuffer->mBuffer.onReadByBuffer(contextVk, &mBuffer, VK_ACCESS_TRANSFER_READ_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT);
}
}
else
{
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, &sourceBuffer->getBuffer()));
ANGLE_TRY(contextVk->onBufferWrite(VK_ACCESS_TRANSFER_WRITE_BIT, &mBuffer));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, &sourceBuffer->getBuffer()));
ANGLE_TRY(contextVk->onBufferWrite(VK_ACCESS_TRANSFER_WRITE_BIT, &mBuffer));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
// Enqueue a copy command on the GPU.
const VkBufferCopy copyRegion = {static_cast<VkDeviceSize>(sourceOffset),
......@@ -415,24 +393,12 @@ angle::Result BufferVk::copyToBuffer(ContextVk *contextVk,
const VkBufferCopy *copies)
{
vk::CommandBuffer *commandBuffer;
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(destBuffer->recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->onBufferWrite(VK_ACCESS_TRANSFER_WRITE_BIT, destBuffer));
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, &mBuffer));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->onBufferWrite(VK_ACCESS_TRANSFER_WRITE_BIT, destBuffer));
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, &mBuffer));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
commandBuffer->copyBuffer(mBuffer.getBuffer(), destBuffer->getBuffer(), copyCount, copies);
if (contextVk->commandGraphEnabled())
{
mBuffer.onReadByBuffer(contextVk, destBuffer, VK_ACCESS_TRANSFER_READ_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT);
}
return angle::Result::Continue;
}
......
......@@ -425,7 +425,6 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
egl::ContextPriority getPriority() const { return mContextPriority; }
ANGLE_INLINE const angle::FeaturesVk &getFeatures() const { return mRenderer->getFeatures(); }
ANGLE_INLINE bool commandGraphEnabled() const { return getFeatures().commandGraph.enabled; }
ANGLE_INLINE void invalidateVertexAndIndexBuffers()
{
......@@ -537,13 +536,6 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
angle::Result getNextSubmitFence(vk::Shared<vk::Fence> *sharedFenceOut);
vk::Shared<vk::Fence> getLastSubmittedFence() const;
// This should only be called from ResourceVk.
vk::CommandGraph *getCommandGraph()
{
ASSERT(commandGraphEnabled());
return &mCommandGraph;
}
vk::ShaderLibrary &getShaderLibrary() { return mShaderLibrary; }
UtilsVk &getUtils() { return mUtils; }
......@@ -996,9 +988,6 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
// Pool allocator used for command graph but may be expanded to other allocations
angle::PoolAllocator mPoolAllocator;
// See CommandGraph.h for a desription of the Command Graph.
vk::CommandGraph mCommandGraph;
// When the command graph is disabled we record commands completely linearly. We have plans to
// reorder independent draws so that we can create fewer RenderPasses in some scenarios.
OutsideRenderPassCommandBuffer mOutsideRenderPassCommands;
......
......@@ -109,16 +109,6 @@ class FramebufferVk : public FramebufferImpl
RenderTargetVk *getColorDrawRenderTarget(size_t colorIndex) const;
RenderTargetVk *getColorReadRenderTarget() const;
// This will clear the current write operation if it is complete.
bool appendToStartedRenderPass(vk::ResourceUseList *resourceUseList,
const gl::Rectangle &renderArea,
vk::CommandBuffer **commandBufferOut)
{
ASSERT(mFramebuffer);
return mFramebuffer->appendToStartedRenderPass(resourceUseList, renderArea,
commandBufferOut);
}
vk::FramebufferHelper *getFramebuffer() { return mFramebuffer; }
angle::Result startNewRenderPass(ContextVk *context,
......@@ -162,13 +152,6 @@ class FramebufferVk : public FramebufferImpl
bool clearStencil,
const VkClearColorValue &clearColorValue,
const VkClearDepthStencilValue &clearDepthStencilValue);
angle::Result clearWithRenderPassOp(ContextVk *contextVk,
const gl::Rectangle &clearArea,
gl::DrawBufferMask clearColorBuffers,
bool clearDepth,
bool clearStencil,
const VkClearColorValue &clearColorValue,
const VkClearDepthStencilValue &clearDepthStencilValue);
angle::Result clearWithDraw(ContextVk *contextVk,
const gl::Rectangle &clearArea,
gl::DrawBufferMask clearColorBuffers,
......
......@@ -121,21 +121,10 @@ angle::Result OverlayVk::createFont(ContextVk *contextVk)
// Copy font data from staging buffer.
vk::CommandBuffer *fontDataUpload;
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(mFontImage.recordCommands(contextVk, &fontDataUpload));
fontDataBuffer.get().onRead(contextVk, &mFontImage, VK_ACCESS_TRANSFER_READ_BIT);
mFontImage.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
fontDataUpload);
}
else
{
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, &fontDataBuffer.get()));
ANGLE_TRY(contextVk->onImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
&mFontImage));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&fontDataUpload));
}
ANGLE_TRY(contextVk->onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, &fontDataBuffer.get()));
ANGLE_TRY(contextVk->onImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
&mFontImage));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&fontDataUpload));
VkBufferImageCopy copy = {};
copy.bufferRowLength = gl::overlay::kFontImageWidth;
......@@ -150,12 +139,6 @@ angle::Result OverlayVk::createFont(ContextVk *contextVk)
mFontImage.getImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1, &copy);
if (contextVk->commandGraphEnabled())
{
mFontImage.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ComputeShaderReadOnly,
fontDataUpload);
}
return angle::Result::Continue;
}
......
......@@ -1389,32 +1389,16 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk,
BufferVk *bufferVk = vk::GetImpl(bufferBinding.get());
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
if (contextVk->getFeatures().commandGraph.enabled)
if (isStorageBuffer)
{
if (isStorageBuffer)
{
// We set the SHADER_READ_BIT to be conservative.
VkAccessFlags accessFlags = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
bufferHelper.onWrite(contextVk, recorder, accessFlags);
}
else
{
bufferHelper.onRead(contextVk, recorder, VK_ACCESS_UNIFORM_READ_BIT);
}
// We set the SHADER_READ_BIT to be conservative.
VkAccessFlags accessFlags = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
commandBufferHelper->bufferWrite(resourceUseList, accessFlags, &bufferHelper);
}
else
{
if (isStorageBuffer)
{
// We set the SHADER_READ_BIT to be conservative.
VkAccessFlags accessFlags = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
commandBufferHelper->bufferWrite(resourceUseList, accessFlags, &bufferHelper);
}
else
{
commandBufferHelper->bufferRead(resourceUseList, VK_ACCESS_UNIFORM_READ_BIT,
&bufferHelper);
}
commandBufferHelper->bufferRead(resourceUseList, VK_ACCESS_UNIFORM_READ_BIT,
&bufferHelper);
}
++writeCount;
......@@ -1475,17 +1459,8 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
// We set SHADER_READ_BIT to be conservative.
if (contextVk->commandGraphEnabled())
{
bufferHelper.onWrite(contextVk, recorder,
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
}
else
{
commandBufferHelper->bufferWrite(resourceUseList,
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
&bufferHelper);
}
commandBufferHelper->bufferWrite(
resourceUseList, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, &bufferHelper);
writtenBindings.set(binding);
}
......@@ -1614,16 +1589,8 @@ angle::Result ProgramVk::updateShaderResourcesDescriptorSet(
angle::Result ProgramVk::updateTransformFeedbackDescriptorSet(ContextVk *contextVk,
vk::FramebufferHelper *framebuffer)
{
const gl::State &glState = contextVk->getState();
ASSERT(hasTransformFeedbackOutput());
if (contextVk->commandGraphEnabled())
{
TransformFeedbackVk *transformFeedbackVk =
vk::GetImpl(glState.getCurrentTransformFeedback());
transformFeedbackVk->addFramebufferDependency(contextVk, mState, framebuffer);
}
ANGLE_TRY(allocateDescriptorSet(contextVk, kUniformsAndXfbDescriptorSetIndex));
updateDefaultUniformsDescriptorSet(contextVk);
......
......@@ -49,14 +49,7 @@ angle::Result QueryVk::begin(const gl::Context *context)
if (getType() == gl::QueryType::TransformFeedbackPrimitivesWritten)
{
mTransformFeedbackPrimitivesDrawn = 0;
if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->beginTransformFeedbackEmulatedQuery();
}
else
{
// We could consider using VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT.
}
// We could consider using VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT.
return angle::Result::Continue;
}
......@@ -101,14 +94,7 @@ angle::Result QueryVk::end(const gl::Context *context)
mCachedResult += transformFeedback->getPrimitivesDrawn();
}
mCachedResultValid = true;
if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->endTransformFeedbackEmulatedQuery();
}
else
{
// We could consider using VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT.
}
// We could consider using VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT.
}
else if (getType() == gl::QueryType::TimeElapsed)
{
......
......@@ -68,55 +68,25 @@ vk::AttachmentSerial RenderTargetVk::getAssignSerial(ContextVk *contextVk)
return attachmentSerial;
}
angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk,
vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer)
angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk)
{
ASSERT(!mImage->getFormat().actualImageFormat().hasDepthOrStencilBits());
if (contextVk->commandGraphEnabled())
{
ASSERT(commandBuffer->valid());
mImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
commandBuffer);
// Set up dependencies between the RT resource and the Framebuffer.
mImage->addWriteDependency(contextVk, framebufferVk);
}
else
{
contextVk->onRenderPassImageWrite(VK_IMAGE_ASPECT_COLOR_BIT,
vk::ImageLayout::ColorAttachment, mImage);
}
contextVk->onRenderPassImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
mImage);
onImageViewAccess(contextVk);
return angle::Result::Continue;
}
angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk,
vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer)
angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk)
{
ASSERT(mImage->getFormat().actualImageFormat().hasDepthOrStencilBits());
const angle::Format &format = mImage->getFormat().actualImageFormat();
VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format);
if (contextVk->commandGraphEnabled())
{
ASSERT(commandBuffer->valid());
mImage->changeLayout(aspectFlags, vk::ImageLayout::DepthStencilAttachment, commandBuffer);
// Set up dependencies between the RT resource and the Framebuffer.
mImage->addWriteDependency(contextVk, framebufferVk);
}
else
{
contextVk->onRenderPassImageWrite(aspectFlags, vk::ImageLayout::DepthStencilAttachment,
mImage);
}
contextVk->onRenderPassImageWrite(aspectFlags, vk::ImageLayout::DepthStencilAttachment, mImage);
onImageViewAccess(contextVk);
return angle::Result::Continue;
......@@ -161,42 +131,9 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageViewH
mImageViews = imageViews;
}
vk::ImageHelper *RenderTargetVk::getImageForRead(ContextVk *contextVk,
vk::CommandGraphResource *readingResource,
vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer)
{
ASSERT(mImage && mImage->valid());
// TODO(jmadill): Better simultaneous resource access. http://anglebug.com/2679
//
// A better alternative would be:
//
// if (mImage->isLayoutChangeNecessary(layout)
// {
// vk::CommandBuffer *srcLayoutChange;
// ANGLE_TRY(mImage->recordCommands(contextVk, &srcLayoutChange));
// mImage->changeLayout(mImage->getAspectFlags(), layout, srcLayoutChange);
// }
// mImage->addReadDependency(readingResource);
//
// 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
// to perform the layout transition and set the dependency.
mImage->addWriteDependency(contextVk, readingResource);
mImage->changeLayout(mImage->getAspectFlags(), layout, commandBuffer);
onImageViewAccess(contextVk);
return mImage;
}
vk::ImageHelper *RenderTargetVk::getImageForWrite(ContextVk *contextVk,
vk::CommandGraphResource *writingResource) const
vk::ImageHelper *RenderTargetVk::getImageForWrite(ContextVk *contextVk) const
{
ASSERT(mImage && mImage->valid());
if (contextVk->commandGraphEnabled())
{
mImage->addWriteDependency(contextVk, writingResource);
}
onImageViewAccess(contextVk);
return mImage;
}
......@@ -208,14 +145,7 @@ angle::Result RenderTargetVk::flushStagedUpdates(ContextVk *contextVk)
return angle::Result::Continue;
vk::CommandBuffer *commandBuffer;
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
return mImage->flushStagedUpdates(contextVk, mLevelIndex, mLevelIndex + 1, mLayerIndex,
mLayerIndex + 1, commandBuffer);
}
......
......@@ -52,23 +52,14 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
vk::AttachmentSerial getAssignSerial(ContextVk *contextVk);
// Note: RenderTargets should be called in order, with the depth/stencil onRender last.
angle::Result onColorDraw(ContextVk *contextVk,
vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer);
angle::Result onDepthStencilDraw(ContextVk *contextVk,
vk::FramebufferHelper *framebufferVk,
vk::CommandBuffer *commandBuffer);
angle::Result onColorDraw(ContextVk *contextVk);
angle::Result onDepthStencilDraw(ContextVk *contextVk);
vk::ImageHelper &getImage();
const vk::ImageHelper &getImage() const;
// getImageForRead will also transition the resource to the given layout.
vk::ImageHelper *getImageForRead(ContextVk *contextVk,
vk::CommandGraphResource *readingResource,
vk::ImageLayout layout,
vk::CommandBuffer *commandBuffer);
vk::ImageHelper *getImageForWrite(ContextVk *contextVk,
vk::CommandGraphResource *writingResource) const;
vk::ImageHelper *getImageForWrite(ContextVk *contextVk) const;
// For cube maps we use single-level single-layer 2D array views.
angle::Result getImageView(ContextVk *contextVk, const vk::ImageView **imageViewOut) const;
......
......@@ -126,14 +126,7 @@ angle::Result RenderbufferVk::setStorageEGLImageTarget(const gl::Context *contex
if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex))
{
vk::CommandBuffer *commandBuffer = nullptr;
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
mImage->changeLayoutAndQueue(aspect, vk::ImageLayout::ColorAttachment,
rendererQueueFamilyIndex, commandBuffer);
}
......
......@@ -1613,8 +1613,6 @@ void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &dev
ANGLE_FEATURE_CONDITION((&mFeatures), disableFlippingBlitWithCommand,
IsAndroid() && isQualcomm);
ANGLE_FEATURE_CONDITION((&mFeatures), commandGraph, false);
// Allocation sanitization disabled by default because of a heaveyweight implementation
// that can cause OOM and timeouts.
ANGLE_FEATURE_CONDITION((&mFeatures), allocateNonZeroMemory, false);
......
......@@ -87,14 +87,7 @@ angle::Result SemaphoreVk::wait(gl::Context *context,
if (!bufferBarriers.empty() || !textureBarriers.empty())
{
// Create one global memory barrier to cover all barriers.
if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->syncExternalMemory();
}
else
{
ANGLE_TRY(contextVk->syncExternalMemory());
}
ANGLE_TRY(contextVk->syncExternalMemory());
}
uint32_t rendererQueueFamilyIndex = contextVk->getRenderer()->getQueueFamilyIndex();
......@@ -108,18 +101,7 @@ angle::Result SemaphoreVk::wait(gl::Context *context,
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
vk::CommandBuffer *commandBuffer;
if (contextVk->commandGraphEnabled())
{
// If there were GL commands using this buffer prior to this call, that's a
// synchronization error on behalf of the program.
ASSERT(!bufferHelper.hasRecordedCommands());
ANGLE_TRY(bufferHelper.recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
// Queue ownership transfer.
bufferHelper.changeQueue(rendererQueueFamilyIndex, commandBuffer);
......@@ -141,17 +123,8 @@ angle::Result SemaphoreVk::wait(gl::Context *context,
image.onExternalLayoutChange(layout);
vk::CommandBuffer *commandBuffer;
if (contextVk->commandGraphEnabled())
{
// If there were GL commands using this image prior to this call, that's a
// synchronization error on behalf of the program.
ASSERT(!image.hasRecordedCommands());
ANGLE_TRY(image.recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
// Queue ownership transfer.
image.changeLayoutAndQueue(image.getAspectFlags(), layout, rendererQueueFamilyIndex,
commandBuffer);
......@@ -177,14 +150,7 @@ angle::Result SemaphoreVk::signal(gl::Context *context,
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
vk::CommandBuffer *commandBuffer;
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(bufferHelper.recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
// Queue ownership transfer.
bufferHelper.changeQueue(VK_QUEUE_FAMILY_EXTERNAL, commandBuffer);
......@@ -210,14 +176,7 @@ angle::Result SemaphoreVk::signal(gl::Context *context,
}
vk::CommandBuffer *commandBuffer;
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(image.recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
// Queue ownership transfer and layout transition.
image.changeLayoutAndQueue(image.getAspectFlags(), layout, VK_QUEUE_FAMILY_EXTERNAL,
......@@ -228,14 +187,7 @@ angle::Result SemaphoreVk::signal(gl::Context *context,
if (!bufferBarriers.empty() || !textureBarriers.empty())
{
// Create one global memory barrier to cover all barriers.
if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->syncExternalMemory();
}
else
{
ANGLE_TRY(contextVk->syncExternalMemory());
}
ANGLE_TRY(contextVk->syncExternalMemory());
}
return contextVk->flushImpl(&mSemaphore);
......
......@@ -1072,34 +1072,16 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
SwapchainImage &image = mSwapchainImages[mCurrentSwapchainImageIndex];
vk::CommandBuffer *commandBuffer = nullptr;
if (!contextVk->commandGraphEnabled())
{
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
if (mColorImageMS.valid())
{
// Transition the multisampled image to TRANSFER_SRC for resolve.
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(mColorImageMS.recordCommands(contextVk, &commandBuffer));
mColorImageMS.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferSrc,
commandBuffer);
image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
commandBuffer);
// Setup graph dependency between the swapchain image and the multisampled one.
image.image.addReadDependency(contextVk, &mColorImageMS);
ANGLE_TRY(image.image.recordCommands(contextVk, &commandBuffer));
}
else
{
ANGLE_TRY(contextVk->onImageRead(VK_IMAGE_ASPECT_COLOR_BIT,
vk::ImageLayout::TransferSrc, &mColorImageMS));
ANGLE_TRY(contextVk->onImageWrite(VK_IMAGE_ASPECT_COLOR_BIT,
vk::ImageLayout::TransferDst, &image.image));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
}
ANGLE_TRY(contextVk->onImageRead(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferSrc,
&mColorImageMS));
ANGLE_TRY(contextVk->onImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::TransferDst,
&image.image));
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
VkImageResolve resolveRegion = {};
resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
......@@ -1116,10 +1098,6 @@ angle::Result WindowSurfaceVk::present(ContextVk *contextVk,
ANGLE_TRY(updateAndDrawOverlay(contextVk, &image));
if (contextVk->commandGraphEnabled())
{
ANGLE_TRY(image.image.recordCommands(contextVk, &commandBuffer));
}
image.image.changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::Present, commandBuffer);
// Knowing that the kSwapHistorySize'th submission ago has finished, we can know that the
......@@ -1509,6 +1487,7 @@ angle::Result WindowSurfaceVk::updateAndDrawOverlay(ContextVk *contextVk,
image->imageViews.getLevelLayerDrawImageView(contextVk, image->image, 0, 0, &imageView));
ANGLE_TRY(overlayVk->onPresent(contextVk, &image->image, imageView));
// TODO(jmadill): Remove this. http://anglebug.com/4029
overlay->getRunningGraphWidget(gl::WidgetId::VulkanCommandGraphSize)->next();
return angle::Result::Continue;
......
......@@ -52,17 +52,9 @@ angle::Result SyncHelper::initialize(ContextVk *contextVk)
mEvent = event.release();
if (contextVk->commandGraphEnabled())
{
CommandGraph *commandGraph = contextVk->getCommandGraph();
commandGraph->setFenceSync(mEvent);
}
else
{
vk::PrimaryCommandBuffer *primary;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primary));
primary->setEvent(mEvent.getHandle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
}
vk::PrimaryCommandBuffer *primary;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primary));
primary->setEvent(mEvent.getHandle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
contextVk->getResourceUseList().add(mUse);
return angle::Result::Continue;
......@@ -114,19 +106,10 @@ angle::Result SyncHelper::clientWait(Context *context,
angle::Result SyncHelper::serverWait(ContextVk *contextVk)
{
if (contextVk->commandGraphEnabled())
{
CommandGraph *commandGraph = contextVk->getCommandGraph();
commandGraph->waitFenceSync(mEvent);
}
else
{
vk::PrimaryCommandBuffer *primary;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primary));
primary->waitEvents(1, mEvent.ptr(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, nullptr, 0, nullptr, 0,
nullptr);
}
vk::PrimaryCommandBuffer *primary;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primary));
primary->waitEvents(1, mEvent.ptr(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, nullptr, 0, nullptr, 0, nullptr);
contextVk->getResourceUseList().add(mUse);
return angle::Result::Continue;
}
......
......@@ -81,8 +81,8 @@ angle::Result TransformFeedbackVk::pause(const gl::Context *context)
if (contextVk->getFeatures().supportsTransformFeedbackExtension.enabled)
{
// We need to create new commandGraphNode to perform transform feedback pause/resume
// becasue vkCmdBegin/EndTransformFeedback can be placed once per commandGraphNode.
// We need to end the RenderPass to perform transform feedback pause/resume
// becasue vkCmdBegin/EndTransformFeedback can be placed once per RenderPass.
ANGLE_TRY(onTransformFeedbackStateChanged(contextVk));
}
......@@ -97,8 +97,8 @@ angle::Result TransformFeedbackVk::resume(const gl::Context *context)
if (contextVk->getFeatures().supportsTransformFeedbackExtension.enabled)
{
// We need to create new commandGraphNode to perform transform feedback pause/resume
// becasue vkCmdBegin/EndTransformFeedback can be placed once per commandGraphNode.
// We need to end the RenderPass to perform transform feedback pause/resume
// becasue vkCmdBegin/EndTransformFeedback can be placed once per RenderPass.
ANGLE_TRY(onTransformFeedbackStateChanged(contextVk));
}
......@@ -176,39 +176,6 @@ void TransformFeedbackVk::updateDescriptorSetLayout(
}
}
void TransformFeedbackVk::addFramebufferDependency(ContextVk *contextVk,
const gl::ProgramState &programState,
vk::FramebufferHelper *framebuffer) const
{
const std::vector<gl::OffsetBindingPointer<gl::Buffer>> &xfbBuffers =
mState.getIndexedBuffers();
size_t xfbBufferCount = programState.getTransformFeedbackBufferCount();
ASSERT(xfbBufferCount > 0);
ASSERT(programState.getTransformFeedbackBufferMode() != GL_INTERLEAVED_ATTRIBS ||
xfbBufferCount == 1);
VkAccessFlags writeAccessType = VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT;
if (!contextVk->getFeatures().supportsTransformFeedbackExtension.enabled)
{
writeAccessType = VK_ACCESS_SHADER_WRITE_BIT;
}
// Set framebuffer dependent to the transform feedback buffers. This is especially done
// separately from |updateDescriptorSet|, to avoid introducing unnecessary buffer barriers
// every time the descriptor set is updated (which, as the set is shared with default uniforms,
// could get updated frequently).
for (size_t bufferIndex = 0; bufferIndex < xfbBufferCount; ++bufferIndex)
{
const gl::OffsetBindingPointer<gl::Buffer> &bufferBinding = xfbBuffers[bufferIndex];
gl::Buffer *buffer = bufferBinding.get();
ASSERT(buffer != nullptr);
vk::BufferHelper &bufferHelper = vk::GetImpl(buffer)->getBuffer();
bufferHelper.onWrite(contextVk, framebuffer, writeAccessType);
}
}
void TransformFeedbackVk::initDescriptorSet(ContextVk *contextVk,
size_t xfbBufferCount,
vk::BufferHelper *emptyBuffer,
......@@ -319,22 +286,7 @@ angle::Result TransformFeedbackVk::onTransformFeedbackStateChanged(ContextVk *co
// TODO(syoussefi): detect changes to buffer usage (e.g. as transform feedback output, vertex
// or index data etc) in the front end and notify the backend. A new node should be created
// only on such changes. http://anglebug.com/3205
FramebufferVk *framebufferVk = vk::GetImpl(contextVk->getState().getDrawFramebuffer());
vk::FramebufferHelper *framebuffer = framebufferVk->getFramebuffer();
if (contextVk->commandGraphEnabled())
{
framebuffer->updateCurrentAccessNodes();
if (framebuffer->hasStartedRenderPass())
{
framebuffer->finishCurrentCommands(contextVk);
}
}
else
{
ANGLE_TRY(contextVk->endRenderPass());
}
ANGLE_TRY(contextVk->endRenderPass());
return angle::Result::Continue;
}
......
......@@ -56,9 +56,6 @@ class TransformFeedbackVk : public TransformFeedbackImpl
void updateDescriptorSetLayout(ContextVk *contextVk,
const gl::ProgramState &programState,
vk::DescriptorSetLayoutDesc *descSetLayoutOut) const;
void addFramebufferDependency(ContextVk *contextVk,
const gl::ProgramState &programState,
vk::FramebufferHelper *framebuffer) const;
void initDescriptorSet(ContextVk *contextVk,
size_t xfbBufferCount,
vk::BufferHelper *emptyBuffer,
......
......@@ -476,42 +476,6 @@ class BufferHelper final : public CommandGraphResource
const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; }
VkDeviceSize getSize() const { return mSize; }
// Helpers for setting the graph dependencies *and* setting the appropriate barrier. These are
// 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
// too, as output buffers could be read as well.
void onRead(ContextVk *contextVk, CommandGraphResource *reader, VkAccessFlags readAccessType)
{
addReadDependency(contextVk, reader);
onReadAccess(reader, readAccessType);
}
void onWrite(ContextVk *contextVk, CommandGraphResource *writer, VkAccessFlags writeAccessType)
{
addWriteDependency(contextVk, writer);
onWriteAccess(contextVk, writeAccessType);
}
// Helper for setting a graph dependency between two buffers. This is a specialized function as
// both buffers may incur a memory barrier. Using |onRead| followed by |onWrite| between the
// buffers is impossible as it would result in a command graph loop.
void onReadByBuffer(ContextVk *contextVk,
BufferHelper *reader,
VkAccessFlags readAccessType,
VkAccessFlags writeAccessType)
{
addReadDependency(contextVk, reader);
onReadAccess(reader, readAccessType);
reader->onWriteAccess(contextVk, writeAccessType);
}
// Helper for setting a barrier when different parts of the same buffer is being read from and
// written to in the same command.
void onSelfReadWrite(ContextVk *contextVk, VkAccessFlags writeAccessType)
{
if (mCurrentReadAccess || mCurrentWriteAccess)
{
finishCurrentCommands(contextVk);
}
onWriteAccess(contextVk, writeAccessType);
}
// Set write access mask when the buffer is modified externally, e.g. by host. There is no
// graph resource to create a dependency to.
void onExternalWrite(VkAccessFlags writeAccessType) { mCurrentWriteAccess |= writeAccessType; }
......@@ -557,7 +521,7 @@ class BufferHelper final : public CommandGraphResource
void changeQueue(uint32_t newQueueFamilyIndex, CommandBuffer *commandBuffer);
// New methods used when the CommandGraph is disabled.
// Currently always returns false. Should be smarter about accumulation.
bool canAccumulateRead(ContextVk *contextVk, VkAccessFlags readAccessType);
bool canAccumulateWrite(ContextVk *contextVk, VkAccessFlags writeAccessType);
......@@ -584,19 +548,9 @@ class BufferHelper final : public CommandGraphResource
mCurrentReadAccess |= readAccessType;
return needsBarrier;
}
void onReadAccess(CommandGraphResource *reader, VkAccessFlags readAccessType)
{
VkAccessFlags barrierSrc, barrierDst;
if (needsOnReadBarrier(readAccessType, &barrierSrc, &barrierDst))
{
reader->addGlobalMemoryBarrier(barrierSrc, barrierDst,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
}
}
bool needsOnWriteBarrier(VkAccessFlags writeAccessType,
VkAccessFlags *barrierSrcOut,
VkAccessFlags *barrierDstOut);
void onWriteAccess(ContextVk *contextVk, VkAccessFlags writeAccessType);
angle::Result initializeNonZeroMemory(Context *context, VkDeviceSize size);
......
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