View Full Version : static branching with cG ?
06-22-2006, 10:49 AM
I'm currently working on a DX9/OGL renderer
I'implemented a very simple vertex shader to test the latest static branching feature
something like that :
uniform bool bAddAmbient : register(b0),
..)on DX9 no problem to run it using the SetVertexShaderConstantB function
the problem arrives on OGL.. i use the cgCreateProgram to compile at runtime the vertex shaders.
but this precedent line creates the following error :
error C5123: invalid register semantic "b0"it seems that static branching isn't supported by cg ??
any ideas ?
thanks a lot !!
06-22-2006, 07:55 PM
I am no Cg expert at all, but I have only ever seen manual register assignment in HLSL. (not in Cg).
As Cg in OpenGL compiles to NV/ARB ASM that does not have "registers" like D3D does, I don't know how it would work.
Perhaps you can just specify as a bool without the register assignment and test to see if static branching is picked up by the compiler? (compiler should be smart enough)
06-23-2006, 03:11 AM
yes i can specify a constant bool without the register assignment like that:
uniform bool bAddAmbient;
but i need to access the bool via its register assigned, not its name (performance issue)
nevermind a tried this but the problem now is how i can set the register value via cg ?
this kind of function doesnt' exist ! ;)
06-23-2006, 06:28 AM
I am still a Cg n00b, but I always thought Cg worked like this:
//At compile time get the parameter index
CGparameter TimeParam1 = cgGetNamedParameter(program1, "time");
//At runtime set the value
So you should not need to set the bool via it's name at runtime. (I see there is no cgGLSetParameter1b, but using cgGLSetParameter1f should work for bools - Cg experts correct this if wrong)
You may also want to look into Parameter Literalization (page 2 of Cg reference manual - http://download.nvidia.com/developer/cg/Cg_1.4/1.4.1/Cg-1.4.1_ReferenceManual.pdf )
06-23-2006, 04:01 PM
That's the way I remember it as well, but it's been a while. I don't recall messing with registers.
06-23-2006, 06:30 PM
You can assing a uniform to a specific constant register using the Cn semantic.
uniform bool bAddAmbient : C21;
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.