Visual Studio 11 Development Guide (11) Visual Studio 11 debug games

Source: Internet
Author: User
3D games present a huge opportunity for developers on new devices (smartphones, tablets. The main API is used to access the underlying graphic hardware. DirectX 11(Including Direct3dAnd Direct2d).

One of the most important innovations in Visual Studio 11 is a series of tools to help develop direct3d games.

New in Visual StudioGraphical DebuggerIs to capture detailed information from direct3d applications, such as execution debugging and analysis tools. You can use it:

  • Capture the rendered frame, and then test and analyze it.
  • View the DirectX event and its impact on the application.
  • Before and after Vertex coloring machine conversion, view 3D mesh.
  • Discover which DirectX event contributes a specific pixel color.
  • Directly jump to the location in the source code of a specific DirectX call

To solve a simple problem, use the graphic debugger step by step. This is a rotating model game. Here is what it should look like.

However, finding the mold when running the application is not present in the game.

To start debugging this game, right-click the project in Solution Explorer and set it to "yes" in "enable graphic capture.

Now, F5 starts debugging your application and notices that the game now has some basic statistics, which are displayed in the upper left corner. This indicates that vs is preparing to capture diagnostic information from the game to investigate and present problems.

To capture frames, click the key of "print screen. You can repeat this step. Each frame is displayed in Visual Studio as part of the "graphic experiment. vsglog" file. The log file contains all the information required for debugging that presents the problem. By default, this file is located in a temporary location, but you can save it and share it with other developers.

Further dig into what frames are being captured through analysis in Visual Studio. To understand this, I want to know more about the code of the "drawindexed" API.

To check the "drawindexed" call framework, right-click the thumbnail, and select "event list" from the context menu ".

Graphic event list windowLists All DirectX events captured by programs running in the vs debugger. It also simulates the graphical debugger and re-uses the events under the commands of the running program used for the same input. In the search box, type the list you want to filter to display the "Draw" DirectX draw call. By drawing the call, you can see that in the (right side) frame window, click the frame to draw in an integer.

In the search box of the type "painting" in this window, this will filter to display the list of draw calls made by the game. Select the "drawindexed" Call event list to check what is displayed in the Framework Window.

Unfortunately, in this case, as shown above, we need to continue our debugging process. (Drawindexed) submits the rendering pipeline. Check whether the "drawindexed" submitted is called as the rendering pipeline. To see what happened, right-click the call in the event list and create a pipeline viewer by selecting "Viewer Pipeline" from the context menu ".

Graphic pipeline ViewerDisplays the different stages of the graphic pipeline and how these stages modify the process in the model.

The viewer displays the grid data of four different views. They correspond to four different stages in the pipeline.

View Description
Pre-vertex shader View the vertex coloring ER before the mesh vertex. The camera is directed to the center of the object.
Boot self-check Vertex coloring er View the mesh vertices after the vertex coloring tool. The camera is directed to the center of the object.
Geometric coloring Tool
(Not considered as not used in this example)
View the mesh Vertex coloring machine ry. The camera is directed to the center of the object. If no geometric shadow is specified, this view is empty (solid light gray shadow ).
View port View the screen space of the mesh vertex. The camera is set to the same as the camera in the target program.

Note that some graphic pipelines do not represent other stages in this view. More new graphics are pipelines on DirectX 11.

What you can see is being drawn in the graphic pipeline view, which looks like the mold that the application wants to render. It seems that the structure from the "dead" (multi-dimensional dataset) is correctly indicated by the graphic pipeline whether the shader works properly.

At this point, you need to continue debugging. Take a look elsewhere. This may be because pixels are overwritten or discarded. To verify this assumption, you need to look at the center of the pixel (the mold should be presented) framework. In the frame buffer window, click center, select a pixel, right-click, and select "pixel history" from the context menu ".

Graphic pixel history windowDisplays the activity that contributes to the color of the selected pixel in the current frame. It contains information about how to modify each event in the DirectX pixel history window. This includes the initial frame buffer state, followed by the presentation and final result of the intermediate draw event.

The pixel color of the frame buffer is blue, and then when the pixel of the pixel shader applies a different color (Gray), you can see the "pixel history" window. However, the final color is still blue. Not all applications are rendering the desired pixel color. This is an indication that the mixed state settings may be incorrect. How to mix the mixed state control of the color and Alpha value in the combination to present the data and the existing target data. The blending status to check, right-click the pixel, and select "Object List" from the context menu ". The "Graph object table" window is displayed.

Graph object tableDisplays the target program created by the direct3d object. You can click "double" on an object in the table to view any objects with status information.

Sort the object table (by "type") and scroll to the "d3d11 mixed state" object in the list. Double-click "d3d11 mixed state" object will be least effective (not without reference) "Use Times ". The scope of the "Age of use" help is to investigate the call of the selected object, which is related to a lot of age reduction. Double-click the mixed state object with the minimum age of use to open the detailed information of the Visual Studio object in a document.

From the above picture, we can see:

 

Blend source = d3d11_blend_zero; // source indicates the color output of the operations performed on the pixel shadow.
Blend Destination = d3d11_blend_one; // destination indicates the color of the frame in which the mixed execution operation is performed.

Blend op = d3d11_blend_add; // source and target of the blend operation.

The mixed state of the source is masked because it is set to zero (d3d11_blend_zero) and the mixed state of the target is set to 1 (d3d11_blend_one ). This will cause the background color to be mixed as the main color, so we do not see the mold being rendered. The output of such a pixel shader is a hybrid operation of the primary output, and the value should be switched.

Blend source = d3d11_blend_one;
Blend Destination = d3d11_blend_zero;
Blend op = d3d11_blend_add;

You can return to the event list window and filter for "blendstate", because the event list lists all events that occur when DirectX events have captured frames, locate the location where the mixed state is set. Once you filter, you can see the "omsetblendstate" appeal. Call to set the mixed state to "omsetblendstate ". Obtain the source code. If you are making this call, right-click "omsetblendstate" and choose "call stack" from the context menu"

Graphic event call stackIn the window, contact the C ++ source code DirectX event that is being debugged.

Double-click the first call stack and it will take you to "omsetblendstate" for calling in code. When you call "omblendstate" at the top of several lines, you will notice the line of code that combines the Set Source and target locations.

Switch through changes to reflect the following code:

Blenddesc. rendertarget [0]. srcblend = d3d11_blend_one;
Blenddesc. rendertarget [0]. destblend = d3d11_blend_zero;

Generate and run.

 

Game Development is not easy. tools can help you use the basic DirectX platform. In this version, this new diagnostic experience is introduced into visual studio11.

Download vs11 now

Http://www.microsoft.com/click/services/Redirect2.ashx? Cr_cc = 200098144

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.