Merge pull request #2801 from haasn/thread_safety
Thread safety fixes
diff --git a/Test/GL_ARB_draw_instanced.vert b/Test/GL_ARB_draw_instanced.vert
new file mode 100644
index 0000000..6e39086
--- /dev/null
+++ b/Test/GL_ARB_draw_instanced.vert
@@ -0,0 +1,18 @@
+#version 150
+#extension GL_ARB_draw_instanced : require
+#define ID gl_InstanceID
+
+uniform mat4 gtf_ModelViewProjectionMatrix;
+uniform vec3 instanceOffsets[3];
+in vec4 va[gl_MaxVertexAttribs];
+out vec4 color;
+
+void main (void)
+{
+ vec4 vertex = vec4(va[0].xy / 3.0, va[0].zw) + vec4(instanceOffsets[ID], 1.0);
+ color = vec4(0, 0, 0, 0);
+ for (int i = 1; i < gl_MaxVertexAttribs; i++)
+ color += va[i];
+ gl_Position = gtf_ModelViewProjectionMatrix * vertex;
+ gl_PointSize = 1.0;
+}
diff --git a/Test/baseResults/GL_ARB_draw_instanced.vert.out b/Test/baseResults/GL_ARB_draw_instanced.vert.out
new file mode 100644
index 0000000..e601bc8
--- /dev/null
+++ b/Test/baseResults/GL_ARB_draw_instanced.vert.out
@@ -0,0 +1,189 @@
+GL_ARB_draw_instanced.vert
+Shader version: 150
+Requested GL_ARB_draw_instanced
+0:? Sequence
+0:10 Function Definition: main( ( global void)
+0:10 Function Parameters:
+0:12 Sequence
+0:12 Sequence
+0:12 move second child to first child ( temp 4-component vector of float)
+0:12 'vertex' ( temp 4-component vector of float)
+0:12 add ( temp 4-component vector of float)
+0:12 Construct vec4 ( temp 4-component vector of float)
+0:12 divide ( temp 2-component vector of float)
+0:12 vector swizzle ( temp 2-component vector of float)
+0:12 direct index ( temp 4-component vector of float)
+0:12 'va' ( in 64-element array of 4-component vector of float)
+0:12 Constant:
+0:12 0 (const int)
+0:12 Sequence
+0:12 Constant:
+0:12 0 (const int)
+0:12 Constant:
+0:12 1 (const int)
+0:12 Constant:
+0:12 3.000000
+0:12 vector swizzle ( temp 2-component vector of float)
+0:12 direct index ( temp 4-component vector of float)
+0:12 'va' ( in 64-element array of 4-component vector of float)
+0:12 Constant:
+0:12 0 (const int)
+0:12 Sequence
+0:12 Constant:
+0:12 2 (const int)
+0:12 Constant:
+0:12 3 (const int)
+0:12 Construct vec4 ( temp 4-component vector of float)
+0:12 indirect index ( temp 3-component vector of float)
+0:12 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
+0:12 'gl_InstanceID' ( gl_InstanceId int InstanceId)
+0:12 Constant:
+0:12 1.000000
+0:13 move second child to first child ( temp 4-component vector of float)
+0:13 'color' ( smooth out 4-component vector of float)
+0:13 Constant:
+0:13 0.000000
+0:13 0.000000
+0:13 0.000000
+0:13 0.000000
+0:14 Sequence
+0:14 Sequence
+0:14 move second child to first child ( temp int)
+0:14 'i' ( temp int)
+0:14 Constant:
+0:14 1 (const int)
+0:14 Loop with condition tested first
+0:14 Loop Condition
+0:14 Compare Less Than ( temp bool)
+0:14 'i' ( temp int)
+0:14 Constant:
+0:14 64 (const int)
+0:14 Loop Body
+0:15 add second child into first child ( temp 4-component vector of float)
+0:15 'color' ( smooth out 4-component vector of float)
+0:15 indirect index ( temp 4-component vector of float)
+0:15 'va' ( in 64-element array of 4-component vector of float)
+0:15 'i' ( temp int)
+0:14 Loop Terminal Expression
+0:14 Post-Increment ( temp int)
+0:14 'i' ( temp int)
+0:16 move second child to first child ( temp 4-component vector of float)
+0:16 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position)
+0:16 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance})
+0:16 Constant:
+0:16 0 (const uint)
+0:16 matrix-times-vector ( temp 4-component vector of float)
+0:16 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
+0:16 'vertex' ( temp 4-component vector of float)
+0:17 move second child to first child ( temp float)
+0:17 gl_PointSize: direct index for structure ( gl_PointSize float PointSize)
+0:17 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance})
+0:17 Constant:
+0:17 1 (const uint)
+0:17 Constant:
+0:17 1.000000
+0:? Linker Objects
+0:? 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
+0:? 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
+0:? 'va' ( in 64-element array of 4-component vector of float)
+0:? 'color' ( smooth out 4-component vector of float)
+0:? 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out unsized 1-element array of float ClipDistance gl_ClipDistance})
+0:? 'gl_VertexID' ( gl_VertexId int VertexId)
+0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
+
+
+Linked vertex stage:
+
+
+Shader version: 150
+Requested GL_ARB_draw_instanced
+0:? Sequence
+0:10 Function Definition: main( ( global void)
+0:10 Function Parameters:
+0:12 Sequence
+0:12 Sequence
+0:12 move second child to first child ( temp 4-component vector of float)
+0:12 'vertex' ( temp 4-component vector of float)
+0:12 add ( temp 4-component vector of float)
+0:12 Construct vec4 ( temp 4-component vector of float)
+0:12 divide ( temp 2-component vector of float)
+0:12 vector swizzle ( temp 2-component vector of float)
+0:12 direct index ( temp 4-component vector of float)
+0:12 'va' ( in 64-element array of 4-component vector of float)
+0:12 Constant:
+0:12 0 (const int)
+0:12 Sequence
+0:12 Constant:
+0:12 0 (const int)
+0:12 Constant:
+0:12 1 (const int)
+0:12 Constant:
+0:12 3.000000
+0:12 vector swizzle ( temp 2-component vector of float)
+0:12 direct index ( temp 4-component vector of float)
+0:12 'va' ( in 64-element array of 4-component vector of float)
+0:12 Constant:
+0:12 0 (const int)
+0:12 Sequence
+0:12 Constant:
+0:12 2 (const int)
+0:12 Constant:
+0:12 3 (const int)
+0:12 Construct vec4 ( temp 4-component vector of float)
+0:12 indirect index ( temp 3-component vector of float)
+0:12 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
+0:12 'gl_InstanceID' ( gl_InstanceId int InstanceId)
+0:12 Constant:
+0:12 1.000000
+0:13 move second child to first child ( temp 4-component vector of float)
+0:13 'color' ( smooth out 4-component vector of float)
+0:13 Constant:
+0:13 0.000000
+0:13 0.000000
+0:13 0.000000
+0:13 0.000000
+0:14 Sequence
+0:14 Sequence
+0:14 move second child to first child ( temp int)
+0:14 'i' ( temp int)
+0:14 Constant:
+0:14 1 (const int)
+0:14 Loop with condition tested first
+0:14 Loop Condition
+0:14 Compare Less Than ( temp bool)
+0:14 'i' ( temp int)
+0:14 Constant:
+0:14 64 (const int)
+0:14 Loop Body
+0:15 add second child into first child ( temp 4-component vector of float)
+0:15 'color' ( smooth out 4-component vector of float)
+0:15 indirect index ( temp 4-component vector of float)
+0:15 'va' ( in 64-element array of 4-component vector of float)
+0:15 'i' ( temp int)
+0:14 Loop Terminal Expression
+0:14 Post-Increment ( temp int)
+0:14 'i' ( temp int)
+0:16 move second child to first child ( temp 4-component vector of float)
+0:16 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position)
+0:16 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance})
+0:16 Constant:
+0:16 0 (const uint)
+0:16 matrix-times-vector ( temp 4-component vector of float)
+0:16 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
+0:16 'vertex' ( temp 4-component vector of float)
+0:17 move second child to first child ( temp float)
+0:17 gl_PointSize: direct index for structure ( gl_PointSize float PointSize)
+0:17 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance})
+0:17 Constant:
+0:17 1 (const uint)
+0:17 Constant:
+0:17 1.000000
+0:? Linker Objects
+0:? 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
+0:? 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
+0:? 'va' ( in 64-element array of 4-component vector of float)
+0:? 'color' ( smooth out 4-component vector of float)
+0:? 'anon@0' ( out block{ gl_Position 4-component vector of float Position gl_Position, gl_PointSize float PointSize gl_PointSize, out 1-element array of float ClipDistance gl_ClipDistance})
+0:? 'gl_VertexID' ( gl_VertexId int VertexId)
+0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
+
diff --git a/Test/baseResults/spv.1.4.OpEntryPoint.frag.out b/Test/baseResults/spv.1.4.OpEntryPoint.frag.out
index cf5d98a..2c6e6dc 100644
--- a/Test/baseResults/spv.1.4.OpEntryPoint.frag.out
+++ b/Test/baseResults/spv.1.4.OpEntryPoint.frag.out
@@ -1,4 +1,5 @@
spv.1.4.OpEntryPoint.frag
+Validation failed
// Module Version 10400
// Generated by (magic number): 8000a
// Id's are bound by 64
diff --git a/Test/baseResults/spv.intrinsicsSpirvLiteral.vert.out b/Test/baseResults/spv.intrinsicsSpirvLiteral.vert.out
index af4ac16..68ad949 100644
--- a/Test/baseResults/spv.intrinsicsSpirvLiteral.vert.out
+++ b/Test/baseResults/spv.intrinsicsSpirvLiteral.vert.out
@@ -1,4 +1,5 @@
spv.intrinsicsSpirvLiteral.vert
+Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 12
diff --git a/glslang/CInterface/glslang_c_interface.cpp b/glslang/CInterface/glslang_c_interface.cpp
index 2e04f53..4fdeff7 100644
--- a/glslang/CInterface/glslang_c_interface.cpp
+++ b/glslang/CInterface/glslang_c_interface.cpp
@@ -269,6 +269,8 @@
switch (client_version) {
case GLSLANG_TARGET_VULKAN_1_1:
return glslang::EShTargetVulkan_1_1;
+ case GLSLANG_TARGET_VULKAN_1_2:
+ return glslang::EShTargetVulkan_1_2;
case GLSLANG_TARGET_OPENGL_450:
return glslang::EShTargetOpenGL_450;
default:
diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h
index e7b5e07..a24977f 100644
--- a/glslang/Include/Common.h
+++ b/glslang/Include/Common.h
@@ -39,6 +39,7 @@
#include <algorithm>
#include <cassert>
+#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <list>
@@ -302,6 +303,34 @@
return result;
}
+inline bool IsInfinity(double x) {
+#ifdef _MSC_VER
+ switch (_fpclass(x)) {
+ case _FPCLASS_NINF:
+ case _FPCLASS_PINF:
+ return true;
+ default:
+ return false;
+ }
+#else
+ return std::isinf(x);
+#endif
+}
+
+inline bool IsNan(double x) {
+#ifdef _MSC_VER
+ switch (_fpclass(x)) {
+ case _FPCLASS_SNAN:
+ case _FPCLASS_QNAN:
+ return true;
+ default:
+ return false;
+ }
+#else
+ return std::isnan(x);
+#endif
+}
+
} // end namespace glslang
#endif // _COMMON_INCLUDED_
diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp
index 7f5d4c4..5fc61db 100644
--- a/glslang/MachineIndependent/Constant.cpp
+++ b/glslang/MachineIndependent/Constant.cpp
@@ -46,35 +46,6 @@
using namespace glslang;
-typedef union {
- double d;
- int i[2];
-} DoubleIntUnion;
-
-// Some helper functions
-
-bool isNan(double x)
-{
- DoubleIntUnion u;
- // tough to find a platform independent library function, do it directly
- u.d = x;
- int bitPatternL = u.i[0];
- int bitPatternH = u.i[1];
- return (bitPatternH & 0x7ff80000) == 0x7ff80000 &&
- ((bitPatternH & 0xFFFFF) != 0 || bitPatternL != 0);
-}
-
-bool isInf(double x)
-{
- DoubleIntUnion u;
- // tough to find a platform independent library function, do it directly
- u.d = x;
- int bitPatternL = u.i[0];
- int bitPatternH = u.i[1];
- return (bitPatternH & 0x7ff00000) == 0x7ff00000 &&
- (bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
-}
-
const double pi = 3.1415926535897932384626433832795;
} // end anonymous namespace
@@ -663,12 +634,12 @@
case EOpIsNan:
{
- newConstArray[i].setBConst(isNan(unionArray[i].getDConst()));
+ newConstArray[i].setBConst(IsNan(unionArray[i].getDConst()));
break;
}
case EOpIsInf:
{
- newConstArray[i].setBConst(isInf(unionArray[i].getDConst()));
+ newConstArray[i].setBConst(IsInfinity(unionArray[i].getDConst()));
break;
}
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 70a5d5e..2fc0d9e 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -225,6 +225,7 @@
extensionBehavior[E_GL_ARB_shading_language_packing] = EBhDisable;
extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable;
extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable;
+ extensionBehavior[E_GL_ARB_draw_instanced] = EBhDisable;
extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable;
extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable;
@@ -465,6 +466,7 @@
"#define GL_ARB_shader_storage_buffer_object 1\n"
"#define GL_ARB_texture_query_lod 1\n"
"#define GL_ARB_vertex_attrib_64bit 1\n"
+ "#define GL_ARB_draw_instanced 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_EXT_shader_image_load_formatted 1\n"
"#define GL_EXT_post_depth_coverage 1\n"
diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h
index 949a7a1..2dbac0b 100644
--- a/glslang/MachineIndependent/Versions.h
+++ b/glslang/MachineIndependent/Versions.h
@@ -161,6 +161,7 @@
const char* const E_GL_ARB_shading_language_packing = "GL_ARB_shading_language_packing";
const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_lod";
const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit";
+const char* const E_GL_ARB_draw_instanced = "GL_ARB_draw_instanced";
const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp
index a0fade1..d8a3aab 100644
--- a/glslang/MachineIndependent/intermOut.cpp
+++ b/glslang/MachineIndependent/intermOut.cpp
@@ -48,37 +48,6 @@
#endif
#include <cstdint>
-namespace {
-
-bool IsInfinity(double x) {
-#ifdef _MSC_VER
- switch (_fpclass(x)) {
- case _FPCLASS_NINF:
- case _FPCLASS_PINF:
- return true;
- default:
- return false;
- }
-#else
- return std::isinf(x);
-#endif
-}
-
-bool IsNan(double x) {
-#ifdef _MSC_VER
- switch (_fpclass(x)) {
- case _FPCLASS_SNAN:
- case _FPCLASS_QNAN:
- return true;
- default:
- return false;
- }
-#else
- return std::isnan(x);
-#endif
-}
-
-}
namespace glslang {
diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp
index 0db9754..f9680dd 100644
--- a/gtests/AST.FromFile.cpp
+++ b/gtests/AST.FromFile.cpp
@@ -285,7 +285,8 @@
"atomicAdd.comp",
"GL_ARB_gpu_shader5.u2i.vert",
"atomicCounterARBOps.vert",
- "GL_EXT_shader_integer_mix.vert"
+ "GL_EXT_shader_integer_mix.vert",
+ "GL_ARB_draw_instanced.vert",
})),
FileNameAsCustomTestSuffix
);
diff --git a/known_good.json b/known_good.json
index e1c2ce8..bed5dd8 100644
--- a/known_good.json
+++ b/known_good.json
@@ -5,14 +5,14 @@
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Tools",
"subdir" : "External/spirv-tools",
- "commit" : "1fbed83c8aab8517d821fcb4164c08567951938f"
+ "commit" : "339d4475c1a806c187c57678af26733575d1cecd"
},
{
"name" : "spirv-tools/external/spirv-headers",
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Headers",
"subdir" : "External/spirv-tools/external/spirv-headers",
- "commit" : "449bc986ba6f4c5e10e32828783f9daef2a77644"
+ "commit" : "29817199b7069bac971e5365d180295d4b077ebe"
}
]
}