Fix crash in Metal backend with screen-space refractions (#2104)

This commit is contained in:
Ben Doherty
2020-02-10 10:34:44 -08:00
committed by GitHub
parent 8f2df79a96
commit 48ba111ccc
2 changed files with 9 additions and 0 deletions

View File

@@ -850,6 +850,9 @@ void MetalDriver::blit(TargetBufferFlags buffers,
id<MTLTexture> srcTexture = srcTarget->getBlitColorSource();
id<MTLTexture> dstTexture = dstTarget->getColor();
ASSERT_PRECONDITION(srcTexture != nil && dstTexture != nil,
"Source texture and destination texture must not be nil");
// Metal's texture coordinates have (0, 0) at the top-left of the texture, but Filament's
// coordinates have (0, 0) at bottom-left.
MTLRegion srcRegion = MTLRegionMake2D(

View File

@@ -441,6 +441,9 @@ id<MTLTexture> MetalRenderTarget::getDepthResolve() {
}
id<MTLTexture> MetalRenderTarget::getBlitColorSource() {
if (defaultRenderTarget) {
return acquireDrawable(context);
}
if (color) {
return color;
}
@@ -448,6 +451,9 @@ id<MTLTexture> MetalRenderTarget::getBlitColorSource() {
}
id<MTLTexture> MetalRenderTarget::getBlitDepthSource() {
if (defaultRenderTarget) {
return acquireDepthTexture(context);
}
if (depth) {
return depth;
}