sublime-glsl icon indicating copy to clipboard operation
sublime-glsl copied to clipboard

Modern built-in variables (gl_FragDepth, gl_GlobalInvocationID, gl_TessCoord, ...) are not highlighted

Open dpc00 opened this issue 2 months ago • 0 comments

Many current built-in variables (gl_FragDepth, the compute-shader and tessellation ones, and others) get no scope, while older ones like gl_FragCoord and gl_Position are highlighted as variable.language.glsl.

Repro (Sublime Text 4215, package installed from Package Control, 1.2.0, syntax "OpenGL Shading Language (GLSL)")

I put x = <name>; inside a void main() body for 34 built-in variable names and read view.scope_name() at the start of each name. 11 were scoped variable.language.glsl. These 23 had no variable.language scope:

gl_FragDepth gl_PrimitiveID gl_ViewportIndex gl_SampleID gl_SamplePosition
gl_SampleMask gl_HelperInvocation gl_DrawID gl_BaseVertex gl_BaseInstance
gl_CullDistance gl_NumWorkGroups gl_WorkGroupID gl_LocalInvocationID
gl_GlobalInvocationID gl_LocalInvocationIndex gl_WorkGroupSize gl_InvocationID
gl_TessLevelOuter gl_TessLevelInner gl_TessCoord gl_PatchVerticesIn gl_FragData

All of these are core built-ins in the GLSL spec (fragment, compute, tessellation and geometry stages; gl_FragData is the legacy array). A compute shader that reads gl_GlobalInvocationID.x gets no highlighting on it, and neither does gl_FragDepth = ... in a fragment shader.

Cause

The variables context matches \bgl_(...) against a fixed list of names (BackColor, ClipDistance, ...) and the list stops at the older GLSL 1.x-era names. The missing ones need to be added to that alternation.

I checked names with the installed 1.2.0 package.

dpc00 avatar Sep 28 '26 21:09 dpc00