View Full Version : are const variables optimized?
05-30-2006, 04:18 PM
I know this is probably highly driver dependent, but would this ever be optimized (by not actually copying gl_Vertex):
const vec4 vec4Pos = gl_Vertex;
}btw, the reason I do this is to use built-in attributes for non-standard reasons (as opposed to using user-defined attributes).
05-30-2006, 05:02 PM
That will be optimized for sure (on ATI anyway, don't know about other IHVs).
05-30-2006, 05:21 PM
06-02-2006, 12:42 PM
canukle, that code is incorrect. You are declaring a variable const, and then assigning to it. It isn't const at all.
The GLSL compiler on Mac OS X (used for ATI, NV, Intel, and Software renderers), will fail to compile that shader. Any compiler that succeeds is broken.
Assuming the const is removed, a simple assignment like that will ineeded be optimized away.
06-02-2006, 12:53 PM
Yes, it fails to compile on ATI for that reason. Removing the const it works and I verified that it indeed optimizes that away as expected.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.