2019-09-24 19:56:59 +00:00
|
|
|
load(
|
|
|
|
":build_defs.bzl",
|
2022-12-20 15:54:46 +00:00
|
|
|
"CLDEBUGINFO100_GRAMMAR_JSON_FILE",
|
2019-09-24 19:56:59 +00:00
|
|
|
"COMMON_COPTS",
|
|
|
|
"DEBUGINFO_GRAMMAR_JSON_FILE",
|
2021-09-15 18:38:53 +00:00
|
|
|
"SHDEBUGINFO100_GRAMMAR_JSON_FILE",
|
2019-09-24 19:56:59 +00:00
|
|
|
"TEST_COPTS",
|
|
|
|
"generate_core_tables",
|
|
|
|
"generate_enum_string_mapping",
|
|
|
|
"generate_extinst_lang_headers",
|
|
|
|
"generate_glsl_tables",
|
|
|
|
"generate_opencl_tables",
|
|
|
|
"generate_vendor_tables",
|
2022-12-20 15:54:46 +00:00
|
|
|
"incompatible_with",
|
2019-09-24 19:56:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
package(
|
|
|
|
default_visibility = ["//visibility:private"],
|
2022-12-20 15:54:46 +00:00
|
|
|
features = [
|
|
|
|
"layering_check",
|
|
|
|
],
|
2019-09-24 19:56:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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"],
|
|
|
|
)
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_core_tables(version = "unified1")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_enum_string_mapping(version = "unified1")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_opencl_tables(version = "unified1")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_glsl_tables(version = "unified1")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(extension = "spv-amd-shader-explicit-vertex-parameter")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(extension = "spv-amd-shader-trinary-minmax")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(extension = "spv-amd-gcn-shader")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(extension = "spv-amd-shader-ballot")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(extension = "debuginfo")
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(extension = "nonsemantic.clspvreflection")
|
2019-12-19 22:16:26 +00:00
|
|
|
|
2024-03-15 17:46:42 +00:00
|
|
|
generate_vendor_tables(extension = "nonsemantic.vkspreflection")
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(
|
|
|
|
extension = "opencl.debuginfo.100",
|
|
|
|
operand_kind_prefix = "CLDEBUG100_",
|
|
|
|
)
|
2021-07-12 09:51:08 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_vendor_tables(
|
|
|
|
extension = "nonsemantic.shader.debuginfo.100",
|
|
|
|
operand_kind_prefix = "SHDEBUG100_",
|
|
|
|
)
|
2020-07-30 16:08:53 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_extinst_lang_headers(
|
|
|
|
name = "DebugInfo",
|
|
|
|
grammar = DEBUGINFO_GRAMMAR_JSON_FILE,
|
|
|
|
)
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_extinst_lang_headers(
|
|
|
|
name = "OpenCLDebugInfo100",
|
|
|
|
grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE,
|
|
|
|
)
|
2019-12-19 22:16:26 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
generate_extinst_lang_headers(
|
|
|
|
name = "NonSemanticShaderDebugInfo100",
|
|
|
|
grammar = SHDEBUGINFO100_GRAMMAR_JSON_FILE,
|
|
|
|
)
|
2021-07-12 09:51:08 +00:00
|
|
|
|
2019-09-24 19:56:59 +00:00
|
|
|
py_binary(
|
|
|
|
name = "generate_registry_tables",
|
|
|
|
srcs = ["utils/generate_registry_tables.py"],
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "generators_inc",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = ["@spirv_headers//:spirv_xml_registry"],
|
|
|
|
outs = ["generators.inc"],
|
2022-12-20 15:54:46 +00:00
|
|
|
cmd = "$(location :generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)",
|
|
|
|
cmd_bat = "$(location :generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)",
|
2023-06-21 19:32:27 +00:00
|
|
|
tools = [":generate_registry_tables"],
|
2019-09-24 19:56:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
py_binary(
|
|
|
|
name = "update_build_version",
|
|
|
|
srcs = ["utils/update_build_version.py"],
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "build_version_inc",
|
2023-03-09 17:24:20 +00:00
|
|
|
srcs = ["CHANGES"],
|
2019-09-24 19:56:59 +00:00
|
|
|
outs = ["build-version.inc"],
|
2023-03-09 17:24:20 +00:00
|
|
|
cmd = "SOURCE_DATE_EPOCH=0 $(location :update_build_version) $(location CHANGES) $(location build-version.inc)",
|
|
|
|
cmd_bat = "set SOURCE_DATE_EPOCH=0 && $(location :update_build_version) $(location CHANGES) $(location build-version.inc)",
|
2023-06-21 19:32:27 +00:00
|
|
|
tools = [":update_build_version"],
|
2019-09-24 19:56:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Libraries
|
|
|
|
|
|
|
|
cc_library(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "spirv_tools",
|
2019-09-24 19:56:59 +00:00
|
|
|
hdrs = [
|
2022-12-20 15:54:46 +00:00
|
|
|
"include/spirv-tools/libspirv.h",
|
|
|
|
"include/spirv-tools/libspirv.hpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
includes = ["include"],
|
|
|
|
linkstatic = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "spirv_tools_internal",
|
|
|
|
srcs = glob([
|
|
|
|
"source/*.cpp",
|
|
|
|
"source/util/*.cpp",
|
|
|
|
"source/val/*.cpp",
|
|
|
|
]) + [
|
|
|
|
":build_version_inc",
|
2019-09-24 19:56:59 +00:00
|
|
|
":gen_core_tables_unified1",
|
|
|
|
":gen_enum_string_mapping",
|
|
|
|
":gen_extinst_lang_headers_DebugInfo",
|
2021-09-15 18:38:53 +00:00
|
|
|
":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100",
|
2022-12-20 15:54:46 +00:00
|
|
|
":gen_extinst_lang_headers_OpenCLDebugInfo100",
|
2019-09-24 19:56:59 +00:00
|
|
|
":gen_glsl_tables_unified1",
|
|
|
|
":gen_opencl_tables_unified1",
|
|
|
|
":gen_vendor_tables_debuginfo",
|
2020-07-30 16:08:53 +00:00
|
|
|
":gen_vendor_tables_nonsemantic_clspvreflection",
|
2024-03-15 17:46:42 +00:00
|
|
|
":gen_vendor_tables_nonsemantic_vkspreflection",
|
2021-09-15 18:38:53 +00:00
|
|
|
":gen_vendor_tables_nonsemantic_shader_debuginfo_100",
|
2022-12-20 15:54:46 +00:00
|
|
|
":gen_vendor_tables_opencl_debuginfo_100",
|
2019-09-24 19:56:59 +00:00
|
|
|
":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",
|
2023-06-21 19:32:27 +00:00
|
|
|
":generators_inc",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
2022-12-20 15:54:46 +00:00
|
|
|
hdrs = [
|
2019-09-24 19:56:59 +00:00
|
|
|
"include/spirv-tools/libspirv.h",
|
|
|
|
"include/spirv-tools/libspirv.hpp",
|
2022-12-20 15:54:46 +00:00
|
|
|
":gen_extinst_lang_headers_DebugInfo",
|
|
|
|
":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100",
|
|
|
|
":gen_extinst_lang_headers_OpenCLDebugInfo100",
|
|
|
|
] + glob([
|
2019-09-24 19:56:59 +00:00
|
|
|
"source/*.h",
|
|
|
|
"source/util/*.h",
|
|
|
|
"source/val/*.h",
|
|
|
|
]),
|
|
|
|
copts = COMMON_COPTS,
|
2022-12-20 15:54:46 +00:00
|
|
|
includes = ["include"],
|
2019-09-24 19:56:59 +00:00
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
"@spirv_headers//:spirv_common_headers",
|
2022-11-04 21:27:10 +00:00
|
|
|
"@spirv_headers//:spirv_cpp11_headers",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "spirv_tools_opt",
|
2019-09-24 19:56:59 +00:00
|
|
|
hdrs = [
|
2022-12-20 15:54:46 +00:00
|
|
|
"include/spirv-tools/optimizer.hpp",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools",
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_opt_internal",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "spirv_tools_opt_internal",
|
|
|
|
srcs = glob(["source/opt/*.cpp"]) + [
|
|
|
|
":gen_vendor_tables_spv_amd_shader_ballot",
|
|
|
|
],
|
|
|
|
hdrs = glob(["source/opt/*.h"]) + [
|
2019-09-24 19:56:59 +00:00
|
|
|
"include/spirv-tools/optimizer.hpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
2019-09-24 19:56:59 +00:00
|
|
|
"@spirv_headers//:spirv_common_headers",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "spirv_tools_reduce",
|
|
|
|
srcs = glob(["source/reduce/*.cpp"]),
|
|
|
|
hdrs = glob(["source/reduce/*.h"]),
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
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 = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "spirv_tools_lint_internal",
|
|
|
|
srcs = glob([
|
|
|
|
"source/lint/*.cpp",
|
|
|
|
"source/lint/*.h",
|
|
|
|
]),
|
|
|
|
hdrs = ["include/spirv-tools/linter.hpp"] + glob([
|
|
|
|
"source/lint/*.h",
|
|
|
|
]),
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
includes = ["include"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2021-08-06 18:03:59 +00:00
|
|
|
cc_library(
|
|
|
|
name = "spirv_tools_lint",
|
|
|
|
hdrs = ["include/spirv-tools/linter.hpp"],
|
|
|
|
copts = COMMON_COPTS,
|
2022-12-20 15:54:46 +00:00
|
|
|
includes = ["include"],
|
2021-08-06 18:03:59 +00:00
|
|
|
linkstatic = 1,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools",
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_lint_internal",
|
2021-08-06 18:03:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-09-24 19:56:59 +00:00
|
|
|
cc_library(
|
|
|
|
name = "tools_util",
|
|
|
|
srcs = glob(["tools/util/*.cpp"]),
|
|
|
|
hdrs = glob(["tools/util/*.h"]),
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
deps = [":spirv_tools"],
|
|
|
|
)
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
cc_library(
|
|
|
|
name = "tools_io",
|
|
|
|
hdrs = ["tools/io.h"],
|
2024-10-28 17:31:54 +00:00
|
|
|
srcs = ["tools/io.cpp"],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = COMMON_COPTS,
|
|
|
|
)
|
|
|
|
|
2019-09-24 19:56:59 +00:00
|
|
|
# Tools
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "spirv-as",
|
|
|
|
srcs = [
|
|
|
|
"tools/as/as.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":tools_io",
|
2023-02-27 17:45:14 +00:00
|
|
|
":tools_util",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "spirv-dis",
|
|
|
|
srcs = [
|
|
|
|
"tools/dis/dis.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools",
|
2022-12-20 15:54:46 +00:00
|
|
|
":tools_io",
|
2023-02-27 17:45:14 +00:00
|
|
|
":tools_util",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2023-03-13 15:39:42 +00:00
|
|
|
cc_binary(
|
|
|
|
name = "spirv-objdump",
|
|
|
|
srcs = [
|
|
|
|
"tools/objdump/extract_source.cpp",
|
|
|
|
"tools/objdump/extract_source.h",
|
2023-06-21 19:32:27 +00:00
|
|
|
"tools/objdump/objdump.cpp",
|
2023-03-13 15:39:42 +00:00
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
2023-06-21 19:32:27 +00:00
|
|
|
":tools_io",
|
|
|
|
":tools_util",
|
2023-03-22 22:57:18 +00:00
|
|
|
"@spirv_headers//:spirv_cpp_headers",
|
2023-03-13 15:39:42 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-09-24 19:56:59 +00:00
|
|
|
cc_binary(
|
|
|
|
name = "spirv-val",
|
|
|
|
srcs = [
|
|
|
|
"tools/val/val.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":tools_io",
|
2019-09-24 19:56:59 +00:00
|
|
|
":tools_util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "spirv-opt",
|
|
|
|
srcs = [
|
|
|
|
"tools/opt/opt.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
|
|
|
":tools_io",
|
2019-09-24 19:56:59 +00:00
|
|
|
":tools_util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "spirv-reduce",
|
|
|
|
srcs = [
|
|
|
|
"tools/reduce/reduce.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
2019-09-24 19:56:59 +00:00
|
|
|
":spirv_tools_reduce",
|
2022-12-20 15:54:46 +00:00
|
|
|
":tools_io",
|
2019-09-24 19:56:59 +00:00
|
|
|
":tools_util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "spirv-link",
|
|
|
|
srcs = [
|
|
|
|
"tools/link/linker.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
2019-09-24 19:56:59 +00:00
|
|
|
":spirv_tools_link",
|
2022-12-20 15:54:46 +00:00
|
|
|
":tools_io",
|
2023-02-27 17:45:14 +00:00
|
|
|
":tools_util",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2021-08-06 18:03:59 +00:00
|
|
|
cc_binary(
|
|
|
|
name = "spirv-lint",
|
|
|
|
srcs = [
|
|
|
|
"tools/lint/lint.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_lint",
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_opt_internal",
|
|
|
|
":tools_io",
|
2021-08-06 18:03:59 +00:00
|
|
|
":tools_util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-09-24 19:56:59 +00:00
|
|
|
cc_binary(
|
|
|
|
name = "spirv-cfg",
|
|
|
|
srcs = [
|
|
|
|
"tools/cfg/bin_to_dot.cpp",
|
|
|
|
"tools/cfg/bin_to_dot.h",
|
|
|
|
"tools/cfg/cfg.cpp",
|
|
|
|
],
|
|
|
|
copts = COMMON_COPTS,
|
|
|
|
visibility = ["//visibility:public"],
|
2022-12-20 15:54:46 +00:00
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":tools_io",
|
2023-02-27 17:45:14 +00:00
|
|
|
":tools_util",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
2019-09-24 19:56:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Unit tests
|
|
|
|
|
|
|
|
cc_library(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "test_lib",
|
2019-09-24 19:56:59 +00:00
|
|
|
testonly = 1,
|
|
|
|
srcs = [
|
|
|
|
"test/unit_spirv.cpp",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
hdrs = [
|
|
|
|
"test/test_fixture.h",
|
2019-09-24 19:56:59 +00:00
|
|
|
"test/unit_spirv.h",
|
|
|
|
],
|
|
|
|
copts = TEST_COPTS,
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
# PCH (precompiled header) tests only work when using CMake and MSVC on Windows,
|
|
|
|
# so they will be skipped in the Bazel builds.
|
|
|
|
|
|
|
|
[cc_test(
|
|
|
|
name = "base_{testcase}_test".format(testcase = f[len("test/"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
|
|
|
srcs = [f],
|
2023-06-21 19:32:27 +00:00
|
|
|
copts = TEST_COPTS + ["-DTESTING"],
|
2019-09-24 19:56:59 +00:00
|
|
|
linkstatic = 1,
|
2022-12-20 15:54:46 +00:00
|
|
|
target_compatible_with = {
|
|
|
|
"test/timer_test.cpp": incompatible_with(["@bazel_tools//src/conditions:windows"]),
|
|
|
|
}.get(f, []),
|
2019-09-24 19:56:59 +00:00
|
|
|
deps = [
|
2023-06-21 19:32:27 +00:00
|
|
|
"tools_util",
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
|
|
|
":test_lib",
|
tools: Accept hex representation as binary input (#5870)
Sometimes when debugging or logging, SPIR-V may be dumped as a stream of
hex values. There are tools to convert such a stream to binary
(such as [1]) but they create an inconvenient extra step when for
example the disassembly of that hex stream is needed.
[1]: https://www.khronos.org/spir/visualizer/hexdump.html
In this change, the binary reader used by the tools is enhanced to
detect when the binary is actually a hex stream, and parse that instead.
The following formats are accepted, detected based on how the SPIR-V
magic number is output:
=== Words
If the first token of the hex stream is one of 0x07230203, 0x7230203,
x07230203, or x7230203, the hex stream is expected to consist of 32-bit
hex words prefixed with 0x or x. For example:
0x7230203, 0x10400, 0x180001, 0x79, 0x0
is parsed as:
0x07230203 0x00010400 0x00180001 0x00000079 0x00000000
Note that `,` is optional in the stream, but the hex values are expected
to be delimited by either `,` or whitespace.
=== Bytes With Prefix
If the first token of the hex stream is one of 0x07, 0x7, x07, x7, 0x03,
0x3, x03, or x3, the hex stream is expected to consist of 8-bit hex
bytes prefixed with 0x or x. If the first token has a value of 7, the
stream is big-endian. Otherwise it's little-endian. For example:
0x3, 0x2, 0x23, 0x7, 0x0, 0x4, 0x1, 0x0, 0x1, 0x0, 0x18, 0x0, 0x79, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
is parsed as:
0x07230203 0x00010400 0x00180001 0x00000079 0x00000000
Similar to "Words", `,` is optional in the stream, but the hex values
are expected to be delimited by either `,` or whitespace.
=== Bytes Without Prefix
If the first two characters of the hex stream is 07, or 03, the hex
stream is expected to consist of 8-bit hex bytes of 2 characters each.
If the first token is 07, the stream is big-endian. Otherwise it's
little-endian. Unlike the other modes, delimiter is optional (which
automatically handles 32-bit word streams), but no 0-padding is done.
For example, all of the following:
03, 02, 23, 07, 00, 04, 01, 00, 01, 00, 18, 00, 79, 00, 00, 00, 00, 00, 00, 00
03 02 23 07 00 04 01 00 01 00 18 00 79 00 00 00 00 00 00 00
03022307 00040100 01001800 79000000 00000000
07,23,02,03,00,01,04,00,00,18,00,01,00,00,00,79,00,00,00,00
07230203, 00010400, 00180001, 00000079, 00000000
are parsed as:
0x07230203 0x00010400 0x00180001 0x00000079 0x00000000
2024-11-04 14:57:37 +00:00
|
|
|
":tools_io",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
2022-12-20 15:54:46 +00:00
|
|
|
) for f in glob(
|
2023-06-21 19:32:27 +00:00
|
|
|
[
|
|
|
|
"test/*_test.cpp",
|
|
|
|
"test/tools/*_test.cpp",
|
|
|
|
],
|
2022-12-20 15:54:46 +00:00
|
|
|
exclude = [
|
|
|
|
"test/cpp_interface_test.cpp",
|
|
|
|
"test/pch_test.cpp",
|
|
|
|
],
|
|
|
|
)]
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
cc_test(
|
|
|
|
name = "base_cpp_interface_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["test/cpp_interface_test.cpp"],
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_opt_internal",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
"@spirv_headers//:spirv_cpp11_headers",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
2022-12-20 15:54:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "base_ilist_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["test/util/ilist_test.cpp"],
|
2019-09-24 19:56:59 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
2022-12-20 15:54:46 +00:00
|
|
|
":spirv_tools_internal",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
2022-12-20 15:54:46 +00:00
|
|
|
name = "link_test_lib",
|
2019-09-24 19:56:59 +00:00
|
|
|
testonly = 1,
|
2022-12-20 15:54:46 +00:00
|
|
|
hdrs = ["test/link/linker_fixture.h"],
|
2019-09-24 19:56:59 +00:00
|
|
|
copts = TEST_COPTS,
|
2022-12-20 15:54:46 +00:00
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_link",
|
|
|
|
":test_lib",
|
2024-06-18 17:52:50 +00:00
|
|
|
"@effcee//:effcee",
|
2024-06-24 18:17:34 +00:00
|
|
|
"@re2//:re2",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
[cc_test(
|
|
|
|
name = "link_{testcase}_test".format(testcase = f[len("test/link/"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":link_test_lib",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
2019-09-24 19:56:59 +00:00
|
|
|
) for f in glob(
|
2022-12-20 15:54:46 +00:00
|
|
|
["test/link/*_test.cpp"],
|
2019-09-24 19:56:59 +00:00
|
|
|
)]
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
[cc_test(
|
|
|
|
name = "lint_{testcase}_test".format(testcase = f[len("test/lint/"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
2021-08-06 18:03:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools",
|
|
|
|
":spirv_tools_lint_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
2021-08-06 18:03:59 +00:00
|
|
|
) for f in glob(
|
2022-12-20 15:54:46 +00:00
|
|
|
["test/lint/*_test.cpp"],
|
2021-08-06 18:03:59 +00:00
|
|
|
)]
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
cc_library(
|
|
|
|
name = "opt_test_lib",
|
|
|
|
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",
|
|
|
|
],
|
|
|
|
copts = TEST_COPTS,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
2024-06-18 17:52:50 +00:00
|
|
|
"@effcee//:effcee",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
[cc_test(
|
|
|
|
name = "opt_{testcase}_test".format(testcase = f[len("test/opt/"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":opt_test_lib",
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
|
|
|
":test_lib",
|
2024-06-18 17:52:50 +00:00
|
|
|
"@effcee//:effcee",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
) for f in glob(["test/opt/*_test.cpp"])]
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
[cc_test(
|
|
|
|
name = "opt_dom_tree_{testcase}_test".format(testcase = f[len("test/opt/dominator_tree/"):-len(".cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":opt_test_lib",
|
|
|
|
":spirv_tools_opt_internal",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
2019-09-24 19:56:59 +00:00
|
|
|
) for f in glob(
|
|
|
|
["test/opt/dominator_tree/*.cpp"],
|
|
|
|
exclude = ["test/opt/dominator_tree/pch_test_opt_dom.cpp"],
|
|
|
|
)]
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
[cc_test(
|
|
|
|
name = "opt_loop_{testcase}_test".format(testcase = f[len("test/opt/loop_optimizations/"):-len(".cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":opt_test_lib",
|
|
|
|
":spirv_tools",
|
|
|
|
":spirv_tools_opt_internal",
|
2024-06-18 17:52:50 +00:00
|
|
|
"@effcee//:effcee",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
2019-09-24 19:56:59 +00:00
|
|
|
) for f in glob(
|
|
|
|
["test/opt/loop_optimizations/*.cpp"],
|
|
|
|
exclude = ["test/opt/loop_optimizations/pch_test_opt_loop.cpp"],
|
|
|
|
)]
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
cc_library(
|
|
|
|
name = "reduce_test_lib",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = [
|
|
|
|
"test/reduce/reduce_test_util.cpp",
|
|
|
|
],
|
|
|
|
hdrs = ["test/reduce/reduce_test_util.h"],
|
|
|
|
copts = TEST_COPTS,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools",
|
|
|
|
":spirv_tools_opt_internal",
|
|
|
|
":spirv_tools_reduce",
|
|
|
|
":test_lib",
|
|
|
|
":tools_io",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
[cc_test(
|
|
|
|
name = "reduce_{testcase}_test".format(testcase = f[len("test/reduce/"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":reduce_test_lib",
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":spirv_tools_opt_internal",
|
|
|
|
":spirv_tools_reduce",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
) for f in glob(["test/reduce/*_test.cpp"])]
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
[cc_test(
|
|
|
|
name = "util_{testcase}_test".format(testcase = f[len("test/util/"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
) for f in glob(["test/util/*_test.cpp"])]
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "val_test_lib",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = [
|
|
|
|
"test/val/val_code_generator.cpp",
|
|
|
|
],
|
|
|
|
hdrs = [
|
|
|
|
"test/val/val_code_generator.h",
|
|
|
|
"test/val/val_fixtures.h",
|
|
|
|
],
|
|
|
|
copts = TEST_COPTS,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":test_lib",
|
|
|
|
],
|
|
|
|
)
|
2019-09-24 19:56:59 +00:00
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
[cc_test(
|
|
|
|
name = "val_{testcase}_test".format(testcase = f[len("test/val/val_"):-len("_test.cpp")]),
|
|
|
|
size = "small",
|
2019-09-24 19:56:59 +00:00
|
|
|
srcs = [f],
|
2022-12-20 15:54:46 +00:00
|
|
|
copts = TEST_COPTS,
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":test_lib",
|
|
|
|
":val_test_lib",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
2019-09-24 19:56:59 +00:00
|
|
|
) for f in glob(
|
2022-12-20 15:54:46 +00:00
|
|
|
["test/val/val_*_test.cpp"],
|
2019-09-24 19:56:59 +00:00
|
|
|
exclude = [
|
2022-12-20 15:54:46 +00:00
|
|
|
"test/val/val_capability_test.cpp",
|
|
|
|
"test/val/val_limits_test.cpp",
|
2019-09-24 19:56:59 +00:00
|
|
|
],
|
|
|
|
)]
|
|
|
|
|
2022-12-20 15:54:46 +00:00
|
|
|
cc_test(
|
|
|
|
name = "val_capability_test",
|
|
|
|
size = "large",
|
|
|
|
timeout = "long",
|
|
|
|
srcs = ["test/val/val_capability_test.cpp"],
|
|
|
|
copts = TEST_COPTS + ["-O3"],
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":spirv_tools_internal",
|
|
|
|
":test_lib",
|
|
|
|
":val_test_lib",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "val_limits_test",
|
|
|
|
size = "large",
|
|
|
|
timeout = "long",
|
|
|
|
srcs = ["test/val/val_limits_test.cpp"],
|
|
|
|
copts = TEST_COPTS + [
|
|
|
|
"-O3",
|
|
|
|
],
|
|
|
|
linkstatic = 1,
|
|
|
|
deps = [
|
|
|
|
":test_lib",
|
|
|
|
":val_test_lib",
|
2024-03-14 21:42:12 +00:00
|
|
|
"@googletest//:gtest",
|
|
|
|
"@googletest//:gtest_main",
|
2022-12-20 15:54:46 +00:00
|
|
|
],
|
|
|
|
)
|