Graphics Reference
In-Depth Information
Count per Type:
Device : 1
DeviceContext : 1
RenderTargetView : 1
SwapChain : 1
Texture2D : 1
5.
The incorrect call to Present should have resulted in the following being written to
the debug output:
DXGI ERROR: IDXGISwapChain::Present: Present is being called
with DXGI_PRESENT_RESTRICT_TO_OUTPUT, which is only valid if
the SwapChain was created with a valid pRestrictToOutput. [
MISCELLANEOUS ERROR #120: ]
How it works…
We begin with the code from the first recipe that was rendering a pleasant light blue
background for our window.
The debug names that we have added are arbitrary values for you to use to distinguish
between different objects of the same type. You may have noticed that these appeared
within the Graphics Object Table when a frame has been captured (marked with a red
square in the previous screenshot). This will help when you are trying to debug with lots
of objects of the same type. From here, it is possible to inspect each object by double clicking,
to view the contents of textures and buffers, or the properties of a device or swap chain.
Once we have captured the frame and selected a pixel, the Graphics Pixel History window
(circled in red in the previous screenshot) shows the initial color, the color after the call to
ClearRenderTarget and the final color of the selected pixel. If there were other operations
that took place on the pixel (including shaders), this is where we would be able to delve deeper.
The second part of this recipe introduces Direct3D error debugging and object tracking.
First we enabled object tracking on the first line of Main() to demonstrate how SharpDX
will keep track of objects for us.
We create the device as before, but pass through DeviceCreationFlags.Debug instead
of DeviceCreationFlags.None . This enables the Direct3D debug layer for this device and
we will receive additional messages for any errors after this point.
Next we generate a report of all active Direct3D COM objects. This is the same report that is
generated if we were to forget to dispose of any resources before application exit. The report
includes the stack trace, and double clicking on the line in the stack trace will take you to the
appropriate line in the source code editor.
 
Search WWH ::




Custom Search