Pix,我不理解的几个问题 [英] Pix, A couple of issues I'm not understanding

查看:105
本文介绍了Pix,我不理解的几个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人要求我在这里问一些问题:

I've been asked to split questions which I asked here:

HLSL和Pix问题数

我认为两个和三个都适合同一个问题,因为一个解决方案可能有助于解决另一个问题.我正在尝试调试着色器,似乎遇到了问题.首先,当我运行分析模式时,Pix似乎正在跳过大量代码.这是在分析F12捕获并关闭D3DX分析的实验.我在使用XNA时必须将其关闭.有问题的着色器代码如下:

I thought two and three would both fit in the same question as a solution of one may help resolve the other. I'm trying to debug a shader and seem to be running into issues. Firstly Pix seems to be skipping a large amount of code when I'm running analyse mode. This is analysing an experiment with F12 captures and with D3DX analysis turned off. I have to turn it off as I'm using XNA. The shader code in question is below:

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 / D.w;  

    // 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's position and last frame's 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;
}

在捕获帧的情况下,调试像素时,我只能看到两条线在工作.它们是color = tex2D(sceneSampler,OriginalUV)和finalColor = color/xNumSamples. Pix的其余部分只是跳过或不执行.

With a captured frame and when debugging a pixel I can only see two lines working. These are color = tex2D(sceneSampler, OriginalUV) and finalColor = color / xNumSamples. The rest of it Pix just skips or doesn't do.

我还可以使用Pix实时调试吗?我想知道这种方法是否可以显示更多信息.

Also can I debug in real time using Pix? I'm wondering if this method would reveal more information.

干杯

推荐答案

似乎大多数着色器代码都已被优化(由于不相关,因此未编译).

It would appear that most of that shader code is being optimized out (not compiled because it is irrelevant).

最后,所有与finalColor的返回值有关的值都由colorxNumSamples设置.

In the end, all that matters in the return value of finalColor which is set with color and xNumSamples.

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

我不确定xNumSamples的设置位置,但是您可以看到,与color唯一相关的行是color = tex2D(sceneSampler, OriginalUV);(因此未将其删除).

I am not sure where xNumSamples gets set, but you can see that the only line that matters to color is color = tex2D(sceneSampler, OriginalUV); (hence it not being removed).

之前的每一行都是无关紧要的,因为它将被该行覆盖.

Every line before that is irrelevant because it will be overwritten by that line.

随后的唯一位是for循环:

The only bit that follows is that for loop:

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

但是这将永远不会执行,因为i < 1从一开始就为假(i的起始值为1).

But this would never execute because i < 1 is false from the get-go (i is assigned a starting value of 1).

希望有帮助!

要回答第二个问题,我相信要实时调试着色器,您需要使用Nvidia的 FX Composer 着色器调试器.但是,那些不在您的游戏中运行,因此结果并不总是有用的.

To answer you second question, I believe to debug shaders in real-time you need to use something like Nvidia's FX Composer and Shader Debugger. However, those run outside of your game, so results are not always useful.

这篇关于Pix,我不理解的几个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆