Skip to content

nir/lower_shader_calls: various optimizations

A bunch of optimization :

  • trivially rematerialize more
  • rematerialize chains of instructions built off filled values to avoid further spills
  • trim the spill/fill operations (when we only need 2 components of a vec4, we can just spill a vec2)
  • remove respill (if a shader fills a value at offset = 16, there is no need to spill same value back at the same offset)

I think this is saner than the previous approach and should help reviewers.

Results on the q2rtx fossilize on DG2 :

Instructions in all programs: 80247 -> 79385 (-1.1%)
Instructions helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/1dbefa540d4e91f8/raygen: 5482 -> 5009 (-8.6%)
Instructions helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/e80330c96c87d5d1/raygen: 5365 -> 5039 (-6.1%)
Instructions helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/ab59d5b8f22cd48d/raygen: 1395 -> 1388 (-0.5%)
Instructions helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/76f7e570f09ed851/raygen: 1421 -> 1365 (-3.9%)

SENDs in all programs: 3039 -> 3013 (-0.9%)
SENDs helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/1dbefa540d4e91f8/raygen: 130 -> 120 (-7.7%)
SENDs helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/e80330c96c87d5d1/raygen: 134 -> 124 (-7.5%)
SENDs helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/ab59d5b8f22cd48d/raygen: 68 -> 66 (-2.9%)
SENDs helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/76f7e570f09ed851/raygen: 74 -> 70 (-5.4%)

Loops in all programs: 40 -> 40 (+0.0%)

Cycles in all programs: 2390085 -> 2383069 (-0.3%)
Cycles helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/1dbefa540d4e91f8/raygen: 97715 -> 94496 (-3.3%)
Cycles helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/e80330c96c87d5d1/raygen: 98242 -> 94454 (-3.9%)
Cycles helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/ab59d5b8f22cd48d/raygen: 12692 -> 12688 (-0.0%)
Cycles helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/76f7e570f09ed851/raygen: 14108 -> 14103 (-0.0%)

Spills in all programs: 360 -> 348 (-3.3%)
Spills helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/1dbefa540d4e91f8/raygen: 63 -> 56 (-11.1%)
Spills helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/e80330c96c87d5d1/raygen: 61 -> 56 (-8.2%)

Fills in all programs: 603 -> 562 (-6.8%)
Fills helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/1dbefa540d4e91f8/raygen: 139 -> 112 (-19.4%)
Fills helped fossils/q2rtx/q2rtx-rt-pipeline.976f4ab1c0fee975.1.foz/e80330c96c87d5d1/raygen: 126 -> 112 (-11.1%)
Edited by Lionel Landwerlin

Merge request reports