A precise definition of fragments, samples, pixels and multisampling?

Hello, I’ve read the specification multiple times fully, and albeit it (and the extension specs) may contain the information I need formally, I haven’t been able to grasp the concepts of fragments, samples, pixels and their relation to eachother, as well as the exact mechanisms of multisampling (to be honest, I think it’s impossible to understand from the specification which appears to mix the terms at random sometimes).

Does anyone know or could kindly give an explanation and a precise definition of those terms? And by definition I mean one that actually puts the items into relation to eachother.

Basically, pixels in a framebuffer are composed of samples. And while I’m oversimplifying a bit, fragments refer to candidate pixels (or samples) that are flowing down the pipeline and haven’t actually hit the framebuffer yet (think of them as pixels or samples in-flight). Bunches of fragments are all composited onto the framebuffer to build your image.

Really briefly: 1XAA aka single sampling refers to the case where there is only 1 sample per pixel. 4XAA refers to the case where there are 4 samples per pixel. Think of a pixel as a rectangular region of your framebuffer. Within it are one or more “point” samples, where the continuous intensity signal which is your scene is sampled; these are the samples. After rendering, all the points within a pixel are “downsampled” (e.g. averaged) together to generate an average intensity. The more samples per pixel, the better your average, but the more it costs you.

MSAA (multisample antialiasing) refers to a technique where there are multiple samples within each pixel (e.g. 4XAA, 8XAA, etc.), and while we only compute shading (i.e. run the fragment shader) once per “pixel” as with single-sample shading, coverage is computed and sampled multiple times per pixel (once per sample). Under-the-hood, depth tests and buffer tests/sets/blends occur on the per-sample level (say for instance if your triangle only overlaps 2 of the 4 subsamples within a pixel, only those two samples’ color/depth values would be affected). Post-downsampling, what this means is that on the edges of your triangles, you’ll get sub-pixel accurate edges which will be nicely antialiasing. However, if you’ve got high-frequency (sub-pixel) detail in your fragment shading, then it won’t help you with that.

MSAA is frequently used because (since the frag shader is still only run 1X per pixel) it is very fast, especially as compared to SSAA (supersample antialiasing) where the frag shader is run “per-sample” rather than per-pixel.

Can you quote some passages? If they are ambiguous or incorrect it’s worth filing a spec bug report.

this might not be related to original post but just curious to know, how would rasterizer works in case of 2 triangles who share the edge?