Fix crash in Metal backend with screen-space refractions (#2104)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user