SPIR-V: loop controls from [unroll] and [loop]

Loops the IR keeps (its unrolling gave up, or [loop] asked it not to)
lost their attribute: every OpLoopMerge had loop control None. The
driver now gets Unroll for [unroll] and DontUnroll for [loop], as from
dxc.

On the Hyperion engine's Glide shaders this is what made its half
resolution Glimmer irradiance pass about 5% slower than with dxc: an
[unroll] loop over a run-time count that RADV unrolls for dxc's output
stayed a loop for zdxc's (2381 instructions against dxc's 5765; now
5856).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Peterino2 2026-11-02 06:55:33 +00:00
parent 01a66d456a
commit 5ec38a7bcb
1 changed files with 8 additions and 1 deletions

View File

@ -2189,7 +2189,14 @@ const Emitter = struct {
switch (blk.merge) {
.none => {},
.selection => |mb| try e.b.emit(.functions, .selection_merge, &.{ labels[mb.index()], 0 }),
.loop => |l| try e.b.emit(.functions, .loop_merge, &.{ labels[l.merge.index()], labels[l.@"continue".index()], 0 }),
// [unroll] / [loop] the IR could not act on are the
// driver's to honor (LoopControl Unroll / DontUnroll), as
// in dxc.
.loop => |l| try e.b.emit(.functions, .loop_merge, &.{ labels[l.merge.index()], labels[l.@"continue".index()], switch (l.unroll) {
.auto => 0,
.unroll => 1,
.dont => 2,
} }),
}
switch (blk.term) {
.none, .@"unreachable" => try e.b.emit(.functions, .@"unreachable", &.{}),