Sh GPU Metaprogramming Language: Frequently Asked Questions
This FAQ page gathers common questions and answers about the Sh GPU metaprogramming language. If you are wondering about Sh, check here first to see whether your question has already been covered. To comment on this FAQ, you can write to the mailing list or use the "Edit" link at the top of this wiki page.
About Sh
How Sh Compares with Other Shading Languages
Many shading languages exist. Cg, HLSL and the OpenGL Shading Language are probably the most prominent ones used on GPUs today, and there are also offline shading languages such as Renderman, which are not treated here. All of the other GPU shading languages are essentially syntactic variants of one another, with at most a few extra function calls, whereas Sh is something entirely different.
With the other shading languages, shaders are written either as strings in the host application or as separate files. With Sh, shaders are written directly in C++, together with the host application. This makes a significant difference:
- Shaders can share variables with the application, eliminating the need for parameter binding (glue) code. For small shaders this more or less means throwing away half the code necessary to write a shader.
- The host application can very easily generate GPU programs on the fly, without having to generate some sort of text representation of the programs. This is very important for generating subtle variants of shader programs, for example for different numbers of light sources or varying levels of complexity.
- Sh also integrates texture handling, taking away much of the burden associated with updating textures and using them from shader programs.
Beyond this crucial basic difference, there are a few other notable differences worth mentioning:
- While all of these shader languages are free, Sh is completely open source. Some other languages provide an open source frontend (the lexer and parser), but Sh makes everything freely available, including the optimizer and code generators.
- The Sh licence is very permissive, stating that you can basically do anything with the language except claim to have written it. This means you can integrate Sh into commercial applications without any sort of obligation, and can make your own derivatives of it.
- Sh is also cross-platform. While the official version currently supports only Windows and Linux, a Mac OS X port is to be integrated soon.
- Being mostly written by university researchers, Sh has no strong ties to a particular platform, API (such as OpenGL or DirectX) or graphics vendor. Compared to Cg, HLSL and the OpenGL Shading Language, it is the most independent shading language out there.
- The research origins of Sh also mean that we are very interested in trying out new ideas in relation to shading. For example, our Shader Algebra paper from SIGGRAPH 2004 illustrates a mechanism built into Sh to take existing Sh programs and easily generate modified programs from these at runtime.
- Lastly, our goal for Sh is to not just be a shading language. GPUs are becoming increasingly suitable for general purpose computation, which is interesting for a number of reasons, not the least of which is the amazing speed that GPUs offer at commodity prices. Thus we are aiming for Sh to be a language suitable for any kind of computation on GPUs, whether graphical or not.
Performance and Compiler Questions
Explore More

- Sh: a quick introduction
- How Sh Works
- Sm, the simulator
- Shrike
- Shmedia
- Sample Code
- Metaprogramming GPUs with Sh
- Frequently Asked Questions
- Main Page
- Recent changes
- Random page
- Upload file
- Special pages
- About ShWiki
Download Sh Read the Licence Back to Home Report an Issue Join the Developers List
Related tools: Subversion, TortoiseSVN, RapidMind, and MediaWiki.
