Microsoft DirectX 8.1 (Visual Basic) |
As an example, run the application and type the following instructions in the instruction window.
ps.1.0 tex t0 mov r0, t0
This results in the Microsoft® DirectX® 5 logo image in the rendered view window.
This shader applies a texture map. Notice that the compilation result text window says Success, which indicates that all the instructions are valid.
Next, remove the second instruction, which is the texture declaration. Once this is deleted, the compilation result says:
(Statement 2) (Validation Error) Read of uninitialized components(*) in t0: *R/X/0 *G/Y/1 *B/Z/2 *A/W/3
This error identifies the statement that fails, Statement 2, and why it fails Uninitialized component in t0. You can fix this problem by adding Statement 2 again. When you do this, the shader works again.
This is a simple example but it illustrates the usefulness of the tool. By trying different instructions, registers, and instruction sequences, you can better understand pixel shaders and vertex shaders. The sample application also has an Open button, which supports loading of a shader file so that you can load any shader files you have already created.
Some graphics chip companies provide a shader debugging tool on their Web sites. Find these tools by searching the Web or by reading the article listed below. You can attach a debugger to a program while it is running and use the debugger to step through a shader. By setting breakpoints, you can step through the shader code one line at a time and watch register state changes. For more information about vertex shaders and debugging tips, see Using Vertex Shaders: Part 1.
Another sample application that is part of the software development kit (SDK) installation is MFCTex. This Microsoft Foundation Classes (MFC) application is a good way to learn how to perform multi-texture blending operations in the fixed function pipeline.
Another option for help with debugging DirectX problems is to use the DirectX Diagnostic Viewer (DXDiag.exe) to create a dump of your machine. This is done by running DxDiag.exe after your machine has crashed and sending the dump to Microsoft, using either the Report button on the More Help tab or by sending it to directx@microsoft.com. The dump can be used to track down and reproduce the problem.
Additional debug information can be found at http://msdn.microsoft.com/directx