skip to main content

Geometry types for graphics programming

Published:13 November 2020Publication History
Skip Abstract Section

Abstract

In domains that deal with physical space and geometry, programmers need to track the coordinate systems that underpin a computation. We identify a class of geometry bugs that arise from confusing which coordinate system a vector belongs to. These bugs are not ruled out by current languages for vector-oriented computing, are difficult to check for at run time, and can generate subtly incorrect output that can be hard to test for.

We introduce a type system and language that prevents geometry bugs by reflecting the coordinate system for each geometric object. A value's geometry type encodes its reference frame, the kind of geometric object (such as a point or a direction), and the coordinate representation (such as Cartesian or spherical coordinates). We show how these types can rule out geometrically incorrect operations, and we show how to use them to automatically generate correct-by-construction code to transform vectors between coordinate systems. We implement a language for graphics programming, Gator, that checks geometry types and compiles to OpenGL's shading language, GLSL. Using case studies, we demonstrate that Gator can raise the level of abstraction for shader programming and prevent common errors without inducing significant annotation overhead or performance cost.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This is a video presentation of my talk at OOPSLA 2020 on our paper accepted to the research track. In this paper, we explore how, in domains that deal with physical space and geometry, programmers need to track the coordinate systems that underpin a computation. We identify a class of geometry bugs that arise from confusing which coordinate system a vector belongs to. These bugs are not ruled out by current languages for vector-oriented computing, are difficult to check for at run time, and can generate subtly incorrect output that can be hard to test for. We introduce a type system and language that prevents geometry bugs by reflecting the coordinate system for each geometric object. We implement a language for graphics programming, Gator, that checks geometry types and compiles to OpenGL's shading language, GLSL.

References

  1. Tim Foley and Pat Hanrahan. 2011. Spark: Modular, Composable Shaders for Graphics Hardware. In SIGGRAPH.Google ScholarGoogle Scholar
  2. Jefrey S. Foster, Manuel Fähndrich, and Alexander Aiken. 1999. A Theory of Type Qualifiers. In ACM Conference on Programming Language Design and Implementation (PLDI).Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Daniel J. Fremont, Tommaso Dreossi, Shromona Ghosh, Xiangyu Yue, Alberto L. Sangiovanni-Vincentelli, and Sanjit A. Seshia. 2019. Functional Programming for Compiling and Decompiling Computer-Aided Design. In ACM Conference on Programming Language Design and Implementation (PLDI).Google ScholarGoogle Scholar
  4. Pat Hanrahan and Jim Lawson. 1990. A Language for Shading and Lighting Calculations. In SIGGRAPH.Google ScholarGoogle Scholar
  5. Yong He, Tim Foley, and Kayvon Fatahalian. 2016. A System for Rapid Exploration of Shader Optimization Choices. In SIGGRAPH.Google ScholarGoogle Scholar
  6. Dean Jackson and Jef Gilbert. 2015. WebGL Specification. https://www.khronos.org/registry/webgl/specs/latest/1.0/.Google ScholarGoogle Scholar
  7. Aditi Kabra, Dietrich Geisler, and Adrian Sampson. 2020. Online Verification of Commutativity. In Workshop on Tools for Automatic Program Analysis (TAPAS).Google ScholarGoogle Scholar
  8. Andrew J. Kennedy. 1994. Dimension Types. In European Symposium on Programming (ESOP).Google ScholarGoogle Scholar
  9. Andrew J. Kennedy. 1997. Relational Parametricity and Units of Measure. In ACM SIGPLANśSIGACT Symposium on Principles of Programming Languages (POPL).Google ScholarGoogle Scholar
  10. Microsoft. 2008. Direct3D. https://msdn.microsoft.com/en-us/library/windows/desktop/hh309466(v=vs.85).aspx.Google ScholarGoogle Scholar
  11. Chandrakana Nandi, James R. Wilcox, Pavel Panchekha, Taylor Blau, Dan Grossman, and Zachary Tatlock. 2018. Functional Programming for Compiling and Decompiling Computer-Aided Design. In ACM SIGPLAN International Conference on Functional Programming (ICFP).Google ScholarGoogle Scholar
  12. Jiawei Ou and Fabio Pellacini. 2010. SafeGI: Type Checking to Improve Correctness in Rendering System Implementation. In Eurographics Conference on Rendering (EGSR).Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Bui Tuong Phong. 1975. Illumination for Computer Generated Pictures. Commun. ACM 18, 6 ( June 1975 ), 311ś317.Google ScholarGoogle Scholar
  14. Adrian Sampson. 2017. Let's Fix OpenGL. In Summit on Advances in Programming Languages (SNAPL).Google ScholarGoogle Scholar
  15. Adrian Sampson, Kathryn S McKinley, and Todd Mytkowicz. 2017. Static Stages for Heterogeneous Programming. In ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).Google ScholarGoogle Scholar
  16. Donald J. Schuirmann. 2005. A comparison of the Two One-Sided Tests Procedure and the Power Approach for assessing the equivalence of average bioavailability. Journal of Pharmacokinetics and Biopharmaceutics 15 ( 2005 ), 657ś680.Google ScholarGoogle Scholar
  17. Mark Segal and Kurt Akeley. 2017. The OpenGL 4.5 Graphics System: A Specification. https://www.opengl.org/registry/doc/ glspec45.core.pdf.Google ScholarGoogle Scholar
  18. Sebastian Sylvan. 2017. Naming Convention for Matrix Math. https://www.sebastiansylvan.com/post/matrix_naming_convention/.Google ScholarGoogle Scholar
  19. The Khronos Group Inc. [n. d.]. The OpenGL ES Shading Language (1.0 ed.). The Khronos Group Inc.Google ScholarGoogle Scholar

Index Terms

  1. Geometry types for graphics programming

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!