!!hot!! — Quadreadacrossx
is a specialized High-Level Shader Language (HLSL) intrinsic function introduced with Shader Model 6.0 . It enables direct data sharing between threads within a 2x2 "quad" of pixels on a GPU, specifically allowing a thread to read a value from its neighbor in the horizontal (X) direction. Core Functionality and Mechanism
float4 main(float2 uv : TEXCOORD) : SV_Target
return float4(neighborUV, 0, 1);
Here is a detailed breakdown of what it does and how it works:
| Top-Left (0) | Top-Right (1) | | :---: | :---: | | | Bottom-Right (3) | quadreadacrossx
In GPU architecture, shaders are often executed in groups of $2 \times 2$ threads (4 pixels total), known as a . This grouping is essential for calculating derivatives (ddx, ddy), which determine texture mip-map levels.
quadReadAcrossX reads a value from another lane (thread) in the current . Specifically, it retrieves the value from the horizontal neighbor . is a specialized High-Level Shader Language (HLSL) intrinsic
A common use case is optimizing texture fetches. Instead of every thread sampling a texture (which is bandwidth heavy), you can have only two threads perform the fetch and share the result, or share weights calculated by a neighbor.