SDSL rewrite#3134
Merged
Merged
Conversation
… (do not deduplicate)
Add CompositionStageInheritedNotPromotedToRoot test and surface compilation errors in RenderingTests instead of swallowing them.
… (already handled)
…ctions, and pass them directly as pointer
…if requested at same time from multiple threads
Add Frozen property and FreezeableDictionary wrapper for Types/ReverseTypes/Names. Freeze contexts after caching in ShaderCache.RegisterShader to catch accidental mutations during development. ThrowIfFrozen guards on mutating methods.
ShaderDefinition no longer inherits from SymbolType. It's stored in SymbolTable.DeclaredShaders (not DeclaredTypes) and imported via SpirvContext.GetOrImportShader (not GetOrRegister). ShaderSymbol remains as the lightweight SymbolType placeholder in Types/ReverseTypes.
InsertWithoutDuplicates was modifying source buffer instructions in-place (RemapIds, opcode swaps) which corrupted frozen cached buffers when called via RegisterArrayType with an ArrayType storing a reference to the cached buffer. Copy each instruction before mutating to preserve source integrity. Also convert raw OpSDSLGenericParameter leaked from parent contexts into OpSDSLGenericReference during import to prevent generic parameter miscounts. Add ThrowIfFrozen guard to RemoveNameAndDecorations.
…epresentation Introduces ConstantExpression hierarchy (IntConstExpr, FloatConstExpr, BoolConstExpr, StringConstExpr, GenericParamExpr, UnaryOpExpr, BinaryOpExpr, SelectExpr) with ParseFromBuffer, Emit, TryEvaluate, and Substitute methods. These will replace raw SPIR-V ID + buffer references in ArrayType.SizeExpression and ShaderClassInstantiation.GenericArguments.
Replace (int Id, SpirvBuffer Buffer)? with ConstantExpression? for array size expressions. This eliminates buffer reference equality issues, mutable setter, and complex import/extraction logic in RegisterArrayType.
Replace raw SPIR-V ID references in ShaderSymbol, ShaderDefinition, ShaderClassInstantiation, and effect/mixin generics with structured ConstantExpression trees. This eliminates buffer-dependent equality issues and enables expression-level generic substitution. Key changes: - ShaderSymbol/ShaderDefinition GenericArguments: int[] → ConstantExpression[] - BuildInheritanceListWithoutSelf: expression-level Substitute replaces RemapGenericParameter - InstantiateGenericShader: tracks currentShaderDeclaringClass for self-referencing generics - GenericResolver: uses TryEvaluate/EmitToBuffer instead of context.ExtractConstantAsSpirvBuffer - ConvertToShaderClassSource: parses import generics via ParseFromBuffer
…icShader When a shader inherits from a generic parent that itself inherits from another generic parent (e.g., TerrainDrectional → Directional → Base), the import map contains chains of GenericReferences. The single-pass resolution would extract an unresolved reference instead of following the chain to the concrete constant. Now follows transitive references through the import map before extracting the constant buffer, with cycle detection via visited set.
This cache was used by the old GenericResolverFromInstantiatingBuffer to map constant IDs to string representations. After the migration to ConstantExpression, generic value resolution uses expr.TryEvaluate() directly, making this cache dead code.
…onstantExpression Replace raw SpirvContext + int ID references with context-independent ConstantExpression values. Add CompositeConstExpr for vector/composite constants. Delete unused ExtractConstantAsSpirvBuffer method.
…romBuffer + TryEvaluate
…rtWithoutDuplicates
…r array sizes and attributes
…pecConstantOp CompileConstantValue was converting all arithmetic to OpSpecConstantOp, even when operands were known OpConstant values. SPIRV-Cross doesn't support all spec constant ops (e.g. FMul). Now folds at compile time when possible, emitting OpConstant/OpConstantComposite instead. Fixes ConstantTypeConversion render test.
|
@xen2 —
Land workflow changes on master first if you need them tested. |
|
@xen2 — |
…ules SPVGenerator runs as a standalone console tool fetching SPIRV-Headers / SPIRV-Registry from GitHub at pinned refs. Generated/*.cs is committed. Regenerate via F5 / dotnet run after bumping the refs in Program.cs.
Member
Author
|
/ci e2e |
|
@xen2 —
Land workflow changes on master first if you need them tested. |
|
@xen2 — |
Member
Author
|
/ci e2e |
|
@xen2 — |
|
@xen2 — |
…PathWithTargetPlatformMoniker
Drops source-generator analyzer load surface from 17 to 9 DLLs.
C# port of the Anarres C preprocessor, vendored from: - Upstream: <https://github.com/MonoGame/CppNet> - Commit: `3dc3eb2db05be9d80b7cc5d00d5814cbe8f0ded2` (`master`, "Make all public API internal for MonoGame Pipeline use. (#2)", 2026-01-24) Not copied from upstream (unused by Stride): `CppReader.cs`, `CppTask.cs`, `InputLexerSource.cs`, `TokenSnifferSource.cs`, `CppNet.csproj`, `CppNet.targets`, `Properties/AssemblyInfo.cs`.
Member
Author
|
/ci e2e |
|
@xen2 — |
Member
Author
|
/ci e2e |
|
@xen2 — |
|
@xen2 — |
|
@xen2 — |
Contributor
|
Wow, good job! A huge endeavour finished at last! I'm eager to try it 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Replaces Stride's HLSL-based shader pipeline with a SPIR-V-centric one driven by a new shader language ("SDSL") and parser, plus a sweep of graphics-backend and build-system improvements.
Special thanks to
New SDSL / SPIR-V pipeline
The old pipeline (HLSL → FXC/glslang → bytecode per API, with Irony-based parsing) is gone. The new flow is:
Pipeline:
.sdsl→ SPIR-V (SDSL variant) → ShaderMixer merges per stage → backendspirv_to_dxil(Mesa).What's new
Stride.Shaders.Parsers— from-scratch SDSL parser. Replaces the oldStride.Shaders.Parser+Ironygrammar.Stride.Shaders.Spirv(andStride.Shaders.Spirv.Generators) — full SPIR-V type system + a standalone code generator that produces opcode bindings from Khronos's SPIRV-Headers grammar JSON. Generated files are committed; the generator fetches grammar from GitHub at pinned tags/SHAs on demand (no submodule).Stride.Shaders.Compilers— orchestrates SDSL → SPIR-V → (HLSL via SPIRV-Cross when targeting D3D) → DXBC/DXIL/SPIR-V bytecode. Usesspirv-optlegalization before SPIRV-Cross (load-bearing for FXC dead-code elimination).Stride.Shaders.Generators/Stride.Shaders.Generators.Internal— Roslyn source generators:IntrinsicsGenerator(HLSL intrinsic dispatch table fromgen_intrin_main.txt),VisitorGenerator(Accept/Walker/Rewriter for the SDSL AST).Stride.Shaders.Effects— sdfx/effect-mixin layer, split out fromStride.Shaders.What's gone
Stride.Core.Shaders(~37 k LOC),Stride.Shaders.Parser(~13 k LOC),Irony+Irony.GrammarExplorer(~12 k LOC), the oldStride.Shaders.Compilerproject skeleton..sdsl.cs/.sdfx.cscompanion files — they're emitted by the new build, not stored in git.glslangValidator.exeand references; the new path uses spirv-tools + SPIRV-Cross.SDSL highlights
OpLine/OpSource) emitted with original.sdslsource for clean SPIRV-Cross#linedirectives, RenderDoc / PIX / NSight source mapping.rgroupStructuredBuffers (stripped from final SPIR-V on Vulkan, kept for SPIRV-Cross HLSL emit).UniformConstantpointers in function calls.OpSpecConstantOpconstant folding (incl.OpBitcast).SymbolTable+TextLocationthreaded through the compiler.D3D12 / Vulkan backend overhaul
ResourceBarrierpath removed. New per-CL layout tracking + per-subresource enhanced barriers. Command lists upgraded toID3D12GraphicsCommandList7. Init-time texture uploads use enhanced barriers too.InfoQueue1callback for error/warning attribution, no-draw Present and "only Barrier commands" perf warnings fixed.DebugGpuValidationEnabled+DebugAlwaysDumpTreeflags, per-message GBV detection.Stride.Graphics.Rendering / compositing
CI / build / SDK
PrivateAssets="compile"on impl-only deps across the engine — keeps native bindings (Silk.NET.*, Vortice.Vulkan, FFmpeg.AutoGen, DotRecast, SSH.NET, etc.) out of consumer compile graphs, materially cuts CA2213 PointsToAnalysis cost on external NuGet consumers.Microsoft.Interop.ComInterfaceGeneratorglobally via SDK target (zero[GeneratedComInterface]usage in tree; pipeline overhead removed)./test e2e,/test screenshots, etc.) and a workflow-YAML-modified warning helper.Editor / test infrastructure
TemplateSampleGenerator(proper sample instantiation with upgrader) + Claude vision fallback to classify gameplay-state drift as not-a-regression.Notes for reviewers
continue-on-error: truefor them on the matrix). Direct3D11 is the source of truth right now.Types of changes