From b1563dabe9b6f1a0434e0ea2ff7be5ff259ed2e4 Mon Sep 17 00:00:00 2001 From: Ben Doherty Date: Fri, 29 May 2020 16:08:47 -0700 Subject: [PATCH] Metal: use render target height to adjust viewport when blitting (#2610) --- RELEASE_NOTES.md | 1 + filament/backend/src/metal/MetalDriver.mm | 4 ++-- shaders/src/post_process.vs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a8f5402e19..46fe4bb29c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -11,6 +11,7 @@ A new header is inserted each time a *tag* is created. - SSAO now has an optional high(er) quality upsampler. - Tone mappping now uses the real ACES tone mapper, applied in the proper color space. - Tone mapping is now applied via a LUT, which will later enable color grading capabilities. +- Fixed bug in the Metal backend when SSR and MSAA were turned on - Fixed Metal issue with `BufferDescriptor` and `PixelBufferDescriptor`s not being called on application thread. ## v1.7.0 diff --git a/filament/backend/src/metal/MetalDriver.mm b/filament/backend/src/metal/MetalDriver.mm index 8e373b36cf..cdfcf91e9d 100644 --- a/filament/backend/src/metal/MetalDriver.mm +++ b/filament/backend/src/metal/MetalDriver.mm @@ -931,12 +931,12 @@ void MetalDriver::blit(TargetBufferFlags buffers, // coordinates have (0, 0) at bottom-left. MTLRegion srcRegion = MTLRegionMake2D( (NSUInteger) srcRect.left, - srcTexture.height - (NSUInteger) srcRect.bottom - srcRect.height, + srcTarget->height - (NSUInteger) srcRect.bottom - srcRect.height, srcRect.width, srcRect.height); MTLRegion dstRegion = MTLRegionMake2D( (NSUInteger) dstRect.left, - dstTexture.height - (NSUInteger) dstRect.bottom - dstRect.height, + dstTarget->height - (NSUInteger) dstRect.bottom - dstRect.height, dstRect.width, dstRect.height); const uint8_t srcLevel = srcColorAttachment.level; diff --git a/shaders/src/post_process.vs b/shaders/src/post_process.vs index 1763957427..644b4a64de 100644 --- a/shaders/src/post_process.vs +++ b/shaders/src/post_process.vs @@ -8,7 +8,7 @@ void main() { // In Vulkan and Metal, texture coords are Y-down. In OpenGL, texture coords are Y-up. #if defined(TARGET_METAL_ENVIRONMENT) || defined(TARGET_VULKAN_ENVIRONMENT) - inputs.texelCoords.y = frameUniforms.resolution.y - 1.0 - inputs.texelCoords.y; + inputs.texelCoords.y = frameUniforms.resolution.y - inputs.texelCoords.y; inputs.normalizedUV.y = 1.0 - inputs.normalizedUV.y; #endif