VS 2015图形调试器给我源错误

VS 2015 graphics debugger giving me source error

本文关键字:错误 调试器 2015 图形 VS      更新时间:2023-10-16

我正在尝试调试我的图形应用程序,以了解为什么对象没有被渲染到屏幕上。因此,我要进入我的图形调试器并检查我要渲染的对象的管道状态(一个简单的平面)。

像素着色器没有运行,但是输入和顶点着色器阶段看起来不错(它显示了平面)。我要单击顶点着色器下方的播放按钮进行调试,但是当我这样做时,我立即收到此错误:此模块的调试信息中缺少源信息。

到目前为止,我已经在几个项目上使用了调试器,但是对于这个项目,调试器无法正常工作。我使用的那些项目是通用应用程序项目,因此它们带有一堆已经呈现对象的代码。我现在正在做这个项目,我从一个空旷的项目开始,然后自己完成了一切。

当我收到错误时,我检查了我的呼叫堆栈,它给了我名称"未知"和语言HLSL。不幸的是,这并不是真的很有帮助。有什么更好的方法可以查看问题吗?还是您知道我可能遇到的任何潜在问题?

旁注:每当我使用Graphics调试器时,都会告诉我去DirectX Control面板并添加我在可执行文件列表中工作的项目目录。出现错误后,我也为这个项目做了这一点,但我仍然有。

update 我正在查看一些事件列表信息,当我查看具有我的着色器代码的OBJ时,它说:"着色器编辑和适用不适用着色器。这可能是由于没有调试信息或不支持编译器的制造着着色器而引起的。"也许这与此有关,因为我的另一个项目中的其他着色器没有此错误。

我忘了包括一些代码,所以这里有一些。我正在做的某些代码在这个项目中有所不同,但是我回来的所有hresult都说它们是s_ok。就像我创建设备,Swapchain和设备上下文时一样,我确保发送调试标志。我认为这实际上只是我的输出窗口,但我只是想包括在内,以防它可能对图形调试器产生影响。

if (_DEBUG)
{
    flags = D3D11_CREATE_DEVICE_DEBUG;
}
HRESULT swapResult = D3D11CreateDeviceAndSwapChain(NULL,   D3D_DRIVER_TYPE_HARDWARE, NULL, flags, NULL, NULL, D3D11_SDK_VERSION, &swapChainDesc, swapChain.GetAddressOf(), device.GetAddressOf(), NULL, deviceContext.GetAddressOf());

我还必须使用d3dcompilefromfile,而不是通用应用程序(甚至是在线教程的方式)的方式,因为他们这样做的方式对我来说有点奇怪。

//compile shaders
Microsoft::WRL::ComPtr<ID3D10Blob> basicVSBuffer;
Microsoft::WRL::ComPtr<ID3D10Blob> basicPSBuffer;
HRESULT vsCompResult = D3DCompileFromFile(L"VS_Basic.hlsl", NULL, NULL, "main", "vs_4_0", NULL, NULL, basicVSBuffer.GetAddressOf(), NULL);
HRESULT psCompResult = D3DCompileFromFile(L"PS_Basic.hlsl", NULL, NULL, "main", "ps_4_0", NULL, NULL, basicPSBuffer.GetAddressOf(), NULL);
//create shaders
HRESULT vsCrtResult = device->CreateVertexShader(basicVSBuffer->GetBufferPointer(), basicVSBuffer->GetBufferSize(), NULL, basicVS.GetAddressOf());
HRESULT psCrtResult = device->CreatePixelShader(basicPSBuffer->GetBufferPointer(), basicPSBuffer->GetBufferSize(), NULL, basicPS.GetAddressOf());
vertexShaders.push_back(basicVS);
pixelShaders.push_back(basicPS);

最后,我的着色器是非常裸露的骨头,因为我只是想现在显示一个基本的对象。我看不出他们真的有什么错,但是在这里,以防万一。

//My Vertex shader (VS_Basic.hlsl)
// A constant buffer that stores the three basic column-major matrices for     composing geometry.
cbuffer ModelViewProjectionConstantBuffer : register(b0)
{
matrix model;
matrix view;
matrix projection;
};
// Per-vertex data used as input to the vertex shader.
struct VertexShaderInput
{
float3 pos : POSITION;
float3 normal : NORMAL;
float3 uv : TEXCOORD;
};
// Per-pixel color data passed through the pixel shader.
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float3 normal : NORMAL;
float3 uv : TEXCOORD;
};
// Simple shader to do vertex processing on the GPU.
PixelShaderInput main(VertexShaderInput input)
{
PixelShaderInput output;
float4 pos = float4(input.pos, 1.0f);
// Transform the vertex position into projected space.
pos = mul(pos, model);
pos = mul(pos, view);
pos = mul(pos, projection);
output.pos = pos;
// Pass the color through without modification.
output.uv = input.uv;
//pass normal
output.normal = input.normal;
return output;
}

这是我的像素着色器(ps_basic.hlsl)

struct PS_BasicInput
{
float4 position : SV_POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD;
};
float4 main(PS_BasicInput input) : SV_TARGET
{
float4 resultColor;
//just basic test
resultColor = float4(1, 0, 0, 1);
return resultColor;
}

我在进行一些挖掘后注意到的错误(着色器编辑和应用不可用于此着色器。这可能是由于没有调试信息的构建着色器或使用不支持的编译器而引起的。)我挠头,我决定看看是否可以向着色器发送标志。果然,在D3DCOMPILEFROMFILE函数中,有一个标志参数。发送D3DCOMPILE_DEBUG中,您将能够调试该着色器。前几天,我将其设置为无效,因为我不知道有任何有益的旗帜。