diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-08-21 23:17:01 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-08-21 23:17:01 +0000 |
commit | bc7611c39c09ce0a69b3dc961d24d019634be0dd (patch) | |
tree | 5d9a36c83e41c83aece048d301785bb3c2602b0c | |
parent | 1ffa644cde7e5e005b953e75ef5268d14a27c79c (diff) | |
parent | 70efe7ea655e2bba080248c239d0798a1a1f1055 (diff) | |
download | shaderc-bc7611c39c09ce0a69b3dc961d24d019634be0dd.tar.gz |
Merge "Merge tag 'v2020.2' into update-shaderc" into master-ndk
64 files changed, 841 insertions, 210 deletions
@@ -5,13 +5,14 @@ build-*/ compile_commands.json .ycm_extra_conf.py cscope.* -third_party/effcee/ -third_party/glslang/ -third_party/googletest/ -third_party/re2/ -third_party/spirv-tools/ -third_party/spirv-headers/ -third_party/spirv-cross/ +third_party/effcee +third_party/glslang +third_party/googletest +third_party/re2 +third_party/spirv-tools +third_party/spirv-headers +third_party/spirv-cross +third_party/tint android_test/libs android_test/include .DS_Store @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + ROOT_SHADERC_PATH := $(call my-dir) include $(ROOT_SHADERC_PATH)/third_party/Android.mk @@ -164,13 +164,11 @@ config("shaderc_spvc_public") { "${spirv_headers_dir}/include", # Accessing a private spirv-tools headers. "${spirv_tools_dir}", + # Accessing auto-generated spirv-tools headers. The headers are generated by + # actions in ${spirv_tools_dir}/BUILD.gn, hence locate the action outputs + # using the generated file directory corresponding to that build file. + get_path_info("${spirv_tools_dir}/BUILD.gn", "gen_dir"), ] - - if (build_with_chromium) { - include_dirs += [ "${target_gen_dir}/../../SPIRV-Tools/src", ] - } else { - include_dirs += [ "${target_gen_dir}/../SPIRV-Tools", ] - } if (is_component_build) { defines = [ "SHADERC_SHAREDLIB" ] @@ -1,7 +1,37 @@ Revision history for Shaderc -v2020.1-dev 2020-03-06 - - Start v2020.1-dev +v2020.2 2020-07-23 + - General: + - Remove VS2013 support + - Support both posix and non-posix MinGW toolchains + - Support optionally building Tint tooling for WGSL + - Add -h option to glslc, spvc; same as --help + - Add source file license checker + - BUILD.gn improvements + + - glslc, libshaderc: + - Update to Glslang generator 9 + - Add interface to support 16bit types in HLSL + - Add glslc hidden experimental option -mfmt=wgsl; requires Tint + + - spvc: + - Add minimum buffer size for Dawn reflection + +v2020.1 2020-06-09 + This is the last version that officially supports VS2013. + + - General: + - Added warning signs about unsupported downloads (#1041) + - Added .NET bindings to README.md (#1060) + - Only add -fPIC if supported by the compiler. (#1061) + + - glslc, libshaderc: + - Removed Singleton pattern around access to glslang (#1059) + + - spvc: + - Added concept of comparison sampler to API (#1036) + - Added support for options.hlsl.nonwritable_uav_texture_as_srv (#1048) + - Support forcing storage buffers to be always declared as UAV. (#1076) v2020.0 2020-03-06 - General: diff --git a/CMakeLists.txt b/CMakeLists.txt index 93a808a..6392d2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 2.8.12) project(shaderc) enable_testing() @@ -10,6 +24,7 @@ endif() message(STATUS "Shaderc: build type is \"${CMAKE_BUILD_TYPE}\".") option(SHADERC_ENABLE_SPVC "Enable libshaderc_spvc" OFF) +option(SHADERC_ENABLE_WGSL_OUTPUT "Enable WGSL output" OFF) option(SHADERC_SKIP_INSTALL "Skip installation" ${SHADERC_SKIP_INSTALL}) if(NOT ${SHADERC_SKIP_INSTALL}) @@ -4,13 +4,13 @@ vars = { 'google_git': 'https://github.com/google', 'khronos_git': 'https://github.com/KhronosGroup', - 'effcee_revision' : '5af957bbfc7da4e9f7aa8cac11379fa36dd79b84', - 'glslang_revision': '2b0eafb1de5b4a1b77cf123545ea269d44248885', - 'googletest_revision': '011959aafddcd30611003de96cfd8d7a7685c700', - 're2_revision': '787495f0ba2e76dcadb21db84455ea0e2ce15beb', - 'spirv_headers_revision': 'ac638f1815425403e946d0ab78bac71d2bdbf3be', - 'spirv_tools_revision': '9cb2571a184c0fe571100c799301426a492f7407', - 'spirv_cross_revision': '61cddd6307ef8a644462bc1263d196e1bae9ec67', + 'effcee_revision' : '2ec8f8738118cc483b67c04a759fee53496c5659', + 'glslang_revision': '3ee5f2f1d3316e228916788b300d786bb574d337', + 'googletest_revision': 'a781fe29bcf73003559a3583167fe3d647518464', + 're2_revision': 'ca11026a032ce2a3de4b3c389ee53d2bdc8794d6', + 'spirv_headers_revision': '979924c8bc839e4cb1b69d03d48398551f369ce7', + 'spirv_tools_revision': '969f0286479b89267b6c89f6d5223285c265e6ae', + 'spirv_cross_revision': '6575e451f5bffded6e308988362224dd076b0f2b', } deps = { @@ -195,8 +195,8 @@ On Linux, if cross compiling to Windows: On Windows, the following tools should be installed and available on your path: -- Visual Studio 2013 Update 4 or later. Previous versions of Visual Studio - will likely work but are untested. +- Visual Studio 2015 or later. Previous versions of Visual Studio may work but + are untested and unsupported. - Git - including the associated tools, Bash, `diff`. Optionally, the following tools may be installed on any OS: diff --git a/android_test/Android.mk b/android_test/Android.mk index 4959331..31ad381 100644 --- a/android_test/Android.mk +++ b/android_test/Android.mk @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) diff --git a/android_test/jni/Android.mk b/android_test/jni/Android.mk index 8a36259..1360751 100644 --- a/android_test/jni/Android.mk +++ b/android_test/jni/Android.mk @@ -1,2 +1,16 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + LOCAL_PATH := $(call my-dir) include $(LOCAL_PATH)/../Android.mk diff --git a/android_test/jni/Application.mk b/android_test/jni/Application.mk index c5d90ef..ef50946 100644 --- a/android_test/jni/Application.mk +++ b/android_test/jni/Application.mk @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + APP_ABI := all APP_BUILD_SCRIPT := Android.mk APP_STL := c++_static diff --git a/cmake/linux-mingw-toolchain.cmake b/cmake/linux-mingw-toolchain.cmake index 400b9a0..60e965e 100644 --- a/cmake/linux-mingw-toolchain.cmake +++ b/cmake/linux-mingw-toolchain.cmake @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + SET(CMAKE_SYSTEM_NAME Windows) set(MINGW_COMPILER_PREFIX "i686-w64-mingw32" CACHE STRING @@ -8,8 +22,12 @@ set(MINGW_SYSROOT "/usr/${MINGW_COMPILER_PREFIX}" CACHE STRING # Which compilers to use for C and C++ find_program(CMAKE_RC_COMPILER NAMES ${MINGW_COMPILER_PREFIX}-windres) -find_program(CMAKE_C_COMPILER NAMES ${MINGW_COMPILER_PREFIX}-gcc) -find_program(CMAKE_CXX_COMPILER NAMES ${MINGW_COMPILER_PREFIX}-g++) +find_program(CMAKE_C_COMPILER NAMES + ${MINGW_COMPILER_PREFIX}-gcc-posix + ${MINGW_COMPILER_PREFIX}-gcc) +find_program(CMAKE_CXX_COMPILER NAMES + ${MINGW_COMPILER_PREFIX}-g++-posix + ${MINGW_COMPILER_PREFIX}-g++) SET(CMAKE_FIND_ROOT_PATH ${MINGW_SYSROOT}) diff --git a/cmake/setup_build.cmake b/cmake/setup_build.cmake index 4dc49c7..5dab384 100644 --- a/cmake/setup_build.cmake +++ b/cmake/setup_build.cmake @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + if(NOT COMMAND find_host_package) macro(find_host_package) find_package(${ARGN}) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index e3b3a77..ffa9336 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # utility functions function (shaderc_use_gmock TARGET) diff --git a/downloads.md b/downloads.md index 72a0446..1738668 100644 --- a/downloads.md +++ b/downloads.md @@ -9,7 +9,6 @@ Download the latest builds. | --- | --- | --- | | [MSVC 2017](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html) | [clang](https://storage.googleapis.com/shaderc/badges/build_link_linux_clang_release.html) | [clang](https://storage.googleapis.com/shaderc/badges/build_link_macos_clang_release.html) | | [MSVC 2015](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2015_release.html) | [gcc](https://storage.googleapis.com/shaderc/badges/build_link_linux_gcc_release.html) | | -| [MSVC 2013](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2013_release.html) | | | ## Debug | Windows | Linux | MacOS | diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 176c40b..ce1f4c0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1 +1,15 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + add_subdirectory(online-compile) diff --git a/examples/online-compile/CMakeLists.txt b/examples/online-compile/CMakeLists.txt index feab8f2..6cceb6b 100644 --- a/examples/online-compile/CMakeLists.txt +++ b/examples/online-compile/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + add_executable(shaderc-online-compile main.cc) shaderc_default_compile_options(shaderc-online-compile) target_include_directories(shaderc-online-compile PUBLIC ${shaderc_SOURCE_DIR}/libshaderc_util/include) diff --git a/glslc/CMakeLists.txt b/glslc/CMakeLists.txt index acf6fb0..31664d1 100644 --- a/glslc/CMakeLists.txt +++ b/glslc/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + find_package(Threads) add_library(glslc STATIC @@ -17,9 +31,22 @@ add_library(glslc STATIC shaderc_default_compile_options(glslc) target_include_directories(glslc PUBLIC ${glslang_SOURCE_DIR}) -target_link_libraries(glslc PRIVATE glslang OSDependent OGLCompiler - HLSL glslang SPIRV ${CMAKE_THREAD_LIBS_INIT}) -target_link_libraries(glslc PRIVATE shaderc_util shaderc) + +if (SHADERC_ENABLE_WGSL_OUTPUT) + if (IS_DIRECTORY "${tint_SOURCE_DIR}/include") + target_include_directories(glslc PRIVATE "${tint_SOURCE_DIR}/include") + target_include_directories(glslc PRIVATE "${tint_SOURCE_DIR}") + endif() + # Turn on features in the tint/tint.h header + add_definitions(-DTINT_BUILD_SPV_READER=1 -DTINT_BUILD_WGSL_WRITER=1) + add_definitions(-DSHADERC_ENABLE_WGSL_OUTPUT=1) +endif(SHADERC_ENABLE_WGSL_OUTPUT) + +target_link_libraries(glslc PRIVATE + glslang OSDependent OGLCompiler HLSL glslang SPIRV # Glslang libraries + $<$<BOOL:${SHADERC_ENABLE_WGSL_OUTPUT}>:libtint> # Tint libraries, optional + shaderc_util shaderc # internal Shaderc libraries + ${CMAKE_THREAD_LIBS_INIT}) add_executable(glslc_exe src/main.cc) shaderc_default_compile_options(glslc_exe) diff --git a/glslc/README.asciidoc b/glslc/README.asciidoc index bfcdbb4..dfd105b 100644 --- a/glslc/README.asciidoc +++ b/glslc/README.asciidoc @@ -13,6 +13,7 @@ Clang-compatible arguments. ---- glslc [--help] +glslc [-h] glslc [--show-limits] @@ -119,9 +120,9 @@ Otherwise, === Overall Options -==== `--help` +==== `--help`, `-h` -`--help` tells the glslc compiler to display all available options and exit. +Option `--help` or `-h` tells the glslc compiler to display all available options and exit. ==== `--show-limits` diff --git a/glslc/src/file_compiler.cc b/glslc/src/file_compiler.cc index 839cc6e..5d67be1 100644 --- a/glslc/src/file_compiler.cc +++ b/glslc/src/file_compiler.cc @@ -20,6 +20,10 @@ #include <iostream> #include <sstream> +#if SHADERC_ENABLE_WGSL_OUTPUT == 1 +#include "tint/tint.h" +#endif // SHADERC_ENABLE_WGSL_OUTPUT==1 + #include "file.h" #include "file_includer.h" #include "shader_stage.h" @@ -246,6 +250,26 @@ bool FileCompiler::EmitCompiledResult( *out << "}" << std::endl; } break; + case SpirvBinaryEmissionFormat::WGSL: { +#if SHADERC_ENABLE_WGSL_OUTPUT == 1 + tint::Context ctx; + tint::reader::spirv::Parser spv_reader( + &ctx, std::vector<uint32_t>(result.begin(), result.end())); + if (!spv_reader.Parse()) { + std::cout << "error: failed to convert SPIR-V binary to WGSL: " + << spv_reader.error() << std::endl; + return false; + } + tint::writer::wgsl::Generator wgsl_writer(spv_reader.module()); + if (!wgsl_writer.Generate()) { + std::cout << "error: failed to convert to WGSL: " + << wgsl_writer.error() << std::endl; + return false; + } + *out << wgsl_writer.result(); +#endif // SHADERC_ENABLE_WGSL_OUTPUT==1 + break; + } } } @@ -344,12 +368,15 @@ bool FileCompiler::ValidateOptions(size_t num_files) { case SpirvBinaryEmissionFormat::CInitList: std::cerr << "C-style initializer list"; break; + case SpirvBinaryEmissionFormat::WGSL: + std::cerr << "WGSL source program"; + break; case SpirvBinaryEmissionFormat::Unspecified: // The compiler should never be here at runtime. This case is added to // complete the switch cases. break; } - std::cerr << " when the output is not SPIR-V binary code" << std::endl; + std::cerr << " when only preprocessing the source" << std::endl; return false; } if (dependency_info_dumping_handler_ && @@ -357,9 +384,19 @@ bool FileCompiler::ValidateOptions(size_t num_files) { std::cerr << "glslc: error: cannot dump dependency info when specifying " "any binary output format" << std::endl; + return false; } } + if (binary_emission_format_ == SpirvBinaryEmissionFormat::WGSL) { +#if SHADERC_ENABLE_WGSL_OUTPUT != 1 + std::cerr << "glslc: error: can't output WGSL: glslc was built without " + "WGSL output support" + << std::endl; + return false; +#endif + } + return true; } diff --git a/glslc/src/file_compiler.h b/glslc/src/file_compiler.h index 1fa7c7e..cd41f73 100644 --- a/glslc/src/file_compiler.h +++ b/glslc/src/file_compiler.h @@ -43,8 +43,10 @@ class FileCompiler { // code form. Binary, // Emits SPIR-V binary code directly. Numbers, // Emits SPIR-V binary code as a list of hex numbers. - CInitList, // Emits SPIR-V bianry code as a C-style initializer list + CInitList, // Emits SPIR-V binary code as a C-style initializer list // of hex numbers. + WGSL, // Emits SPIR-V module converted to WGSL source text. + // Requires a build with Tint support. }; FileCompiler() diff --git a/glslc/src/main.cc b/glslc/src/main.cc index bed325b..2b1c03e 100644 --- a/glslc/src/main.cc +++ b/glslc/src/main.cc @@ -125,12 +125,15 @@ Options: tesc, tesseval, tese, geometry, geom, compute, and comp. -g Generate source-level debug information. Currently this option has no effect. + -h Display available options. --help Display available options. -I <value> Add directory to include search path. -mfmt=<format> Output SPIR-V binary code using the selected format. This option may be specified only when the compilation output is - in SPIR-V binary code form. Available options include bin, c - and num. By default the binary output format is bin. + in SPIR-V binary code form. Available options are: + bin - SPIR-V binary words. This is the default. + c - Binary words as C initializer list of 32-bit ints + num - List of comma-separated 32-bit hex integers -M Generate make dependencies. Implies -E and -w. -MM An alias for -M. -MD Generate make dependencies and compile. @@ -263,7 +266,7 @@ int main(int argc, char** argv) { for (int i = 1; i < argc; ++i) { const string_piece arg = argv[i]; - if (arg == "--help") { + if (arg == "--help" || arg == "-h") { ::PrintHelp(&std::cout); return 0; } else if (arg == "--show-limits") { @@ -310,7 +313,8 @@ int main(int argc, char** argv) { compiler.options().SetHlslIoMapping(true); } else if (arg == "-fhlsl-offsets") { compiler.options().SetHlslOffsets(true); - } else if (arg == "-fhlsl_functionality1" || arg == "-fhlsl-functionality1") { + } else if (arg == "-fhlsl_functionality1" || + arg == "-fhlsl-functionality1") { compiler.options().SetHlslFunctionality1(true); } else if (arg == "-finvert-y") { compiler.options().SetInvertY(true); @@ -477,6 +481,9 @@ int main(int argc, char** argv) { } else if (binary_output_format == "c") { compiler.SetSpirvBinaryOutputFormat( glslc::FileCompiler::SpirvBinaryEmissionFormat::CInitList); + } else if (binary_output_format == "wgsl") { + compiler.SetSpirvBinaryOutputFormat( + glslc::FileCompiler::SpirvBinaryEmissionFormat::WGSL); } else { std::cerr << "glslc: error: invalid value '" << binary_output_format << "' in '-mfmt=" << binary_output_format << "'" << std::endl; diff --git a/glslc/test/CMakeLists.txt b/glslc/test/CMakeLists.txt index 6916192..ac001bd 100644 --- a/glslc/test/CMakeLists.txt +++ b/glslc/test/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + add_test(NAME shaderc_expect_unittests COMMAND ${PYTHON_EXECUTABLE} -m unittest expect_unittest.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/glslc/test/assembly.py b/glslc/test/assembly.py index 6a5f096..30fdba4 100644 --- a/glslc/test/assembly.py +++ b/glslc/test/assembly.py @@ -21,7 +21,7 @@ def assembly_comments(): return """ ; SPIR-V ; Version: 1.0 - ; Generator: Google Shaderc over Glslang; 8 + ; Generator: Google Shaderc over Glslang; 10 ; Bound: 6 ; Schema: 0""" diff --git a/glslc/test/expect.py b/glslc/test/expect.py index 4950405..7410f73 100644 --- a/glslc/test/expect.py +++ b/glslc/test/expect.py @@ -27,6 +27,11 @@ import sys from glslc_test_framework import GlslCTest from builtins import bytes +GLSLANG_GENERATOR_VERSION=10 +SHADERC_GENERATOR_NUMBER=13 +SHADERC_GENERATOR_WORD=(SHADERC_GENERATOR_NUMBER << 16) + GLSLANG_GENERATOR_VERSION +ASSEMBLER_GENERATOR_WORD=(7<<16) + def convert_to_string(input): if type(input) is not str: if sys.version_info[0] == 2: @@ -190,8 +195,8 @@ class CorrectBinaryLengthAndPreamble(GlslCTest): return False, 'Incorrect SPV binary: wrong version number' # Shaderc-over-Glslang (0x000d....) or # SPIRV-Tools (0x0007....) generator number - if read_word(preamble, 2, little_endian) != 0x000d0008 and \ - read_word(preamble, 2, little_endian) != 0x00070000: + if read_word(preamble, 2, little_endian) != SHADERC_GENERATOR_WORD and \ + read_word(preamble, 2, little_endian) != ASSEMBLER_GENERATOR_WORD: return False, ('Incorrect SPV binary: wrong generator magic ' 'number') # reserved for instruction schema diff --git a/glslc/test/option_dash_cap_O.py b/glslc/test/option_dash_cap_O.py index c8ada7d..9655a39 100644 --- a/glslc/test/option_dash_cap_O.py +++ b/glslc/test/option_dash_cap_O.py @@ -23,7 +23,7 @@ EMPTY_SHADER_IN_CWD = Directory('.', [File('shader.vert', MINIMAL_SHADER)]) ASSEMBLY_WITH_DEBUG_SOURCE = [ '; SPIR-V\n', '; Version: 1.0\n', - '; Generator: Google Shaderc over Glslang; 8\n', + '; Generator: Google Shaderc over Glslang; 10\n', '; Bound: 7\n', '; Schema: 0\n', ' OpCapability Shader\n', @@ -51,7 +51,7 @@ ASSEMBLY_WITH_DEBUG_SOURCE = [ ASSEMBLY_WITH_DEBUG = [ '; SPIR-V\n', '; Version: 1.0\n', - '; Generator: Google Shaderc over Glslang; 8\n', + '; Generator: Google Shaderc over Glslang; 10\n', '; Bound: 6\n', '; Schema: 0\n', ' OpCapability Shader\n', @@ -72,7 +72,7 @@ ASSEMBLY_WITH_DEBUG = [ ASSEMBLY_WITHOUT_DEBUG = [ '; SPIR-V\n', '; Version: 1.0\n', - '; Generator: Google Shaderc over Glslang; 8\n', + '; Generator: Google Shaderc over Glslang; 10\n', '; Bound: 6\n', '; Schema: 0\n', ' OpCapability Shader\n', diff --git a/glslc/test/option_dash_o.py b/glslc/test/option_dash_o.py index d3ddab4..cd7f1d1 100644 --- a/glslc/test/option_dash_o.py +++ b/glslc/test/option_dash_o.py @@ -80,7 +80,7 @@ class OutputFileBinaryAvoidsCRLFTranslation(expect.ReturnCodeIsZero, # object file checks. SHADER_WITH_THREE_NEWLINES_IN_BINARY = """#version 450 layout(location = 0) out uint ovar; - void main() { ovar = 10; } + void main() { ovar = 9; } """ shader = FileShader(SHADER_WITH_THREE_NEWLINES_IN_BINARY, '.vert') diff --git a/glslc/test/option_mfmt.py b/glslc/test/option_mfmt.py index 2466319..bd58478 100644 --- a/glslc/test/option_mfmt.py +++ b/glslc/test/option_mfmt.py @@ -90,8 +90,7 @@ class TestFmtCErrorWhenOutputDisasembly(expect.ErrorMessage): shader = FileShader(MINIMAL_SHADER, '.vert') glslc_args = [shader, '-mfmt=c', '-S', '-o', 'output_file'] expected_error = ("glslc: error: cannot emit output as a C-style " - "initializer list when the output is not SPIR-V " - "binary code\n") + "initializer list when only preprocessing the source\n") @inside_glslc_testsuite('OptionMfmt') @@ -103,7 +102,7 @@ class TestFmtNumErrorWhenOutputDisasembly(expect.ErrorMessage): glslc_args = [shader, '-mfmt=num', '-S', '-o', 'output_file'] expected_error = ( "glslc: error: cannot emit output as a list of hex numbers " - "when the output is not SPIR-V binary code\n") + "when only preprocessing the source\n") @inside_glslc_testsuite('OptionMfmt') @@ -114,7 +113,7 @@ class TestFmtBinErrorWhenOutputDisasembly(expect.ErrorMessage): shader = FileShader(MINIMAL_SHADER, '.vert') glslc_args = [shader, '-mfmt=bin', '-S', '-o', 'output_file'] expected_error = ("glslc: error: cannot emit output as a binary " - "when the output is not SPIR-V binary code\n") + "when only preprocessing the source\n") @inside_glslc_testsuite('OptionMfmt') @@ -126,7 +125,7 @@ class TestFmtNumErrorWhenOutputPreprocess(expect.ErrorMessage): glslc_args = [shader, '-mfmt=num', '-E', '-o', 'output_file'] expected_error = ( "glslc: error: cannot emit output as a list of hex numbers " - "when the output is not SPIR-V binary code\n") + "when only preprocessing the source\n") @inside_glslc_testsuite('OptionMfmt') @@ -138,8 +137,7 @@ class TestFmtCErrorWithDashCapM(expect.ErrorMessage): shader = FileShader(MINIMAL_SHADER, '.vert') glslc_args = [shader, '-mfmt=c', '-M', '-o', 'output_file'] expected_error = ("glslc: error: cannot emit output as a C-style " - "initializer list when the output is not SPIR-V " - "binary code\n") + "initializer list when only preprocessing the source\n") @inside_glslc_testsuite('OptionMfmt') diff --git a/glslc/test/parameter_tests.py b/glslc/test/parameter_tests.py index 8705211..18b43f4 100644 --- a/glslc/test/parameter_tests.py +++ b/glslc/test/parameter_tests.py @@ -129,12 +129,15 @@ Options: tesc, tesseval, tese, geometry, geom, compute, and comp. -g Generate source-level debug information. Currently this option has no effect. + -h Display available options. --help Display available options. -I <value> Add directory to include search path. -mfmt=<format> Output SPIR-V binary code using the selected format. This option may be specified only when the compilation output is - in SPIR-V binary code form. Available options include bin, c - and num. By default the binary output format is bin. + in SPIR-V binary code form. Available options are: + bin - SPIR-V binary words. This is the default. + c - Binary words as C initializer list of 32-bit ints + num - List of comma-separated 32-bit hex integers -M Generate make dependencies. Implies -E and -w. -MM An alias for -M. -MD Generate make dependencies and compile. diff --git a/kokoro/linux/build-docker.sh b/kokoro/linux/build-docker.sh new file mode 100755 index 0000000..fb65f81 --- /dev/null +++ b/kokoro/linux/build-docker.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# Copyright (C) 2017 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Linux Build Script run inside docker container. + +set -e # Fail on any error. + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # Display commands being run. + +SKIP_TESTS="False" +BUILD_TYPE="Debug" + +using cmake-3.17.2 +using ninja-1.10.0 + +if [ ! -z "$COMPILER" ]; then + using "$COMPILER" +fi + +# Possible configurations are: +# ASAN, COVERAGE, RELEASE, DEBUG, DEBUG_EXCEPTION, RELEASE_MINGW + +if [ $CONFIG = "RELEASE" ] || [ $CONFIG = "RELEASE_MINGW" ] +then + BUILD_TYPE="RelWithDebInfo" +fi + +ADDITIONAL_CMAKE_FLAGS="" +if [ $CONFIG = "ASAN" ] +then + ADDITIONAL_CMAKE_FLAGS="-DCMAKE_CXX_FLAGS=-fsanitize=address -DCMAKE_C_FLAGS=-fsanitize=address" +elif [ $CONFIG = "COVERAGE" ] +then + ADDITIONAL_CMAKE_FLAGS="-DENABLE_CODE_COVERAGE=ON" + SKIP_TESTS="True" +elif [ $CONFIG = "DEBUG_EXCEPTION" ] +then + ADDITIONAL_CMAKE_FLAGS="-DDISABLE_EXCEPTIONS=ON -DDISABLE_RTTI=ON" +elif [ $CONFIG = "RELEASE_MINGW" ] +then + ADDITIONAL_CMAKE_FLAGS="-Dgtest_disable_pthreads=ON -DCMAKE_TOOLCHAIN_FILE=$ROOT_DIR/cmake/linux-mingw-toolchain.cmake" + SKIP_TESTS="True" +fi + +cd $ROOT_DIR +./utils/git-sync-deps + +mkdir build +cd $ROOT_DIR/build + +# Invoke the build. +BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} +echo $(date): Starting build... +cmake -GNinja -DCMAKE_INSTALL_PREFIX=$KOKORO_ARTIFACTS_DIR/install -DSHADERC_ENABLE_SPVC=ON -DRE2_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE $ADDITIONAL_CMAKE_FLAGS .. + +echo $(date): Build glslang... +ninja glslangValidator + +echo $(date): Build everything... +ninja +echo $(date): Build completed. + +echo $(date): Check Shaderc for copyright notices... +ninja check-copyright + +if [ $CONFIG = "COVERAGE" ] +then + echo $(date): Check coverage... + ninja report-coverage + echo $(date): Check coverage completed. +fi + +echo $(date): Starting ctest... +if [ $SKIP_TESTS = "False" ] +then + ctest --output-on-failure -j4 +fi +echo $(date): ctest completed. + +# Package the build. +ninja install +cd $KOKORO_ARTIFACTS_DIR +tar czf install.tgz install diff --git a/kokoro/linux/build.sh b/kokoro/linux/build.sh index a1a3396..765a387 100644..100755 --- a/kokoro/linux/build.sh +++ b/kokoro/linux/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (C) 2017 Google Inc. +# Copyright (C) 2020 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,94 +16,22 @@ # # Linux Build Script. +set -e # Fail on any error. -# Fail on any error. -set -e -# Display commands being run. -set -x +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )" -BUILD_ROOT=$PWD -SRC=$PWD/github/shaderc CONFIG=$1 COMPILER=$2 -SKIP_TESTS="False" -BUILD_TYPE="Debug" - -CMAKE_C_CXX_COMPILER="" -if [ $COMPILER = "clang" ] -then - PATH=/usr/lib/llvm-3.8/bin:$PATH - CMAKE_C_CXX_COMPILER="-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" -fi - -# Possible configurations are: -# ASAN, COVERAGE, RELEASE, DEBUG, DEBUG_EXCEPTION, RELEASE_MINGW - -if [ $CONFIG = "RELEASE" ] || [ $CONFIG = "RELEASE_MINGW" ] -then - BUILD_TYPE="RelWithDebInfo" -fi - -ADDITIONAL_CMAKE_FLAGS="" -if [ $CONFIG = "ASAN" ] -then - ADDITIONAL_CMAKE_FLAGS="-DCMAKE_CXX_FLAGS=-fsanitize=address -DCMAKE_C_FLAGS=-fsanitize=address" - [ $COMPILER = "clang" ] || { echo "$CONFIG requires clang"; exit 1; } -elif [ $CONFIG = "COVERAGE" ] -then - ADDITIONAL_CMAKE_FLAGS="-DENABLE_CODE_COVERAGE=ON" - SKIP_TESTS="True" -elif [ $CONFIG = "DEBUG_EXCEPTION" ] -then - ADDITIONAL_CMAKE_FLAGS="-DDISABLE_EXCEPTIONS=ON -DDISABLE_RTTI=ON" -elif [ $CONFIG = "RELEASE_MINGW" ] -then - ADDITIONAL_CMAKE_FLAGS="-Dgtest_disable_pthreads=ON -DCMAKE_TOOLCHAIN_FILE=$SRC/cmake/linux-mingw-toolchain.cmake" - SKIP_TESTS="True" -fi - -# Get NINJA. -wget -q https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip -unzip -q ninja-linux.zip -export PATH="$PWD:$PATH" - -cd $SRC -./utils/git-sync-deps - -mkdir build -cd $SRC/build - -# Invoke the build. -BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} -echo $(date): Starting build... -cmake -GNinja -DCMAKE_INSTALL_PREFIX=$KOKORO_ARTIFACTS_DIR/install -DSHADERC_ENABLE_SPVC=ON -DRE2_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE $ADDITIONAL_CMAKE_FLAGS $CMAKE_C_CXX_COMPILER .. - -echo $(date): Build glslang... -ninja glslangValidator - -echo $(date): Build everything... -ninja -echo $(date): Build completed. - -echo $(date): Check Shaderc for copyright notices... -ninja check-copyright - -if [ $CONFIG = "COVERAGE" ] -then - echo $(date): Check coverage... - ninja report-coverage - echo $(date): Check coverage completed. -fi - -echo $(date): Starting ctest... -if [ $SKIP_TESTS = "False" ] -then - ctest --output-on-failure -j4 -fi -echo $(date): ctest completed. - -# Package the build. -ninja install -cd $KOKORO_ARTIFACTS_DIR -tar czf install.tgz install +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}" \ + --volume "${KOKORO_ARTIFACTS_DIR}:${KOKORO_ARTIFACTS_DIR}" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --env CONFIG="${CONFIG}" \ + --env COMPILER="${COMPILER}" \ + --env KOKORO_ARTIFACTS_DIR="${KOKORO_ARTIFACTS_DIR}" \ + --entrypoint "${SCRIPT_DIR}/build-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" diff --git a/kokoro/linux/build_clang_asan.sh b/kokoro/linux/build_clang_asan.sh index dae3173..9110bc5 100644..100755 --- a/kokoro/linux/build_clang_asan.sh +++ b/kokoro/linux/build_clang_asan.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh ASAN clang +source $SCRIPT_DIR/build.sh ASAN "clang-10.0.0" diff --git a/kokoro/linux/build_clang_debug.sh b/kokoro/linux/build_clang_debug.sh index 6e045ae..227237e 100644..100755 --- a/kokoro/linux/build_clang_debug.sh +++ b/kokoro/linux/build_clang_debug.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh DEBUG clang +source $SCRIPT_DIR/build.sh DEBUG "clang-10.0.0" diff --git a/kokoro/linux/build_clang_release.sh b/kokoro/linux/build_clang_release.sh index de73841..126f5d4 100644..100755 --- a/kokoro/linux/build_clang_release.sh +++ b/kokoro/linux/build_clang_release.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh RELEASE clang +source $SCRIPT_DIR/build.sh RELEASE "clang-10.0.0" diff --git a/kokoro/linux/build_gcc_coverage.sh b/kokoro/linux/build_gcc_coverage.sh index 4ee1848..7270334 100644..100755 --- a/kokoro/linux/build_gcc_coverage.sh +++ b/kokoro/linux/build_gcc_coverage.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh COVERAGE gcc +source $SCRIPT_DIR/build.sh COVERAGE "gcc-7" # gcc-8+ has issues with lcov diff --git a/kokoro/linux/build_gcc_debug.sh b/kokoro/linux/build_gcc_debug.sh index 23f4819..3a96cf7 100644..100755 --- a/kokoro/linux/build_gcc_debug.sh +++ b/kokoro/linux/build_gcc_debug.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh DEBUG gcc +source $SCRIPT_DIR/build.sh DEBUG "gcc-9" diff --git a/kokoro/linux/build_gcc_debug_exception.sh b/kokoro/linux/build_gcc_debug_exception.sh index d2c8e9a..9849336 100644..100755 --- a/kokoro/linux/build_gcc_debug_exception.sh +++ b/kokoro/linux/build_gcc_debug_exception.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh DEBUG_EXCEPTION gcc +source $SCRIPT_DIR/build.sh DEBUG_EXCEPTION "gcc-9" diff --git a/kokoro/linux/build_gcc_release.sh b/kokoro/linux/build_gcc_release.sh index fedc393..9123604 100644..100755 --- a/kokoro/linux/build_gcc_release.sh +++ b/kokoro/linux/build_gcc_release.sh @@ -22,4 +22,4 @@ set -e set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` -source $SCRIPT_DIR/build.sh RELEASE gcc +source $SCRIPT_DIR/build.sh RELEASE "gcc-9" diff --git a/kokoro/linux/build_mingw_release.sh b/kokoro/linux/build_mingw_release.sh index 0b54dc6..0b54dc6 100644..100755 --- a/kokoro/linux/build_mingw_release.sh +++ b/kokoro/linux/build_mingw_release.sh diff --git a/kokoro/windows/continuous_release_2013.cfg b/kokoro/linux/continuous_license_check.cfg index 0f9f7ac..066a4d3 100644 --- a/kokoro/windows/continuous_release_2013.cfg +++ b/kokoro/linux/continuous_license_check.cfg @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Google Inc. +# Copyright (C) 2020 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,10 +13,4 @@ # limitations under the License. # Continuous build configuration. -build_file: "shaderc/kokoro/windows/build_release_2013.bat" - -action { - define_artifacts { - regex: "install.zip" - } -} +build_file: "shaderc/kokoro/linux/license_check.sh" diff --git a/kokoro/linux/license_check.sh b/kokoro/linux/license_check.sh new file mode 100755 index 0000000..a36e4ff --- /dev/null +++ b/kokoro/linux/license_check.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright (C) 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" +ROOT_DIR="$( cd "${SCRIPT_DIR}/../.." >/dev/null 2>&1 && pwd )" + +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}:ro" \ + --workdir "${ROOT_DIR}" \ + --env ROOT_DIR="${ROOT_DIR}" \ + --env SCRIPT_DIR="${SCRIPT_DIR}" \ + --entrypoint "${SCRIPT_DIR}/license_check_docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest" diff --git a/kokoro/linux/license_check_docker.sh b/kokoro/linux/license_check_docker.sh new file mode 100755 index 0000000..f88077e --- /dev/null +++ b/kokoro/linux/license_check_docker.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright (C) 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e # Fail on any error. +set -x # Display commands being run. + +license-checker --dir="$ROOT_DIR"
\ No newline at end of file diff --git a/kokoro/windows/presubmit_release_2013.cfg b/kokoro/linux/presubmit_license_check.cfg index fbb64d4..38db8f5 100644 --- a/kokoro/windows/presubmit_release_2013.cfg +++ b/kokoro/linux/presubmit_license_check.cfg @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Google Inc. +# Copyright (C) 2020 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # limitations under the License. # Presubmit build configuration. -build_file: "shaderc/kokoro/windows/build_release_2013.bat" +build_file: "shaderc/kokoro/linux/license_check.sh" diff --git a/kokoro/windows/build.bat b/kokoro/windows/build.bat index 55d46ba..077caef 100644 --- a/kokoro/windows/build.bat +++ b/kokoro/windows/build.bat @@ -41,9 +41,6 @@ if %VS_VERSION% == 2017 ( ) else if %VS_VERSION% == 2015 ( call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 echo "Using VS 2015..." -) else if %VS_VERSION% == 2013 ( - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 - echo "Using VS 2013..." ) :: ######################################### @@ -58,11 +55,6 @@ if "%KOKORO_GITHUB_COMMIT%." == "." ( set CMAKE_FLAGS=-DCMAKE_INSTALL_PREFIX=%KOKORO_ARTIFACTS_DIR%\install -DSHADERC_ENABLE_SPVC=ON -DRE2_BUILD_TESTING=OFF -GNinja -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -:: Skip building SPIRV-Tools tests for VS2013 -if %VS_VERSION% == 2013 ( - set CMAKE_FLAGS=%CMAKE_FLAGS% -DSHADERC_SKIP_TESTS=ON -DSPIRV_SKIP_TESTS=ON -) - cmake %CMAKE_FLAGS% .. if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% @@ -83,13 +75,11 @@ echo "Build Completed %DATE% %TIME%" setlocal ENABLEDELAYEDEXPANSION :: ################################################ -:: Run the tests (We no longer run tests on VS2013) +:: Run the tests :: ################################################ echo "Running tests... %DATE% %TIME%" -if %VS_VERSION% NEQ 2013 ( - ctest -C %BUILD_TYPE% --output-on-failure -j4 - if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! -) +ctest -C %BUILD_TYPE% --output-on-failure -j4 +if !ERRORLEVEL! NEQ 0 exit /b !ERRORLEVEL! echo "Tests passed %DATE% %TIME%" :: ################################################ diff --git a/kokoro/windows/build_release_2013.bat b/kokoro/windows/build_release_2013.bat deleted file mode 100644 index 84e7ede..0000000 --- a/kokoro/windows/build_release_2013.bat +++ /dev/null @@ -1,24 +0,0 @@ -:: Copyright (C) 2017 Google Inc. -:: -:: Licensed under the Apache License, Version 2.0 (the "License"); -:: you may not use this file except in compliance with the License. -:: You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: -:: Windows Build Script. - -@echo on - -:: Find out the directory of the common build script. -set SCRIPT_DIR=%~dp0 - -:: Call with correct parameter -call %SCRIPT_DIR%\build.bat RelWithDebInfo 2013 - diff --git a/libshaderc/Android.mk b/libshaderc/Android.mk index 64618af..294af69 100644 --- a/libshaderc/Android.mk +++ b/libshaderc/Android.mk @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) diff --git a/libshaderc/CMakeLists.txt b/libshaderc/CMakeLists.txt index f4a80d8..3ada419 100644 --- a/libshaderc/CMakeLists.txt +++ b/libshaderc/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + project(libshaderc) # Even though shaderc.hpp is a headers-only library, adding diff --git a/libshaderc/src/common_shaders_for_test.h b/libshaderc/src/common_shaders_for_test.h index 8a2ee41..e177797 100644 --- a/libshaderc/src/common_shaders_for_test.h +++ b/libshaderc/src/common_shaders_for_test.h @@ -233,7 +233,7 @@ const char kVertexOnlyShaderWithInvalidPragma[] = const char* kMinimalShaderDisassemblySubstrings[] = { "; SPIR-V\n" "; Version: 1.0\n" - "; Generator: Google Shaderc over Glslang; 8\n" + "; Generator: Google Shaderc over Glslang; 10\n" "; Bound:", " OpCapability Shader\n", @@ -245,7 +245,7 @@ const char* kMinimalShaderDisassemblySubstrings[] = { const char* kMinimalShaderDebugInfoDisassemblySubstrings[] = { "; SPIR-V\n" "; Version: 1.0\n" - "; Generator: Google Shaderc over Glslang; 8\n" + "; Generator: Google Shaderc over Glslang; 10\n" "; Bound:", " OpCapability Shader\n", @@ -257,7 +257,7 @@ const char* kMinimalShaderDebugInfoDisassemblySubstrings[] = { const char kMinimalShaderAssembly[] = R"( ; SPIR-V ; Version: 1.0 - ; Generator: Google Shaderc over Glslang; 8 + ; Generator: Google Shaderc over Glslang; 10 ; Bound: 6 ; Schema: 0 diff --git a/libshaderc_spvc/Android.mk b/libshaderc_spvc/Android.mk index f0579a8..a13e05b 100644 --- a/libshaderc_spvc/Android.mk +++ b/libshaderc_spvc/Android.mk @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) diff --git a/libshaderc_spvc/CMakeLists.txt b/libshaderc_spvc/CMakeLists.txt index b22f9eb..927375c 100644 --- a/libshaderc_spvc/CMakeLists.txt +++ b/libshaderc_spvc/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + project(libshaderc) find_package(Threads) diff --git a/libshaderc_spvc/include/spvc/spvc.h b/libshaderc_spvc/include/spvc/spvc.h index f952ece..d216ad5 100644 --- a/libshaderc_spvc/include/spvc/spvc.h +++ b/libshaderc_spvc/include/spvc/spvc.h @@ -242,6 +242,7 @@ typedef struct { shaderc_spvc_texture_format_type texture_component_type; bool multisampled; shaderc_spvc_storage_texture_format storage_texture_format; + uint64_t minimum_buffer_size; } shaderc_spvc_binding_info; typedef struct { @@ -457,12 +458,23 @@ SHADERC_EXPORT shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_point_coord_compat( shaderc_spvc_compile_options_t options, bool b); +// If true, enable 16-bit types. Default is false. +SHADERC_EXPORT shaderc_spvc_status +shaderc_spvc_compile_options_set_hlsl_enable_16bit_types( + shaderc_spvc_compile_options_t options, bool b); + // If true, set non-writable storage images to be SRV, see spirv_hlsl.hpp in // SPIRV-Cross for more details. SHADERC_EXPORT shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_nonwritable_uav_texture_as_srv( shaderc_spvc_compile_options_t options, bool b); +// Set storage buffers to be always declared as UAV, even if the read-only +// declaration is used, see spirv_hlsl.hpp in SPIRV-Cross for more details. +SHADERC_EXPORT shaderc_spvc_status +shaderc_spvc_set_hlsl_force_storage_buffer_as_uav( + const shaderc_spvc_context_t context, uint32_t desc_set, uint32_t binding); + // If true (default is false): // GLSL: map depth from Vulkan/D3D style to GL style, i.e. [ 0,w] -> [-w,w] // MSL : map depth from GL style to Vulkan/D3D style, i.e. [-w,w] -> [ 0,w] diff --git a/libshaderc_spvc/include/spvc/spvc.hpp b/libshaderc_spvc/include/spvc/spvc.hpp index 42b7149..1c2e7d4 100644 --- a/libshaderc_spvc/include/spvc/spvc.hpp +++ b/libshaderc_spvc/include/spvc/spvc.hpp @@ -295,6 +295,12 @@ class CompileOptions { options_.get(), b); } + // If true, enable 16-bit types. Default is false. + shaderc_spvc_status SetHLSLEnable16BitTypes(bool b) { + return shaderc_spvc_compile_options_set_hlsl_enable_16bit_types( + options_.get(), b); + } + // If true, set non-writable storage images to be SRV, see spirv_hlsl.hpp in // SPIRV-Cross for more details. shaderc_spvc_status SetHLSLNonWritableUAVTextureAsSRV(bool b) { @@ -570,6 +576,12 @@ class Context { types->data(), &type_count); } + // Set storage buffers to be always declared as UAV, even if the read-only + // declaration is used, see spirv_hlsl.hpp in SPIRV-Cross for more details. + shaderc_spvc_status SetHLSLForceStorageBufferAsUAV(uint32_t desc_set, uint32_t binding) { + return shaderc_spvc_set_hlsl_force_storage_buffer_as_uav(context_.get(), desc_set, binding); + } + private: Context(const Context&) = delete; Context& operator=(const Context& other) = delete; diff --git a/libshaderc_spvc/src/spvc.cc b/libshaderc_spvc/src/spvc.cc index 20f208a..5e27b56 100644 --- a/libshaderc_spvc/src/spvc.cc +++ b/libshaderc_spvc/src/spvc.cc @@ -630,6 +630,14 @@ shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_point_coord_compat( return shaderc_spvc_status_success; } +shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_enable_16bit_types( + shaderc_spvc_compile_options_t options, bool b) { + CHECK_OPTIONS(nullptr, options); + + options->hlsl.enable_16bit_types = b; + return shaderc_spvc_status_success; +} + shaderc_spvc_status shaderc_spvc_compile_options_set_hlsl_nonwritable_uav_texture_as_srv( shaderc_spvc_compile_options_t options, bool b) { @@ -639,6 +647,17 @@ shaderc_spvc_compile_options_set_hlsl_nonwritable_uav_texture_as_srv( return shaderc_spvc_status_success; } +shaderc_spvc_status shaderc_spvc_set_hlsl_force_storage_buffer_as_uav( + const shaderc_spvc_context_t context, uint32_t desc_set, uint32_t binding) { + CHECK_CONTEXT(context); + CHECK_CROSS_COMPILER(context, context->cross_compiler); + + auto* hlsl_compiler = reinterpret_cast<spirv_cross::CompilerHLSL*>( + context->cross_compiler.get()); + hlsl_compiler->set_hlsl_force_storage_buffer_as_uav(desc_set, binding); + return shaderc_spvc_status_success; +} + shaderc_spvc_status shaderc_spvc_compile_options_set_fixup_clipspace( shaderc_spvc_compile_options_t options, bool b) { CHECK_OPTIONS(nullptr, options); @@ -1033,6 +1052,15 @@ shaderc_spvc_status shaderc_spvc_get_binding_info( bindings->id = shader_resource.id; bindings->base_type_id = shader_resource.base_type_id; + if (binding_type == shaderc_spvc_binding_type_uniform_buffer || + binding_type == shaderc_spvc_binding_type_storage_buffer) { + // Determine buffer size, with a minimum of 1 element in the runtime array + spirv_cross::SPIRType type = + compiler->get_type(shader_resource.base_type_id); + bindings->minimum_buffer_size = + compiler->get_declared_struct_size_runtime_array(type, 1); + } + switch (binding_type) { case shaderc_spvc_binding_type_sampled_texture: { spirv_cross::SPIRType::ImageType imageType = diff --git a/libshaderc_util/Android.mk b/libshaderc_util/Android.mk index 81b4c76..a694787 100644 --- a/libshaderc_util/Android.mk +++ b/libshaderc_util/Android.mk @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) diff --git a/libshaderc_util/CMakeLists.txt b/libshaderc_util/CMakeLists.txt index f8ae95d..48f9991 100644 --- a/libshaderc_util/CMakeLists.txt +++ b/libshaderc_util/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + project(libshaderc_util) add_library(shaderc_util STATIC diff --git a/libshaderc_util/testdata/copy-to-build.cmake b/libshaderc_util/testdata/copy-to-build.cmake index bf50a72..7b41b61 100644 --- a/libshaderc_util/testdata/copy-to-build.cmake +++ b/libshaderc_util/testdata/copy-to-build.cmake @@ -1,2 +1,16 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + file(GLOB all_files ${CMAKE_CURRENT_LIST_DIR}/*) file(COPY ${all_files} DESTINATION .)
\ No newline at end of file diff --git a/license-checker.cfg b/license-checker.cfg new file mode 100644 index 0000000..d30ca8e --- /dev/null +++ b/license-checker.cfg @@ -0,0 +1,42 @@ +[ + { + "licenses": [ "Apache-2.0-Header" ], + "paths": [ + { + "exclude": [ + "**.md", + "**.png", + "**/README.asciidoc", + + ".*", + "AUTHORS", + "CHANGES", + "CONTRIBUTORS", + "DEPS", + "LICENSE", + + "cmake/*.pc.in", + "libshaderc_util/testdata/dir/subdir/include_file.2", + "libshaderc_util/testdata/include_file.1", + "spvc/README.asciidoc", + "spvc/test/known_failures", + "spvc/test/known_invalids", + "spvc/test/known_spvc_failures", + "spvc/test/unconfirmed_invalids", + "spvc/test/**.vert", + + "utils/git-sync-deps", + + "third_party/**" + ] + } + ] + }, + { + "licenses": [ "BSD-3-Clause" ], + "paths": [ + { "exclude": [ "**" ] }, + { "include": [ "utils/git-sync-deps" ] } + ] + } +]
\ No newline at end of file diff --git a/spvc/CMakeLists.txt b/spvc/CMakeLists.txt index f465972..399b04e 100644 --- a/spvc/CMakeLists.txt +++ b/spvc/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + add_executable(spvc_exe src/main.cc) shaderc_default_compile_options(spvc_exe) target_include_directories(spvc_exe PRIVATE ${shaderc_SOURCE_DIR}/libshaderc/include ${spirv-tools_SOURCE_DIR}/include) diff --git a/spvc/src/main.cc b/spvc/src/main.cc index 8a31af6..b8e03e9 100644 --- a/spvc/src/main.cc +++ b/spvc/src/main.cc @@ -38,6 +38,7 @@ Usage: spvc [options] file An input file of - represents standard input. Options: + -h Display available options. --help Display available options. -v Display compiler version information. -o <output file> '-' means standard output. @@ -184,7 +185,7 @@ int main(int argc, char** argv) { shaderc_spvc::CompileOptions options(source_env, target_env); for (int i = 1; i < argc; ++i) { const string_piece arg = argv[i]; - if (arg == "--help") { + if (arg == "--help" || arg == "-h") { ::PrintHelp(&std::cout); return 0; } else if (arg == "-v") { @@ -237,11 +238,11 @@ int main(int argc, char** argv) { } } else if (arg == "--remove-unused-variables") { options.SetRemoveUnusedVariables(true); - } else if (arg == "--no-validate"){ + } else if (arg == "--no-validate") { options.SetValidate(false); - } else if (arg == "--no-optimize"){ + } else if (arg == "--no-optimize") { options.SetOptimize(false); - } else if (arg == "--robust-buffer-access-pass"){ + } else if (arg == "--robust-buffer-access-pass") { options.SetRobustBufferAccessPass(true); } else if (arg == "--vulkan-semantics") { options.SetVulkanSemantics(true); diff --git a/spvc/test/CMakeLists.txt b/spvc/test/CMakeLists.txt index 0116897..0bb039c 100644 --- a/spvc/test/CMakeLists.txt +++ b/spvc/test/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The Shaderc Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + if(${SHADERC_ENABLE_TESTS}) add_test(NAME spvc_spirv_cross_tests COMMAND ${PYTHON_EXECUTABLE} diff --git a/spvc/test/known_failures b/spvc/test/known_failures index 227a3cf..7ce027b 100644 --- a/spvc/test/known_failures +++ b/spvc/test/known_failures @@ -1,5 +1,6 @@ shaders-hlsl-no-opt/asm/frag/phi.zero-initialize.asm.frag,False shaders-hlsl-no-opt/asm/temporary.zero-initialize.asm.frag,False +shaders-hlsl-no-opt/frag/native-16bit-types.fxconly.nofxc.sm62.native-16bit.frag,False shaders-hlsl-no-opt/frag/variables.zero-initialize.frag,False shaders-hlsl/comp/access-chains.force-uav.comp,False shaders-hlsl/comp/access-chains.force-uav.comp,True @@ -9,18 +10,24 @@ shaders-hlsl/comp/num-workgroups-alone.comp,False shaders-hlsl/comp/num-workgroups-alone.comp,True shaders-hlsl/comp/num-workgroups-with-builtins.comp,False shaders-hlsl/comp/num-workgroups-with-builtins.comp,True +shaders-hlsl/frag/combined-texture-sampler-shadow.frag,False shaders-hlsl/frag/image-query-uav.nonwritable-uav-texture.frag,False shaders-hlsl/frag/readonly-coherent-ssbo.force-uav.frag,False shaders-hlsl/frag/readonly-coherent-ssbo.force-uav.frag,True shaders-hlsl/frag/separate-combined-fake-overload.sm30.frag,False shaders-hlsl/frag/separate-combined-fake-overload.sm30.frag,True +shaders-hlsl/vert/read-from-row-major-array.vert,False +shaders-hlsl/vert/read-from-row-major-array.vert,True shaders-msl-no-opt/asm/comp/copy-logical-2.spv14.asm.comp,False shaders-msl-no-opt/asm/comp/copy-logical.spv14.asm.comp,False +shaders-msl-no-opt/asm/comp/device-array-load-temporary.force-native-array.asm.comp,False +shaders-msl-no-opt/asm/comp/device-constant-array-load-store.force-native-array.asm.comp,False shaders-msl-no-opt/asm/frag/phi.zero-initialize.asm.frag,False shaders-msl-no-opt/asm/temporary.zero-initialize.asm.frag,False shaders-msl-no-opt/comp/basic.dynamic-buffer.msl2.invalid.comp,False shaders-msl-no-opt/comp/int64.invalid.msl22.comp,False shaders-msl-no-opt/frag/force-active-resources.msl2.argument..force-active.discrete.frag,False +shaders-msl-no-opt/frag/subpass-input-attachment-index-fallback.msl20.ios.framebuffer-fetch.frag,False shaders-msl-no-opt/frag/subpass-input-function-argument.framebuffer-fetch.ios.frag,False shaders-msl-no-opt/frag/variables.zero-initialize.frag,False shaders-msl-no-opt/vert/pass-array-by-value.force-native-array.vert,False @@ -49,21 +56,32 @@ shaders-msl/frag/barycentric-nv.msl22.frag,False shaders-msl/frag/barycentric-nv.msl22.frag,True shaders-msl/frag/buffer-read-write.texture-buffer-native.msl21.frag,False shaders-msl/frag/buffer-read-write.texture-buffer-native.msl21.frag,True +shaders-msl/frag/constant-array.frag,False +shaders-msl/frag/constant-array.frag,True shaders-msl/frag/disable-frag-output.frag-output.frag,False shaders-msl/frag/disable-frag-output.frag-output.frag,True shaders-msl/frag/huge-argument-buffer.device-argument-buffer.argument.msl2.frag,False shaders-msl/frag/huge-argument-buffer.device-argument-buffer.argument.msl2.frag,True shaders-msl/frag/image-query-lod.msl22.frag,False shaders-msl/frag/image-query-lod.msl22.frag,True +shaders-msl/frag/separate-image-sampler-argument.frag,False shaders-msl/frag/subgroup-builtins.msl22.frag,False shaders-msl/frag/subgroup-builtins.msl22.frag,True shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag,False shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag,True +shaders-msl/frag/vecsize-mismatch.shader-inputs.frag,False +shaders-msl/frag/vecsize-mismatch.shader-inputs.frag,True +shaders-msl/tese/water_tess.tese,False +shaders-msl/tese/water_tess.tese,True shaders-msl/vert/clip-distance-block.no-user-varying.vert,False shaders-msl/vert/clip-distance-block.no-user-varying.vert,True shaders-msl/vert/float-math.invariant-float-math.vert,False shaders-msl/vert/float-math.invariant-float-math.vert,True +shaders-msl/vert/read-from-row-major-array.vert,False +shaders-msl/vert/read-from-row-major-array.vert,True shaders-msl/vert/return-array.force-native-array.vert,False +shaders-msl/vert/signedness-mismatch.shader-inputs.vert,False +shaders-msl/vert/signedness-mismatch.shader-inputs.vert,True shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert,False shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert,True shaders-no-opt/asm/comp/copy-logical.spv14.asm.comp,False @@ -106,3 +124,15 @@ shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag,True shaders/asm/frag/image-query-no-sampler.no-samplerless.vk.asm.frag,False shaders/desktop-only/frag/image-size.no-qualifier-deduction.frag,False shaders/desktop-only/frag/image-size.no-qualifier-deduction.frag,True +shaders/frag/constant-array.frag,False +shaders/frag/constant-array.frag,True +shaders/tese/water_tess.tese,False +shaders/tese/water_tess.tese,True +shaders/vert/read-from-row-major-array.vert,False +shaders/vert/read-from-row-major-array.vert,True +shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag,False +shaders/vulkan/frag/combined-texture-sampler.vk.frag,False +shaders/vulkan/frag/separate-sampler-texture-array.vk.frag,False +shaders/vulkan/frag/separate-sampler-texture-array.vk.frag,True +shaders/vulkan/frag/separate-sampler-texture.vk.frag,False +shaders/vulkan/frag/separate-sampler-texture.vk.frag,True diff --git a/spvc/test/known_invalids b/spvc/test/known_invalids index 81fc005..c3a3a12 100644 --- a/spvc/test/known_invalids +++ b/spvc/test/known_invalids @@ -1,2 +1,5 @@ +shaders-msl-no-opt/asm/comp/composite-construct-buffer-struct.asm.comp,False +shaders-msl-no-opt/asm/comp/device-array-load-temporary.asm.comp,False +shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp,False shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-inverted.asm.invalid.frag,False -shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-non-inverted.asm.invalid.frag,False +shaders-no-opt/asm/frag/for-loop-dedicated-merge-block-non-inverted.asm.invalid.frag,False
\ No newline at end of file diff --git a/spvc/test/known_spvc_failures b/spvc/test/known_spvc_failures index 0377e3b..db3c83b 100644 --- a/spvc/test/known_spvc_failures +++ b/spvc/test/known_spvc_failures @@ -3,6 +3,7 @@ shaders-hlsl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag,Fals shaders-hlsl-no-opt/asm/temporary.zero-initialize.asm.frag,False shaders-hlsl-no-opt/frag/constant-buffer-array.invalid.sm51.frag,False shaders-hlsl-no-opt/frag/fp16.invalid.desktop.frag,False +shaders-hlsl-no-opt/frag/native-16bit-types.fxconly.nofxc.sm62.native-16bit.frag,False shaders-hlsl-no-opt/frag/variables.zero-initialize.frag,False shaders-hlsl/asm/comp/control-flow-hints.asm.comp,False shaders-hlsl/asm/comp/control-flow-hints.asm.comp,True @@ -14,13 +15,21 @@ shaders-hlsl/comp/num-workgroups-alone.comp,False shaders-hlsl/comp/num-workgroups-alone.comp,True shaders-hlsl/comp/num-workgroups-with-builtins.comp,False shaders-hlsl/comp/num-workgroups-with-builtins.comp,True +shaders-hlsl/frag/combined-texture-sampler-shadow.frag,False shaders-hlsl/frag/image-query-uav.nonwritable-uav-texture.frag,False shaders-hlsl/frag/readonly-coherent-ssbo.force-uav.frag,False shaders-hlsl/frag/readonly-coherent-ssbo.force-uav.frag,True shaders-hlsl/frag/separate-combined-fake-overload.sm30.frag,False shaders-hlsl/frag/separate-combined-fake-overload.sm30.frag,True +shaders-hlsl/vert/read-from-row-major-array.vert,False +shaders-hlsl/vert/read-from-row-major-array.vert,True +shaders-msl-no-opt/asm/comp/composite-construct-buffer-struct.asm.comp,False shaders-msl-no-opt/asm/comp/copy-logical-2.spv14.asm.comp,False shaders-msl-no-opt/asm/comp/copy-logical.spv14.asm.comp,False +shaders-msl-no-opt/asm/comp/device-array-load-temporary.asm.comp,False +shaders-msl-no-opt/asm/comp/device-array-load-temporary.force-native-array.asm.comp,False +shaders-msl-no-opt/asm/comp/device-constant-array-load-store.asm.comp,False +shaders-msl-no-opt/asm/comp/device-constant-array-load-store.force-native-array.asm.comp,False shaders-msl-no-opt/asm/frag/phi.zero-initialize.asm.frag,False shaders-msl-no-opt/asm/frag/switch-block-case-fallthrough.asm.invalid.frag,False shaders-msl-no-opt/asm/packing/load-packed-no-forwarding-3.asm.comp,False @@ -42,6 +51,7 @@ shaders-msl-no-opt/frag/force-active-resources.msl2.argument..force-active.discr shaders-msl-no-opt/frag/fp16.desktop.invalid.frag,False shaders-msl-no-opt/frag/min-max-clamp.invalid.asm.frag,False shaders-msl-no-opt/frag/shadow-compare-global-alias.invalid.frag,False +shaders-msl-no-opt/frag/subpass-input-attachment-index-fallback.msl20.ios.framebuffer-fetch.frag,False shaders-msl-no-opt/frag/subpass-input-function-argument.framebuffer-fetch.ios.frag,False shaders-msl-no-opt/frag/variables.zero-initialize.frag,False shaders-msl-no-opt/packing/array-of-vec3.comp,False @@ -80,21 +90,32 @@ shaders-msl/frag/barycentric-nv.msl22.frag,False shaders-msl/frag/barycentric-nv.msl22.frag,True shaders-msl/frag/buffer-read-write.texture-buffer-native.msl21.frag,False shaders-msl/frag/buffer-read-write.texture-buffer-native.msl21.frag,True +shaders-msl/frag/constant-array.frag,False +shaders-msl/frag/constant-array.frag,True shaders-msl/frag/disable-frag-output.frag-output.frag,False shaders-msl/frag/disable-frag-output.frag-output.frag,True shaders-msl/frag/huge-argument-buffer.device-argument-buffer.argument.msl2.frag,False shaders-msl/frag/huge-argument-buffer.device-argument-buffer.argument.msl2.frag,True shaders-msl/frag/image-query-lod.msl22.frag,False shaders-msl/frag/image-query-lod.msl22.frag,True +shaders-msl/frag/separate-image-sampler-argument.frag,False shaders-msl/frag/subgroup-builtins.msl22.frag,False shaders-msl/frag/subgroup-builtins.msl22.frag,True shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag,False shaders-msl/frag/texture-cube-array.ios.emulate-cube-array.frag,True +shaders-msl/frag/vecsize-mismatch.shader-inputs.frag,False +shaders-msl/frag/vecsize-mismatch.shader-inputs.frag,True +shaders-msl/tese/water_tess.tese,False +shaders-msl/tese/water_tess.tese,True shaders-msl/vert/clip-distance-block.no-user-varying.vert,False shaders-msl/vert/clip-distance-block.no-user-varying.vert,True shaders-msl/vert/float-math.invariant-float-math.vert,False shaders-msl/vert/float-math.invariant-float-math.vert,True +shaders-msl/vert/read-from-row-major-array.vert,False +shaders-msl/vert/read-from-row-major-array.vert,True shaders-msl/vert/return-array.force-native-array.vert,False +shaders-msl/vert/signedness-mismatch.shader-inputs.vert,False +shaders-msl/vert/signedness-mismatch.shader-inputs.vert,True shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert,False shaders-msl/vert/texture_buffer.texture-buffer-native.msl21.vert,True shaders-no-opt/asm/comp/copy-logical.spv14.asm.comp,False @@ -149,3 +170,15 @@ shaders/asm/frag/image-fetch-no-sampler.no-samplerless.asm.vk.frag,True shaders/asm/frag/image-query-no-sampler.no-samplerless.vk.asm.frag,False shaders/desktop-only/frag/image-size.no-qualifier-deduction.frag,False shaders/desktop-only/frag/image-size.no-qualifier-deduction.frag,True +shaders/frag/constant-array.frag,False +shaders/frag/constant-array.frag,True +shaders/tese/water_tess.tese,False +shaders/tese/water_tess.tese,True +shaders/vert/read-from-row-major-array.vert,False +shaders/vert/read-from-row-major-array.vert,True +shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag,False +shaders/vulkan/frag/combined-texture-sampler.vk.frag,False +shaders/vulkan/frag/separate-sampler-texture-array.vk.frag,False +shaders/vulkan/frag/separate-sampler-texture-array.vk.frag,True +shaders/vulkan/frag/separate-sampler-texture.vk.frag,False +shaders/vulkan/frag/separate-sampler-texture.vk.frag,True diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 87c11cb..b2293b3 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -17,6 +17,8 @@ set(SHADERC_EFFCEE_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/effcee" CACHE STRING "Location of effcee source") set(SHADERC_RE2_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/re2" CACHE STRING "Location of re2 source") +set(SHADERC_TINT_DIR "${SHADERC_THIRD_PARTY_ROOT_DIR}/tint" CACHE STRING + "Location of tint source") set( SKIP_GLSLANG_INSTALL ${SHADERC_SKIP_INSTALL} ) set( SKIP_SPIRV_TOOLS_INSTALL ${SHADERC_SKIP_INSTALL} ) @@ -33,6 +35,7 @@ if(${SHADERC_ENABLE_TESTS}) endif() set(OLD_PLATFORM_TOOLSET ${CMAKE_GENERATOR_TOOLSET}) +check_cxx_compiler_flag(-fPIC COMPILER_SUPPORTS_PIC) if (IS_DIRECTORY ${SHADERC_SPIRV_HEADERS_DIR}) @@ -82,7 +85,6 @@ if (SHADERC_ENABLE_SPVC) if (NOT TARGET spirv-cross-core) if (IS_DIRECTORY ${SHADERC_SPIRV_CROSS_DIR}) # Add -fPIC to SPIRV-Cross build, if supported - check_cxx_compiler_flag(-fPIC COMPILER_SUPPORTS_PIC) if (COMPILER_SUPPORTS_PIC) set(CXX_BACK ${CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fPIC") @@ -99,3 +101,23 @@ if (SHADERC_ENABLE_SPVC) endif() endif() endif (SHADERC_ENABLE_SPVC) + +if (SHADERC_ENABLE_WGSL_OUTPUT) + # Use Google Tint for WGSL output. + if (NOT TARGET libtint) + if (IS_DIRECTORY ${SHADERC_TINT_DIR}) + if (NOT IS_DIRECTORY ${SHADERC_TINT_DIR}/out/docs) + # The Tint Doxygen configuration assumes it can write to the out/docs + # source directory. + message(STATUS "Tint source directory out/docs does not exist. Disabling doc generation") + set(TINT_BUILD_DOCS OFF) + endif() + set(TINT_BUILD_SPV_READER ON CACHE BOOL "Built Tint SPIR-V reader" FORCE) + set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build Tint WGSL writer" FORCE) + add_subdirectory(${SHADERC_TINT_DIR} tint) + endif() + endif() + if (NOT TARGET libtint) + message(FATAL_ERROR "Tint was not found - required for WGSL output") + endif() +endif (SHADERC_ENABLE_WGSL_OUTPUT) diff --git a/utils/roll-deps b/utils/roll-deps index 410a6fc..fa05c62 100755 --- a/utils/roll-deps +++ b/utils/roll-deps @@ -14,22 +14,43 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Attempts to roll all entries in DEPS to origin/master and creates a -# commit. +# Attempts to roll all entries in DEPS to tip-of-tree and create a commit. # # Depends on roll-dep from depot_path being in PATH. -# This script assumes it's parent directory is the repo root. -repo_path=$(dirname "$0")/.. - effcee_dir="third_party/effcee/" +effcee_trunk="origin/main" glslang_dir="third_party/glslang/" +glslang_trunk="origin/master" googletest_dir="third_party/googletest/" +googletest_trunk="origin/master" re2_dir="third_party/re2/" +re2_trunk="origin/master" spirv_cross_dir="third_party/spirv-cross/" +spirv_cross_trunk="origin/master" spirv_headers_dir="third_party/spirv-headers/" +spirv_headers_trunk="origin/master" spirv_tools_dir="third_party/spirv-tools/" +spirv_tools_trunk="origin/master" + +# This script assumes it's parent directory is the repo root. +repo_path=$(dirname "$0")/.. cd "$repo_path" -roll-dep "$@" "${effcee_dir}" "${glslang_dir}" "${googletest_dir}" "${re2_dir}" "${spirv_cross_dir}" "${spirv_headers_dir}" "${spirv_tools_dir}" +if [[ $(git diff --stat) != '' ]]; then + echo "Working tree is dirty, commit changes before attempting to roll DEPS" + exit 1 +fi + +old_head=$(git rev-parse HEAD) + +roll-dep --ignore-dirty-tree --roll-to="${effcee_trunk}" "${effcee_dir}" +roll-dep --ignore-dirty-tree --roll-to="${glslang_trunk}" "${glslang_dir}" +roll-dep --ignore-dirty-tree --roll-to="${googletest_trunk}" "${googletest_dir}" +roll-dep --ignore-dirty-tree --roll-to="${re2_trunk}" "${re2_dir}" +roll-dep --ignore-dirty-tree --roll-to="${spirv_cross_trunk}" "${spirv_cross_dir}" +roll-dep --ignore-dirty-tree --roll-to="${spirv_headers_trunk}" "${spirv_headers_dir}" +roll-dep --ignore-dirty-tree --roll-to="${spirv_tools_trunk}" "${spirv_tools_dir}" + +git rebase --interactive "${old_head}" |