Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Multisampling in pipeline

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207

    Multisampling in pipeline

    In multisampling, during rasterization there are more than one sample points in each pixel and sample points are decided which constitutes the primitive.

    which attributes are same for each sample in a pixel? I read somewhere that color and texture values are same but depth and stensil values for samples in a pixel are different. But as fragment shader is executed for each sample points then they should be different.

    Also, When does the multiple samples are resolved in pipeline, after fragment shader? And do they linearly average out?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2009
    Posts
    212
    If you have <n> samples per Pixel, the OpenGL may run the fragment shader any number between 1 and <n> times per fragment. If the number of fragment shader invocations is less than the number of samples, it will obviously replicate some fragment shader outputs to multiple samples. This is also true if you write to depth and/or stencil in the fragment shader (using extensions), but if you don't overwrite the system-provided depth and stencil values, they will be computed per-sample.

    The samples will be resolved when the multisample framebuffer is blitted to a non-multisample framebuffer. In case of the system framebuffer this is usually the case when it is copied to the front framebuffer in glxSwapBuffers().

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Thanks for your reply..!!

    Quote Originally Posted by mbentrup View Post
    If you have <n> samples per Pixel, the OpenGL may run the fragment shader any number between 1 and <n> times per fragment. If the number of fragment shader invocations is less than the number of samples, it will obviously replicate some fragment shader outputs to multiple samples. This is also true if you write to depth and/or stencil in the fragment shader (using extensions), but if you don't overwrite the system-provided depth and stencil values, they will be computed per-sample.
    I am still confused with depth and stencil values, you said fragment shader is executed per sample so depth and stencil values will be calculated per sample of a pixel?
    And if we don't modify them in shader ( we can modify depth by gl_FradDepth, how to modify stencil ?) then also they will be calculated per sample? what is difference between two?

    Also, I read in "Advanced Graphics Programming Using OpenGL" chapt 6.1 that "The specification allows the color and texture values to be the same for all samples within a pixel; only the depth and stencil information must represent the values at the sample point."

  4. #4
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    Stencil is controlled by depth-fail/pass conditions.
    The depth+stencil operations always run at fullrate (e.g 8x), while the fragment will be run only in 1x, if any of the 8 depth/stencil tests pass. The fragment's texcoords will be interpolated at pixel center, but you can mark some of the texcoords to be interpolated at "centroid" position.
    In newer GL, this has been extended a bit, (ARB_sample_shading) you can tell the driver to run the fragment-shader at 8x, too - to get supersampling instead of multisampling. There you get 8 fragment shader instances run per pixel, and each has slightly different texcoords.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Thanks for your reply.

    And how does multisampled textures work?

  6. #6
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    They are textures with N texel values per texel. Every hardware has different memory layout for them, so only the specialized texelFetch(texMSAA, ivec2coord, int sampleIdx) function has to be used to grab data. For simplification purposes, you can imagine a 8xMSAA 128x128 texture as being a 1024x128 one, and fexelFetch(tex, ivec2(10,20) , 3) is somewhat like a texelFetch(tex, ivec2(10*8+3,20)).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •