mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-01 05:48:11 +03:00
Metal: Don't use implicit MSAA for render buffers.
This CL removes the usage of implicit MSAA from render buffers. Implicit MSAA added an extra single-sampled texture & resolve step when clients render to a multisampled render buffer. It is as if EXT_multisampled_render_to_texture extension is always used even though users might not request for it. Not to mention this extension's implementation is incomplete. Furthermore, it is hidden from users. Thus the only way for them to use the render buffer after rendering (presentting to screen, sampling the pixels, etc) is manually resolving the render buffer with glBlitFramebuffer. This results in another redudant texture copy operation. This CL also removes no-longer used function FrameBufferMtl::getReadableViewForRenderTarget() Bug: angleproject:8301 Change-Id: I63053b9e1d1a5cf47a023291b8fcb31d3636d3ff Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4840154 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
43130a0aba
commit
e305459968
@@ -180,23 +180,6 @@ class FramebufferMtl : public FramebufferImpl
|
||||
const gl::FramebufferAttachment *attachment,
|
||||
RenderTargetMtl **cachedRenderTarget);
|
||||
|
||||
// This function either returns the render target's texture itself if the texture is readable
|
||||
// or create a copy of that texture that is readable if not. This function is typically used
|
||||
// for packed depth stencil where reading stencil requires a stencil view. However if a texture
|
||||
// has both render target, pixel format view & shader readable usage flags, there will be
|
||||
// some glitches happen in Metal framework.
|
||||
// So the solution is creating a depth stencil texture without pixel format view flag but has
|
||||
// render target flag, then during blitting process, this texture is copied to another
|
||||
// intermidiate texture having pixel format view flag, but not render target flag.
|
||||
angle::Result getReadableViewForRenderTarget(const gl::Context *context,
|
||||
const RenderTargetMtl &rtt,
|
||||
const gl::Rectangle &readArea,
|
||||
mtl::TextureRef *readableDepthView,
|
||||
mtl::TextureRef *readableStencilView,
|
||||
uint32_t *readableViewLevel,
|
||||
uint32_t *readableViewLayer,
|
||||
gl::Rectangle *readableViewArea);
|
||||
|
||||
angle::Result readPixelsToPBO(const gl::Context *context,
|
||||
const gl::Rectangle &area,
|
||||
const PackPixelsParams &packPixelsParams,
|
||||
|
||||
@@ -952,92 +952,6 @@ angle::Result FramebufferMtl::updateCachedRenderTarget(const gl::Context *contex
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
angle::Result FramebufferMtl::getReadableViewForRenderTarget(
|
||||
const gl::Context *context,
|
||||
const RenderTargetMtl &rtt,
|
||||
const gl::Rectangle &readArea,
|
||||
mtl::TextureRef *readableDepthViewOut,
|
||||
mtl::TextureRef *readableStencilViewOut,
|
||||
uint32_t *readableViewLevel,
|
||||
uint32_t *readableViewLayer,
|
||||
gl::Rectangle *readableViewArea)
|
||||
{
|
||||
ContextMtl *contextMtl = mtl::GetImpl(context);
|
||||
mtl::TextureRef srcTexture = rtt.getTexture();
|
||||
uint32_t level = rtt.getLevelIndex().get();
|
||||
uint32_t slice = rtt.getLayerIndex();
|
||||
|
||||
// NOTE(hqle): slice is not used atm.
|
||||
ASSERT(slice == 0);
|
||||
|
||||
bool readStencil = readableStencilViewOut;
|
||||
|
||||
if (!srcTexture)
|
||||
{
|
||||
if (readableDepthViewOut)
|
||||
{
|
||||
*readableDepthViewOut = nullptr;
|
||||
}
|
||||
if (readableStencilViewOut)
|
||||
{
|
||||
*readableStencilViewOut = nullptr;
|
||||
}
|
||||
*readableViewArea = readArea;
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
bool skipCopy = srcTexture->isShaderReadable();
|
||||
if (rtt.getFormat()->hasDepthAndStencilBits() && readStencil)
|
||||
{
|
||||
// If the texture is packed depth stencil, and we need stencil view,
|
||||
// then it must support creating different format view.
|
||||
skipCopy = skipCopy && srcTexture->supportFormatView();
|
||||
}
|
||||
|
||||
if (skipCopy)
|
||||
{
|
||||
// Texture supports stencil view, just use it directly
|
||||
if (readableDepthViewOut)
|
||||
{
|
||||
*readableDepthViewOut = srcTexture;
|
||||
}
|
||||
if (readableStencilViewOut)
|
||||
{
|
||||
*readableStencilViewOut = srcTexture;
|
||||
}
|
||||
*readableViewLevel = level;
|
||||
*readableViewLayer = slice;
|
||||
*readableViewArea = readArea;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(srcTexture->textureType() != MTLTextureType3D);
|
||||
|
||||
// Texture doesn't support stencil view or not shader readable, copy to an interminate
|
||||
// texture that supports stencil view and shader read.
|
||||
mtl::TextureRef formatableView = srcTexture->getReadableCopy(
|
||||
contextMtl, contextMtl->getBlitCommandEncoder(), level, slice,
|
||||
MTLRegionMake2D(readArea.x, readArea.y, readArea.width, readArea.height));
|
||||
|
||||
ANGLE_CHECK_GL_ALLOC(contextMtl, formatableView);
|
||||
|
||||
if (readableDepthViewOut)
|
||||
{
|
||||
*readableDepthViewOut = formatableView;
|
||||
}
|
||||
if (readableStencilViewOut)
|
||||
{
|
||||
*readableStencilViewOut = formatableView->getStencilView();
|
||||
}
|
||||
|
||||
*readableViewLevel = 0;
|
||||
*readableViewLayer = 0;
|
||||
*readableViewArea = gl::Rectangle(0, 0, readArea.width, readArea.height);
|
||||
}
|
||||
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
||||
angle::Result FramebufferMtl::prepareRenderPass(const gl::Context *context,
|
||||
mtl::RenderPassDesc *pDescOut)
|
||||
{
|
||||
|
||||
@@ -74,27 +74,12 @@ angle::Result RenderbufferMtl::setStorageImpl(const gl::Context *context,
|
||||
|
||||
if ((mTexture == nullptr || !mTexture->valid()) && (width != 0 && height != 0))
|
||||
{
|
||||
if (actualSamples == 1 || (mFormat.getCaps().resolve))
|
||||
if (actualSamples == 1)
|
||||
{
|
||||
ANGLE_TRY(mtl::Texture::Make2DTexture(
|
||||
contextMtl, mFormat, static_cast<uint32_t>(width), static_cast<uint32_t>(height), 1,
|
||||
/* renderTargetOnly */ false,
|
||||
/* allowFormatView */ mFormat.hasDepthAndStencilBits(), &mTexture));
|
||||
|
||||
// Use implicit resolve for depth stencil texture whenever possible. This is because
|
||||
// for depth stencil texture, if stencil needs to be blitted, a formatted clone has
|
||||
// to be created. And it is expensive to clone a multisample texture.
|
||||
if (actualSamples > 1)
|
||||
{
|
||||
// This format must supports implicit resolve
|
||||
ASSERT(mFormat.getCaps().resolve);
|
||||
|
||||
ANGLE_TRY(mtl::Texture::Make2DMSTexture(
|
||||
contextMtl, mFormat, static_cast<uint32_t>(width),
|
||||
static_cast<uint32_t>(height), actualSamples,
|
||||
/* renderTargetOnly */ true,
|
||||
/* allowFormatView */ mFormat.hasDepthAndStencilBits(), &mImplicitMSTexture));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -219,4 +204,4 @@ angle::Result RenderbufferMtl::initializeContents(const gl::Context *context,
|
||||
context, mTexture, mFormat,
|
||||
mtl::ImageNativeIndex::FromBaseZeroGLIndex(gl::ImageIndex::Make2D(0)));
|
||||
}
|
||||
}
|
||||
} // namespace rx
|
||||
|
||||
Reference in New Issue
Block a user