Metal: Refactor; fix dynamic uniforms; acyclic render graph support #114484
+2,857
−1,595
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a major refactoring of the Metal rendering driver with three key improvements:
1. Architecture Refactoring
The primary purpose of these changes were to separate common code that can be shared with Metal 3 and Metal 4. I have a complete Metal 4 renderer working with this branch to prove the refactoring is complete.
metal_objects.h/mm→metal3_objects.h/mmand extracted shared code into newmetal_objects_shared.h/mmMTL3::RenderingDeviceDriverMetalclassMDCommandBuffernow inherits fromMDCommandBufferBasewith virtual methods for polymorphic dispatch to Metal 3 and Metal 4 in the future.MDRenderPass,MDAttachment,MDSubpass,MDFrameBuffer, shaders, pipelines) moved to shared header for reusebind_uniforms_argument_buffersmoved fromMDUniformSettoMDCommandBuffer, which is Metal 3 specific2. Dynamic Uniforms Fix
A hack was implemented to disable argument buffers (and use slot binding) when a shader used dynamic uniforms. This has been resolved with this update.
MDRingBufferclass for efficient transient GPU memory allocations (16-byte aligned, 64KB default segments)MTLGPUAddressfor argument buffer updates instead of per-frame buffer copies using slot binding, which was a hack.3. Acyclic Render Graph Support
Important
ARG is opt-in by enabling the
rendering/rendering_device/metal3/enable_pipeline_barriersproject settings.Explicit synchronization: Added
pipeline_barrier()implementation that tracks pending stages across render/compute/blit encodersAdditional Changes