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, ...@@ -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. // Ensure any writes to the textures are flushed before we read from them.
TextureVk *textureVk = mActiveTextures[textureIndex]; TextureVk *textureVk = mActiveTextures[textureIndex];
ANGLE_TRY(textureVk->ensureImageInitialized(this)); ANGLE_TRY(textureVk->ensureImageInitialized(this));
textureVk->getImage().addReadDependency(mDrawFramebuffer); textureVk->getImage().addReadDependency(mDrawFramebuffer->getFramebuffer());
} }
if (mProgram->hasTextures()) if (mProgram->hasTextures())
...@@ -421,7 +421,8 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context, ...@@ -421,7 +421,8 @@ angle::Result ContextVk::handleDirtyVertexBuffers(const gl::Context *context,
for (size_t attribIndex : context->getStateCache().getActiveBufferedAttribsMask()) for (size_t attribIndex : context->getStateCache().getActiveBufferedAttribsMask())
{ {
if (arrayBufferResources[attribIndex]) if (arrayBufferResources[attribIndex])
arrayBufferResources[attribIndex]->addReadDependency(mDrawFramebuffer); arrayBufferResources[attribIndex]->addReadDependency(
mDrawFramebuffer->getFramebuffer());
} }
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -438,7 +439,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context, ...@@ -438,7 +439,7 @@ angle::Result ContextVk::handleDirtyIndexBuffer(const gl::Context *context,
mVertexArray->getCurrentElementArrayBufferResource(); mVertexArray->getCurrentElementArrayBufferResource();
if (elementArrayBufferResource) if (elementArrayBufferResource)
{ {
elementArrayBufferResource->addReadDependency(mDrawFramebuffer); elementArrayBufferResource->addReadDependency(mDrawFramebuffer->getFramebuffer());
} }
return angle::Result::Continue(); return angle::Result::Continue();
} }
......
...@@ -136,7 +136,7 @@ void FramebufferVk::destroy(const gl::Context *context) ...@@ -136,7 +136,7 @@ void FramebufferVk::destroy(const gl::Context *context)
{ {
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
renderer->releaseObject(getStoredQueueSerial(), &mFramebuffer); mFramebuffer.release(renderer);
mReadPixelBuffer.destroy(contextVk->getDevice()); mReadPixelBuffer.destroy(contextVk->getDevice());
mBlitPixelBuffer.destroy(contextVk->getDevice()); mBlitPixelBuffer.destroy(contextVk->getDevice());
...@@ -232,7 +232,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -232,7 +232,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
// Standard Depth/stencil clear without scissor. // Standard Depth/stencil clear without scissor.
if (clearDepth || clearStencil) if (clearDepth || clearStencil)
{ {
ANGLE_TRY(recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
const VkClearDepthStencilValue &clearDepthStencilValue = const VkClearDepthStencilValue &clearDepthStencilValue =
contextVk->getClearDepthStencilValue().depthStencil; contextVk->getClearDepthStencilValue().depthStencil;
...@@ -241,7 +241,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -241,7 +241,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
const angle::Format &format = renderTarget->getImageFormat().textureFormat(); const angle::Format &format = renderTarget->getImageFormat().textureFormat();
const VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format); const VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format);
vk::ImageHelper *image = renderTarget->getImageForWrite(this); vk::ImageHelper *image = renderTarget->getImageForWrite(&mFramebuffer);
image->clearDepthStencil(aspectFlags, clearDepthStencilValue, commandBuffer); image->clearDepthStencil(aspectFlags, clearDepthStencilValue, commandBuffer);
} }
...@@ -255,7 +255,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -255,7 +255,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
if (!commandBuffer) if (!commandBuffer)
{ {
ANGLE_TRY(recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
} }
// TODO(jmadill): Support gaps in RenderTargets. http://anglebug.com/2394 // TODO(jmadill): Support gaps in RenderTargets. http://anglebug.com/2394
...@@ -275,7 +275,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask) ...@@ -275,7 +275,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
} }
ASSERT(colorRenderTarget); ASSERT(colorRenderTarget);
vk::ImageHelper *image = colorRenderTarget->getImageForWrite(this); vk::ImageHelper *image = colorRenderTarget->getImageForWrite(&mFramebuffer);
GLint mipLevelToClear = (attachment->type() == GL_TEXTURE) ? attachment->mipLevel() : 0; GLint mipLevelToClear = (attachment->type() == GL_TEXTURE) ? attachment->mipLevel() : 0;
// If we're clearing a cube map face ensure we only clear the selected layer. // If we're clearing a cube map face ensure we only clear the selected layer.
...@@ -404,8 +404,8 @@ void FramebufferVk::blitWithCopy(vk::CommandBuffer *commandBuffer, ...@@ -404,8 +404,8 @@ void FramebufferVk::blitWithCopy(vk::CommandBuffer *commandBuffer,
VkFlags aspectFlags = VkFlags aspectFlags =
vk::GetDepthStencilAspectFlags(readRenderTarget->getImageFormat().textureFormat()); vk::GetDepthStencilAspectFlags(readRenderTarget->getImageFormat().textureFormat());
vk::ImageHelper *readImage = readRenderTarget->getImageForRead( vk::ImageHelper *readImage = readRenderTarget->getImageForRead(
this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, commandBuffer); &mFramebuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, commandBuffer);
vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(this); vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
// Requirement of the copyImageToBuffer, the dst image must be in // Requirement of the copyImageToBuffer, the dst image must be in
// VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL layout. // VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL layout.
writeImage->changeLayoutWithStages(aspectFlags, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, writeImage->changeLayoutWithStages(aspectFlags, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
...@@ -482,11 +482,11 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk, ...@@ -482,11 +482,11 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
// Reinitialize the commandBuffer after a read pixels because it calls // Reinitialize the commandBuffer after a read pixels because it calls
// renderer->finish which makes command buffers obsolete. // renderer->finish which makes command buffers obsolete.
ANGLE_TRY(recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// We read the bytes of the image in a buffer, now we have to copy them into the // We read the bytes of the image in a buffer, now we have to copy them into the
// destination target. // destination target.
vk::ImageHelper *imageForWrite = drawRenderTarget->getImageForWrite(this); vk::ImageHelper *imageForWrite = drawRenderTarget->getImageForWrite(&mFramebuffer);
imageForWrite->changeLayoutWithStages( imageForWrite->changeLayoutWithStages(
imageForWrite->getAspectFlags(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, imageForWrite->getAspectFlags(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
...@@ -516,7 +516,7 @@ gl::Error FramebufferVk::blit(const gl::Context *context, ...@@ -516,7 +516,7 @@ gl::Error FramebufferVk::blit(const gl::Context *context,
bool blitStencilBuffer = (mask & GL_STENCIL_BUFFER_BIT) != 0; bool blitStencilBuffer = (mask & GL_STENCIL_BUFFER_BIT) != 0;
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
FramebufferVk *sourceFramebufferVk = vk::GetImpl(sourceFramebuffer); FramebufferVk *sourceFramebufferVk = vk::GetImpl(sourceFramebuffer);
bool flipSource = contextVk->isViewportFlipEnabledForReadFBO(); bool flipSource = contextVk->isViewportFlipEnabledForReadFBO();
bool flipDest = contextVk->isViewportFlipEnabledForDrawFBO(); bool flipDest = contextVk->isViewportFlipEnabledForDrawFBO();
...@@ -649,7 +649,7 @@ void FramebufferVk::blitWithCommand(vk::CommandBuffer *commandBuffer, ...@@ -649,7 +649,7 @@ void FramebufferVk::blitWithCommand(vk::CommandBuffer *commandBuffer,
colorBlit ? VK_IMAGE_ASPECT_COLOR_BIT colorBlit ? VK_IMAGE_ASPECT_COLOR_BIT
: vk::GetDepthStencilAspectFlags(readImageFormat.textureFormat()); : vk::GetDepthStencilAspectFlags(readImageFormat.textureFormat());
vk::ImageHelper *srcImage = readRenderTarget->getImageForRead( vk::ImageHelper *srcImage = readRenderTarget->getImageForRead(
this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, commandBuffer); &mFramebuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, commandBuffer);
const gl::Extents sourceFrameBufferExtents = readRenderTarget->getImageExtents(); const gl::Extents sourceFrameBufferExtents = readRenderTarget->getImageExtents();
gl::Rectangle readRect = readRectIn; gl::Rectangle readRect = readRectIn;
...@@ -682,7 +682,7 @@ void FramebufferVk::blitWithCommand(vk::CommandBuffer *commandBuffer, ...@@ -682,7 +682,7 @@ void FramebufferVk::blitWithCommand(vk::CommandBuffer *commandBuffer,
blit.dstOffsets[0] = {drawRect.x0(), flipDest ? drawRect.y1() : drawRect.y0(), 0}; blit.dstOffsets[0] = {drawRect.x0(), flipDest ? drawRect.y1() : drawRect.y0(), 0};
blit.dstOffsets[1] = {drawRect.x1(), flipDest ? drawRect.y0() : drawRect.y1(), 1}; blit.dstOffsets[1] = {drawRect.x1(), flipDest ? drawRect.y0() : drawRect.y1(), 1};
vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(this); vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
// Requirement of the copyImageToBuffer, the dst image must be in // Requirement of the copyImageToBuffer, the dst image must be in
// VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL layout. // VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL layout.
...@@ -768,11 +768,11 @@ gl::Error FramebufferVk::syncState(const gl::Context *context, ...@@ -768,11 +768,11 @@ gl::Error FramebufferVk::syncState(const gl::Context *context,
mActiveColorComponentMasksForClear[2].any(), mActiveColorComponentMasksForClear[3].any()); mActiveColorComponentMasksForClear[2].any(), mActiveColorComponentMasksForClear[3].any());
mRenderPassDesc.reset(); mRenderPassDesc.reset();
renderer->releaseObject(getStoredQueueSerial(), &mFramebuffer); mFramebuffer.release(renderer);
// Will freeze the current set of dependencies on this FBO. The next time we render we will // Will freeze the current set of dependencies on this FBO. The next time we render we will
// create a new entry in the command graph. // create a new entry in the command graph.
finishCurrentCommands(renderer); mFramebuffer.finishCurrentCommands(renderer);
contextVk->invalidateCurrentPipeline(); contextVk->invalidateCurrentPipeline();
...@@ -812,7 +812,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk, vk::Framebuffe ...@@ -812,7 +812,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk, vk::Framebuffe
// If we've already created our cached Framebuffer, return it. // If we've already created our cached Framebuffer, return it.
if (mFramebuffer.valid()) if (mFramebuffer.valid())
{ {
*framebufferOut = &mFramebuffer; *framebufferOut = &mFramebuffer.getFramebuffer();
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -869,7 +869,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk, vk::Framebuffe ...@@ -869,7 +869,7 @@ angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk, vk::Framebuffe
ANGLE_TRY(mFramebuffer.init(contextVk, framebufferInfo)); ANGLE_TRY(mFramebuffer.init(contextVk, framebufferInfo));
*framebufferOut = &mFramebuffer; *framebufferOut = &mFramebuffer.getFramebuffer();
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -879,7 +879,7 @@ angle::Result FramebufferVk::clearWithClearAttachments(ContextVk *contextVk, ...@@ -879,7 +879,7 @@ angle::Result FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
bool clearStencil) bool clearStencil)
{ {
// Trigger a new command node to ensure overlapping writes happen sequentially. // Trigger a new command node to ensure overlapping writes happen sequentially.
finishCurrentCommands(contextVk->getRenderer()); mFramebuffer.finishCurrentCommands(contextVk->getRenderer());
// This command can only happen inside a render pass, so obtain one if its already happening // This command can only happen inside a render pass, so obtain one if its already happening
// or create a new one if not. // or create a new one if not.
...@@ -895,8 +895,8 @@ angle::Result FramebufferVk::clearWithClearAttachments(ContextVk *contextVk, ...@@ -895,8 +895,8 @@ angle::Result FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
// When clearing, the scissor region must be clipped to the renderArea per the validation rules // When clearing, the scissor region must be clipped to the renderArea per the validation rules
// in Vulkan. // in Vulkan.
gl::Rectangle intersection; gl::Rectangle intersection;
if (!gl::ClipRectangle(contextVk->getGLState().getScissor(), getRenderPassRenderArea(), if (!gl::ClipRectangle(contextVk->getGLState().getScissor(),
&intersection)) mFramebuffer.getRenderPassRenderArea(), &intersection))
{ {
// There is nothing to clear since the scissor is outside of the render area. // There is nothing to clear since the scissor is outside of the render area.
return angle::Result::Continue(); return angle::Result::Continue();
...@@ -906,8 +906,8 @@ angle::Result FramebufferVk::clearWithClearAttachments(ContextVk *contextVk, ...@@ -906,8 +906,8 @@ angle::Result FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
if (contextVk->isViewportFlipEnabledForDrawFBO()) if (contextVk->isViewportFlipEnabledForDrawFBO())
{ {
clearRect.rect.offset.y = getRenderPassRenderArea().height - clearRect.rect.offset.y - clearRect.rect.offset.y = mFramebuffer.getRenderPassRenderArea().height -
clearRect.rect.extent.height; clearRect.rect.offset.y - clearRect.rect.extent.height;
} }
gl::AttachmentArray<VkClearAttachment> clearAttachments; gl::AttachmentArray<VkClearAttachment> clearAttachments;
...@@ -980,7 +980,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -980,7 +980,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
vk::ShaderLibrary *shaderLibrary = renderer->getShaderLibrary(); vk::ShaderLibrary *shaderLibrary = renderer->getShaderLibrary();
// Trigger a new command node to ensure overlapping writes happen sequentially. // Trigger a new command node to ensure overlapping writes happen sequentially.
finishCurrentCommands(renderer); mFramebuffer.finishCurrentCommands(renderer);
const vk::ShaderAndSerial *fullScreenQuad = nullptr; const vk::ShaderAndSerial *fullScreenQuad = nullptr;
ANGLE_TRY(shaderLibrary->getShader(contextVk, vk::InternalShaderID::FullScreenQuad_vert, ANGLE_TRY(shaderLibrary->getShader(contextVk, vk::InternalShaderID::FullScreenQuad_vert,
...@@ -1006,7 +1006,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -1006,7 +1006,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
vk::CommandBuffer *drawCommands = nullptr; vk::CommandBuffer *drawCommands = nullptr;
ANGLE_TRY(getCommandBufferForDraw(contextVk, &drawCommands, &recordingMode)); ANGLE_TRY(getCommandBufferForDraw(contextVk, &drawCommands, &recordingMode));
const gl::Rectangle &renderArea = getRenderPassRenderArea(); const gl::Rectangle &renderArea = mFramebuffer.getRenderPassRenderArea();
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO(); bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
// This pipeline desc could be cached. // This pipeline desc could be cached.
...@@ -1040,7 +1040,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -1040,7 +1040,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
pipeline->updateSerial(renderer->getCurrentQueueSerial()); pipeline->updateSerial(renderer->getCurrentQueueSerial());
vk::CommandBuffer *writeCommands = nullptr; vk::CommandBuffer *writeCommands = nullptr;
ANGLE_TRY(recordCommands(contextVk, &writeCommands)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &writeCommands));
// If the format of the framebuffer does not have an alpha channel, we need to make sure we does // If the format of the framebuffer does not have an alpha channel, we need to make sure we does
// not affect the alpha channel of the type we're using to emulate the format. // not affect the alpha channel of the type we're using to emulate the format.
...@@ -1099,7 +1099,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -1099,7 +1099,7 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
std::vector<VkClearValue> attachmentClearValues; std::vector<VkClearValue> attachmentClearValues;
vk::CommandBuffer *writeCommands = nullptr; vk::CommandBuffer *writeCommands = nullptr;
ANGLE_TRY(recordCommands(contextVk, &writeCommands)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &writeCommands));
vk::RenderPassDesc renderPassDesc; vk::RenderPassDesc renderPassDesc;
...@@ -1111,22 +1111,23 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk, ...@@ -1111,22 +1111,23 @@ angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex]; RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex];
ASSERT(colorRenderTarget); ASSERT(colorRenderTarget);
colorRenderTarget->onColorDraw(this, writeCommands, &renderPassDesc); colorRenderTarget->onColorDraw(&mFramebuffer, writeCommands, &renderPassDesc);
attachmentClearValues.emplace_back(contextVk->getClearColorValue()); attachmentClearValues.emplace_back(contextVk->getClearColorValue());
} }
RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil(); RenderTargetVk *depthStencilRenderTarget = mRenderTargetCache.getDepthStencil();
if (depthStencilRenderTarget) if (depthStencilRenderTarget)
{ {
depthStencilRenderTarget->onDepthStencilDraw(this, writeCommands, &renderPassDesc); depthStencilRenderTarget->onDepthStencilDraw(&mFramebuffer, writeCommands, &renderPassDesc);
attachmentClearValues.emplace_back(contextVk->getClearDepthStencilValue()); attachmentClearValues.emplace_back(contextVk->getClearDepthStencilValue());
} }
gl::Rectangle renderArea = gl::Rectangle renderArea =
gl::Rectangle(0, 0, mState.getDimensions().width, mState.getDimensions().height); gl::Rectangle(0, 0, mState.getDimensions().width, mState.getDimensions().height);
return beginRenderPass(contextVk, *framebuffer, renderArea, mRenderPassDesc.value(), return mFramebuffer.beginRenderPass(contextVk, *framebuffer, renderArea,
attachmentClearValues, commandBufferOut); mRenderPassDesc.value(), attachmentClearValues,
commandBufferOut);
} }
void FramebufferVk::updateActiveColorMasks(size_t colorIndex, bool r, bool g, bool b, bool a) void FramebufferVk::updateActiveColorMasks(size_t colorIndex, bool r, bool g, bool b, bool a)
...@@ -1152,12 +1153,12 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk, ...@@ -1152,12 +1153,12 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// Note that although we're reading from the image, we need to update the layout below. // Note that although we're reading from the image, we need to update the layout below.
vk::ImageHelper *srcImage = vk::ImageHelper *srcImage = renderTarget->getImageForRead(
renderTarget->getImageForRead(this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, commandBuffer); &mFramebuffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, commandBuffer);
const angle::Format *readFormat = &srcImage->getFormat().textureFormat(); const angle::Format *readFormat = &srcImage->getFormat().textureFormat();
......
...@@ -22,7 +22,7 @@ class RendererVk; ...@@ -22,7 +22,7 @@ class RendererVk;
class RenderTargetVk; class RenderTargetVk;
class WindowSurfaceVk; class WindowSurfaceVk;
class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource class FramebufferVk : public FramebufferImpl
{ {
public: public:
// Factory methods so we don't have to use constructors with overloads. // Factory methods so we don't have to use constructors with overloads.
...@@ -105,7 +105,12 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource ...@@ -105,7 +105,12 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
RenderTargetVk *getColorReadRenderTarget() const; RenderTargetVk *getColorReadRenderTarget() const;
// This will clear the current write operation if it is complete. // 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); angle::Result startNewRenderPass(ContextVk *context, vk::CommandBuffer **commandBufferOut);
...@@ -159,7 +164,7 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource ...@@ -159,7 +164,7 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
WindowSurfaceVk *mBackbuffer; WindowSurfaceVk *mBackbuffer;
Optional<vk::RenderPassDesc> mRenderPassDesc; Optional<vk::RenderPassDesc> mRenderPassDesc;
vk::Framebuffer mFramebuffer; vk::FramebufferHelper mFramebuffer;
RenderTargetCache<RenderTargetVk> mRenderTargetCache; RenderTargetCache<RenderTargetVk> mRenderTargetCache;
// These two variables are used to quickly compute if we need to do a masked clear. If a color // 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, ...@@ -626,7 +626,7 @@ angle::Result TextureVk::copySubImageImpl(const gl::Context *context,
framebufferVk)); framebufferVk));
mImage.finishCurrentCommands(renderer); mImage.finishCurrentCommands(renderer);
framebufferVk->addReadDependency(&mImage); framebufferVk->getFramebuffer()->addReadDependency(&mImage);
return angle::Result::Continue(); return angle::Result::Continue();
} }
......
...@@ -933,5 +933,21 @@ void ImageHelper::Copy(ImageHelper *srcImage, ...@@ -933,5 +933,21 @@ void ImageHelper::Copy(ImageHelper *srcImage,
commandBuffer->copyImage(srcImage->getImage(), srcImage->getCurrentLayout(), commandBuffer->copyImage(srcImage->getImage(), srcImage->getCurrentLayout(),
dstImage->getImage(), dstImage->getCurrentLayout(), 1, &region); 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 vk
} // namespace rx } // namespace rx
...@@ -166,7 +166,7 @@ class LineLoopHelper final : angle::NonCopyable ...@@ -166,7 +166,7 @@ class LineLoopHelper final : angle::NonCopyable
DynamicBuffer mDynamicIndexBuffer; DynamicBuffer mDynamicIndexBuffer;
}; };
class BufferHelper final : public CommandGraphResource class BufferHelper final : public CommandGraphResource, angle::NonCopyable
{ {
public: public:
BufferHelper(); BufferHelper();
...@@ -190,7 +190,7 @@ class BufferHelper final : public CommandGraphResource ...@@ -190,7 +190,7 @@ class BufferHelper final : public CommandGraphResource
VkMemoryPropertyFlags mMemoryPropertyFlags; VkMemoryPropertyFlags mMemoryPropertyFlags;
}; };
class ImageHelper final : public CommandGraphResource class ImageHelper final : public CommandGraphResource, angle::NonCopyable
{ {
public: public:
ImageHelper(); ImageHelper();
...@@ -298,6 +298,35 @@ class ImageHelper final : public CommandGraphResource ...@@ -298,6 +298,35 @@ class ImageHelper final : public CommandGraphResource
// Cached properties. // Cached properties.
uint32_t mLayerCount; 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 vk
} // namespace rx } // 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