Roman Yurin
Roman Yurin

Reputation: 67

Is OpenGL 4.3 API and glsl language safe?

I'm developing a Java graphical application with jogl and OpenGL at the Linux. My application contains over 30 shaders and they work fine in most cases. But about once a week there is a driver (amdgpu pro) error (SIGSEGV).

Please tell me, is OpenGL safe language: It is protected from errors by the application program or incorrect actions of the application can cause damage to the memory of the driver (writing to someone else's memory or data race). In what do I look for the cause of the error (SIGSEGV) in the incorrect driver (amdgpu pro) or in the errors of the application itself? (The glGetError show that all fine at each application step).

Upvotes: 0

Views: 456

Answers (2)

Nicol Bolas
Nicol Bolas

Reputation: 473447

Is OpenGL 4.3 "safe"? Absolutely not. There are many things you can do that can crash the program. Having a rendering operation read from past the boundaries of a buffer, for example. 4.3 has plenty of ways of doing that.

Indeed, simply writing a shader that executes for too long can cause a GPU failure.

You could in theory read GPU memory that was written by some other application, just by reading from an uninitialized buffer.

There is no simple way to tell whether a particular crash was caused by a driver bug or by user error. You have to actually debug it and have a working understanding of the OpenGL specification to know for sure.

Upvotes: 3

Dietrich Epp
Dietrich Epp

Reputation: 213338

In general, there are going to be plenty of ways to crash your program when you are using the OpenGL API. Buggy drivers are an unfortunate reality that you cannot avoid completely, and misuse of the API in creative ways can cause crashes instead of errors. In fact, I have personally caused computers to completely hang (unresponsive) on multiple platforms and different GPU vendors, even when using WebGL which is supposedly "safe".

So the only possible answer is "no, OpenGL is not safe."

Some tips for debugging OpenGL:

  • Don't use glGetError, use KHR_debug instead (unless it's not available).

  • Create a debug context with GL_CONTEXT_FLAG_DEBUG_BIT.

  • Use a less buggy OpenGL implementation when you are testing. In my experience, the Mesa implementation is very stable.

Upvotes: 4

Related Questions