Reputation: 31
I'm trying to debug my graphics application to see why the object isn't being rendered to the screen. So I'm going into my graphics debugger and checking out the pipeline status of the object I'm trying to render (a simple plane).
The Pixel Shader didn't run, but the input and vertex shader stages look fine (it shows a plane). I went to click on the play button underneath vertex shader to debug it, but when I do I get this error right away: source information is missing from the debug information for this module.
I've used the debugger on a couple of projects so far, but for this project, the debugger won't work. Those projects I used were universal app projects though, so they came with a bunch of code that already had an object rendered. This project I'm doing now I started with an empty project and made everything myself so far.
I checked my call stack when I get the error, and it gives me the name "unknown" and the language HLSL. Not really helpful unfortunately. Are there any better ways to see what the problem may be? Or do you know of any potential problems I may be having?
Side note: Whenever I've used the graphics debugger, I was told to go to directx control panel and add the directory of the project I'm working into in the executable list. I did this for this project as well after I had the error, and I still have it.
Update I'm looking at some of the event list info, and when I look the obj that has the code for my shaders, it says, "Shader Edit and Apply is not available for this shader. This can be caused by building shaders without debug information or with an unsupported compiler." Maybe this has something to do with it because my other shaders in my other project do not have this error.
I forgot to include some code, so here's some. Some of the code I'm doing is different in this project, but all of the HRESULTs I'm getting back say they're S_OK. Like when I create my device, swapchain, and device context, I make sure to send the debug flag. I think this is really just for my output window, but I just thought to include just in case it might have an effect on graphics debugger.
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());
I also have to use D3DCompileFromFile instead of the way the Universal App does it (or even the way tutorials online do it) because the way they were doing it was a bit weird for me to replicate.
//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);
Lastly, my shaders are very bare bone because I'm just trying to get a basic object showing right now. I don't see how there could really be any faults with them, but here they are just in case.
//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;
}
Here's my pixel shader (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;
}
Upvotes: 1
Views: 527
Reputation: 31
The error that I noticed after doing some digging (Shader Edit and Apply is not available for this shader. This can be caused by building shaders without debug information or with an unsupported compiler.) made me scratch my head and I decided to see if shaders could be sent flags. Sure enough, in the D3DCompileFromFile function, there is a flag parameter. Send in D3DCOMPILE_DEBUG, and you will be able to debug that shader. I had it set to NULL when I made it the other day because I didn't know of any flags that would be beneficial.
Upvotes: 2