Skip to main content
GameDev.net gamedev.net
🔒 Locked

Cg Semantics ??

Started by Great_White Jul 19, 2008 at 2:13 AM 1 replies 5.7k views
Original Post
Great_White
Great_White
What's the purpose of using semantics in shading languages? Are they hardware gpu releated storage locations ? Any help would be appreciated.
"A human being is a part of a whole, called by us,universe, a part limited in time and space. He experiences himself, his thoughts and feelings as something separated from the rest... a kind of optical delusion of his consciousness. This delusion is a kind of prison for us, restricting us to our personal desires and to affection for a few persons nearest to us. Our task must be to free ourselves from this prison by widening our circle of compassion to embrace all living creatures and the whole o
idinev
idinev
I use them to specify the hardware registers to be used. Here's a bit docs that I copied from the cg reference pdf into a neat table, putting it in a header, to look it up easily.

2) making textures take a specific unit:	Units are TEXUNIT0... TEXUNIT15	uniform texture2D myTex : TEXUNIT7;	uniform textureRect myRect : TEXUNIT3; 3) binding semantics for Uniform data:	uniform vec4 data1 : C0;	uniform vec3 data2 : register(c1);	uniform vec4 data3 : C2;	Constants are c0...c2554) binding semantics for attribute Input:	attribute vec4 myAtt : ATTR7;	POSITION, ATTR0				Input Vertex, Generic Attribute 0	BLENDWEIGHT, ATTR1			Input vertex weight, Generic Attribute 1	NORMAL, ATTR2				Input normal, Generic Attribute 2	COLOR0, DIFFUSE, ATTR3		Input primary color, Generic Attribute 3	COLOR1, SPECULAR, ATTR4		Input secondary color, Generic Attribute 4	TESSFACTOR, FOGCOORD,ATTR5	Input fog coordinate, Generic Attribute 5	PSIZE, ATTR6				Input point size, Generic Attribute 6	BLENDINDICES, ATTR7			Generic Attribute 7	TEXCOORD0-TEXCOORD7,			ATTR8-ATTR15		Input texture coordinates (texcoord0-	texcoord7), Generic Attributes 8–15	TANGENT, ATTR14				Generic Attribute 14	BINORMAL, ATTR15			Generic Attribute 155) binding semantics for varying Output/Input:	varying vec4 myVar1 : TEX0;	POSITION, HPOS		Output position	PSIZE, PSIZ			Output point size	FOG, FOGC			Output fog coordinate	COLOR0, COL0		Output primary color	COLOR1, COL1		Output secondary color	BCOL0				Output backface primary color	BCOL1				Output backface secondary color	TEXCOORD0-TEXCOORD7,	TEX0-TEX7			Output texture coordinates	CLP0-CL5			Output Clip distances


For instance, in my glsl code, that I will compile with cgc.exe, if I want one of my textures to be exactly using unit 7, just specify:

uniform texture2D myTex : TEXUNIT7;

It is very useful, as I can skip setting-up some special textures again and again (env cubemap, global noise texture, etc). Also, it's vital when I develop shaders, that I will be compiling and passing them as ARB (asm) shaders, because if I don't use some varying in both the vtx-shader and frag-shader, their order is messed-up. For instance, if I have 3 varyings: "v1,v2,v3", and I don't use v1 in the frag-shader, then the data I expect in v2 will be actually in v3. Once I specify which registers to be used, I can be sure my data will be properly passed. Also, I can know the address of uniforms easily :).
I use ARB shaders, because I don't want to recompile 500 shaders at runtime and I don't want to make it easy for the driver to decide to recompile shaders if I set some uniform to "0.0f".

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.