Commit a741abb9 by Jamie Madill Committed by Commit Bot

Vulkan: Rename CommandGraphResource to Resource.

Also renames the h and cpp files to ResourceVk (to keep distinct from other resource.h/cpp files) and renames 'onResourceAccess' to 'retain'. Cleans up a few remaining mentions of the command graph in comments. Bug: angleproject:4029 Change-Id: Ifc8e880c8cea3fc48a4aec4730191c88aa35a076 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2065920 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 468dfed3
...@@ -20,8 +20,6 @@ declare_args() { ...@@ -20,8 +20,6 @@ declare_args() {
_vulkan_backend_sources = [ _vulkan_backend_sources = [
"BufferVk.cpp", "BufferVk.cpp",
"BufferVk.h", "BufferVk.h",
"CommandGraph.cpp",
"CommandGraph.h",
"CompilerVk.cpp", "CompilerVk.cpp",
"CompilerVk.h", "CompilerVk.h",
"ContextVk.cpp", "ContextVk.cpp",
...@@ -57,6 +55,8 @@ _vulkan_backend_sources = [ ...@@ -57,6 +55,8 @@ _vulkan_backend_sources = [
"RenderbufferVk.h", "RenderbufferVk.h",
"RendererVk.cpp", "RendererVk.cpp",
"RendererVk.h", "RendererVk.h",
"ResourceVk.cpp",
"ResourceVk.h",
"SamplerVk.cpp", "SamplerVk.cpp",
"SamplerVk.h", "SamplerVk.h",
"SecondaryCommandBuffer.cpp", "SecondaryCommandBuffer.cpp",
......
...@@ -258,13 +258,13 @@ angle::Result BufferVk::mapRangeImpl(ContextVk *contextVk, ...@@ -258,13 +258,13 @@ angle::Result BufferVk::mapRangeImpl(ContextVk *contextVk,
if ((access & GL_MAP_UNSYNCHRONIZED_BIT) == 0) if ((access & GL_MAP_UNSYNCHRONIZED_BIT) == 0)
{ {
// If there are pending commands for the buffer, flush them. // If there are pending commands for the buffer, flush them.
if (mBuffer.hasRecordedCommands()) if (mBuffer.usedInRecordedCommands())
{ {
ANGLE_TRY(contextVk->flushImpl(nullptr)); ANGLE_TRY(contextVk->flushImpl(nullptr));
} }
// Make sure the driver is done with the buffer. // Make sure the driver is done with the buffer.
if (mBuffer.hasRunningCommands(contextVk->getLastCompletedQueueSerial())) if (mBuffer.usedInRunningCommands(contextVk->getLastCompletedQueueSerial()))
{ {
ANGLE_TRY(mBuffer.finishRunningCommands(contextVk)); ANGLE_TRY(mBuffer.finishRunningCommands(contextVk));
} }
...@@ -366,7 +366,7 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk, ...@@ -366,7 +366,7 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
VkBufferCopy copyRegion = {stagingBufferOffset, offset, size}; VkBufferCopy copyRegion = {stagingBufferOffset, offset, size};
ANGLE_TRY(mBuffer.copyFromBuffer(contextVk, mStagingBuffer.getCurrentBuffer()->getBuffer(), ANGLE_TRY(mBuffer.copyFromBuffer(contextVk, mStagingBuffer.getCurrentBuffer()->getBuffer(),
VK_ACCESS_HOST_WRITE_BIT, copyRegion)); VK_ACCESS_HOST_WRITE_BIT, copyRegion));
mStagingBuffer.getCurrentBuffer()->onResourceAccess(&contextVk->getResourceUseList()); mStagingBuffer.getCurrentBuffer()->retain(&contextVk->getResourceUseList());
} }
else else
{ {
......
...@@ -513,6 +513,7 @@ egl::ContextPriority GetContextPriority(const gl::State &state) ...@@ -513,6 +513,7 @@ egl::ContextPriority GetContextPriority(const gl::State &state)
ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk *renderer) ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk *renderer)
: ContextImpl(state, errorSet), : ContextImpl(state, errorSet),
vk::Context(renderer), vk::Context(renderer),
mRenderPassCommandBuffer(nullptr),
mCurrentGraphicsPipeline(nullptr), mCurrentGraphicsPipeline(nullptr),
mCurrentComputePipeline(nullptr), mCurrentComputePipeline(nullptr),
mCurrentDrawMode(gl::PrimitiveMode::InvalidEnum), mCurrentDrawMode(gl::PrimitiveMode::InvalidEnum),
...@@ -1116,7 +1117,7 @@ angle::Result ContextVk::handleDirtyComputePipeline(const gl::Context *context, ...@@ -1116,7 +1117,7 @@ angle::Result ContextVk::handleDirtyComputePipeline(const gl::Context *context,
ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl( ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl(
const gl::Context *context, const gl::Context *context,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
CommandBufferHelper *commandBufferHelper) CommandBufferHelper *commandBufferHelper)
{ {
const gl::ActiveTextureMask &activeTextures = mProgram->getState().getActiveSamplersMask(); const gl::ActiveTextureMask &activeTextures = mProgram->getState().getActiveSamplersMask();
...@@ -1141,15 +1142,15 @@ ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl( ...@@ -1141,15 +1142,15 @@ ANGLE_INLINE angle::Result ContextVk::handleDirtyTexturesImpl(
commandBufferHelper->imageRead(&mResourceUseList, image.getAspectFlags(), textureLayout, commandBufferHelper->imageRead(&mResourceUseList, image.getAspectFlags(), textureLayout,
&image); &image);
textureVk->onImageViewUse(&mResourceUseList); textureVk->retainImageViews(&mResourceUseList);
if (unit.sampler) if (unit.sampler)
{ {
unit.sampler->onSamplerAccess(&mResourceUseList); unit.sampler->retain(&mResourceUseList);
} }
else else
{ {
textureVk->onSamplerUse(&mResourceUseList); textureVk->retainSampler(&mResourceUseList);
} }
} }
...@@ -1221,7 +1222,7 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte ...@@ -1221,7 +1222,7 @@ angle::Result ContextVk::handleDirtyGraphicsIndexBuffer(const gl::Context *conte
ANGLE_INLINE angle::Result ContextVk::handleDirtyShaderResourcesImpl( ANGLE_INLINE angle::Result ContextVk::handleDirtyShaderResourcesImpl(
const gl::Context *context, const gl::Context *context,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
CommandBufferHelper *commandBufferHelper) CommandBufferHelper *commandBufferHelper)
{ {
if (mProgram->hasImages()) if (mProgram->hasImages())
...@@ -3400,7 +3401,7 @@ angle::Result ContextVk::updateActiveTextures(const gl::Context *context) ...@@ -3400,7 +3401,7 @@ angle::Result ContextVk::updateActiveTextures(const gl::Context *context)
} }
angle::Result ContextVk::updateActiveImages(const gl::Context *context, angle::Result ContextVk::updateActiveImages(const gl::Context *context,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
CommandBufferHelper *commandBufferHelper) CommandBufferHelper *commandBufferHelper)
{ {
const gl::State &glState = mState; const gl::State &glState = mState;
...@@ -3838,7 +3839,7 @@ angle::Result ContextVk::onImageRead(VkImageAspectFlags aspectFlags, ...@@ -3838,7 +3839,7 @@ angle::Result ContextVk::onImageRead(VkImageAspectFlags aspectFlags,
ANGLE_TRY(getOutsideRenderPassCommandBuffer(&commandBuffer)); ANGLE_TRY(getOutsideRenderPassCommandBuffer(&commandBuffer));
image->changeLayout(aspectFlags, imageLayout, commandBuffer); image->changeLayout(aspectFlags, imageLayout, commandBuffer);
} }
image->onResourceAccess(&mResourceUseList); image->retain(&mResourceUseList);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -3855,7 +3856,7 @@ angle::Result ContextVk::onImageWrite(VkImageAspectFlags aspectFlags, ...@@ -3855,7 +3856,7 @@ angle::Result ContextVk::onImageWrite(VkImageAspectFlags aspectFlags,
ANGLE_TRY(getOutsideRenderPassCommandBuffer(&commandBuffer)); ANGLE_TRY(getOutsideRenderPassCommandBuffer(&commandBuffer));
image->changeLayout(aspectFlags, imageLayout, commandBuffer); image->changeLayout(aspectFlags, imageLayout, commandBuffer);
image->onResourceAccess(&mResourceUseList); image->retain(&mResourceUseList);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -3947,7 +3948,7 @@ void CommandBufferHelper::bufferRead(vk::ResourceUseList *resourceUseList, ...@@ -3947,7 +3948,7 @@ void CommandBufferHelper::bufferRead(vk::ResourceUseList *resourceUseList,
VkAccessFlags readAccessType, VkAccessFlags readAccessType,
vk::BufferHelper *buffer) vk::BufferHelper *buffer)
{ {
buffer->onResourceAccess(resourceUseList); buffer->retain(resourceUseList);
buffer->updateReadBarrier(readAccessType, &mGlobalMemoryBarrierSrcAccess, buffer->updateReadBarrier(readAccessType, &mGlobalMemoryBarrierSrcAccess,
&mGlobalMemoryBarrierDstAccess); &mGlobalMemoryBarrierDstAccess);
mGlobalMemoryBarrierStages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; mGlobalMemoryBarrierStages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
...@@ -3957,7 +3958,7 @@ void CommandBufferHelper::bufferWrite(vk::ResourceUseList *resourceUseList, ...@@ -3957,7 +3958,7 @@ void CommandBufferHelper::bufferWrite(vk::ResourceUseList *resourceUseList,
VkAccessFlags writeAccessType, VkAccessFlags writeAccessType,
vk::BufferHelper *buffer) vk::BufferHelper *buffer)
{ {
buffer->onResourceAccess(resourceUseList); buffer->retain(resourceUseList);
buffer->updateWriteBarrier(writeAccessType, &mGlobalMemoryBarrierSrcAccess, buffer->updateWriteBarrier(writeAccessType, &mGlobalMemoryBarrierSrcAccess,
&mGlobalMemoryBarrierDstAccess); &mGlobalMemoryBarrierDstAccess);
mGlobalMemoryBarrierStages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; mGlobalMemoryBarrierStages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
...@@ -3978,7 +3979,7 @@ void CommandBufferHelper::imageRead(vk::ResourceUseList *resourceUseList, ...@@ -3978,7 +3979,7 @@ void CommandBufferHelper::imageRead(vk::ResourceUseList *resourceUseList,
vk::ImageLayout imageLayout, vk::ImageLayout imageLayout,
vk::ImageHelper *image) vk::ImageHelper *image)
{ {
image->onResourceAccess(resourceUseList); image->retain(resourceUseList);
if (image->isLayoutChangeNecessary(imageLayout)) if (image->isLayoutChangeNecessary(imageLayout))
{ {
image->changeLayout(aspectFlags, imageLayout, this); image->changeLayout(aspectFlags, imageLayout, this);
...@@ -3990,7 +3991,7 @@ void CommandBufferHelper::imageWrite(vk::ResourceUseList *resourceUseList, ...@@ -3990,7 +3991,7 @@ void CommandBufferHelper::imageWrite(vk::ResourceUseList *resourceUseList,
vk::ImageLayout imageLayout, vk::ImageLayout imageLayout,
vk::ImageHelper *image) vk::ImageHelper *image)
{ {
image->onResourceAccess(resourceUseList); image->retain(resourceUseList);
image->changeLayout(aspectFlags, imageLayout, this); image->changeLayout(aspectFlags, imageLayout, this);
} }
......
...@@ -232,7 +232,7 @@ class RenderPassCommandBuffer final : public CommandBufferHelper ...@@ -232,7 +232,7 @@ class RenderPassCommandBuffer final : public CommandBufferHelper
bool mRebindTransformFeedbackBuffers; bool mRebindTransformFeedbackBuffers;
}; };
class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassOwner class ContextVk : public ContextImpl, public vk::Context
{ {
public: public:
ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk *renderer); ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk *renderer);
...@@ -778,7 +778,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO ...@@ -778,7 +778,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
angle::Result updateActiveTextures(const gl::Context *context); angle::Result updateActiveTextures(const gl::Context *context);
angle::Result updateActiveImages(const gl::Context *context, angle::Result updateActiveImages(const gl::Context *context,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
CommandBufferHelper *commandBufferHelper); CommandBufferHelper *commandBufferHelper);
angle::Result updateDefaultAttribute(size_t attribIndex); angle::Result updateDefaultAttribute(size_t attribIndex);
...@@ -839,11 +839,11 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO ...@@ -839,11 +839,11 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
// Common parts of the common dirty bit handlers. // Common parts of the common dirty bit handlers.
angle::Result handleDirtyTexturesImpl(const gl::Context *context, angle::Result handleDirtyTexturesImpl(const gl::Context *context,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
CommandBufferHelper *commandBufferHelper); CommandBufferHelper *commandBufferHelper);
angle::Result handleDirtyShaderResourcesImpl(const gl::Context *context, angle::Result handleDirtyShaderResourcesImpl(const gl::Context *context,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
CommandBufferHelper *commandBufferHelper); CommandBufferHelper *commandBufferHelper);
void handleDirtyDriverUniformsBindingImpl(vk::CommandBuffer *commandBuffer, void handleDirtyDriverUniformsBindingImpl(vk::CommandBuffer *commandBuffer,
VkPipelineBindPoint bindPoint, VkPipelineBindPoint bindPoint,
...@@ -883,9 +883,13 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO ...@@ -883,9 +883,13 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
bool hasRecordedCommands(); bool hasRecordedCommands();
void dumpCommandStreamDiagnostics(); void dumpCommandStreamDiagnostics();
ANGLE_INLINE void onRenderPassFinished() { mRenderPassCommandBuffer = nullptr; }
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers;
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers;
vk::CommandBuffer *mRenderPassCommandBuffer;
vk::PipelineHelper *mCurrentGraphicsPipeline; vk::PipelineHelper *mCurrentGraphicsPipeline;
vk::PipelineAndSerial *mCurrentComputePipeline; vk::PipelineAndSerial *mCurrentComputePipeline;
gl::PrimitiveMode mCurrentDrawMode; gl::PrimitiveMode mCurrentDrawMode;
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/renderer_utils.h" #include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h" #include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/RenderTargetVk.h" #include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h" #include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/SurfaceVk.h" #include "libANGLE/renderer/vulkan/SurfaceVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/trace.h" #include "libANGLE/trace.h"
...@@ -156,7 +156,7 @@ angle::Result FramebufferVk::invalidate(const gl::Context *context, ...@@ -156,7 +156,7 @@ angle::Result FramebufferVk::invalidate(const gl::Context *context,
if (mFramebuffer != nullptr) if (mFramebuffer != nullptr)
{ {
ASSERT(mFramebuffer->valid()); ASSERT(mFramebuffer->valid());
mFramebuffer->onResourceAccess(&contextVk->getResourceUseList()); mFramebuffer->retain(&contextVk->getResourceUseList());
if (contextVk->hasStartedRenderPass()) if (contextVk->hasStartedRenderPass())
{ {
...@@ -179,7 +179,7 @@ angle::Result FramebufferVk::invalidateSub(const gl::Context *context, ...@@ -179,7 +179,7 @@ angle::Result FramebufferVk::invalidateSub(const gl::Context *context,
if (mFramebuffer != nullptr) if (mFramebuffer != nullptr)
{ {
ASSERT(mFramebuffer->valid()); ASSERT(mFramebuffer->valid());
mFramebuffer->onResourceAccess(&contextVk->getResourceUseList()); mFramebuffer->retain(&contextVk->getResourceUseList());
if (contextVk->hasStartedRenderPass() && if (contextVk->hasStartedRenderPass() &&
area.encloses(contextVk->getStartedRenderPassCommands().getRenderArea())) area.encloses(contextVk->getStartedRenderPassCommands().getRenderArea()))
...@@ -755,7 +755,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context, ...@@ -755,7 +755,7 @@ angle::Result FramebufferVk::blit(const gl::Context *context,
{ {
const vk::ImageView *readImageView = nullptr; const vk::ImageView *readImageView = nullptr;
ANGLE_TRY(readRenderTarget->getImageView(contextVk, &readImageView)); ANGLE_TRY(readRenderTarget->getImageView(contextVk, &readImageView));
readRenderTarget->onImageViewAccess(contextVk); readRenderTarget->retainImageViews(contextVk);
ANGLE_TRY(utilsVk.colorBlitResolve(contextVk, this, &readRenderTarget->getImage(), ANGLE_TRY(utilsVk.colorBlitResolve(contextVk, this, &readRenderTarget->getImage(),
readImageView, params)); readImageView, params));
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/RenderTargetCache.h" #include "libANGLE/renderer/RenderTargetCache.h"
#include "libANGLE/renderer/vulkan/BufferVk.h" #include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/UtilsVk.h" #include "libANGLE/renderer/vulkan/UtilsVk.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h" #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
......
...@@ -1293,7 +1293,7 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk) ...@@ -1293,7 +1293,7 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk)
} }
else else
{ {
mEmptyBuffer.onResourceAccess(&contextVk->getResourceUseList()); mEmptyBuffer.retain(&contextVk->getResourceUseList());
bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle(); bufferInfo.buffer = mEmptyBuffer.getBuffer().getHandle();
mDescriptorBuffersCache.emplace_back(&mEmptyBuffer); mDescriptorBuffersCache.emplace_back(&mEmptyBuffer);
} }
...@@ -1326,7 +1326,7 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk) ...@@ -1326,7 +1326,7 @@ void ProgramVk::updateDefaultUniformsDescriptorSet(ContextVk *contextVk)
void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk, void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk,
vk::ResourceUseList *resourceUseList, vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper, CommandBufferHelper *commandBufferHelper,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
const std::vector<gl::InterfaceBlock> &blocks, const std::vector<gl::InterfaceBlock> &blocks,
VkDescriptorType descriptorType) VkDescriptorType descriptorType)
{ {
...@@ -1412,7 +1412,7 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk, ...@@ -1412,7 +1412,7 @@ void ProgramVk::updateBuffersDescriptorSet(ContextVk *contextVk,
void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
vk::ResourceUseList *resourceUseList, vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper, CommandBufferHelper *commandBufferHelper,
vk::CommandGraphResource *recorder) vk::Resource *recorder)
{ {
const gl::State &glState = contextVk->getState(); const gl::State &glState = contextVk->getState();
const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers = const std::vector<gl::AtomicCounterBuffer> &atomicCounterBuffers =
...@@ -1466,7 +1466,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, ...@@ -1466,7 +1466,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.onResourceAccess(&contextVk->getResourceUseList()); mEmptyBuffer.retain(&contextVk->getResourceUseList());
for (size_t binding : ~writtenBindings) for (size_t binding : ~writtenBindings)
{ {
VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding]; VkDescriptorBufferInfo &bufferInfo = descriptorBufferInfo[binding];
...@@ -1494,8 +1494,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, ...@@ -1494,8 +1494,7 @@ void ProgramVk::updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
writeDescriptorInfo.data(), 0, nullptr); writeDescriptorInfo.data(), 0, nullptr);
} }
angle::Result ProgramVk::updateImagesDescriptorSet(ContextVk *contextVk, angle::Result ProgramVk::updateImagesDescriptorSet(ContextVk *contextVk, vk::Resource *recorder)
vk::CommandGraphResource *recorder)
{ {
const gl::State &glState = contextVk->getState(); const gl::State &glState = contextVk->getState();
const std::vector<gl::ImageBinding> &imageBindings = mState.getImageBindings(); const std::vector<gl::ImageBinding> &imageBindings = mState.getImageBindings();
...@@ -1573,7 +1572,7 @@ angle::Result ProgramVk::updateShaderResourcesDescriptorSet( ...@@ -1573,7 +1572,7 @@ angle::Result ProgramVk::updateShaderResourcesDescriptorSet(
ContextVk *contextVk, ContextVk *contextVk,
vk::ResourceUseList *resourceUseList, vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper, CommandBufferHelper *commandBufferHelper,
vk::CommandGraphResource *recorder) vk::Resource *recorder)
{ {
ANGLE_TRY(allocateDescriptorSet(contextVk, kShaderResourceDescriptorSetIndex)); ANGLE_TRY(allocateDescriptorSet(contextVk, kShaderResourceDescriptorSetIndex));
...@@ -1829,7 +1828,7 @@ angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk, ...@@ -1829,7 +1828,7 @@ angle::Result ProgramVk::updateDescriptorSets(ContextVk *contextVk,
for (vk::BufferHelper *buffer : mDescriptorBuffersCache) for (vk::BufferHelper *buffer : mDescriptorBuffersCache)
{ {
buffer->onResourceAccess(&contextVk->getResourceUseList()); buffer->retain(&contextVk->getResourceUseList());
} }
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -111,7 +111,7 @@ class ProgramVk : public ProgramImpl ...@@ -111,7 +111,7 @@ class ProgramVk : public ProgramImpl
angle::Result updateShaderResourcesDescriptorSet(ContextVk *contextVk, angle::Result updateShaderResourcesDescriptorSet(ContextVk *contextVk,
vk::ResourceUseList *resourceUseList, vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper, CommandBufferHelper *commandBufferHelper,
vk::CommandGraphResource *recorder); vk::Resource *recorder);
angle::Result updateTransformFeedbackDescriptorSet(ContextVk *contextVk, angle::Result updateTransformFeedbackDescriptorSet(ContextVk *contextVk,
vk::FramebufferHelper *framebuffer); vk::FramebufferHelper *framebuffer);
...@@ -192,15 +192,14 @@ class ProgramVk : public ProgramImpl ...@@ -192,15 +192,14 @@ class ProgramVk : public ProgramImpl
void updateBuffersDescriptorSet(ContextVk *contextVk, void updateBuffersDescriptorSet(ContextVk *contextVk,
vk::ResourceUseList *resourceUseList, vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper, CommandBufferHelper *commandBufferHelper,
vk::CommandGraphResource *recorder, vk::Resource *recorder,
const std::vector<gl::InterfaceBlock> &blocks, const std::vector<gl::InterfaceBlock> &blocks,
VkDescriptorType descriptorType); VkDescriptorType descriptorType);
void updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk, void updateAtomicCounterBuffersDescriptorSet(ContextVk *contextVk,
vk::ResourceUseList *resourceUseList, vk::ResourceUseList *resourceUseList,
CommandBufferHelper *commandBufferHelper, CommandBufferHelper *commandBufferHelper,
vk::CommandGraphResource *recorder); vk::Resource *recorder);
angle::Result updateImagesDescriptorSet(ContextVk *contextVk, angle::Result updateImagesDescriptorSet(ContextVk *contextVk, vk::Resource *recorder);
vk::CommandGraphResource *recorder);
template <class T> template <class T>
void getUniformImpl(GLint location, T *v, GLenum entryPointType) const; void getUniformImpl(GLint location, T *v, GLenum entryPointType) const;
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "libANGLE/renderer/vulkan/RenderTargetVk.h" #include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/TextureVk.h" #include "libANGLE/renderer/vulkan/TextureVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h" #include "libANGLE/renderer/vulkan/vk_helpers.h"
...@@ -74,7 +74,7 @@ angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk) ...@@ -74,7 +74,7 @@ angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk)
contextVk->onRenderPassImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment, contextVk->onRenderPassImageWrite(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
mImage); mImage);
onImageViewAccess(contextVk); retainImageViews(contextVk);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -87,7 +87,7 @@ angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk) ...@@ -87,7 +87,7 @@ angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk)
VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format); VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format);
contextVk->onRenderPassImageWrite(aspectFlags, vk::ImageLayout::DepthStencilAttachment, mImage); contextVk->onRenderPassImageWrite(aspectFlags, vk::ImageLayout::DepthStencilAttachment, mImage);
onImageViewAccess(contextVk); retainImageViews(contextVk);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -134,7 +134,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageViewH ...@@ -134,7 +134,7 @@ void RenderTargetVk::updateSwapchainImage(vk::ImageHelper *image, vk::ImageViewH
vk::ImageHelper *RenderTargetVk::getImageForWrite(ContextVk *contextVk) const vk::ImageHelper *RenderTargetVk::getImageForWrite(ContextVk *contextVk) const
{ {
ASSERT(mImage && mImage->valid()); ASSERT(mImage && mImage->valid());
onImageViewAccess(contextVk); retainImageViews(contextVk);
return mImage; return mImage;
} }
...@@ -150,8 +150,8 @@ angle::Result RenderTargetVk::flushStagedUpdates(ContextVk *contextVk) ...@@ -150,8 +150,8 @@ angle::Result RenderTargetVk::flushStagedUpdates(ContextVk *contextVk)
mLayerIndex + 1, commandBuffer); mLayerIndex + 1, commandBuffer);
} }
void RenderTargetVk::onImageViewAccess(ContextVk *contextVk) const void RenderTargetVk::retainImageViews(ContextVk *contextVk) const
{ {
mImageViews->onResourceAccess(&contextVk->getResourceUseList()); mImageViews->retain(&contextVk->getResourceUseList());
} }
} // namespace rx } // namespace rx
...@@ -24,7 +24,7 @@ struct Format; ...@@ -24,7 +24,7 @@ struct Format;
class FramebufferHelper; class FramebufferHelper;
class ImageHelper; class ImageHelper;
class ImageView; class ImageView;
class CommandGraphResource; class Resource;
class RenderPassDesc; class RenderPassDesc;
} // namespace vk } // namespace vk
...@@ -75,7 +75,7 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget ...@@ -75,7 +75,7 @@ class RenderTargetVk final : public FramebufferAttachmentRenderTarget
angle::Result flushStagedUpdates(ContextVk *contextVk); angle::Result flushStagedUpdates(ContextVk *contextVk);
void onImageViewAccess(ContextVk *contextVk) const; void retainImageViews(ContextVk *contextVk) const;
private: private:
vk::ImageHelper *mImage; vk::ImageHelper *mImage;
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/renderer/driver_utils.h" #include "libANGLE/renderer/driver_utils.h"
#include "libANGLE/renderer/glslang_wrapper_utils.h" #include "libANGLE/renderer/glslang_wrapper_utils.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/CompilerVk.h" #include "libANGLE/renderer/vulkan/CompilerVk.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h" #include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h" #include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/ProgramVk.h" #include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/VertexArrayVk.h" #include "libANGLE/renderer/vulkan/VertexArrayVk.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h" #include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/BlobCache.h" #include "libANGLE/BlobCache.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/QueryVk.h" #include "libANGLE/renderer/vulkan/QueryVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/UtilsVk.h" #include "libANGLE/renderer/vulkan/UtilsVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h" #include "libANGLE/renderer/vulkan/vk_helpers.h"
......
...@@ -3,39 +3,30 @@ ...@@ -3,39 +3,30 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// CommandGraph: // Resource:
// Deferred work constructed by GL calls, that will later be flushed to Vulkan. // Resource lifetime tracking in the Vulkan back-end.
// //
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/ResourceVk.h"
#include <iostream>
#include "libANGLE/Overlay.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
#include "libANGLE/trace.h"
namespace rx namespace rx
{ {
namespace vk namespace vk
{ {
// CommandGraphResource implementation. // Resource implementation.
CommandGraphResource::CommandGraphResource() Resource::Resource()
{ {
mUse.init(); mUse.init();
} }
CommandGraphResource::~CommandGraphResource() Resource::~Resource()
{ {
mUse.release(); mUse.release();
} }
angle::Result CommandGraphResource::finishRunningCommands(ContextVk *contextVk) angle::Result Resource::finishRunningCommands(ContextVk *contextVk)
{ {
return contextVk->finishToSerial(mUse.getSerial()); return contextVk->finishToSerial(mUse.getSerial());
} }
......
...@@ -3,47 +3,31 @@ ...@@ -3,47 +3,31 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// CommandGraph: // ResourceVk:
// Deferred work constructed by GL calls, that will later be flushed to Vulkan. // Resource lifetime tracking in the Vulkan back-end.
// //
#ifndef LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_ #ifndef LIBANGLE_RENDERER_VULKAN_RESOURCEVK_H_
#define LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_ #define LIBANGLE_RENDERER_VULKAN_RESOURCEVK_H_
#include "libANGLE/renderer/vulkan/SecondaryCommandBuffer.h" #include "libANGLE/renderer/vulkan/vk_utils.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
namespace rx namespace rx
{ {
namespace vk namespace vk
{ {
class CommandGraph; // Tracks how a resource is used by ANGLE and by a VkQueue. The reference count indicates the number
// of times a resource is retained by ANGLE. The serial indicates the most recent use of a resource
// Receives notifications when a render pass command buffer is no longer able to record. Can be // in the VkQueue. The reference count and serial together can determine if a resource is currently
// used with inheritance. Faster than using an interface class since it has inlined methods. Could // in use.
// be used with composition by adding a getCommandBuffer method.
class RenderPassOwner
{
public:
RenderPassOwner() = default;
virtual ~RenderPassOwner() {}
ANGLE_INLINE void onRenderPassFinished() { mRenderPassCommandBuffer = nullptr; }
protected:
CommandBuffer *mRenderPassCommandBuffer = nullptr;
};
// Tracks how a resource is used in a command graph and in a VkQueue. The reference count indicates
// the number of times a resource is used in the graph. The serial indicates the last current use
// of a resource in the VkQueue. The reference count and serial together can determine if a
// resource is in use.
struct ResourceUse struct ResourceUse
{ {
ResourceUse() = default; ResourceUse() = default;
// The number of times a resource is retained by ANGLE.
uint32_t counter = 0; uint32_t counter = 0;
// The most recent time of use in a VkQueue.
Serial serial; Serial serial;
}; };
...@@ -101,14 +85,14 @@ class SharedResourceUse final : angle::NonCopyable ...@@ -101,14 +85,14 @@ class SharedResourceUse final : angle::NonCopyable
} }
// The base counter value for a live resource is "1". Any value greater than one indicates // The base counter value for a live resource is "1". Any value greater than one indicates
// the resource is in use by a vk::CommandGraph. // the resource is in use by a command buffer.
ANGLE_INLINE bool hasRecordedCommands() const ANGLE_INLINE bool usedInRecordedCommands() const
{ {
ASSERT(valid()); ASSERT(valid());
return mUse->counter > 1; return mUse->counter > 1;
} }
ANGLE_INLINE bool hasRunningCommands(Serial lastCompletedSerial) const ANGLE_INLINE bool usedInRunningCommands(Serial lastCompletedSerial) const
{ {
ASSERT(valid()); ASSERT(valid());
return mUse->serial > lastCompletedSerial; return mUse->serial > lastCompletedSerial;
...@@ -116,7 +100,7 @@ class SharedResourceUse final : angle::NonCopyable ...@@ -116,7 +100,7 @@ class SharedResourceUse final : angle::NonCopyable
ANGLE_INLINE bool isCurrentlyInUse(Serial lastCompletedSerial) const ANGLE_INLINE bool isCurrentlyInUse(Serial lastCompletedSerial) const
{ {
return hasRecordedCommands() || hasRunningCommands(lastCompletedSerial); return usedInRecordedCommands() || usedInRunningCommands(lastCompletedSerial);
} }
ANGLE_INLINE Serial getSerial() const ANGLE_INLINE Serial getSerial() const
...@@ -163,36 +147,27 @@ class ResourceUseList final : angle::NonCopyable ...@@ -163,36 +147,27 @@ class ResourceUseList final : angle::NonCopyable
std::vector<SharedResourceUse> mResourceUses; std::vector<SharedResourceUse> mResourceUses;
}; };
// ResourceUser inlines.
ANGLE_INLINE void ResourceUseList::add(const SharedResourceUse &resourceUse) ANGLE_INLINE void ResourceUseList::add(const SharedResourceUse &resourceUse)
{ {
// Disabled the assert because of difficulties with ImageView references.
// TODO(jmadill): Clean up with graph redesign. http://anglebug.com/4029
// ASSERT(!empty());
SharedResourceUse newUse; SharedResourceUse newUse;
newUse.set(resourceUse); newUse.set(resourceUse);
mResourceUses.emplace_back(std::move(newUse)); mResourceUses.emplace_back(std::move(newUse));
} }
// This is a helper class for back-end objects used in Vk command buffers. It records a serial // This is a helper class for back-end objects used in Vk command buffers. They keep a record
// at command recording times indicating an order in the queue. We use Fences to detect when // of their use in ANGLE and VkQueues via SharedResourceUse.
// commands finish, and then release any unreferenced and deleted resources based on the stored class Resource : angle::NonCopyable
// queue serial in a special 'garbage' queue. Resources also track current read and write
// dependencies. Only one command buffer node can be writing to the Resource at a time, but many
// can be reading from it. Together the dependencies will form a command graph at submission time.
class CommandGraphResource : angle::NonCopyable
{ {
public: public:
virtual ~CommandGraphResource(); virtual ~Resource();
// Returns true if the resource has commands in the graph. This is used to know if a flush // Returns true if the resource is used by ANGLE in an unflushed command buffer.
// should be performed, e.g. if we need to wait for the GPU to finish with the resource. bool usedInRecordedCommands() const { return mUse.usedInRecordedCommands(); }
bool hasRecordedCommands() const { return mUse.hasRecordedCommands(); }
// Determine if the driver has finished execution with this resource. // Determine if the driver has finished execution with this resource.
bool hasRunningCommands(Serial lastCompletedSerial) const bool usedInRunningCommands(Serial lastCompletedSerial) const
{ {
return mUse.hasRunningCommands(lastCompletedSerial); return mUse.usedInRunningCommands(lastCompletedSerial);
} }
// Returns true if the resource is in use by ANGLE or the driver. // Returns true if the resource is in use by ANGLE or the driver.
...@@ -204,34 +179,17 @@ class CommandGraphResource : angle::NonCopyable ...@@ -204,34 +179,17 @@ class CommandGraphResource : angle::NonCopyable
// Ensures the driver is caught up to this resource and it is only in use by ANGLE. // Ensures the driver is caught up to this resource and it is only in use by ANGLE.
angle::Result finishRunningCommands(ContextVk *contextVk); angle::Result finishRunningCommands(ContextVk *contextVk);
// Updates the in-use serial tracked for this resource. Will clear dependencies if the resource // Adds the resource to a resource use list.
// was not used in this set of command nodes. void retain(ResourceUseList *resourceUseList);
// TODO(jmadill): Merge and rename. http://anglebug.com/4029
void onResourceAccess(ResourceUseList *resourceUseList);
// If a resource is recreated, as in released and reinitialized, the next access to the
// resource will not create an edge from its last node and will create a new independent node.
// This is because mUse is reset and the graph believes it's an entirely new resource. In very
// particular cases, such as recreating an image with full mipchain or adding STORAGE_IMAGE flag
// to its uses, this function is used to preserve the link between the previous and new
// nodes allocated for this resource.
// TODO(jmadill): Merge and rename. http://anglebug.com/4029
void onResourceRecreated(ResourceUseList *resourceUseList);
protected: protected:
CommandGraphResource(); Resource();
// Current resource lifetime. // Current resource lifetime.
SharedResourceUse mUse; SharedResourceUse mUse;
}; };
ANGLE_INLINE void CommandGraphResource::onResourceRecreated(ResourceUseList *resourceUseList) ANGLE_INLINE void Resource::retain(ResourceUseList *resourceUseList)
{
// Store reference in resource list.
resourceUseList->add(mUse);
}
ANGLE_INLINE void CommandGraphResource::onResourceAccess(ResourceUseList *resourceUseList)
{ {
// Store reference in resource list. // Store reference in resource list.
resourceUseList->add(mUse); resourceUseList->add(mUse);
...@@ -239,4 +197,4 @@ ANGLE_INLINE void CommandGraphResource::onResourceAccess(ResourceUseList *resour ...@@ -239,4 +197,4 @@ ANGLE_INLINE void CommandGraphResource::onResourceAccess(ResourceUseList *resour
} // namespace vk } // namespace vk
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_ #endif // LIBANGLE_RENDERER_VULKAN_RESOURCEVK_H_
...@@ -34,10 +34,7 @@ class SamplerVk : public SamplerImpl ...@@ -34,10 +34,7 @@ class SamplerVk : public SamplerImpl
Serial getSerial() const { return mSerial; } Serial getSerial() const { return mSerial; }
void onSamplerAccess(vk::ResourceUseList *resourceUseList) void retain(vk::ResourceUseList *resourceUseList) { mSampler.retain(resourceUseList); }
{
mSampler.onResourceAccess(resourceUseList);
}
private: private:
vk::SamplerHelper mSampler; vk::SamplerHelper mSampler;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "libANGLE/renderer/EGLSyncImpl.h" #include "libANGLE/renderer/EGLSyncImpl.h"
#include "libANGLE/renderer/SyncImpl.h" #include "libANGLE/renderer/SyncImpl.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/ResourceVk.h"
namespace egl namespace egl
{ {
......
...@@ -448,7 +448,7 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context, ...@@ -448,7 +448,7 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context,
const vk::ImageView *readImageView = nullptr; const vk::ImageView *readImageView = nullptr;
ANGLE_TRY(colorReadRT->getImageView(contextVk, &readImageView)); ANGLE_TRY(colorReadRT->getImageView(contextVk, &readImageView));
colorReadRT->onImageViewAccess(contextVk); colorReadRT->retainImageViews(contextVk);
return copySubImageImplWithDraw(contextVk, offsetImageIndex, modifiedDestOffset, destFormat, return copySubImageImplWithDraw(contextVk, offsetImageIndex, modifiedDestOffset, destFormat,
0, clippedSourceArea, isViewportFlipY, false, false, false, 0, clippedSourceArea, isViewportFlipY, false, false, false,
...@@ -1138,7 +1138,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context) ...@@ -1138,7 +1138,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context)
if (mImage->hasStagedUpdates()) if (mImage->hasStagedUpdates())
{ {
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
mImage->onResourceAccess(&contextVk->getResourceUseList()); mImage->retain(&contextVk->getResourceUseList());
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer)); ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer(&commandBuffer));
ANGLE_TRY(mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0), ANGLE_TRY(mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0),
mImage->getLevelCount(), getNativeImageLayer(0), mImage->getLevelCount(), getNativeImageLayer(0),
...@@ -1154,7 +1154,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context) ...@@ -1154,7 +1154,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context)
// Release the origin image and recreate it with new mipmap counts. // Release the origin image and recreate it with new mipmap counts.
releaseImage(contextVk); releaseImage(contextVk);
mImage->onResourceRecreated(&contextVk->getResourceUseList()); mImage->retain(&contextVk->getResourceUseList());
ANGLE_TRY(ensureImageInitialized(contextVk, ImageMipLevels::FullMipChain)); ANGLE_TRY(ensureImageInitialized(contextVk, ImageMipLevels::FullMipChain));
} }
...@@ -1317,7 +1317,7 @@ angle::Result TextureVk::changeLevels(ContextVk *contextVk, ...@@ -1317,7 +1317,7 @@ angle::Result TextureVk::changeLevels(ContextVk *contextVk,
// recreated with the correct number of mip levels, base level, and max level. // recreated with the correct number of mip levels, base level, and max level.
releaseImage(contextVk); releaseImage(contextVk);
mImage->onResourceRecreated(&contextVk->getResourceUseList()); mImage->retain(&contextVk->getResourceUseList());
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -1570,7 +1570,7 @@ const vk::ImageView &TextureVk::getReadImageViewAndRecordUse(ContextVk *contextV ...@@ -1570,7 +1570,7 @@ const vk::ImageView &TextureVk::getReadImageViewAndRecordUse(ContextVk *contextV
{ {
ASSERT(mImage->valid()); ASSERT(mImage->valid());
mImageViews.onResourceAccess(&contextVk->getResourceUseList()); mImageViews.retain(&contextVk->getResourceUseList());
if (mState.isStencilMode() && mImageViews.hasStencilReadImageView()) if (mState.isStencilMode() && mImageViews.hasStencilReadImageView())
{ {
...@@ -1584,7 +1584,7 @@ const vk::ImageView &TextureVk::getFetchImageViewAndRecordUse(ContextVk *context ...@@ -1584,7 +1584,7 @@ const vk::ImageView &TextureVk::getFetchImageViewAndRecordUse(ContextVk *context
{ {
ASSERT(mImage->valid()); ASSERT(mImage->valid());
mImageViews.onResourceAccess(&contextVk->getResourceUseList()); mImageViews.retain(&contextVk->getResourceUseList());
// We don't currently support fetch for depth/stencil cube map textures. // We don't currently support fetch for depth/stencil cube map textures.
ASSERT(!mImageViews.hasStencilReadImageView() || !mImageViews.hasFetchImageView()); ASSERT(!mImageViews.hasStencilReadImageView() || !mImageViews.hasFetchImageView());
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#define LIBANGLE_RENDERER_VULKAN_TEXTUREVK_H_ #define LIBANGLE_RENDERER_VULKAN_TEXTUREVK_H_
#include "libANGLE/renderer/TextureImpl.h" #include "libANGLE/renderer/TextureImpl.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/RenderTargetVk.h" #include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/SamplerVk.h" #include "libANGLE/renderer/vulkan/SamplerVk.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h" #include "libANGLE/renderer/vulkan/vk_helpers.h"
...@@ -179,15 +179,12 @@ class TextureVk : public TextureImpl ...@@ -179,15 +179,12 @@ class TextureVk : public TextureImpl
return *mImage; return *mImage;
} }
void onImageViewUse(vk::ResourceUseList *resourceUseList) void retainImageViews(vk::ResourceUseList *resourceUseList)
{ {
mImageViews.onResourceAccess(resourceUseList); mImageViews.retain(resourceUseList);
} }
void onSamplerUse(vk::ResourceUseList *resourceUseList) void retainSampler(vk::ResourceUseList *resourceUseList) { mSampler.retain(resourceUseList); }
{
mSampler.onResourceAccess(resourceUseList);
}
void releaseOwnershipOfImage(const gl::Context *context); void releaseOwnershipOfImage(const gl::Context *context);
......
...@@ -1514,7 +1514,7 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, ...@@ -1514,7 +1514,7 @@ 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().onResourceAccess(&contextVk->getResourceUseList()); blitBuffer.get().retain(&contextVk->getResourceUseList());
BlitResolveStencilNoExportShaderParams shaderParams; BlitResolveStencilNoExportShaderParams shaderParams;
if (isResolve) if (isResolve)
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/BufferVk.h" #include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h" #include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h" #include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/trace.h" #include "libANGLE/trace.h"
......
...@@ -3328,7 +3328,7 @@ angle::Result ImageHelper::readPixels(ContextVk *contextVk, ...@@ -3328,7 +3328,7 @@ angle::Result ImageHelper::readPixels(ContextVk *contextVk,
ANGLE_TRY(resolvedImage.get().init2DStaging( ANGLE_TRY(resolvedImage.get().init2DStaging(
contextVk, renderer->getMemoryProperties(), gl::Extents(area.width, area.height, 1), contextVk, renderer->getMemoryProperties(), gl::Extents(area.width, area.height, 1),
*mFormat, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 1)); *mFormat, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 1));
resolvedImage.get().onResourceAccess(&contextVk->getResourceUseList()); resolvedImage.get().retain(&contextVk->getResourceUseList());
} }
// 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.
...@@ -3674,7 +3674,7 @@ angle::Result ImageViewHelper::getLevelDrawImageView(ContextVk *contextVk, ...@@ -3674,7 +3674,7 @@ angle::Result ImageViewHelper::getLevelDrawImageView(ContextVk *contextVk,
uint32_t layer, uint32_t layer,
const ImageView **imageViewOut) const ImageView **imageViewOut)
{ {
onResourceAccess(&contextVk->getResourceUseList()); retain(&contextVk->getResourceUseList());
ImageView *imageView = GetLevelImageView(&mLevelDrawImageViews, level, image.getLevelCount()); ImageView *imageView = GetLevelImageView(&mLevelDrawImageViews, level, image.getLevelCount());
...@@ -3698,7 +3698,7 @@ angle::Result ImageViewHelper::getLevelLayerDrawImageView(ContextVk *contextVk, ...@@ -3698,7 +3698,7 @@ angle::Result ImageViewHelper::getLevelLayerDrawImageView(ContextVk *contextVk,
ASSERT(image.valid()); ASSERT(image.valid());
ASSERT(!image.getFormat().actualImageFormat().isBlock); ASSERT(!image.getFormat().actualImageFormat().isBlock);
onResourceAccess(&contextVk->getResourceUseList()); retain(&contextVk->getResourceUseList());
uint32_t layerCount = GetImageLayerCountForView(image); uint32_t layerCount = GetImageLayerCountForView(image);
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#ifndef LIBANGLE_RENDERER_VULKAN_VK_HELPERS_H_ #ifndef LIBANGLE_RENDERER_VULKAN_VK_HELPERS_H_
#define LIBANGLE_RENDERER_VULKAN_VK_HELPERS_H_ #define LIBANGLE_RENDERER_VULKAN_VK_HELPERS_H_
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/vk_utils.h" #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
namespace gl namespace gl
{ {
...@@ -458,7 +458,7 @@ class LineLoopHelper final : angle::NonCopyable ...@@ -458,7 +458,7 @@ class LineLoopHelper final : angle::NonCopyable
class FramebufferHelper; class FramebufferHelper;
class BufferHelper final : public CommandGraphResource class BufferHelper final : public Resource
{ {
public: public:
BufferHelper(); BufferHelper();
...@@ -621,7 +621,7 @@ enum class ImageLayout ...@@ -621,7 +621,7 @@ enum class ImageLayout
EnumCount = 13, EnumCount = 13,
}; };
class ImageHelper final : public CommandGraphResource class ImageHelper final : public Resource
{ {
public: public:
ImageHelper(); ImageHelper();
...@@ -1063,7 +1063,7 @@ class ImageViewHelper : angle::NonCopyable ...@@ -1063,7 +1063,7 @@ class ImageViewHelper : angle::NonCopyable
bool hasFetchImageView() const { return mFetchImageView.valid(); } bool hasFetchImageView() const { return mFetchImageView.valid(); }
// Store reference to usage in graph. // Store reference to usage in graph.
void onResourceAccess(ResourceUseList *resourceUseList) const { resourceUseList->add(mUse); } void retain(ResourceUseList *resourceUseList) const { resourceUseList->add(mUse); }
// Creates views with multiple layers and levels. // Creates views with multiple layers and levels.
angle::Result initReadViews(ContextVk *contextVk, angle::Result initReadViews(ContextVk *contextVk,
...@@ -1118,14 +1118,14 @@ class SamplerHelper final : angle::NonCopyable ...@@ -1118,14 +1118,14 @@ class SamplerHelper final : angle::NonCopyable
Sampler &get() { return mSampler; } Sampler &get() { return mSampler; }
const Sampler &get() const { return mSampler; } const Sampler &get() const { return mSampler; }
void onResourceAccess(ResourceUseList *resourceUseList) { resourceUseList->add(mUse); } void retain(ResourceUseList *resourceUseList) { resourceUseList->add(mUse); }
private: private:
SharedResourceUse mUse; SharedResourceUse mUse;
Sampler mSampler; Sampler mSampler;
}; };
class FramebufferHelper : public CommandGraphResource class FramebufferHelper : public Resource
{ {
public: public:
FramebufferHelper(); FramebufferHelper();
...@@ -1158,7 +1158,7 @@ class FramebufferHelper : public CommandGraphResource ...@@ -1158,7 +1158,7 @@ class FramebufferHelper : public CommandGraphResource
// A special command graph resource to hold resource dependencies for dispatch calls. It's the // A special command graph resource to hold resource dependencies for dispatch calls. It's the
// equivalent of FramebufferHelper, though it doesn't contain a Vulkan object. // equivalent of FramebufferHelper, though it doesn't contain a Vulkan object.
class DispatchHelper : public CommandGraphResource class DispatchHelper : public Resource
{ {
public: public:
DispatchHelper(); DispatchHelper();
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/BufferVk.h" #include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/ContextVk.h" #include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h" #include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h" #include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
namespace angle namespace angle
{ {
......
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