Skip to content
Commits on Source (218)
......@@ -42,7 +42,7 @@ install:
- set NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip"
- appveyor DownloadFile %NINJA_URL% -FileName ninja.zip
- 7z x ninja.zip -oC:\ninja > nul
- set PATH=C:\ninja;%PATH%
- set PATH=C:\ninja;C:\Python36;%PATH%
before_build:
- git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers.git external/spirv-headers
......@@ -59,11 +59,11 @@ build:
build_script:
- mkdir build && cd build
- cmake -GNinja -DSPIRV_BUILD_COMPRESSION=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=install -DRE2_BUILD_TESTING=OFF ..
- cmake -GNinja -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCMAKE_INSTALL_PREFIX=install -DRE2_BUILD_TESTING=OFF ..
- ninja install
test_script:
- ctest -C %CONFIGURATION% --output-on-failure --timeout 300
- ctest -C %CONFIGURATION% --output-on-failure --timeout 310
after_test:
# Zip build artifacts for uploading and deploying
......
......@@ -9,6 +9,7 @@ compile_commands.json
/external/spirv-headers
/external/effcee
/external/re2
/external/protobuf
/out
/TAGS
/third_party/llvm-build/
......@@ -21,5 +22,5 @@ compile_commands.json
*~
# C-Lion
.idea
cmake-build-debug
\ No newline at end of file
/.idea/
/cmake-build-*/
......@@ -13,7 +13,6 @@ SPVTOOLS_SRC_FILES := \
source/ext_inst.cpp \
source/enum_string_mapping.cpp \
source/extensions.cpp \
source/id_descriptor.cpp \
source/libspirv.cpp \
source/name_mapper.cpp \
source/opcode.cpp \
......@@ -63,6 +62,7 @@ SPVTOOLS_SRC_FILES := \
source/val/validate_instruction.cpp \
source/val/validate_memory.cpp \
source/val/validate_memory_semantics.cpp \
source/val/validate_misc.cpp \
source/val/validate_mode_setting.cpp \
source/val/validate_layout.cpp \
source/val/validate_literals.cpp \
......@@ -70,6 +70,7 @@ SPVTOOLS_SRC_FILES := \
source/val/validate_non_uniform.cpp \
source/val/validate_primitives.cpp \
source/val/validate_scopes.cpp \
source/val/validate_small_type_uses.cpp \
source/val/validate_type.cpp
SPVTOOLS_OPT_SRC_FILES := \
......@@ -83,7 +84,6 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/ccp_pass.cpp \
source/opt/code_sink.cpp \
source/opt/combine_access_chains.cpp \
source/opt/common_uniform_elim_pass.cpp \
source/opt/compact_ids_pass.cpp \
source/opt/composite.cpp \
source/opt/const_folding_rules.cpp \
......@@ -92,8 +92,10 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/dead_branch_elim_pass.cpp \
source/opt/dead_insert_elim_pass.cpp \
source/opt/dead_variable_elimination.cpp \
source/opt/decompose_initialized_variables_pass.cpp \
source/opt/decoration_manager.cpp \
source/opt/def_use_manager.cpp \
source/opt/desc_sroa.cpp \
source/opt/dominator_analysis.cpp \
source/opt/dominator_tree.cpp \
source/opt/eliminate_dead_constant_pass.cpp \
......@@ -101,12 +103,15 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/eliminate_dead_functions_util.cpp \
source/opt/eliminate_dead_members_pass.cpp \
source/opt/feature_manager.cpp \
source/opt/fix_storage_class.cpp \
source/opt/flatten_decoration_pass.cpp \
source/opt/fold.cpp \
source/opt/folding_rules.cpp \
source/opt/fold_spec_constant_op_and_composite_pass.cpp \
source/opt/freeze_spec_constant_value_pass.cpp \
source/opt/function.cpp \
source/opt/generate_webgpu_initializers_pass.cpp \
source/opt/graphics_robust_access_pass.cpp \
source/opt/if_conversion.cpp \
source/opt/inline_pass.cpp \
source/opt/inline_exhaustive_pass.cpp \
......@@ -117,6 +122,7 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/instrument_pass.cpp \
source/opt/ir_context.cpp \
source/opt/ir_loader.cpp \
source/opt/legalize_vector_shuffle_pass.cpp \
source/opt/licm_pass.cpp \
source/opt/local_access_chain_convert_pass.cpp \
source/opt/local_redundancy_elimination.cpp \
......@@ -152,8 +158,10 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/scalar_replacement_pass.cpp \
source/opt/set_spec_constant_default_value_pass.cpp \
source/opt/simplification_pass.cpp \
source/opt/split_invalid_unreachable_pass.cpp \
source/opt/ssa_rewrite_pass.cpp \
source/opt/strength_reduction_pass.cpp \
source/opt/strip_atomic_counter_memory_pass.cpp \
source/opt/strip_debug_info_pass.cpp \
source/opt/strip_reflect_info_pass.cpp \
source/opt/struct_cfg_analysis.cpp \
......
......@@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build_overrides/build.gni")
import("//build_overrides/spirv_tools.gni")
if (build_with_chromium) {
import("//testing/test.gni")
import("//build_overrides/build.gni")
}
spirv_headers = spirv_tools_spirv_headers_dir
......@@ -293,11 +294,11 @@ config("spvtools_internal_config") {
source_set("spvtools_headers") {
sources = [
"include/spirv-tools/instrument.hpp",
"include/spirv-tools/libspirv.h",
"include/spirv-tools/libspirv.hpp",
"include/spirv-tools/linker.hpp",
"include/spirv-tools/optimizer.hpp",
"include/spirv-tools/instrument.hpp",
]
public_configs = [ ":spvtools_public_config" ]
......@@ -379,11 +380,11 @@ static_library("spvtools") {
":spvtools_headers",
]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":spvtools_internal_config",
]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
configs += [ ":spvtools_internal_config" ]
}
static_library("spvtools_val") {
......@@ -422,10 +423,12 @@ static_library("spvtools_val") {
"source/val/validate_logicals.cpp",
"source/val/validate_memory.cpp",
"source/val/validate_memory_semantics.cpp",
"source/val/validate_misc.cpp",
"source/val/validate_mode_setting.cpp",
"source/val/validate_non_uniform.cpp",
"source/val/validate_primitives.cpp",
"source/val/validate_scopes.cpp",
"source/val/validate_small_type_uses.cpp",
"source/val/validate_type.cpp",
"source/val/validation_state.cpp",
]
......@@ -437,11 +440,11 @@ static_library("spvtools_val") {
":spvtools_headers",
]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":spvtools_internal_config",
]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
configs += [ ":spvtools_internal_config" ]
}
static_library("spvtools_opt") {
......@@ -466,8 +469,6 @@ static_library("spvtools_opt") {
"source/opt/code_sink.h",
"source/opt/combine_access_chains.cpp",
"source/opt/combine_access_chains.h",
"source/opt/common_uniform_elim_pass.cpp",
"source/opt/common_uniform_elim_pass.h",
"source/opt/compact_ids_pass.cpp",
"source/opt/compact_ids_pass.h",
"source/opt/composite.cpp",
......@@ -484,10 +485,14 @@ static_library("spvtools_opt") {
"source/opt/dead_insert_elim_pass.h",
"source/opt/dead_variable_elimination.cpp",
"source/opt/dead_variable_elimination.h",
"source/opt/decompose_initialized_variables_pass.cpp",
"source/opt/decompose_initialized_variables_pass.h",
"source/opt/decoration_manager.cpp",
"source/opt/decoration_manager.h",
"source/opt/def_use_manager.cpp",
"source/opt/def_use_manager.h",
"source/opt/desc_sroa.cpp",
"source/opt/desc_sroa.h",
"source/opt/dominator_analysis.cpp",
"source/opt/dominator_analysis.h",
"source/opt/dominator_tree.cpp",
......@@ -502,6 +507,8 @@ static_library("spvtools_opt") {
"source/opt/eliminate_dead_members_pass.h",
"source/opt/feature_manager.cpp",
"source/opt/feature_manager.h",
"source/opt/fix_storage_class.cpp",
"source/opt/fix_storage_class.h",
"source/opt/flatten_decoration_pass.cpp",
"source/opt/flatten_decoration_pass.h",
"source/opt/fold.cpp",
......@@ -514,6 +521,10 @@ static_library("spvtools_opt") {
"source/opt/freeze_spec_constant_value_pass.h",
"source/opt/function.cpp",
"source/opt/function.h",
"source/opt/generate_webgpu_initializers_pass.cpp",
"source/opt/generate_webgpu_initializers_pass.h",
"source/opt/graphics_robust_access_pass.cpp",
"source/opt/graphics_robust_access_pass.h",
"source/opt/if_conversion.cpp",
"source/opt/if_conversion.h",
"source/opt/inline_exhaustive_pass.cpp",
......@@ -536,6 +547,8 @@ static_library("spvtools_opt") {
"source/opt/ir_loader.cpp",
"source/opt/ir_loader.h",
"source/opt/iterator.h",
"source/opt/legalize_vector_shuffle_pass.cpp",
"source/opt/legalize_vector_shuffle_pass.h",
"source/opt/licm_pass.cpp",
"source/opt/licm_pass.h",
"source/opt/local_access_chain_convert_pass.cpp",
......@@ -608,10 +621,14 @@ static_library("spvtools_opt") {
"source/opt/set_spec_constant_default_value_pass.h",
"source/opt/simplification_pass.cpp",
"source/opt/simplification_pass.h",
"source/opt/split_invalid_unreachable_pass.cpp",
"source/opt/split_invalid_unreachable_pass.h",
"source/opt/ssa_rewrite_pass.cpp",
"source/opt/ssa_rewrite_pass.h",
"source/opt/strength_reduction_pass.cpp",
"source/opt/strength_reduction_pass.h",
"source/opt/strip_atomic_counter_memory_pass.cpp",
"source/opt/strip_atomic_counter_memory_pass.h",
"source/opt/strip_debug_info_pass.cpp",
"source/opt/strip_debug_info_pass.h",
"source/opt/strip_reflect_info_pass.cpp",
......@@ -642,17 +659,109 @@ static_library("spvtools_opt") {
":spvtools_headers",
]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
":spvtools_internal_config",
configs += [ "//build/config/compiler:no_chromium_code" ]
}
configs += [ ":spvtools_internal_config" ]
}
static_library("spvtools_link") {
sources = [
"source/link/linker.cpp",
]
deps = [
":spvtools",
":spvtools_opt",
":spvtools_val",
]
public_deps = [
":spvtools_headers",
]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
configs += [ ":spvtools_internal_config" ]
}
static_library("spvtools_reduce") {
sources = [
"source/reduce/change_operand_reduction_opportunity.cpp",
"source/reduce/change_operand_reduction_opportunity.h",
"source/reduce/change_operand_to_undef_reduction_opportunity.cpp",
"source/reduce/change_operand_to_undef_reduction_opportunity.h",
"source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.cpp",
"source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.h",
"source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.cpp",
"source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.h",
"source/reduce/merge_blocks_reduction_opportunity.cpp",
"source/reduce/merge_blocks_reduction_opportunity.h",
"source/reduce/merge_blocks_reduction_opportunity_finder.cpp",
"source/reduce/merge_blocks_reduction_opportunity_finder.h",
"source/reduce/operand_to_const_reduction_opportunity_finder.cpp",
"source/reduce/operand_to_const_reduction_opportunity_finder.h",
"source/reduce/operand_to_dominating_id_reduction_opportunity_finder.cpp",
"source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h",
"source/reduce/operand_to_undef_reduction_opportunity_finder.cpp",
"source/reduce/operand_to_undef_reduction_opportunity_finder.h",
"source/reduce/reducer.cpp",
"source/reduce/reducer.h",
"source/reduce/reduction_opportunity.cpp",
"source/reduce/reduction_opportunity.h",
"source/reduce/reduction_pass.cpp",
"source/reduce/reduction_pass.h",
"source/reduce/reduction_util.cpp",
"source/reduce/reduction_util.h",
"source/reduce/remove_block_reduction_opportunity.cpp",
"source/reduce/remove_block_reduction_opportunity.h",
"source/reduce/remove_block_reduction_opportunity_finder.cpp",
"source/reduce/remove_block_reduction_opportunity_finder.h",
"source/reduce/remove_function_reduction_opportunity.cpp",
"source/reduce/remove_function_reduction_opportunity.h",
"source/reduce/remove_function_reduction_opportunity_finder.cpp",
"source/reduce/remove_function_reduction_opportunity_finder.h",
"source/reduce/remove_instruction_reduction_opportunity.cpp",
"source/reduce/remove_instruction_reduction_opportunity.h",
"source/reduce/remove_opname_instruction_reduction_opportunity_finder.cpp",
"source/reduce/remove_opname_instruction_reduction_opportunity_finder.h",
"source/reduce/remove_selection_reduction_opportunity.cpp",
"source/reduce/remove_selection_reduction_opportunity.h",
"source/reduce/remove_selection_reduction_opportunity_finder.cpp",
"source/reduce/remove_selection_reduction_opportunity_finder.h",
"source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.cpp",
"source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h",
"source/reduce/simple_conditional_branch_to_branch_opportunity_finder.cpp",
"source/reduce/simple_conditional_branch_to_branch_opportunity_finder.h",
"source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.cpp",
"source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.h",
"source/reduce/structured_loop_to_selection_reduction_opportunity.cpp",
"source/reduce/structured_loop_to_selection_reduction_opportunity.h",
"source/reduce/structured_loop_to_selection_reduction_opportunity_finder.cpp",
"source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h",
"source/spirv_reducer_options.cpp",
"source/spirv_reducer_options.h",
]
deps = [
":spvtools",
":spvtools_opt",
]
public_deps = [
":spvtools_headers",
]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
configs += [ ":spvtools_internal_config" ]
}
group("SPIRV-Tools") {
deps = [
":spvtools",
":spvtools_link",
":spvtools_opt",
":spvtools_reduce",
":spvtools_val",
]
}
......@@ -722,12 +831,12 @@ if (build_with_chromium) {
]
deps = [
"//testing/gmock",
"//testing/gtest",
"//testing/gtest:gtest_main",
":spvtools",
":spvtools_language_header_unified1",
":spvtools_val",
"//testing/gmock",
"//testing/gtest",
"//testing/gtest:gtest_main",
]
if (is_clang) {
......@@ -747,14 +856,129 @@ if (spirv_tools_standalone) {
}
}
executable("spirv-as") {
source_set("spvtools_util_cli_consumer") {
sources = [
"tools/util/cli_consumer.cpp",
"tools/util/cli_consumer.h",
]
configs += [ ":spvtools_internal_config" ]
}
source_set("spvtools_software_version") {
sources = [
"source/software_version.cpp",
]
deps = [
":spvtools_build_version",
":spvtools_headers",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-as") {
sources = [
"tools/as/as.cpp",
]
deps = [
":spvtools",
":spvtools_build_version",
":spvtools_software_version",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-dis") {
sources = [
"tools/dis/dis.cpp",
]
deps = [
":spvtools",
":spvtools_software_version",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-val") {
sources = [
"tools/val/val.cpp",
]
deps = [
":spvtools",
":spvtools_software_version",
":spvtools_util_cli_consumer",
":spvtools_val",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-cfg") {
sources = [
"tools/cfg/bin_to_dot.cpp",
"tools/cfg/bin_to_dot.h",
"tools/cfg/cfg.cpp",
]
deps = [
":spvtools",
":spvtools_software_version",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-opt") {
sources = [
"tools/opt/opt.cpp",
]
deps = [
":spvtools",
":spvtools_opt",
":spvtools_software_version",
":spvtools_util_cli_consumer",
":spvtools_val",
]
configs += [ ":spvtools_internal_config" ]
}
executable("spirv-link") {
sources = [
"tools/link/linker.cpp",
]
deps = [
":spvtools",
":spvtools_link",
":spvtools_opt",
":spvtools_software_version",
":spvtools_val",
]
configs += [ ":spvtools_internal_config" ]
}
if (!is_ios) {
# iOS does not allow std::system calls which spirv-reduce requires
executable("spirv-reduce") {
sources = [
"tools/reduce/reduce.cpp",
]
deps = [
":spvtools",
":spvtools_opt",
":spvtools_reduce",
":spvtools_software_version",
":spvtools_util_cli_consumer",
":spvtools_val",
]
configs += [ ":spvtools_internal_config" ]
}
}
group("all_spirv_tools") {
deps = [
":spirv-as",
":spirv-cfg",
":spirv-dis",
":spirv-link",
":spirv-opt",
":spirv-val",
]
if (!is_ios) {
deps += [ ":spirv-reduce" ]
}
}
Revision history for SPIRV-Tools
v2019.4 2019-08-08
- General:
- Memory model support for SPIR-V 1.4
- Add new spirv-fuzz tool
- Add option for base branch in check_code_format.sh
- Removed MarkV and Stats code. (#2576)
- Instrument: Add version 2 of record formats (#2630)
- Linker: Better type comparison for OpTypeArray and OpTypeForwardPointer (#2580)
- Optimizer
- Bindless Validation: Instrument descriptor-based loads and stores (#2583)
- Better folding for OpSpecConstantOp (#2585, #2614)
- Add in individual flags for Vulkan <-> WebGPU passes (#2615)
- Handle nested breaks from switches. (#2624)
- Optimizer: Handle array type with OpSpecConstantOp length (#2652)
- Perform merge return with single return in loop. (#2714)
- Add —preserve-bindings and —preserve-spec-constants (#2693)
- Remove Common Uniform Elimination Pass (#2731)
- Allow ray tracing shaders in inst bindle check pass. (#2733)
- Add pass to inject code for robust-buffer-access semantics (#2771)
- Treat access chain indexes as signed in SROA (#2776)
- Handle RelaxedPrecision in SROA (#2788)
- Add descriptor array scalar replacement (#2742)
Fixes:
- Handle decorations better in some optimizations (#2716)
- Change the order branches are simplified in dead branch elim (#2728)
- Fix bug in merge return (#2734)
- SSA rewriter: Don't use trivial phis (#2757)
- Record correct dominators in merge return (#2760)
- Process OpDecorateId in ADCE (#2761)
- Fix check for unreachable blocks in merge-return (#2762)
- Handle out-of-bounds scalar replacements. (#2767)
- Don't move debug or decorations when folding (#2772)
- Protect against out-of-bounds references when folding OpCompositeExtract (#2774)
- Validator
- Validate loop merge (#2579)
- Validate construct exits (#2459)
- Validate OpenCL memory and addressing model environment rules (#2589)
- Validate OpenCL environment rules for OpTypeImage (#2606)
- Allow breaks to switch merge from nested construct (#2604)
- Validate OpenCL environment rules for OpImageWrite (#2619)
- Allow arrays of out per-primitive builtins for mesh shaders (#2617)
- Validate OpenCL rules for ImageRead and OpImageSampleExplicitLod (#2643)
- Add validation for SPV_EXT_fragment_shader_interlock (#2650)
- Add builtin validation for SPV_NV_shader_sm_builtins (#2656)
- Add validation for Subgroup builtins (#2637)
- Validate variable initializer type (#2668)
- Disallow stores to UBOs (#2651)A
- Validate Volatile memory semantics bit (#2672)
- Basic validation for Component decorations (#2679)
- Validate that in OpenGL env block variables have Binding (#2685)
- Validate usage of 8- and 16-bit types with only storage capabilities (#2704)
- Add validation for SPV_EXT_demote_to_helper_invocation (#2707)
- Extra small storage validation (#2732)
- For Vulkan, disallow structures containing opaque types (#2546)
- Validate storage class OpenCL environment rules for atomics (#2750)
- Update OpControlBarriers rules for WebGPU (#2769)
- Update OpMemoryBarriers rules for WebGPU (#2775)
- Update WebGPU validation rules of OpAtomic*s (#2777)
Fixes:
- Disallow merge targeting block with OpLoopMerge (#2610)
- Update vloadn and vstoren validation to match the OpenCL Extended
Instruction Set Specification (#2599)
- Update memory scope rules for WebGPU (#2725)
- Allow LOD ops in compute shaders with derivative group execution modes (#2752)
- Reduce
Fixes:
v2019.3 2019-05-14
- General:
- Require Python 3 since Python 2 will out of service soon.
- Add a continuous test that does memory checks using the address sanitizer.
- Fix the build files so the SPIRV_USE_SANITIZER=address build works.
- Packaging top of tree build artifacts again.
- Added support for SPIR-V 1.4. (#2550)
- Optimizer
- Remove duplicates from list of interface IDs in OpEntryPoint instruction (#2449)
- Bindless Validation: Descriptor Initialization Check (#2419)
- Add option to validate after each pass (#2462)
- Add legalization pass to fix mismatched pointer (#2430, #2535)
- Add error messages when the input contains unknown instructions. (#2487)
- Add pass to convert from WebGPU Spir-V to Vulkan Spir-V and back. (#2495)
Fixes:
- #2412: Dead memeber elimination should not change input and output variables.
- #2405: Fix OpDot folding of half float vectors.
- #2391: Dead branch elim should not fold away back edges.
- #2441: Removing decorations when doing constant propagation.
- #2455: Maintain inst to block mapping in merge return.
- #2453: Fix merge return in the face of breaks.
- #2456: Handle dead infinite loops in DCE.
- #2458: Handle variable pointer in some optimizations.
- #2452: Fix dead branch elimination to handle unreachable blocks better.
- #2528: Fix undefined bit shift in sroa.
- #2539: Change implementation of post order CFG traversal.
- Validator
- Add validation of storage classes for WebGPU (#2446)
- Add validation for ExecutionMode in WebGPU (#2443)
- Implement WebGPU specific CFG validation (#2386)
- Allow NonWritable to target struct members. (#2420)
- Allow storage type mismatch for parameter in relaxed addressing mode.
- Allow non memory objects as parameter in relaxed addressing mode.
- Disallow nested Blocks and buffer blocks (#2410).
- Add validation for SPV_NV_cooperative_matrix (#2404)
- Add --strip-atomic-counter-memory (#2413)
- Check OpSampledImage is only passed into valid instructions (#2467)
- Handle function decls in Structured CFG analysis (#2474)
- Validate that OpUnreacahble is not statically reachable (#2473)
- Add pass to generate needed initializers for WebGPU (#2481)
- Allow images without format for OpenCL. (#2470)
- Remove unreachable block validation (#2525)
- Reduce runtime of array layout checks (#2534)
- Add validation specific to OpExecutionModeId (#2536)
- Validate sign of int types. (#2549)
- VK_KHR_uniform_buffer_standard_layout validation (#2562)
Fixes:
- #2439: Add missing DepthGreater case to Fragment only check.
- #2168: Disallow BufferBlock on StorageBuffer variables for Vulkan.
- #2408: Restrict and Aliased decorations cannot be applied to the same id.
- #2447: Improve function call parameter check.
- Reduce
- Add Pass to remove unreferenced blocks. (#2398)
- Allows passing options to the validator. (#2401)
- Improve reducer algorithm and other changes (#2472)
- Add Pass to remove selections (#2485)
- Add passes to simplify branches (#2507)
Fixes:
- #2478: fix loop to selection pass for loops with combined header/continue block
v2019.2 2019-02-20
- General:
- Support SPV_EXT_physical_storage_buffer
......
......@@ -69,6 +69,10 @@ if(NOT ${SKIP_SPIRV_TOOLS_INSTALL})
endif()
option(SPIRV_BUILD_COMPRESSION "Build SPIR-V compressing codec" OFF)
if(SPIRV_BUILD_COMPRESSION)
message(FATAL_ERROR "SPIR-V compression codec has been removed from SPIR-V tools. "
"Please remove SPIRV_BUILD_COMPRESSION from your build options.")
endif(SPIRV_BUILD_COMPRESSION)
option(SPIRV_WERROR "Enable error on warning" ON)
if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))
......@@ -140,6 +144,8 @@ function(spvtools_default_compile_options TARGET)
if(NOT "${SPIRV_USE_SANITIZER}" STREQUAL "")
target_compile_options(${TARGET} PRIVATE
-fsanitize=${SPIRV_USE_SANITIZER})
set_target_properties(${TARGET} PROPERTIES
LINK_FLAGS -fsanitize=${SPIRV_USE_SANITIZER})
endif()
target_compile_options(${TARGET} PRIVATE
-ftemplate-depth=1024)
......@@ -176,7 +182,8 @@ if(NOT COMMAND find_host_program)
endmacro()
endif()
find_host_package(PythonInterp)
# Tests require Python3
find_host_package(PythonInterp 3 REQUIRED)
# Check for symbol exports on Linux.
# At the moment, this check will fail on the OSX build machines for the Android NDK.
......@@ -228,6 +235,21 @@ endmacro(spvtools_pch)
add_subdirectory(external)
# Warning about extra semi-colons.
#
# This is not supported on all compilers/versions. so enabling only
# for clang, since that works for all versions that our bots run.
#
# This is intentionally done after adding the external subdirectory,
# so we don't enforce this flag on our dependencies, some of which do
# not pass it.
#
# If the minimum version of CMake supported is updated to 3.0 or
# later, then check_cxx_compiler_flag could be used instead.
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_compile_options("-Wextra-semi")
endif()
add_subdirectory(source)
add_subdirectory(tools)
......@@ -254,9 +276,6 @@ endif()
set(SPIRV_LIBRARIES "-lSPIRV-Tools -lSPIRV-Tools-link -lSPIRV-Tools-opt")
set(SPIRV_SHARED_LIBRARIES "-lSPIRV-Tools-shared")
if(SPIRV_BUILD_COMPRESSION)
set(SPIRV_LIBRARIES "${SPIRV_LIBRARIES} -lSPIRV-Tools-comp")
endif(SPIRV_BUILD_COMPRESSION)
# Build pkg-config file
# Use a first-class target so it's regenerated when relevant files are updated.
......
use_relative_paths = True
vars = {
'chromium_git': 'https://chromium.googlesource.com',
'github': 'https://github.com',
'build_revision': '037f38ae0fe5e11b4f7c33b750fd7a1e9634a606',
'buildtools_revision': 'ab7b6a7b350dd15804c87c20ce78982811fdd76f',
'clang_revision': 'abe5e4f9dc0f1df848c7a0efa05256253e77a7b7',
'effcee_revision': '04b624799f5a9dbaf3fa1dbed2ba9dce2fc8dcf2',
'googletest_revision': '98a0d007d7092b72eea0e501bb9ad17908a1a036',
'testing_revision': '340252637e2e7c72c0901dcbeeacfff419e19b59',
're2_revision': '6cf8ccd82dbaab2668e9b13596c68183c9ecd13f',
'spirv_headers_revision': '79b6681aadcb53c27d1052e5f8a0e82a981dbf2f',
'effcee_revision': 'b83b58d177b797edd1f94c5f10837f2cc2863f0a',
'googletest_revision': '2f42d769ad1b08742f7ccb5ad4dd357fc5ff248c',
're2_revision': 'e356bd3f80e0c15c1050323bb5a2d0f8ea4845f4',
'spirv_headers_revision': '123dc278f204f8e833e1a88d31c46d0edf81d4b2',
}
deps = {
"build":
Var('chromium_git') + "/chromium/src/build.git@" + Var('build_revision'),
'buildtools':
Var('chromium_git') + '/chromium/buildtools.git@' +
Var('buildtools_revision'),
'external/spirv-headers':
Var('github') + '/KhronosGroup/SPIRV-Headers.git@' +
Var('spirv_headers_revision'),
'external/effcee':
Var('github') + '/google/effcee.git@' + Var('effcee_revision'),
'external/googletest':
Var('github') + '/google/googletest.git@' + Var('googletest_revision'),
'external/effcee':
Var('github') + '/google/effcee.git@' + Var('effcee_revision'),
'external/re2':
Var('github') + '/google/re2.git@' + Var('re2_revision'),
'testing':
Var('chromium_git') + '/chromium/src/testing@' +
Var('testing_revision'),
'tools/clang':
Var('chromium_git') + '/chromium/src/tools/clang@' + Var('clang_revision')
'external/spirv-headers':
Var('github') + '/KhronosGroup/SPIRV-Headers.git@' +
Var('spirv_headers_revision'),
}
recursedeps = [
# buildtools provides clang_format, libc++, and libc++api
'buildtools',
]
hooks = [
{
'name': 'gn_win',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=win32',
'--no_auth',
'--bucket', 'chromium-gn',
'-s', 'SPIRV-Tools/buildtools/win/gn.exe.sha1',
],
},
{
'name': 'gn_mac',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--no_auth',
'--bucket', 'chromium-gn',
'-s', 'SPIRV-Tools/buildtools/mac/gn.sha1',
],
},
{
'name': 'gn_linux64',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-gn',
'-s', 'SPIRV-Tools/buildtools/linux64/gn.sha1',
],
},
# Pull clang-format binaries using checked-in hashes.
{
'name': 'clang_format_win',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=win32',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'SPIRV-Tools/buildtools/win/clang-format.exe.sha1',
],
},
{
'name': 'clang_format_mac',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'SPIRV-Tools/buildtools/mac/clang-format.sha1',
],
},
{
'name': 'clang_format_linux',
'pattern': '.',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'SPIRV-Tools/buildtools/linux64/clang-format.sha1',
],
},
{
# Pull clang
'name': 'clang',
'pattern': '.',
'action': ['python',
'SPIRV-Tools/tools/clang/scripts/update.py'
],
},
{
'name': 'sysroot_arm',
'pattern': '.',
'condition': 'checkout_linux and checkout_arm',
'action': ['python', 'SPIRV-Tools/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=arm'],
},
{
'name': 'sysroot_arm64',
'pattern': '.',
'condition': 'checkout_linux and checkout_arm64',
'action': ['python', 'SPIRV-Tools/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=arm64'],
},
{
'name': 'sysroot_x86',
'pattern': '.',
'condition': 'checkout_linux and (checkout_x86 or checkout_x64)',
'action': ['python', 'SPIRV-Tools/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=x86'],
},
{
'name': 'sysroot_mips',
'pattern': '.',
'condition': 'checkout_linux and checkout_mips',
'action': ['python', 'SPIRV-Tools/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=mips'],
},
{
'name': 'sysroot_x64',
'pattern': '.',
'condition': 'checkout_linux and checkout_x64',
'action': ['python', 'SPIRV-Tools/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=x64'],
},
{
# Update the Windows toolchain if necessary.
'name': 'win_toolchain',
'pattern': '.',
'condition': 'checkout_win',
'action': ['python', 'SPIRV-Tools/build/vs_toolchain.py', 'update', '--force'],
},
{
# Update the Mac toolchain if necessary.
'name': 'mac_toolchain',
'pattern': '.',
'action': ['python', 'SPIRV-Tools/build/mac_toolchain.py'],
},
]
# SPIR-V Tools
[![Build status](https://ci.appveyor.com/api/projects/status/gpue87cesrx3pi0d/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/spirv-tools/branch/master)
<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>![Linux Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_linux_release.svg)
<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>![MacOS Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_macos_release.svg)
<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_release.svg)
## Overview
The SPIR-V Tools project provides an API and commands for processing SPIR-V
......@@ -24,6 +19,15 @@ SPIR-V is defined by the Khronos Group Inc.
See the [SPIR-V Registry][spirv-registry] for the SPIR-V specification,
headers, and XML registry.
## Downloads
[![Build status](https://ci.appveyor.com/api/projects/status/gpue87cesrx3pi0d/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/spirv-tools/branch/master)
<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>[![Linux Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_linux_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html)
<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>[![MacOS Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_macos_clang_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html)
<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>[![Windows Build Status](https://storage.googleapis.com/spirv-tools/badges/build_status_windows_release.svg)](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_release.html)
[More downloads](downloads.md)
## Versioning SPIRV-Tools
See [`CHANGES`](CHANGES) for a high level summary of recent changes, by version.
......@@ -47,7 +51,7 @@ version. An API call reports the software version as a C-style string.
* Support for SPIR-V 1.0, 1.1, 1.2, and 1.3
* Based on SPIR-V syntax described by JSON grammar files in the
[SPIRV-Headers](spirv-headers) repository.
[SPIRV-Headers](https://github.com/KhronosGroup/SPIRV-Headers) repository.
* Support for extended instruction sets:
* GLSL std450 version 1.0 Rev 3
* OpenCL version 1.0 Rev 2
......@@ -266,9 +270,38 @@ mkdir build && cd build
cmake [-G <platform-generator>] <spirv-dir>
```
*Note*:
The script `utils/git-sync-deps` can be used to checkout and/or update the
contents of the repos under `external/` instead of manually maintaining them.
Once the build files have been generated, build using your preferred
development environment.
### Tools you'll need
For building and testing SPIRV-Tools, the following tools should be
installed regardless of your OS:
- [CMake](http://www.cmake.org/): for generating compilation targets. Version
2.8.12 or later.
- [Python 3](http://www.python.org/): for utility scripts and running the test
suite.
SPIRV-Tools is regularly tested with the the following compilers:
On Linux
- GCC version 4.8.5
- Clang version 3.8
On MacOS
- AppleClang 10.0
On Windows
- Visual Studio 2015
- Visual Studio 2017
Other compilers or later versions may work, but they are not tested.
### CMake options
The following CMake options are supported:
......@@ -278,8 +311,6 @@ The following CMake options are supported:
the command line tools. This will prevent the tests from being built.
* `SPIRV_SKIP_EXECUTABLES={ON|OFF}`, default `OFF`- Build only the library, not
the command line tools and tests.
* `SPIRV_BUILD_COMPRESSION={ON|OFF}`, default `OFF`- Build SPIR-V compressing
codec.
* `SPIRV_USE_SANITIZER=<sanitizer>`, default is no sanitizing - On UNIX
platforms with an appropriate version of `clang` this option enables the use
of the sanitizers documented [here][clang-sanitizers].
......@@ -317,6 +348,13 @@ $ANDROID_NDK/ndk-build -C ../android_test \
NDK_APP_OUT=`pwd`/app
```
### Updating DEPS
Occasionally the entries in DEPS will need to be updated. This is done on demand
when there is a request to do this, often due to downstream breakages. There is
a script `utils/roll_deps.sh` provided, which will generate a patch with the
updated DEPS values. This will still need to be tested in your checkout to
confirm that there are no integration issues that need to be resolved.
## Library
### Usage
......
# Downloads
Download the latest builds.
## Release
| Windows | Linux | MacOS |
| --- | --- | --- |
| [MSVC 2017](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_release.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_release.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_release.html) |
| | [gcc](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_gcc_release.html) | |
## Debug
| Windows | Linux | MacOS |
| --- | --- | --- |
| [MSVC 2017](https://storage.googleapis.com/spirv-tools/badges/build_link_windows_vs2017_debug.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_clang_debug.html) | [clang](https://storage.googleapis.com/spirv-tools/badges/build_link_macos_clang_debug.html) |
| | [gcc](https://storage.googleapis.com/spirv-tools/badges/build_link_linux_gcc_debug.html) | |
......@@ -28,6 +28,7 @@
int main() {
const std::string source =
" OpCapability Linkage "
" OpCapability Shader "
" OpMemoryModel Logical GLSL450 "
" OpSource GLSL 450 "
......@@ -36,8 +37,8 @@ int main() {
" %spec = OpSpecConstant %int 0 "
"%const = OpConstant %int 42";
spvtools::SpirvTools core(SPV_ENV_VULKAN_1_0);
spvtools::Optimizer opt(SPV_ENV_VULKAN_1_0);
spvtools::SpirvTools core(SPV_ENV_UNIVERSAL_1_3);
spvtools::Optimizer opt(SPV_ENV_UNIVERSAL_1_3);
auto print_msg_to_stderr = [](spv_message_level_t, const char*,
const spv_position_t&, const char* m) {
......
......@@ -102,3 +102,15 @@ if (NOT ${SPIRV_SKIP_TESTS})
endif()
endif()
endif()
if(SPIRV_BUILD_FUZZER)
set(PROTOBUF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake)
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf tests")
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Do not build protobuf static runtime")
if (IS_DIRECTORY ${PROTOBUF_DIR})
add_subdirectory(${PROTOBUF_DIR} EXCLUDE_FROM_ALL)
else()
message(FATAL_ERROR
"protobuf not found - please checkout a copy under external/.")
endif()
endif(SPIRV_BUILD_FUZZER)
......@@ -34,6 +34,11 @@ namespace spvtools {
// generated by InstrumentPass::GenDebugStreamWrite. This method is utilized
// by InstBindlessCheckPass.
//
// kInst2* values support version 2 of the output record format. These should
// be used if available and version 2 is enabled. Version 1 is DEPRECATED.
// Specifically, version 1 uses two words for the stage-specific section of
// the output record; version 2 uses three words.
//
// The first member of the debug output buffer contains the next available word
// in the data stream to be written. Shaders will atomically read and update
// this value so as not to overwrite each others records. This value must be
......@@ -70,38 +75,63 @@ static const int kInstCommonOutCnt = 4;
// Stage-specific Stream Record Offsets
//
// Each stage will contain different values in the next two words of the record
// used to identify which instantiation of the shader generated the validation
// error.
// Each stage will contain different values in the next set of words of the
// record used to identify which instantiation of the shader generated the
// validation error.
//
// Vertex Shader Output Record Offsets
static const int kInstVertOutVertexIndex = kInstCommonOutCnt;
static const int kInstVertOutInstanceIndex = kInstCommonOutCnt + 1;
static const int kInstVertOutUnused = kInstCommonOutCnt + 2;
// Frag Shader Output Record Offsets
static const int kInstFragOutFragCoordX = kInstCommonOutCnt;
static const int kInstFragOutFragCoordY = kInstCommonOutCnt + 1;
static const int kInstFragOutUnused = kInstCommonOutCnt + 2;
// Compute Shader Output Record Offsets
static const int kInstCompOutGlobalInvocationIdX = kInstCommonOutCnt;
static const int kInstCompOutGlobalInvocationIdY = kInstCommonOutCnt + 1;
static const int kInstCompOutGlobalInvocationIdZ = kInstCommonOutCnt + 2;
// Compute Shader Output Record Offsets - Version 1 (DEPRECATED)
static const int kInstCompOutGlobalInvocationId = kInstCommonOutCnt;
static const int kInstCompOutUnused = kInstCommonOutCnt + 1;
// Tessellation Shader Output Record Offsets
// Tessellation Control Shader Output Record Offsets
static const int kInstTessCtlOutInvocationId = kInstCommonOutCnt;
static const int kInstTessCtlOutPrimitiveId = kInstCommonOutCnt + 1;
static const int kInstTessCtlOutUnused = kInstCommonOutCnt + 2;
// Tessellation Eval Shader Output Record Offsets
static const int kInstTessEvalOutPrimitiveId = kInstCommonOutCnt;
static const int kInstTessEvalOutTessCoordU = kInstCommonOutCnt + 1;
static const int kInstTessEvalOutTessCoordV = kInstCommonOutCnt + 2;
// Tessellation Shader Output Record Offsets - Version 1 (DEPRECATED)
static const int kInstTessOutInvocationId = kInstCommonOutCnt;
static const int kInstTessOutUnused = kInstCommonOutCnt + 1;
// Geometry Shader Output Record Offsets
static const int kInstGeomOutPrimitiveId = kInstCommonOutCnt;
static const int kInstGeomOutInvocationId = kInstCommonOutCnt + 1;
static const int kInstGeomOutUnused = kInstCommonOutCnt + 2;
// Ray Tracing Shader Output Record Offsets
static const int kInstRayTracingOutLaunchIdX = kInstCommonOutCnt;
static const int kInstRayTracingOutLaunchIdY = kInstCommonOutCnt + 1;
static const int kInstRayTracingOutLaunchIdZ = kInstCommonOutCnt + 2;
// Size of Common and Stage-specific Members
static const int kInstStageOutCnt = kInstCommonOutCnt + 2;
static const int kInst2StageOutCnt = kInstCommonOutCnt + 3;
// Validation Error Code
// Validation Error Code Offset
//
// This identifies the validation error. It also helps to identify
// how many words follow in the record and their meaning.
static const int kInstValidationOutError = kInstStageOutCnt;
static const int kInst2ValidationOutError = kInst2StageOutCnt;
// Validation-specific Output Record Offsets
//
......@@ -110,17 +140,37 @@ static const int kInstValidationOutError = kInstStageOutCnt;
// about the validation error.
//
// A bindless bounds error will output the index and the bound.
static const int kInstBindlessBoundsOutDescIndex = kInstStageOutCnt + 1;
static const int kInstBindlessBoundsOutDescBound = kInstStageOutCnt + 2;
static const int kInstBindlessBoundsOutCnt = kInstStageOutCnt + 3;
static const int kInst2BindlessBoundsOutDescIndex = kInst2StageOutCnt + 1;
static const int kInst2BindlessBoundsOutDescBound = kInst2StageOutCnt + 2;
static const int kInst2BindlessBoundsOutCnt = kInst2StageOutCnt + 3;
// A bindless uninitialized error will output the index.
static const int kInstBindlessUninitOutDescIndex = kInstStageOutCnt + 1;
static const int kInstBindlessUninitOutUnused = kInstStageOutCnt + 2;
static const int kInstBindlessUninitOutCnt = kInstStageOutCnt + 3;
static const int kInst2BindlessUninitOutDescIndex = kInst2StageOutCnt + 1;
static const int kInst2BindlessUninitOutUnused = kInst2StageOutCnt + 2;
static const int kInst2BindlessUninitOutCnt = kInst2StageOutCnt + 3;
// DEPRECATED
static const int kInstBindlessOutDescIndex = kInstStageOutCnt + 1;
static const int kInstBindlessOutDescBound = kInstStageOutCnt + 2;
static const int kInstBindlessOutCnt = kInstStageOutCnt + 3;
// Maximum Output Record Member Count
static const int kInstMaxOutCnt = kInstStageOutCnt + 3;
static const int kInst2MaxOutCnt = kInst2StageOutCnt + 3;
// Validation Error Codes
//
// These are the possible validation error codes.
static const int kInstErrorBindlessBounds = 0;
static const int kInstErrorBindlessUninit = 1;
// Direct Input Buffer Offsets
//
......@@ -141,11 +191,8 @@ static const int kDebugInputDataOffset = 0;
// and possibly other future validations.
static const int kDebugOutputBindingStream = 0;
// The binding for the input buffer for InstBindlessCheckPass. The input
// buffer needs only be created if the shaders being validated contain a
// descriptor array of runtime size, and validation of runtime size descriptor
// arrays have been enabled at the time of the bindless validation pass
// creation.
// The binding for the input buffer read by InstBindlessCheckPass and
// possibly other future validations.
static const int kDebugInputBindingBindless = 1;
// Bindless Validation Input Buffer Format
......@@ -153,11 +200,19 @@ static const int kDebugInputBindingBindless = 1;
// An input buffer for bindless validation consists of a single array of
// unsigned integers we will call Data[]. This array is formatted as follows.
//
// At the beginning of the array is a single uint reserved for future use.
// At offset kDebugInputBindlessInitOffset in Data[] is a single uint which
// gives an offset to the start of the bindless initialization data. More
// specifically, if the following value is zero, we know that the descriptor at
// (set = s, binding = b, index = i) is not initialized:
// Data[ i + Data[ b + Data[ s + Data[ kDebugInputBindlessInitOffset ] ] ] ]
static const int kDebugInputBindlessInitOffset = 0;
// DEPRECATED
static const int kDebugInputBindlessOffsetReserved = 0;
// Following the reserved uint is some number of uints such that the following
// is true: the number of descriptors at (set=s, binding=b) is:
// At offset kDebugInputBindlessOffsetLengths is some number of uints which
// provide the bindless length data. More specifically, the number of
// descriptors at (set=s, binding=b) is:
// Data[ Data[ s + kDebugInputBindlessOffsetLengths ] + b ]
static const int kDebugInputBindlessOffsetLengths = 1;
......
......@@ -370,6 +370,8 @@ typedef struct spv_optimizer_options_t spv_optimizer_options_t;
typedef struct spv_reducer_options_t spv_reducer_options_t;
typedef struct spv_fuzzer_options_t spv_fuzzer_options_t;
// Type Definitions
typedef spv_const_binary_t* spv_const_binary;
......@@ -385,6 +387,8 @@ typedef spv_optimizer_options_t* spv_optimizer_options;
typedef const spv_optimizer_options_t* spv_const_optimizer_options;
typedef spv_reducer_options_t* spv_reducer_options;
typedef const spv_reducer_options_t* spv_const_reducer_options;
typedef spv_fuzzer_options_t* spv_fuzzer_options;
typedef const spv_fuzzer_options_t* spv_const_fuzzer_options;
// Platform API
......@@ -427,6 +431,8 @@ typedef enum {
SPV_ENV_UNIVERSAL_1_3, // SPIR-V 1.3 latest revision, no other restrictions.
SPV_ENV_VULKAN_1_1, // Vulkan 1.1 latest revision.
SPV_ENV_WEBGPU_0, // Work in progress WebGPU 1.0.
SPV_ENV_UNIVERSAL_1_4, // SPIR-V 1.4 latest revision, no other restrictions.
SPV_ENV_VULKAN_1_1_SPIRV_1_4, // Vulkan 1.1 with SPIR-V 1.4 binary.
} spv_target_env;
// SPIR-V Validator can be parameterized with the following Universal Limits.
......@@ -492,6 +498,20 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxStoreStruct(
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxLogicalPointer(
spv_validator_options options, bool val);
// Records whether or not the validator should relax the rules because it is
// expected that the optimizations will make the code legal.
//
// When relaxed, it will allow the following:
// 1) It will allow relaxed logical pointers. Setting this option will also
// set that option.
// 2) Pointers that are pass as parameters to function calls do not have to
// match the storage class of the formal parameter.
// 3) Pointers that are actaul parameters on function calls do not have to point
// to the same type pointed as the formal parameter. The types just need to
// logically match.
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetBeforeHlslLegalization(
spv_validator_options options, bool val);
// Records whether the validator should use "relaxed" block layout rules.
// Relaxed layout rules are described by Vulkan extension
// VK_KHR_relaxed_block_layout, and they affect uniform blocks, storage blocks,
......@@ -502,6 +522,11 @@ SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxLogicalPointer(
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetRelaxBlockLayout(
spv_validator_options options, bool val);
// Records whether the validator should use standard block layout rules for
// uniform blocks.
SPIRV_TOOLS_EXPORT void spvValidatorOptionsSetUniformBufferStandardLayout(
spv_validator_options options, bool val);
// Records whether the validator should use "scalar" block layout rules.
// Scalar layout rules are more permissive than relaxed block layout.
//
......@@ -549,6 +574,15 @@ SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetValidatorOptions(
SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetMaxIdBound(
spv_optimizer_options options, uint32_t val);
// Records whether all bindings within the module should be preserved.
SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetPreserveBindings(
spv_optimizer_options options, bool val);
// Records whether all specialization constants within the module
// should be preserved.
SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetPreserveSpecConstants(
spv_optimizer_options options, bool val);
// Creates a reducer options object with default options. Returns a valid
// options object. The object remains valid until it is passed into
// |spvReducerOptionsDestroy|.
......@@ -557,14 +591,35 @@ SPIRV_TOOLS_EXPORT spv_reducer_options spvReducerOptionsCreate();
// Destroys the given reducer options object.
SPIRV_TOOLS_EXPORT void spvReducerOptionsDestroy(spv_reducer_options options);
// Records the maximum number of reduction steps that should run before the
// reducer gives up.
// Sets the maximum number of reduction steps that should run before the reducer
// gives up.
SPIRV_TOOLS_EXPORT void spvReducerOptionsSetStepLimit(
spv_reducer_options options, uint32_t step_limit);
// Sets seed for random number generation.
SPIRV_TOOLS_EXPORT void spvReducerOptionsSetSeed(spv_reducer_options options,
uint32_t seed);
// Sets the fail-on-validation-error option; if true, the reducer will return
// kStateInvalid if a reduction step yields a state that fails SPIR-V
// validation. Otherwise, an invalid state is treated as uninteresting and the
// reduction backtracks and continues.
SPIRV_TOOLS_EXPORT void spvReducerOptionsSetFailOnValidationError(
spv_reducer_options options, bool fail_on_validation_error);
// Creates a fuzzer options object with default options. Returns a valid
// options object. The object remains valid until it is passed into
// |spvFuzzerOptionsDestroy|.
SPIRV_TOOLS_EXPORT spv_fuzzer_options spvFuzzerOptionsCreate();
// Destroys the given fuzzer options object.
SPIRV_TOOLS_EXPORT void spvFuzzerOptionsDestroy(spv_fuzzer_options options);
// Sets the seed with which the random number generator used by the fuzzer
// should be initialized.
SPIRV_TOOLS_EXPORT void spvFuzzerOptionsSetRandomSeed(
spv_fuzzer_options options, uint32_t seed);
// Sets the maximum number of steps that the shrinker should take before giving
// up.
SPIRV_TOOLS_EXPORT void spvFuzzerOptionsSetShrinkerStepLimit(
spv_fuzzer_options options, uint32_t shrinker_step_limit);
// Encodes the given SPIR-V assembly text to its binary representation. The
// length parameter specifies the number of bytes for text. Encoded binary will
......
......@@ -88,6 +88,12 @@ class ValidatorOptions {
spvValidatorOptionsSetRelaxBlockLayout(options_, val);
}
// Enables VK_KHR_uniform_buffer_standard_layout when validating standard
// uniform layout. If true, disables scalar block layout rules.
void SetUniformBufferStandardLayout(bool val) {
spvValidatorOptionsSetUniformBufferStandardLayout(options_, val);
}
// Enables VK_EXT_scalar_block_layout when validating standard
// uniform/storage buffer/push-constant layout. If true, disables
// relaxed block layout rules.
......@@ -110,6 +116,21 @@ class ValidatorOptions {
spvValidatorOptionsSetRelaxLogicalPointer(options_, val);
}
// Records whether or not the validator should relax the rules because it is
// expected that the optimizations will make the code legal.
//
// When relaxed, it will allow the following:
// 1) It will allow relaxed logical pointers. Setting this option will also
// set that option.
// 2) Pointers that are pass as parameters to function calls do not have to
// match the storage class of the formal parameter.
// 3) Pointers that are actaul parameters on function calls do not have to
// point to the same type pointed as the formal parameter. The types just
// need to logically match.
void SetBeforeHlslLegalization(bool val) {
spvValidatorOptionsSetBeforeHlslLegalization(options_, val);
}
private:
spv_validator_options options_;
};
......@@ -140,6 +161,18 @@ class OptimizerOptions {
spvOptimizerOptionsSetMaxIdBound(options_, new_bound);
}
// Records whether all bindings within the module should be preserved.
void set_preserve_bindings(bool preserve_bindings) {
spvOptimizerOptionsSetPreserveBindings(options_, preserve_bindings);
}
// Records whether all specialization constants within the module
// should be preserved.
void set_preserve_spec_constants(bool preserve_spec_constants) {
spvOptimizerOptionsSetPreserveSpecConstants(options_,
preserve_spec_constants);
}
private:
spv_optimizer_options options_;
};
......@@ -151,21 +184,50 @@ class ReducerOptions {
~ReducerOptions() { spvReducerOptionsDestroy(options_); }
// Allow implicit conversion to the underlying object.
operator spv_reducer_options() const { return options_; }
operator spv_reducer_options() const { // NOLINT(google-explicit-constructor)
return options_;
}
// Records the maximum number of reduction steps that should
// run before the reducer gives up.
// See spvReducerOptionsSetStepLimit.
void set_step_limit(uint32_t step_limit) {
spvReducerOptionsSetStepLimit(options_, step_limit);
}
// Sets a seed to be used for random number generation.
void set_seed(uint32_t seed) { spvReducerOptionsSetSeed(options_, seed); }
// See spvReducerOptionsSetFailOnValidationError.
void set_fail_on_validation_error(bool fail_on_validation_error) {
spvReducerOptionsSetFailOnValidationError(options_,
fail_on_validation_error);
}
private:
spv_reducer_options options_;
};
// A C++ wrapper around a fuzzer options object.
class FuzzerOptions {
public:
FuzzerOptions() : options_(spvFuzzerOptionsCreate()) {}
~FuzzerOptions() { spvFuzzerOptionsDestroy(options_); }
// Allow implicit conversion to the underlying object.
operator spv_fuzzer_options() const { // NOLINT(google-explicit-constructor)
return options_;
}
// See spvFuzzerOptionsSetRandomSeed.
void set_random_seed(uint32_t seed) {
spvFuzzerOptionsSetRandomSeed(options_, seed);
}
// See spvFuzzerOptionsSetShrinkerStepLimit.
void set_shrinker_step_limit(uint32_t shrinker_step_limit) {
spvFuzzerOptionsSetShrinkerStepLimit(options_, shrinker_step_limit);
}
private:
spv_fuzzer_options options_;
};
// C++ interface for SPIRV-Tools functionalities. It wraps the context
// (including target environment and the corresponding SPIR-V grammar) and
// provides methods for assembling, disassembling, and validating.
......
......@@ -101,10 +101,15 @@ class Optimizer {
// from time to time.
Optimizer& RegisterSizePasses();
// Registers passes that have been prescribed for WebGPU environments.
// This sequence of passes is subject to constant review and will change
// from time to time.
Optimizer& RegisterWebGPUPasses();
// Registers passes that have been prescribed for converting from Vulkan to
// WebGPU. This sequence of passes is subject to constant review and will
// change from time to time.
Optimizer& RegisterVulkanToWebGPUPasses();
// Registers passes that have been prescribed for converting from WebGPU to
// Vulkan. This sequence of passes is subject to constant review and will
// change from time to time.
Optimizer& RegisterWebGPUToVulkanPasses();
// Registers passes that attempt to legalize the generated code.
//
......@@ -199,6 +204,9 @@ class Optimizer {
// |out| output stream.
Optimizer& SetTimeReport(std::ostream* out);
// Sets the option to validate the module after each pass.
Optimizer& SetValidateAfterAll(bool validate);
private:
struct Impl; // Opaque struct for holding internal data.
std::unique_ptr<Impl> impl_; // Unique pointer to internal data.
......@@ -208,6 +216,13 @@ class Optimizer {
// A null pass does nothing to the SPIR-V module to be optimized.
Optimizer::PassToken CreateNullPass();
// Creates a strip-atomic-counter-memory pass.
// A strip-atomic-counter-memory pass removes all usages of the
// AtomicCounterMemory bit in Memory Semantics bitmasks. This bit is a no-op in
// Vulkan, so isn't needed in that env. And the related capability is not
// allowed in WebGPU, so it is not allowed in that env.
Optimizer::PassToken CreateStripAtomicCounterMemoryPass();
// Creates a strip-debug-info pass.
// A strip-debug-info pass removes all debug instructions (as documented in
// Section 3.32.2 of the SPIR-V spec) of the SPIR-V module to be optimized.
......@@ -477,20 +492,6 @@ Optimizer::PassToken CreateInsertExtractElimPass();
// inserts created by that pass.
Optimizer::PassToken CreateDeadInsertElimPass();
// Creates a pass to consolidate uniform references.
// For each entry point function in the module, first change all constant index
// access chain loads into equivalent composite extracts. Then consolidate
// identical uniform loads into one uniform load. Finally, consolidate
// identical uniform extracts into one uniform extract. This may require
// moving a load or extract to a point which dominates all uses.
//
// This pass requires a module to have structured control flow ie shader
// capability. It also requires logical addressing ie Addresses capability
// is not enabled. It also currently does not support any extensions.
//
// This pass currently only optimizes loads with a single index.
Optimizer::PassToken CreateCommonUniformElimPass();
// Create aggressive dead code elimination pass
// This pass eliminates unused code from the module. In addition,
// it detects and eliminates code which may have spurious uses but which do
......@@ -697,10 +698,14 @@ Optimizer::PassToken CreateCombineAccessChainsPass();
// Create a pass to instrument bindless descriptor checking
// This pass instruments all bindless references to check that descriptor
// array indices are inbounds. If the reference is invalid, a record is
// written to the debug output buffer (if space allows) and a null value is
// returned. This pass is designed to support bindless validation in the Vulkan
// validation layers.
// array indices are inbounds, and if the descriptor indexing extension is
// enabled, that the descriptor has been initialized. If the reference is
// invalid, a record is written to the debug output buffer (if space allows)
// and a null value is returned. This pass is designed to support bindless
// validation in the Vulkan validation layers.
//
// TODO(greg-lunarg): Add support for buffer references. Currently only does
// checking for image references.
//
// Dead code elimination should be run after this pass as the original,
// potentially invalid code is not removed and could cause undefined behavior,
......@@ -716,12 +721,13 @@ Optimizer::PassToken CreateCombineAccessChainsPass();
// The instrumentation will read and write buffers in debug
// descriptor set |desc_set|. It will write |shader_id| in each output record
// to identify the shader module which generated the record.
// |runtime_array_enable| controls instrumentation of runtime arrays which
// require input buffer support.
//
// TODO(greg-lunarg): Add support for vk_ext_descriptor_indexing.
// |input_length_enable| controls instrumentation of runtime descriptor array
// references, and |input_init_enable| controls instrumentation of descriptor
// initialization checking, both of which require input buffer support.
// |version| specifies the buffer record format.
Optimizer::PassToken CreateInstBindlessCheckPass(
uint32_t desc_set, uint32_t shader_id, bool runtime_array_enable = false);
uint32_t desc_set, uint32_t shader_id, bool input_length_enable = false,
bool input_init_enable = false, uint32_t version = 1);
// Create a pass to upgrade to the VulkanKHR memory model.
// This pass upgrades the Logical GLSL450 memory model to Logical VulkanKHR.
......@@ -733,6 +739,62 @@ Optimizer::PassToken CreateUpgradeMemoryModelPass();
// where an instruction is moved into a more deeply nested construct.
Optimizer::PassToken CreateCodeSinkingPass();
// Create a pass to adds initializers for OpVariable calls that require them
// in WebGPU. Currently this pass naively initializes variables that are
// missing an initializer with a null value. In the future it may initialize
// variables to the first value stored in them, if that is a constant.
Optimizer::PassToken CreateGenerateWebGPUInitializersPass();
// Create a pass to fix incorrect storage classes. In order to make code
// generation simpler, DXC may generate code where the storage classes do not
// match up correctly. This pass will fix the errors that it can.
Optimizer::PassToken CreateFixStorageClassPass();
// Create a pass to legalize OpVectorShuffle operands going into WebGPU. WebGPU
// forbids using 0xFFFFFFFF, which indicates an undefined result, so this pass
// converts those literals to 0.
Optimizer::PassToken CreateLegalizeVectorShufflePass();
// Create a pass to decompose initialized variables into a seperate variable
// declaration and an initial store.
Optimizer::PassToken CreateDecomposeInitializedVariablesPass();
// Create a pass to attempt to split up invalid unreachable merge-blocks and
// continue-targets to legalize for WebGPU.
Optimizer::PassToken CreateSplitInvalidUnreachablePass();
// Creates a graphics robust access pass.
//
// This pass injects code to clamp indexed accesses to buffers and internal
// arrays, providing guarantees satisfying Vulkan's robustBufferAccess rules.
//
// TODO(dneto): Clamps coordinates and sample index for pointer calculations
// into storage images (OpImageTexelPointer). For an cube array image, it
// assumes the maximum layer count times 6 is at most 0xffffffff.
//
// NOTE: This pass will fail with a message if:
// - The module is not a Shader module.
// - The module declares VariablePointers, VariablePointersStorageBuffer, or
// RuntimeDescriptorArrayEXT capabilities.
// - The module uses an addressing model other than Logical
// - Access chain indices are wider than 64 bits.
// - Access chain index for a struct is not an OpConstant integer or is out
// of range. (The module is already invalid if that is the case.)
// - TODO(dneto): The OpImageTexelPointer coordinate component is not 32-bits
// wide.
Optimizer::PassToken CreateGraphicsRobustAccessPass();
// Create descriptor scalar replacement pass.
// This pass replaces every array variable |desc| that has a DescriptorSet and
// Binding decorations with a new variable for each element of the array.
// Suppose |desc| was bound at binding |b|. Then the variable corresponding to
// |desc[i]| will have binding |b+i|. The descriptor set will be the same. It
// is assumed that no other variable already has a binding that will used by one
// of the new variables. If not, the pass will generate invalid Spir-V. All
// accesses to |desc| must be OpAccessChain instructions with a literal index
// for the first index.
Optimizer::PassToken CreateDescriptorScalarReplacementPass();
} // namespace spvtools
#endif // INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_
......@@ -44,7 +44,7 @@ mkdir build && cd $SRC/build
# Invoke the build.
BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT}
echo $(date): Starting build...
cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_NATIVE_API_LEVEL=android-14 -DANDROID_ABI="armeabi-v7a with NEON" -DSPIRV_BUILD_COMPRESSION=ON -DSPIRV_SKIP_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_PATH -GNinja -DANDROID_NDK=$ANDROID_NDK ..
cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Release -DANDROID_NATIVE_API_LEVEL=android-14 -DANDROID_ABI="armeabi-v7a with NEON" -DSPIRV_SKIP_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN_PATH -GNinja -DANDROID_NDK=$ANDROID_NDK ..
echo $(date): Build everything...
ninja
......
# Copyright (c) 2017 Google Inc.
#!/bin/bash
# Copyright (c) 2019 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -11,17 +12,13 @@
# 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.
set(VAL_TEST_COMMON_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/../test_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/../unit_spirv.h
)
# Fail on any error.
set -e
# Display commands being run.
set -x
add_spvtools_unittest(TARGET stats
SRCS stats_aggregate_test.cpp
stats_analyzer_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../tools/stats/spirv_stats.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../tools/stats/stats_analyzer.cpp
${VAL_TEST_COMMON_SRCS}
LIBS ${SPIRV_TOOLS}
)
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
source $SCRIPT_DIR/../scripts/linux/build.sh ASAN clang
# Copyright (c) 2019 Google LLC.
#
# 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.
# Continuous build configuration.
build_file: "SPIRV-Tools/kokoro/linux-clang-asan/build.sh"
# Copyright (c) 2019 Google LLC.
#
# 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.
# Presubmit build configuration.
build_file: "SPIRV-Tools/kokoro/linux-clang-asan/build.sh"
......@@ -14,3 +14,9 @@
# Continuous build configuration.
build_file: "SPIRV-Tools/kokoro/linux-clang-debug/build.sh"
action {
define_artifacts {
regex: "install.tgz"
}
}