Skip to content

Proposal: Move ZenithCompiler.cs to a separate Zenith.NET.Shader project to decouple runtime from Slangc.Net #29

Description

@dooogee

Feature Description

Description
Currently, ZenithCompiler.cs resides directly in the core project, and the core project has a dependency on slangc.net (the .NET binding for the Slang compiler). This means that any project using the Zenith.NET core runtime (e.g., a game's release build) must carry the compiler SDK dependency.

Proposed Improvement
I suggest extracting all shader compilation-related code (including ZenithCompiler.cs and associated compilation logic) from the core project and moving it into a new, separate project called Zenith.NET.Shader.

Benefits of This Change

  1. Clear Separation of Concerns: The core project would focus on shader loading, binding, and runtime execution (RHI), while the Zenith.NET.Shader project would focus on offline shader compilation and validation.
  2. Reduced Runtime Dependencies: For final release builds of games or applications, there would be no need to distribute or load slangc.net and its native libraries, significantly reducing runtime footprint and startup overhead.
  3. Optimized Workflow: This naturally supports the "offline compilation" best practice. Developers could use Zenith.NET.Shader in their tooling layer (e.g., editor or build server) to pre-compile .slang or .hlsl source files into final bytecode or DXIL/SPIR-V. The game runtime would only need to load these pre-compiled artifacts, without carrying the compiler SDK, improving runtime stability and security.
  4. Build Flexibility: It would allow users of the core library to choose their preferred shader compilation toolchain, rather than being limited to the Slang compiler.

I hope you'll consider this suggestion. If needed, I'm also willing to assist with the initial refactoring work and submit a pull request (PR). Thank you for creating such an excellent library!

Use Case

Zenith.NET --> Zenith.NET(RHI)+Zenith.NET.Shader
Engine ->Zenith.NET(RHI)
Editor->Zenith.NET.Shader(tool)

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions