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
    example:

    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:

    COLOR0, COLOR1, COLOR2, COLOR3

    This is related to CGFX.

    Using_SAS_v1_01.pdf

    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,
    Bye,
    Skybuck.
    Skybuck Flying, Sep 26, 2009
    #1
    1. Advertising

  2. Re: Multiple colors/pixels/outputs per pixel for pixel shaders onDirectX9 graphics cards (OpenGL 3.0) ?

    On Sep 26, 2:39 pm, "Skybuck Flying" <> wrote:
    > 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
    > example:
    >
    > 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:
    >
    > COLOR0, COLOR1, COLOR2, COLOR3
    >
    > This is related to CGFX.
    >
    > Using_SAS_v1_01.pdf
    >
    > 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,
    >   Bye,
    >     Skybuck.


    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
    #2
    1. Advertising

  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 ?

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

    "Skybuck Flying" <> wrote in message
    news:27cf7$4ac328b5$d53372a9$1.nb.home.nl...
    > Ok,
    >
    > Question for you:
    >
    > Suppose the frame/texture buffers are not cleared.


    Doesn't matter probably ;)

    >
    > Suppose only a few verteces are drawn with gl_points.


    Yeah :)

    > This would trigger only a few pixel shaders.


    Yeah probably :)

    > What will MRT do ?


    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 :)

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


    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 ;) :)

    > Or will MRT start copieing everything ?


    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.

    Bye,
    Skybuck.
    Skybuck Flying, Jan 12, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lee Marsh
    Replies:
    8
    Views:
    230
  2. cheezemurda
    Replies:
    3
    Views:
    218
  3. Virgulilla

    Pixel Shaders

    Virgulilla, Dec 26, 2004, in forum: Nvidia
    Replies:
    12
    Views:
    520
    Sam Hamwich
    Mar 13, 2005
  4. amigaboy
    Replies:
    0
    Views:
    374
    amigaboy
    Nov 14, 2005
  5. Skybuck Flying
    Replies:
    2
    Views:
    630
    Wolfgang Draxinger
    Oct 25, 2009
Loading...

Share This Page