NAME
cgc - cg compiler driver
SYNOPSIS
cgc [options] file ...
DESCRIPTION
cgc is the standalone Cg compiler which translates Cg or GLSL programs into OpenGL or DirectX shader assembly code, or OpenGL or DirectX shading language code.
OPTIONS
Basic options
- -entry name
Sets the entry function for the shader to compile. Defaults to
main- -o file
Sets the output file to be written. Default outputs to stdout
- -l file
Sets the listing file, where error and warning messages are written. Defaults to stderr
- -profile name
Selects the target profile, specifying the shader language to be generated
- -profileopts opt1,opt2,...
- -po opt1,opt2,...
Sets one or more profile specific options
- -noentry
Sets check only mode, where no shader is compiled, but all the code in the input file is checked for syntactic correctness
Language options
- -oglsl
Sets the source language to GLSL.
- -ogles
Sets the source language to OpneGL/ES GLSL.
- -strict
- -nostrict
Enable or disable strict typechecking, where most questionable constructs will be flagged as warnings.
- -glslWerror
Like
-strictbut in addition, unportable GLSL constructs will be flagged as errors- -nowarn
Disable all warnings
- -nowarn=N,N,...
Disable one or more specific numbered warnings
- -fx
- -nofx
Enables or disables FX parsing mode, where FX keywords are recognized. Defaults to on in Cg mode and off in GLSL mode
- -nostdlib
Disable the standard library.
Code Generation Options
- -fastmath
- -nofastmath
Enable or disable optimizations that may chage/lose precision in low order bits, such as assocative transforms like
(a + b) + cinstead ofa + (b + c). Default is -fastmath- -fastprecision
- -nofastprecision
Enable or disable optimzations doing operations at lower precision than is specified when the result is later converted to a lower precision or the operands were originally in lower precision. Default is -nofastprecision
- -bestprecision
Always do things in the best possible precision; only use lower precision operations if there is no possibility of difference. Implies -nofastmath and -nofastprecision
- -unroll all|none|count=N
Control loop unrolling.
-unroll allwill force unrolling of all loops that can be unrolled, while-unroll nonewill prevent unrolling except if code cannot otherwise be generated in the current profiles (so it will have no effect in profiles that don't support looping).unroll count=Nwill unroll loops if the estimate of the resulting code is less than N instructions. The estimate does not take into account further optimizations that may be done after unrolling, so it might be quite inaccurate.- -inline all|none|count=N
Control function inlining. Setting
-inline nonewill additionally disable inlining of functions with an explicitinlinekeyword, which are otherwise always inlined. Setting-inline count=0will effectively disable inlining of all functions that do not have an explicitinlinekeyword.- -ifcvt all|none|count=N
control if conversion (replacement of small if/else blocks with conditional assignments)
- -ON
Sets the optimization level of the compiler, from 0 (lowest) to 3 (highest). Higher values may produce better code and will cause compile time to increase. Default is
-O1.- -looplimit N
Assume loops that the compiler cannot determine an upper bound on the number of iterations may loop as many as N iterations. This may require generating extra code for such loops in some profiles.
- -d3d
Generate code compatable with the Direct3D specification.
- -MaxInstInBasicBlock N
break basic blocks after N instructions. This has an effect on local optimizations that don't cross basic block boundaries and may avoid bad compile time blowups in the presence of huge basic blocks due to algorithms that are non-linear in the basic block size.
- -maxunrollcount N
Deprecated. Don't unroll loops with more than N iterations. Use the -unroll option instead, which provides better fine-grained control.
Preprocessor Options
- -DMACRO[=VALUE]
Sets a preprocessor macro. If VALUE is not specified it defaults to
1.- -Idirectory
Adds a directory to the end of the search path for
#includefiles. The default search path is empty.- -E
Don't compile, just prepocess the input.
- -P
With
-E, supresses the generation of#linedirectives in the output.- -C
With
-E, preserves comments in the output.- -MG
Ignore
#includefiles that can't be found, rather than issuing an error- -M
- -MM
- -MD
- -MMD
- -MP
- -MF file
- -MT target
- -MQ target
Generate dependency information about
#included files. These options are intended to be compatible with the options togccMiscellaneous Options
- -quiet
- -q
Supress all 'noise' output (copyright notices, indications of which files are being compiled, etc). With -o and -l, should result in no output being produced.
- -nocode
Supress final code generation. Will actually run all the way through the compiler (so any errors present should be diagnosed), but don't produce any actual output code.
- -v
- --version
Print compiler version information to listing.
- -h
Print short option help summary to stdout and exit
- -help
Print longer option help summary to stdout, including all supported profiles and profile options, and exit
- -type type_definition
Set an override type binding for a variable
- -typefile file
Read override type bindings for variables from a file.
- -dumpinputbind
Dump type bindings for all variables to a file. This file may be passed back to the compiler with
-typefile.Debugging options
- -debug
Enable the
debugbuiltin function to abort operation of a shader and immedaitely output a value.- -debuglast
Like
-debug, except the shader does not abort; instead it continues and outputs the value of the lastdebugfunction called.- -debugdefault=value
Like
-debug, except if nodebugcall is reached, the output will be set to the specified value instead of what the shader normally computes.PROFILES
A profile specifies the output language of the cg compiler (either a shader assembly dialect, or a shading language). Each profile has its own set of profile options that can be set for it, though many related profiles have similar or identical options. Profiles can be grouped by program type, API, or GPU generation.
- DirectX profiles
dx8ps,dx8vs,dx9ps2,dxvs2,hlslf,hlslv,ps_1_1,ps_1_2,ps_1_3,ps_2_0,ps_2_x,ps_3_0,vs_1_1,vs_2_0,vs_2_x,vs_3_0- OpenGL profiles
arbfp1,arbvp1,fp20,fp30,fp30unlimited,fp40,fp40unlimited,glslf,glslv,gp4fp,gp4gp,gp4vp,gpu_fp,gpu_gp,gpu_vp,vp20,vp30,vp40- Fragment profiles
arbfp1,dx8ps,dx9ps2,hlslf,fp20,fp30,fp30unlimited,fp40,fp40unlimited,glslf,gp4fp,gpu_fp,ps_1_1,ps_1_2,ps_1_3,ps_2_0,ps_2_x,ps_3_0- Geometry profiles
gp4gp,gpu_gp- Vertex profiles
arbvp1,dx8vs,dxvs2,glslv,gp4vp,gpu_vp,hlslv,vp20,vp30,vp40,vs_1_1,vs_2_0,vs_2_x,vs_3_0- Geforce 3/4 profiles
fp20,vp20- Geforce 5 profiles
fp30,vp30- Geforce 6/7 profiles
fp40,vp40- Geforce 8 profiles
gp4fp,gp4gp,gp4vp,gpu_fp,gpu_gp,gpu_vpProfile options
Here is a complete list of all profiles and their corresponding profile options
arbfp1Targets the ARB_fragment_program OpenGL extension
-poARB_draw_buffersUse the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default
-poATI_draw_buffersUse the ATI_draw_buffers option for multiple renderbuffer targets (MRT).
-poMaxDrawBuffers=NSet the maximum number of renderbuffer targets. Default is 1
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 32
-poMaxTexIndirections=NSets the maximum number of texture indirections allowed in the output program. Default is 1024
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 1024
-poNumMathInstructionSlots=NSets the maximum number of non-texture instructions in the output program. Default is 1024
-poNumTemps=NSets the maximum number of TEMP registers in the output program. Default is 32
-poNumTexInstructionSlots=NSets the maximum number of texture instructions in the output program. Default is 1024
arbvp1Targets the ARB_vertex_program OpenGL extension
-poMaxAddressRegs=NSets the maximum number of ADDRESS registers in the output program. Default is 1
-poMaxInstructions=NSets the maximum number of instructions in the output program. Default is 1024
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 96
-poNumTemps=NSets the maximum number of TEMP registers in the output program. Default is 32
-poPosInvGenerate position invariant code (same as fixed-function) for POSITION output
dx8psTargets DirectX8 pixel programs (ps 1.1)
-poMaxPixelShaderValue=NMaximum absolute value representable in a pixel shader. Default is 1.
dx8vsTargets DirectX8 vertex programs (vs 1.1)
-podclsOutput dx9-style dcls statements
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 96
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 128
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 12
dx9ps2Targets DirectX9 pixel programs (ps 2.0)
-poMaxDrawBuffers=NSet the maximum number of renderbuffer targets. Default is 1
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 96
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 12
dxvs2Targets DirectX9 vertex programs (ps 2.0)
-podclsOutput dx9-style dcls statements
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 32
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 256
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 12
fp20Targets the NV_register_combiners2 and NV_texture_shader OpenGL extensions
fp30Targets the NV_fragment_program OpenGL extension
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 256
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 32
fp30unlimitedSame as
fp30with various hardware limits on registers and instructions lifted
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 4194304
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 512
fp40Targets the NV_fragment_program2 OpenGL extension
-poappleKilWARWork around various bugs with KIL instructions in the OSX-tiger implementation of NV_fragment_program2
-poARB_draw_buffersUse the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default
-poATI_draw_buffersUse the ATI_draw_buffers option for multiple renderbuffer targets (MRT).
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is infinite
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is infinite
-poNumTemps=NSets the maximum number of TEMP registers in the output program. Default is infinite
-poOutColorPrec=NIf N is 3 or 4, force output to fp16 precision. If N is 2, force output to fp32 precision.
fp40unlimitedSame as
fp40with various hardware limits on registers and instructions lifted
-poappleKilWARWork around various bugs with KIL instructions in the OSX-tiger implementation of NV_fragment_program2
-poARB_draw_buffersUse the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default
-poATI_draw_buffersUse the ATI_draw_buffers option for multiple renderbuffer targets (MRT).
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 1024
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 4194304
-poNumTemps=NSets the maximum number of TEMP registers in the output program. Default is 512
-poOutColorPrec=NIf N is 3 or 4, force output to fp16 precision. If N is 2, force output to fp32 precision.
genericProduces a dump of the program in a non-executable format
glslfglslvTargets the OpenGL Shading language (GLSL) v1.10.
glslftargets fragment programs whileglslvtargets vertex programsgp4fpgpu_fpTargets the NV_gpu_program4 and NV_fragment_program4 OpenGL extensions.
-poARB_draw_buffersUse the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default
-poATI_draw_buffersUse the ATI_draw_buffers option for multiple renderbuffer targets (MRT).
gp4gpgpu_gpTargets the NV_gpu_program4 and NV_geometry_program4 OpenGL extensions.
-poPOINT-poLINE-poLINE_ADJ-poTRIANGLE-poTRIANGLE_ADJSet the input primitive type for the geometry program
-poPOINT_OUT-poLINE_OUT-poTRIANGLE_OUTSet the output primitive type for the geometry program
-poVertices=NSet the number of vertices output by the geometry program
gp4vpgpu_vpTargets the NV_gpu_program4 and NV_vertex_program4 OpenGL extensions.
-poPosInvGenerate position invariant code (same as fixed-function) for POSITION output
hlslfhlslvTargets Microsoft High-Level Shading Language (HLSL).
hlslftargets pixel programs whilehlslvtargets vertex programsps_1_1ps_1_2ps_1_3Targets DirectX pixel programs
-poMaxPixelShaderValue=NMaximum absolute value representable in a pixel shader. Default is 1.
ps_2_0ps_2_xTargets DirectX pixel programs
-poMaxDrawBuffers=NSet the maximum number of renderbuffer targets. Default is 1
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 96 or 512
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 12 or 32
ps_3_0Targets DirectX pixel programs
-poMaxDrawBuffers=NSet the maximum number of renderbuffer targets. Default is 1
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 224
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 32768
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 32
-poOutColorPrec=NIf N is 3 or 4, force output to fp16 precision. If N is 2, force output to fp32 precision.
vp20Targets the NV_vertex_program OpenGL extension
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 96
-poPosInvGenerate position invariant code (same as fixed-function) for POSITION output
vp30Targets the NV_vertex_program2 OpenGL extension
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 256
-poPosInvGenerate position invariant code (same as fixed-function) for POSITION output
vp40Targets the NV_vertex_program3 OpenGL extension
-poMaxAddressRegs=NSets the maximum number of ADDRESS registers in the output program. Default is 2
-poMaxInstructions=NSets the maximum number of instructions in the output program. Default is 2048
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 544
-poNumTemps=NSets the maximum number of TEMP registers in the output program. Default is 32
-poPosInvGenerate position invariant code (same as fixed-function) for POSITION output
vs_1_1Targets DirectX vertex programs
-podclsOutput dx9-style dcls statements
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 96
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 128
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 12
vs_2_0vs_2_xTargets DirectX vertex programs
-podclsOutput dx9-style dcls statements
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 256
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 256
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 12
vs_3_0Targets DirectX vertex programs
-podclsOutput dx9-style dcls statements
-poMaxLocalParams=NSet the maximum number of uniform parameter slots available. Default is 256
-poNumInstructionSlots=NSets the maximum number of instructions in the output program. Default is 32768
-poNumTemps=NSets the maximum number of temporaries in the output program. Default is 32
ENVIRONMENT
SEE ALSO
Cg_language, arbfp1, arbvp1, fp20, fp30, fp40, glslf, glslv, gp4fp, gp4gp, gp4vp, hlslf, hlslv, vp20, vp30, vp40