View unanswered posts | View active topics


Reply to topic  [ 1 post ] 
NVidia Shaders integration 
Author Message
Member

Joined: Tue Nov 23, 2010 3:10 am
Posts: 1
Post 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.zip

The 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.html

Future 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!


Tue Nov 23, 2010 1:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.