#include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include <array>
#include "common/debug.h"
#include "common/vulkan/vk_headers.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/ErrorStrings.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/SurfaceVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_renderer.h"
#include "libANGLE/renderer/vulkan/vk_resource.h"
namespace rx
{
namespace
{
constexpr VkClearValue kUninitializedClearValue = …;
constexpr unsigned int kEmulatedAlphaValue = …;
bool HasSrcBlitFeature(vk::Renderer *renderer, RenderTargetVk *srcRenderTarget)
{ … }
bool HasDstBlitFeature(vk::Renderer *renderer, RenderTargetVk *dstRenderTarget)
{ … }
bool AreSrcAndDstColorChannelsBlitCompatible(RenderTargetVk *srcRenderTarget,
RenderTargetVk *dstRenderTarget)
{ … }
bool AreSrcAndDstFormatsIdentical(RenderTargetVk *srcRenderTarget, RenderTargetVk *dstRenderTarget)
{ … }
bool AreSrcAndDstDepthStencilChannelsBlitCompatible(RenderTargetVk *srcRenderTarget,
RenderTargetVk *dstRenderTarget)
{ … }
void EarlyAdjustFlipYForPreRotation(SurfaceRotation blitAngleIn,
SurfaceRotation *blitAngleOut,
bool *blitFlipYOut)
{ … }
void AdjustBlitAreaForPreRotation(SurfaceRotation framebufferAngle,
const gl::Rectangle &blitAreaIn,
const gl::Rectangle &framebufferDimensions,
gl::Rectangle *blitAreaOut)
{ … }
void AdjustDimensionsAndFlipForPreRotation(SurfaceRotation framebufferAngle,
gl::Rectangle *framebufferDimensions,
bool *flipX,
bool *flipY)
{ … }
void AdjustBlitResolveParametersForResolve(const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
UtilsVk::BlitResolveParameters *params)
{ … }
void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle,
SurfaceRotation srcFramebufferAngle,
UtilsVk::BlitResolveParameters *params)
{ … }
vk::FramebufferNonResolveAttachmentMask MakeUnresolveAttachmentMask(const vk::RenderPassDesc &desc)
{ … }
bool IsAnyAttachment3DWithoutAllLayers(const RenderTargetCache<RenderTargetVk> &renderTargetCache,
gl::DrawBufferMask colorAttachmentsMask,
uint32_t framebufferLayerCount)
{ … }
void AdjustLayersAndDepthFor3DImages(VkImageSubresourceLayers *subresource,
VkOffset3D *offsetsStart,
VkOffset3D *offsetsEnd)
{ … }
bool AllowAddingResolveAttachmentsToSubpass(const vk::RenderPassDesc &desc)
{ … }
}
FramebufferVk::FramebufferVk(vk::Renderer *renderer, const gl::FramebufferState &state)
: … { … }
FramebufferVk::~FramebufferVk() = default;
void FramebufferVk::destroy(const gl::Context *context)
{ … }
void FramebufferVk::insertCache(ContextVk *contextVk,
const vk::FramebufferDesc &desc,
vk::FramebufferHelper &&newFramebuffer)
{ … }
angle::Result FramebufferVk::discard(const gl::Context *context,
size_t count,
const GLenum *attachments)
{ … }
angle::Result FramebufferVk::invalidate(const gl::Context *context,
size_t count,
const GLenum *attachments)
{ … }
angle::Result FramebufferVk::invalidateSub(const gl::Context *context,
size_t count,
const GLenum *attachments,
const gl::Rectangle &area)
{ … }
angle::Result FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
{ … }
VkClearColorValue adjustFloatClearColorPrecision(const VkClearColorValue &color,
const angle::Format &colorFormat)
{ … }
angle::Result FramebufferVk::clearImpl(const gl::Context *context,
gl::DrawBufferMask clearColorBuffers,
bool clearDepth,
bool clearStencil,
const VkClearColorValue &clearColorValue,
const VkClearDepthStencilValue &clearDepthStencilValue)
{ … }
angle::Result FramebufferVk::clearBufferfv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLfloat *values)
{ … }
angle::Result FramebufferVk::clearBufferuiv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLuint *values)
{ … }
angle::Result FramebufferVk::clearBufferiv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLint *values)
{ … }
angle::Result FramebufferVk::clearBufferfi(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
GLfloat depth,
GLint stencil)
{ … }
const gl::InternalFormat &FramebufferVk::getImplementationColorReadFormat(
const gl::Context *context) const
{ … }
angle::Result FramebufferVk::readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
gl::Buffer *packBuffer,
void *pixels)
{ … }
RenderTargetVk *FramebufferVk::getDepthStencilRenderTarget() const
{ … }
RenderTargetVk *FramebufferVk::getColorDrawRenderTarget(size_t colorIndexGL) const
{ … }
RenderTargetVk *FramebufferVk::getColorReadRenderTarget() const
{ … }
RenderTargetVk *FramebufferVk::getReadPixelsRenderTarget(GLenum format) const
{ … }
VkImageAspectFlagBits FramebufferVk::getReadPixelsAspectFlags(GLenum format) const
{ … }
angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
RenderTargetVk *readRenderTarget,
RenderTargetVk *drawRenderTarget,
GLenum filter,
bool colorBlit,
bool depthBlit,
bool stencilBlit,
bool flipX,
bool flipY)
{ … }
angle::Result FramebufferVk::blit(const gl::Context *context,
const gl::Rectangle &sourceAreaIn,
const gl::Rectangle &destAreaIn,
GLbitfield mask,
GLenum filter)
{ … }
void FramebufferVk::releaseCurrentFramebuffer(ContextVk *contextVk)
{ … }
void FramebufferVk::updateLayerCount()
{ … }
angle::Result FramebufferVk::ensureFragmentShadingRateImageAndViewInitialized(
ContextVk *contextVk,
const uint32_t fragmentShadingRateAttachmentWidth,
const uint32_t fragmentShadingRateAttachmentHeight)
{ … }
angle::Result FramebufferVk::generateFragmentShadingRateWithCPU(
ContextVk *contextVk,
const uint32_t fragmentShadingRateWidth,
const uint32_t fragmentShadingRateHeight,
const uint32_t fragmentShadingRateBlockWidth,
const uint32_t fragmentShadingRateBlockHeight,
const uint32_t foveatedAttachmentWidth,
const uint32_t foveatedAttachmentHeight,
const std::vector<gl::FocalPoint> &activeFocalPoints)
{ … }
angle::Result FramebufferVk::generateFragmentShadingRateWithCompute(
ContextVk *contextVk,
const uint32_t fragmentShadingRateWidth,
const uint32_t fragmentShadingRateHeight,
const uint32_t fragmentShadingRateBlockWidth,
const uint32_t fragmentShadingRateBlockHeight,
const uint32_t foveatedAttachmentWidth,
const uint32_t foveatedAttachmentHeight,
const std::vector<gl::FocalPoint> &activeFocalPoints)
{ … }
angle::Result FramebufferVk::updateFragmentShadingRateAttachment(
ContextVk *contextVk,
const gl::FoveationState &foveationState,
const gl::Extents &foveatedAttachmentSize)
{ … }
angle::Result FramebufferVk::updateFoveationState(ContextVk *contextVk,
const gl::FoveationState &newFoveationState,
const gl::Extents &foveatedAttachmentSize)
{ … }
angle::Result FramebufferVk::resolveColorWithSubpass(ContextVk *contextVk,
const UtilsVk::BlitResolveParameters ¶ms)
{ … }
angle::Result FramebufferVk::resolveDepthStencilWithSubpass(
ContextVk *contextVk,
const UtilsVk::BlitResolveParameters ¶ms,
VkImageAspectFlags aspects)
{ … }
angle::Result FramebufferVk::resolveColorWithCommand(ContextVk *contextVk,
const UtilsVk::BlitResolveParameters ¶ms,
vk::ImageHelper *srcImage)
{ … }
gl::FramebufferStatus FramebufferVk::checkStatus(const gl::Context *context) const
{ … }
angle::Result FramebufferVk::invalidateImpl(ContextVk *contextVk,
size_t count,
const GLenum *attachments,
bool isSubInvalidate,
const gl::Rectangle &invalidateArea)
{ … }
angle::Result FramebufferVk::updateColorAttachment(const gl::Context *context,
uint32_t colorIndexGL)
{ … }
angle::Result FramebufferVk::updateDepthStencilAttachment(const gl::Context *context)
{ … }
void FramebufferVk::updateDepthStencilAttachmentSerial(ContextVk *contextVk)
{ … }
angle::Result FramebufferVk::flushColorAttachmentUpdates(const gl::Context *context,
bool deferClears,
uint32_t colorIndexGL)
{ … }
angle::Result FramebufferVk::flushDepthStencilAttachmentUpdates(const gl::Context *context,
bool deferClears)
{ … }
angle::Result FramebufferVk::syncState(const gl::Context *context,
GLenum binding,
const gl::Framebuffer::DirtyBits &dirtyBits,
gl::Command command)
{ … }
void FramebufferVk::updateRenderPassDesc(ContextVk *contextVk)
{ … }
angle::Result FramebufferVk::getAttachmentsAndRenderTargets(
vk::Context *context,
vk::FramebufferAttachmentsVector<VkImageView> *unpackedAttachments,
vk::FramebufferAttachmentsVector<RenderTargetInfo> *packedRenderTargetsInfoOut)
{ … }
angle::Result FramebufferVk::createNewFramebuffer(
ContextVk *contextVk,
uint32_t framebufferWidth,
const uint32_t framebufferHeight,
const uint32_t framebufferLayers,
const vk::FramebufferAttachmentsVector<VkImageView> &unpackedAttachments,
const vk::FramebufferAttachmentsVector<RenderTargetInfo> &renderTargetsInfo)
{ … }
angle::Result FramebufferVk::getFramebuffer(ContextVk *contextVk,
vk::RenderPassFramebuffer *framebufferOut)
{ … }
void FramebufferVk::mergeClearsWithDeferredClears(
gl::DrawBufferMask clearColorBuffers,
bool clearDepth,
bool clearStencil,
const gl::DrawBuffersArray<VkClearColorValue> &clearColorValues,
const VkClearDepthStencilValue &clearDepthStencilValue)
{ … }
angle::Result FramebufferVk::clearWithDraw(
ContextVk *contextVk,
const gl::Rectangle &clearArea,
gl::DrawBufferMask clearColorBuffers,
bool clearDepth,
bool clearStencil,
gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
uint8_t stencilMask,
const gl::DrawBuffersArray<VkClearColorValue> &clearColorValues,
const VkClearDepthStencilValue &clearDepthStencilValue)
{ … }
VkClearValue FramebufferVk::getCorrectedColorClearValue(size_t colorIndexGL,
const VkClearColorValue &clearColor) const
{ … }
void FramebufferVk::restageDeferredClears(ContextVk *contextVk)
{ … }
void FramebufferVk::restageDeferredClearsForReadFramebuffer(ContextVk *contextVk)
{ … }
void FramebufferVk::restageDeferredClearsImpl(ContextVk *contextVk)
{ … }
void FramebufferVk::clearWithCommand(ContextVk *contextVk,
const gl::Rectangle &scissoredRenderArea,
ClearWithCommand behavior,
vk::ClearValuesArray *clears)
{ … }
void FramebufferVk::clearWithLoadOp(ContextVk *contextVk)
{ … }
angle::Result FramebufferVk::getSamplePosition(const gl::Context *context,
size_t index,
GLfloat *xy) const
{ … }
angle::Result FramebufferVk::startNewRenderPass(ContextVk *contextVk,
const gl::Rectangle &renderArea,
vk::RenderPassCommandBuffer **commandBufferOut,
bool *renderPassDescChangedOut)
{ … }
gl::Rectangle FramebufferVk::getRenderArea(ContextVk *contextVk) const
{ … }
void FramebufferVk::updateActiveColorMasks(size_t colorIndexGL, bool r, bool g, bool b, bool a)
{ … }
const gl::DrawBufferMask &FramebufferVk::getEmulatedAlphaAttachmentMask() const
{ … }
angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
const gl::Rectangle &area,
const PackPixelsParams &packPixelsParams,
VkImageAspectFlagBits copyAspectFlags,
RenderTargetVk *renderTarget,
void *pixels)
{ … }
gl::Extents FramebufferVk::getReadImageExtents() const
{ … }
gl::Rectangle FramebufferVk::getNonRotatedCompleteRenderArea() const
{ … }
gl::Rectangle FramebufferVk::getRotatedCompleteRenderArea(ContextVk *contextVk) const
{ … }
gl::Rectangle FramebufferVk::getRotatedScissoredRenderArea(ContextVk *contextVk) const
{ … }
GLint FramebufferVk::getSamples() const
{ … }
angle::Result FramebufferVk::flushDeferredClears(ContextVk *contextVk)
{ … }
void FramebufferVk::switchToFramebufferFetchMode(ContextVk *contextVk, bool hasFramebufferFetch)
{ … }
bool FramebufferVk::updateLegacyDither(ContextVk *contextVk)
{ … }
}