Graphics Reference
In-Depth Information
"DesaturateCS", "cs_5_0", ShaderFlags.None,
EffectFlags.None, defines , null))
using (var cs = new ComputeShader(device, bytecode))
{
// Set the source resource
context.ComputeShader.SetShaderResource(0,
srcTextureSRV);
// Set the destination resource
context.ComputeShader.SetUnorderedAccessView(0,
targetUAV);
context.ComputeShader.Set(cs);
// e.g. 640x480 -> Dispatch(40, 120, 1);
context.Dispatch((int)Math.Ceiling(desc.Width / 16.0 ),
(int)Math.Ceiling(desc.Height / 4.0 ), 1);
}
6.
After running the previous code, the target texture now contains the desaturated
image. We can use the graphics debugger to peek at the contents of the texture
without having to render or save to a file. To do this, ensure that the project is
configured to enable native code debugging (see Chapter 1 , Getting Started with
Direct3D ) and run the project within the Visual Studio Graphics Debugger ( Alt + F5 ).
Pressing the Print Screen key will capture all resources and list them in the graphics
object table where you can select the texture with the debug name CSTarget
as shown in the following screenshot (a grayscale result when viewed within the
Graphics Debugger of Visual Studio):
Grayscale result when viewed within the Graphics Debugger of Visual Studio
 
Search WWH ::




Custom Search