Graphics Reference
In-Depth Information
High Level
Shading Language
6.1 introduction
The core of the Direct3D 11 pipeline is its various programmable shader stages. These
stages are where the vast majority of rendering tasks occur, and are also the means by
which a CPU's power and flexibility are made available to the user. While various API
functions can manipulate the state in which a shader program will be executed, the actual
authoring of shader functionality and behavior is not done with these APIs. Instead, shader
programs (also referred to as simply shaders) are authored, using a specially designed pro-
gramming language known as High Level Shading Language.
High Level Shading Language (commonly abbreviated as HLSL), is primarily a C/
C++-derived language with a simplified feature set. Things like semicolons for line termi-
nation, braces for statement blocks, and C-style function and struct declarations make the
language immediately familiar to a C or C++ programmer. The major exceptions are that
pointer types and operations are not supported, as well as C++-style templates. In addi-
tion, the language does not support a dynamic memory allocation model. As in C or C++,
programs are written by authoring a function that serves as the entry point. This code is
executed at runtime and runs until the end of the function is reached. It should be noted that
in D3D11, the language is always compiled in advance, before shaders are bound to the
pipeline, as opposed to being dynamically interpreted, like a scripting language. To support
static compilation, the compiler features a C-style preprocessor. The preprocessor supports
common uses such as macro definitions, conditional compilation, and include statements.
311
Search WWH ::




Custom Search