“Spark: modular, composable shaders for graphics hardware” by Foley and Hanrahan

  • ©Tim Foley and Patrick (Pat) Hanrahan




    Spark: modular, composable shaders for graphics hardware



    In creating complex real-time shaders, programmers should be able to decompose code into independent, localized modules of their choosing. Current real-time shading languages, however, enforce a fixed decomposition into per-pipeline-stage procedures. Program concerns at other scales — including those that cross-cut multiple pipeline stages — cannot be expressed as reusable modules.We present a shading language, Spark, and its implementation for modern graphics hardware that improves support for separation of concerns into modules. A Spark shader class can encapsulate code that maps to more than one pipeline stage, and can be extended and composed using object-oriented inheritance. In our tests, shaders written in Spark achieve performance within 2% of HLSL.


    1. Adobe, 2011. Pixel Bender 3D. http://labs.adobe.com/technologies/pixelbender3d/.Google Scholar
    2. Austin, C., and Reiners, D. 2005. Renaissance: A functional shading language. In Proceedings of Graphics Hardware 2005, ACM, New York, NY, USA, 1–8.Google Scholar
    3. Blythe, D. 2006. The Direct3D 10 system. Transactions on Graphics 25, 3, 724–734. Google ScholarDigital Library
    4. Codd, E. F. 1970. A relational model of data for large shared data banks. Commun. ACM 13 (June), 377–387. Google ScholarCross Ref
    5. Cook, R. L. 1984. Shade trees. In Proceedings of SIGGRAPH 1984, ACM, New York, NY, USA, vol. 18, 223–231. Google ScholarDigital Library
    6. Hanrahan, P., and Lawson, J. 1990. A language for shading and lighting calculations. In Proceedings of SIGGRAPH 1990, ACM, New York, NY, USA, 289–298. Google Scholar
    7. Kessinich, J., Baldwin, D., and Rost, R., 2003. The OpenGL® shading language, version 1.05. http://www.opengl.org, February.Google Scholar
    8. Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C. V., Loingtier, J.-M., and Irwin, J. 1997. Aspect-oriented programming. In Proceedings of ECOOP 1997, Springer-Verlag.Google Scholar
    9. Kuck, R., and Wesche, G. 2009. A framework for object-oriented shader design. In Proceedings of ISVC 2009: International Symposium on Advances in Visual Computing, Springer-Verlag, Berlin, Heidelberg, 1019–1030. Google Scholar
    10. Lalonde, P., and Schenk, E. 2002. Shader-driven compilation of rendering assets. Transactions on Graphics 21, 3, 713–720. Google ScholarDigital Library
    11. Lattner, C., and Adve, V. 2004. LLVM: A compilation framework for lifelong program analysis & transformation. In Proceedings of CGO 2004: International Symposium on Code Generation and Optimization. Google ScholarDigital Library
    12. Lejdfors, C., and Ohlsson, L. 2004. PyFX — an active effect framework. In Proceedings of SIGRAD 2004, Linköping University Electronic Press, Gävle, Sweden, 17–24.Google Scholar
    13. Loop, C., Schaefer, S., Ni, T., and Castaño, I. 2009. Approximating subdivision surfaces with Gregory patches for hardware tessellation. Transactions on Graphics 28, 151:1–151:9. Google ScholarDigital Library
    14. Mark, W. R., Glanville, R. S., Akeley, K., and Kilgard, M. J. 2003. Cg: A system for programming graphics hardware in a C-like language. Transactions on Graphics 22, 896–907. Google ScholarDigital Library
    15. McCool, M. D., Qin, Z., and Popa, T. S. 2002. Shader metaprogramming. In Proceedings of Graphics Hardware 2002, Eurographics, Aire-la-Ville, Switzerland, Switzerland, 57–68. Google ScholarDigital Library
    16. McCool, M. D. 2000. SMASH: A next-generation API for programmable graphics accelerators. Tech. Rep. CS-2000-14, University of Waterloo, August.Google Scholar
    17. Microsoft, 2002. Shader model 1 (DirectX HLSL). http://msdn.microsoft.com.Google Scholar
    18. Microsoft, 2010. Direct3D 11 reference. http://msdn.microsoft.com.Google Scholar
    19. Microsoft, 2010. Effect format (Direct3D 11). http://msdn.microsoft.com.Google Scholar
    20. NVIDIA, 2010. Introduction to CgFX. http://developer.nvidia.com.Google Scholar
    21. Odersky, M., Altherr, P., Cremet, V., Emir, B., Maneth, S., Micheloud, S., Mihaylov, N., Schinz, M., Stenman, E., and Zenger, M. 2004. An overview of the Scala programming language. Tech. Rep. IC/2004/64, EPFL Lausanne, Switzerland.Google Scholar
    22. Perlin, K. 1985. An image synthesizer. In Proceedings of SIGGRAPH 1985, ACM, New York, NY, USA, vol. 19, 287–296. Google ScholarDigital Library
    23. Phong, B. T. 1973. Illumination for Computer-Generated Images. PhD thesis. Google Scholar
    24. Proudfoot, K., Mark, W. R., Tzvetkov, S., and Hanrahan, P. 2001. A real-time procedural shading system for programmable graphics hardware. In Proceedings of SIGGRAPH 2001, ACM, New York, NY, USA, 159–170. Google Scholar
    25. Segal, M., Akeley, K., Frazier, C., Leech, J., and Brown, P., 2010. The OpenGL® graphics system: A specification (version 4.0 (core profile) – march 11, 2010). http://www.opengl.org/registry/doc/glspec40.core.20100311.pdf.Google Scholar
    26. Sugerman, J., Fatahalian, K., Boulos, S., Akeley, K., and Hanrahan, P. 2009. GRAMPS: A programming model for graphics pipelines. Transactions on Graphics 28, 1, 1–11. Google ScholarDigital Library
    27. Wadler, P. 1990. Comprehending monads. In Proceeding of LFP 1990: ACM Conference on LISP and Functional Programming, ACM, New York, NY, USA, 61–78. Google Scholar

ACM Digital Library Publication:

Overview Page: