Merge pull request #1941 from ehsannas/bazel_build
authorJohn Kessenich <johnkslang@users.noreply.github.com>
Tue, 22 Oct 2019 04:30:13 +0000 (22:30 -0600)
committerGitHub <noreply@github.com>
Tue, 22 Oct 2019 04:30:13 +0000 (22:30 -0600)
Add Bazel build files and bots for them

CMakeLists.txt
SPIRV/GlslangToSpv.cpp
Test/baseResults/spv.volatileAtomic.comp.out [new file with mode: 0644]
Test/runtests
Test/spv.volatileAtomic.comp [new file with mode: 0644]
gtests/Spv.FromFile.cpp

index 623045e..78dc5b2 100644 (file)
@@ -152,7 +152,7 @@ endfunction(glslang_set_link_args)
 # otherwise, it will find the wrong version and fail later
 if(BUILD_EXTERNAL AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/External)
     find_package(PythonInterp 3 REQUIRED)
-       
+
        # We depend on these for later projects, so they should come first.
        add_subdirectory(External)
 endif()
@@ -181,3 +181,26 @@ if(ENABLE_HLSL)
     add_subdirectory(hlsl)
 endif(ENABLE_HLSL)
 add_subdirectory(gtests)
+
+if(BUILD_TESTING)
+    # glslang-testsuite runs a bash script on Windows.
+    # Make sure to use '-o igncr' flag to ignore carriage returns (\r).
+    set(IGNORE_CR_FLAG "")
+    if(WIN32)
+        set(IGNORE_CR_FLAG -o igncr)
+    endif()
+
+    if (CMAKE_CONFIGURATION_TYPES)
+        set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/localResults)
+        set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIGURATION>/glslangValidator)
+        set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/$<CONFIGURATION>/spirv-remap)
+    else(CMAKE_CONFIGURATION_TYPES)
+        set(RESULTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/localResults)
+        set(VALIDATOR_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/glslangValidator)
+        set(REMAP_PATH ${CMAKE_CURRENT_BINARY_DIR}/StandAlone/spirv-remap)
+    endif(CMAKE_CONFIGURATION_TYPES)
+
+    add_test(NAME glslang-testsuite
+        COMMAND bash ${IGNORE_CR_FLAG} runtests ${RESULTS_PATH} ${VALIDATOR_PATH} ${REMAP_PATH}
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Test/)
+endif(BUILD_TESTING)
index f4e0fdb..ae5f24d 100644 (file)
@@ -6401,7 +6401,7 @@ spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv
         scopeId = builder.makeUintConstant(spv::ScopeDevice);
     }
     // semantics default to relaxed 
-    spv::Id semanticsId = builder.makeUintConstant(lvalueCoherentFlags.isVolatile() 
+    spv::Id semanticsId = builder.makeUintConstant(lvalueCoherentFlags.isVolatile() && glslangIntermediate->usingVulkanMemoryModel() ?
                                                     spv::MemorySemanticsVolatileMask :
                                                     spv::MemorySemanticsMaskNone);
     spv::Id semanticsId2 = semanticsId;
diff --git a/Test/baseResults/spv.volatileAtomic.comp.out b/Test/baseResults/spv.volatileAtomic.comp.out
new file mode 100644 (file)
index 0000000..aa2d211
--- /dev/null
@@ -0,0 +1,40 @@
+spv.volatileAtomic.comp
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 18
+
+                              Capability Shader
+               1:             ExtInstImport  "GLSL.std.450"
+                              MemoryModel Logical GLSL450
+                              EntryPoint GLCompute 4  "main"
+                              ExecutionMode 4 LocalSize 1 1 1
+                              Source GLSL 450
+                              Name 4  "main"
+                              Name 8  "D"
+                              MemberName 8(D) 0  "d"
+                              Name 10  "d"
+                              Decorate 7 ArrayStride 4
+                              MemberDecorate 8(D) 0 Volatile
+                              MemberDecorate 8(D) 0 Coherent
+                              MemberDecorate 8(D) 0 Offset 0
+                              Decorate 8(D) BufferBlock
+                              Decorate 10(d) DescriptorSet 0
+                              Decorate 10(d) Binding 3
+               2:             TypeVoid
+               3:             TypeFunction 2
+               6:             TypeInt 32 0
+               7:             TypeRuntimeArray 6(int)
+            8(D):             TypeStruct 7
+               9:             TypePointer Uniform 8(D)
+           10(d):      9(ptr) Variable Uniform
+              11:             TypeInt 32 1
+              12:     11(int) Constant 0
+              13:             TypePointer Uniform 6(int)
+              15:      6(int) Constant 0
+              16:      6(int) Constant 1
+         4(main):           2 Function None 3
+               5:             Label
+              14:     13(ptr) AccessChain 10(d) 12 12
+              17:      6(int) AtomicExchange 14 16 15 15
+                              Return
+                              FunctionEnd
index 8e31c06..23406dc 100755 (executable)
@@ -1,11 +1,16 @@
 #!/usr/bin/env bash
 
-TARGETDIR=localResults
+# Arguments:
+#  1- TargetDirectory, where to write test results and intermediary files
+#  2- Path to glslangValidator
+#  3- Path to spirv-remap
+
+TARGETDIR=${1:-localResults}
 BASEDIR=baseResults
-EXE=../build/install/bin/glslangValidator
-REMAPEXE=../build/install/bin/spirv-remap
+EXE=${2:-../build/install/bin/glslangValidator}
+REMAPEXE=${3:-../build/install/bin/spirv-remap}
 HASERROR=0
-mkdir -p localResults
+mkdir -p $TARGETDIR
 
 if [ -a localtestlist ]
   then
@@ -55,13 +60,13 @@ diff -b $BASEDIR/hlsl.automap.frag.out $TARGETDIR/hlsl.automap.frag.out || HASER
 # multi-threaded test
 #
 echo Comparing single thread to multithread for all tests in current directory...
-$EXE -i -C *.vert *.geom *.frag *.tesc *.tese *.comp > singleThread.out
-$EXE -i -C *.vert *.geom *.frag *.tesc *.tese *.comp -t > multiThread.out
-diff singleThread.out multiThread.out || HASERROR=1
+$EXE -i -C *.vert *.geom *.frag *.tesc *.tese *.comp > $TARGETDIR/singleThread.out
+$EXE -i -C *.vert *.geom *.frag *.tesc *.tese *.comp -t > $TARGETDIR/multiThread.out
+diff $TARGETDIR/singleThread.out $TARGETDIR/multiThread.out || HASERROR=1
 if [ $HASERROR -eq 0 ]
 then
-    rm singleThread.out
-    rm multiThread.out
+    rm $TARGETDIR/singleThread.out
+    rm $TARGETDIR/multiThread.out
 fi
 
 #
diff --git a/Test/spv.volatileAtomic.comp b/Test/spv.volatileAtomic.comp
new file mode 100644 (file)
index 0000000..2b7e6c6
--- /dev/null
@@ -0,0 +1,8 @@
+#version 450 core\r
+\r
+layout(set=0, binding=3) volatile buffer D { uint d[]; } d;\r
+\r
+void main()\r
+{\r
+    atomicExchange(d.d[0], 0);\r
+}\r
index d0c0751..9620341 100644 (file)
@@ -404,6 +404,7 @@ INSTANTIATE_TEST_CASE_P(
         "spv.storageBuffer.vert",
         "spv.precise.tese",
         "spv.precise.tesc",
+        "spv.volatileAtomic.comp",
         "spv.vulkan100.subgroupArithmetic.comp",
         "spv.vulkan100.subgroupPartitioned.comp",
         "spv.xfb.vert",