Vulkan: Implement a SharedResourceUse pool

When adding a Resource to the ResourceUseList of ContextVk
we constructed a new SharedResourceUse object for tracking
and update of the Resource's Serial. We would then delete
it after releasing the resource. This incurs repeated
memory operation costs.

Instead we now allocate a pool of SharedResourceUse objects
and acquire and release from this pool as needed.

VTune profile of the Manhattan 30 offscreen benchmark
shows the CPU occupancy of bufferRead decrease from an
average of 0.9% -> 0.6% and imageRead decreases from
an average of 0.4% -> 0.3%. The bottleneck for both
these methods is the retain() method that leverages
the new SharedResourceUse pool.

Bug: angleproject:4950
Change-Id: Ib4f67c6f101d4b2de118014546e6cc14ad108703
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2396597
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
This commit is contained in:
Mohan Maiya 2020-09-14 12:04:20 -07:00 коммит произвёл Commit Bot
Родитель 76e90947a8
Коммит de335c1685
16 изменённых файлов: 177 добавлений и 91 удалений

Просмотреть файл

@ -621,12 +621,15 @@ egl::Error Context::onDestroy(const egl::Display *display)
mState.mFramebufferManager->release(this);
mState.mMemoryObjectManager->release(this);
mState.mSemaphoreManager->release(this);
mState.mShareGroup->release(this);
mThreadPool.reset();
mImplementation->onDestroy(this);
// Some ShareGroup implementations contain resource pools that implementation contexts
// can leverage thus enforcing an ordering during destroy.
mState.mShareGroup->release(this);
mOverlay.destroy(this);
return egl::NoError();

Просмотреть файл

@ -536,7 +536,7 @@ angle::Result BufferVk::acquireAndUpdate(ContextVk *contextVk,
if (updateRegionBeforeSubData || updateRegionAfterSubData)
{
src->retain(&contextVk->getResourceUseList());
src->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
}
ANGLE_TRY(acquireBufferHelper(contextVk, size, &mBuffer));

Просмотреть файл

@ -795,7 +795,7 @@ void ContextVk::onDestroy(const gl::Context *context)
mCommandQueue.destroy(device);
mResourceUseList.releaseResourceUses();
mResourceUseList.releaseResourceUses(getSharedResourceUsePool());
mUtils.destroy(mRenderer);
@ -1143,7 +1143,7 @@ angle::Result ContextVk::setupIndirectDraw(const gl::Context *context,
mCurrentIndirectBuffer = indirectBuffer;
}
mRenderPassCommands->bufferRead(&mResourceUseList, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, indirectBuffer);
ANGLE_TRY(setupDraw(context, mode, firstVertex, vertexCount, instanceCount,
@ -1416,10 +1416,9 @@ ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl(
}
}
// Ensure the image is in read-only layout
commandBufferHelper->imageRead(&mResourceUseList, image.getAspectFlags(), textureLayout,
&image);
commandBufferHelper->imageRead(this, image.getAspectFlags(), textureLayout, &image);
textureVk->retainImageViews(&mResourceUseList);
textureVk->retainImageViews(this);
}
if (executable->hasTextures())
@ -1463,7 +1462,7 @@ angle::Result ContextVk::handleDirtyGraphicsVertexBuffers(const gl::Context *con
vk::BufferHelper *arrayBuffer = arrayBufferResources[attribIndex];
if (arrayBuffer)
{
mRenderPassCommands->bufferRead(&mResourceUseList, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT,
mRenderPassCommands->bufferRead(this, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT,
vk::PipelineStage::VertexInput, arrayBuffer);
}
}
@ -1481,8 +1480,8 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte
mVertexArray->getCurrentElementArrayBufferOffset(),
getVkIndexType(mCurrentDrawElementsType));
mRenderPassCommands->bufferRead(&mResourceUseList, VK_ACCESS_INDEX_READ_BIT,
vk::PipelineStage::VertexInput, elementArrayBuffer);
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDEX_READ_BIT, vk::PipelineStage::VertexInput,
elementArrayBuffer);
return angle::Result::Continue;
}
@ -1544,7 +1543,7 @@ angle::Result ContextVk::handleDirtyGraphicsTransformFeedbackBuffersEmulation(
{
vk::BufferHelper *bufferHelper = bufferHelpers[bufferIndex];
ASSERT(bufferHelper);
mRenderPassCommands->bufferWrite(&mResourceUseList, VK_ACCESS_SHADER_WRITE_BIT,
mRenderPassCommands->bufferWrite(this, VK_ACCESS_SHADER_WRITE_BIT,
vk::PipelineStage::VertexShader,
vk::AliasingMode::Disallowed, bufferHelper);
}
@ -1583,9 +1582,9 @@ angle::Result ContextVk::handleDirtyGraphicsTransformFeedbackBuffersExtension(
{
vk::BufferHelper *bufferHelper = bufferHelpers[bufferIndex];
ASSERT(bufferHelper);
mRenderPassCommands->bufferWrite(
&mResourceUseList, VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT,
vk::PipelineStage::TransformFeedback, vk::AliasingMode::Disallowed, bufferHelper);
mRenderPassCommands->bufferWrite(this, VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT,
vk::PipelineStage::TransformFeedback,
vk::AliasingMode::Disallowed, bufferHelper);
}
const gl::TransformFeedbackBuffersArray<VkBuffer> &bufferHandles =
@ -2282,7 +2281,7 @@ angle::Result ContextVk::drawArraysIndirect(const gl::Context *context,
if (mVertexArray->getStreamingVertexAttribsMask().any())
{
mRenderPassCommands->bufferRead(&mResourceUseList, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, currentIndirectBuf);
// We have instanced vertex attributes that need to be emulated for Vulkan.
@ -2336,7 +2335,7 @@ angle::Result ContextVk::drawElementsIndirect(const gl::Context *context,
if (mVertexArray->getStreamingVertexAttribsMask().any())
{
mRenderPassCommands->bufferRead(&mResourceUseList, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, currentIndirectBuf);
// We have instanced vertex attributes that need to be emulated for Vulkan.
@ -3561,7 +3560,7 @@ angle::Result ContextVk::dispatchComputeIndirect(const gl::Context *context, GLi
gl::Buffer *glBuffer = getState().getTargetBuffer(gl::BufferBinding::DispatchIndirect);
vk::BufferHelper &buffer = vk::GetImpl(glBuffer)->getBuffer();
mOutsideRenderPassCommands->bufferRead(&mResourceUseList, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
mOutsideRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, &buffer);
commandBuffer->dispatchIndirect(buffer.getBuffer(), indirect);
@ -4100,8 +4099,8 @@ angle::Result ContextVk::updateActiveImages(const gl::Context *context,
}
VkImageAspectFlags aspectFlags = image->getAspectFlags();
commandBufferHelper->imageWrite(&mResourceUseList, aspectFlags, imageLayout,
vk::AliasingMode::Allowed, image);
commandBufferHelper->imageWrite(this, aspectFlags, imageLayout, vk::AliasingMode::Allowed,
image);
}
return angle::Result::Continue;
@ -4176,7 +4175,7 @@ angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
ANGLE_VK_TRY(this, mPrimaryCommands.end());
Serial serial = getCurrentQueueSerial();
mResourceUseList.releaseResourceUsesAndUpdateSerials(serial);
mResourceUseList.releaseResourceUsesAndUpdateSerials(serial, getSharedResourceUsePool());
waitForSwapchainImageIfNecessary();
@ -4478,7 +4477,7 @@ angle::Result ContextVk::onBufferRead(VkAccessFlags readAccessType,
ANGLE_TRY(flushOutsideRenderPassCommands());
}
mOutsideRenderPassCommands->bufferRead(&mResourceUseList, readAccessType, readStage, buffer);
mOutsideRenderPassCommands->bufferRead(this, readAccessType, readStage, buffer);
return angle::Result::Continue;
}
@ -4498,7 +4497,7 @@ angle::Result ContextVk::onBufferWrite(VkAccessFlags writeAccessType,
ANGLE_TRY(flushOutsideRenderPassCommands());
}
mOutsideRenderPassCommands->bufferWrite(&mResourceUseList, writeAccessType, writeStage,
mOutsideRenderPassCommands->bufferWrite(this, writeAccessType, writeStage,
vk::AliasingMode::Disallowed, buffer);
return angle::Result::Continue;
@ -4538,7 +4537,7 @@ angle::Result ContextVk::onImageRead(VkImageAspectFlags aspectFlags,
image->recordReadBarrier(aspectFlags, imageLayout,
&mOutsideRenderPassCommands->getCommandBuffer());
image->retain(&mResourceUseList);
image->retain(&mResourceUseList, getSharedResourceUsePool());
return angle::Result::Continue;
}
@ -4554,7 +4553,7 @@ angle::Result ContextVk::onImageWrite(VkImageAspectFlags aspectFlags,
image->recordWriteBarrier(aspectFlags, imageLayout,
&mOutsideRenderPassCommands->getCommandBuffer());
image->retain(&mResourceUseList);
image->retain(&mResourceUseList, getSharedResourceUsePool());
image->onWrite();
return angle::Result::Continue;

Просмотреть файл

@ -16,6 +16,7 @@
#include "common/vulkan/vk_headers.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/OverlayVk.h"
#include "libANGLE/renderer/vulkan/PersistentCommandPool.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
@ -482,6 +483,11 @@ class ContextVk : public ContextImpl, public vk::Context
vk::ResourceUseList &getResourceUseList() { return mResourceUseList; }
ANGLE_INLINE vk::SharedResourceUsePool *getSharedResourceUsePool()
{
return mShareGroupVk->getSharedResourceUsePool();
}
angle::Result onBufferTransferRead(vk::BufferHelper *buffer)
{
return onBufferRead(VK_ACCESS_TRANSFER_READ_BIT, vk::PipelineStage::Transfer, buffer);
@ -526,7 +532,7 @@ class ContextVk : public ContextImpl, public vk::Context
vk::ImageHelper *image)
{
ASSERT(mRenderPassCommands->started());
mRenderPassCommands->imageRead(&mResourceUseList, aspectFlags, imageLayout, image);
mRenderPassCommands->imageRead(this, aspectFlags, imageLayout, image);
}
void onImageRenderPassWrite(VkImageAspectFlags aspectFlags,
@ -534,8 +540,8 @@ class ContextVk : public ContextImpl, public vk::Context
vk::ImageHelper *image)
{
ASSERT(mRenderPassCommands->started());
mRenderPassCommands->imageWrite(&mResourceUseList, aspectFlags, imageLayout,
vk::AliasingMode::Allowed, image);
mRenderPassCommands->imageWrite(this, aspectFlags, imageLayout, vk::AliasingMode::Allowed,
image);
}
vk::CommandBuffer &getOutsideRenderPassCommandBuffer()

Просмотреть файл

@ -22,6 +22,7 @@
namespace rx
{
// DisplayVk implementation
DisplayVk::DisplayVk(const egl::DisplayState &state)
: DisplayImpl(state),
vk::Context(new RendererVk()),

Просмотреть файл

@ -12,6 +12,7 @@
#include "common/MemoryBuffer.h"
#include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/vk_utils.h"
namespace rx
@ -22,6 +23,14 @@ class ShareGroupVk : public ShareGroupImpl
{
public:
ShareGroupVk() {}
ANGLE_INLINE vk::SharedResourceUsePool *getSharedResourceUsePool()
{
return &mSharedResourceUsePool;
}
private:
vk::SharedResourceUsePool mSharedResourceUsePool;
};
class DisplayVk : public DisplayImpl, public vk::Context

Просмотреть файл

@ -940,7 +940,7 @@ void ProgramExecutableVk::updateDefaultUniformsDescriptorSet(
else
{
vk::BufferHelper &emptyBuffer = contextVk->getEmptyBuffer();
emptyBuffer.retain(&contextVk->getResourceUseList());
emptyBuffer.retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
bufferInfo.buffer = emptyBuffer.getBuffer().getHandle();
}
@ -1044,13 +1044,13 @@ angle::Result ProgramExecutableVk::updateBuffersDescriptorSet(
{
// 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,
commandBufferHelper->bufferWrite(contextVk, accessFlags,
kPipelineStageShaderMap[shaderType],
vk::AliasingMode::Allowed, &bufferHelper);
}
else
{
commandBufferHelper->bufferRead(resourceUseList, VK_ACCESS_UNIFORM_READ_BIT,
commandBufferHelper->bufferRead(contextVk, VK_ACCESS_UNIFORM_READ_BIT,
kPipelineStageShaderMap[shaderType], &bufferHelper);
}
}
@ -1126,7 +1126,7 @@ angle::Result ProgramExecutableVk::updateAtomicCounterBuffersDescriptorSet(
// We set SHADER_READ_BIT to be conservative.
commandBufferHelper->bufferWrite(
resourceUseList, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
contextVk, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
kPipelineStageShaderMap[shaderType], vk::AliasingMode::Allowed, &bufferHelper);
writtenBindings.set(binding);
@ -1136,7 +1136,7 @@ angle::Result ProgramExecutableVk::updateAtomicCounterBuffersDescriptorSet(
// Bind the empty buffer to every array slot that's unused.
vk::BufferHelper &emptyBuffer = contextVk->getEmptyBuffer();
emptyBuffer.retain(&contextVk->getResourceUseList());
emptyBuffer.retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
size_t count = (~writtenBindings).count();
VkDescriptorBufferInfo *bufferInfos = contextVk->allocDescriptorBufferInfos(count);
VkWriteDescriptorSet *writeInfos = contextVk->allocWriteDescriptorSets(count);

Просмотреть файл

@ -293,10 +293,11 @@ angle::Result RenderTargetVk::flushStagedUpdates(ContextVk *contextVk,
void RenderTargetVk::retainImageViews(ContextVk *contextVk) const
{
mImageViews->retain(&contextVk->getResourceUseList());
mImageViews->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
if (mResolveImageViews)
{
mResolveImageViews->retain(&contextVk->getResourceUseList());
mResolveImageViews->retain(&contextVk->getResourceUseList(),
contextVk->getSharedResourceUsePool());
}
}

Просмотреть файл

@ -59,6 +59,33 @@ angle::Result Resource::waitForIdle(ContextVk *contextVk, const char *debugMessa
return angle::Result::Continue;
}
// SharedResourceUsePool implementation.
SharedResourceUsePool::SharedResourceUsePool() {}
SharedResourceUsePool::~SharedResourceUsePool() = default;
void SharedResourceUsePool::ensureCapacity()
{
// Allocate a SharedResourceUse block
constexpr size_t kSharedResourceUseBlockSize = 2048;
size_t newSize = (mSharedResourceUsePool.empty())
? kSharedResourceUseBlockSize
: mSharedResourceUsePool.back().capacity() * 2;
SharedResourceUseBlock sharedResourceUseBlock;
sharedResourceUseBlock.resize(newSize);
// Append it to the SharedResourceUse pool
mSharedResourceUsePool.emplace_back(std::move(sharedResourceUseBlock));
// Add the newly allocated SharedResourceUse to the free list
mSharedResourceUseFreeList.reserve(newSize);
SharedResourceUseBlock &newSharedResourceUseBlock = mSharedResourceUsePool.back();
for (SharedResourceUse &use : newSharedResourceUseBlock)
{
mSharedResourceUseFreeList.push_back(&use);
}
}
// SharedGarbage implementation.
SharedGarbage::SharedGarbage() = default;
@ -107,23 +134,25 @@ ResourceUseList::~ResourceUseList()
ASSERT(mResourceUses.empty());
}
void ResourceUseList::releaseResourceUses()
void ResourceUseList::releaseResourceUses(SharedResourceUsePool *sharedResourceUsePool)
{
for (SharedResourceUse &use : mResourceUses)
for (SharedResourceUse *use : mResourceUses)
{
use.release();
use->release();
sharedResourceUsePool->releaseSharedResouceUse(use);
}
mResourceUses.clear();
}
void ResourceUseList::releaseResourceUsesAndUpdateSerials(Serial serial)
void ResourceUseList::releaseResourceUsesAndUpdateSerials(
Serial serial,
SharedResourceUsePool *sharedResourceUsePool)
{
for (SharedResourceUse &use : mResourceUses)
for (SharedResourceUse *use : mResourceUses)
{
use.releaseAndUpdateSerial(serial);
use->releaseAndUpdateSerial(serial);
sharedResourceUsePool->releaseSharedResouceUse(use);
}
mResourceUses.clear();
}
} // namespace vk

Просмотреть файл

@ -113,6 +113,37 @@ class SharedResourceUse final : angle::NonCopyable
ResourceUse *mUse;
};
class SharedResourceUsePool
{
public:
SharedResourceUsePool();
~SharedResourceUsePool();
ANGLE_INLINE SharedResourceUse *acquireSharedResouceUse()
{
if (mSharedResourceUseFreeList.empty())
{
ensureCapacity();
}
SharedResourceUse *sharedResourceUse = mSharedResourceUseFreeList.back();
mSharedResourceUseFreeList.pop_back();
return sharedResourceUse;
}
ANGLE_INLINE void releaseSharedResouceUse(SharedResourceUse *sharedResourceUse)
{
mSharedResourceUseFreeList.push_back(sharedResourceUse);
}
private:
void ensureCapacity();
using SharedResourceUseBlock = std::vector<SharedResourceUse>;
std::vector<SharedResourceUseBlock> mSharedResourceUsePool;
std::vector<SharedResourceUse *> mSharedResourceUseFreeList;
};
class SharedGarbage
{
public:
@ -138,22 +169,22 @@ class ResourceUseList final : angle::NonCopyable
ResourceUseList();
virtual ~ResourceUseList();
void add(const SharedResourceUse &resourceUse);
ANGLE_INLINE void add(const SharedResourceUse &resourceUse,
SharedResourceUsePool *sharedResourceUsePool)
{
SharedResourceUse *newUse = sharedResourceUsePool->acquireSharedResouceUse();
newUse->set(resourceUse);
mResourceUses.emplace_back(newUse);
}
void releaseResourceUses();
void releaseResourceUsesAndUpdateSerials(Serial serial);
void releaseResourceUses(SharedResourceUsePool *sharedResourceUsePool);
void releaseResourceUsesAndUpdateSerials(Serial serial,
SharedResourceUsePool *sharedResourceUsePool);
private:
std::vector<SharedResourceUse> mResourceUses;
std::vector<SharedResourceUse *> mResourceUses;
};
ANGLE_INLINE void ResourceUseList::add(const SharedResourceUse &resourceUse)
{
SharedResourceUse newUse;
newUse.set(resourceUse);
mResourceUses.emplace_back(std::move(newUse));
}
// This is a helper class for back-end objects used in Vk command buffers. They keep a record
// of their use in ANGLE and VkQueues via SharedResourceUse.
class Resource : angle::NonCopyable
@ -183,7 +214,12 @@ class Resource : angle::NonCopyable
angle::Result waitForIdle(ContextVk *contextVk, const char *debugMessage);
// Adds the resource to a resource use list.
void retain(ResourceUseList *resourceUseList);
ANGLE_INLINE void retain(ResourceUseList *resourceUseList,
SharedResourceUsePool *sharedResourceUsePool)
{
// Store reference in resource list.
resourceUseList->add(mUse, sharedResourceUsePool);
}
protected:
Resource();
@ -192,12 +228,6 @@ class Resource : angle::NonCopyable
// Current resource lifetime.
SharedResourceUse mUse;
};
ANGLE_INLINE void Resource::retain(ResourceUseList *resourceUseList)
{
// Store reference in resource list.
resourceUseList->add(mUse);
}
} // namespace vk
} // namespace rx

Просмотреть файл

@ -54,7 +54,7 @@ angle::Result SyncHelper::initialize(ContextVk *contextVk)
vk::CommandBuffer &commandBuffer = contextVk->getOutsideRenderPassCommandBuffer();
commandBuffer.setEvent(mEvent.getHandle(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
retain(&contextVk->getResourceUseList());
retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
contextVk->onSyncHelperInitialize();
@ -111,7 +111,7 @@ angle::Result SyncHelper::serverWait(ContextVk *contextVk)
commandBuffer.waitEvents(1, mEvent.ptr(), VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, nullptr, 0, nullptr, 0,
nullptr);
retain(&contextVk->getResourceUseList());
retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
return angle::Result::Continue;
}
@ -187,7 +187,7 @@ angle::Result SyncHelperNativeFence::initializeWithFd(ContextVk *contextVk, int
// Flush first because the fence comes after current pending set of commands.
ANGLE_TRY(contextVk->flushImpl(nullptr));
retain(&contextVk->getResourceUseList());
retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
Serial serialOut;
VkSubmitInfo submitInfo = {};
@ -220,7 +220,7 @@ angle::Result SyncHelperNativeFence::initializeWithFd(ContextVk *contextVk, int
ANGLE_VK_TRY(contextVk, fence.get().importFd(device, importFenceFdInfo));
mFenceWithFd = fence.release();
retain(&contextVk->getResourceUseList());
retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
return angle::Result::Continue;
}

Просмотреть файл

@ -1640,8 +1640,9 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context)
{
ASSERT((mImageUsageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0);
mImage->retain(&contextVk->getResourceUseList());
getImageViews().retain(&contextVk->getResourceUseList());
mImage->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
getImageViews().retain(&contextVk->getResourceUseList(),
contextVk->getSharedResourceUsePool());
return generateMipmapsWithCompute(contextVk);
}
@ -1834,7 +1835,7 @@ angle::Result TextureVk::respecifyImageAttributesAndLevels(ContextVk *contextVk,
// recreated with the correct number of mip levels, base level, and max level.
releaseImage(contextVk);
mImage->retain(&contextVk->getResourceUseList());
mImage->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
return angle::Result::Continue;
}
@ -2236,7 +2237,7 @@ const vk::ImageView &TextureVk::getReadImageViewAndRecordUse(ContextVk *contextV
ASSERT(mImage->valid());
const vk::ImageViewHelper &imageViews = getImageViews();
imageViews.retain(&contextVk->getResourceUseList());
imageViews.retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
if (mState.isStencilMode() && imageViews.hasStencilReadImageView())
{
@ -2257,7 +2258,7 @@ const vk::ImageView &TextureVk::getFetchImageViewAndRecordUse(ContextVk *context
ASSERT(mImage->valid());
const vk::ImageViewHelper &imageViews = getImageViews();
imageViews.retain(&contextVk->getResourceUseList());
imageViews.retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
// We don't currently support fetch for depth/stencil cube map textures.
ASSERT(!imageViews.hasStencilReadImageView() || !imageViews.hasFetchImageView());
@ -2277,7 +2278,7 @@ const vk::ImageView &TextureVk::getCopyImageViewAndRecordUse(ContextVk *contextV
ASSERT(mImage->valid());
const vk::ImageViewHelper &imageViews = getImageViews();
imageViews.retain(&contextVk->getResourceUseList());
imageViews.retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
if (mState.getSRGBOverride() == gl::SrgbOverride::Enabled)
{

Просмотреть файл

@ -167,9 +167,10 @@ class TextureVk : public TextureImpl, public angle::ObserverInterface
return *mImage;
}
void retainImageViews(vk::ResourceUseList *resourceUseList)
ANGLE_INLINE void retainImageViews(ContextVk *contextVk)
{
getImageViews().retain(resourceUseList);
getImageViews().retain(&contextVk->getResourceUseList(),
contextVk->getSharedResourceUsePool());
}
void releaseOwnershipOfImage(const gl::Context *context);

Просмотреть файл

@ -1520,7 +1520,8 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
ANGLE_TRY(
blitBuffer.get().init(contextVk, blitBufferInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
blitBuffer.get().retain(&contextVk->getResourceUseList());
blitBuffer.get().retain(&contextVk->getResourceUseList(),
contextVk->getSharedResourceUsePool());
BlitResolveStencilNoExportShaderParams shaderParams;
// Note: adjustments made for pre-rotatation in FramebufferVk::blit() affect these

Просмотреть файл

@ -648,12 +648,12 @@ bool CommandBufferHelper::usesBufferForWrite(const BufferHelper &buffer) const
return access == BufferAccess::Write;
}
void CommandBufferHelper::bufferRead(ResourceUseList *resourceUseList,
void CommandBufferHelper::bufferRead(ContextVk *contextVk,
VkAccessFlags readAccessType,
PipelineStage readStage,
BufferHelper *buffer)
{
buffer->retain(resourceUseList);
buffer->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
VkPipelineStageFlagBits stageBits = kPipelineStageFlagBitMap[readStage];
if (buffer->recordReadBarrier(readAccessType, stageBits, &mPipelineBarriers[readStage]))
{
@ -667,13 +667,13 @@ void CommandBufferHelper::bufferRead(ResourceUseList *resourceUseList,
}
}
void CommandBufferHelper::bufferWrite(ResourceUseList *resourceUseList,
void CommandBufferHelper::bufferWrite(ContextVk *contextVk,
VkAccessFlags writeAccessType,
PipelineStage writeStage,
AliasingMode aliasingMode,
BufferHelper *buffer)
{
buffer->retain(resourceUseList);
buffer->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
VkPipelineStageFlagBits stageBits = kPipelineStageFlagBitMap[writeStage];
if (buffer->recordWriteBarrier(writeAccessType, stageBits, &mPipelineBarriers[writeStage]))
{
@ -691,12 +691,12 @@ void CommandBufferHelper::bufferWrite(ResourceUseList *resourceUseList,
}
}
void CommandBufferHelper::imageRead(ResourceUseList *resourceUseList,
void CommandBufferHelper::imageRead(ContextVk *contextVk,
VkImageAspectFlags aspectFlags,
ImageLayout imageLayout,
ImageHelper *image)
{
image->retain(resourceUseList);
image->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
if (image->isReadBarrierNecessary(imageLayout))
{
@ -720,13 +720,13 @@ void CommandBufferHelper::imageRead(ResourceUseList *resourceUseList,
}
}
void CommandBufferHelper::imageWrite(ResourceUseList *resourceUseList,
void CommandBufferHelper::imageWrite(ContextVk *contextVk,
VkImageAspectFlags aspectFlags,
ImageLayout imageLayout,
AliasingMode aliasingMode,
ImageHelper *image)
{
image->retain(resourceUseList);
image->retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
image->onWrite();
// Write always requires a barrier
PipelineStage barrierIndex = kImageMemoryBarrierData[imageLayout].barrierIndex;
@ -1486,10 +1486,10 @@ void DynamicBuffer::release(RendererVk *renderer)
void DynamicBuffer::releaseInFlightBuffersToResourceUseList(ContextVk *contextVk)
{
ResourceUseList *resourceUseList = &contextVk->getResourceUseList();
for (BufferHelper *bufferHelper : mInFlightBuffers)
{
bufferHelper->retain(resourceUseList);
bufferHelper->retain(&contextVk->getResourceUseList(),
contextVk->getSharedResourceUsePool());
// If the dynamic buffer was resized we cannot reuse the retained buffer.
if (bufferHelper->getSize() < mSize)
@ -5086,7 +5086,8 @@ 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().retain(&contextVk->getResourceUseList());
resolvedImage.get().retain(&contextVk->getResourceUseList(),
contextVk->getSharedResourceUsePool());
}
VkImageAspectFlags layoutChangeAspectFlags = src->getAspectFlags();
@ -5666,7 +5667,7 @@ angle::Result ImageViewHelper::getLevelDrawImageView(ContextVk *contextVk,
{
ASSERT(mImageViewSerial.valid());
retain(&contextVk->getResourceUseList());
retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
ImageView *imageView = GetLevelImageView(&mLevelDrawImageViews, levelVk, image.getLevelCount());
@ -5692,7 +5693,7 @@ angle::Result ImageViewHelper::getLevelLayerDrawImageView(ContextVk *contextVk,
ASSERT(mImageViewSerial.valid());
ASSERT(!image.getFormat().actualImageFormat().isBlock);
retain(&contextVk->getResourceUseList());
retain(&contextVk->getResourceUseList(), contextVk->getSharedResourceUsePool());
uint32_t layerCount = GetImageLayerCountForView(image);

Просмотреть файл

@ -921,21 +921,21 @@ class CommandBufferHelper : angle::NonCopyable
// General Functions (non-renderPass specific)
void initialize(bool isRenderPassCommandBuffer);
void bufferRead(ResourceUseList *resourceUseList,
void bufferRead(ContextVk *contextVk,
VkAccessFlags readAccessType,
PipelineStage readStage,
BufferHelper *buffer);
void bufferWrite(ResourceUseList *resourceUseList,
void bufferWrite(ContextVk *contextVk,
VkAccessFlags writeAccessType,
PipelineStage writeStage,
AliasingMode aliasingMode,
BufferHelper *buffer);
void imageRead(ResourceUseList *resourceUseList,
void imageRead(ContextVk *contextVk,
VkImageAspectFlags aspectFlags,
ImageLayout imageLayout,
ImageHelper *image);
void imageWrite(ResourceUseList *resourceUseList,
void imageWrite(ContextVk *contextVk,
VkImageAspectFlags aspectFlags,
ImageLayout imageLayout,
AliasingMode aliasingMode,
@ -1848,7 +1848,11 @@ class ImageViewHelper : angle::NonCopyable
}
// Store reference to usage in graph.
void retain(ResourceUseList *resourceUseList) const { resourceUseList->add(mUse); }
ANGLE_INLINE void retain(ResourceUseList *resourceUseList,
SharedResourceUsePool *sharedResourceUsePool) const
{
resourceUseList->add(mUse, sharedResourceUsePool);
}
// For applications that frequently switch a texture's max level, and make no other changes to
// the texture, change the currently-used max level, and potentially create new "read views"