Graphics Reference
In-Depth Information
Shaders and High Level Shader Language
The graphics pipeline is made up of fixed function and programmable stages.
The programmable stages are referred to as shaders, and are programmed using small
High Level Shader Language (HLSL) programs. The HLSL is implemented with a series
of shader models, each building upon the previous version. Each shader model version
supports a set of shader profiles, which represent the target pipeline stage to compile a
shader. Direct3D 11 introduces Shader Model 5 (SM5), a superset of Shader Model 4 (SM4).
An example shader profile is ps_5_0 , which indicates a shader program is for use in the pixel
shader stage and requires SM5.
Stages of the programmable pipeline
All Direct3D operations take place via one of the two pipelines, known as pipelines for
the fact that information flows in one direction from one stage to the next. For all drawing
operations, the graphics pipeline is used (also known as drawing pipeline or rendering
pipeline). To run compute shaders, the dispatch pipeline is used (aka DirectCompute
pipeline or compute shader pipeline).
Although these two pipelines are conceptually separate. They cannot be active at the same
time. Context switching between the two pipelines also incurs additional overhead so each
pipeline should be used in blocks—for example, run any compute shaders to prepare data,
perform all rendering, and finally post processing.
Methods related to stages of the pipeline are found on the device context. For the managed
API, each stage is grouped into a property named after the pipeline stage. For example, for the
vertex shader stage, deviceContext.VertexShader.SetShaderResources , whereas
the unmanaged API groups the methods by a stage acronym directly on the device context,
for example, deviceContext->VSSetShaderResources , where VS represents the vertex
shader stage.
The graphics pipeline
The graphics pipeline is comprised of nine distinct stages that are generally used to create 2D
raster representations of 3D scenes, that is, take our 3D model and turn it into what we see
on the display. Four of these stages are fixed function and the remaining five programmable
stages are called shaders (the following diagram shows the programmable stages as a circle).
The output of each stage is taken as input into the next along with bound resources or in the
case of the last stage, Output Merger (OM), the output is sent to one or more render targets.
Not all of the stages are mandatory and keeping the number of stages involved to a minimum
will generally result in faster rendering.
 
Search WWH ::




Custom Search