Here We Go
I always do one of these big roundups for each Mesa release, so here’s what you can expect to see from zink in the upcoming release:
- fewer hangs on RADV
- massively improved usability on NVIDIA
- greatly improved performance with unsupported texture download formats (e.g., CS:GO, L4D2)
- more extensions: ARB_sparse_texture, ARB_sparse_texture2, ARB_sparse_texture_clamp, EXT_memory_object, EXT_memory_object_fd, GL_EXT_semaphore, GL_EXT_semaphore_fd
- ~1000% improved glxgears performance (be sure to run with
--i-know-this-is-not-a-benchmarkto see the real speed)
- tons and tons and tons of bug fixes
All around looking like another great release.
I Hate gl_PointSize And So Can You
Yes, we’re here.
After literally years of awfulness, I’ve finally solved (for good) the debacle that is point size conversion from GL to Vulkan.
What’s so awful about it, you might be asking. How hard can it be to just add
gl_PointSize to a shader, you follow up with as you push your glasses higher up your nose.
Allow me to explain.
In Vulkan, there is exactly one method for setting the size of points: the
gl_PointSize shader output controls it, and that’s it.
If program point size mode is enabled, the derived point size is taken from the (potentially clipped) shader built-in gl_PointSize written by the last vertex processing stage and clamped to the implementation-dependent point size range. If the value written to gl_PointSize is less than or equal to zero, or if no value was written to gl_PointSize, results are undefined. If program point size mode is disabled, the derived point size is specified with the command
void PointSize( float size );
- 22.214.171.124 Tessellation Evaluation Shader Outputs
Tessellation evaluation shaders have a number of built-in output variables used to pass values to equivalent built-in input variables read by subsequent shader stages or to subsequent fixed functionality vertex processing pipeline stages. These variables are gl_Position, gl_PointSize, gl_ClipDistance, and gl_CullDistance, and all behave identically to equivalently named vertex shader outputs.
- 126.96.36.199 Geometry Shader Outputs
The built-in output gl_PointSize, if written, holds the size of the point to be rasterized, measured in pixels
In short, if
PROGRAM_POINT_SIZE is enabled, then points are sized based on the
gl_PointSize shader output of the last vertex stage.
- (3.3 | 3.4 | 13.3) Points
The point size is taken from the shader built-in gl_PointSize written by the vertex shader, and clamped to the implementation-dependent point size range.
In OpenGL ES (version 3.2):
- 13.5 Points
The point size is determined by the last vertex processing stage. If the last vertex processing stage is not a vertex shader, the point size is 1.0. If the last vertex processing stage is a vertex shader, the point size is taken from the shader built-in gl_PointSize written by the vertex shader, and is clamped to the implementation-dependent point size range.
Thus for an ES context, the point size always comes from the last vertex stage, which means it can be anything it wants to be if that stage is a vertex shader and cannot be written to for all other stages because it is not a valid output (this last, bolded part is going to be really funny in a minute or two).
What do the specs agree on?
- If a vertex shader is the last vertex stage, it can write
Literally that’s it.
As we know, Vulkan has a very simple and clearly defined model for point size:
The point size is taken from the (potentially clipped) shader built-in PointSize written by: • the geometry shader, if active; • the tessellation evaluation shader, if active and no geometry shader is active; • the vertex shader, otherwise - 27.10. Points
It really can be that simple.
So one would think that we can just hook up some conditionals based on the GL rules and then export the correct value.
That would be easy.
It would make sense.
It gets worse (obviously).
gl_PointSize is a valid XFB varying, which means it must be exported correctly to the transform feedback buffer. For the ES case, it’s simple, but for desktop GL, there’s a little something called
PROGRAM_POINT_SIZE state which totally fucks that up. Because, as we know, Vulkan has exactly one way of setting point size, and it’s the shader variable.
Thus, if there is a desktop GL context using a vertex shader as its last vertex stage for a draw, and if that shader has its own
gl_PointSize value, this value must be exported for XFB.
But not used for point rasterization.
It’s Actually Even Worse Than That
…Because in order to pass CTS for ES 3.2, your implementation also has to be able to violate spec.
Remember above when I said it was going to be funny that
gl_PointSize is not a legal output for non-vertex stages in ES contexts?
CTS explicitly has “wide points” tests which verify illegal point sizes that are exported by the tessellation and geometry shader stages. Isn’t that cool?
Also, let’s be reasonable people for a moment, who actually wants a point that’s just one pixel? Nobody can see that on their 8k display.
To Sum Up
I hate GL point size, and so should you.