Skip to content

Feature: Implement Metal backend for macOS/iOS GPU support#25

Merged
qian-o merged 147 commits into
masterfrom
feature/metal-backend
Mar 31, 2026
Merged

Feature: Implement Metal backend for macOS/iOS GPU support#25
qian-o merged 147 commits into
masterfrom
feature/metal-backend

Conversation

@qian-o

@qian-o qian-o commented Mar 31, 2026

Copy link
Copy Markdown
Owner

This pull request introduces several improvements and updates across the documentation, tutorials, and project configuration. The main themes are enhanced memory layout documentation for struct types, improved mesh shading and ray tracing tutorial accuracy, updates to documentation navigation and API presentation, and dependency version bumps.

Key changes:

Memory Layout and Struct Improvements in Tutorials

  • Updated all C# struct definitions in the tutorials (spinning-cube.md, indirect-drawing.md, mesh-shading.md, ray-tracing.md) to use [StructLayout(LayoutKind.Explicit, Size = ...)] and explicit field offsets, ensuring correct memory alignment for interop and GPU usage. This includes new or updated definitions for Vertex, Triangle, Meshlet, TransformConstants, MVPConstants, InstanceData, ViewConstants, and Sphere. [1] [2] [3] [4] [5] [6]

  • Refactored mesh shading and ray tracing shader code and C# examples to use new struct layouts, including switching from flat index arrays to a Triangle struct for mesh indices and updating property accessors. [1] [2] [3] [4] [5] [6] [7]

Mesh Shading and Ray Tracing Tutorial Corrections

  • Corrected naming and usage in mesh and amplification shaders (e.g., groupIdgroupID, groupThreadIdgroupThreadID) for consistency and accuracy. [1] [2] [3]

  • Updated ray tracing instance descriptor field names from InstanceID/InstanceMask to ID/Mask for clarity and alignment with API changes. [1] [2]

Documentation and API Presentation Improvements

  • Added homepage fields to the documentation table of contents for better navigation.

  • Enhanced API documentation presentation by hiding inherited, protected, and override members, and removing empty section headers via new logic in main.js.

Project and Dependency Updates

  • Updated NuGet package dependencies, including bumping Avalonia, Microsoft.Maui.Controls, and Microsoft.WindowsAppSDK, and adding Metal.NET.

  • Modified the solution file to add the CornellBox experiment and remove the SponzaScene project.


References:

Updated Microsoft.Maui.Controls to 10.0.41 and Slangc.NET to 2026.3.1. Added Metal.NET (1.0.4) to solution packages and referenced it directly in the Zenith.NET.Metal project.
Specified index.md as the homepage for Docs, Tutorials, and API sections in toc.yml to improve navigation and section landing pages.
Add Metal.NET support to Zenith.NET with MTLGraphicsContext, which now manages the system default Metal device and checks for Metal 4 support. Introduce MTLCapabilities to expose device features such as name, ray tracing, and mesh shading support. Ensure proper disposal of the Metal device and update code to use Metal.NET types throughout.
Updated Metal.NET package to version 1.0.5. Removed unnecessary null-forgiving operators from Metal device property initializations in MTLCapabilities.cs and MTLGraphicsContext.cs, reflecting improved nullability guarantees in the updated package.
Bump the Metal.NET package version from 1.0.5 to 1.1.0 in Directory.Packages.props to incorporate the latest features and fixes. No other dependencies were changed.
Switched macOS graphics context from Vulkan to Metal with validation layers enabled. Updated swap chain surface creation to use Surface.Apple for macOS, removing platform checks and fallback exception. Imported Metal namespace for proper support.
Introduces Metal 4 support with updated MTLGraphicsContext to manage device, residency set, and command queues. Adds allocation management and proper resource disposal. Implements MTLCommandQueue and MTLFence for queue logic and synchronization. Improves error handling with NSError extension. Lays foundation for Metal 4 backend integration.
Simplified the process of adding residency sets to command queues by removing redundant lines and consolidating the logic. Also removed explicit RemoveResidencySet calls in Destroy(), relying on Dispose() for cleanup. This reduces code duplication and streamlines resource management.
Introduce MTLHeap for Metal heap management with stubbed constructors. Change key MTLGraphicsContext properties to public fields. Add global using aliases for Metal.NET buffer, heap, and texture types.
Implemented MTLHeap resource allocation for buffers and textures using Metal.NET APIs, replacing previous NotImplementedExceptions. Added MTLFormats.cs with helper methods to map Zenith.NET graphics enums to Metal types, including detailed pixel format and usage flag conversions. Updated MTLHeap to use these helpers for all Metal-specific type translations.
Introduce internal MTLBuffer and MTLTexture classes in the Zenith.NET.Metal namespace. These classes wrap Metal buffer and texture resources, manage their lifecycles, and provide .NET abstractions for resource creation, mapping, naming, and disposal. This enhances Metal-specific resource management within the framework.
Implemented CreateBufferImpl and CreateTextureImpl to return
MTLBuffer and MTLTexture instances, replacing the previous
NotImplementedException. This enables actual buffer and texture
object creation within the Metal graphics context.
Introduce internal extension methods to cast Buffer to MTLBuffer and Texture to MTLTexture, enabling easier access to underlying Metal objects.
Reordered property assignments in MTLHeapDescriptor and MTLTextureDescriptor initializations for both buffer and texture heap creation. ResourceOptions is now set before Size, and Usage is set after ResourceOptions for clarity and consistency. No functional changes were made.
Implemented MTLBufferView and MTLTextureView classes for Metal-specific buffer and texture view handling. Updated Extensions with Metal() methods for BufferView and TextureView. MTLGraphicsContext now creates Metal views instead of throwing exceptions. Refined MTLHeap resource creation logic. These changes improve compatibility and resource management in the Metal backend.
Implement MTLShader and MTLSampler classes for Metal API integration. Update MTLGraphicsContext to create Metal-specific shader and sampler objects. Add enum conversion helpers to MTLFormats for sampler descriptor construction. Provide internal extension methods for safe casting to Metal types.
Upgraded Metal.NET from 1.1.0 to 1.2.0 in Directory.Packages.props.
No other package versions were modified.
Replaced NotImplementedException in MTLShader constructor with logic to create a DispatchData from shader bytes and initialize the Metal library using context.Device.NewLibrary. Errors are checked and the library is stored in the Library field.
Upgraded the Metal.NET NuGet package from 1.2.0 to 1.3.1 in Directory.Packages.props to ensure compatibility with the latest features and bug fixes. No other package changes were made.
Refactored MTLShader to call DispatchData.Create with only desc.ShaderBytes, relying on default parameters. Removed the temporary dispatchData variable and its using statement, passing the result directly to NewLibrary for improved code clarity.
Implement MTLFrameBuffer to support Metal framebuffers using Metal.NET.
Update MTLGraphicsContext to instantiate MTLFrameBuffer.
Add FrameBuffer.Metal() extension for easy access to Metal internals.
Introduces MTLSwapChain and MTLSwapChainFrameBuffer classes to manage Metal-based swap chain creation, presentation, and resizing using CAMetalLayer and CAMetalDrawable. Updates MTLFrameBuffer to properly dispose of its Descriptor. These changes enable Metal-backed rendering and presentation in Zenith.NET with correct resource management.
Implemented CreateSwapChainImpl in MTLGraphicsContext to return a new MTLSwapChain instance. Added a Metal() extension method for SwapChain to enable casting to MTLSwapChain.
Introduced MTLResourceLayout class to track buffer, texture, and sampler counts from ResourceLayoutDesc. Updated MTLGraphicsContext to instantiate MTLResourceLayout. Added Metal() extension method for ResourceLayout casting. Stubbed SetResourceName and Destroy methods.
Implemented MTLResourceTable for Metal backend, mapping high-level resource bindings to Metal argument tables. GraphicsContext now creates MTLResourceTable instances. Added internal Metal() extension for accessing the underlying Metal resource table.
Replaced temporary lists with direct array assignment for buffer, texture, and sampler bindings in MTLResourceTable. This streamlines initialization, improves efficiency, and uses Metal-specific layout for binding iteration.
Refactored MTLResourceTable constructor to initialize MTL4ArgumentTableDescriptor and ArgumentTable before resource binding. Descriptor now uses layout counts directly. Removed redundant initialization code at the end of the constructor.
Upgraded the Slangc.NET package from 2026.3.1 to 2026.4.0 in Directory.Packages.props to ensure compatibility with the latest features and improvements.
Upgraded the Microsoft.Maui.Controls NuGet package from 10.0.41 to 10.0.50 in Directory.Packages.props to ensure compatibility with the latest features and bug fixes.
Standardize shader compilation arguments by always adding "-target" before backend-specific options. Adjust argument order for DirectX12, Metal, and Vulkan, update Metal and Vulkan profiles, and remove "-fvk-use-dx-layout" for Vulkan.
qian-o added 18 commits March 29, 2026 19:45
Previously, texture bindings were removed before texture view bindings when deleting a texture ID. This change reverses the order, removing texture view bindings first to ensure correct cleanup. The removal logic for each binding remains the same.
Introduce an abstract Renderer base class to unify and encapsulate common rendering logic, including framebuffer and resource management. Remove the IRenderer interface; both PathTracingRenderer and RasterizationRenderer now inherit from Renderer and implement its abstract methods. Update App and ImGui logic to use the new Renderer abstraction and simplify renderer switching and resizing. Clean up redundant code and ensure proper resource disposal throughout.
Scaled background image rendering in ImGui to account for DPI,
ensuring proper display on high-DPI screens. Switched depth-stencil
texture format from D24UNormS8UInt to D32FloatS8UInt for improved
depth precision in the renderer.
Replaces PackedVertex with a 28-byte Vertex struct using explicit Vector3 and uint fields for position, normal, and material ID. Material struct now uses Vector3 albedo and float emission. Updates all geometry generation, buffer uploads, and shaders to match new layouts, removing bit-packing. Refactors camera and lighting constant buffers to use Vector3 fields for clarity. Updates documentation and all usages to reflect new conventions, improving code clarity and GPU interop.
Updated VSInput struct to make fields private and added properties for Position, Normal, and MaterialID. Updated VSMain to use these properties, improving code readability, encapsulation, and type safety.
- Refactored App.cs render loop: ImGui UI and renderer logic are now clearly separated; ImGui handles swap chain clear and UI, renderer writes to its own color texture.
- Updated renderer switching and update order for correctness.
- Replaced IRenderer interface with abstract Renderer base class managing Color/Depth/FrameBuffer and resource lifecycle.
- Expanded and clarified CONVENTIONS.md:
    - Detailed struct layout/alignment rules for C# and Slang.
    - Documented both path tracing and rasterization renderer architectures, resource bindings, and algorithms.
    - Updated vertex struct to 32B (float4+float4) with explicit FieldOffsets.
    - InputLayout now matches Slang vertex input (float4s).
- Removed redundant null-forgiving operator in PathTracingRenderer.
- Documentation and code are now tightly aligned for both rendering modes.
- Clarified render loop steps and ImGui responsibilities in English
- Made CameraParams.PositionAndPadding private for encapsulation
- Expanded path tracer resource layout: added vertex/index buffers
- Updated binding order and resource table to match shader layout
- Documented direct compute output to Color texture (no CopyTexture)
- Revised resize/disposal patterns: Color handled by base, only accumTexture recreated/disposed in path tracer
- Improved clarity and consistency throughout the documentation
Renamed the constant MaxInstanceId to MaxRayTracingInstanceID in ValidationConstants for improved clarity and consistency. Updated all related validation logic to use the new name. The constant's value remains unchanged.
Renamed groupId/groupThreadId to groupID/groupThreadID in mesh
and amplification shader code and docs for consistency. Also
removed the Id attribute from the CornellBox project entry in
Zenith.NET.slnx to standardize project references.
- Extended Material struct (Slang/HLSL & C#) with metallic and roughness fields, updated alignment and packing conventions.
- Added GGX microfacet BRDF and importance sampling to path tracer.
- Updated direct lighting to use full BRDF, not just Lambertian.
- Materials array now supports six materials with varied PBR properties; short/tall blocks use new indices.
- Updated throughput and PDF handling for correct energy conservation; clamped output to reduce fireflies.
- Synced RasterizationRenderer's Material struct for consistency.
Updated both path tracing and rasterization renderers to use a hemispherical ambient lighting model. The path tracer now blends between ground and sky colors based on ray direction when no geometry is hit. The rasterizer interpolates ambient intensity based on the surface normal's Y component, providing more realistic ambient illumination.
- Apply ACES tonemapping to both path tracing and rasterization for more filmic color output.
- Clamp material roughness to a minimum of 0.04 in path tracing to improve stability and realism.
- Increase path tracing bounce count from 5 to 8 for better global illumination.
- Change rasterization framebuffer clear color to a light grayish-blue for a more neutral background.
Expanded CONVENTIONS.md to document major renderer upgrades:
- Path tracer now uses Cook-Torrance PBR BRDF (GGX, Schlick Fresnel, Smith G), GGX importance sampling, sky environment, 8 bounces, and per-sample clamping.
- Rasterization mode now features hemisphere ambient and ACES tonemapping.
- Material struct expanded to 32 bytes (adds metallic, roughness).
- Cornell Box geometry updated: 6 material groups, PBR block properties, light emission increased.
- Renderer base class is now abstract; file structure and resource layouts updated.
- Shader resource bindings and clear values revised to match new implementation.
- Updated current state date to 2026-03-30.
Introduce NSAutoreleasePool.Run<T> extension to simplify and standardize autorelease pool usage when creating Metal objects. Refactor code to use this method for command buffers, encoders, and drawables, ensuring proper memory management and improved readability. Retain created objects to maintain validity after pool disposal.
Replace NSAutoreleasePool.Run with a new NSAutorelease static class providing generic Retain methods for Metal objects. Update all relevant usages in MTLCommandBuffer, MTLCommandEncoder, and MTLSwapChain to use this new pattern. Remove the obsolete extension and inline AcquireNextDrawable logic. This improves memory management, code clarity, and reduces repetition.
Renamed NSAutorelease.Retain methods to Own and updated all usages in the Metal backend (MTLCommandBuffer, MTLCommandEncoder, MTLSwapChain) to use Own. This clarifies ownership semantics, making it explicit that the caller is responsible for disposing of the returned objects. No changes to the underlying implementation logic.
Updated material property initializations in CornellBoxGeometry to use consistent two-decimal float formatting (e.g., 0.00f, 0.90f). No changes to values or logic—only improved code clarity and consistency.
Copilot AI review requested due to automatic review settings March 31, 2026 02:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Metal backend (macOS/iOS GPU support) and updates core texture upload/copy logic to better handle block-compressed formats across backends. It also refreshes tutorials/docs and pivots the experiments set by adding CornellBox while removing the SponzaScene experiment from the solution and deleting its code/shaders.

Changes:

  • Implement Metal backend project (Zenith.NET.Metal) including context, pipelines, resources, swap chain, and ray tracing AS support.
  • Refactor texture upload/copy paths to use block layout calculations (BC/ETC2/ASTC) and update validation/constants and renamed fields.
  • Replace the SponzaScene experiment with a new CornellBox experiment; update docs/tutorials and doc-site presentation.

Reviewed changes

Copilot reviewed 108 out of 186 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Zenith.NET.slnx Adds CornellBox experiment to the solution and removes SponzaScene from the solution folder.
sources/Zenith.NET/ZenithHelper.cs Introduces BlockLayout() helper and reorganizes depth/stencil helpers for format handling.
sources/Zenith.NET/ValidationLayer.cs Updates validation messages/fields for mesh shading amplification sizes and ray tracing instance ID naming.
sources/Zenith.NET/Texture.cs Simplifies texture Upload() call path (now delegates to command buffer without size checks).
sources/Zenith.NET/Structs/RayTracingInstance.cs Renames instance fields to ID and Mask.
sources/Zenith.NET/Structs/MeshShadingPipelineDesc.cs Renames amplification threadgroup size fields for clarity/consistency.
sources/Zenith.NET/CommandBuffer.cs Refactors buffer/texture upload logic to operate on byte spans and block layout row/depth pitches.
sources/Zenith.NET.Vulkan/VKTopLevelAccelerationStructure.cs Updates Vulkan TLAS instance field mappings to renamed ID/Mask.
sources/Zenith.NET.Vulkan/VKGraphicsPipeline.cs Minor variable rename in vertex input loop for clarity.
sources/Zenith.NET.Vulkan/VKFrameBuffer.cs Renames attachment transition helpers to PrepareAttachments / PresentColorAttachments.
sources/Zenith.NET.Vulkan/VKCommandBuffer.cs Updates buffer-texture copy pitch math to use block layout for compressed formats and uses renamed framebuffer helpers.
sources/Zenith.NET.Metal/Zenith.NET.Metal.csproj Adds Metal.NET dependency for the new backend project.
sources/Zenith.NET.Metal/Usings.cs Adds global type aliases for Metal resource types used throughout the backend.
sources/Zenith.NET.Metal/NSAutorelease.cs Adds helper wrappers for autorelease pool ownership/retain patterns.
sources/Zenith.NET.Metal/MTLTopLevelAccelerationStructure.cs Adds Metal TLAS implementation using indirect instance descriptors and refit support.
sources/Zenith.NET.Metal/MTLTextureView.cs Adds Metal texture view implementation (view creation via MakeTextureView).
sources/Zenith.NET.Metal/MTLTexture.cs Adds Metal texture wrapper with heap-backed creation and swapchain-wrapped construction.
sources/Zenith.NET.Metal/MTLSwapChainFrameBuffer.cs Adds swapchain framebuffer caching/recreation logic for Metal drawables.
sources/Zenith.NET.Metal/MTLSwapChain.cs Adds Metal swapchain implementation backed by CAMetalLayer and drawable presentation.
sources/Zenith.NET.Metal/MTLShader.cs Adds Metal shader/library loading from compiled bytes.
sources/Zenith.NET.Metal/MTLSampler.cs Adds Metal sampler state creation mapping engine sampler desc to Metal.
sources/Zenith.NET.Metal/MTLResourceTable.cs Adds Metal resource table binding via Metal argument tables and resource IDs/addresses.
sources/Zenith.NET.Metal/MTLResourceLayout.cs Adds Metal resource layout counting logic for argument table sizing.
sources/Zenith.NET.Metal/MTLQueryHeap.cs Adds Metal timestamp query heap backed by counter heap + readback buffer.
sources/Zenith.NET.Metal/MTLMeshShadingPipeline.cs Adds Metal mesh shading pipeline construction and render state mapping.
sources/Zenith.NET.Metal/MTLHeap.cs Adds heap-backed buffer/texture allocation and residency set tracking.
sources/Zenith.NET.Metal/MTLGraphicsPipeline.cs Adds Metal graphics pipeline creation including vertex descriptor configuration.
sources/Zenith.NET.Metal/MTLGraphicsContext.cs Implements Metal graphics context initialization, queues, compiler/residency set, and resource factories.
sources/Zenith.NET.Metal/MTLFrameBuffer.cs Adds Metal framebuffer wrapper building an MTL4RenderPassDescriptor from attachments.
sources/Zenith.NET.Metal/MTLFence.cs Adds shared-event-based fence used for queue idle waits.
sources/Zenith.NET.Metal/MTLComputePipeline.cs Adds Metal compute pipeline creation via compiler.
sources/Zenith.NET.Metal/MTLCommandQueue.cs Adds Metal command queue wrapper integrating with engine submit/wait model.
sources/Zenith.NET.Metal/MTLCapabilities.cs Exposes Metal device capability flags (ray tracing, mesh shading, device name).
sources/Zenith.NET.Metal/MTLBufferView.cs Adds Metal buffer view wrapper exposing GPU address + offset.
sources/Zenith.NET.Metal/MTLBuffer.cs Adds Metal buffer wrapper with mapping support and heap-backed allocation.
sources/Zenith.NET.Metal/MTLBottomLevelAccelerationStructure.cs Adds Metal BLAS implementation building triangle/AABB geometries and scratch resources.
sources/Zenith.NET.Metal/Extensions.cs Adds Metal backend factory and a shared error helper plus per-type .Metal() cast helpers.
sources/Zenith.NET.DirectX12/DXTopLevelAccelerationStructure.cs Updates DX12 TLAS instance fields to renamed ID/Mask.
sources/Zenith.NET.DirectX12/DXGraphicsPipeline.cs Moves primitive topology type assignment into PSO initialization.
sources/Zenith.NET.DirectX12/DXFrameBuffer.cs Renames attachment transition helpers to PrepareAttachments / PresentColorAttachments.
sources/Zenith.NET.DirectX12/DXFormats.cs Relocates/keeps primitive topology mapping helper in a new region (no behavioral change intended).
sources/Zenith.NET.DirectX12/DXCommandBuffer.cs Updates buffer-texture copy to consider block layout and adjusts framebuffer helper names.
sources/Extensions/Zenith.NET.Extensions.Slang/Extensions.cs Updates Slang compiler arguments for backend targets/capabilities and target selection structure.
sources/Experiments/SponzaScene/Renderer/Passes/VolumetricLightPass.cs Removes SponzaScene volumetric lighting pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/VolumetricLightBlurPass.cs Removes SponzaScene volumetric blur pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/SVGFTemporalPass.cs Removes SponzaScene SVGF temporal pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/SVGFAtrousPass.cs Removes SponzaScene SVGF a-trous pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/RTGIPass.cs Removes SponzaScene RTGI pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/RenderPass.cs Removes SponzaScene render pass base + binding index helper logic.
sources/Experiments/SponzaScene/Renderer/Passes/LightingPass.cs Removes SponzaScene deferred lighting pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/GTAOPass.cs Removes SponzaScene GTAO pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/GTAOBlurPass.cs Removes SponzaScene GTAO blur pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/GBufferPass.cs Removes SponzaScene G-buffer pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/FullscreenPass.cs Removes SponzaScene fullscreen compute pass base.
sources/Experiments/SponzaScene/Renderer/Passes/CSMPass.cs Removes SponzaScene cascaded shadow map pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/ComposePass.cs Removes SponzaScene final compose pass implementation.
sources/Experiments/SponzaScene/Renderer/Passes/BloomPass.cs Removes SponzaScene bloom pass implementation.
sources/Experiments/SponzaScene/Renderer/DeferredRenderer.cs Removes SponzaScene deferred renderer orchestration.
sources/Experiments/SponzaScene/Program.cs Removes SponzaScene entrypoint.
sources/Experiments/SponzaScene/Models/Vertex.cs Removes SponzaScene vertex model struct.
sources/Experiments/SponzaScene/Models/PointLight.cs Removes SponzaScene point light model struct.
sources/Experiments/SponzaScene/Models/Node.cs Removes SponzaScene node model struct.
sources/Experiments/SponzaScene/Models/Material.cs Removes SponzaScene material loader/model implementation.
sources/Experiments/SponzaScene/Models/DirectionalLight.cs Removes SponzaScene directional light model struct.
sources/Experiments/SponzaScene/Models/CSMData.cs Removes SponzaScene CSM data struct.
sources/Experiments/SponzaScene/Helpers/ImGuiHelper.cs Removes SponzaScene ImGui helper utilities.
sources/Experiments/SponzaScene/Assets/Shaders/VolumetricLightBlur.slang Removes SponzaScene shader source (volumetric blur).
sources/Experiments/SponzaScene/Assets/Shaders/VolumetricLight.slang Removes SponzaScene shader source (volumetric light).
sources/Experiments/SponzaScene/Assets/Shaders/SVGFTemporal.slang Removes SponzaScene shader source (SVGF temporal).
sources/Experiments/SponzaScene/Assets/Shaders/SVGFAtrous.slang Removes SponzaScene shader source (SVGF a-trous).
sources/Experiments/SponzaScene/Assets/Shaders/slangdconfig.json Removes SponzaScene slangd configuration file.
sources/Experiments/SponzaScene/Assets/Shaders/GTAOBlur.slang Removes SponzaScene shader source (GTAO blur).
sources/Experiments/SponzaScene/Assets/Shaders/GTAO.slang Removes SponzaScene shader source (GTAO).
sources/Experiments/SponzaScene/Assets/Shaders/GBuffer.slang Removes SponzaScene shader source (GBuffer).
sources/Experiments/SponzaScene/Assets/Shaders/CSM.slang Removes SponzaScene shader source (CSM).
sources/Experiments/SponzaScene/Assets/Shaders/Compose.slang Removes SponzaScene shader source (compose).
sources/Experiments/SponzaScene/Assets/Shaders/Bloom.slang Removes SponzaScene shader source (bloom).
sources/Experiments/SponzaScene/App.cs Removes SponzaScene application bootstrap.
sources/Experiments/Directory.Packages.props Removes SharpGLTF.Toolkit dependency from experiments package set.
sources/Experiments/CornellBox/Renderers/Renderer.cs Adds renderer base that manages per-renderer targets/framebuffer lifecycle.
sources/Experiments/CornellBox/Renderers/RasterizationRenderer.cs Adds CornellBox raster renderer with explicit struct layouts and inline shader source.
sources/Experiments/CornellBox/Properties/launchSettings.json Renames launch profiles from SponzaScene to CornellBox.
sources/Experiments/CornellBox/Program.cs Adds CornellBox entrypoint.
sources/Experiments/CornellBox/Helpers/Extensions.cs Adds ImGui overlay helper for CornellBox experiment.
sources/Experiments/CornellBox/Helpers/CornellBoxGeometry.cs Adds CornellBox geometry + explicitly laid-out vertex/material structs.
sources/Experiments/CornellBox/Helpers/CocoaHelper.cs Moves Cocoa layer creation helper into CornellBox namespace.
sources/Experiments/CornellBox/Helpers/BindingHelper.cs Adds backend-specific resource binding index assignment helper.
sources/Experiments/CornellBox/Handlers/ImGuiHandler.cs Adds Silk.NET input bindings integration for ImGui controller.
sources/Experiments/CornellBox/Handlers/CameraHandler.cs Adds camera input handler (renamed from prior experiment controller).
sources/Experiments/CornellBox/CornellBox.csproj Removes unused ImageSharp/SharpGLTF dependencies and keeps core experiment references.
sources/Experiments/CornellBox/Assets/Shaders/.clang-format Adds formatting configuration for embedded shader code assets.
sources/Experiments/CornellBox/App.cs Adds CornellBox app bootstrap selecting backend per OS (DX12/Vulkan/Metal) and renderer mode.
sources/Directory.Packages.props Bumps package versions and adds Metal.NET + updates Slangc.NET version.
documents/tutorials/intermediate/indirect-drawing.md Updates tutorial structs to explicit layout/size for correct interop alignment.
documents/tutorials/getting-started/spinning-cube.md Updates MVP constants structs to explicit layout/size in tutorial snippets.
documents/tutorials/advanced/ray-tracing.md Updates tutorial shader/C# structs for alignment, and renames instance fields to ID/Mask.
documents/toc.yml Adds homepage metadata entries to improve docs navigation.
documents/templates/public/main.js Adds JS logic to hide inherited/protected/override API members and remove empty headers in generated docs.
documents/images/Zenith.NET.svg Updates icon artwork (new “liquid glass” style).
documents/images/Zenith.NET-Logo.svg Updates logo artwork and viewbox/text styling.
Comments suppressed due to low confidence (1)

sources/Zenith.NET/Texture.cs:19

  • Texture.Upload now only checks for empty data and delegates to a command buffer without validating that data length matches extent/format. This weakens the public API contract: callers can accidentally upload incorrect sizes and get runtime exceptions or corrupted texture contents. Consider adding argument validation here (or in CommandBuffer.Upload) so invalid uploads fail fast with a clear error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sources/Zenith.NET/CommandBuffer.cs
Comment thread sources/Zenith.NET.DirectX12/DXCommandBuffer.cs
Comment thread sources/Zenith.NET.Metal/MTLTextureView.cs
Comment thread sources/Zenith.NET.Metal/Extensions.cs
Comment thread sources/Zenith.NET.Metal/MTLTopLevelAccelerationStructure.cs
Comment thread sources/Zenith.NET.Metal/MTLTopLevelAccelerationStructure.cs
Comment thread sources/Zenith.NET.Metal/MTLGraphicsContext.cs
qian-o added 6 commits March 31, 2026 10:51
Explicitly dispose of Texture in MTLTextureView.Destroy().
Add MTLGraphicsContext property to MTLTopLevelAccelerationStructure.
Ensure acceleration structure allocations are removed from context
before disposal to prevent resource leaks.
Upgraded the Metal.NET package from version 2.2.1 to 2.3.0 in Directory.Packages.props to incorporate the latest features and fixes. No other dependencies were changed.
Eliminated the Silk.NET.MoltenVK.Native dependency from both Directory.Packages.props and Zenith.NET.Vulkan.csproj. The project no longer relies on MoltenVK native bindings for Vulkan via Silk.NET.
Changed the default value of the generateMipMaps parameter in
LoadTextureFromStream from false to true, so mipmaps are now
generated by default when loading textures from a stream.
Upgraded the Slangc.NET NuGet package from version 2026.5.1 to 2026.5.2 in Directory.Packages.props to include the latest fixes and improvements. No other dependencies were changed.

@qian-o qian-o left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

@qian-o qian-o merged commit 76a7407 into master Mar 31, 2026
2 checks passed
@qian-o qian-o deleted the feature/metal-backend branch March 31, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants