CGC(1)

๐Ÿ‘‘ CGC(1) โ€” the cg compiler driver

okay so real talk: cgc is the standalone Cg compiler, and it is the main character of this manual page (it lives in the "Cg Commands" section of the manual, iykyk). She takes your Cg or GLSL programs and translates them into OpenGL or DirectX shader assembly code, or into OpenGL or DirectX shading language code. That's it, that's the whole job, and she ate. ๐Ÿ’…


๐ŸŒธ 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. she just does that. ๐Ÿฆ‹


๐ŸŽ€ 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. (same flag, two names, slay)
  • -noentry โ€” Sets check only mode, where no shader is compiled, but all the code in the input file is checked for syntactic correctness. Just vibes-checking your code, no output. ๐Ÿซถ

Language options

  • -oglsl โ€” Sets the source language to GLSL.
  • -ogles โ€” Sets the source language to OpenGL/ES GLSL.
  • -strict / -nostrict โ€” Enable or disable strict typechecking, where most questionable constructs will be flagged as warnings.
  • -glslWerror โ€” Like -strict but in addition, unportable GLSL constructs will be flagged as errors. no more mr. nice compiler ๐Ÿ˜ญ
  • -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 change/lose precision in low order bits, such as associative transforms like "(a + b) + c" instead of "a + (b + c)". Default is -fastmath.
  • -fastprecision / -nofastprecision โ€” Enable or disable optimizations 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 all will force unrolling of all loops that can be unrolled, while -unroll none will 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=N will 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. she's guessing a little, bestie, be nice ๐Ÿ™ˆ
  • -inline all|none|count=N โ€” Control function inlining. Setting -inline none will additionally disable inlining of functions with an explicit "inline" keyword, which are otherwise always inlined. Setting -inline count=0 will effectively disable inlining of all functions that do not have an explicit "inline" keyword.
  • -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 compatible 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 "#include" files. The default search path is empty.
  • -E โ€” Don't compile, just prepocess the input.
  • -P โ€” With -E, suppresses the generation of "#line" directives in the output.
  • -C โ€” With -E, preserves comments in the output.
  • -MG โ€” Ignore "#include" files 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 "#include"d files. These options are intended to be compatible with the options to "gcc". ๐Ÿซก

Miscellaneous Options

  • -quiet / -q โ€” Suppress all 'noise' output (copyright notices, indications of which files are being compiled, etc). With -o and -l, should result in no output being produced. silence is golden, periodt
  • -nocode โ€” Suppress 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 file โ€” 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 "debug" builtin 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 last "debug" function called.
  • -debugdefault=value โ€” Like -debug, except if no "debug" call is reached, the output will be set to the specified value instead of what the shader normally computes.
  • -deprecated โ€” Issue errors instead of warnings for any deprecated features used.

๐ŸŒˆ 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. it's giving choose-your-own-adventure, honestly. ๐Ÿงš

DirectX profiles

ds_5_0, gs_4_0, gs_5_0, hlslf, hlslv, hs_5_0, ps_1_1, ps_1_2, ps_1_3, ps_2_0, ps_2_x, ps_3_0, ps_4_0, ps_5_0, vs_1_1, vs_2_0, vs_2_x, vs_3_0, vs_4_0, vs_5_0

OpenGL profiles

arbfp1, arbvp1, fp20, fp30, "fp30unlimited", fp40, "fp40unlimited", glslf, glslg, glslv, gp4fp, gp4gp, gp4vp, gp5fp, gp5gp, gp5tcp, gp5tep, gp5vp, vp20, vp30, vp40

Fragment profiles

arbfp1, fp20, fp30, "fp30unlimited", fp40, "fp40unlimited", glslf, gp4fp, gp5fp, hlslf, ps_1_1, ps_1_2, ps_1_3, ps_2_0, ps_2_x, ps_3_0, ps_4_0, ps_5_0

Geometry profiles

glslg, gp4gp, gp5gp, gs_4_0, gs_5_0

Vertex profiles

arbvp1, glslv, gp4vp, gp5vp, hlslv, vp20, vp30, vp40, vs_1_1, vs_2_0, vs_2_x, vs_3_0, vs_4_0, vs_5_0

GeForce 3/4 Series profiles

fp20, vp20

GeForce 5 Series profiles

fp30, vp30

GeForce 6/7 Series profiles

fp40, vp40

GeForce 8/9/100/200/300 Series, OpenGL 3.x Quadro profiles

gp4fp, gp4gp, gp4vp

GeForce 400 Series, OpenGL 4.x Quadro profiles

gp5fp, gp5gp, gp5tcp, gp5tep, gp5vp


โญ Profile options โญ

Here is a complete list of all profiles and their corresponding profile options. yes, all of them. no skipping. ๐Ÿ‘‘

arbfp1

Targets the ARB_fragment_program OpenGL extension

  • -po ARB_draw_buffers โ€” Use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default
  • -po ATI_draw_buffers โ€” Use the ATI_draw_buffers option for multiple renderbuffer targets (MRT).
  • -po MaxDrawBuffers=N โ€” Set the maximum number of renderbuffer targets. Default is 1
  • -po MaxLocalParams=N โ€” Set the maximum number of uniform parameter slots available. Default is 32
  • -po MaxTexIndirections=N โ€” Sets the maximum number of texture indirections allowed in the output program. Default is 1024
  • -po NumInstructionSlots=N โ€” Sets the maximum number of instructions in the output program. Default is 1024
  • -po NumMathInstructionSlots=N โ€” Sets the maximum number of non-texture instructions in the output program. Default is 1024
  • -po NumTemps=N โ€” Sets the maximum number of TEMP registers in the output program. Default is 32
  • -po NumTexInstructionSlots=N โ€” Sets the maximum number of texture instructions in the output program. Default is 1024

arbvp1

Targets the ARB_vertex_program OpenGL extension

  • -po MaxAddressRegs=N โ€” Sets the maximum number of ADDRESS registers in the output program. Default is 1
  • -po MaxInstructions=N โ€” Sets the maximum number of instructions in the output program. Default is 1024
  • -po MaxLocalParams=N โ€” Set the maximum number of uniform parameter slots available. Default is 96
  • -po NumTemps=N โ€” Sets the maximum number of TEMP registers in the output program. Default is 32
  • -po PosInv โ€” Generate position invariant code (same as fixed-function) for POSITION output

fp20

Targets the NV_register_combiners2 and NV_texture_shader OpenGL extensions

fp30

Targets the NV_fragment_program OpenGL extension

  • -po NumInstructionSlots=N โ€” Sets the maximum number of instructions in the output program. Default is 256
  • -po NumTemps=N โ€” Sets the maximum number of temporaries in the output program. Default is 32

okay wait there's more, don't go anywhere โ€” part 2 is coming and she's got even more to say ๐Ÿฆ‹๐Ÿ’œ

fp30unlimited

Okay so it's literally the same as fp30, bestie, except all the hardware limits on registers and instructions have been lifted. No cap. โœจ

  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions that can live in the output program. default is 4194304 ๐Ÿ‘‘
  • -po NumTemps=<em>N</em> โ€” sets the max number of temporaries in the output program. default is 512 ๐ŸŽ€

fp40

This one targets the NV_fragment_program2 OpenGL extension ๐Ÿ’…

  • -po appleKilWAR โ€” works around a bunch of bugs with KIL instructions in the OSX-tiger implementation of NV_fragment_program2 ๐ŸŽ๐Ÿ˜ญ
  • -po ARB_draw_buffers โ€” uses the ARB_draw_buffers option for multiple renderbuffer targets (MRT). this is the default โญ
  • -po ATI_draw_buffers โ€” uses the ATI_draw_buffers option for multiple renderbuffer targets (MRT). ๐Ÿฆ‹
  • -po MaxLocalParams=<em>N</em> โ€” sets the max number of uniform parameter slots available. default is infinite ๐ŸŒˆ
  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions in the output program. default is infinite โœจ
  • -po NumTemps=<em>N</em> โ€” sets the max number of TEMP registers in the output program. default is infinite ๐Ÿ’ซ
  • -po OutColorPrec=<em>N</em> โ€” if <em>N</em> is 3 or 4, it forces output to fp16 precision. if <em>N</em> is 2, it forces output to fp32 precision. periodt. ๐Ÿ’…

fp40unlimited

Same as fp40, except the hardware limits on registers and instructions? lifted. iconic. ๐Ÿ‘‘

  • -po appleKilWAR โ€” works around various bugs with KIL instructions in the OSX-tiger implementation of NV_fragment_program2 ๐ŸŽ
  • -po ARB_draw_buffers โ€” uses the ARB_draw_buffers option for multiple renderbuffer targets (MRT). this is the default โญ
  • -po ATI_draw_buffers โ€” uses the ATI_draw_buffers option for multiple renderbuffer targets (MRT). ๐Ÿฆ‹
  • -po MaxLocalParams=<em>N</em> โ€” sets the max number of uniform parameter slots available. default is 1024 โœจ
  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions in the output program. default is 4194304 ๐Ÿ”ฅ
  • -po NumTemps=<em>N</em> โ€” sets the max number of TEMP registers in the output program. default is 512 ๐ŸŽ€
  • -po OutColorPrec=<em>N</em> โ€” if <em>N</em> is 3 or 4, it forces output to fp16 precision. if <em>N</em> is 2, it forces output to fp32 precision. ๐Ÿ’–

generic

Produces a dump of the program in a non-executable format. it's giving "just vibes, no run" ๐Ÿ˜Œ


glslf, glslg and glslv

These target the OpenGL Shading Language (GLSL) v1.10 ๐ŸŽ€ glslf targets fragment programs, while glslv targets vertex programs. iykyk ๐Ÿ’…

  • version=val โ€” the GLSL version to target. supported versions are 100, 110, 120, 130, 140 and 150. ๐Ÿ‘‘
  • userTexCoord โ€” use a user-defined varying instead of gl_TexCoord. ๐Ÿฆ‹
  • ATI_draw_buffers โ€” use the ATI_draw_buffers extension for MRT. ๐ŸŒธ
  • EXT_gpu_shader4 โ€” use the EXT_gpu_shader4 extension where useful. โœจ

gp4fp

Targets the NV_gpu_program4 and NV_fragment_program4 OpenGL extensions ๐Ÿ’œ

  • -po fastimul โ€” assume integer multiply inputs have at most 24 significant bits. ๐Ÿ”ข
  • -po NV_shader_buffer_load โ€” use the NV_shader_buffer_load OpenGL extension. ๐Ÿงš
  • -po NV_parameter_buffer_object2 โ€” use the NV_parameter_buffer_object2 OpenGL extension. ๐ŸŽ€
  • -po PaBO2 โ€” use the NV_parameter_buffer_object2 OpenGL extension. (same thing, shorter name, slay) ๐Ÿ’…
  • -po ARB_draw_buffers โ€” use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). this is the default โญ
  • -po ATI_draw_buffers โ€” use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). ๐Ÿฆ‹
  • -po pixel_center_integer โ€” use integer pixel centers. ๐Ÿ“
  • -po origin_upper_left โ€” use upper left pixel origin. ๐ŸŒˆ

gp4gp

Targets the NV_gpu_program4 and NV_geometry_program4 OpenGL extensions ๐ŸŽ€

  • -po POINT
  • -po LINE
  • -po LINE_ADJ
  • -po TRIANGLE
  • -po TRIANGLE_ADJ

these set the input primitive type for the geometry program ๐Ÿ‘‘

  • -po POINT_OUT
  • -po LINE_OUT
  • -po TRIANGLE_OUT

these set the output primitive type for the geometry program โœจ

  • -po Vertices=<em>N</em> โ€” set the number of vertices output by the geometry program. ๐Ÿ”ข

gp4vp

Targets the NV_gpu_program4 and NV_vertex_program4 OpenGL extensions ๐Ÿ’œ

  • -po PosInv โ€” generate position invariant code (same as fixed-function) for POSITION output. ๐ŸŽฏ

gp5fp

Targets the NV_gpu_program5 OpenGL extension โœจ

  • -po fastimul โ€” assume integer multiply inputs have at most 24 significant bits. ๐Ÿ”ข
  • -po NV_shader_buffer_load โ€” use the NV_shader_buffer_load OpenGL extension. ๐Ÿงš
  • -po NV_parameter_buffer_object2 โ€” use the NV_parameter_buffer_object2 OpenGL extension. ๐ŸŽ€
  • -po PaBO2 โ€” use the NV_parameter_buffer_object2 OpenGL extension. ๐Ÿ’…
  • -po ARB_draw_buffers โ€” use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). this is the default โญ
  • -po ATI_draw_buffers โ€” use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). ๐Ÿฆ‹
  • -po pixel_center_integer โ€” use the ARB_fragment_coord_conventions OpenGL extension to specify integer pixel centers. ๐Ÿ“
  • -po origin_upper_left โ€” use the ARB_fragment_coord_conventions OpenGL extension to specify upper left pixel origin. ๐ŸŒˆ
  • -po NV_early_fragment_tests โ€” perform depth and stencil tests prior to fragment program invocation. ๐Ÿ”ฅ

gp5gp

Targets the NV_gpu_program5 OpenGL extension ๐Ÿ’œ

  • -po POINT
  • -po LINE
  • -po LINE_ADJ
  • -po TRIANGLE
  • -po TRIANGLE_ADJ

set the input primitive type for the geometry program ๐Ÿ‘‘

  • -po POINT_OUT
  • -po LINE_OUT
  • -po TRIANGLE_OUT

set the output primitive type for the geometry program โœจ

  • -po Vertices=<em>N</em> โ€” set the number of vertices output by the geometry program. ๐Ÿ”ข

gp5tcp

Targets the NV_tessellation_program and NV_gpu_program5 OpenGL extensions ๐ŸŽ€


gp5tep

Targets the NV_tessellation_program and NV_gpu_program5 OpenGL extensions โœจ


gp5vp

Targets the NV_gpu_program5 OpenGL extension ๐Ÿ’œ

  • -po PosInv โ€” generate position invariant code (same as fixed-function) for POSITION output. ๐ŸŽฏ

hlslf hlslv

Targets Microsoft High-Level Shading Language (HLSL) ๐ŸชŸ hlslf targets pixel programs, while hlslv targets vertex programs. bestie behavior fr fr ๐Ÿ’…


ps_1_1 ps_1_2 ps_1_3

Targets DirectX pixel programs ๐ŸŽฎ

  • -po MaxPixelShaderValue=<em>N</em> โ€” the max absolute value representable in a pixel shader. default is 1. ๐Ÿ”ข

ps_2_0 ps_2_x

Targets DirectX pixel programs ๐ŸŽฎ

  • -po MaxDrawBuffers=<em>N</em> โ€” set the max number of renderbuffer targets. default is 1 ๐ŸŽ€
  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions in the output program. default is 96 or 512 โœจ
  • -po NumTemps=<em>N</em> โ€” sets the max number of temporaries in the output program. default is 12 or 32 ๐Ÿ’ซ

ps_3_0

Targets DirectX pixel programs ๐ŸŽฎ

  • -po MaxDrawBuffers=<em>N</em> โ€” set the max number of renderbuffer targets. default is 1 ๐ŸŽ€
  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 224 โœจ
  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions in the output program. default is 32768 ๐Ÿ”ฅ
  • -po NumTemps=<em>N</em> โ€” sets the max number of temporaries in the output program. default is 32 ๐Ÿ’ซ
  • -po OutColorPrec=<em>N</em> โ€” if <em>N</em> is 3 or 4, it forces output to fp16 precision. if <em>N</em> is 2, it forces output to fp32 precision. ๐Ÿ’–

vp20

Targets the NV_vertex_program OpenGL extension ๐Ÿ’œ

  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 96 ๐ŸŽ€
  • -po PosInv โ€” generate position invariant code (same as fixed-function) for POSITION output. ๐ŸŽฏ

vp30

Targets the NV_vertex_program2 OpenGL extension โœจ

  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 256 ๐ŸŽ€
  • -po PosInv โ€” generate position invariant code (same as fixed-function) for POSITION output. ๐ŸŽฏ

vp40

Targets the NV_vertex_program3 OpenGL extension ๐Ÿ”ฅ

  • -po MaxAddressRegs=<em>N</em> โ€” sets the max number of ADDRESS registers in the output program. default is 2 ๐Ÿ“
  • -po MaxInstructions=<em>N</em> โ€” sets the max number of instructions in the output program. default is 2048 โœจ
  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 544 ๐ŸŽ€
  • -po NumTemps=<em>N</em> โ€” sets the max number of TEMP registers in the output program. default is 32 ๐Ÿ’ซ
  • -po PosInv โ€” generate position invariant code (same as fixed-function) for POSITION output. ๐ŸŽฏ

vs_1_1

Targets DirectX vertex programs ๐ŸŽฎ

  • -po dcls โ€” output dx9-style dcls statements. ๐Ÿ’…
  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 96 ๐ŸŽ€
  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions in the output program. default is 128 โœจ
  • -po NumTemps=<em>N</em> โ€” sets the max number of temporaries in the output program. default is 12 ๐Ÿ’ซ

vs_2_0 vs_2_x

Targets DirectX vertex programs ๐ŸŽฎ

  • -po dcls โ€” output dx9-style dcls statements. ๐Ÿ’…
  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 256 ๐ŸŽ€
  • -po NumInstructionSlots=<em>N</em> โ€” sets the max number of instructions in the output program. default is 256 โœจ
  • -po NumTemps=<em>N</em> โ€” sets the max number of temporaries in the output program. default is 12 ๐Ÿ’ซ

vs_3_0

Targets DirectX vertex programs ๐ŸŽฎ

  • -po dcls โ€” output dx9-style dcls statements. ๐Ÿ’…
  • -po MaxLocalParams=<em>N</em> โ€” set the max number of uniform parameter slots available. default is 256 ๐ŸŽ€
  • -po NumInstructionSlots=N โ€” sets the maximum number of instructions in the output program. default is 32768, bestie, that's your ceiling ๐ŸŽ€
  • -po NumTemps=N โ€” sets the maximum number of temporaries in the output program. default is 32 โœจ

๐ŸŒธ ENVIRONMENT ๐ŸŒธ

ngl, this section is literally empty in the original โ€” no environment variables documented here at all. no cap, that's the whole vibe. ๐Ÿ’…


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

the whole friend group, go say hi ๐Ÿ‘‘:

  • Cg_language
  • arbfp1
  • arbvp1
  • fp20
  • fp30
  • fp40
  • glslf
  • glslv
  • gp4fp
  • gp4gp
  • gp4vp
  • hlslf
  • hlslv
  • vp20
  • vp30
  • vp40

and that's the whole page, bestie ๐Ÿ’– this manual page belongs to Cg Toolkit 3.0 and was rendered out of perl v5.10.0, with CGC(1) sitting pretty at the bottom right like the main character it is. go compile something gorgeous. periodt. ๐Ÿซถ๐ŸŒˆโญ