mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-03 02:35:55 +00:00
For the textures got from Metal swap chain, their "framebufferOnly" may be true, which means they can only be used as attachments in a render pass, and they are not allowed to be used in MTLRenderCommandEncoder, MTLBlitCommandEncoder or MTLComputeCommandEncoder. So currently Dawn examples all crash when METAL_DEVICE_WRAPPER_TYPE = 1 is set into environmental variables. This patch adds checks on the situations that we do not need to create a Metal texture view: 1. We create Metal texture only when the usage of the texture includes Sampled or Storage. 2. We won't create Metal texture view if the view uses the same format as the original texture, the whole mipmap levels and array slices. 3. We use the original MTLTexture and set the slice and level in MTLRenderPassDescriptor. Furthermore, with this patch, "setFramebufferOnly" is set to true only when the usage passed to configure is a subset of (OutputAttachment | Present). BUG=dawn:69 Change-Id: Ie2670f383c16eafa3b1c6f99126922e940721174 Reviewed-on: https://dawn-review.googlesource.com/c/3400 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>