1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Multiple colors/pixels/outputs per pixel for pixel shaders on DirectX9 graphics cards (OpenGL 3.0) ?

Discussion in 'Nvidia' started by Skybuck Flying, Sep 26, 2009.

  1. Hello,

    I am wondering if it's possible to output multiple colors/pixels/outputs per
    pixel for a pixel shader ?

    So instead of

    Float4 PSMAin()


    It would be something like (conceptually):
    Float4 Float4 Float4 Float4 PsMain()
    Return Color0/Pixel0/Texture0
    Return Color1/Pixel1/Texture1
    Return Color2/Pixel2/Texture2
    Return Color3/Pixel3/Texture3

    These could be stuffed into a structure to make it look more nice... for

    FourPixels PsMain()
    Return FourPixels;

    However I wonder if this can work on DirectX9 graphics cards because I never
    tried it...

    I also wonder what the necessary opengl bindings would be...

    Probably 4 buffers attached to some frame buffer object and use render to
    texture ?

    The following document mentions 4 output semantics for pixel shaders:


    This is related to CGFX.


    I am not sure if these can all be used at the same time for a pixel
    shader... as demonstrated in the examples above...

    Can somebody please enlighten me ?

    Euhm to be clear, this feature could be handy for gpgpu programming... so
    more state can be kept, processed and passed through the pixel shaders from
    pass to pass.

    Thank you for any answers,
    Skybuck Flying, Sep 26, 2009
    1. Advertisements

  2. I'm sorry that I am not familar with DX but OpenGL. Since GL 2.0, your
    GPU could use MRT in your Pixel Shader to output data into texture
    render targets.

    They could be used at the same time if you prepared the enough render
    targets to retreive the data. In fact the GPU could output unlimited
    render targets but the boundwidth is the greatest problem . As I known
    current GPU supports at most 4 render target, e.g, 4x4=16 FP32
    scalars, that should be enough for defered shading.
    Bo Schwarzstein, Sep 27, 2009
    1. Advertisements

  3. Ok,

    Question for you:

    Suppose the frame/texture buffers are not cleared.

    Suppose only a few verteces are drawn with gl_points.

    This would trigger only a few pixel shaders.

    What will MRT do ?

    Will it only update the pixels from the pixel shaders on the multiple render
    targets ?

    Or will MRT start copieing everything ?

    Skybuck Flying, Sep 30, 2009
  4. I am gonna answer my own questions here since now I have more experience
    with it ! ;) :)

    Doesn't matter probably ;)
    Yeah :)
    Yeah probably :)
    Read the documentation ;)

    In short it can do two things:

    1. If the pixel shader outputs one color via Color0 then it's outputted to
    all buffers.

    2. If the pixel shader outputs individual colors via Color0, Color1, Color2,
    Color3, etc then the colors will respectively end up in Buffer0, Buffer1,
    Buffer2, Buffer3. So Color0 goes to Buffer0, Color1 goes to Buffer1, and so
    on :)
    Yes, Do you think the GPU is crazy ? ;) Why would it do unnecessary work ?

    Seriously that's how it works... the GPU only does what you tell it do... it
    can be pixel-efficient probably ;) :)
    No... if you wanna do a copy... you will have to do that yourself...

    Either via pixel shader... or maybe blending the output with something else.

    Skybuck Flying, Jan 12, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.