From 6768ded895867ed366fd8b00ab6964c98cebaa00 Mon Sep 17 00:00:00 2001 From: Jason Fielder Date: Sat, 16 Mar 2024 20:16:37 +0100 Subject: [PATCH] Fix #118868: Metal render pass output for EEVEE Next Resolves render pass export for EEVEE Next on Metal. Reads from texture views was previously utilising the root texture rather than the view variant, resulting in views into texture arrays being incorrectly sampled. Authored by Apple: Michael Parkin-White Pull Request: https://projects.blender.org/blender/blender/pulls/119563 --- source/blender/gpu/metal/mtl_texture.mm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/metal/mtl_texture.mm b/source/blender/gpu/metal/mtl_texture.mm index 08097e81e70..a3d3265d53d 100644 --- a/source/blender/gpu/metal/mtl_texture.mm +++ b/source/blender/gpu/metal/mtl_texture.mm @@ -1689,11 +1689,16 @@ void gpu::MTLTexture::read_internal(int mip, * happen after work with associated texture is finished. */ GPU_finish(); - /* Texture View for SRGB special case. */ + /** Determine source read texture handle. */ id read_texture = texture_; + /* Use textureview handle if reading from a GPU texture view. */ + if (resource_mode_ == MTL_TEXTURE_MODE_TEXTURE_VIEW) { + read_texture = this->get_metal_handle(); + } + /* Create Texture View for SRGB special case to bypass internal type conversion. */ if (format_ == GPU_SRGB8_A8) { BLI_assert(gpu_image_usage_flags_ & GPU_TEXTURE_USAGE_FORMAT_VIEW); - read_texture = [texture_ newTextureViewWithPixelFormat:MTLPixelFormatRGBA8Unorm]; + read_texture = [read_texture newTextureViewWithPixelFormat:MTLPixelFormatRGBA8Unorm]; } /* Perform per-texture type read. */