Skip to content

panfrost: clamp small gl_Position.w values

Benjamin Lee requested to merge benjaminl/mesa:panfrost-clamp-pos-w into main

Because we are doing perspective division before clipping, small gl_Position.w values will give Inf for positions and interpolated varyings.

I didn't find any tests in the vulkan CTS that hit this, so tested with the following vkrunner test

[vertex shader]
#version 430

layout(location = 0) in vec4 position;

void main() {
    gl_Position = position;
}

[fragment shader]
#version 430

layout(location = 0) out vec4 color_out;

void main() {
    color_out = vec4(1.0, 0.0, 0.0, 1.0);
}

[vertex data]
0/R32G32B32A32_SFLOAT

 -1 -1 0 0
  1 -1 0 1
 -1  1 0 1

[test]
clear
draw arrays TRIANGLE_LIST 0 3

relative probe rgb (0.25, 0.25) (1, 0, 0)
relative probe rgb (0.75, 0.75) (0, 0, 0)

Before this change, the rendered image is all black. After, it is a triangle on the upper left diagonal.

/cc @kusma @marysaka @bbrezillon

Merge request reports

Loading