mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated spirv-tools.
This commit is contained in:
187
3rdparty/spirv-tools/BUILD.gn
vendored
187
3rdparty/spirv-tools/BUILD.gn
vendored
@@ -657,132 +657,85 @@ group("SPIRV-Tools") {
|
||||
]
|
||||
}
|
||||
|
||||
if (!build_with_chromium) {
|
||||
googletest_dir = spirv_tools_googletest_dir
|
||||
|
||||
config("gtest_config") {
|
||||
include_dirs = [
|
||||
"${googletest_dir}/googletest",
|
||||
"${googletest_dir}/googletest/include",
|
||||
]
|
||||
}
|
||||
|
||||
static_library("gtest") {
|
||||
testonly = true
|
||||
# The tests are scoped to Chromium to avoid needing to write gtest integration.
|
||||
# See Chromium's third_party/googletest/BUILD.gn for a complete integration.
|
||||
if (build_with_chromium) {
|
||||
test("spvtools_test") {
|
||||
sources = [
|
||||
"${googletest_dir}/googletest/src/gtest-all.cc",
|
||||
"test/assembly_context_test.cpp",
|
||||
"test/assembly_format_test.cpp",
|
||||
"test/binary_destroy_test.cpp",
|
||||
"test/binary_endianness_test.cpp",
|
||||
"test/binary_header_get_test.cpp",
|
||||
"test/binary_parse_test.cpp",
|
||||
"test/binary_strnlen_s_test.cpp",
|
||||
"test/binary_to_text.literal_test.cpp",
|
||||
"test/binary_to_text_test.cpp",
|
||||
"test/comment_test.cpp",
|
||||
"test/enum_set_test.cpp",
|
||||
"test/enum_string_mapping_test.cpp",
|
||||
"test/ext_inst.debuginfo_test.cpp",
|
||||
"test/ext_inst.glsl_test.cpp",
|
||||
"test/ext_inst.opencl_test.cpp",
|
||||
"test/fix_word_test.cpp",
|
||||
"test/generator_magic_number_test.cpp",
|
||||
"test/hex_float_test.cpp",
|
||||
"test/immediate_int_test.cpp",
|
||||
"test/libspirv_macros_test.cpp",
|
||||
"test/name_mapper_test.cpp",
|
||||
"test/named_id_test.cpp",
|
||||
"test/opcode_make_test.cpp",
|
||||
"test/opcode_require_capabilities_test.cpp",
|
||||
"test/opcode_split_test.cpp",
|
||||
"test/opcode_table_get_test.cpp",
|
||||
"test/operand_capabilities_test.cpp",
|
||||
"test/operand_pattern_test.cpp",
|
||||
"test/operand_test.cpp",
|
||||
"test/target_env_test.cpp",
|
||||
"test/test_fixture.h",
|
||||
"test/text_advance_test.cpp",
|
||||
"test/text_destroy_test.cpp",
|
||||
"test/text_literal_test.cpp",
|
||||
"test/text_start_new_inst_test.cpp",
|
||||
"test/text_to_binary.annotation_test.cpp",
|
||||
"test/text_to_binary.barrier_test.cpp",
|
||||
"test/text_to_binary.constant_test.cpp",
|
||||
"test/text_to_binary.control_flow_test.cpp",
|
||||
"test/text_to_binary.debug_test.cpp",
|
||||
"test/text_to_binary.device_side_enqueue_test.cpp",
|
||||
"test/text_to_binary.extension_test.cpp",
|
||||
"test/text_to_binary.function_test.cpp",
|
||||
"test/text_to_binary.group_test.cpp",
|
||||
"test/text_to_binary.image_test.cpp",
|
||||
"test/text_to_binary.literal_test.cpp",
|
||||
"test/text_to_binary.memory_test.cpp",
|
||||
"test/text_to_binary.misc_test.cpp",
|
||||
"test/text_to_binary.mode_setting_test.cpp",
|
||||
"test/text_to_binary.pipe_storage_test.cpp",
|
||||
"test/text_to_binary.reserved_sampling_test.cpp",
|
||||
"test/text_to_binary.subgroup_dispatch_test.cpp",
|
||||
"test/text_to_binary.type_declaration_test.cpp",
|
||||
"test/text_to_binary_test.cpp",
|
||||
"test/text_word_get_test.cpp",
|
||||
"test/unit_spirv.cpp",
|
||||
"test/unit_spirv.h",
|
||||
]
|
||||
public_configs = [ ":gtest_config" ]
|
||||
}
|
||||
|
||||
config("gmock_config") {
|
||||
include_dirs = [
|
||||
"${googletest_dir}/googlemock",
|
||||
"${googletest_dir}/googlemock/include",
|
||||
"${googletest_dir}/googletest/include",
|
||||
]
|
||||
if (is_clang) {
|
||||
# TODO: Can remove this if/when the issue is fixed.
|
||||
# https://github.com/google/googletest/issues/533
|
||||
cflags = [ "-Wno-inconsistent-missing-override" ]
|
||||
}
|
||||
}
|
||||
|
||||
static_library("gmock") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"${googletest_dir}/googlemock/src/gmock-all.cc",
|
||||
]
|
||||
public_configs = [ ":gmock_config" ]
|
||||
}
|
||||
}
|
||||
|
||||
test("spvtools_test") {
|
||||
sources = [
|
||||
"test/assembly_context_test.cpp",
|
||||
"test/assembly_format_test.cpp",
|
||||
"test/binary_destroy_test.cpp",
|
||||
"test/binary_endianness_test.cpp",
|
||||
"test/binary_header_get_test.cpp",
|
||||
"test/binary_parse_test.cpp",
|
||||
"test/binary_strnlen_s_test.cpp",
|
||||
"test/binary_to_text.literal_test.cpp",
|
||||
"test/binary_to_text_test.cpp",
|
||||
"test/comment_test.cpp",
|
||||
"test/enum_set_test.cpp",
|
||||
"test/enum_string_mapping_test.cpp",
|
||||
"test/ext_inst.debuginfo_test.cpp",
|
||||
"test/ext_inst.glsl_test.cpp",
|
||||
"test/ext_inst.opencl_test.cpp",
|
||||
"test/fix_word_test.cpp",
|
||||
"test/generator_magic_number_test.cpp",
|
||||
"test/hex_float_test.cpp",
|
||||
"test/immediate_int_test.cpp",
|
||||
"test/libspirv_macros_test.cpp",
|
||||
"test/name_mapper_test.cpp",
|
||||
"test/named_id_test.cpp",
|
||||
"test/opcode_make_test.cpp",
|
||||
"test/opcode_require_capabilities_test.cpp",
|
||||
"test/opcode_split_test.cpp",
|
||||
"test/opcode_table_get_test.cpp",
|
||||
"test/operand_capabilities_test.cpp",
|
||||
"test/operand_pattern_test.cpp",
|
||||
"test/operand_test.cpp",
|
||||
"test/target_env_test.cpp",
|
||||
"test/test_fixture.h",
|
||||
"test/text_advance_test.cpp",
|
||||
"test/text_destroy_test.cpp",
|
||||
"test/text_literal_test.cpp",
|
||||
"test/text_start_new_inst_test.cpp",
|
||||
"test/text_to_binary.annotation_test.cpp",
|
||||
"test/text_to_binary.barrier_test.cpp",
|
||||
"test/text_to_binary.constant_test.cpp",
|
||||
"test/text_to_binary.control_flow_test.cpp",
|
||||
"test/text_to_binary.debug_test.cpp",
|
||||
"test/text_to_binary.device_side_enqueue_test.cpp",
|
||||
"test/text_to_binary.extension_test.cpp",
|
||||
"test/text_to_binary.function_test.cpp",
|
||||
"test/text_to_binary.group_test.cpp",
|
||||
"test/text_to_binary.image_test.cpp",
|
||||
"test/text_to_binary.literal_test.cpp",
|
||||
"test/text_to_binary.memory_test.cpp",
|
||||
"test/text_to_binary.misc_test.cpp",
|
||||
"test/text_to_binary.mode_setting_test.cpp",
|
||||
"test/text_to_binary.pipe_storage_test.cpp",
|
||||
"test/text_to_binary.reserved_sampling_test.cpp",
|
||||
"test/text_to_binary.subgroup_dispatch_test.cpp",
|
||||
"test/text_to_binary.type_declaration_test.cpp",
|
||||
"test/text_to_binary_test.cpp",
|
||||
"test/text_word_get_test.cpp",
|
||||
"test/unit_spirv.cpp",
|
||||
"test/unit_spirv.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":spvtools",
|
||||
":spvtools_language_header_unified1",
|
||||
":spvtools_val",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
deps += [
|
||||
deps = [
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
"//testing/gtest:gtest_main",
|
||||
":spvtools",
|
||||
":spvtools_language_header_unified1",
|
||||
":spvtools_val",
|
||||
]
|
||||
} else {
|
||||
deps += [
|
||||
":gmock",
|
||||
":gtest",
|
||||
]
|
||||
sources += [ "${googletest_dir}/googletest/src/gtest_main.cc" ]
|
||||
}
|
||||
|
||||
if (is_clang) {
|
||||
cflags_cc = [ "-Wno-self-assign" ]
|
||||
}
|
||||
if (is_clang) {
|
||||
cflags_cc = [ "-Wno-self-assign" ]
|
||||
}
|
||||
|
||||
configs += [ ":spvtools_internal_config" ]
|
||||
configs += [ ":spvtools_internal_config" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (spirv_tools_standalone) {
|
||||
|
||||
39
3rdparty/spirv-tools/CHANGES
vendored
39
3rdparty/spirv-tools/CHANGES
vendored
@@ -1,7 +1,42 @@
|
||||
Revision history for SPIRV-Tools
|
||||
|
||||
v2019.2-dev 2019-01-07
|
||||
- Start v2019.2-dev
|
||||
2019.3-dev 2019-02-20
|
||||
- Start 2019.3-dev
|
||||
|
||||
v2019.2 2019-02-20
|
||||
- General:
|
||||
- Support SPV_EXT_physical_storage_buffer
|
||||
- A number of memory leak have been fixed.
|
||||
- Removed use of deprecated Google test macro:
|
||||
- Changed the BUILD.gn to only build tests in Chromium.
|
||||
- Optimizer
|
||||
- Upgrade memory model improvments for modf and frexp.
|
||||
- Add a new pass to move loads closer to their uses: code sinking.
|
||||
- Invalidating the type manager now invalidates the constnat manager.
|
||||
- Expand instrumentation pass for bindless bounds checking to runtime-sized descriptor arrays.
|
||||
- Add a new pass that removes members from structs that are not used: dead member elimination.
|
||||
Fixes:
|
||||
- #2292: Remove undefined behaviour when folding bit shifts.
|
||||
- #2294: Fixes for instrumentation code.
|
||||
- #2293: Fix overflow when folding -INT_MIN.
|
||||
- #2374: Don't merge unreachable blocks when merging blocks.
|
||||
- Validator
|
||||
- Support SPV_KHR_no_integer_wrap and related decorations.
|
||||
- Validate Vulkan rules for OpTypeRuntimeArray.
|
||||
- Validate NonWritable decoration.
|
||||
- Many WebGPU specific validation rules were added.
|
||||
- Validate variable pointer related function call rules.
|
||||
- Better error messages.
|
||||
Fixes:
|
||||
- #2307: Check forwards references in OpTypeArray.
|
||||
- #2315, #2303: Fixed the layout check for relaxed layout.
|
||||
- #1628: Emit an error when an OpSwitch target is not an OpLabel.
|
||||
- Reduce
|
||||
- Added more documentation for spirv-reduce.
|
||||
- Add ability to remove OpPhi instructions.
|
||||
- Add ability to merge two basic blocks.
|
||||
- Add ability to remove unused functions and unused basic blocks.
|
||||
Fixes:
|
||||
|
||||
v2019.1 2019-01-07
|
||||
- General:
|
||||
|
||||
2
3rdparty/spirv-tools/CMakeLists.txt
vendored
2
3rdparty/spirv-tools/CMakeLists.txt
vendored
@@ -176,7 +176,7 @@ if(NOT COMMAND find_host_program)
|
||||
endmacro()
|
||||
endif()
|
||||
|
||||
find_host_package(PythonInterp)
|
||||
find_host_package(PythonInterp 2.7 REQUIRED)
|
||||
|
||||
# Check for symbol exports on Linux.
|
||||
# At the moment, this check will fail on the OSX build machines for the Android NDK.
|
||||
|
||||
@@ -1 +1 @@
|
||||
"v2019.2-dev", "SPIRV-Tools v2019.2-dev f237f9cff729a0b78c8e979a4da7f4428bfeeaf2"
|
||||
"v2019.2", "SPIRV-Tools v2019.2 5ba4893f729c5c3fbf89a11270a6663ca48a0478"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
static const SpvCapability pygen_variable_caps_Addresses[] = {SpvCapabilityAddresses};
|
||||
static const SpvCapability pygen_variable_caps_AddressesPhysicalStorageBufferAddressesEXT[] = {SpvCapabilityAddresses, SpvCapabilityPhysicalStorageBufferAddressesEXT};
|
||||
static const SpvCapability pygen_variable_caps_AddressesVariablePointersVariablePointersStorageBufferPhysicalStorageBufferAddressesEXT[] = {SpvCapabilityAddresses, SpvCapabilityVariablePointers, SpvCapabilityVariablePointersStorageBuffer, SpvCapabilityPhysicalStorageBufferAddressesEXT};
|
||||
static const SpvCapability pygen_variable_caps_CooperativeMatrixNV[] = {SpvCapabilityCooperativeMatrixNV};
|
||||
static const SpvCapability pygen_variable_caps_DerivativeControl[] = {SpvCapabilityDerivativeControl};
|
||||
static const SpvCapability pygen_variable_caps_DeviceEnqueue[] = {SpvCapabilityDeviceEnqueue};
|
||||
static const SpvCapability pygen_variable_caps_FragmentMaskAMD[] = {SpvCapabilityFragmentMaskAMD};
|
||||
@@ -42,6 +43,7 @@ static const spvtools::Extension pygen_variable_exts_SPV_GOOGLE_decorate_stringS
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_GOOGLE_hlsl_functionality1[] = {spvtools::Extension::kSPV_GOOGLE_hlsl_functionality1};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_KHR_shader_ballot[] = {spvtools::Extension::kSPV_KHR_shader_ballot};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_KHR_subgroup_vote[] = {spvtools::Extension::kSPV_KHR_subgroup_vote};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_cooperative_matrix[] = {spvtools::Extension::kSPV_NV_cooperative_matrix};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_mesh_shader[] = {spvtools::Extension::kSPV_NV_mesh_shader};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_ray_tracing[] = {spvtools::Extension::kSPV_NV_ray_tracing};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_shader_image_footprint[] = {spvtools::Extension::kSPV_NV_shader_image_footprint};
|
||||
@@ -413,6 +415,11 @@ static const spv_opcode_desc_t kOpcodeTableEntries[] = {
|
||||
{"TraceNV", SpvOpTraceNV, 1, pygen_variable_caps_RayTracingNV, 11, {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 0, 0, 1, pygen_variable_exts_SPV_NV_ray_tracing, SPV_SPIRV_VERSION_WORD(1, 0)},
|
||||
{"TypeAccelerationStructureNV", SpvOpTypeAccelerationStructureNV, 1, pygen_variable_caps_RayTracingNV, 1, {SPV_OPERAND_TYPE_RESULT_ID}, 1, 0, 1, pygen_variable_exts_SPV_NV_ray_tracing, SPV_SPIRV_VERSION_WORD(1, 0)},
|
||||
{"ExecuteCallableNV", SpvOpExecuteCallableNV, 1, pygen_variable_caps_RayTracingNV, 2, {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 0, 0, 1, pygen_variable_exts_SPV_NV_ray_tracing, SPV_SPIRV_VERSION_WORD(1, 0)},
|
||||
{"TypeCooperativeMatrixNV", SpvOpTypeCooperativeMatrixNV, 1, pygen_variable_caps_CooperativeMatrixNV, 5, {SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_SCOPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 1, 0, 1, pygen_variable_exts_SPV_NV_cooperative_matrix, 0xffffffffu},
|
||||
{"CooperativeMatrixLoadNV", SpvOpCooperativeMatrixLoadNV, 1, pygen_variable_caps_CooperativeMatrixNV, 6, {SPV_OPERAND_TYPE_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS}, 1, 1, 1, pygen_variable_exts_SPV_NV_cooperative_matrix, 0xffffffffu},
|
||||
{"CooperativeMatrixStoreNV", SpvOpCooperativeMatrixStoreNV, 1, pygen_variable_caps_CooperativeMatrixNV, 5, {SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS}, 0, 0, 1, pygen_variable_exts_SPV_NV_cooperative_matrix, 0xffffffffu},
|
||||
{"CooperativeMatrixMulAddNV", SpvOpCooperativeMatrixMulAddNV, 1, pygen_variable_caps_CooperativeMatrixNV, 5, {SPV_OPERAND_TYPE_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 1, 1, 1, pygen_variable_exts_SPV_NV_cooperative_matrix, 0xffffffffu},
|
||||
{"CooperativeMatrixLengthNV", SpvOpCooperativeMatrixLengthNV, 1, pygen_variable_caps_CooperativeMatrixNV, 3, {SPV_OPERAND_TYPE_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID}, 1, 1, 1, pygen_variable_exts_SPV_NV_cooperative_matrix, 0xffffffffu},
|
||||
{"SubgroupShuffleINTEL", SpvOpSubgroupShuffleINTEL, 1, pygen_variable_caps_SubgroupShuffleINTEL, 4, {SPV_OPERAND_TYPE_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 1, 1, 0, nullptr, 0xffffffffu},
|
||||
{"SubgroupShuffleDownINTEL", SpvOpSubgroupShuffleDownINTEL, 1, pygen_variable_caps_SubgroupShuffleINTEL, 5, {SPV_OPERAND_TYPE_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 1, 1, 0, nullptr, 0xffffffffu},
|
||||
{"SubgroupShuffleUpINTEL", SpvOpSubgroupShuffleUpINTEL, 1, pygen_variable_caps_SubgroupShuffleINTEL, 5, {SPV_OPERAND_TYPE_TYPE_ID, SPV_OPERAND_TYPE_RESULT_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID}, 1, 1, 0, nullptr, 0xffffffffu},
|
||||
|
||||
@@ -72,6 +72,8 @@ const char* ExtensionToString(Extension extension) {
|
||||
return "SPV_NVX_multiview_per_view_attributes";
|
||||
case Extension::kSPV_NV_compute_shader_derivatives:
|
||||
return "SPV_NV_compute_shader_derivatives";
|
||||
case Extension::kSPV_NV_cooperative_matrix:
|
||||
return "SPV_NV_cooperative_matrix";
|
||||
case Extension::kSPV_NV_fragment_shader_barycentric:
|
||||
return "SPV_NV_fragment_shader_barycentric";
|
||||
case Extension::kSPV_NV_geometry_shader_passthrough:
|
||||
@@ -101,8 +103,8 @@ const char* ExtensionToString(Extension extension) {
|
||||
|
||||
|
||||
bool GetExtensionFromString(const char* str, Extension* extension) {
|
||||
static const char* known_ext_strs[] = { "SPV_AMD_gcn_shader", "SPV_AMD_gpu_shader_half_float", "SPV_AMD_gpu_shader_half_float_fetch", "SPV_AMD_gpu_shader_int16", "SPV_AMD_shader_ballot", "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_fragment_mask", "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_texture_gather_bias_lod", "SPV_EXT_descriptor_indexing", "SPV_EXT_fragment_fully_covered", "SPV_EXT_fragment_invocation_density", "SPV_EXT_physical_storage_buffer", "SPV_EXT_shader_stencil_export", "SPV_EXT_shader_viewport_index_layer", "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1", "SPV_INTEL_media_block_io", "SPV_INTEL_subgroups", "SPV_KHR_16bit_storage", "SPV_KHR_8bit_storage", "SPV_KHR_device_group", "SPV_KHR_float_controls", "SPV_KHR_multiview", "SPV_KHR_no_integer_wrap_decoration", "SPV_KHR_post_depth_coverage", "SPV_KHR_shader_atomic_counter_ops", "SPV_KHR_shader_ballot", "SPV_KHR_shader_draw_parameters", "SPV_KHR_storage_buffer_storage_class", "SPV_KHR_subgroup_vote", "SPV_KHR_variable_pointers", "SPV_KHR_vulkan_memory_model", "SPV_NVX_multiview_per_view_attributes", "SPV_NV_compute_shader_derivatives", "SPV_NV_fragment_shader_barycentric", "SPV_NV_geometry_shader_passthrough", "SPV_NV_mesh_shader", "SPV_NV_ray_tracing", "SPV_NV_sample_mask_override_coverage", "SPV_NV_shader_image_footprint", "SPV_NV_shader_subgroup_partitioned", "SPV_NV_shading_rate", "SPV_NV_stereo_view_rendering", "SPV_NV_viewport_array2", "SPV_VALIDATOR_ignore_type_decl_unique" };
|
||||
static const Extension known_ext_ids[] = { Extension::kSPV_AMD_gcn_shader, Extension::kSPV_AMD_gpu_shader_half_float, Extension::kSPV_AMD_gpu_shader_half_float_fetch, Extension::kSPV_AMD_gpu_shader_int16, Extension::kSPV_AMD_shader_ballot, Extension::kSPV_AMD_shader_explicit_vertex_parameter, Extension::kSPV_AMD_shader_fragment_mask, Extension::kSPV_AMD_shader_image_load_store_lod, Extension::kSPV_AMD_shader_trinary_minmax, Extension::kSPV_AMD_texture_gather_bias_lod, Extension::kSPV_EXT_descriptor_indexing, Extension::kSPV_EXT_fragment_fully_covered, Extension::kSPV_EXT_fragment_invocation_density, Extension::kSPV_EXT_physical_storage_buffer, Extension::kSPV_EXT_shader_stencil_export, Extension::kSPV_EXT_shader_viewport_index_layer, Extension::kSPV_GOOGLE_decorate_string, Extension::kSPV_GOOGLE_hlsl_functionality1, Extension::kSPV_INTEL_media_block_io, Extension::kSPV_INTEL_subgroups, Extension::kSPV_KHR_16bit_storage, Extension::kSPV_KHR_8bit_storage, Extension::kSPV_KHR_device_group, Extension::kSPV_KHR_float_controls, Extension::kSPV_KHR_multiview, Extension::kSPV_KHR_no_integer_wrap_decoration, Extension::kSPV_KHR_post_depth_coverage, Extension::kSPV_KHR_shader_atomic_counter_ops, Extension::kSPV_KHR_shader_ballot, Extension::kSPV_KHR_shader_draw_parameters, Extension::kSPV_KHR_storage_buffer_storage_class, Extension::kSPV_KHR_subgroup_vote, Extension::kSPV_KHR_variable_pointers, Extension::kSPV_KHR_vulkan_memory_model, Extension::kSPV_NVX_multiview_per_view_attributes, Extension::kSPV_NV_compute_shader_derivatives, Extension::kSPV_NV_fragment_shader_barycentric, Extension::kSPV_NV_geometry_shader_passthrough, Extension::kSPV_NV_mesh_shader, Extension::kSPV_NV_ray_tracing, Extension::kSPV_NV_sample_mask_override_coverage, Extension::kSPV_NV_shader_image_footprint, Extension::kSPV_NV_shader_subgroup_partitioned, Extension::kSPV_NV_shading_rate, Extension::kSPV_NV_stereo_view_rendering, Extension::kSPV_NV_viewport_array2, Extension::kSPV_VALIDATOR_ignore_type_decl_unique };
|
||||
static const char* known_ext_strs[] = { "SPV_AMD_gcn_shader", "SPV_AMD_gpu_shader_half_float", "SPV_AMD_gpu_shader_half_float_fetch", "SPV_AMD_gpu_shader_int16", "SPV_AMD_shader_ballot", "SPV_AMD_shader_explicit_vertex_parameter", "SPV_AMD_shader_fragment_mask", "SPV_AMD_shader_image_load_store_lod", "SPV_AMD_shader_trinary_minmax", "SPV_AMD_texture_gather_bias_lod", "SPV_EXT_descriptor_indexing", "SPV_EXT_fragment_fully_covered", "SPV_EXT_fragment_invocation_density", "SPV_EXT_physical_storage_buffer", "SPV_EXT_shader_stencil_export", "SPV_EXT_shader_viewport_index_layer", "SPV_GOOGLE_decorate_string", "SPV_GOOGLE_hlsl_functionality1", "SPV_INTEL_media_block_io", "SPV_INTEL_subgroups", "SPV_KHR_16bit_storage", "SPV_KHR_8bit_storage", "SPV_KHR_device_group", "SPV_KHR_float_controls", "SPV_KHR_multiview", "SPV_KHR_no_integer_wrap_decoration", "SPV_KHR_post_depth_coverage", "SPV_KHR_shader_atomic_counter_ops", "SPV_KHR_shader_ballot", "SPV_KHR_shader_draw_parameters", "SPV_KHR_storage_buffer_storage_class", "SPV_KHR_subgroup_vote", "SPV_KHR_variable_pointers", "SPV_KHR_vulkan_memory_model", "SPV_NVX_multiview_per_view_attributes", "SPV_NV_compute_shader_derivatives", "SPV_NV_cooperative_matrix", "SPV_NV_fragment_shader_barycentric", "SPV_NV_geometry_shader_passthrough", "SPV_NV_mesh_shader", "SPV_NV_ray_tracing", "SPV_NV_sample_mask_override_coverage", "SPV_NV_shader_image_footprint", "SPV_NV_shader_subgroup_partitioned", "SPV_NV_shading_rate", "SPV_NV_stereo_view_rendering", "SPV_NV_viewport_array2", "SPV_VALIDATOR_ignore_type_decl_unique" };
|
||||
static const Extension known_ext_ids[] = { Extension::kSPV_AMD_gcn_shader, Extension::kSPV_AMD_gpu_shader_half_float, Extension::kSPV_AMD_gpu_shader_half_float_fetch, Extension::kSPV_AMD_gpu_shader_int16, Extension::kSPV_AMD_shader_ballot, Extension::kSPV_AMD_shader_explicit_vertex_parameter, Extension::kSPV_AMD_shader_fragment_mask, Extension::kSPV_AMD_shader_image_load_store_lod, Extension::kSPV_AMD_shader_trinary_minmax, Extension::kSPV_AMD_texture_gather_bias_lod, Extension::kSPV_EXT_descriptor_indexing, Extension::kSPV_EXT_fragment_fully_covered, Extension::kSPV_EXT_fragment_invocation_density, Extension::kSPV_EXT_physical_storage_buffer, Extension::kSPV_EXT_shader_stencil_export, Extension::kSPV_EXT_shader_viewport_index_layer, Extension::kSPV_GOOGLE_decorate_string, Extension::kSPV_GOOGLE_hlsl_functionality1, Extension::kSPV_INTEL_media_block_io, Extension::kSPV_INTEL_subgroups, Extension::kSPV_KHR_16bit_storage, Extension::kSPV_KHR_8bit_storage, Extension::kSPV_KHR_device_group, Extension::kSPV_KHR_float_controls, Extension::kSPV_KHR_multiview, Extension::kSPV_KHR_no_integer_wrap_decoration, Extension::kSPV_KHR_post_depth_coverage, Extension::kSPV_KHR_shader_atomic_counter_ops, Extension::kSPV_KHR_shader_ballot, Extension::kSPV_KHR_shader_draw_parameters, Extension::kSPV_KHR_storage_buffer_storage_class, Extension::kSPV_KHR_subgroup_vote, Extension::kSPV_KHR_variable_pointers, Extension::kSPV_KHR_vulkan_memory_model, Extension::kSPV_NVX_multiview_per_view_attributes, Extension::kSPV_NV_compute_shader_derivatives, Extension::kSPV_NV_cooperative_matrix, Extension::kSPV_NV_fragment_shader_barycentric, Extension::kSPV_NV_geometry_shader_passthrough, Extension::kSPV_NV_mesh_shader, Extension::kSPV_NV_ray_tracing, Extension::kSPV_NV_sample_mask_override_coverage, Extension::kSPV_NV_shader_image_footprint, Extension::kSPV_NV_shader_subgroup_partitioned, Extension::kSPV_NV_shading_rate, Extension::kSPV_NV_stereo_view_rendering, Extension::kSPV_NV_viewport_array2, Extension::kSPV_VALIDATOR_ignore_type_decl_unique };
|
||||
const auto b = std::begin(known_ext_strs);
|
||||
const auto e = std::end(known_ext_strs);
|
||||
const auto found = std::equal_range(
|
||||
@@ -372,6 +374,8 @@ const char* CapabilityToString(SpvCapability capability) {
|
||||
return "FragmentDensityEXT";
|
||||
case SpvCapabilityPhysicalStorageBufferAddressesEXT:
|
||||
return "PhysicalStorageBufferAddressesEXT";
|
||||
case SpvCapabilityCooperativeMatrixNV:
|
||||
return "CooperativeMatrixNV";
|
||||
case SpvCapabilityMax:
|
||||
assert(0 && "Attempting to convert SpvCapabilityMax to string");
|
||||
return "";
|
||||
|
||||
@@ -34,6 +34,7 @@ kSPV_KHR_variable_pointers,
|
||||
kSPV_KHR_vulkan_memory_model,
|
||||
kSPV_NVX_multiview_per_view_attributes,
|
||||
kSPV_NV_compute_shader_derivatives,
|
||||
kSPV_NV_cooperative_matrix,
|
||||
kSPV_NV_fragment_shader_barycentric,
|
||||
kSPV_NV_geometry_shader_passthrough,
|
||||
kSPV_NV_mesh_shader,
|
||||
|
||||
@@ -112,6 +112,7 @@ static const spvtools::Extension pygen_variable_exts_SPV_KHR_vulkan_memory_model
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NVX_multiview_per_view_attributes[] = {spvtools::Extension::kSPV_NVX_multiview_per_view_attributes};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NVX_multiview_per_view_attributesSPV_NV_mesh_shader[] = {spvtools::Extension::kSPV_NVX_multiview_per_view_attributes, spvtools::Extension::kSPV_NV_mesh_shader};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_compute_shader_derivatives[] = {spvtools::Extension::kSPV_NV_compute_shader_derivatives};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_cooperative_matrix[] = {spvtools::Extension::kSPV_NV_cooperative_matrix};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_fragment_shader_barycentric[] = {spvtools::Extension::kSPV_NV_fragment_shader_barycentric};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_geometry_shader_passthrough[] = {spvtools::Extension::kSPV_NV_geometry_shader_passthrough};
|
||||
static const spvtools::Extension pygen_variable_exts_SPV_NV_mesh_shader[] = {spvtools::Extension::kSPV_NV_mesh_shader};
|
||||
@@ -778,6 +779,7 @@ static const spv_operand_desc_t pygen_variable_CapabilityEntries[] = {
|
||||
{"VulkanMemoryModelDeviceScopeKHR", 5346, 0, nullptr, 1, pygen_variable_exts_SPV_KHR_vulkan_memory_model, {}, 0xffffffffu},
|
||||
{"PhysicalStorageBufferAddressesEXT", 5347, 1, pygen_variable_caps_Shader, 1, pygen_variable_exts_SPV_EXT_physical_storage_buffer, {}, 0xffffffffu},
|
||||
{"ComputeDerivativeGroupLinearNV", 5350, 0, nullptr, 1, pygen_variable_exts_SPV_NV_compute_shader_derivatives, {}, 0xffffffffu},
|
||||
{"CooperativeMatrixNV", 5357, 1, pygen_variable_caps_Shader, 1, pygen_variable_exts_SPV_NV_cooperative_matrix, {}, 0xffffffffu},
|
||||
{"SubgroupShuffleINTEL", 5568, 0, nullptr, 1, pygen_variable_exts_SPV_INTEL_subgroups, {}, 0xffffffffu},
|
||||
{"SubgroupBufferBlockIOINTEL", 5569, 0, nullptr, 1, pygen_variable_exts_SPV_INTEL_subgroups, {}, 0xffffffffu},
|
||||
{"SubgroupImageBlockIOINTEL", 5570, 0, nullptr, 1, pygen_variable_exts_SPV_INTEL_subgroups, {}, 0xffffffffu},
|
||||
|
||||
@@ -582,13 +582,17 @@ ConstantFoldingRule FoldOpDotWithConstants() {
|
||||
std::vector<uint32_t> words = result.GetWords();
|
||||
const analysis::Constant* result_const =
|
||||
const_mgr->GetConstant(float_type, words);
|
||||
for (uint32_t i = 0; i < a_components.size(); ++i) {
|
||||
for (uint32_t i = 0; i < a_components.size() && result_const != nullptr;
|
||||
++i) {
|
||||
if (a_components[i] == nullptr || b_components[i] == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const analysis::Constant* component = FOLD_FPARITH_OP(*)(
|
||||
new_type, a_components[i], b_components[i], const_mgr);
|
||||
if (component == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
result_const =
|
||||
FOLD_FPARITH_OP(+)(new_type, result_const, component, const_mgr);
|
||||
}
|
||||
|
||||
@@ -39,10 +39,18 @@ void EliminateDeadMembersPass::FindLiveMembers() {
|
||||
// Until we have implemented the rewritting of OpSpecConsantOp instructions,
|
||||
// we have to mark them as fully used just to be safe.
|
||||
for (auto& inst : get_module()->types_values()) {
|
||||
if (inst.opcode() != SpvOpSpecConstantOp) {
|
||||
continue;
|
||||
if (inst.opcode() == SpvOpSpecConstantOp) {
|
||||
MarkTypeAsFullyUsed(inst.type_id());
|
||||
} else if (inst.opcode() == SpvOpVariable) {
|
||||
switch (inst.GetSingleWordInOperand(0)) {
|
||||
case SpvStorageClassInput:
|
||||
case SpvStorageClassOutput:
|
||||
MarkPointeeTypeAsFullUsed(inst.type_id());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
MarkTypeAsFullyUsed(inst.type_id());
|
||||
}
|
||||
|
||||
for (const Function& func : *get_module()) {
|
||||
@@ -127,6 +135,12 @@ void EliminateDeadMembersPass::MarkTypeAsFullyUsed(uint32_t type_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void EliminateDeadMembersPass::MarkPointeeTypeAsFullUsed(uint32_t ptr_type_id) {
|
||||
Instruction* ptr_type_inst = get_def_use_mgr()->GetDef(ptr_type_id);
|
||||
assert(ptr_type_inst->opcode() == SpvOpTypePointer);
|
||||
MarkTypeAsFullyUsed(ptr_type_inst->GetSingleWordInOperand(1));
|
||||
}
|
||||
|
||||
void EliminateDeadMembersPass::MarkMembersAsLiveForCopyMemory(
|
||||
const Instruction* inst) {
|
||||
uint32_t target_id = inst->GetSingleWordInOperand(0);
|
||||
@@ -619,6 +633,5 @@ void EliminateDeadMembersPass::MarkStructOperandsAsFullyUsed(
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
||||
@@ -137,6 +137,7 @@ class EliminateDeadMembersPass : public MemPass {
|
||||
// type that are used, and must be kept.
|
||||
std::unordered_map<uint32_t, std::set<uint32_t>> used_members_;
|
||||
void MarkStructOperandsAsFullyUsed(const Instruction* inst);
|
||||
void MarkPointeeTypeAsFullUsed(uint32_t ptr_type_id);
|
||||
};
|
||||
|
||||
} // namespace opt
|
||||
|
||||
@@ -36,14 +36,14 @@ namespace spvtools {
|
||||
namespace opt {
|
||||
|
||||
uint32_t InstBindlessCheckPass::GenDebugReadLength(
|
||||
uint32_t image_id, InstructionBuilder* builder) {
|
||||
uint32_t var_id, InstructionBuilder* builder) {
|
||||
uint32_t desc_set_idx =
|
||||
var2desc_set_[image_id] + kDebugInputBindlessOffsetLengths;
|
||||
var2desc_set_[var_id] + kDebugInputBindlessOffsetLengths;
|
||||
uint32_t desc_set_idx_id = builder->GetUintConstantId(desc_set_idx);
|
||||
uint32_t desc_set_offset_id = GenDebugDirectRead(desc_set_idx_id, builder);
|
||||
Instruction* binding_idx_inst =
|
||||
builder->AddBinaryOp(GetUintId(), SpvOpIAdd, desc_set_offset_id,
|
||||
builder->GetUintConstantId(var2binding_[image_id]));
|
||||
builder->GetUintConstantId(var2binding_[var_id]));
|
||||
return GenDebugDirectRead(binding_idx_inst->result_id(), builder);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void InstBindlessCheckPass::GenBindlessCheckCode(
|
||||
if (length_id == 0) {
|
||||
assert(ptr_type_inst->opcode() == SpvOpTypeRuntimeArray &&
|
||||
"unexpected bindless type");
|
||||
length_id = GenDebugReadLength(image_id, &builder);
|
||||
length_id = GenDebugReadLength(ptr_id, &builder);
|
||||
}
|
||||
Instruction* ult_inst =
|
||||
builder.AddBinaryOp(GetBoolId(), SpvOpULessThan, index_id, length_id);
|
||||
|
||||
@@ -47,8 +47,8 @@ class InstBindlessCheckPass : public InstrumentPass {
|
||||
|
||||
private:
|
||||
// Generate instructions into |builder| to read length of runtime descriptor
|
||||
// array |image_id| from debug input buffer and return id of value.
|
||||
uint32_t GenDebugReadLength(uint32_t image_id, InstructionBuilder* builder);
|
||||
// array |var_id| from debug input buffer and return id of value.
|
||||
uint32_t GenDebugReadLength(uint32_t var_id, InstructionBuilder* builder);
|
||||
|
||||
// Initialize state for instrumenting bindless checking
|
||||
void InitializeInstBindlessCheck();
|
||||
|
||||
@@ -617,11 +617,7 @@ bool InstrumentPass::InstrumentFunction(Function* func, uint32_t stage_idx,
|
||||
// Start count after function and param instructions
|
||||
uint32_t instruction_idx = funcIdx2offset_[function_idx] + 1;
|
||||
func->ForEachParam(
|
||||
[this, &instruction_idx](const Instruction* i) {
|
||||
(void)i;
|
||||
++instruction_idx;
|
||||
},
|
||||
true);
|
||||
[&instruction_idx](const Instruction*) { ++instruction_idx; }, true);
|
||||
// Using block iterators here because of block erasures and insertions.
|
||||
for (auto bi = func->begin(); bi != func->end(); ++bi) {
|
||||
// Count block's label
|
||||
@@ -792,12 +788,8 @@ void InstrumentPass::InitializeInstrument() {
|
||||
for (++curr_fn; curr_fn != get_module()->end(); ++curr_fn) {
|
||||
// Count function, end and param instructions
|
||||
uint32_t func_size = 2;
|
||||
prev_fn->ForEachParam(
|
||||
[this, &func_size](const Instruction* i) {
|
||||
(void)i;
|
||||
++func_size;
|
||||
},
|
||||
true);
|
||||
prev_fn->ForEachParam([&func_size](const Instruction*) { ++func_size; },
|
||||
true);
|
||||
for (auto& blk : *prev_fn) {
|
||||
// Count label
|
||||
func_size += 1;
|
||||
|
||||
@@ -909,6 +909,13 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) {
|
||||
: (push_constant ? "PushConstant" : "StorageBuffer");
|
||||
|
||||
if (spvIsVulkanEnv(vstate.context()->target_env)) {
|
||||
if (storage_buffer &&
|
||||
hasDecoration(id, SpvDecorationBufferBlock, vstate)) {
|
||||
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id))
|
||||
<< "Storage buffer id '" << var_id
|
||||
<< " In Vulkan, BufferBlock is disallowed on variables in "
|
||||
"the StorageBuffer storage class";
|
||||
}
|
||||
// Vulkan 14.5.1: Check Block decoration for PushConstant variables.
|
||||
if (push_constant && !hasDecoration(id, SpvDecorationBlock, vstate)) {
|
||||
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
||||
@@ -1028,6 +1035,10 @@ bool AtMostOncePerMember(SpvDecoration decoration) {
|
||||
// Returns the string name for |decoration|.
|
||||
const char* GetDecorationName(SpvDecoration decoration) {
|
||||
switch (decoration) {
|
||||
case SpvDecorationAliased:
|
||||
return "Aliased";
|
||||
case SpvDecorationRestrict:
|
||||
return "Restrict";
|
||||
case SpvDecorationArrayStride:
|
||||
return "ArrayStride";
|
||||
case SpvDecorationOffset:
|
||||
@@ -1054,7 +1065,8 @@ spv_result_t CheckDecorationsCompatibility(ValidationState_t& vstate) {
|
||||
// An Array of pairs where the decorations in the pair cannot both be applied
|
||||
// to the same id.
|
||||
static const SpvDecoration mutually_exclusive_per_id[][2] = {
|
||||
{SpvDecorationBlock, SpvDecorationBufferBlock}};
|
||||
{SpvDecorationBlock, SpvDecorationBufferBlock},
|
||||
{SpvDecorationRestrict, SpvDecorationAliased}};
|
||||
static const auto num_mutually_exclusive_per_id_pairs =
|
||||
sizeof(mutually_exclusive_per_id) / (2 * sizeof(SpvDecoration));
|
||||
|
||||
|
||||
@@ -253,7 +253,8 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _,
|
||||
}
|
||||
|
||||
if (_.addressing_model() == SpvAddressingModelLogical) {
|
||||
if (parameter_type->opcode() == SpvOpTypePointer) {
|
||||
if (parameter_type->opcode() == SpvOpTypePointer &&
|
||||
!_.options()->relax_logical_pointer) {
|
||||
SpvStorageClass sc = parameter_type->GetOperandAs<SpvStorageClass>(1u);
|
||||
// Validate which storage classes can be pointer operands.
|
||||
switch (sc) {
|
||||
|
||||
@@ -5151,7 +5151,6 @@ OpFunctionEnd
|
||||
TEST_F(AggressiveDCETest, ParitallyDeadDecorationGroup) {
|
||||
const std::string text = R"(
|
||||
; CHECK: OpDecorate [[grp:%\w+]] Restrict
|
||||
; CHECK: OpDecorate [[grp]] Aliased
|
||||
; CHECK: [[grp]] = OpDecorationGroup
|
||||
; CHECK: OpGroupDecorate [[grp]] [[output:%\w+]]
|
||||
; CHECK: [[output]] = OpVariable {{%\w+}} Output
|
||||
@@ -5161,7 +5160,6 @@ OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %output
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpDecorate %1 Restrict
|
||||
OpDecorate %1 Aliased
|
||||
%1 = OpDecorationGroup
|
||||
OpGroupDecorate %1 %var %output
|
||||
%void = OpTypeVoid
|
||||
@@ -5185,7 +5183,6 @@ OpFunctionEnd
|
||||
TEST_F(AggressiveDCETest, ParitallyDeadDecorationGroupDifferentGroupDecorate) {
|
||||
const std::string text = R"(
|
||||
; CHECK: OpDecorate [[grp:%\w+]] Restrict
|
||||
; CHECK: OpDecorate [[grp]] Aliased
|
||||
; CHECK: [[grp]] = OpDecorationGroup
|
||||
; CHECK: OpGroupDecorate [[grp]] [[output:%\w+]]
|
||||
; CHECK-NOT: OpGroupDecorate
|
||||
@@ -5196,7 +5193,6 @@ OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %output
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpDecorate %1 Restrict
|
||||
OpDecorate %1 Aliased
|
||||
%1 = OpDecorationGroup
|
||||
OpGroupDecorate %1 %output
|
||||
OpGroupDecorate %1 %var
|
||||
|
||||
@@ -1007,14 +1007,14 @@ TEST_F(EliminateDeadMemberTest, DontRemoveModfStructResultTypeMembers) {
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %PS_TerrainElevation "PS_TerrainElevation"
|
||||
OpExecutionMode %PS_TerrainElevation OriginUpperLeft
|
||||
OpEntryPoint Fragment %main "main"
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource HLSL 600
|
||||
%float = OpTypeFloat 32
|
||||
%void = OpTypeVoid
|
||||
%21 = OpTypeFunction %void
|
||||
%ModfStructType = OpTypeStruct %float %float
|
||||
%PS_TerrainElevation = OpFunction %void None %21
|
||||
%main = OpFunction %void None %21
|
||||
%22 = OpLabel
|
||||
%23 = OpUndef %float
|
||||
%24 = OpExtInst %ModfStructType %1 ModfStruct %23
|
||||
@@ -1028,4 +1028,60 @@ TEST_F(EliminateDeadMemberTest, DontRemoveModfStructResultTypeMembers) {
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
TEST_F(EliminateDeadMemberTest, DontChangeInputStructs) {
|
||||
// The input for a shader has to match the type of the output from the
|
||||
// previous shader in the pipeline. Because of that, we cannot change the
|
||||
// types of input variables.
|
||||
const std::string text = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %input_var
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource HLSL 600
|
||||
%float = OpTypeFloat 32
|
||||
%void = OpTypeVoid
|
||||
%21 = OpTypeFunction %void
|
||||
%in_var_type = OpTypeStruct %float %float
|
||||
%in_ptr_type = OpTypePointer Input %in_var_type
|
||||
%input_var = OpVariable %in_ptr_type Input
|
||||
%main = OpFunction %void None %21
|
||||
%22 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto result = SinglePassRunAndDisassemble<opt::EliminateDeadMembersPass>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ true);
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
TEST_F(EliminateDeadMemberTest, DontChangeOutputStructs) {
|
||||
// The output for a shader has to match the type of the output from the
|
||||
// previous shader in the pipeline. Because of that, we cannot change the
|
||||
// types of output variables.
|
||||
const std::string text = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %output_var
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource HLSL 600
|
||||
%float = OpTypeFloat 32
|
||||
%void = OpTypeVoid
|
||||
%21 = OpTypeFunction %void
|
||||
%out_var_type = OpTypeStruct %float %float
|
||||
%out_ptr_type = OpTypePointer Output %out_var_type
|
||||
%output_var = OpVariable %out_ptr_type Output
|
||||
%main = OpFunction %void None %21
|
||||
%22 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto result = SinglePassRunAndDisassemble<opt::EliminateDeadMembersPass>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ true);
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
26
3rdparty/spirv-tools/test/opt/fold_test.cpp
vendored
26
3rdparty/spirv-tools/test/opt/fold_test.cpp
vendored
@@ -142,6 +142,7 @@ OpName %main "main"
|
||||
%v4double = OpTypeVector %double 4
|
||||
%v2float = OpTypeVector %float 2
|
||||
%v2double = OpTypeVector %double 2
|
||||
%v2half = OpTypeVector %half 2
|
||||
%v2bool = OpTypeVector %bool 2
|
||||
%struct_v2int_int_int = OpTypeStruct %v2int %int %int
|
||||
%_ptr_int = OpTypePointer Function %int
|
||||
@@ -231,6 +232,7 @@ OpName %main "main"
|
||||
%v2double_null = OpConstantNull %v2double
|
||||
%108 = OpConstant %half 0
|
||||
%half_1 = OpConstant %half 1
|
||||
%half_0_1 = OpConstantComposite %v2half %108 %half_1
|
||||
%106 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
|
||||
%v4float_0_0_0_0 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
|
||||
%v4float_0_0_0_1 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1
|
||||
@@ -3171,7 +3173,7 @@ INSTANTIATE_TEST_SUITE_P(FloatRedundantFoldingTest, GeneralInstructionFoldingTes
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
3, 2),
|
||||
// Test case 15: Fold vector fsub with null
|
||||
// Test case 17: Fold vector fsub with null
|
||||
InstructionFoldingCase<uint32_t>(
|
||||
Header() + "%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
@@ -3181,7 +3183,7 @@ INSTANTIATE_TEST_SUITE_P(FloatRedundantFoldingTest, GeneralInstructionFoldingTes
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
3, 2),
|
||||
// Test case 16: Fold 0.0(half) * n
|
||||
// Test case 18: Fold 0.0(half) * n
|
||||
InstructionFoldingCase<uint32_t>(
|
||||
Header() + "%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
@@ -3191,7 +3193,7 @@ INSTANTIATE_TEST_SUITE_P(FloatRedundantFoldingTest, GeneralInstructionFoldingTes
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
2, HALF_0_ID),
|
||||
// Test case 17: Don't fold 1.0(half) * n
|
||||
// Test case 19: Don't fold 1.0(half) * n
|
||||
InstructionFoldingCase<uint32_t>(
|
||||
Header() + "%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
@@ -3201,13 +3203,29 @@ INSTANTIATE_TEST_SUITE_P(FloatRedundantFoldingTest, GeneralInstructionFoldingTes
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
2, 0),
|
||||
// Test case 18: Don't fold 1.0 * 1.0 (half)
|
||||
// Test case 20: Don't fold 1.0 * 1.0 (half)
|
||||
InstructionFoldingCase<uint32_t>(
|
||||
Header() + "%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
"%2 = OpFMul %half %half_1 %half_1\n" +
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
2, 0),
|
||||
// Test case 21: Don't fold (0.0, 1.0) * (0.0, 1.0) (half)
|
||||
InstructionFoldingCase<uint32_t>(
|
||||
Header() + "%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
"%2 = OpFMul %v2half %half_0_1 %half_0_1\n" +
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
2, 0),
|
||||
// Test case 22: Don't fold (0.0, 1.0) dotp (0.0, 1.0) (half)
|
||||
InstructionFoldingCase<uint32_t>(
|
||||
Header() + "%main = OpFunction %void None %void_func\n" +
|
||||
"%main_lab = OpLabel\n" +
|
||||
"%2 = OpDot %half %half_0_1 %half_0_1\n" +
|
||||
"OpReturn\n" +
|
||||
"OpFunctionEnd",
|
||||
2, 0)
|
||||
));
|
||||
|
||||
|
||||
@@ -1925,12 +1925,12 @@ OpName %_ ""
|
||||
OpName %g_sAniso "g_sAniso"
|
||||
OpName %i_vTextureCoords "i.vTextureCoords"
|
||||
OpName %_entryPointOutput_vColor "@entryPointOutput.vColor"
|
||||
OpDecorate %g_tColor DescriptorSet 0
|
||||
OpDecorate %g_tColor Binding 0
|
||||
OpDecorate %g_tColor DescriptorSet 1
|
||||
OpDecorate %g_tColor Binding 1
|
||||
OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0
|
||||
OpDecorate %PerViewConstantBuffer_t Block
|
||||
OpDecorate %g_sAniso DescriptorSet 0
|
||||
OpDecorate %g_sAniso Binding 1
|
||||
OpDecorate %g_sAniso DescriptorSet 1
|
||||
OpDecorate %g_sAniso Binding 0
|
||||
OpDecorate %i_vTextureCoords Location 0
|
||||
OpDecorate %_entryPointOutput_vColor Location 0
|
||||
%void = OpTypeVoid
|
||||
@@ -1979,24 +1979,24 @@ OpName %_ ""
|
||||
OpName %g_sAniso "g_sAniso"
|
||||
OpName %i_vTextureCoords "i.vTextureCoords"
|
||||
OpName %_entryPointOutput_vColor "@entryPointOutput.vColor"
|
||||
OpDecorate %g_tColor DescriptorSet 0
|
||||
OpDecorate %g_tColor Binding 0
|
||||
OpDecorate %g_tColor DescriptorSet 1
|
||||
OpDecorate %g_tColor Binding 1
|
||||
OpMemberDecorate %PerViewConstantBuffer_t 0 Offset 0
|
||||
OpDecorate %PerViewConstantBuffer_t Block
|
||||
OpDecorate %g_sAniso DescriptorSet 0
|
||||
OpDecorate %g_sAniso Binding 1
|
||||
OpDecorate %g_sAniso DescriptorSet 1
|
||||
OpDecorate %g_sAniso Binding 0
|
||||
OpDecorate %i_vTextureCoords Location 0
|
||||
OpDecorate %_entryPointOutput_vColor Location 0
|
||||
OpDecorate %_runtimearr_uint ArrayStride 4
|
||||
OpDecorate %_struct_40 Block
|
||||
OpMemberDecorate %_struct_40 0 Offset 0
|
||||
OpDecorate %42 DescriptorSet 7
|
||||
OpDecorate %42 Binding 1
|
||||
OpDecorate %_struct_64 Block
|
||||
OpMemberDecorate %_struct_64 0 Offset 0
|
||||
OpMemberDecorate %_struct_64 1 Offset 4
|
||||
OpDecorate %66 DescriptorSet 7
|
||||
OpDecorate %66 Binding 0
|
||||
OpDecorate %_struct_41 Block
|
||||
OpMemberDecorate %_struct_41 0 Offset 0
|
||||
OpDecorate %43 DescriptorSet 7
|
||||
OpDecorate %43 Binding 1
|
||||
OpDecorate %_struct_65 Block
|
||||
OpMemberDecorate %_struct_65 0 Offset 0
|
||||
OpMemberDecorate %_struct_65 1 Offset 4
|
||||
OpDecorate %67 DescriptorSet 7
|
||||
OpDecorate %67 Binding 0
|
||||
OpDecorate %gl_FragCoord BuiltIn FragCoord
|
||||
%void = OpTypeVoid
|
||||
%10 = OpTypeFunction %void
|
||||
@@ -2025,20 +2025,20 @@ OpDecorate %gl_FragCoord BuiltIn FragCoord
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%_runtimearr_uint = OpTypeRuntimeArray %uint
|
||||
%_struct_40 = OpTypeStruct %_runtimearr_uint
|
||||
%_ptr_StorageBuffer__struct_40 = OpTypePointer StorageBuffer %_struct_40
|
||||
%42 = OpVariable %_ptr_StorageBuffer__struct_40 StorageBuffer
|
||||
%_struct_41 = OpTypeStruct %_runtimearr_uint
|
||||
%_ptr_StorageBuffer__struct_41 = OpTypePointer StorageBuffer %_struct_41
|
||||
%43 = OpVariable %_ptr_StorageBuffer__struct_41 StorageBuffer
|
||||
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
||||
%bool = OpTypeBool
|
||||
%58 = OpTypeFunction %void %uint %uint %uint %uint
|
||||
%_struct_64 = OpTypeStruct %uint %_runtimearr_uint
|
||||
%_ptr_StorageBuffer__struct_64 = OpTypePointer StorageBuffer %_struct_64
|
||||
%66 = OpVariable %_ptr_StorageBuffer__struct_64 StorageBuffer
|
||||
%59 = OpTypeFunction %void %uint %uint %uint %uint
|
||||
%_struct_65 = OpTypeStruct %uint %_runtimearr_uint
|
||||
%_ptr_StorageBuffer__struct_65 = OpTypePointer StorageBuffer %_struct_65
|
||||
%67 = OpVariable %_ptr_StorageBuffer__struct_65 StorageBuffer
|
||||
%uint_9 = OpConstant %uint 9
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%uint_23 = OpConstant %uint 23
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%_ptr_Input_v4float = OpTypePointer Input %v4float
|
||||
%gl_FragCoord = OpVariable %_ptr_Input_v4float Input
|
||||
@@ -2077,77 +2077,77 @@ OpFunctionEnd
|
||||
%34 = OpLoad %16 %33
|
||||
%35 = OpLoad %24 %g_sAniso
|
||||
%36 = OpSampledImage %26 %34 %35
|
||||
%44 = OpAccessChain %_ptr_StorageBuffer_uint %42 %uint_0 %uint_1
|
||||
%45 = OpLoad %uint %44
|
||||
%46 = OpIAdd %uint %45 %uint_0
|
||||
%47 = OpAccessChain %_ptr_StorageBuffer_uint %42 %uint_0 %46
|
||||
%48 = OpLoad %uint %47
|
||||
%50 = OpULessThan %bool %32 %48
|
||||
OpSelectionMerge %51 None
|
||||
OpBranchConditional %50 %52 %53
|
||||
%52 = OpLabel
|
||||
%54 = OpLoad %16 %33
|
||||
%55 = OpSampledImage %26 %54 %35
|
||||
%56 = OpImageSampleImplicitLod %v4float %55 %30
|
||||
OpBranch %51
|
||||
%45 = OpAccessChain %_ptr_StorageBuffer_uint %43 %uint_0 %uint_2
|
||||
%46 = OpLoad %uint %45
|
||||
%47 = OpIAdd %uint %46 %uint_1
|
||||
%48 = OpAccessChain %_ptr_StorageBuffer_uint %43 %uint_0 %47
|
||||
%49 = OpLoad %uint %48
|
||||
%51 = OpULessThan %bool %32 %49
|
||||
OpSelectionMerge %52 None
|
||||
OpBranchConditional %51 %53 %54
|
||||
%53 = OpLabel
|
||||
%109 = OpFunctionCall %void %57 %uint_59 %uint_0 %32 %48
|
||||
OpBranch %51
|
||||
%51 = OpLabel
|
||||
%111 = OpPhi %v4float %56 %52 %110 %53
|
||||
%55 = OpLoad %16 %33
|
||||
%56 = OpSampledImage %26 %55 %35
|
||||
%57 = OpImageSampleImplicitLod %v4float %56 %30
|
||||
OpBranch %52
|
||||
%54 = OpLabel
|
||||
%109 = OpFunctionCall %void %58 %uint_59 %uint_0 %32 %49
|
||||
OpBranch %52
|
||||
%52 = OpLabel
|
||||
%111 = OpPhi %v4float %57 %53 %110 %54
|
||||
OpStore %_entryPointOutput_vColor %111
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
const std::string output_func =
|
||||
R"(%57 = OpFunction %void None %58
|
||||
%59 = OpFunctionParameter %uint
|
||||
R"(%58 = OpFunction %void None %59
|
||||
%60 = OpFunctionParameter %uint
|
||||
%61 = OpFunctionParameter %uint
|
||||
%62 = OpFunctionParameter %uint
|
||||
%63 = OpLabel
|
||||
%67 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_0
|
||||
%70 = OpAtomicIAdd %uint %67 %uint_4 %uint_0 %uint_9
|
||||
%71 = OpIAdd %uint %70 %uint_9
|
||||
%72 = OpArrayLength %uint %66 1
|
||||
%73 = OpULessThanEqual %bool %71 %72
|
||||
OpSelectionMerge %74 None
|
||||
OpBranchConditional %73 %75 %74
|
||||
%75 = OpLabel
|
||||
%76 = OpIAdd %uint %70 %uint_0
|
||||
%77 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %76
|
||||
OpStore %77 %uint_9
|
||||
%79 = OpIAdd %uint %70 %uint_1
|
||||
%80 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %79
|
||||
OpStore %80 %uint_23
|
||||
%82 = OpIAdd %uint %70 %uint_2
|
||||
%83 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %82
|
||||
OpStore %83 %59
|
||||
%85 = OpIAdd %uint %70 %uint_3
|
||||
%86 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %85
|
||||
%63 = OpFunctionParameter %uint
|
||||
%64 = OpLabel
|
||||
%68 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_0
|
||||
%71 = OpAtomicIAdd %uint %68 %uint_4 %uint_0 %uint_9
|
||||
%72 = OpIAdd %uint %71 %uint_9
|
||||
%73 = OpArrayLength %uint %67 1
|
||||
%74 = OpULessThanEqual %bool %72 %73
|
||||
OpSelectionMerge %75 None
|
||||
OpBranchConditional %74 %76 %75
|
||||
%76 = OpLabel
|
||||
%77 = OpIAdd %uint %71 %uint_0
|
||||
%78 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %77
|
||||
OpStore %78 %uint_9
|
||||
%80 = OpIAdd %uint %71 %uint_1
|
||||
%81 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %80
|
||||
OpStore %81 %uint_23
|
||||
%82 = OpIAdd %uint %71 %uint_2
|
||||
%83 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %82
|
||||
OpStore %83 %60
|
||||
%85 = OpIAdd %uint %71 %uint_3
|
||||
%86 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %85
|
||||
OpStore %86 %uint_4
|
||||
%89 = OpLoad %v4float %gl_FragCoord
|
||||
%91 = OpBitcast %v4uint %89
|
||||
%92 = OpCompositeExtract %uint %91 0
|
||||
%93 = OpIAdd %uint %70 %uint_4
|
||||
%94 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %93
|
||||
%93 = OpIAdd %uint %71 %uint_4
|
||||
%94 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %93
|
||||
OpStore %94 %92
|
||||
%95 = OpCompositeExtract %uint %91 1
|
||||
%97 = OpIAdd %uint %70 %uint_5
|
||||
%98 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %97
|
||||
%97 = OpIAdd %uint %71 %uint_5
|
||||
%98 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %97
|
||||
OpStore %98 %95
|
||||
%100 = OpIAdd %uint %70 %uint_6
|
||||
%101 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %100
|
||||
OpStore %101 %60
|
||||
%103 = OpIAdd %uint %70 %uint_7
|
||||
%104 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %103
|
||||
OpStore %104 %61
|
||||
%106 = OpIAdd %uint %70 %uint_8
|
||||
%107 = OpAccessChain %_ptr_StorageBuffer_uint %66 %uint_1 %106
|
||||
OpStore %107 %62
|
||||
OpBranch %74
|
||||
%74 = OpLabel
|
||||
%100 = OpIAdd %uint %71 %uint_6
|
||||
%101 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %100
|
||||
OpStore %101 %61
|
||||
%103 = OpIAdd %uint %71 %uint_7
|
||||
%104 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %103
|
||||
OpStore %104 %62
|
||||
%106 = OpIAdd %uint %71 %uint_8
|
||||
%107 = OpAccessChain %_ptr_StorageBuffer_uint %67 %uint_1 %106
|
||||
OpStore %107 %63
|
||||
OpBranch %75
|
||||
%75 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
@@ -2160,7 +2160,12 @@ OpFunctionEnd
|
||||
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
//
|
||||
// TODO(greg-lunarg): Come up with cases to put here :)
|
||||
// Compute shader
|
||||
// Geometry shader
|
||||
// Tesselation control shader
|
||||
// Tesselation eval shader
|
||||
// OpImage
|
||||
// SampledImage variable
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
|
||||
@@ -225,7 +225,7 @@ TEST_F(ValidateAtomics, AtomicLoadKernelSuccess) {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicLoadVulkanSuccess) {
|
||||
TEST_F(ValidateAtomics, AtomicLoadInt32VulkanSuccess) {
|
||||
const std::string body = R"(
|
||||
%val1 = OpAtomicLoad %u32 %u32_var %device %relaxed
|
||||
%val2 = OpAtomicLoad %u32 %u32_var %workgroup %acquire
|
||||
@@ -235,6 +235,41 @@ TEST_F(ValidateAtomics, AtomicLoadVulkanSuccess) {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicLoadFloatVulkan) {
|
||||
const std::string body = R"(
|
||||
%val1 = OpAtomicLoad %f32 %f32_var %device %relaxed
|
||||
%val2 = OpAtomicLoad %f32 %f32_var %workgroup %acquire
|
||||
)";
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("expected Result Type to be int scalar type"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicLoadInt64WithCapabilityVulkanSuccess) {
|
||||
const std::string body = R"(
|
||||
%val1 = OpAtomicLoad %u64 %u64_var %device %relaxed
|
||||
%val2 = OpAtomicLoad %u64 %u64_var %workgroup %acquire
|
||||
)";
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body, "OpCapability Int64Atomics\n"),
|
||||
SPV_ENV_VULKAN_1_0);
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicLoadInt64WithoutCapabilityVulkan) {
|
||||
const std::string body = R"(
|
||||
%val1 = OpAtomicLoad %u64 %u64_var %device %relaxed
|
||||
%val2 = OpAtomicLoad %u64 %u64_var %workgroup %acquire
|
||||
)";
|
||||
|
||||
CompileSuccessfully(GenerateShaderCode(body), SPV_ENV_VULKAN_1_0);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("64-bit atomics require the Int64Atomics capability"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateAtomics, AtomicStoreOpenCLFunctionPointerStorageTypeSuccess) {
|
||||
const std::string body = R"(
|
||||
%f32_var_function = OpVariable %f32_ptr_function Function
|
||||
|
||||
@@ -2101,6 +2101,37 @@ TEST_F(ValidateDecorations, BlockArrayBadAlignmentWithVulkan1_1StillBad) {
|
||||
"member 1 at offset 8 is not aligned to 16"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, VulkanBufferBlockOnStorageBufferBad) {
|
||||
std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpExtension "SPV_KHR_storage_buffer_storage_class"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %1 "main"
|
||||
OpExecutionMode %1 OriginUpperLeft
|
||||
|
||||
OpDecorate %struct BufferBlock
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer StorageBuffer %struct
|
||||
%var = OpVariable %ptr StorageBuffer
|
||||
|
||||
%1 = OpFunction %void None %voidfn
|
||||
%label = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_1);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID,
|
||||
ValidateAndRetrieveValidationState(SPV_ENV_VULKAN_1_1));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("In Vulkan, BufferBlock is disallowed on variables in "
|
||||
"the StorageBuffer storage class"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, PushConstantArrayBaseAlignmentGood) {
|
||||
// Tests https://github.com/KhronosGroup/SPIRV-Tools/issues/1664
|
||||
// From GLSL vertex shader:
|
||||
@@ -2303,10 +2334,10 @@ TEST_F(ValidateDecorations, MultiplePushConstantsSingleEntryPointGood) {
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %1 "main"
|
||||
OpExecutionMode %1 OriginUpperLeft
|
||||
|
||||
|
||||
OpDecorate %struct Block
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -2314,7 +2345,7 @@ TEST_F(ValidateDecorations, MultiplePushConstantsSingleEntryPointGood) {
|
||||
%int_0 = OpConstant %int 0
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer PushConstant %struct
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%pc1 = OpVariable %ptr PushConstant
|
||||
%pc2 = OpVariable %ptr PushConstant
|
||||
|
||||
@@ -2341,10 +2372,10 @@ TEST_F(ValidateDecorations,
|
||||
OpEntryPoint Vertex %1 "func1"
|
||||
OpEntryPoint Fragment %2 "func2"
|
||||
OpExecutionMode %2 OriginUpperLeft
|
||||
|
||||
|
||||
OpDecorate %struct Block
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -2352,7 +2383,7 @@ TEST_F(ValidateDecorations,
|
||||
%int_0 = OpConstant %int 0
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer PushConstant %struct
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%pc1 = OpVariable %ptr PushConstant
|
||||
%pc2 = OpVariable %ptr PushConstant
|
||||
|
||||
@@ -2383,10 +2414,10 @@ TEST_F(ValidateDecorations,
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %1 "main"
|
||||
OpExecutionMode %1 OriginUpperLeft
|
||||
|
||||
|
||||
OpDecorate %struct Block
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -2394,7 +2425,7 @@ TEST_F(ValidateDecorations,
|
||||
%int_0 = OpConstant %int 0
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer PushConstant %struct
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%pc1 = OpVariable %ptr PushConstant
|
||||
%pc2 = OpVariable %ptr PushConstant
|
||||
|
||||
@@ -2415,10 +2446,10 @@ TEST_F(ValidateDecorations, VulkanMultiplePushConstantsSingleEntryPointBad) {
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %1 "main"
|
||||
OpExecutionMode %1 OriginUpperLeft
|
||||
|
||||
|
||||
OpDecorate %struct Block
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -2426,7 +2457,7 @@ TEST_F(ValidateDecorations, VulkanMultiplePushConstantsSingleEntryPointBad) {
|
||||
%int_0 = OpConstant %int 0
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer PushConstant %struct
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%pc1 = OpVariable %ptr PushConstant
|
||||
%pc2 = OpVariable %ptr PushConstant
|
||||
|
||||
@@ -2460,10 +2491,10 @@ TEST_F(ValidateDecorations,
|
||||
OpEntryPoint Vertex %1 "func1"
|
||||
OpEntryPoint Fragment %2 "func2"
|
||||
OpExecutionMode %2 OriginUpperLeft
|
||||
|
||||
|
||||
OpDecorate %struct Block
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -2471,10 +2502,10 @@ TEST_F(ValidateDecorations,
|
||||
%int_0 = OpConstant %int 0
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer PushConstant %struct
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%pc1 = OpVariable %ptr PushConstant
|
||||
%pc2 = OpVariable %ptr PushConstant
|
||||
|
||||
|
||||
%sub1 = OpFunction %void None %voidfn
|
||||
%label_sub1 = OpLabel
|
||||
%3 = OpAccessChain %ptr_float %pc1 %int_0
|
||||
@@ -2514,10 +2545,10 @@ TEST_F(ValidateDecorations,
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %1 "main"
|
||||
OpExecutionMode %1 OriginUpperLeft
|
||||
|
||||
|
||||
OpDecorate %struct Block
|
||||
OpMemberDecorate %struct 0 Offset 0
|
||||
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -2525,7 +2556,7 @@ TEST_F(ValidateDecorations,
|
||||
%int_0 = OpConstant %int 0
|
||||
%struct = OpTypeStruct %float
|
||||
%ptr = OpTypePointer PushConstant %struct
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%ptr_float = OpTypePointer PushConstant %float
|
||||
%pc1 = OpVariable %ptr PushConstant
|
||||
%pc2 = OpVariable %ptr PushConstant
|
||||
|
||||
@@ -2841,8 +2872,6 @@ TEST_F(ValidateDecorations,
|
||||
OpEntryPoint Fragment %1 "main"
|
||||
OpExecutionMode %1 OriginUpperLeft
|
||||
|
||||
OpDecorate %struct BufferBlock
|
||||
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
@@ -5097,6 +5126,37 @@ TEST_F(ValidateDecorations, NoUnsignedWrapExtInstGLSLGood) {
|
||||
EXPECT_THAT(getDiagnosticString(), Eq(""));
|
||||
}
|
||||
|
||||
TEST_F(ValidateDecorations, AliasedandRestrictBad) {
|
||||
const std::string body = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpSource GLSL 430
|
||||
OpMemberDecorate %Output 0 Offset 0
|
||||
OpDecorate %Output BufferBlock
|
||||
OpDecorate %dataOutput Restrict
|
||||
OpDecorate %dataOutput Aliased
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%Output = OpTypeStruct %float
|
||||
%_ptr_Uniform_Output = OpTypePointer Uniform %Output
|
||||
%dataOutput = OpVariable %_ptr_Uniform_Output Uniform
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(body.c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("decorated with both Aliased and Restrict is not allowed"));
|
||||
}
|
||||
|
||||
// TODO(dneto): For NoUnsignedWrap and NoUnsignedWrap, permit
|
||||
// "OpExtInst for instruction numbers specified in the extended
|
||||
// instruction-set specifications as accepting this decoration."
|
||||
|
||||
41
3rdparty/spirv-tools/test/val/val_id_test.cpp
vendored
41
3rdparty/spirv-tools/test/val/val_id_test.cpp
vendored
@@ -2178,6 +2178,47 @@ OpFunctionEnd
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, OpFunctionWithNonMemoryObject) {
|
||||
// DXC generates code that looks like when given something like:
|
||||
// T t;
|
||||
// t.s.fn_1();
|
||||
// This needs to be accepted before legalization takes place, so we
|
||||
// will include it with the relaxed logical pointer.
|
||||
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Vertex %1 "main"
|
||||
OpSource HLSL 600
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%void = OpTypeVoid
|
||||
%9 = OpTypeFunction %void
|
||||
%_struct_5 = OpTypeStruct
|
||||
%_struct_6 = OpTypeStruct %_struct_5
|
||||
%_ptr_Function__struct_6 = OpTypePointer Function %_struct_6
|
||||
%_ptr_Function__struct_5 = OpTypePointer Function %_struct_5
|
||||
%23 = OpTypeFunction %void %_ptr_Function__struct_5
|
||||
%1 = OpFunction %void None %9
|
||||
%10 = OpLabel
|
||||
%11 = OpVariable %_ptr_Function__struct_6 Function
|
||||
%20 = OpAccessChain %_ptr_Function__struct_5 %11 %int_0
|
||||
%21 = OpFunctionCall %void %12 %20
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%12 = OpFunction %void None %23
|
||||
%13 = OpFunctionParameter %_ptr_Function__struct_5
|
||||
%14 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto options = getValidatorOptions();
|
||||
options->relax_logical_pointer = true;
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage,
|
||||
OpVariablePointerVariablePointersStorageBufferGood) {
|
||||
const std::string spirv = R"(
|
||||
|
||||
Reference in New Issue
Block a user