Skip to content

Refactor canonical shader lowering and accelerate compilation - #92

Merged
Sieluna merged 3 commits into
masterfrom
refactor/compiler-review
Oct 12, 2026
Merged

Sieluna merged 3 commits into
masterfrom
refactor/compiler-review

Conversation

@Sieluna

@Sieluna Sieluna commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Closed #91

Comment thread tools/naga-archive/snapshot/probe-float-atomic-device.py Fixed
Comment thread tools/naga-archive/snapshot/probe-image-atomic-device.py Fixed
Comment thread tools/naga-archive/snapshot/probe-mesh-device.py Fixed
Comment thread tools/naga-archive/snapshot/check-image-atomic-vulkan.py Fixed
Comment thread tools/naga-archive/snapshot/check-specop-vulkan.py Fixed
Comment thread tools/naga-archive/snapshot/check-specop-vulkan.py Fixed
Comment thread tools/naga-archive/snapshot/check-storage-formats-vulkan.py Fixed
Comment thread tools/naga-archive/snapshot/check-vector-vulkan.py Fixed
Comment thread tools/naga-archive/snapshot/probe-storage-format-device.py Fixed
Comment thread tools/naga-archive/snapshot/vulkan_images.py Fixed
Comment thread Sia.Spirv.Compiler/Translation/Front/SpirvReader.Continuing.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Front/SpirvReader.Textures.cs Fixed
@Sieluna
Sieluna force-pushed the refactor/compiler-review branch 3 times, most recently from 0b3f9f5 to f2f711f Compare October 8, 2026 14:16
@Sieluna Sieluna changed the title Integrate managed shader compilation and archive Naga tools Decouple shader compilation and document compiler architecture Oct 8, 2026
@Sieluna
Sieluna force-pushed the refactor/compiler-review branch from f2f711f to d80a70b Compare October 8, 2026 15:05
Comment thread Sia.Spirv.Compiler.Tests/Translation/BarrierMemoryTests.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Back/SpirvWriter.Mesh.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Back/SpirvWriter.Mesh.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Front/SpirvReader.PointerPhi.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Back/SpirvWriter.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/PointerMemoryTests.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Back/SpirvWriter.Textures.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/SpirvWorkgroupAccessTests.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/CooperativeMatrixTests.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/SpirvWorkgroupAccessTests.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/CanonicalControlFlowTests.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/CanonicalControlFlowTests.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/CanonicalDataTests.cs Fixed
Comment thread Sia.Spirv.Compiler.Tests/Translation/HelperInvocationQueryTests.cs Fixed
bool exits = statement switch
{
Statement.Break => true,
Statement.If branch => Rewrite(branch.Accept) | Rewrite(branch.Reject),
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Proc/QueryStateLowering.cs Fixed
Comment thread Sia.Spirv.Compiler/Translation/Front/SpirvReader.Textures.cs Fixed
Comment thread tools/compiler-validation/gpu/MatrixStorageGpuTests.cs Fixed
Comment thread tools/compiler-validation/gpu/MatrixStorageGpuTests.cs Fixed
@Sieluna
Sieluna force-pushed the refactor/compiler-review branch from 154dc3f to 1e7b0c3 Compare October 11, 2026 11:08
args.Add(pair.Image); args.Add(pair.Sampler); args.Add(coordinate); if (layer is not null) args.Add(layer); if (depth is not null) args.Add(depth);
if (compare && operands.Level is not null)
{
if (!ConstantEvaluator.TryEvaluate(operands.Level, out var level) || level is not Expression.Literal literal || System.Convert.ToDouble(literal.Value) != 0) throw Error("WGSL comparison sampling only supports level zero.");
}
return scalar.Kind switch
{
ScalarKind.Bool => new Expression.Literal(literal.Value is bool boolean ? boolean : Floating(literal.Value) != 0, type),
{
double x = Floating(a.Value), y = Floating(b.Value);
if (op is "<" or ">" or "<=" or ">=" or "==" or "!=") return Expression.Bool(op switch
{ "<" => x < y, ">" => x > y, "<=" => x <= y, ">=" => x >= y, "==" => x == y, _ => x != y });
{
double x = Floating(a.Value), y = Floating(b.Value);
if (op is "<" or ">" or "<=" or ">=" or "==" or "!=") return Expression.Bool(op switch
{ "<" => x < y, ">" => x > y, "<=" => x <= y, ">=" => x >= y, "==" => x == y, _ => x != y });
private DescriptorValue ScalarDescriptor(uint id)
{
if (descriptorValues.TryGetValue(id, out var cached)) return cached;
if (!definitions.TryGetValue(id, out var i) || !types.TryGetValue(i.Operands[0], out var type) || (Op)type.Opcode != Op.TypeInt)
}
private Part IndexPart(uint id)
{
if (!definitions.TryGetValue(id, out var i) || !types.TryGetValue(i.Operands[0], out var type) || (Op)type.Opcode != Op.TypeInt)
public sealed record TaskDispatch(SsaValue Dimensions, string? Payload, SourceSpan Span = default) : ControlFlowTerminator;
public sealed record Unreachable(SourceSpan Span = default) : ControlFlowTerminator;
public sealed record InvocationKill(SourceSpan Span = default, bool ExplicitTermination = false) : ControlFlowTerminator;
public ShaderEffects Effects => this is TaskDispatch ? ShaderBuiltinEffects.Barrier(true) | ShaderEffects.InvocationTermination
public sealed record Unreachable(SourceSpan Span = default) : ControlFlowTerminator;
public sealed record InvocationKill(SourceSpan Span = default, bool ExplicitTermination = false) : ControlFlowTerminator;
public ShaderEffects Effects => this is TaskDispatch ? ShaderBuiltinEffects.Barrier(true) | ShaderEffects.InvocationTermination
: this is InvocationKill ? ShaderEffects.Convergent | ShaderEffects.InvocationTermination : ShaderEffects.None;
if (bitcast) return Bitcast(input, type);
if (input is Expression.Construct c && type is ShaderType.Vector vector)
return new Expression.Construct(type, c.Components.Select(e => ConvertCore(e, vector.Component, bitcast)).ToArray());
if (input is Expression.Construct matrix && type is ShaderType.Matrix m && !bitcast)
@Sieluna Sieluna changed the title Decouple shader compilation and document compiler architecture Optimize canonical shader compilation and target legalization Oct 11, 2026
@Sieluna
Sieluna changed the base branch from master to fix/compiler-pr-workflow October 11, 2026 11:10
@Sieluna
Sieluna added this pull request to stack #93 October 11, 2026 11:22
@Sieluna
Sieluna force-pushed the refactor/compiler-review branch 2 times, most recently from bfdc472 to 465c0fd Compare October 11, 2026 14:59
@Sieluna Sieluna self-assigned this Oct 11, 2026
@Sieluna Sieluna added the enhancement New feature or request label Oct 11, 2026
@Sieluna
Sieluna force-pushed the refactor/compiler-review branch 2 times, most recently from 04f5c11 to 330f43d Compare October 11, 2026 15:47
@Sieluna Sieluna changed the title Optimize canonical shader compilation and target legalization Refactor canonical shader lowering and accelerate compilation Oct 12, 2026
Base automatically changed from fix/compiler-pr-workflow to master October 12, 2026 06:57
@Sieluna
Sieluna force-pushed the refactor/compiler-review branch from ac1f81f to dadea12 Compare October 12, 2026 06:57
@Sieluna
Sieluna merged commit 75727d5 into master Oct 12, 2026
9 checks passed
@Sieluna
Sieluna deleted the refactor/compiler-review branch October 12, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Decouple shader compilation and clarify compiler architecture

1 participant