Page MenuHome

Fix accesses of ThreadLocal variable g_currentfb in gpu_framebuffer.c on macOS
ClosedPublic

Authored by Edmund Kapusniak (edmundmk) on Jun 11 2018, 8:08 PM.

Details

Summary

A ThreadLocal() variable should be accessed through BLI_thread_local_get() and BLI_thread_local_set(). On non-Apple platforms accessing it directly is fine, but on macOS the macros are required.

This patch updates gpu_framebuffer.c to access the thread-local variable g_currentfb using the correct macros rather than directly. Because this uses pthread thread-specific data, we also need to create and destroy the pthread_key_t. And the pthread interface also requires that the variable is a pointer, so the type changes to void* and we add macros to cast the GLuint into and out of the void*.

This fixes assertion failures on macOS particularly in WM_opengl_context_activate() when rendering is happening on multiple threads.

Diff Detail

Repository
rB Blender

Event Timeline

Thanks a lot for finding this, I'll commit it with some naming tweaks.

This revision is now accepted and ready to land.Jun 11 2018, 9:06 PM
This revision was automatically updated to reflect the committed changes.