GameFoundry / bsf

Modern C++14 library for the development of real-time graphical applications

Home Page:https://www.bsframework.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error reporting on shader compile does not work

underdoeg opened this issue · comments

The openGL renderer is not reporting shader compile errors on arch linux with nvidia graphics.

The application crashes with "GL_INVALID_OPERATION error generated. object is not successfully linked" that hints at a wrong shader. but I did not receive any errors when starting up.

I intentionally added an error into the fragment shader of the LowLevelRendering Example. The result ist a message:
[ERROR] Cannot find parameter block with the name: 'Params' which makes sense since the shader was not properly compiled. thous I would expect a shader compiler error message.

This is when compiling the shaders through low-level rendering, or are you importing a .bsl shader?

With low-level rendering you need to check for compile status yourself. For example:

SPtr<GpuProgram> prog = ...; // create the shader
prog->blockUntilCoreInitialized();

if (!prog->isCompiled())
    BS_LOG(Error, Renderer, prog->getCompileErrorMessage())

That is with the low level interface. I'll try this tomorrow. Thanks

Yes. That works. Thank you. I still feel like it would be nicer if the engine would report the error itself instead of just crashing. (at least in the debug build)

That's how it used to be, but it's problematic when you have a higher-level shader parsing code that parses the entire BSL file, in which case you want to be able to report all the errors in one place, rather than reporting BSL parsing errors in one spot and individual shader function compilation errors elsewhere.

Ah I see the problem. Well it is called low level interface, so an extra step is not too bad. But couldn't you check before submitting the pipeline to the renderer if the shader is actually compiled?

Possibly, but in the editor where the user can dynamically change shaders it could get pretty spammy when the user makes an error, so it would need to be a bit more sophisticated solution.