Repository navigation
Refactor canonical shader lowering and accelerate compilation - #92
Merged
Merged
Conversation
Sieluna
force-pushed
the
refactor/compiler-review
branch
3 times, most recently
from
October 8, 2026 14:16
0b3f9f5 to
f2f711f
Compare
Sieluna
force-pushed
the
refactor/compiler-review
branch
from
October 8, 2026 15:05
f2f711f to
d80a70b
Compare
| bool exits = statement switch | ||
| { | ||
| Statement.Break => true, | ||
| Statement.If branch => Rewrite(branch.Accept) | Rewrite(branch.Reject), |
Sieluna
force-pushed
the
refactor/compiler-review
branch
from
October 11, 2026 11:08
154dc3f to
1e7b0c3
Compare
| 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
added this pull request to stack #93
October 11, 2026 11:22
Sieluna
force-pushed
the
refactor/compiler-review
branch
2 times, most recently
from
October 11, 2026 14:59
bfdc472 to
465c0fd
Compare
Sieluna
force-pushed
the
refactor/compiler-review
branch
2 times, most recently
from
October 11, 2026 15:47
04f5c11 to
330f43d
Compare
Sieluna
force-pushed
the
refactor/compiler-review
branch
from
October 12, 2026 06:57
ac1f81f to
dadea12
Compare
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.
Closed #91