0

I have this weird error. I'm trying to compile a HLSL file, but my debugging isn't working properly. Here's how I set up the error checking:

hresult = D3DCompileFromFile(vs_fn, 0, 0, "VShader", "vs_4_0", D3DCOMPILE_DEBUG, 0, &vertex_shader_blob, &error_message);
    if (FAILED(hresult))
    {
        // If the shader failed to compile it should have writen something to the error message.
        if (error_message)
        {
            auto error = (char*)error_message->GetBufferPointer();
            return false;
        }

    }

However, my shader code does work. It displays how I want it too, but when I place a random character or change anything in the code to produce an error, nothing gets outputted to the error variable. It worked just the other day.

The check fails, it steps onto the if statement but never goes into it and just breaks to end of the entire code block. I'm confused.

  • yeah my bad I accidentially changed that variable when I uploaded it to show it is an actual HRESULT but both the "check" and "hresult" are the same viariable in the code. I changed my original post. – Kristal Meyer Jun 23 '18 at 18:17
  • Did you tried to output the error message to the console or disabled compiler optimization? If the variable isn't used as you return directly after, the compiler may optimize the section and remove the assignment. – Gnietschow Jun 23 '18 at 20:40
  • I've tried both. The error checking works completely fine on my other laptop with the same exact project. Probably something going wrong in one of the visual studio settings but I have no idea where to start – Kristal Meyer Jun 24 '18 at 01:05
  • Are you running release or debug? On a release build the branch will get optimized out so you'd just step over it. – Varrak Jun 25 '18 at 14:58

0 Answers0