Permalink
Browse files

Do static initialization of global dispatch table,

including static EGL, as necessary at startup.
  • Loading branch information...
1 parent f542d0b commit 3a686e602b2aadacdb485299246f0a6b784515c7 @nigels-com nigels-com committed Aug 29, 2012
View
@@ -70,6 +70,7 @@ LIB.SRCS += src/regal/RegalLookup.cpp
LIB.SRCS += src/regal/RegalHelper.cpp
LIB.SRCS += src/regal/RegalContext.cpp
LIB.SRCS += src/regal/RegalContextInfo.cpp
+LIB.SRCS += src/regal/RegalDispatchGlobal.cpp
LIB.SRCS += src/regal/RegalDispatcher.cpp
LIB.SRCS += src/regal/RegalDispatchEmu.cpp
LIB.SRCS += src/regal/RegalDispatchLog.cpp
@@ -62,6 +62,7 @@
43FC5FA315C4619B00D0177C /* RegalUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 43FC5F7615C4619B00D0177C /* RegalUtil.h */; };
43FC5FA415C4619B00D0177C /* RegalVao.h in Headers */ = {isa = PBXBuildFile; fileRef = 43FC5F7715C4619B00D0177C /* RegalVao.h */; };
43FC5FA715C461AC00D0177C /* mongoose.c in Sources */ = {isa = PBXBuildFile; fileRef = 43FC5FA615C461AC00D0177C /* mongoose.c */; };
+ BC6C912A15EE3DC60056E4F7 /* RegalDispatchGlobal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6C912915EE3DC60056E4F7 /* RegalDispatchGlobal.cpp */; };
BC921A5E15D5624600E52C91 /* RegalDispatchMissing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC921A5C15D5624600E52C91 /* RegalDispatchMissing.cpp */; };
BC921A5F15D5624600E52C91 /* RegalDispatchNacl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC921A5D15D5624600E52C91 /* RegalDispatchNacl.cpp */; };
/* End PBXBuildFile section */
@@ -123,6 +124,7 @@
43FC5F7615C4619B00D0177C /* RegalUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegalUtil.h; path = ../../../src/regal/RegalUtil.h; sourceTree = "<group>"; };
43FC5F7715C4619B00D0177C /* RegalVao.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegalVao.h; path = ../../../src/regal/RegalVao.h; sourceTree = "<group>"; };
43FC5FA615C461AC00D0177C /* mongoose.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mongoose.c; path = ../../../src/mongoose/mongoose.c; sourceTree = "<group>"; };
+ BC6C912915EE3DC60056E4F7 /* RegalDispatchGlobal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchGlobal.cpp; path = ../../../src/regal/RegalDispatchGlobal.cpp; sourceTree = "<group>"; };
BC921A5C15D5624600E52C91 /* RegalDispatchMissing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchMissing.cpp; path = ../../../src/regal/RegalDispatchMissing.cpp; sourceTree = "<group>"; };
BC921A5D15D5624600E52C91 /* RegalDispatchNacl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchNacl.cpp; path = ../../../src/regal/RegalDispatchNacl.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -188,6 +190,7 @@
43FC5F5715C4619B00D0177C /* RegalDispatchEmu.cpp */,
43FC5F5815C4619B00D0177C /* RegalDispatchError.cpp */,
43FC5F5915C4619B00D0177C /* RegalDispatchError.h */,
+ BC6C912915EE3DC60056E4F7 /* RegalDispatchGlobal.cpp */,
43FC5F5A15C4619B00D0177C /* RegalDispatchLoader.cpp */,
BC921A5C15D5624600E52C91 /* RegalDispatchMissing.cpp */,
BC921A5D15D5624600E52C91 /* RegalDispatchNacl.cpp */,
@@ -352,6 +355,7 @@
43EFD6F915EAADAC004080CE /* RegalDispatcher.cpp in Sources */,
43EFD6FB15EAADAC004080CE /* RegalDispatchStaticEGL.cpp in Sources */,
43EFD6FC15EAADAC004080CE /* RegalDispatchStaticES2.cpp in Sources */,
+ BC6C912A15EE3DC60056E4F7 /* RegalDispatchGlobal.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -58,6 +58,7 @@
43A6C22E15C48D3A0063667E /* mongoose.c in Sources */ = {isa = PBXBuildFile; fileRef = 43A6C22D15C48D3A0063667E /* mongoose.c */; };
BC456F1215D55F8E0080B420 /* RegalDispatchMissing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC456F1015D55F8E0080B420 /* RegalDispatchMissing.cpp */; };
BC456F1315D55F8E0080B420 /* RegalDispatchNacl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC456F1115D55F8E0080B420 /* RegalDispatchNacl.cpp */; };
+ BC6C911D15EE3CDF0056E4F7 /* RegalDispatchGlobal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC6C911C15EE3CDF0056E4F7 /* RegalDispatchGlobal.cpp */; };
BCF889A715E079C20093B7D5 /* RegalDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF889A515E079C20093B7D5 /* RegalDispatcher.cpp */; };
BCF889A815E079C20093B7D5 /* RegalDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF889A615E079C20093B7D5 /* RegalDispatcher.h */; };
BCF889AA15E079D80093B7D5 /* RegalDispatchStaticES2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF889A915E079D80093B7D5 /* RegalDispatchStaticES2.cpp */; };
@@ -116,6 +117,7 @@
43A6C22D15C48D3A0063667E /* mongoose.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mongoose.c; path = ../../../src/mongoose/mongoose.c; sourceTree = "<group>"; };
BC456F1015D55F8E0080B420 /* RegalDispatchMissing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchMissing.cpp; path = ../../../src/regal/RegalDispatchMissing.cpp; sourceTree = "<group>"; };
BC456F1115D55F8E0080B420 /* RegalDispatchNacl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchNacl.cpp; path = ../../../src/regal/RegalDispatchNacl.cpp; sourceTree = "<group>"; };
+ BC6C911C15EE3CDF0056E4F7 /* RegalDispatchGlobal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchGlobal.cpp; path = ../../../src/regal/RegalDispatchGlobal.cpp; sourceTree = "<group>"; };
BCF889A515E079C20093B7D5 /* RegalDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatcher.cpp; path = ../../../src/regal/RegalDispatcher.cpp; sourceTree = "<group>"; };
BCF889A615E079C20093B7D5 /* RegalDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegalDispatcher.h; path = ../../../src/regal/RegalDispatcher.h; sourceTree = "<group>"; };
BCF889A915E079D80093B7D5 /* RegalDispatchStaticES2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegalDispatchStaticES2.cpp; path = ../../../src/regal/RegalDispatchStaticES2.cpp; sourceTree = "<group>"; };
@@ -172,6 +174,7 @@
43A6C1DE15C48D1F0063667E /* RegalDispatchEmu.cpp */,
43A6C1DF15C48D1F0063667E /* RegalDispatchError.cpp */,
43A6C1E015C48D1F0063667E /* RegalDispatchError.h */,
+ BC6C911C15EE3CDF0056E4F7 /* RegalDispatchGlobal.cpp */,
43A6C1E115C48D1F0063667E /* RegalDispatchLoader.cpp */,
43A6C1E215C48D1F0063667E /* RegalDispatchLog.cpp */,
BC456F1015D55F8E0080B420 /* RegalDispatchMissing.cpp */,
@@ -332,6 +335,7 @@
BC456F1315D55F8E0080B420 /* RegalDispatchNacl.cpp in Sources */,
BCF889A715E079C20093B7D5 /* RegalDispatcher.cpp in Sources */,
BCF889AA15E079D80093B7D5 /* RegalDispatchStaticES2.cpp in Sources */,
+ BC6C911D15EE3CDF0056E4F7 /* RegalDispatchGlobal.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -145,6 +145,7 @@
<ClCompile Include="..\..\..\..\src\regal\RegalDispatchEmu.cpp" />
<ClCompile Include="..\..\..\..\src\regal\RegalDispatcher.cpp" />
<ClCompile Include="..\..\..\..\src\regal\RegalDispatchError.cpp" />
+ <ClCompile Include="..\..\..\..\src\regal\RegalDispatchGlobal.cpp" />
<ClCompile Include="..\..\..\..\src\regal\RegalDispatchLoader.cpp" />
<ClCompile Include="..\..\..\..\src\regal\RegalDispatchLog.cpp" />
<ClCompile Include="..\..\..\..\src\regal\RegalDispatchMissing.cpp" />
View
@@ -2272,7 +2272,7 @@
glXQueryContext.ret = Return('int')
glXQueryContext.add( Input( 'dpy','Display *' ))
glXQueryContext.add( Input( 'ctx','GLXContext' ))
-glXQueryContext.add( Input( 'attribute','int' ))
+glXQueryContext.add( Input( 'attribute','int' ,regalLog = 'GLXenumToString(attribute)' ))
glXQueryContext.add( Output( 'value','int *' ,size = 1 ))
glXQueryContext.version = '1.3'
glXQueryContext.category = 'GLX_VERSION_1_3'
@@ -18,6 +18,9 @@ def apiGlobalDispatchTableDefineCode(apis, args):
code = ''
code += 'struct DispatchTableGlobal {\n'
+ code += '\n'
+ code += ' DispatchTableGlobal();\n'
+ code += ' ~DispatchTableGlobal();\n'
for api in apis:
View
@@ -24278,7 +24278,7 @@ REGAL_DECL Bool REGAL_CALL glXMakeContextCurrent(Display *display, GLXDrawable d
REGAL_DECL int REGAL_CALL glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
{
- RTrace("glXQueryContext(", dpy, ", ", ctx, ", ", attribute, ")");
+ RTrace("glXQueryContext(", dpy, ", ", ctx, ", ", GLXenumToString(attribute), ")");
if (dispatchTableGlobal.glXQueryContext == NULL) {
GetProcAddress( dispatchTableGlobal.glXQueryContext, "glXQueryContext" );
RegalAssert(dispatchTableGlobal.glXQueryContext!=glXQueryContext);
@@ -24287,7 +24287,7 @@ REGAL_DECL int REGAL_CALL glXQueryContext(Display *dpy, GLXContext ctx, int attr
}
int ret = (int )0;
if (dispatchTableGlobal.glXQueryContext) {
- GTrace("glXQueryContext(", dpy, ", ", ctx, ", ", attribute, ")");
+ GTrace("glXQueryContext(", dpy, ", ", ctx, ", ", GLXenumToString(attribute), ")");
ret = dispatchTableGlobal.glXQueryContext(dpy, ctx, attribute, value);
}
else
@@ -47,6 +47,9 @@ REGAL_NAMESPACE_BEGIN
struct DispatchTableGlobal {
+ DispatchTableGlobal();
+ ~DispatchTableGlobal();
+
#if REGAL_SYS_WGL
// WGL_3DL_stereo_control
@@ -0,0 +1,64 @@
+/*
+ Copyright (c) 2011 NVIDIA Corporation
+ Copyright (c) 2011-2012 Cass Everitt
+ Copyright (c) 2012 Scott Nations
+ Copyright (c) 2012 Mathias Schott
+ Copyright (c) 2012 Nigel Stewart
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "pch.h" /* For MS precompiled header support */
+
+#include "RegalUtil.h"
+
+REGAL_GLOBAL_BEGIN
+
+#include <cstdlib>
+
+#include "RegalDispatch.h"
+
+REGAL_GLOBAL_END
+
+REGAL_NAMESPACE_BEGIN
+
+DispatchTableGlobal dispatchTableGlobal;
+
+#if REGAL_SYS_ANDROID && REGAL_STATIC_EGL
+extern void InitDispatchTableStaticEGL(DispatchTableGlobal &tbl);
+#endif
+
+DispatchTableGlobal::DispatchTableGlobal()
+{
+ memset(this,0,sizeof(DispatchTableGlobal));
+
+#if REGAL_SYS_ANDROID && REGAL_STATIC_EGL
+ InitDispatchTableStaticEGL(*this);
+#endif
+}
+
+DispatchTableGlobal::~DispatchTableGlobal()
+{
+}
+
+REGAL_NAMESPACE_END
View
@@ -42,7 +42,6 @@ using namespace std;
#include "RegalConfig.h"
#include "RegalHttp.h"
#include "RegalToken.h"
-#include "RegalDispatch.h"
#include "RegalDispatcher.h"
#include "RegalPrivate.h"
#include "RegalContextInfo.h"
@@ -62,12 +61,6 @@ using Token::toString;
static ::REGAL_NAMESPACE_INTERNAL::Init *init = NULL;
-DispatchTableGlobal dispatchTableGlobal;
-
-#if REGAL_SYS_ANDROID && REGAL_STATIC_EGL
-extern void InitDispatchTableStaticEGL(DispatchTableGlobal &tbl);
-#endif
-
#if !defined(REGAL_NAMESPACE) && REGAL_SYS_WGL
// Phony advapi32.dll, gdi32.dll and user32.dll dependencies for
// closely matching opengl32.dll
@@ -91,10 +84,6 @@ Init::Init()
return;
#endif
-#if REGAL_SYS_ANDROID && REGAL_STATIC_EGL
- InitDispatchTableStaticEGL(dispatchTableGlobal);
-#endif
-
Logging::Init();
Config::Init();
Http::Init();
@@ -145,6 +145,7 @@
<ClCompile Include="..\..\..\src\regal\RegalDispatchEmu.cpp" />
<ClCompile Include="..\..\..\src\regal\RegalDispatcher.cpp" />
<ClCompile Include="..\..\..\src\regal\RegalDispatchError.cpp" />
+ <ClCompile Include="..\..\..\src\regal\RegalDispatchGlobal.cpp" />
<ClCompile Include="..\..\..\src\regal\RegalDispatchLoader.cpp" />
<ClCompile Include="..\..\..\src\regal\RegalDispatchLog.cpp" />
<ClCompile Include="..\..\..\src\regal\RegalDispatchMissing.cpp" />

0 comments on commit 3a686e6

Please sign in to comment.