Google-apps
Hoofdmenu

Post a Comment On: C0DE517E

"Quick shader tip"

3 Comments -

1 – 3 of 3
Blogger Nick said...

I haven't experimented with const in shaders; what kind of bugs have you seen? Is it specific to a particular shader language?

BTW, thought it was worth mentioning that in C++ the usual reason to care about const pointers as parameters is for alias optimization.

http://www.compileroptimizations.com/category/alias_optimization_const_qualifier.htm

Despite being marked uncommon on that page, I have seen this optimization (although I haven't checked for it recently).

July 24, 2008 at 10:19 PM

Blogger DEADC0DE said...

Some versions of the DirectX HLSL compiler do produce bad code (corrupted) with const. I could not really nail down when it happens, but I've seen it happening, more than once.

July 24, 2008 at 10:57 PM

Blogger DEADC0DE said...

And by the way, const objects are good, in C++, the unuseful thing (optimization-wise) is passing non-const objects as const! And to avoid pointer aliasing, the best thing is to use the restrict keyword (even if it's not in the C++ standard yet, so you might want to wrap it into a macro defined depending on your compiler)

July 24, 2008 at 11:03 PM

You can use some HTML tags, such as <b>, <i>, <a>

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.
Please prove you're not a robot