Hi regal team,
The Windows XP with MSVCRT.DLL is my min-spec target, and I'm using the Windows WDK 7.1 to compile it.
Compiled this way, it runs fine under Vista / Windows 7, but it does not on XP. The problem is that __declspec(thread) is not supported there with the combination above.
Given that REGAL uses __declspec(thread) in isolated way, I've mimicked the pthread approach, and wrote a version, disabled by default, and enabled with #define REGAL_WIN_TLS 1 that uses the Widnows TLS API - TlsAlloc, TlsSet/GetValue, etc.
I've tested that under the one machine that I have with Windows XP Service Pack 3 (32-bit) and works so far.
Dimiter 'malkia' Stanev
Added REGAL_WIN_TLS #define - REGAL would use the Windows TLS API (Tl…
…sAlloc, TlsSet/GetValue, etc.) instead of __declspec(thread). This allows REGAL to be compiled with Windows WDK 7.1 targeting MSVCRT.DLL and working on Windows XP Service Pack 3 (tested)
Looks good to me. I'll do some homework first...
It seems that __declspec(thread) won't work with dynamic libraries that use it, but are loaded after the first (well second excluding the main one) thread is created - Check Raymond Chen's blog - http://blogs.msdn.com/b/oldnewthing/archive/2010/11/22/10094489.aspx
EDIT: If a DLL is loaded with LoadLibrary() and has __declspec(thread) it won't work. But thas has been fixed on Vista and above. I guess that's why I was having problems with XP.
On the downside of using TLS api - is that it's somewhat slower (probably), instead of directly using the fs:[_tls_index] to access the register, it goes through couple of jumps to do it (but then again, anyone thinking that speeding up OpenGL calls is the silver bullet, is asking for misery).
We're leaning toward using the TLS api only for Windows to keep the code simpler and more portable.
Merge branch 'master' of git://github.com/p3/regal
It's merged in, thanks for the contribution.
I think we may switch to this path being the default, at least.