071104 / GPU Assembly

previous | next

Looks like I am going to switch to using NV_gpu_program4 instead of GLSL because I need to have hardware ability to pack and unpack. Looks like I will have to again pull the Mac off my list of supported platforms, unless they magically roll out NV_gpu_program4 support in 2008!

Saved by Near Undocumented Features

Found a way output the NV_gpu_program4 assembler code from my GLSL programs. Simply add the following environment variables before running your program (in Linux),

export __GL_WriteProgramObjectSource=1
export __GL_WriteProgramObjectAssembly=1
export __GL_WriteInfoLog=1
export __GL_ShaderPortabilityWarnings=1

This should be a tremendous tool for GLSL optimization as well. One interesting thing I have noticed is that the NVidia drivers are using an unreleased Cg 2.0 cgc compiler to compile GLSL in the driver. Also reading this output should give me a great idea of how to optimize for scaler instructions.

NV_gpu_program4 and NV_transform_feedback

Also turns out that it should be easy to use transform feedback with assembly shaders, simply use TransformFeedbackAttribsNV(). Also found this attribute mapping in NVidia's GLSL Enhancements doc,

0 = gl_Vertex
2 = gl_Normal
3 = gl_Color
4 = gl_SecondaryColor
5 = gl_FogCoord
8 = gl_MultiTexCoord0
9 = gl_MultiTexCoord1
10 = gl_MultiTexCoord2
11 = gl_MultiTexCoord3
12 = gl_MultiTexCoord4
13 = gl_MultiTexCoord5
14 = gl_MultiTexCoord6
15 = gl_MultiTexCoord7

This should be all the tools and info I need to get back up to speed with a GLSL to GPU assembly conversion.