Graphics Reference
In-Depth Information
13. In order to complete the CreateDeviceDependentResources method,
we will create the particle constant buffers and load the particle textures.
// Create the per compute shader constant buffer
perComputeBuffer = ToDispose(new Buffer(device,
Utilities.SizeOf<ParticleConstants>(),
ResourceUsage.Default, BindFlags.ConstantBuffer,
CpuAccessFlags.None, ResourceOptionFlags.None, 0));
// Create the particle frame buffer
perFrame = ToDispose(new Buffer(device,
Utilities.SizeOf<ParticleFrame>(),
ResourceUsage.Default, BindFlags.ConstantBuffer,
CpuAccessFlags.None, ResourceOptionFlags.None, 0));
particleTextureSRV = ToDispose(ShaderResourceView
.FromFile(device, "Particle.png"));
14. Copy the CreateBufferUAV function into the ParticleRenderer class
created in the Calculating an image's luminance histogram recipe of Chapter 7 ,
Performing Image Processing Techniques . We need to make the following
highlighted changes to support the append/consume buffers:
public static UnorderedAccessView CreateBufferUAV(
SharpDX.Direct3D11.Device device, Buffer buffer,
UnorderedAccessViewBufferFlags flags =
UnorderedAccessViewBufferFlags.None)
{
...
else if ((buffer.Description.OptionFlags &
ResourceOptionFlags.BufferStructured) ==
ResourceOptionFlags.BufferStructured)
{
uavDesc.Format = Format.Unknown;
uavDesc.Buffer.Flags = flags;
...
}
...
}
15. We will initialize our particle buffers and set the constants within a new function
named InitializeParticles .
// Private member fields
Buffer indirectArgsBuffer;
List<Buffer> particleBuffers = new List<Buffer>();
List<ShaderResourceView> particleSRVs =
new List<ShaderResourceView>();
 
Search WWH ::




Custom Search