“Cg: a system for programming graphics hardware in a C-like language” by Mark, Glanville, Akeley and Kilgard

  • ©William R. Mark, R. Steven Glanville, Kurt Akeley, and Mark J. Kilgard




    Cg: a system for programming graphics hardware in a C-like language



    The latest real-time graphics architectures include programmable floating-point vertex and fragment processors, with support for data-dependent control flow in the vertex processor. We present a programming language and a supporting system that are designed for programming these stream processors. The language follows the philosophy of C, in that it is a hardware-oriented, general-purpose language, rather than an application-specific shading language. The language includes a variety of facilities designed to support the key architectural features of programmable graphics processors, and is designed to support multiple generations of graphics architectures with different levels of functionality. The system supports both of the major 3D graphics APIs: OpenGL and Direct3D. This paper identifies many of the choices that we faced as we designed the system, and explains why we made the decisions that we did.


    1. 3DLABS. 2002. OpenGL 2.0 shading language white paper, version 1.2, Feb.Google Scholar
    2. AKELEY, K. 1993. RealityEngine graphics. In SIGGRAPH 93, 109–116. Google Scholar
    3. BOLTZ, J., FARMER, I., GRINSPUN, E., AND SCHRODER, P. 2003. The GPU as numerical simulation engine. In SIGGRAPH 2003.Google Scholar
    4. BUCK, I., AND HANRAHAN, P. 2003. Data parallel computation on graphics hardware. unpublished report, Jan.Google Scholar
    5. CHAN, E., NG, R., SEN, P., PROUDFOOT, K., AND HANRAHAN, P. 2002. Efficient partitioning of fragment shaders for multipass rendering on programmable graphics hardware. In SIGGRAPH/Eurographics workshop on graphics hardware. Google Scholar
    6. CODEPLAY CORPORATION. 2003. VectorC documentation, Jan. Available at http://www.codeplay.com/support/documentation.html.Google Scholar
    7. COOK, R. L. 1984. Shade trees. In SIGGRAPH 84, 223–231. Google ScholarDigital Library
    8. DALLY, W. J., AND POULTON, J. W. 1998. Digital Systems Engineering. Cambridge University Press. Google Scholar
    9. FERNANDO, R., AND KILGARD, M. J. 2003. The Cg Tutorial: The definitive guide to programmable real-time graphics. Addison-Wesley. Google Scholar
    10. HANRAHAN, P., AND LAWSON, J. 1990. A language for shading and lighting calculations. In SIGGRAPH 90, 289–298. Google ScholarCross Ref
    11. HERWITZ, P. S., AND POMERENE, J. H. 1960. The Harvest system. In Proc. of the AIEE-ACM-IRE 1960 Western Joint Computer Conf., 23–32.Google Scholar
    12. JAQUAYS, P., AND HOOK, B. 1999. Quake 3: Arena Shader Manual, Revision 10, Sept.Google Scholar
    13. JOY, B., STEELE, G., GOSLING, J., AND BRACHA, G. 2000. Java(TM) Language Specification, 2nd ed. Addison-Wesley.Google Scholar
    14. KAPASI, U. J., DALLY, W. J., RIXNER, S., OWENS, J. D., AND KHAILANY, B. 2002. The Imagine stream processor. In Proc. of IEEE Conf. on Computer Design, 295–302.Google Scholar
    15. KERNIGHAN, B. W., AND RITCHIE, D. M. 1988. The C Programming Language. Prentice Hall. Google Scholar
    16. KESSENICH, J., BALDWIN, D., AND ROST, R. 2003. The OpenGL Shading Language, version 1.05, Feb.Google Scholar
    17. LALONDE, P., AND SCHENK, E. 2002. Shader-driven compilation of rendering assets. In SIGGRAPH 2002, 713–720. Google ScholarDigital Library
    18. LARSEN, S., AND AMARASINGHE, S. 2000. Exploiting superworld level parallelism with multimedia instruction sets. In Proc. of ACM SIGPLAN PLDI 2000, 145–156. Google ScholarCross Ref
    19. LEECH, J. 1998. OpenGL extensions and restrictions for PixelFlow. Technical Report UNC-CH TR98-019, Univ. of North Carolina at Chapel Hill, Dept. of Computer Science, Apr.Google Scholar
    20. LEVINTHAL, A., HANRAHAN, P., PAQUETTE, M., AND LAWSON, J. 1987. Parallel computers for graphics applications. In Proc. of 2nd Intl. Conf. on architectural support for programming languages and operating systems (ASPLOS ’87), 193–198. Google Scholar
    21. LINDHOLM, E., KILGARD, M. J., AND MORETON, H. 2001. A user-programmable vertex engine. In SIGGRAPH 2001. Google ScholarDigital Library
    22. MARK, W. R., AND PROUDFOOT, K. 2001. Compiling to a VLIW fragment pipeline. In SIGGRAPH/Eurographics workshop on graphics hardware. Google Scholar
    23. MATTSON, P. 2001. A Programming System for the Imagine Media Processor. PhD thesis, Stanford University. Google Scholar
    24. MCCOOL, M. D., QIN, Z., AND POPA, T. S. 2002. Shader metaprogramming. In Eurographics/SIGGRAPH workshop on graphics hardware, 57–68. Google Scholar
    25. MICROSOFT CORP. 2002. DirectX 9.0 graphics, Dec. Available at http://msdn.microsoft.com/directx.Google Scholar
    26. MICROSOFT CORP. 2002. High-level shader language. In DirectX 9.0 graphics. Dec. Available at http://msdn.microsoft.com/directx.Google Scholar
    27. MICROSOFT CORP. 2003. Common type system. In .NET framework developer’s guide. Jan. Available at http://msdn.microsoft.com/.Google Scholar
    28. MITCHELL, J. L. 2002. RADEON 9700 Shading (ATI Technologies white paper), July.Google Scholar
    29. MOLNAR, S., EYLES, J., AND POULTON, J. 1992. PixelFlow: high-speed rendering using image composition. In SIGGRAPH 92, 231–240. Google ScholarDigital Library
    30. MOTOROLA CORP. 1999. AltiVec Technology Programming Interface Manual, June.Google Scholar
    31. NVIDIA CORP. 2003. Cg Toolkit, Release 1.1. Software and documentation available at http://developer.nvidia.com/Cg.Google Scholar
    32. NVIDIA CORP. 2003. NV_fragment_program. In NVIDIA OpenGL Extension Specifications. Jan.Google Scholar
    33. NVIDIA CORP. 2003. NV_vertex_program2. In NVIDIA OpenGL Extension Specifications. Jan.Google Scholar
    34. OLANO, M., AND LASTRA, A. 1998. A shading language on graphics hardware: The PixelFlow shading system. In SIGGRAPH 98, 159–168. Google Scholar
    35. PEERCY, M., OLANO, M., AIREY, J., AND UNGAR, J. 2000. Interactive multi-pass programmable shading. In SIGGRAPH 2000, 425–432. Google ScholarDigital Library
    36. PERLIN, K. 1985. An image synthesizer. In SIGGRAPH 85, 287–296. Google ScholarDigital Library
    37. PROUDFOOT, K., MARK, W. R., TZVETKOV, S., AND HANRAHAN, P. 2001. A real-time procedural shading system for programmable graphics hardware. In SIGGRAPH 2001. Google ScholarDigital Library
    38. RITCHIE, D. M. 1993. The development of the C language. In Second ACM SIGPLAN Conference on History of Programming Languages, 201–208. Google Scholar
    39. ROHLF, J., AND HELMAN, J. 1994. IRIS performer: A high performance multiprocessing toolkit for real–time 3D graphics. In SIGGRAPH 94, 381–394. Google Scholar
    40. SEGAL, M., AND AKELEY, K. 2002. The OpenGL Graphics System: A Specification (Version 1.4). OpenGL Architecture Review Board. Editor: Jon Leech.Google Scholar
    41. STEPHENS, R. 1997. A survey of stream processing. Acta Informatica 34, 7, 491–541.Google ScholarCross Ref
    42. STROUSTRUP, B. 2000. The C++ Programming Language, 3rd ed. Addison-Wesley. Google Scholar
    43. THIES, W., KARCZMAREK, M., AND AMARASINGHE, S. 2002. StreamIt: a language for streaming applications. In Proc. Intl. Conf. on Compiler Construction. Google Scholar

ACM Digital Library Publication: