Graphics Reference
In-Depth Information
drawing. In this case, we can copy the number of particles in the buffer to an indirect argu-
ments buffer resource, which can then execute the pipeline with a call to ID3DllDevice
Context: :DrawInstancedIndirect. This will let us invoke the rendering pipeline an ap-
propriate number of times, but we still have the problem of supplying the particle data as
vertices to the input assembler. To solve this problem, we can bypass the input assembler
stage altogether. If we don't bind a vertex buffer to the input assembler, but we still invoke
the pipeline with our indirect draw call using a point-primitive type, the input assembler
will still create a corresponding number of vertices. The only problem is that these input
vertices won't have any user-supplied input vertex attributes. Fortunately, we can still de-
clare the SV_VertexID, which will uniquely identify each of the vertices that are passed
into the pipeline. Then we can use the vertex shader to read the vertex data out of the
structured buffer based on the vertex identifier. This effectively lets us funnel the particle
data into the pipeline through the vertex shader, instead of the input assembler. This vertex
shader program is shown in Listing 12.11.
struct Particle
{
float3 position;
float3 direction;
float time;
};
StructuredBuffer<Particle> SimulationState;
struct VS_INPUT
{
uint vertexid : SV_VertexID;
};
struct GS_INPUT
{
float3 position : Position;
};
GS_INPUT VSMAIN( in VS_INPUT input )
{
GS_INPUT output;
output.position.xyz = SimulationState[input.vertexid].position;
return output;
}
Listing 12.11. Loading the particle data into empty input vertices using the SV_VertexID system value
semantic.
Search WWH ::




Custom Search