Buffer Type

Use the following syntax to declare a buffer variable.

Buffer<Type> Name;

 

Parameters

Buffer

Required keyword.

Type

One of the scalar, vector, and some matrix HLSL types. You can declare a buffer variable with a matrix as long as it fits in 4 32-bit quantities. So, you can write Buffer<float2x2>. But Buffer<float4x4> is too large, and the compiler will generate an error.

Name

An ASCII string that uniquely identifies the variable name.

Example

Here is an example of a buffer declaration from the PipesGS.fx file in PipesGS Sample.


Buffer<float4> g_Buffer;

Data is read from a buffer using an overloaded version of the Load HLSL intrinsic function that takes one input parameter (an integer index). A buffer is accessed like an array of elements; therefore, this example reads the second element.


float4 bufferData = g_Buffer.Load( 1 );

Use the stream-output stage to output data to a buffer.

See also

Data Types (DirectX HLSL)

 

 

Community Additions

ADD
Show:
© 2014 Microsoft