Rationalize naming/access to current thread-local-storage scheme. However, the prepr...
authorJohn Kessenich <cepheus@frii.com>
Tue, 2 Jul 2013 20:18:59 +0000 (20:18 +0000)
committerJohn Kessenich <cepheus@frii.com>
Tue, 2 Jul 2013 20:18:59 +0000 (20:18 +0000)
Also adding missing test.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22249 e7fa87d3-cd2b-0410-9028-fcbf551c1848

OGLCompilersDLL/InitializeDll.cpp
Test/precision.vert [new file with mode: 0644]
glslang/Include/InitializeParseContext.h
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.h
glslang/MachineIndependent/ShaderLang.cpp
glslang/MachineIndependent/glslang.l
glslang/OSDependent/Linux/ossource.cpp
glslang/OSDependent/Windows/ossource.cpp
glslang/Public/ShaderLang.h

index 8804ae853c3f427f1f0276100fe7bb904e0eaf61..7a9955d56ef417115010b875c603172cc2600a86 100644 (file)
@@ -89,7 +89,7 @@ bool InitThread()
 
        InitializeGlobalPools();
 
-       if (!InitializeGlobalParseContext())
+       if (!InitializeThreadParseContext())
         return false;
 
     if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
diff --git a/Test/precision.vert b/Test/precision.vert
new file mode 100644 (file)
index 0000000..5d07348
--- /dev/null
@@ -0,0 +1,25 @@
+#version 300 es
+
+in vec4 pos;
+
+uniform sampler2D s2D;
+uniform samplerCube sCube;
+uniform isampler2DArray is2DAbad;      // ERROR, no default precision
+uniform sampler2DArrayShadow s2dASbad; // ERROR, no default precision
+
+precision highp sampler2D;
+precision mediump sampler2DArrayShadow;
+
+uniform sampler2DArrayShadow s2dAS;
+uniform isampler2DArray is2DAbad2;     // ERROR, still no default precision
+
+uniform sampler2D s2Dhigh;
+
+void main()
+{
+    vec4 t = texture(s2D, vec2(0.1, 0.2));
+    t += texture(s2Dhigh, vec2(0.1, 0.2));
+    t += texture(s2dAS, vec4(0.5));
+
+    gl_Position = pos;
+}
index 4d369e8af63795b0bf379bb7e3fb175dd3d6feec..6fe095e7fbeaadc6ef995b406446cf219448691f 100644 (file)
@@ -37,7 +37,7 @@
 #include "osinclude.h"
 
 bool InitializeParseContextIndex();
-bool InitializeGlobalParseContext();
+bool InitializeThreadParseContext();
 bool FreeParseContext();
 bool FreeParseContextIndex();
 
index d6ac017adffd2ef05a8d76e663f851ef5e0af927..e6006c24dc87a446be158acab4d92e5e4f8ce6ce 100644 (file)
@@ -2038,10 +2038,10 @@ bool InitializeParseContextIndex()
     return true;
 }
 
-bool InitializeGlobalParseContext()
+bool InitializeThreadParseContext()
 {
     if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
-        assert(0 && "InitializeGlobalParseContext(): Parse Context index not initialized");
+        assert(0 && "InitializeThreadParseContext(): Parse Context index not initialized");
         return false;
     }
 
@@ -2053,7 +2053,7 @@ bool InitializeGlobalParseContext()
 
     TThreadParseContext *lpThreadData = new TThreadParseContext();
     if (lpThreadData == 0) {
-        assert(0 && "InitializeGlobalParseContext(): Unable to create thread parse context");
+        assert(0 && "InitializeThreadParseContext(): Unable to create thread parse context");
         return false;
     }
 
@@ -2063,7 +2063,7 @@ bool InitializeGlobalParseContext()
     return true;
 }
 
-TParseContextPointer& GetGlobalParseContext()
+TParseContextPointer& ThreadLocalParseContext()
 {
     //
     // Minimal error checking for speed
index aa7962d5b6b6151264e69ca19e7fbc5857117dab..990fd3fd2232ccc7a75f0b7f6a0388bd33f8a8c8 100644 (file)
@@ -185,8 +185,7 @@ int PaParseComment(int &lineno, TParseContext&);
 void ResetFlex();
 
 typedef TParseContext* TParseContextPointer;
-extern TParseContextPointer& GetGlobalParseContext();
-#define GlobalParseContext GetGlobalParseContext()
+TParseContextPointer& ThreadLocalParseContext();
 
 typedef struct TThreadParseContextRec
 {
index 20533d33d563ac154d2daca15ae27e898836d262..6c84330c83ebe05fd7db526a318b76c66d56aa02 100644 (file)
@@ -100,7 +100,7 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
 
     TParseContext parseContext(*symbolTable, intermediate, true, version, profile, language, infoSink);
 
-    GlobalParseContext = &parseContext;
+    ThreadLocalParseContext() = &parseContext;
     
     assert(symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
        
@@ -259,15 +259,14 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
 
 }; // end anonymous namespace for local functions
 
+//
+// ShInitialize() should be called exactly once per process, not per thread.
+//
 int ShInitialize()
 {
     if (! InitProcess())
         return 0;
 
-    // TODO: Quality: Thread safety:
-    // This method should be called once per process. If it's called by multiple threads, then 
-    // we need to have thread synchronization code around the initialization of per process
-    // global pool allocator
     if (! PerProcessGPA) { 
         PerProcessGPA = new TPoolAllocator(true);
     }
@@ -422,7 +421,7 @@ int ShCompile(
     else if (profile == EEsProfile && version >= 300 && versionNotFirst)
         parseContext.error(1, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
 
-    GlobalParseContext = &parseContext;
+    ThreadLocalParseContext() = &parseContext;
     
     ResetFlex();
     InitPreprocessor();
index 0845f8ae0b15638d4f0257839cacada38e82401c..1ca307dafc9e77b19eb12d2feaafe9d463d38c0b 100644 (file)
@@ -724,14 +724,14 @@ void yyerror(const char *s)
 \r
     if (pc.AfterEOF) {\r
         if (cpp->tokensBeforeEOF == 1)\r
-            GlobalParseContext->error(yylineno, "", "pre-mature EOF", s, "");\r
+            ThreadLocalParseContext()->error(yylineno, "", "pre-mature EOF", s, "");\r
     } else\r
-        GlobalParseContext->error(yylineno, "", yytext, s, "");\r
+        ThreadLocalParseContext()->error(yylineno, "", yytext, s, "");\r
 }\r
 \r
 void PaReservedWord()\r
 {\r
-    GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");\r
+    ThreadLocalParseContext()->error(yylineno, "Reserved word.", yytext, "", "");\r
 }\r
 \r
 int PaIdentOrType(const char* yytext, TParseContext& parseContextLocal, YYSTYPE* pyylval)\r
index 74a4107a383304d87562875387a722f728576caa..879e8385908d6080c469e08a01cfae5973f19435 100644 (file)
@@ -33,7 +33,7 @@
 //
 
 //
-// This file contains the Linux specific functions
+// This file contains the Linux-specific functions
 //
 #include "osinclude.h"
 #include "InitializeDll.h"
index 3c2cb85a0d212eebf4b15d6189bf11b6c1e6f1da..697e690d02e170d7552acc9a74420f863284aacb 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "osinclude.h"
 //
-// This file contains contains the window's specific functions
+// This file contains contains the Window-OS-specific functions
 //
 
 #if !(defined(_WIN32) || defined(_WIN64))
index d20b5d73ee24fd85e2f33cad6476dc55b4bbd42b..a6b057343804a05756a9e9eaec63cf55bee69e7d 100644 (file)
 #ifdef __cplusplus
     extern "C" {
 #endif
+
 //
 // Driver must call this first, once, before doing any other
 // compiler/linker operations.
 //
+// (Call once per process, not once per thread.)
+//
 SH_IMPORT_EXPORT int ShInitialize();
+
 //
-// Driver should call this at shutdown.
+// Driver should call this at process shutdown.
 //
 SH_IMPORT_EXPORT int __fastcall ShFinalize();