Skip to content

Commit

Permalink
Merge pull request #1 from KhronosGroup/master
Browse files Browse the repository at this point in the history
sync to KhronosGroup/glslang
  • Loading branch information
neslimsah authored Mar 26, 2020
2 parents cea9384 + 2df8c71 commit 575f9df
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 50 deletions.
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ genrule(
"SPIRV/GLSL.ext.KHR.h",
"SPIRV/GLSL.ext.NV.h",
"SPIRV/GLSL.std.450.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/spirv.hpp",
],
outs = [
Expand All @@ -94,7 +94,7 @@ genrule(
"include/SPIRV/GLSL.ext.KHR.h",
"include/SPIRV/GLSL.ext.NV.h",
"include/SPIRV/GLSL.std.450.h",
"include/SPIRV/NonSemanticDebugPrintf.h",
"include/SPIRV/NonSemanticDebugPrintf.h",
"include/SPIRV/spirv.hpp",
],
cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/",
Expand Down
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ source_set("glslang_sources") {
"SPIRV/InReadableOrder.cpp",
"SPIRV/Logger.cpp",
"SPIRV/Logger.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/SPVRemapper.cpp",
"SPIRV/SPVRemapper.h",
"SPIRV/SpvBuilder.cpp",
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ if(ENABLE_GLSLANG_JS)
add_compile_options(/Os /GR-)
else()
add_compile_options(-Os -fno-exceptions)
add_link_options(-Os)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-unused-variable -Wno-unused-const-variable)
endif()
endif()
endif(ENABLE_GLSLANG_JS)

# Request C++11
if(${CMAKE_VERSION} VERSION_LESS 3.1)
# CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
# remove this block once CMake >=3.1 has fixated in the ecosystem
add_compile_options(-std=c++11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,29 @@ With no arguments it builds the full grammar, and with a "web" argument,
the web grammar subset (see more about the web subset in the next section).

### Building to WASM for the Web and Node
### Building a standalone JS/WASM library for the Web and Node

Use the steps in [Build Steps](#build-steps), with the following notes/exceptions:
* For building the web subset of core glslang:
+ execute `updateGrammar web` from the glslang subdirectory
(or if using your own scripts, `m4` needs a `-DGLSLANG_WEB` argument)
+ set `-DENABLE_HLSL=OFF -DBUILD_TESTING=OFF -DENABLE_OPT=OFF -DINSTALL_GTEST=OFF`
+ turn on `-DENABLE_GLSLANG_JS=ON`
+ optionally, for a minimum-size binary, turn on `-DENABLE_GLSLANG_WEBMIN=ON`
+ optionally, for GLSL compilation error messages, turn on `-DENABLE_GLSLANG_WEB_DEVEL=ON`
* `emsdk` needs to be present in your executable search path, *PATH* for
Bash-like environments
+ [Instructions located
here](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install)
Bash-like environments:
+ [Instructions located here](https://emscripten.org/docs/getting_started/downloads.html#sdk-download-and-install)
* Wrap cmake call: `emcmake cmake`
* Set `-DBUILD_TESTING=OFF -DENABLE_OPT=OFF -DINSTALL_GTEST=OFF`.
* Set `-DENABLE_HLSL=OFF` if HLSL is not needed.
* For a standalone JS/WASM library, turn on `-DENABLE_GLSLANG_JS=ON`.
* For building a minimum-size web subset of core glslang:
+ turn on `-DENABLE_GLSLANG_WEBMIN=ON` (disables HLSL)
+ execute `updateGrammar web` from the glslang subdirectory
(or if using your own scripts, `m4` needs a `-DGLSLANG_WEB` argument)
+ optionally, for GLSL compilation error messages, turn on
`-DENABLE_GLSLANG_WEBMIN_DEVEL=ON`
* To get a fully minimized build, make sure to use `brotli` to compress the .js
and .wasm files

Example:

```sh
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_WEB=ON \
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_GLSLANG_JS=ON \
-DENABLE_HLSL=OFF -DBUILD_TESTING=OFF -DENABLE_OPT=OFF -DINSTALL_GTEST=OFF ..
```

Expand Down
2 changes: 1 addition & 1 deletion SPIRV/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ std::string SpvBuildLogger::getAllMessages() const {

} // end spv namespace

#endif
#endif
2 changes: 1 addition & 1 deletion Test/foo.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#error should not be included
#error should not be included
2 changes: 1 addition & 1 deletion Test/inc2/foo.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
float4 i6;
float4 i6;
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
theme: jekyll-theme-merlot
theme: jekyll-theme-merlot
2 changes: 1 addition & 1 deletion glslang/Include/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ class TQualifier {
bool hasAttachment() const { return false; }
TLayoutFormat getFormat() const { return ElfNone; }
bool isPushConstant() const { return false; }
bool isShaderRecordNV() const { return false; }
bool isShaderRecord() const { return false; }
bool hasBufferReference() const { return false; }
bool hasBufferReferenceAlign() const { return false; }
bool isNonUniform() const { return false; }
Expand Down
2 changes: 1 addition & 1 deletion glslang/Include/glslang_c_shader_types.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
This code is based on the glslang_c_interface implementation by Viktor Latypov
**/

Expand Down
26 changes: 13 additions & 13 deletions glslang/Include/revision.template
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// The file revision.h should be updated to the latest version, somehow, on
// check-in, if glslang has changed.
//
// revision.template is the source for revision.h when using SubWCRev as the
// method of updating revision.h. You don't have to do it this way, the
// requirement is only that revision.h gets updated.
//
// revision.h is under source control so that not all consumers of glslang
// source have to figure out how to create revision.h just to get a build
// going. However, if it is not updated, it can be a version behind.
#define GLSLANG_REVISION "$WCREV$"
#define GLSLANG_DATE "$WCDATE$"
// The file revision.h should be updated to the latest version, somehow, on
// check-in, if glslang has changed.
//
// revision.template is the source for revision.h when using SubWCRev as the
// method of updating revision.h. You don't have to do it this way, the
// requirement is only that revision.h gets updated.
//
// revision.h is under source control so that not all consumers of glslang
// source have to figure out how to create revision.h just to get a build
// going. However, if it is not updated, it can be a version behind.

#define GLSLANG_REVISION "$WCREV$"
#define GLSLANG_DATE "$WCDATE$"
3 changes: 2 additions & 1 deletion glslang/MachineIndependent/Initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8983,9 +8983,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
}
break;
case EShLangIntersect:
if (profile != EEsProfile && version >= 460)
if (profile != EEsProfile && version >= 460) {
symbolTable.relateToOperator("reportIntersectionNV", EOpReportIntersection);
symbolTable.relateToOperator("reportIntersectionEXT", EOpReportIntersection);
}
break;
case EShLangAnyHit:
if (profile != EEsProfile && version >= 460) {
Expand Down
2 changes: 1 addition & 1 deletion glslang/MachineIndependent/intermOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,4 +1562,4 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)

} // end namespace glslang

#endif // not GLSLANG_WEB
#endif // not GLSLANG_WEB
2 changes: 1 addition & 1 deletion glslang/MachineIndependent/localintermediate.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class TIntermediate {
bool getAutoMapBindings() const { return false; }
bool getAutoMapLocations() const { return false; }
int getNumPushConstants() const { return 0; }
void addShaderRecordNVCount() { }
void addShaderRecordCount() { }
void addTaskNVCount() { }
void setUseVulkanMemoryModel() { }
bool usingVulkanMemoryModel() const { return false; }
Expand Down
2 changes: 1 addition & 1 deletion glslang/MachineIndependent/parseConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
if (nodeComps == 1) {
// If there is a single scalar parameter to a matrix
// constructor, it is used to initialize all the
// components on the matrixs diagonal, with the
// components on the matrix's diagonal, with the
// remaining components initialized to 0.0.
if (i == startIndex || (i - startIndex) % (matrixRows + 1) == 0 )
leftUnionArray[i] = rightUnionArray[count];
Expand Down
2 changes: 1 addition & 1 deletion glslang/MachineIndependent/propagateNoContraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,4 @@ void PropagateNoContraction(const glslang::TIntermediate& intermediate)
}
};

#endif // GLSLANG_WEB
#endif // GLSLANG_WEB
2 changes: 1 addition & 1 deletion glslang/MachineIndependent/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ class TReflection {

#endif // _REFLECTION_INCLUDED

#endif // GLSLANG_WEB
#endif // GLSLANG_WEB
22 changes: 13 additions & 9 deletions glslang/OSDependent/Web/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ if(ENABLE_GLSLANG_JS)
glslang_set_link_args(glslang.js)
target_link_libraries(glslang.js glslang SPIRV)

# Link library names that start with "-" are treated as link flags.
# "-Os" should be OK in MSVC; don't use /Os because CMake won't
# treat it as a link flag.
target_link_libraries(glslang.js "-Os")

if(EMSCRIPTEN)
set_target_properties(glslang.js PROPERTIES
OUTPUT_NAME "glslang"
SUFFIX ".js")
em_link_pre_js(glslang.js "${CMAKE_CURRENT_SOURCE_DIR}/glslang.pre.js")

target_link_options(glslang.js PRIVATE "SHELL: -Os")
target_link_options(glslang.js PRIVATE "SHELL: --llvm-lto 1")
target_link_options(glslang.js PRIVATE "SHELL: --closure 1")
target_link_options(glslang.js PRIVATE "SHELL: -s MODULARIZE=1")
target_link_options(glslang.js PRIVATE "SHELL: -s ALLOW_MEMORY_GROWTH=1")
target_link_options(glslang.js PRIVATE "SHELL: -s FILESYSTEM=0")
target_link_libraries(glslang.js "--llvm-lto 1")
target_link_libraries(glslang.js "--closure 1")
target_link_libraries(glslang.js "-s MODULARIZE=1")
target_link_libraries(glslang.js "-s ALLOW_MEMORY_GROWTH=1")
target_link_libraries(glslang.js "-s FILESYSTEM=0")

if(ENABLE_EMSCRIPTEN_SINGLE_FILE)
target_link_options(glslang.js PRIVATE "SHELL: -s SINGLE_FILE=1")
target_link_libraries(glslang.js "-s SINGLE_FILE=1")
endif(ENABLE_EMSCRIPTEN_SINGLE_FILE)

if(ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
target_link_options(glslang.js PRIVATE "SHELL: -s ENVIRONMENT=node -s BINARYEN_ASYNC_COMPILATION=0")
target_link_libraries(glslang.js "-s ENVIRONMENT=node -s BINARYEN_ASYNC_COMPILATION=0")
else()
target_link_options(glslang.js PRIVATE "SHELL: -s ENVIRONMENT=web,worker")
target_link_libraries(glslang.js "-s ENVIRONMENT=web,worker")
endif()

if(NOT ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
Expand Down

0 comments on commit 575f9df

Please sign in to comment.