Unified Shader Programming in C++

09/29/2021
by   Kerry A. Seitz Jr., et al.
0

In real-time graphics, the strict separation of programming languages and environments for host (CPU) code and GPU code results in code duplication, subtle compatibility bugs, and additional development and maintenance costs. In contrast, popular general-purpose GPU (GPGPU) programming models like CUDA and C++ AMP avoid many of these issues by presenting unified programming environments where both host and GPU code are written in the same language, can be in the same file, and share lexical scopes. To bring the benefits of unified programming to real-time graphics, this paper examines graphics-specific challenges that complicate the development of such a unified model and explores how to overcome them in a widely used programming language. We observe that GPU code specialization, a key optimization in real-time graphics, requires coordination between parameters that are compile-time-constant in GPU code but are assigned values at runtime in host code based on dynamic data. Current methods used to implement specialization do not translate to a unified environment where host and GPU code share declarations of these parameters. Furthermore, this compile-time vs. runtime coordination is not innately expressible in the popular languages used in this domain. In this paper, we create a unified environment for real-time graphics programming in C++ by co-opting existing features of the language and implementing them with alternate semantics to express the services required. Specifically, we co-opt C++ attributes and virtual functions, which enables us to provide first-class support for specialization in our unified system. By co-opting existing features, we enable programmers to use familiar C++ programming techniques to write host and GPU code together, while still achieving efficient generated C++ and HLSL code via our source-to-source translator.

READ FULL TEXT

page 3

page 7

page 8

page 11

page 12

research
08/09/2023

__host__ __device__ – Generic programming in Cuda

We present patterns for Cuda/C++ to write save generic code which works ...
research
08/14/2018

Bringing Together Dynamic Geometry Software and the Graphics Processing Unit

We equip dynamic geometry software (DGS) with a user-friendly method tha...
research
05/05/2023

Descend: A Safe GPU Systems Programming Language

Graphics Processing Units (GPU) offer tremendous computational power by ...
research
04/14/2022

A Unified Programming Model for Heterogeneous Computing with CPU and Accelerator Technologies

This paper consists of three parts. The first part provides a unified pr...
research
05/18/2020

Sham: A DSL for Fast DSLs

Domain-specific languages (DSLs) are touted as both easy to embed in pro...
research
04/22/2020

A scriptable, generative modelling system for dynamic 3D meshes

We describe a flexible, script-based system for the procedural generatio...
research
12/01/2020

Customizing Host IDE for Non-programming Users of Pure Embedded DSLs: A Case Study

Pure embedding as an implementation strategy of domain-specific language...

Please sign up or login with your details

Forgot password? Click here to reset