Commit e8dd0796 by Jamie Madill Committed by Commit Bot

Vulkan: Make vk::FramebufferHelper the graph resource.

It seems conceptually easier to understand that a vk::Framebuffer is the resource used in graph. Rather than making the GraphResource be integrated into the FramebufferVk class itself. This means that the only objects that are graph resources are Vulkan objects: Images, Buffers, and Framebuffers. Refactoring change only. Bug: angleproject:2828 Change-Id: I59d60643182287d4b1fcf9730a3c3a0da5b65973 Reviewed-on: https://chromium-review.googlesource.com/1249561 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent 2d03ff4a
......@@ -397,7 +397,7 @@ angle::Result ContextVk::handleDirtyTextures(const gl::Context *context,
// Ensure any writes to the textures are flushed before we read from them.
TextureVk *textureVk = mActiveTextures[textureIndex];
ANGLE_TRY(textureVk->ensureImageInitialized(this));
textureVk->getImage().addReadDependency(mDrawFramebuffer);
textureVk->getImage().addReadDependency(mDrawFramebuffer->getFramebuffer());
}
if (mProgram->hasTextures())
......@@ -421,7 +421,8 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
for (size_t attribIndex : context->getStateCache().getActiveBufferedAttribsMask())
{
if (arrayBufferResources[attribIndex])
arrayBufferResources[attribIndex]->addReadDependency(mDrawFramebuffer);
arrayBufferResources[attribIndex]->addReadDependency(
mDrawFramebuffer->getFramebuffer());
}
return angle::Result::Continue();
}
......@@ -438,7 +439,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
mVertexArray->getCurrentElementArrayBufferResource();
if (elementArrayBufferResource)
{
elementArrayBufferResource->addReadDependency(mDrawFramebuffer);
elementArrayBufferResource->addReadDependency(mDrawFramebuffer->getFramebuffer());
}
return angle::Result::Continue();
}
......
......@@ -22,7 +22,7 @@ class RendererVk;
class RenderTargetVk;
class WindowSurfaceVk;
class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
class FramebufferVk : public FramebufferImpl
{
public:
// Factory methods so we don't have to use constructors with overloads.
......@@ -105,7 +105,12 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
RenderTargetVk *getColorReadRenderTarget() const;
// This will clear the current write operation if it is complete.
using CommandGraphResource::appendToStartedRenderPass;
bool appendToStartedRenderPass(RendererVk *renderer, vk::CommandBuffer **commandBufferOut)
{
return mFramebuffer.appendToStartedRenderPass(renderer, commandBufferOut);
}
vk::FramebufferHelper *getFramebuffer() { return &mFramebuffer; }
angle::Result startNewRenderPass(ContextVk *context, vk::CommandBuffer **commandBufferOut);
......@@ -159,7 +164,7 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
WindowSurfaceVk *mBackbuffer;
Optional<vk::RenderPassDesc> mRenderPassDesc;
vk::Framebuffer mFramebuffer;
vk::FramebufferHelper mFramebuffer;
RenderTargetCache<RenderTargetVk> mRenderTargetCache;
// These two variables are used to quickly compute if we need to do a masked clear. If a color
......
......@@ -626,7 +626,7 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context,
framebufferVk));
mImage.finishCurrentCommands(renderer);
framebufferVk->addReadDependency(&mImage);
framebufferVk->getFramebuffer()->addReadDependency(&mImage);
return angle::Result::Continue();
}
......
......@@ -933,5 +933,21 @@ void ImageHelper::Copy(ImageHelper *srcImage,
commandBuffer->copyImage(srcImage->getImage(), srcImage->getCurrentLayout(),
dstImage->getImage(), dstImage->getCurrentLayout(), 1, &region);
}
// FramebufferHelper implementation.
FramebufferHelper::FramebufferHelper() = default;
FramebufferHelper::~FramebufferHelper() = default;
angle::Result FramebufferHelper::init(ContextVk *contextVk,
const VkFramebufferCreateInfo &createInfo)
{
return mFramebuffer.init(contextVk, createInfo);
}
void FramebufferHelper::release(RendererVk *renderer)
{
renderer->releaseObject(getStoredQueueSerial(), &mFramebuffer);
}
} // namespace vk
} // namespace rx
......@@ -166,7 +166,7 @@ class LineLoopHelper final : angle::NonCopyable
DynamicBuffer mDynamicIndexBuffer;
};
class BufferHelper final : public CommandGraphResource
class BufferHelper final : public CommandGraphResource, angle::NonCopyable
{
public:
BufferHelper();
......@@ -190,7 +190,7 @@ class BufferHelper final : public CommandGraphResource
VkMemoryPropertyFlags mMemoryPropertyFlags;
};
class ImageHelper final : public CommandGraphResource
class ImageHelper final : public CommandGraphResource, angle::NonCopyable
{
public:
ImageHelper();
......@@ -298,6 +298,35 @@ class ImageHelper final : public CommandGraphResource
// Cached properties.
uint32_t mLayerCount;
};
class FramebufferHelper : public CommandGraphResource, angle::NonCopyable
{
public:
FramebufferHelper();
~FramebufferHelper();
angle::Result init(ContextVk *contextVk, const VkFramebufferCreateInfo &createInfo);
void release(RendererVk *renderer);
bool valid() { return mFramebuffer.valid(); }
const Framebuffer &getFramebuffer() const
{
ASSERT(mFramebuffer.valid());
return mFramebuffer;
}
Framebuffer &getFramebuffer()
{
ASSERT(mFramebuffer.valid());
return mFramebuffer;
}
private:
// Vulkan object.
Framebuffer mFramebuffer;
};
} // namespace vk
} // namespace rx
......
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