Vulkan: Implement framebuffers without attachments
It is possible to render to a framebuffer object that has no
attachments. However, the rasterization of primitives is always
based on the area and characteristics of the bound framebuffer.
These characteristics (size, number of samples, etc.) would normally be
defined by the attached images. If no images are attached, these
characteristics are defined by their default values.
Bug: angleproject:3579
Test: dEQP-GLES31.functional.fbo.*no_attachments*
Test: dEQP-GLES31.functional.state_query.framebuffer_default.*
Change-Id: I9580b924ac810db573cd8df96273fbb01bbb1f73
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1690688
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Commit-Queue: Tim Van Patten <timvp@google.com>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 7aeb3ef..e744030 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -1097,11 +1097,14 @@
ANGLE_TRY(mRenderTargetCache.getColors()[colorIndexGL]->flushStagedUpdates(
contextVk));
}
- break;
}
}
}
+ // The FBOs new attachment may have changed the renderable area
+ const gl::State &glState = context->getState();
+ contextVk->updateScissor(glState);
+
mActiveColorComponents = gl_vk::GetColorComponentFlags(
mActiveColorComponentMasksForClear[0].any(), mActiveColorComponentMasksForClear[1].any(),
mActiveColorComponentMasksForClear[2].any(), mActiveColorComponentMasksForClear[3].any());
@@ -1197,6 +1200,14 @@
attachmentsSize = depthStencilRenderTarget->getExtents();
}
+ if (attachmentsSize.empty())
+ {
+ // No attachments, so use the default values.
+ attachmentsSize.height = mState.getDefaultHeight();
+ attachmentsSize.width = mState.getDefaultWidth();
+ attachmentsSize.depth = 0;
+ }
+
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
@@ -1515,13 +1526,14 @@
gl::Rectangle FramebufferVk::getCompleteRenderArea() const
{
- return gl::Rectangle(0, 0, mState.getDimensions().width, mState.getDimensions().height);
+ const gl::Box &dimensions = mState.getDimensions();
+ return gl::Rectangle(0, 0, dimensions.width, dimensions.height);
}
gl::Rectangle FramebufferVk::getScissoredRenderArea(ContextVk *contextVk) const
{
- const gl::Rectangle renderArea(0, 0, mState.getDimensions().width,
- mState.getDimensions().height);
+ const gl::Box &dimensions = mState.getDimensions();
+ const gl::Rectangle renderArea(0, 0, dimensions.width, dimensions.height);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
return ClipRectToScissor(contextVk->getState(), renderArea, invertViewport);