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.
Supplemental Material
- Tim Foley and Pat Hanrahan. 2011. Spark: Modular, Composable Shaders for Graphics Hardware. In SIGGRAPH.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- Pat Hanrahan and Jim Lawson. 1990. A Language for Shading and Lighting Calculations. In SIGGRAPH.Google Scholar
- Yong He, Tim Foley, and Kayvon Fatahalian. 2016. A System for Rapid Exploration of Shader Optimization Choices. In SIGGRAPH.Google Scholar
- Dean Jackson and Jef Gilbert. 2015. WebGL Specification. https://www.khronos.org/registry/webgl/specs/latest/1.0/.Google Scholar
- Aditi Kabra, Dietrich Geisler, and Adrian Sampson. 2020. Online Verification of Commutativity. In Workshop on Tools for Automatic Program Analysis (TAPAS).Google Scholar
- Andrew J. Kennedy. 1994. Dimension Types. In European Symposium on Programming (ESOP).Google Scholar
- Andrew J. Kennedy. 1997. Relational Parametricity and Units of Measure. In ACM SIGPLANśSIGACT Symposium on Principles of Programming Languages (POPL).Google Scholar
- Microsoft. 2008. Direct3D. https://msdn.microsoft.com/en-us/library/windows/desktop/hh309466(v=vs.85).aspx.Google Scholar
- 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 Scholar
- Jiawei Ou and Fabio Pellacini. 2010. SafeGI: Type Checking to Improve Correctness in Rendering System Implementation. In Eurographics Conference on Rendering (EGSR).Google Scholar
Digital Library
- Bui Tuong Phong. 1975. Illumination for Computer Generated Pictures. Commun. ACM 18, 6 ( June 1975 ), 311ś317.Google Scholar
- Adrian Sampson. 2017. Let's Fix OpenGL. In Summit on Advances in Programming Languages (SNAPL).Google Scholar
- 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 Scholar
- 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 Scholar
- Mark Segal and Kurt Akeley. 2017. The OpenGL 4.5 Graphics System: A Specification. https://www.opengl.org/registry/doc/ glspec45.core.pdf.Google Scholar
- Sebastian Sylvan. 2017. Naming Convention for Matrix Math. https://www.sebastiansylvan.com/post/matrix_naming_convention/.Google Scholar
- The Khronos Group Inc. [n. d.]. The OpenGL ES Shading Language (1.0 ed.). The Khronos Group Inc.Google Scholar
Index Terms
Geometry types for graphics programming
Recommendations
Cayenne—a language with dependent types
Cayenne is a Haskell-like language. The main difference between Haskell and Cayenne is that Cayenne has dependent types, i.e., the result type of a function may depend on the argument value, and types of record components (which can be types or values) ...
Cayenne—a language with dependent types
ICFP '98: Proceedings of the third ACM SIGPLAN international conference on Functional programmingCayenne is a Haskell-like language. The main difference between Haskell and Cayenne is that Cayenne has dependent types, i.e., the result type of a function may depend on the argument value, and types of record components (which can be types or values) ...
Interactive Rendering of Acquired Materials on Dynamic Geometry Using Frequency Analysis
Shading acquired materials with high-frequency illumination is computationally expensive. Estimating the shading integral requires multiple samples of the incident illumination. The number of samples required may vary across the image, and the image ...






Comments