Opengl multithreading, loss context

Hi. I am facing the following problem. The application uses two contexts (wglShareLists) for background texture loading and it works well on most computers. Until we came across, for example, NVIDIA GeForce GTX 1060 for laptops, and not only. There, at a certain moment, quite by accident, 10-15 minutes after the launch, the context is lost and the user observes a black screen, what can be done about this?

What do you mean by accident? That suggests a possible cause is known.
What do you mean by a certain moment? That suggests something else specific happened then.

What have you done already to gather data on the problem?

You’re not really giving us much. You haven’t even described your laptop config. Is this an Optimus system (dual Intel/NVIDIA GPUs)? Which GPU were you rendering to at the time? Do you know? What OS? Have you checked the system event log for clues? Was your app killed or does the rendering just stop? Do you have a CPU or GPU memory leak? Are you monitoring your app’s total CPU and GPU memory consumption? To the latter, this is easy to do in OpenGL with NVIDIA GPUs (see NV_gpu_memory_info). If your app is still running, what info do you have in your app logs about that time? Have you tried to repro this in a debugger? etcetc.

Solved, after all, it is better to disable the automatic selection of the video card for working with the application. If anyone else comes across this, just add yourself this code:
for NVIDIA:

extern "C" {
	_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}

for ATI:

extern "C" {
	_declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}

Good find! And thanks for following up with your solution. I’m sure you’ll save other laptop users some time.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.