Skip to main content
eScholarship
Open Access Publications from the University of California

UC Davis

UC Davis Electronic Theses and Dissertations bannerUC Davis

Toward Unified Shader Programming

Abstract

Real-time graphics programming is more complex due to the strict separation of programming languages and environments between host (CPU) code and GPU code. In contrast, popular general-purpose GPU (GPGPU) programming models provide unified programming environments, in which both host and GPU code are written in the same language, can be in the same file, and share lexical scopes. Such unified systems avoid code duplication, subtle compatibility bugs, and additional development and maintenance costs that arise from manually coordinating between host code and GPU code. While real-time graphics predates—and, in many ways, inspired—GPGPU programming, it has yet to incorporate the advantages of unified programming that helped to propel the popular GPGPU systems to success.

In this dissertation, we propose two overarching implementation methodologies for creating unified programming environments for real-time graphics. These methods have complementary trade-offs, with one motivated by practical applicability in existing systems today and the other providing a principled approach for new systems utilizing future programming language evolutions. The first method is to co-opt existing features of a programming language and implement them with alternate semantics to express the host-GPU interface requirements and code optimization techniques ubiquitous in real-time rendering. Using this strategy, we integrate GPU shader code into C++ by co-opting annotations, inheritance, and virtual functions to express the shader specialization optimization. Our compiler-based tool transforms host and GPU shader code into efficient implementations by generating specialized shader variants in place of virtual function calls. The second method is a general-purpose language feature called staged metaprogramming. Using this technique, we create a unified shader system entirely in user-space code, without the need for a compiler-based implementation. Our use of staged metaprogramming enables exploration of the shader specialization design space, resulting in improved performance relative to the complete, static specialization baseline. Along with presenting these two implementation strategies, we also compare their strengths and shortcomings to better inform graphics programmers seeking to create unified environments today and in the future.

Main Content
For improved accessibility of PDF content, download the file to your device.
Current View