Skip to content
Commits on Source (140)
......@@ -16,6 +16,11 @@ compile_commands.json
/testing
/tools/clang/
/utils/clang-format-diff.py
bazel-bin
bazel-genfiles
bazel-out
bazel-spirv-tools
bazel-testlogs
# Vim
[._]*.s[a-w][a-z]
......
......@@ -49,7 +49,6 @@ SPVTOOLS_SRC_FILES := \
source/val/validate_composites.cpp \
source/val/validate_constants.cpp \
source/val/validate_conversion.cpp \
source/val/validate_datarules.cpp \
source/val/validate_debug.cpp \
source/val/validate_decorations.cpp \
source/val/validate_derivatives.cpp \
......@@ -75,6 +74,7 @@ SPVTOOLS_SRC_FILES := \
SPVTOOLS_OPT_SRC_FILES := \
source/opt/aggressive_dead_code_elim_pass.cpp \
source/opt/amd_ext_to_khr.cpp \
source/opt/basic_block.cpp \
source/opt/block_merge_pass.cpp \
source/opt/block_merge_util.cpp \
......@@ -88,6 +88,7 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/composite.cpp \
source/opt/const_folding_rules.cpp \
source/opt/constants.cpp \
source/opt/convert_to_half_pass.cpp \
source/opt/copy_prop_arrays.cpp \
source/opt/dead_branch_elim_pass.cpp \
source/opt/dead_insert_elim_pass.cpp \
......@@ -117,6 +118,7 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/inline_exhaustive_pass.cpp \
source/opt/inline_opaque_pass.cpp \
source/opt/inst_bindless_check_pass.cpp \
source/opt/inst_buff_addr_check_pass.cpp \
source/opt/instruction.cpp \
source/opt/instruction_list.cpp \
source/opt/instrument_pass.cpp \
......@@ -128,7 +130,6 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/local_redundancy_elimination.cpp \
source/opt/local_single_block_elim_pass.cpp \
source/opt/local_single_store_elim_pass.cpp \
source/opt/local_ssa_elim_pass.cpp \
source/opt/loop_dependence.cpp \
source/opt/loop_dependence_helpers.cpp \
source/opt/loop_descriptor.cpp \
......@@ -151,6 +152,7 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/reduce_load_size.cpp \
source/opt/redundancy_elimination.cpp \
source/opt/register_pressure.cpp \
source/opt/relax_float_ops_pass.cpp \
source/opt/remove_duplicates_pass.cpp \
source/opt/replace_invalid_opc.cpp \
source/opt/scalar_analysis.cpp \
......@@ -171,7 +173,8 @@ SPVTOOLS_OPT_SRC_FILES := \
source/opt/upgrade_memory_model.cpp \
source/opt/value_number_table.cpp \
source/opt/vector_dce.cpp \
source/opt/workaround1209.cpp
source/opt/workaround1209.cpp \
source/opt/wrap_opkill.cpp
# Locations of grammar files.
#
......@@ -246,6 +249,8 @@ $(LOCAL_PATH)/source/ext_inst.cpp: \
$(1)/spv-amd-shader-ballot.insts.inc \
$(1)/spv-amd-shader-explicit-vertex-parameter.insts.inc \
$(1)/spv-amd-shader-trinary-minmax.insts.inc
$(LOCAL_PATH)/source/opt/amd_ext_to_khr.cpp: \
$(1)/spv-amd-shader-ballot.insts.inc
endef
$(eval $(call gen_spvtools_grammar_tables,$(SPVTOOLS_OUT_PATH)))
......
load(
":build_defs.bzl",
"COMMON_COPTS",
"DEBUGINFO_GRAMMAR_JSON_FILE",
"TEST_COPTS",
"base_test",
"generate_core_tables",
"generate_enum_string_mapping",
"generate_extinst_lang_headers",
"generate_glsl_tables",
"generate_opencl_tables",
"generate_vendor_tables",
"link_test",
"opt_test",
"reduce_test",
"util_test",
"val_test",
)
package(
default_visibility = ["//visibility:private"],
)
licenses(["notice"])
exports_files([
"CHANGES",
"LICENSE",
])
py_binary(
name = "generate_grammar_tables",
srcs = ["utils/generate_grammar_tables.py"],
)
py_binary(
name = "generate_language_headers",
srcs = ["utils/generate_language_headers.py"],
)
generate_core_tables("1.0")
generate_core_tables("1.1")
generate_core_tables("1.2")
generate_core_tables("unified1")
generate_enum_string_mapping("unified1")
generate_opencl_tables("unified1")
generate_glsl_tables("unified1")
generate_vendor_tables("spv-amd-shader-explicit-vertex-parameter")
generate_vendor_tables("spv-amd-shader-trinary-minmax")
generate_vendor_tables("spv-amd-gcn-shader")
generate_vendor_tables("spv-amd-shader-ballot")
generate_vendor_tables("debuginfo")
generate_extinst_lang_headers("DebugInfo", DEBUGINFO_GRAMMAR_JSON_FILE)
py_binary(
name = "generate_registry_tables",
srcs = ["utils/generate_registry_tables.py"],
)
genrule(
name = "gen_registry_tables",
srcs = ["@spirv_headers//:spirv_xml_registry"],
outs = ["generators.inc"],
cmd = "$(location generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)",
tools = [":generate_registry_tables"],
)
py_binary(
name = "update_build_version",
srcs = ["utils/update_build_version.py"],
)
genrule(
name = "gen_build_version",
srcs = ["CHANGES"],
outs = ["build-version.inc"],
cmd = "SOURCE_DATE_EPOCH=0 $(location update_build_version) $$(dirname $(location CHANGES)) $(location build-version.inc)",
tools = [":update_build_version"],
)
# Libraries
cc_library(
name = "generated_headers",
hdrs = [
":gen_build_version",
":gen_core_tables_1.0",
":gen_core_tables_1.1",
":gen_core_tables_1.2",
":gen_core_tables_unified1",
":gen_enum_string_mapping",
":gen_extinst_lang_headers_DebugInfo",
":gen_glsl_tables_unified1",
":gen_opencl_tables_unified1",
":gen_registry_tables",
":gen_vendor_tables_debuginfo",
":gen_vendor_tables_spv_amd_gcn_shader",
":gen_vendor_tables_spv_amd_shader_ballot",
":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter",
":gen_vendor_tables_spv_amd_shader_trinary_minmax",
],
copts = COMMON_COPTS,
)
cc_library(
name = "spirv_tools_headers",
hdrs = glob([
"include/spirv-tools/libspirv.h",
"include/spirv-tools/libspirv.hpp",
"source/*.h",
"source/util/*.h",
"source/val/*.h",
]),
copts = COMMON_COPTS,
includes = ["source"],
deps = [
"@spirv_headers//:spirv_c_headers",
],
)
cc_library(
name = "spirv_tools",
srcs = glob([
"source/*.cpp",
"source/util/*.cpp",
"source/val/*.cpp",
]),
hdrs = [
"include/spirv-tools/libspirv.h",
"include/spirv-tools/libspirv.hpp",
],
copts = COMMON_COPTS + select({
"@bazel_tools//src/conditions:windows": [""],
"//conditions:default": ["-Wno-implicit-fallthrough"],
}),
includes = ["include"],
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":generated_headers",
":spirv_tools_headers",
"@spirv_headers//:spirv_c_headers",
"@spirv_headers//:spirv_common_headers",
],
)
cc_library(
name = "spirv_tools_comp",
srcs = glob([
"source/comp/*.cpp",
"source/comp/*.h",
]),
copts = COMMON_COPTS,
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":generated_headers",
":spirv_tools",
":spirv_tools_headers",
"@spirv_headers//:spirv_common_headers",
],
)
cc_library(
name = "spirv_tools_opt_headers",
hdrs = glob(["source/opt/*.h"]),
copts = COMMON_COPTS,
)
cc_library(
name = "spirv_tools_opt",
srcs = glob(["source/opt/*.cpp"]),
hdrs = [
"include/spirv-tools/instrument.hpp",
"include/spirv-tools/optimizer.hpp",
],
copts = COMMON_COPTS,
includes = ["include"],
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":spirv_tools_headers",
":spirv_tools_opt_headers",
"@spirv_headers//:spirv_common_headers",
],
)
cc_library(
name = "spirv_tools_reduce",
srcs = glob(["source/reduce/*.cpp"]),
hdrs = glob(["source/reduce/*.h"]),
copts = COMMON_COPTS,
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":spirv_tools_opt",
],
)
cc_library(
name = "spirv_tools_link",
srcs = glob(["source/link/*.cpp"]),
hdrs = ["include/spirv-tools/linker.hpp"],
copts = COMMON_COPTS,
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":spirv_tools_opt",
],
)
cc_library(
name = "tools_util",
srcs = glob(["tools/util/*.cpp"]),
hdrs = glob(["tools/util/*.h"]),
copts = COMMON_COPTS,
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [":spirv_tools"],
)
# Tools
cc_binary(
name = "spirv-as",
srcs = [
"tools/as/as.cpp",
"tools/io.h",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
],
)
cc_binary(
name = "spirv-dis",
srcs = [
"tools/dis/dis.cpp",
"tools/io.h",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
],
)
cc_binary(
name = "spirv-val",
srcs = [
"tools/io.h",
"tools/val/val.cpp",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":tools_util",
],
)
cc_binary(
name = "spirv-opt",
srcs = [
"tools/io.h",
"tools/opt/opt.cpp",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":spirv_tools_opt",
":tools_util",
],
)
cc_binary(
name = "spirv-reduce",
srcs = [
"tools/io.h",
"tools/reduce/reduce.cpp",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":spirv_tools_opt",
":spirv_tools_reduce",
":tools_util",
],
)
cc_binary(
name = "spirv-link",
srcs = [
"tools/io.h",
"tools/link/linker.cpp",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [
":spirv_tools",
":spirv_tools_link",
],
)
cc_binary(
name = "spirv-cfg",
srcs = [
"tools/cfg/bin_to_dot.cpp",
"tools/cfg/bin_to_dot.h",
"tools/cfg/cfg.cpp",
"tools/io.h",
],
copts = COMMON_COPTS,
visibility = ["//visibility:public"],
deps = [":spirv_tools"],
)
# Unit tests
cc_library(
name = "test_common",
testonly = 1,
srcs = [
"test/test_fixture.h",
"test/unit_spirv.cpp",
"test/unit_spirv.h",
],
compatible_with = [],
copts = TEST_COPTS,
includes = ["test"],
linkstatic = 1,
deps = [
":spirv_tools",
"@com_google_googletest//:gtest",
],
)
cc_library(
name = "link_test_common",
testonly = 1,
srcs = ["test/link/linker_fixture.h"],
compatible_with = [],
copts = TEST_COPTS,
linkstatic = 1,
deps = [
":spirv_tools_link",
":test_common",
],
)
cc_library(
name = "opt_test_common",
testonly = 1,
srcs = ["test/opt/pass_utils.cpp"],
hdrs = [
"test/opt/assembly_builder.h",
"test/opt/function_utils.h",
"test/opt/module_utils.h",
"test/opt/pass_fixture.h",
"test/opt/pass_utils.h",
],
compatible_with = [],
copts = TEST_COPTS,
linkstatic = 1,
deps = [
":spirv_tools_opt",
":test_common",
],
)
cc_library(
name = "reduce_test_common",
testonly = 1,
srcs = [
"test/reduce/reduce_test_util.cpp",
"tools/io.h",
],
hdrs = ["test/reduce/reduce_test_util.h"],
compatible_with = [],
copts = TEST_COPTS,
linkstatic = 1,
deps = [
":spirv_tools_reduce",
":test_common",
],
)
cc_library(
name = "val_test_common",
testonly = 1,
srcs = [
"test/val/val_code_generator.cpp",
"test/val/val_fixtures.h",
],
hdrs = [
"test/val/val_code_generator.h",
],
compatible_with = [],
copts = TEST_COPTS,
linkstatic = 1,
deps = [":test_common"],
)
# PCH (precompiled header) tests only work when using CMake and MSVC on Windows,
# so they will be skipped in the Bazel builds.
[base_test(
name = f[5:-4], # strip test/, .cpp
srcs = [f],
) for f in glob(
["test/*.cpp"],
exclude = [
"test/cpp_interface_test.cpp", # has its own base_test below.
"test/log_test.cpp", # has its own base_test below.
"test/pch_test.cpp", # pch tests are skipped.
"test/timer_test.cpp", # has its own base_test below.
],
)]
# This test uses unistd.h and does not run on Windows.
base_test(
name = "timer_test",
srcs = select({
"@bazel_tools//src/conditions:windows": [],
"//conditions:default": ["test/timer_test.cpp"],
}),
)
base_test(
name = "cpp_interface_test",
srcs = ["test/cpp_interface_test.cpp"],
deps = [":spirv_tools_opt"],
)
base_test(
name = "log_test",
srcs = ["test/log_test.cpp"],
deps = [":spirv_tools_opt"],
)
[link_test(
name = f[10:-4], # strip test/link/, .cpp
srcs = [f],
) for f in glob(
["test/link/*.cpp"],
)]
[opt_test(
name = f[9:-4], # strip test/opt/, .cpp
srcs = [f],
) for f in glob(
["test/opt/*.cpp"],
# pch tests are skipped.
exclude = ["test/opt/pch_test_opt.cpp"],
)]
[opt_test(
name = "dom_tree_" + f[24:-4], # strip test/opt/dominator_tree/, .cpp
srcs = [f],
) for f in glob(
["test/opt/dominator_tree/*.cpp"],
# pch tests are skipped.
exclude = ["test/opt/dominator_tree/pch_test_opt_dom.cpp"],
)]
[opt_test(
name = "loop_" + f[28:-4], # strip test/opt/loop_optimizations/, .cpp
srcs = [f],
) for f in glob(
["test/opt/loop_optimizations/*.cpp"],
# pch tests are skipped.
exclude = ["test/opt/loop_optimizations/pch_test_opt_loop.cpp"],
)]
[reduce_test(
name = f[12:-4], # strip test/reduce/, .cpp
srcs = [f],
) for f in glob(["test/reduce/*.cpp"])]
[util_test(
name = f[10:-4], # strip test/util/, .cpp
srcs = [f],
) for f in glob(["test/util/*.cpp"])]
[val_test(
name = f[9:-4], # strip test/val/, .cpp
srcs = [f],
) for f in glob(
["test/val/*.cpp"],
exclude = [
"test/val/pch_test_val.cpp", # pch tests are skipped.
],
)]
......@@ -288,7 +288,10 @@ config("spvtools_internal_config") {
configs = [ ":spvtools_public_config" ]
if (is_clang) {
cflags = [ "-Wno-implicit-fallthrough" ]
cflags = [
"-Wno-implicit-fallthrough",
"-Wno-newline-eof",
]
}
}
......@@ -407,7 +410,6 @@ static_library("spvtools_val") {
"source/val/validate_composites.cpp",
"source/val/validate_constants.cpp",
"source/val/validate_conversion.cpp",
"source/val/validate_datarules.cpp",
"source/val/validate_debug.cpp",
"source/val/validate_decorations.cpp",
"source/val/validate_derivatives.cpp",
......@@ -451,6 +453,8 @@ static_library("spvtools_opt") {
sources = [
"source/opt/aggressive_dead_code_elim_pass.cpp",
"source/opt/aggressive_dead_code_elim_pass.h",
"source/opt/amd_ext_to_khr.cpp",
"source/opt/amd_ext_to_khr.h",
"source/opt/basic_block.cpp",
"source/opt/basic_block.h",
"source/opt/block_merge_pass.cpp",
......@@ -477,6 +481,8 @@ static_library("spvtools_opt") {
"source/opt/const_folding_rules.h",
"source/opt/constants.cpp",
"source/opt/constants.h",
"source/opt/convert_to_half_pass.cpp",
"source/opt/convert_to_half_pass.h",
"source/opt/copy_prop_arrays.cpp",
"source/opt/copy_prop_arrays.h",
"source/opt/dead_branch_elim_pass.cpp",
......@@ -535,6 +541,8 @@ static_library("spvtools_opt") {
"source/opt/inline_pass.h",
"source/opt/inst_bindless_check_pass.cpp",
"source/opt/inst_bindless_check_pass.h",
"source/opt/inst_buff_addr_check_pass.cpp",
"source/opt/inst_buff_addr_check_pass.h",
"source/opt/instruction.cpp",
"source/opt/instruction.h",
"source/opt/instruction_list.cpp",
......@@ -559,8 +567,6 @@ static_library("spvtools_opt") {
"source/opt/local_single_block_elim_pass.h",
"source/opt/local_single_store_elim_pass.cpp",
"source/opt/local_single_store_elim_pass.h",
"source/opt/local_ssa_elim_pass.cpp",
"source/opt/local_ssa_elim_pass.h",
"source/opt/log.h",
"source/opt/loop_dependence.cpp",
"source/opt/loop_dependence.h",
......@@ -607,6 +613,8 @@ static_library("spvtools_opt") {
"source/opt/reflect.h",
"source/opt/register_pressure.cpp",
"source/opt/register_pressure.h",
"source/opt/relax_float_ops_pass.cpp",
"source/opt/relax_float_ops_pass.h",
"source/opt/remove_duplicates_pass.cpp",
"source/opt/remove_duplicates_pass.h",
"source/opt/replace_invalid_opc.cpp",
......@@ -650,10 +658,13 @@ static_library("spvtools_opt") {
"source/opt/vector_dce.h",
"source/opt/workaround1209.cpp",
"source/opt/workaround1209.h",
"source/opt/wrap_opkill.cpp",
"source/opt/wrap_opkill.h",
]
deps = [
":spvtools",
":spvtools_vendor_tables_spv-amd-shader-ballot",
]
public_deps = [
":spvtools_headers",
......@@ -723,8 +734,6 @@ static_library("spvtools_reduce") {
"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",
......@@ -757,7 +766,7 @@ static_library("spvtools_reduce") {
}
group("SPIRV-Tools") {
deps = [
public_deps = [
":spvtools",
":spvtools_link",
":spvtools_opt",
......@@ -837,6 +846,8 @@ if (build_with_chromium) {
"//testing/gmock",
"//testing/gtest",
"//testing/gtest:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
if (is_clang) {
......@@ -861,6 +872,7 @@ source_set("spvtools_util_cli_consumer") {
"tools/util/cli_consumer.cpp",
"tools/util/cli_consumer.h",
]
deps = [ ":spvtools_headers" ]
configs += [ ":spvtools_internal_config" ]
}
......
Revision history for SPIRV-Tools
v2019.5-dev 2019-10-21
- General:
- Export SPIRV-Tools targets on installation
- SPIRV-Tools support for SPIR-V 1.5 (#2865)
- Add WebGPU SPIR-V Assembler in JavaScript. (#2876)
- Add Bazel build configuration. (#2891)
- Add support for building with emscripten (#2948)
- Update SPIR-V binary header test for SPIR-V 1.5 (#2967)
- Add fuzzer for spirv-as call path (#2976)
- Improved CMake install step. (#2963)
- Add fuzzer for spirv-dis call path (#2977)
- Ensure timestamp does not vary with timezone. (#2982)
- Optimizer
- Add descriptor array scalar replacement (#2742)
- Add pass to wrap OpKill in a function call (#2790)
- Fold FMix during constant folding. (#2818)
- Add pass to replace AMD shader ballot extension (#2811)
- Add pass to make Float32 operation relax precision (#2808)
- Add pass to make relax precision operation Float16 (#2808)
- Add pass to replace uses of 3 AMD extensions (#2814)
- Fold Min, Max, and Clamp instructions. (#2836)
- Better handling of OpKill in continues (#2842,#2922,#2933)
- Enable OpTypeCooperativeMatrix specialization (#2927)
- Support constant-folding UConvert and SConvert (#2960)
Fixes:
- Instrument: Fix version 2 output record write for tess eval shaders. (#2782)
- Instrument: Add support for Buffer Device Address extension (#2792)
- Fix check for changed binary in API call. (#2798)
- For WebGPU<->Vulkan optimization, set correct execution environment (#2834)
- Handle OpConstantNull in copy-prop-arrays. (#2870)
- Use OpReturn* in wrap-opkill (#2886)
- Validator
- Add generic builtin validation of target (#2843)
- Extra resource interface validation (#2864)
- Adding valilidation checks for OpEntryPoint duplicate names and execution mode (#2862)
- Relaxed bitcast with pointers (#2878)
- Validate physical storage buffer restrictions (#2930)
- Add SPV_KHR_shader_clock validation (#2879)
- Validate that selections are structured (#2962)
- Disallow use of OpCompositeExtract/OpCompositeInsert with no indices (#2980)
- Check that derivatives operate on 32-bit values (#2983)
Fixes:
- Fix validation of constant matrices (#2794)
- Update "remquor" validation
- Only allow previously declared forward refs in structs (#2920)
- Reduce
- Remove relaxed precision decorations (#2797)
- Reduce/fuzz: improve command line args (#2932)
- Improve remove unref instr pass (#2945)
Fixes:
- Fuzz
- Fix add-dead-break and add-dead-continue passes to respect dominance (#2838)
- Add fuzzer pass to copy objects (#2853)
- Add fuzzer pass to replace ids with synonyms (#2857)
- Allow validation during spirv-fuzz replay (#2873)
- Employ the "swarm testing" idea in spirv-fuzz (#2890)
- reduce/fuzz: improve command line args (#2932)
- option to convert shader into a form that renders red (#2934)
- Add fuzzer pass to change selection controls (#2944)
- add transformation and pass to construct composites (#2941)
- Add fuzzer pass to change loop controls (#2949)
- Add fuzzer pass to change function controls (#2951)
- Add fuzzer pass to add NoContraction decorations (#2950)
v2019.4 2019-08-08
- General:
- Memory model support for SPIR-V 1.4
......@@ -15,7 +80,7 @@ v2019.4 2019-08-08
- 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)
- 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)
......
......@@ -39,6 +39,8 @@ option(SPIRV_ALLOW_TIMERS "Allow timers via clock_gettime on supported platforms
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
add_definitions(-DSPIRV_LINUX)
set(SPIRV_TIMER_ENABLED ${SPIRV_ALLOW_TIMERS})
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
add_definitions(-DSPIRV_EMSCRIPTEN)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
add_definitions(-DSPIRV_WINDOWS)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
......@@ -204,6 +206,27 @@ else()
endmacro()
endif()
if(ENABLE_SPIRV_TOOLS_INSTALL)
if(WIN32)
macro(spvtools_config_package_dir TARGET PATH)
set(${PATH} ${TARGET}/cmake)
endmacro()
else()
macro(spvtools_config_package_dir TARGET PATH)
set(${PATH} lib/cmake/${TARGET})
endmacro()
endif()
macro(spvtools_generate_config_file TARGET)
file(WRITE ${CMAKE_BINARY_DIR}/${TARGET}Config.cmake
"include(CMakeFindDependencyMacro)\n"
"find_dependency(${SPIRV_TOOLS})\n"
"include(\${CMAKE_CURRENT_LIST_DIR}/${TARGET}Targets.cmake)\n"
"set(${TARGET}_LIBRARIES ${TARGET})\n"
"get_target_property(${TARGET}_INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)\n")
endmacro()
endif()
# Defaults to OFF if the user didn't set it.
option(SPIRV_SKIP_EXECUTABLES
"Skip building the executable and tests along with the library"
......
......@@ -4,7 +4,7 @@
We organize known future work in GitHub projects. See [Tracking SPIRV-Tools work
with GitHub
projects](https://github.com/KhronosGroup/SPIRV-Tools/blob/master/projects.md)
projects](https://github.com/KhronosGroup/SPIRV-Tools/blob/master/docs/projects.md)
for more.
To report a new bug or request a new feature, please file a GitHub issue. Please
......
......@@ -3,10 +3,10 @@ use_relative_paths = True
vars = {
'github': 'https://github.com',
'effcee_revision': 'b83b58d177b797edd1f94c5f10837f2cc2863f0a',
'googletest_revision': '2f42d769ad1b08742f7ccb5ad4dd357fc5ff248c',
're2_revision': 'e356bd3f80e0c15c1050323bb5a2d0f8ea4845f4',
'spirv_headers_revision': '123dc278f204f8e833e1a88d31c46d0edf81d4b2',
'effcee_revision': 'cd25ec17e9382f99a895b9ef53ff3c277464d07d',
'googletest_revision': 'f2fb48c3b3d79a75a88a99fba6576b25d42ec528',
're2_revision': '5bd613749fd530b576b890283bfb6bc6ea6246cb',
'spirv_headers_revision': '842ec90674627ed2ffef609e3cd79d1562eded01',
}
deps = {
......
......@@ -26,7 +26,7 @@ headers, and XML registry.
<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)
[More downloads](docs/downloads.md)
## Versioning SPIRV-Tools
......@@ -59,7 +59,7 @@ version. An API call reports the software version as a C-style string.
IDs or types is performed, except to check literal arguments to
`OpConstant`, `OpSpecConstant`, and `OpSwitch`.
See [`syntax.md`](syntax.md) for the assembly language syntax.
See [`docs/syntax.md`](docs/syntax.md) for the assembly language syntax.
### Validator
......@@ -171,7 +171,7 @@ specific work is tracked via issues and sometimes in one of the
(To provide feedback on the SPIR-V _specification_, file an issue on the
[SPIRV-Headers][spirv-headers] GitHub repository.)
See [`projects.md`](projects.md) to see how we use the
See [`docs/projects.md`](docs/projects.md) to see how we use the
[GitHub Project
feature](https://help.github.com/articles/tracking-the-progress-of-your-work-with-projects/)
to organize planned and in-progress work.
......@@ -255,9 +255,9 @@ Those binaries are automatically uploaded by the buildbots after successful
testing and they always reflect the current top of the tree of the master
branch.
The project uses [CMake][cmake] to generate platform-specific build
configurations. Assume that `<spirv-dir>` is the root directory of the checked
out code:
In order to build the code, you first need to sync the external repositories
that it depends on. Assume that `<spirv-dir>` is the root directory of the
checked out code:
```sh
cd <spirv-dir>
......@@ -266,26 +266,44 @@ git clone https://github.com/google/effcee.git external/effcee
git clone https://github.com/google/re2.git external/re2
git clone https://github.com/google/googletest.git external/googletest # optional
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.
### Build using CMake
You can build The project using [CMake][cmake] to generate platform-specific
build configurations.
```sh
cd <spirv-dir>
mkdir build && cd build
cmake [-G <platform-generator>] <spirv-dir>
```
Once the build files have been generated, build using your preferred
development environment.
### Build using Bazel
You can also use [Bazel](https://bazel.build/) to build the project.
```sh
cd <spirv-dir>
bazel build :all
```
### 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.
- [CMake](http://www.cmake.org/): if using CMake for generating compilation
targets, you need to install CMake Version 2.8.12 or later.
- [Python 3](http://www.python.org/): for utility scripts and running the test
suite.
- [Bazel](https://baze.build/) (optional): if building the source with Bazel,
you need to install Bazel Version 0.29.1 on your machine. Other versions may
also work, but are not verified.
SPIRV-Tools is regularly tested with the the following compilers:
......
local_repository(
name = "spirv_headers",
path = "external/spirv-headers",
)
local_repository(
name = "com_google_googletest",
path = "external/googletest",
)
local_repository(
name = "com_googlesource_code_re2",
path = "external/re2",
)
local_repository(
name = "com_google_effcee",
path = "external/effcee",
)
COMMON_COPTS = [
"-DSPIRV_CHECK_CONTEXT",
"-DSPIRV_COLOR_TERMINAL",
] + select({
"@bazel_tools//src/conditions:windows": [""],
"//conditions:default": [
"-DSPIRV_LINUX",
"-DSPIRV_TIMER_ENABLED",
"-Wall",
"-Wextra",
"-Wnon-virtual-dtor",
"-Wno-missing-field-initializers",
"-Werror",
"-std=c++11",
"-fvisibility=hidden",
"-fno-exceptions",
"-fno-rtti",
"-Wno-long-long",
"-Wshadow",
"-Wundef",
"-Wconversion",
"-Wno-sign-conversion",
],
})
TEST_COPTS = COMMON_COPTS + select({
"@bazel_tools//src/conditions:windows": [
# Disable C4503 "decorated name length exceeded" warning,
# triggered by some heavily templated types.
# We don't care much about that in test code.
# Important to do since we have warnings-as-errors.
"/wd4503"
],
"//conditions:default": [
"-Wno-undef",
"-Wno-self-assign",
"-Wno-shadow",
"-Wno-unused-parameter"
],
})
DEBUGINFO_GRAMMAR_JSON_FILE = "source/extinst.debuginfo.grammar.json"
def generate_core_tables(version = None):
if not version:
fail("Must specify version", "version")
grammars = [
"@spirv_headers//:spirv_core_grammar_" + version,
DEBUGINFO_GRAMMAR_JSON_FILE,
]
outs = [
"core.insts-{}.inc".format(version),
"operand.kinds-{}.inc".format(version),
]
fmtargs = grammars + outs
native.genrule(
name = "gen_core_tables_" + version,
srcs = grammars,
outs = outs,
cmd = (
"$(location :generate_grammar_tables) " +
"--spirv-core-grammar=$(location {0}) " +
"--extinst-debuginfo-grammar=$(location {1}) " +
"--core-insts-output=$(location {2}) " +
"--operand-kinds-output=$(location {3})"
).format(*fmtargs),
tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"],
)
def generate_enum_string_mapping(version = None):
if not version:
fail("Must specify version", "version")
grammars = [
"@spirv_headers//:spirv_core_grammar_" + version,
DEBUGINFO_GRAMMAR_JSON_FILE,
]
outs = [
"extension_enum.inc",
"enum_string_mapping.inc",
]
fmtargs = grammars + outs
native.genrule(
name = "gen_enum_string_mapping",
srcs = grammars,
outs = outs,
cmd = (
"$(location :generate_grammar_tables) " +
"--spirv-core-grammar=$(location {0}) " +
"--extinst-debuginfo-grammar=$(location {1}) " +
"--extension-enum-output=$(location {2}) " +
"--enum-string-mapping-output=$(location {3})"
).format(*fmtargs),
tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"],
)
def generate_opencl_tables(version = None):
if not version:
fail("Must specify version", "version")
grammars = [
"@spirv_headers//:spirv_opencl_grammar_" + version,
]
outs = ["opencl.std.insts.inc"]
fmtargs = grammars + outs
native.genrule(
name = "gen_opencl_tables_" + version,
srcs = grammars,
outs = outs,
cmd = (
"$(location :generate_grammar_tables) " +
"--extinst-opencl-grammar=$(location {0}) " +
"--opencl-insts-output=$(location {1})"
).format(*fmtargs),
tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"],
)
def generate_glsl_tables(version = None):
if not version:
fail("Must specify version", "version")
grammars = [
"@spirv_headers//:spirv_glsl_grammar_" + version,
]
outs = ["glsl.std.450.insts.inc"]
fmtargs = grammars + outs
native.genrule(
name = "gen_glsl_tables_" + version,
srcs = grammars,
outs = outs,
cmd = (
"$(location :generate_grammar_tables) " +
"--extinst-glsl-grammar=$(location {0}) " +
"--glsl-insts-output=$(location {1})"
).format(*fmtargs),
tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"],
)
def generate_vendor_tables(extension = None):
if not extension:
fail("Must specify extension", "extension")
extension_rule = extension.replace("-", "_")
grammars = ["source/extinst.{}.grammar.json".format(extension)]
outs = ["{}.insts.inc".format(extension)]
fmtargs = grammars + outs
native.genrule(
name = "gen_vendor_tables_" + extension_rule,
srcs = grammars,
outs = outs,
cmd = (
"$(location :generate_grammar_tables) " +
"--extinst-vendor-grammar=$(location {0}) " +
"--vendor-insts-output=$(location {1})"
).format(*fmtargs),
tools = [":generate_grammar_tables"],
visibility = ["//visibility:private"],
)
def generate_extinst_lang_headers(name, grammar = None):
if not grammar:
fail("Must specify grammar", "grammar")
fmtargs = [name]
native.genrule(
name = "gen_extinst_lang_headers_" + name,
srcs = [grammar],
outs = [name + ".h"],
cmd = (
"$(location :generate_language_headers) " +
"--extinst-name={0} " +
"--extinst-grammar=$< " +
"--extinst-output-base=$(@D)/{0}"
).format(*fmtargs),
tools = [":generate_language_headers"],
visibility = ["//visibility:private"],
)
def base_test(name, srcs, deps = []):
if srcs == []:
return
if name[-5:] != "_test":
name = name + "_test"
native.cc_test(
name = "base_" + name,
srcs = srcs,
compatible_with = [],
copts = TEST_COPTS,
size = "large",
deps = [
":test_common",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
"@com_google_effcee//:effcee",
] + deps,
)
def link_test(name, srcs, deps = []):
if name[-5:] != "_test":
name = name + "_test"
native.cc_test(
name = "link_" + name,
srcs = srcs,
compatible_with = [],
copts = TEST_COPTS,
size = "large",
deps = [
":link_test_common",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
"@com_google_effcee//:effcee",
] + deps,
)
def opt_test(name, srcs, deps = []):
if name[-5:] != "_test":
name = name + "_test"
native.cc_test(
name = "opt_" + name,
srcs = srcs,
compatible_with = [],
copts = TEST_COPTS,
size = "large",
deps = [
":opt_test_common",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
"@com_google_effcee//:effcee",
] + deps,
)
def reduce_test(name, srcs, deps = []):
if name[-5:] != "_test":
name = name + "_test"
native.cc_test(
name = "reduce_" + name,
srcs = srcs,
compatible_with = [],
copts = TEST_COPTS,
size = "large",
deps = [
":reduce_test_common",
":spirv_tools_reduce",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
"@com_google_effcee//:effcee",
] + deps,
)
def util_test(name, srcs, deps = []):
if name[-5:] != "_test":
name = name + "_test"
native.cc_test(
name = "util_" + name,
srcs = srcs,
compatible_with = [],
copts = TEST_COPTS,
size = "large",
deps = [
":opt_test_common",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
"@com_google_effcee//:effcee",
] + deps,
)
def val_test(name, srcs = [], copts = [], deps = [], **kwargs):
if name[-5:] != "_test":
name = name + "_test"
if name[:4] != "val_":
name = "val_" + name
native.cc_test(
name = name,
srcs = srcs,
compatible_with = [],
copts = TEST_COPTS + copts,
size = "large",
deps = [
":val_test_common",
"@com_google_googletest//:gtest_main",
"@com_google_googletest//:gtest",
"@com_google_effcee//:effcee",
] + deps,
**kwargs
)
spirv-tools (2019.4+git20191022-1) unstable; urgency=medium
* Sync with upstream/stable 02910ffdffaa.
* control: Bump spirv-headers build dependency.
-- Timo Aaltonen <tjaalton@debian.org> Tue, 19 Nov 2019 23:58:49 +0200
spirv-tools (2019.4-1) unstable; urgency=medium
* New upstream release.
......
......@@ -5,7 +5,7 @@ Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
Build-Depends: debhelper (>=10),
cmake,
python3-dev,
spirv-headers (>= 1.4.1+git20190816),
spirv-headers (>= 1.5.1-2),
Standards-Version: 4.1.3
Homepage: https://github.com/KhronosGroup/SPIRV-Tools
Vcs-Git: https://salsa.debian.org/git/xorg-team/vulkan/spirv-tools.git
......
......@@ -23,8 +23,9 @@
// communicate with shaders instrumented by passes created by:
//
// CreateInstBindlessCheckPass
// CreateInstBuffAddrCheckPass
//
// More detailed documentation of this routine can be found in optimizer.hpp
// More detailed documentation of these routines can be found in optimizer.hpp
namespace spvtools {
......@@ -157,6 +158,12 @@ static const int kInst2BindlessUninitOutDescIndex = kInst2StageOutCnt + 1;
static const int kInst2BindlessUninitOutUnused = kInst2StageOutCnt + 2;
static const int kInst2BindlessUninitOutCnt = kInst2StageOutCnt + 3;
// A buffer address unalloc error will output the 64-bit pointer in
// two 32-bit pieces, lower bits first.
static const int kInst2BuffAddrUnallocOutDescPtrLo = kInst2StageOutCnt + 1;
static const int kInst2BuffAddrUnallocOutDescPtrHi = kInst2StageOutCnt + 2;
static const int kInst2BuffAddrUnallocOutCnt = kInst2StageOutCnt + 3;
// DEPRECATED
static const int kInstBindlessOutDescIndex = kInstStageOutCnt + 1;
static const int kInstBindlessOutDescBound = kInstStageOutCnt + 2;
......@@ -171,6 +178,7 @@ static const int kInst2MaxOutCnt = kInst2StageOutCnt + 3;
// These are the possible validation error codes.
static const int kInstErrorBindlessBounds = 0;
static const int kInstErrorBindlessUninit = 1;
static const int kInstErrorBuffAddrUnallocRef = 2;
// Direct Input Buffer Offsets
//
......@@ -187,14 +195,16 @@ static const int kDebugInputDataOffset = 0;
// These are the bindings for the different buffers which are
// read or written by the instrumentation passes.
//
// This is the output buffer written by InstBindlessCheckPass
// and possibly other future validations.
// This is the output buffer written by InstBindlessCheckPass,
// InstBuffAddrCheckPass, and possibly other future validations.
static const int kDebugOutputBindingStream = 0;
// The binding for the input buffer read by InstBindlessCheckPass and
// possibly other future validations.
// The binding for the input buffer read by InstBindlessCheckPass.
static const int kDebugInputBindingBindless = 1;
// The binding for the input buffer read by InstBuffAddrCheckPass.
static const int kDebugInputBindingBuffAddr = 2;
// Bindless Validation Input Buffer Format
//
// An input buffer for bindless validation consists of a single array of
......@@ -216,6 +226,31 @@ static const int kDebugInputBindlessOffsetReserved = 0;
// Data[ Data[ s + kDebugInputBindlessOffsetLengths ] + b ]
static const int kDebugInputBindlessOffsetLengths = 1;
// Buffer Device Address Input Buffer Format
//
// An input buffer for buffer device address validation consists of a single
// array of unsigned 64-bit integers we will call Data[]. This array is
// formatted as follows:
//
// At offset kDebugInputBuffAddrPtrOffset is a list of sorted valid buffer
// addresses. The list is terminated with the address 0xffffffffffffffff.
// If 0x0 is not a valid buffer address, this address is inserted at the
// start of the list.
//
static const int kDebugInputBuffAddrPtrOffset = 1;
//
// At offset kDebugInputBuffAddrLengthOffset in Data[] is a single uint64 which
// gives an offset to the start of the buffer length data. More
// specifically, for a buffer whose pointer is located at input buffer offset
// i, the length is located at:
//
// Data[ i - kDebugInputBuffAddrPtrOffset
// + Data[ kDebugInputBuffAddrLengthOffset ] ]
//
// The length associated with the 0xffffffffffffffff address is zero. If
// not a valid buffer, the length associated with the 0x0 address is zero.
static const int kDebugInputBuffAddrLengthOffset = 0;
} // namespace spvtools
#endif // INCLUDE_SPIRV_TOOLS_INSTRUMENT_HPP_
......@@ -433,6 +433,7 @@ typedef enum {
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_ENV_UNIVERSAL_1_5, // SPIR-V 1.5 latest revision, no other restrictions.
} spv_target_env;
// SPIR-V Validator can be parameterized with the following Universal Limits.
......@@ -611,6 +612,11 @@ SPIRV_TOOLS_EXPORT spv_fuzzer_options spvFuzzerOptionsCreate();
// Destroys the given fuzzer options object.
SPIRV_TOOLS_EXPORT void spvFuzzerOptionsDestroy(spv_fuzzer_options options);
// Enables running the validator after every transformation is applied during
// a replay.
SPIRV_TOOLS_EXPORT void spvFuzzerOptionsEnableReplayValidation(
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(
......
......@@ -214,6 +214,11 @@ class FuzzerOptions {
return options_;
}
// See spvFuzzerOptionsEnableReplayValidation.
void enable_replay_validation() {
spvFuzzerOptionsEnableReplayValidation(options_);
}
// See spvFuzzerOptionsSetRandomSeed.
void set_random_seed(uint32_t seed) {
spvFuzzerOptionsSetRandomSeed(options_, seed);
......
......@@ -68,6 +68,11 @@ class Optimizer {
// The constructed instance will have an empty message consumer, which just
// ignores all messages from the library. Use SetMessageConsumer() to supply
// one if messages are of concern.
//
// For collections of passes that are meant to transform the input into
// another execution environment, then the source environment should be
// supplied. e.g. for VulkanToWebGPUPasses the environment should be
// SPV_ENV_VULKAN_1_1 not SPV_ENV_WEBGPU_0.
explicit Optimizer(spv_target_env env);
// Disables copy/move constructor/assignment operations.
......@@ -674,6 +679,22 @@ Optimizer::PassToken CreateLoopUnrollPass(bool fully_unroll, int factor = 0);
// processed (see IsSSATargetVar for details).
Optimizer::PassToken CreateSSARewritePass();
// Create pass to convert relaxed precision instructions to half precision.
// This pass converts as many relaxed float32 arithmetic operations to half as
// possible. It converts any float32 operands to half if needed. It converts
// any resulting half precision values back to float32 as needed. No variables
// are changed. No image operations are changed.
//
// Best if run late since it will generate better code with unneeded function
// scope loads and stores and composite inserts and extracts removed. Also best
// if followed by instruction simplification, redundancy elimination and DCE.
Optimizer::PassToken CreateConvertRelaxedToHalfPass();
// Create relax float ops pass.
// This pass decorates all float32 result instructions with RelaxedPrecision
// if not already so decorated.
Optimizer::PassToken CreateRelaxFloatOpsPass();
// Create copy propagate arrays pass.
// This pass looks to copy propagate memory references for arrays. It looks
// for specific code patterns to recognize array copies.
......@@ -729,6 +750,30 @@ Optimizer::PassToken CreateInstBindlessCheckPass(
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 instrument physical buffer address checking
// This pass instruments all physical buffer address references to check that
// all referenced bytes fall in a valid buffer. 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 buffer
// address validation in the Vulkan validation layers.
//
// Dead code elimination should be run after this pass as the original,
// potentially invalid code is not removed and could cause undefined behavior,
// including crashes. Instruction simplification would likely also be
// beneficial. It is also generally recommended that this pass (and all
// instrumentation passes) be run after any legalization and optimization
// passes. This will give better analysis for the instrumentation and avoid
// potentially de-optimizing the instrument code, for example, inlining
// the debug record output function throughout the module.
//
// 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.
// |version| specifies the output buffer record format.
Optimizer::PassToken CreateInstBuffAddrCheckPass(uint32_t desc_set,
uint32_t shader_id,
uint32_t version = 2);
// Create a pass to upgrade to the VulkanKHR memory model.
// This pass upgrades the Logical GLSL450 memory model to Logical VulkanKHR.
// Additionally, it modifies memory, image, atomic and barrier operations to
......@@ -795,6 +840,15 @@ Optimizer::PassToken CreateGraphicsRobustAccessPass();
// for the first index.
Optimizer::PassToken CreateDescriptorScalarReplacementPass();
// Create a pass to replace all OpKill instruction with a function call to a
// function that has a single OpKill. This allows more code to be inlined.
Optimizer::PassToken CreateWrapOpKillPass();
// Replaces the extensions VK_AMD_shader_ballot,VK_AMD_gcn_shader, and
// VK_AMD_shader_trinary_minmax with equivalent code using core instructions and
// capabilities.
Optimizer::PassToken CreateAmdExtToKhrPass();
} // namespace spvtools
#endif // INCLUDE_SPIRV_TOOLS_OPTIMIZER_HPP_