tag:blogger.com,1999:blog-6950833531562942289.post8355784472685032741..comments2024-03-25T03:36:48.099-07:00Comments on C0DE517E: Quick shader tipDEADC0DEhttp://www.blogger.com/profile/01477408942876127202noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6950833531562942289.post-75466149992085738912008-07-24T23:03:00.000-07:002008-07-24T23:03:00.000-07:00And by the way, const objects are good, in C++, th...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)DEADC0DEhttps://www.blogger.com/profile/01477408942876127202noreply@blogger.comtag:blogger.com,1999:blog-6950833531562942289.post-60290584736696153452008-07-24T22:57:00.000-07:002008-07-24T22:57:00.000-07:00Some versions of the DirectX HLSL compiler do prod...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.DEADC0DEhttps://www.blogger.com/profile/01477408942876127202noreply@blogger.comtag:blogger.com,1999:blog-6950833531562942289.post-35246934928715838672008-07-24T22:19:00.000-07:002008-07-24T22:19:00.000-07:00I haven't experimented with const in shaders; what...I haven't experimented with const in shaders; what kind of bugs have you seen? Is it specific to a particular shader language?<BR/><BR/>BTW, thought it was worth mentioning that in C++ the usual reason to care about const pointers as parameters is for alias optimization.<BR/><BR/>http://www.compileroptimizations.com/category/alias_optimization_const_qualifier.htm<BR/><BR/>Despite being marked uncommon on that page, I have seen this optimization (although I haven't checked for it recently).Nickhttps://www.blogger.com/profile/07554585746004123227noreply@blogger.com