
NVidia Shaders integration
Hi everyone!
Messing around with NVidia SDK I discovered that it comes with a shader compiler called "CGC.exe"...
This compiler can (duh) compile shaders from different hardware profiles.. and output GPU assembler code...
Something like this:
Code:
PARAM c[1] = { { 0.99999988, 1, 0 } };
TEMP RC, HC;
BB0:
MOV result.texcoord[0], c[0].z;
MOV result.texcoord[1], vertex.texcoord[1];
MOV result.texcoord[2], vertex.texcoord[2];
MOV result.texcoord[3], c[0].z;
MOV result.color, vertex.color;
MOV result.texcoord[4].xyz, c[0].z;
MOV result.position.zw, c[0].xyxy;
MOV result.position.xy, vertex.position;
END
# 8 instructions, 0 R-regs
Using the Pre-Build commands I made my project call "cgc.exe" passing the current shader file to it!
The result is FD actually compiling a shader and generating a GPU-ASM output!
After that I had the following idea!
1) Create classes with names of the shader data types / functions / commands, inside a "nvidia" package
class float3
class float4
class struct
function normalize()
and so on...
2) Choose AS3 as syntax hilight
3) Inside my "Shader.cg" I put
#ifdef FD
import nvidia.*;
#endif
This trick made all classes/functions inside nvidia package visible to the Shader, but do not mess with the compiling!
Follow this link with you want to test it!
http://www.thelaborat.org/fd_shader/ShaderProject.zipThe syntax is still incomplete but it is functional!
If the build don't work try to get the SDK here
http://developer.nvidia.com/object/cg_toolkit.htmlFuture Flash 3d API "Molehill" probably will use this kind of GPU-ASM code internally! So compiling shaders with CGC would generate outputs usefull for future applications!
Any questions mail-me!
Thanks!