Graphics Reference
In-Depth Information
resource views in any way. They are specified exactly as they should be made available
within HLSL, so there is no need to use a resource view.
HLSL constant buffer resource object. This is the first buffer type we have encountered
that is directly accessible from within HLSL code in the programmable shader stages. In
HLSL, constant buffers are resource objects that are declared with the cbuff er keyword.
A sample declaration is provided in Listing 2.9.
cbuffer Transforms
{
matrix WorldMatrixj
matrix ViewProjMatrix;
matrix SkinMatrices[26];
};
cbuffer LightParameters
{
float3 LightPositionWS;
float4 LightColor;
};
cbuffer ParticlelnsertParameters
{
float4 EmitterLocation;
float4 RandomVector;
};
Listing 2.9. Various declarations of a constant buffer from within HLSL.
Each of the variables declared within this cbuffer structure can be directly used
within the HLSL shader program as if it were declared at a global scope. The name of the
constant buffer, as specified in the listing above, is used by the host application to identify
the buffer by name, and to load the appropriate contents into it. However, the buffer name
is not used within HLSL. As with the constant buffer name, the names and types of the
individual elements of the constant buffer are also accessible through the shader reflection
API. 1 This series of methods can be used to determine the name and type of each subpa-
rameter, to allow the application to know which information to insert into the buffer at
runtime.
Buffer/Structured Buffer Resources
Our next type of buffer is referred to by two different names, depending on what type of
data it holds. A standard buffer resource means a buffer whose elements are one of the
1 The shader reflection API is discussed in more detail in Chapter 6: High Level Shading Language.
Search WWH ::




Custom Search