XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

if and #ifdef in shader code for performance

Last post 05-06-2008 10:24 AM by Gaud. 1 replies.
  • 05-06-2008 8:54 AM

    if and #ifdef in shader code for performance

    if and #ifdef which is better used in shader code and does not affect the performance seriously?

    #ifdef _DEBUG_
    return float4(1.0f,0,0,1);
    #else
    clip(-1);
    #endif

    if (bDeug)
    return float4(1.0f,0,0,1);
    else
    clip(-1);
  • 05-06-2008 10:24 AM In reply to

    Re: if and #ifdef in shader code for performance

    It is all about context. If the particular thing your doing is handling a debug code path over a release then using preprocessors like #ifdef will certainly be better for you. They will make your shaders smaller as the shader code in there will be compiled out. If you use branching you can certainly make things fast but again if your not going to be using whatever is inside the block, using #ifdef will still make it smaller.

    Cheers

    Kyle
Page 1 of 1 (2 items) Previous Next