Search

A technology, a device or an article

Invisible neighbors of a fragment also work on the GPU

Derivatives need neighboring values, including beyond a visible primitive’s edge. Helper invocations explain invisible shader work and the distinction between demotion and termination.

Blue gouache squares and pale neighboring impressions cross a diagonal terracotta boundary
ITNWS AI-generated conceptual illustration. A visual metaphor for computational neighbors beyond coverage, not a literal hardware group layout.ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

Empty space lies just beyond the sloping edge of a triangle. It does not belong to its visible surface, should not receive its color, and does not reveal itself in any way in the finished image. But a calculation near this boundary may need the value obtained just on the other side. To estimate how quickly a value changes in an image, the value inside the triangle alone is not enough. In GPU graphics work there are therefore participants who cannot be counted by the shaded points. Their absence from the picture does not mean the absence of a useful calculation.

These participants are called helper invocations – auxiliary shader invocations. The name is modest, but it corrects an important error in the visual imagination: one fragment shader invocation does not always equal one future colored pixel. The Vulkan Shader Specification allows additional invocations for derivatives and operations on adjacent members. They are needed so that the results of the main calculation have a defined neighborhood. The mechanism was verified against primary sources on November 3, 2026; this is a long-standing part of the execution model, and not an announcement of a new video card.

Let’s imagine a surface with a gradually changing texture coordinate. The value at one point reports the position in the texture, but not its local scale on the screen. To estimate scale, the difference in values at adjacent positions is useful. If the coordinate changes noticeably in one step, a large area of the texture falls on a small area of the image. If the change is small, the situation is different. In this reasoning, the adjacent value is the input of the operation, even though the corresponding point will not become the visible output of that primitive in its own right. The computational neighborhood does not have to coincide with the shaded area.

Two by two squares are often drawn here. This representation helps to see horizontal and vertical differences, but should not be turned into a universal description of the internal workings of all GPUs. The API specifies rules for derivatives and grouping in its terms; the specific mode, stage and additional capabilities matter. Within the usual explanation of fragment neighborhood, the idea of neighborhood itself is useful. It does not promise that each observed hardware counter can be obtained by dividing the number of screen pixels by four, or that the hardware warp is equal to the depicted square.

Value on the other side of the edge

Let’s return to the diagonal. Some of the neighboring positions are covered by the triangle, some lie beyond its edge. To calculate the gradient over the covered part, the GPU can make additional invocations that produce the desired neighboring values while keeping their contribution to the framebuffer disabled. The external participant does not transform the triangle into a wider primitive. Coverage and computational participation answer different questions. In the finished image, the boundary remains where the geometry and rasterization rules determined it, although the work to obtain it goes beyond that boundary.

Adjacent values must be meaningful relative to the expression being evaluated. The derivative of an arbitrary variable does not receive the correct meaning only from the presence of the word dFdx in the source code. It matters where the variable is defined, whether the evaluation path is the same for the desired participants, and whether the context allows such an operation. GLSL 4.60.8, revised August 14, 2023, describes derivatives and limitations of non-uniform control flow. The date of the document is historical; today’s review does not make these rules the news of November.

If half of the neighbors entered a branch and the other half bypassed it, the expression within the branch may not have the required set of neighboring values. For ordinary derivatives in such non-uniform control flow, one cannot promise a certain result without taking into account the rules of a particular language and mode. Outwardly, the problem may look like a texture detail error at the edge of the mask, although the reason is due to the availability of calculation inputs. More video memory does not restore a value that the program has not defined in the correct context. This is a question of the program and execution model, not of buffer capacity.

Implicit LOD selection during normal texture sampling may also require derivatives. Therefore, a source without an explicit dFdx is not necessarily free from this dependency. The author sees only texture(), but instructs the implementation to determine the sample size from the variation in coordinates. Branching around such an operation requires the same care with the meaning of available neighbors. Explicitly passed gradients allow us to formulate a different contract, but they must first be obtained correctly. It is also impossible to call any explicit LOD a full-fledged replacement for a gradient: it expresses a different amount of information about the local mapping.

You can calculate the desired gradients before the non-uniform choice and use them later where the interface allows it. But moving an expression changes the operation and must preserve the values required by the task. If a coordinate within a branch is further transformed, the old gradient does not automatically become the gradient of the new function. This is especially noticeable at discontinuities, where the local linear pattern itself requires caution. The correction begins with the question of what kind of derivative and in what space they really wanted to get, and not with a mechanical move of the line above any if.

Blue-and-white botanical impressions in four panes, partly covered by a diagonal translucent curtain
ITNWS AI-generated conceptual illustration. A cyanotype-style image of visible and helper participants; not a test photograph or an exact invocation map. — ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

The helper invocation should not leave ordinary external side effects. Vulkan specifically limits its writes and atomic operations: they do not affect memory outside of the provided local storage classes; atomic operation return values for helper are undefined. The ability to write local or Output variables is necessary for the calculation itself, but does not mean letting that invocation write to the framebuffer. The same assignment syntax can serve an intermediate value and not give the right to change the final image. This is an important distinction when the shader is both drawing and collecting statistics.

Therefore, the counter in the storage buffer is not a direct device for recording all hardware-executed helper invocations. Auxiliary participants are subject to restrictions on side effects, and the program cannot simply force them to add one like ordinary visible invocations. The converse explanation is also incorrect: the absence of an increment does not prove that the adjacent computation was not performed. Measuring internal costs requires the right hardware and an understanding of its definitions. In this material, GPU counters were not taken; the scenes illustrate the execution contract.

When an invocation stops drawing, but continues to help

There is also a way in which an initially ordinary invocation becomes a helper invocation. GLSL_EXT_demote_to_helper_invocation introduces demote: the invocation then stops future external writes and output to the framebuffer, while still participating in derivative calculations. This more accurately expresses the intention “this participant no longer draws, but is still needed by the neighbors.” Reducing a role does not have to immediately complete all work. For a masked surface, this is a significant opportunity to preserve the computational neighborhood after the visibility decision.

However, demotion does not mean canceling the entire invocation history. If a normal participant has already committed a valid external side effect before demote, a subsequent role change does not automatically roll it back. A program that first updates a general counter and then decides to remove a fragment must separately determine the meaning of that counter. It can take into account processing attempts or final contributions, and these are different quantities. The order of the statements becomes part of the definition of the statistic. The inscription “pixels” next to the result does not correct the fact that other events were actually counted.

Defining the current role also has subtleties. In the specified GLSL extension, after demote the value of the input variable gl_HelperInvocation is considered undefined; the helperInvocationEXT() function is provided to check the current state. It distinguishes between initially auxiliary and later demoted invocations. This interface cannot be replaced by the assumption that one variable, once read, forever describes a further role. When porting a shader, you should read the specific language mapping and capabilities of the target environment. Similar names at different API levels do not guarantee interchangeability.

The Vulkan extension itself VK_EXT_shader_demote_to_helper_invocation was included in Vulkan 1.3 core. This is a history of the interface, and not a guarantee that any program you run will have a suitable feature. We need appropriate support, declaration and use of permitted semantics. It is impossible to conclude from the date of the standard that the installed driver, shader compiler and set of included features are automatically consistent. At the same time, discussing support does not require changing the reader’s system: it is enough to understand which contract the explanation applies to.

Terminating an invocation represents another intent. The current Vulkan specification distinguishes between stopping execution and becoming a helper; the behavior of OpKill may be implementation dependent within the specified limits. So the short "discard always immediately stops the flow" is too crude. For predictable meaning, the document recommends distinguishing between the corresponding SPIR-V operations. The language operator, compiler translation, and hardware path do not need to have the same level of detail. From the name discard you cannot independently deduce what happens to all neighboring calculations and each instruction after it.

However, you should not go to the opposite extreme and promise eternal execution of every helper until the last line. An implementation may terminate unnecessary auxiliary participants as long as the result requirements are met. If there are no more useful ordinary invocations in the relevant area, the reason to continue a piece of work disappears. The model guarantees the necessary semantics, and not the observable biography of each imaginary square. That is why the conceptual picture helps explain the dependence, but does not serve as a trace of the execution of a specific video card.

The influence of the size of the triangles becomes clearer through this juxtaposition. For small triangles, a significant proportion of the required neighborhoods may intersect edges. Then the number of visible covered points describes the amount of shader work less well. But from such an observation it is impossible to obtain a universal percentage of losses: the shape, placement, rasterization modes, shader cost and GPU architecture are important. Tessellation, masks, and organizing rendering passes change different parts of the problem. Without measurements, it is impossible to honestly convert the helper’s existence into the promised gain from a single mesh change.

An invocation outside the visible coverage boundary also does not receive permission to access arbitrary memory. If the neighboring coordinate calculation is then turned into an array index, access must be allowed according to the rules of the appropriate interface. Helper participation in derivatives is not a general bounds checking mechanism. In particular, the assumption “this pixel is not drawn anyway” does not justify going beyond the allocated buffer. The semantics of sampling a texture with a selected sampler and the semantics of accessing the storage buffer are different. The visual inconspicuousness of the result does not exempt the program from the rules for calculating inputs.

Early depth checks and multisampling add their own conditions. They are capable of changing what ordinary invocations are needed for a primitive, but the mere mention of early-Z does not mean that all auxiliary calculations are eliminated. Likewise, sample shading changes the frequency of operation relative to samples, rather than turning the word invocation into a permanent synonym for screen pixel. It is useful to explain the cost of a frame through specific events: coverage, invocation, sample, write. By mixing the units, you can get a nice work-per-pixel number that compares completely different modes.

Even equal derivatives do not mean equal colors. Adjacent invocations may have different interpolated inputs, executed branches, and texture values. The derivative specifies the local dependence of a particular expression, and does not necessarily align all calculations. The auxiliary participant provides data for this dependency; it does not copy the visible neighbor’s finished result. This ensures that the coverage boundary and the change in surface content remain independent image properties.

The external voids of the image turn out to be part of its computational content. For a covered point, it is important not only its own value, but also the availability of neighboring ones, and for the program, the exact moment when the participant loses the right to draw and retains the obligation to help. This way the angled edge remains sharp and finite, although the work around it has a wider area. GPU creates a visible surface with the participation of invisible neighbors; counting the image only by the remaining colored dots means forgetting part of what made these dots happen.

Sources & documentation

  1. Vulkan specification: shaders, derivatives and helper invocations ↗
  2. GLSL_EXT_demote_to_helper_invocation ↗
  3. Vulkan shader demote feature ↗
  4. GLSL 4.60.8 specification ↗