Pix, A couple of issues that I don't understand

I was asked to share the questions I asked here:

Number of HLSL and Pix Requests

I thought that two and three would correspond to the same question, since resolving one might help resolve the other. I am trying to debug a shader and it seems to run into problems. First off, the Pix seems to miss a lot of code when I run the analysis mode. This is an analysis of the F12 gripper experiment and the D3DX analysis is turned off. I have to disable it as I use XNA. Below is the shader code:

float4 PixelShaderFunction(float2 OriginalUV : TEXCOORD0) : COLOR0 { // Get the depth buffer value at this pixel. float4 color = float4 (0, 0,0,0); float4 finalColor = float4(0,0,0,0); float zOverW = tex2D(mySampler, OriginalUV); // H is the viewport position at this pixel in the range -1 to 1. float4 H = float4(OriginalUV.x * 2 - 1, (1 - OriginalUV.y) * 2 - 1, zOverW, 1); // Transform by the view-projection inverse. float4 D = mul(H, xViewProjectionInverseMatrix); // Divide by w to get the world position. float4 worldPos = D / Dw; // Current viewport position float4 currentPos = H; // Use the world position, and transform by the previous view- // projection matrix. float4 previousPos = mul(worldPos, xPreviousViewProjectionMatrix); // Convert to nonhomogeneous points [-1,1] by dividing by w. previousPos /= previousPos.w; // Use this frame position and last frame to compute the pixel // velocity. float2 velocity = (currentPos - previousPos)/2.f; // Get the initial color at this pixel. color = tex2D(sceneSampler, OriginalUV); OriginalUV += velocity; for(int i = 1; i < 1; ++i, OriginalUV += velocity) { // Sample the color buffer along the velocity vector. float4 currentColor = tex2D(sceneSampler, OriginalUV); // Add the current color to our color sum. color += currentColor; } // Average all of the samples to get the final blur color. finalColor = color / xNumSamples; return finalColor; } 

With a captured frame and when debugging a pixel, I can only see two lines. These are color = tex2D (sceneSampler, OriginalUV) and finalColor = color / xNumSamples. The rest of this Pix is ​​simply skipped or not.

Is it also possible to debug in real time using Pix? I am wondering if this method will reveal more information.

Greetings

+4
source share
1 answer

It seems like most of this shader code is being optimized (not compiled because it does not matter).

As a result, everything that matters in the finalColor return value, which is set using color and xNumSamples .

 // Average all of the samples to get the final blur color. finalColor = color / xNumSamples; 

I'm not sure where xNumSamples installed, but you can see that the only line that matters to color is color = tex2D(sceneSampler, OriginalUV); (therefore, it is not deleted).

Each line before this does not matter, because it will be overwritten by this line.

The only bit that follows this is that for the loop:

 for(int i = 1; i < 1; ++i, OriginalUV += velocity) 

But this will never be done, because i < 1 is false from get-go (i is assigned an initial value of 1).

Hope this helps!


To answer the second question, I believe that for debugging shaders in real time, you need to use something like Nvidia FX Composer and Shader Debugger . However, those that work outside of your game, so the results are not always useful.

+1
source

All Articles