Class ShaderCompilerValidationExtensions
- Namespace
- ShadowDusk.Core
- Assembly
- ShadowDusk.Core.dll
Validate / ValidateAsync for any IShaderCompiler — extension
methods rather than interface members so they are reachable from a variable declared as
the CONCRETE compiler type (e.g. var compiler = new EffectCompiler();, the pattern
the README/quickstarts use for CompileAsync(string, CompilerOptions, CancellationToken)), not only from
one declared as IShaderCompiler. A C# default interface method would compile
only through the interface-typed reference — a footgun for exactly this "just add the
package and call the API" promise. Every current and future IShaderCompiler
implementation gets these for free, with nothing to override.
public static class ShaderCompilerValidationExtensions
- Inheritance
-
ShaderCompilerValidationExtensions
- Inherited Members
Methods
Validate(IShaderCompiler, string, CompilerOptions?, CancellationToken)
Synchronous counterpart of
ValidateAsync(IShaderCompiler, string, CompilerOptions?, CancellationToken),
for call sites that cannot await. Same pipeline, same report. On the browser/WASM
host the same precondition as Compile(string, CompilerOptions, CancellationToken) applies:
InitializeAsync(CancellationToken) must have completed first, otherwise
each target's result carries the clear SD1903 error.
public static ShaderValidationReport Validate(this IShaderCompiler compiler, string hlslSource, CompilerOptions? options = null, CancellationToken cancellationToken = default)
Parameters
compilerIShaderCompilerThe compiler to validate with.
hlslSourcestringThe HLSL
.fxeffect source to validate.optionsCompilerOptionsOptional settings; Target is ignored.
cancellationTokenCancellationTokenToken observed between pipeline stages.
Returns
ValidateAsync(IShaderCompiler, string, CompilerOptions?, CancellationToken)
Tries to show ALL issues with a shader in one call: compiles it for each validation target (by default OpenGL and DirectX) and reports every error and every warning per target. Print the returned report — its ToString() is the full human-readable story — or walk Targets for structured access. Validation never throws for shader problems; a broken shader simply produces a report with errors.
public static Task<ShaderValidationReport> ValidateAsync(this IShaderCompiler compiler, string hlslSource, CompilerOptions? options = null, CancellationToken cancellationToken = default)
Parameters
compilerIShaderCompilerThe compiler to validate with.
hlslSourcestringThe HLSL
.fxeffect source to validate.optionsCompilerOptionsOptional settings (include resolution, source file name, …). The Target value is ignored — each validation target is applied in turn. Omit for defaults.
cancellationTokenCancellationTokenToken used to cancel the validation.
Returns
- Task<ShaderValidationReport>
The per-target report; see ShaderValidationReport.
Remarks
Runs the exact same pipeline as CompileAsync(string, CompilerOptions, CancellationToken) per
target (never a fork), so what validates is precisely what compiles. When
options carries a Profile,
that profile pins the backend, so only the profile's target is validated.
FNA and Vulkan are not in the default set (FNA's SM2–3 dialect would
false-alarm MonoGame/KNI shaders); pass explicit targets via
ValidateAsync(IShaderCompiler, string, IReadOnlyList<PlatformTarget>, CompilerOptions?, CancellationToken)
to include them.
ValidateAsync(IShaderCompiler, string, IReadOnlyList<PlatformTarget>, CompilerOptions?, CancellationToken)
ValidateAsync(IShaderCompiler, string, CompilerOptions?, CancellationToken) over an explicit set of targets (e.g. add Fna or Vulkan, or check a single target).
public static Task<ShaderValidationReport> ValidateAsync(this IShaderCompiler compiler, string hlslSource, IReadOnlyList<PlatformTarget> targets, CompilerOptions? options = null, CancellationToken cancellationToken = default)
Parameters
compilerIShaderCompilerThe compiler to validate with.
hlslSourcestringThe HLSL
.fxeffect source to validate.targetsIReadOnlyList<PlatformTarget>The platform backends to validate, in order.
optionsCompilerOptionsOptional settings; Target is ignored.
cancellationTokenCancellationTokenToken used to cancel the validation.