Skip to content

gallium: add PIPE_CAP_PREFER_POT_ALIGNED_VARYINGS

Some GPUs (e.g. Mali4x0) prefer varyings to be aligned to POT in a slot, however while vec4/vec2/scalar are guaranteed to be aligned to closest POT, vec3s are not even guaranteed to be in the same slot.

On Mali4x0 it results in an extra mov and extra load_input+mov if it's double-parked and if this vec3 holds coordinates for sampler it results in precision downgrade to FP16.

Introduce PIPE_CAP_PREFER_POT_ALIGNED_VARYINGS that prevents packing of vec3 varyings.

shader-db on lima:

    total instructions in shared programs: 15707 -> 15623 (-0.53%)
    instructions in affected programs: 3906 -> 3822 (-2.15%)
    helped: 47
    HURT: 18
    helped stats (abs) min: 1 max: 9 x̄: 3.09 x̃: 2
    helped stats (rel) min: 1.49% max: 23.53% x̄: 8.20% x̃: 6.45%
    HURT stats (abs)   min: 1 max: 7 x̄: 3.39 x̃: 3
    HURT stats (rel)   min: 0.78% max: 20.59% x̄: 10.45% x̃: 10.97%
    95% mean confidence interval for instructions value: -2.18 -0.41
    95% mean confidence interval for instructions %-change: -5.70% -0.38%
    Instructions are helped.

    total spills in shared programs: 146 -> 136 (-6.85%)
    spills in affected programs: 39 -> 29 (-25.64%)
    helped: 6
    HURT: 0

    total fills in shared programs: 617 -> 598 (-3.08%)
    fills in affected programs: 125 -> 106 (-15.20%)
    helped: 6
    HURT: 0

HURT shaders are vertex shaders where we may need more instructions for non-packed vec3s. It's acceptable trade-off since we don't get precision downgrade if this varying holds coordinates for a sampler.

Edited by Vasily Khoruzhick

Merge request reports