|
49 | 49 | /**************************************************************************/ |
50 | 50 |
|
51 | 51 | #import "metal_objects.h" |
| 52 | +#include <cstdint> |
52 | 53 |
|
53 | 54 | #import "metal_utils.h" |
54 | 55 | #import "pixel_formats.h" |
|
640 | 641 | // see: https://github.com/KhronosGroup/MoltenVK/blob/d20d13fe2735adb845636a81522df1b9d89c0fba/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm#L407 |
641 | 642 | } |
642 | 643 |
|
| 644 | + uint32_t depth_resolve_index = subpass.depth_stencil_resolve_reference.attachment; |
| 645 | + if (depth_resolve_index != RDD::AttachmentReference::UNUSED && fb_info.has_texture(depth_resolve_index)) { |
| 646 | + id<MTLTexture> resolve_tex = fb_info.get_texture(depth_resolve_index); |
| 647 | + CRASH_COND_MSG(!flags::all(pf.getCapabilities(resolve_tex.pixelFormat), kMTLFmtCapsResolve), "not implemented: unresolvable texture types"); |
| 648 | + } |
| 649 | + |
643 | 650 | render.end_encoding(); |
644 | 651 | } |
645 | 652 |
|
|
751 | 758 | MDAttachment const &attachment = pass.attachments[idx]; |
752 | 759 | id<MTLTexture> tex = fb.get_texture(idx); |
753 | 760 | ERR_FAIL_NULL_MSG(tex, "Frame buffer depth / stencil texture is null."); |
| 761 | + |
| 762 | + uint32_t depth_resolve_index = subpass.depth_stencil_resolve_reference.attachment; |
| 763 | + bool has_resolve = depth_resolve_index != RDD::AttachmentReference::UNUSED; |
| 764 | + bool can_resolve = true; |
| 765 | + if (has_resolve) { |
| 766 | + MTLRenderPassDepthAttachmentDescriptor *da = desc.depthAttachment; |
| 767 | + id<MTLTexture> resolve_tex = fb.get_texture(depth_resolve_index); |
| 768 | + can_resolve = flags::all(pf.getCapabilities(resolve_tex.pixelFormat), kMTLFmtCapsResolve); |
| 769 | + if (can_resolve) { |
| 770 | + da.resolveTexture = resolve_tex; |
| 771 | + } else { |
| 772 | + CRASH_NOW_MSG("unimplemented: using a texture format that is not supported for resolve"); |
| 773 | + } |
| 774 | + } |
| 775 | + |
754 | 776 | if (attachment.type & MDAttachmentType::Depth) { |
755 | 777 | MTLRenderPassDepthAttachmentDescriptor *da = desc.depthAttachment; |
756 | | - if (attachment.configureDescriptor(da, pf, subpass, tex, render.is_rendering_entire_area, false, false, false)) { |
| 778 | + if (attachment.configureDescriptor(da, pf, subpass, tex, render.is_rendering_entire_area, has_resolve, can_resolve, false)) { |
757 | 779 | da.clearDepth = render.clear_values[idx].depth; |
758 | 780 | } |
759 | 781 | } |
|
1727 | 1749 | flags::set(caps, kMTLFmtCapsDSAtt); |
1728 | 1750 | } |
1729 | 1751 |
|
| 1752 | + if (depth_stencil_resolve_reference.attachment == p_index) { |
| 1753 | + flags::set(caps, kMTLFmtCapsResolve); |
| 1754 | + } |
| 1755 | + |
1730 | 1756 | return caps; |
1731 | 1757 | } |
1732 | 1758 |
|
|
0 commit comments