diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml new file mode 100644 index 0000000000..c101eb66c4 --- /dev/null +++ b/.github/workflows/bazel.yml @@ -0,0 +1,26 @@ +name: Build and Test with Bazel + +on: [push, pull_request] + +jobs: + build: + timeout-minutes: 120 + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + - name: Download dependencies + run: python3 utils/git-sync-deps + - name: Mount Bazel cache + uses: actions/cache@v3 + with: + path: ~/.bazel/cache + key: bazel-cache-${{ runner.os }} + - name: Build All + run: bazel --output_user_root=~/.bazel/cache build //... + - name: Test All + run: bazel --output_user_root=~/.bazel/cache test //... diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 008a8678c5..0fc18062b4 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -1,6 +1,6 @@ name: Wasm Build -on: [ push, pull_request ] +on: [push, pull_request] jobs: build: diff --git a/CHANGES b/CHANGES index 384805c32b..6658e0e130 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,33 @@ Revision history for SPIRV-Tools -v2022.5-dev 2022-10-12 - - Start v2022.5-dev +v2023.1 2023-01-17 + - General + - Renamed "master" to "main" (issue#5051) + - Validate version 5 of clspv reflection (#5050) + - Remove testing support for VS2015 (#5027) + - Fix undef behaviour in hex float parsing (#5025) + - Require C++11 *or later* (#5020) + - Instrument + - Instrument: Fix bindless checking for BufferDeviceAddress (#5049) + - Optimizer + - Optimize allocation of spvtools::opt::Instruction::operands_ (#5024) + - spirv-opt: Fix OpCompositeInsert with Null Constant (#5008) + - spirv-opt: Handle null CompositeInsert (#4998) + - Add option to ADCE to remove output variables from interface. (#4994) + - Add support for tesc, tese and geom to EliminateDead*Components (#4990) + - Add pass to eliminate dead output components (#4982) + - spirv-opt: Add const folding for CompositeInsert (#4943) + - Add passes to eliminate dead output stores (#4970) + - Prevent eliminating case constructs in block merging (#4976) + - Validator + - Fix layout validation (#5015) + - Fix use of invalid analysis (#5013) + - Fix infinite loop in validator (#5006) + - Add validation support for SPV_NV_shader_invocation_reorder. (#4979) + - Only validate full layout in Vulkan environments (#4972) + - spirv-val: Label new Vulkan OpPtrAccessChain VUs (#4975) + - spirv-val: Add OpPtrAccessChain Base checks (#4965) + v2022.4 2022-10-12 - General diff --git a/CMakeLists.txt b/CMakeLists.txt index f9bfb4a303..a0f4eb23f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,18 +13,11 @@ # limitations under the License. cmake_minimum_required(VERSION 3.17.2) -if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) -endif() -if (POLICY CMP0054) - # Avoid dereferencing variables or interpret keywords that have been - # quoted or bracketed. - # https://cmake.org/cmake/help/v3.1/policy/CMP0054.html - cmake_policy(SET CMP0054 NEW) -endif() -set_property(GLOBAL PROPERTY USE_FOLDERS ON) project(spirv-tools) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + enable_testing() set(SPIRV_TOOLS "SPIRV-Tools") diff --git a/DEPS b/DEPS index b16d696431..c6e32ed601 100644 --- a/DEPS +++ b/DEPS @@ -3,7 +3,7 @@ use_relative_paths = True vars = { 'github': 'https://github.com', - 'effcee_revision': '35912e1b7778ec2ddcff7e7188177761539e59e0', + 'effcee_revision': 'c7b4db79f340f7a9981e8a484f6d5785e24242d1', # Pin to the last version of googletest that supports C++11. # Anything later requires C++14 @@ -12,8 +12,8 @@ vars = { # Use protobufs before they gained the dependency on abseil 'protobuf_revision': 'v3.13.0.1', - 're2_revision': 'd2836d1b1c34c4e330a85a1006201db474bf2c8a', - 'spirv_headers_revision': '34d04647d384e0aed037e7a2662a655fc39841bb', + 're2_revision': '954656f47fe8fb505d4818da1e128417a79ea500', + 'spirv_headers_revision': 'd13b52222c39a7e9a401b44646f0ca3a640fbd47', } deps = { diff --git a/README.md b/README.md index 6d1d66fa5d..10a8187bf1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # SPIR-V Tools +NEWS 2023-01-11: Development occurs on the `main` branch. + ## Overview The SPIR-V Tools project provides an API and commands for processing SPIR-V @@ -271,7 +273,7 @@ Contributions via merge request are welcome. Changes should: `clang-format version 5.0.0` for SPIRV-Tools. Settings are defined by the included [.clang-format](.clang-format) file. -We intend to maintain a linear history on the GitHub `master` branch. +We intend to maintain a linear history on the GitHub `main` branch. ### Getting the source diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e85ec9d9ae..acfa0c123b 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -425,10 +425,7 @@ if (ANDROID) endif() if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${SPIRV_TOOLS_TARGETS} EXPORT ${SPIRV_TOOLS}Targets) export(EXPORT ${SPIRV_TOOLS}Targets FILE ${SPIRV_TOOLS}Target.cmake) spvtools_config_package_dir(${SPIRV_TOOLS} PACKAGE_DIR) diff --git a/source/diff/CMakeLists.txt b/source/diff/CMakeLists.txt index 1328699ab1..52f18f2d13 100644 --- a/source/diff/CMakeLists.txt +++ b/source/diff/CMakeLists.txt @@ -39,10 +39,7 @@ set_property(TARGET SPIRV-Tools-diff PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-diff) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-diff EXPORT SPIRV-Tools-diffTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-diff EXPORT SPIRV-Tools-diffTargets) export(EXPORT SPIRV-Tools-diffTargets FILE SPIRV-Tools-diffTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-diff PACKAGE_DIR) diff --git a/source/fuzz/CMakeLists.txt b/source/fuzz/CMakeLists.txt index dd674dd04c..86ee657a1c 100644 --- a/source/fuzz/CMakeLists.txt +++ b/source/fuzz/CMakeLists.txt @@ -470,10 +470,7 @@ if(SPIRV_BUILD_FUZZER) spvtools_check_symbol_exports(SPIRV-Tools-fuzz) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-fuzz EXPORT SPIRV-Tools-fuzzTargets) export(EXPORT SPIRV-Tools-fuzzTargets FILE SPIRV-Tools-fuzzTarget.cmake) spvtools_config_package_dir(SPIRV-Tools-fuzz PACKAGE_DIR) diff --git a/source/link/CMakeLists.txt b/source/link/CMakeLists.txt index a452a107df..a35b9a58fd 100644 --- a/source/link/CMakeLists.txt +++ b/source/link/CMakeLists.txt @@ -31,10 +31,7 @@ set_property(TARGET SPIRV-Tools-link PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-link) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-link EXPORT SPIRV-Tools-linkTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-link EXPORT SPIRV-Tools-linkTargets) export(EXPORT SPIRV-Tools-linkTargets FILE SPIRV-Tools-linkTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-link PACKAGE_DIR) diff --git a/source/lint/CMakeLists.txt b/source/lint/CMakeLists.txt index 1feae3f94d..4704beb1fc 100644 --- a/source/lint/CMakeLists.txt +++ b/source/lint/CMakeLists.txt @@ -46,10 +46,7 @@ set_property(TARGET SPIRV-Tools-lint PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-lint) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-lint EXPORT SPIRV-Tools-lintTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-lint EXPORT SPIRV-Tools-lintTargets) export(EXPORT SPIRV-Tools-lintTargets FILE SPIRV-Tools-lintTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-lint PACKAGE_DIR) diff --git a/source/opt/CMakeLists.txt b/source/opt/CMakeLists.txt index c34c38d0b8..eea3c47532 100644 --- a/source/opt/CMakeLists.txt +++ b/source/opt/CMakeLists.txt @@ -271,10 +271,7 @@ set_property(TARGET SPIRV-Tools-opt PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-opt) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-opt EXPORT SPIRV-Tools-optTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-opt EXPORT SPIRV-Tools-optTargets) export(EXPORT SPIRV-Tools-optTargets FILE SPIRV-Tools-optTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-opt PACKAGE_DIR) diff --git a/source/opt/inst_bindless_check_pass.cpp b/source/opt/inst_bindless_check_pass.cpp index ca36dd6062..ad581e14c9 100644 --- a/source/opt/inst_bindless_check_pass.cpp +++ b/source/opt/inst_bindless_check_pass.cpp @@ -536,6 +536,8 @@ void InstBindlessCheckPass::GenCheckCode( new BasicBlock(std::move(valid_label))); builder.SetInsertPoint(&*new_blk_ptr); uint32_t new_ref_id = CloneOriginalReference(ref, &builder); + uint32_t null_id = 0; + uint32_t ref_type_id = ref->ref_inst->type_id(); (void)builder.AddBranch(merge_blk_id); new_blocks->push_back(std::move(new_blk_ptr)); // Gen invalid block @@ -563,10 +565,23 @@ void InstBindlessCheckPass::GenCheckCode( GenDebugStreamWrite(uid2offset_[ref->ref_inst->unique_id()], stage_idx, {error_id, u_index_id, u_length_id}, &builder); } + // Generate a ConstantNull, converting to uint64 if the type cannot be a null. + if (new_ref_id != 0) { + analysis::TypeManager* type_mgr = context()->get_type_mgr(); + analysis::Type* ref_type = type_mgr->GetType(ref_type_id); + if (ref_type->AsPointer() != nullptr) { + context()->AddCapability(spv::Capability::Int64); + uint32_t null_u64_id = GetNullId(GetUint64Id()); + Instruction* null_ptr_inst = builder.AddUnaryOp( + ref_type_id, spv::Op::OpConvertUToPtr, null_u64_id); + null_id = null_ptr_inst->result_id(); + } else { + null_id = GetNullId(ref_type_id); + } + } // Remember last invalid block id uint32_t last_invalid_blk_id = new_blk_ptr->GetLabelInst()->result_id(); // Gen zero for invalid reference - uint32_t ref_type_id = ref->ref_inst->type_id(); (void)builder.AddBranch(merge_blk_id); new_blocks->push_back(std::move(new_blk_ptr)); // Gen merge block @@ -577,8 +592,7 @@ void InstBindlessCheckPass::GenCheckCode( // reference. if (new_ref_id != 0) { Instruction* phi_inst = builder.AddPhi( - ref_type_id, {new_ref_id, valid_blk_id, GetNullId(ref_type_id), - last_invalid_blk_id}); + ref_type_id, {new_ref_id, valid_blk_id, null_id, last_invalid_blk_id}); context()->ReplaceAllUsesWith(ref->ref_inst->result_id(), phi_inst->result_id()); } @@ -734,15 +748,7 @@ void InstBindlessCheckPass::GenTexBuffCheckCode( if (image_ty_inst->GetSingleWordInOperand(kSpvTypeImageArrayed) != 0) return; if (image_ty_inst->GetSingleWordInOperand(kSpvTypeImageMS) != 0) return; // Enable ImageQuery Capability if not yet enabled - if (!get_feature_mgr()->HasCapability(spv::Capability::ImageQuery)) { - std::unique_ptr cap_image_query_inst( - new Instruction(context(), spv::Op::OpCapability, 0, 0, - std::initializer_list{ - {SPV_OPERAND_TYPE_CAPABILITY, - {uint32_t(spv::Capability::ImageQuery)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*cap_image_query_inst); - context()->AddCapability(std::move(cap_image_query_inst)); - } + context()->AddCapability(spv::Capability::ImageQuery); // Move original block's preceding instructions into first new block std::unique_ptr new_blk_ptr; MovePreludeCode(ref_inst_itr, ref_block_itr, &new_blk_ptr); diff --git a/source/opt/inst_buff_addr_check_pass.cpp b/source/opt/inst_buff_addr_check_pass.cpp index be361e69be..97d25f3c99 100644 --- a/source/opt/inst_buff_addr_check_pass.cpp +++ b/source/opt/inst_buff_addr_check_pass.cpp @@ -408,14 +408,7 @@ uint32_t InstBuffAddrCheckPass::GenSearchAndTest(Instruction* ref_inst, InstructionBuilder* builder, uint32_t* ref_uptr_id) { // Enable Int64 if necessary - if (!get_feature_mgr()->HasCapability(spv::Capability::Int64)) { - std::unique_ptr cap_int64_inst(new Instruction( - context(), spv::Op::OpCapability, 0, 0, - std::initializer_list{{SPV_OPERAND_TYPE_CAPABILITY, - {uint32_t(spv::Capability::Int64)}}})); - get_def_use_mgr()->AnalyzeInstDefUse(&*cap_int64_inst); - context()->AddCapability(std::move(cap_int64_inst)); - } + context()->AddCapability(spv::Capability::Int64); // Convert reference pointer to uint64 uint32_t ref_ptr_id = ref_inst->GetSingleWordInOperand(0); Instruction* ref_uptr_inst = diff --git a/source/reduce/CMakeLists.txt b/source/reduce/CMakeLists.txt index 6fd8409f69..9ebe4183ef 100644 --- a/source/reduce/CMakeLists.txt +++ b/source/reduce/CMakeLists.txt @@ -101,10 +101,7 @@ set_property(TARGET SPIRV-Tools-reduce PROPERTY FOLDER "SPIRV-Tools libraries") spvtools_check_symbol_exports(SPIRV-Tools-reduce) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS SPIRV-Tools-reduce EXPORT SPIRV-Tools-reduceTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS SPIRV-Tools-reduce EXPORT SPIRV-Tools-reduceTargets) export(EXPORT SPIRV-Tools-reduceTargets FILE SPIRV-Tools-reduceTarget.cmake) spvtools_config_package_dir(SPIRV-Tools-reduce PACKAGE_DIR) diff --git a/source/val/validate_extensions.cpp b/source/val/validate_extensions.cpp index ebb13cfd42..fa58e0f940 100644 --- a/source/val/validate_extensions.cpp +++ b/source/val/validate_extensions.cpp @@ -39,6 +39,20 @@ namespace spvtools { namespace val { namespace { +std::string ReflectionInstructionName(ValidationState_t& _, + const Instruction* inst) { + spv_ext_inst_desc desc = nullptr; + if (_.grammar().lookupExtInst(SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION, + inst->word(4), &desc) != SPV_SUCCESS || + !desc) { + return std::string("Unknown ExtInst"); + } + std::ostringstream ss; + ss << desc->name; + + return ss.str(); +} + uint32_t GetSizeTBitWidth(const ValidationState_t& _) { if (_.addressing_model() == spv::AddressingModel::Physical32) return 32; @@ -273,12 +287,14 @@ spv_result_t ValidateOperandDebugType( } spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, - const Instruction* inst) { + const Instruction* inst, + uint32_t version) { + const auto inst_name = ReflectionInstructionName(_, inst); const auto kernel_id = inst->GetOperandAs(4); const auto kernel = _.FindDef(kernel_id); if (kernel->opcode() != spv::Op::OpFunction) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel does not reference a function"; + << inst_name << " does not reference a function"; } bool found_kernel = false; @@ -290,18 +306,18 @@ spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, } if (!found_kernel) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel does not reference an entry-point"; + << inst_name << " does not reference an entry-point"; } const auto* exec_models = _.GetExecutionModels(kernel_id); if (!exec_models || exec_models->empty()) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel does not reference an entry-point"; + << inst_name << " does not reference an entry-point"; } for (auto exec_model : *exec_models) { if (exec_model != spv::ExecutionModel::GLCompute) { return _.diag(SPV_ERROR_INVALID_ID, inst) - << "Kernel must refer only to GLCompute entry-points"; + << inst_name << " must refer only to GLCompute entry-points"; } } @@ -323,6 +339,37 @@ spv_result_t ValidateClspvReflectionKernel(ValidationState_t& _, << "Name must match an entry-point for Kernel"; } + const auto num_operands = inst->operands().size(); + if (version < 5 && num_operands > 6) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Version " << version << " of the " << inst_name + << " instruction can only have 2 additional operands"; + } + + if (num_operands > 6) { + const auto num_args_id = inst->GetOperandAs(6); + if (!IsUint32Constant(_, num_args_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "NumArguments must be a 32-bit unsigned integer OpConstant"; + } + } + + if (num_operands > 7) { + const auto flags_id = inst->GetOperandAs(7); + if (!IsUint32Constant(_, flags_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Flags must be a 32-bit unsigned integer OpConstant"; + } + } + + if (num_operands > 8) { + const auto atts_id = inst->GetOperandAs(8); + if (_.GetIdOpcode(atts_id) != spv::Op::OpString) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Attributes must be an OpString"; + } + } + return SPV_SUCCESS; } @@ -439,8 +486,8 @@ spv_result_t ValidateClspvReflectionArgumentBuffer(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateClspvReflectionArgumentPodBuffer(ValidationState_t& _, - const Instruction* inst) { +spv_result_t ValidateClspvReflectionArgumentOffsetBuffer(ValidationState_t& _, + const Instruction* inst) { const auto num_operands = inst->operands().size(); if (auto error = ValidateKernelDecl(_, inst)) { return error; @@ -480,7 +527,7 @@ spv_result_t ValidateClspvReflectionArgumentPodBuffer(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateClspvReflectionArgumentPodPushConstant( +spv_result_t ValidateClspvReflectionArgumentPushConstant( ValidationState_t& _, const Instruction* inst) { const auto num_operands = inst->operands().size(); if (auto error = ValidateKernelDecl(_, inst)) { @@ -587,8 +634,8 @@ spv_result_t ValidateClspvReflectionPushConstant(ValidationState_t& _, return SPV_SUCCESS; } -spv_result_t ValidateClspvReflectionConstantData(ValidationState_t& _, - const Instruction* inst) { +spv_result_t ValidateClspvReflectionInitializedData(ValidationState_t& _, + const Instruction* inst) { if (!IsUint32Constant(_, inst->GetOperandAs(4))) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "DescriptorSet must be a 32-bit unsigned integer OpConstant"; @@ -650,18 +697,250 @@ spv_result_t ValidateClspvReflectionPropertyRequiredWorkgroupSize( return SPV_SUCCESS; } +spv_result_t ValidateClspvReflectionSubgroupMaxSize(ValidationState_t& _, + const Instruction* inst) { + const auto size_id = inst->GetOperandAs(4); + if (!IsUint32Constant(_, size_id)) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPointerRelocation(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "ObjectOffset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "PointerOffset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "PointerSize must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionImageMetadataPushConstant( + ValidationState_t& _, const Instruction* inst) { + if (auto error = ValidateKernelDecl(_, inst)) { + return error; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Ordinal must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(7))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionImageMetadataUniform( + ValidationState_t& _, const Instruction* inst) { + if (auto error = ValidateKernelDecl(_, inst)) { + return error; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Ordinal must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "DescriptorSet must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(7))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Binding must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(8))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(9))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPushConstantData(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + if (_.GetIdOpcode(inst->GetOperandAs(6)) != spv::Op::OpString) { + return _.diag(SPV_ERROR_INVALID_ID, inst) << "Data must be an OpString"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPrintfInfo(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "PrintfID must be a 32-bit unsigned integer OpConstant"; + } + + if (_.GetIdOpcode(inst->GetOperandAs(5)) != spv::Op::OpString) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "FormatString must be an OpString"; + } + + for (size_t i = 6; i < inst->operands().size(); ++i) { + if (!IsUint32Constant(_, inst->GetOperandAs(i))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "ArgumentSizes must be a 32-bit unsigned integer OpConstant"; + } + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPrintfStorageBuffer(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "DescriptorSet must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Binding must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + +spv_result_t ValidateClspvReflectionPrintfPushConstant(ValidationState_t& _, + const Instruction* inst) { + if (!IsUint32Constant(_, inst->GetOperandAs(4))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Offset must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(5))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "Size must be a 32-bit unsigned integer OpConstant"; + } + + if (!IsUint32Constant(_, inst->GetOperandAs(6))) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "BufferSize must be a 32-bit unsigned integer OpConstant"; + } + + return SPV_SUCCESS; +} + spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _, const Instruction* inst, - uint32_t /*version*/) { + uint32_t version) { if (!_.IsVoidType(inst->type_id())) { return _.diag(SPV_ERROR_INVALID_ID, inst) << "Return Type must be OpTypeVoid"; } - auto ext_inst = inst->GetOperandAs(3); + uint32_t required_version = 0; + const auto ext_inst = + inst->GetOperandAs(3); + switch (ext_inst) { + case NonSemanticClspvReflectionKernel: + case NonSemanticClspvReflectionArgumentInfo: + case NonSemanticClspvReflectionArgumentStorageBuffer: + case NonSemanticClspvReflectionArgumentUniform: + case NonSemanticClspvReflectionArgumentPodStorageBuffer: + case NonSemanticClspvReflectionArgumentPodUniform: + case NonSemanticClspvReflectionArgumentPodPushConstant: + case NonSemanticClspvReflectionArgumentSampledImage: + case NonSemanticClspvReflectionArgumentStorageImage: + case NonSemanticClspvReflectionArgumentSampler: + case NonSemanticClspvReflectionArgumentWorkgroup: + case NonSemanticClspvReflectionSpecConstantWorkgroupSize: + case NonSemanticClspvReflectionSpecConstantGlobalOffset: + case NonSemanticClspvReflectionSpecConstantWorkDim: + case NonSemanticClspvReflectionPushConstantGlobalOffset: + case NonSemanticClspvReflectionPushConstantEnqueuedLocalSize: + case NonSemanticClspvReflectionPushConstantGlobalSize: + case NonSemanticClspvReflectionPushConstantRegionOffset: + case NonSemanticClspvReflectionPushConstantNumWorkgroups: + case NonSemanticClspvReflectionPushConstantRegionGroupOffset: + case NonSemanticClspvReflectionConstantDataStorageBuffer: + case NonSemanticClspvReflectionConstantDataUniform: + case NonSemanticClspvReflectionLiteralSampler: + case NonSemanticClspvReflectionPropertyRequiredWorkgroupSize: + required_version = 1; + break; + case NonSemanticClspvReflectionSpecConstantSubgroupMaxSize: + required_version = 2; + break; + case NonSemanticClspvReflectionArgumentPointerPushConstant: + case NonSemanticClspvReflectionArgumentPointerUniform: + case NonSemanticClspvReflectionProgramScopeVariablesStorageBuffer: + case NonSemanticClspvReflectionProgramScopeVariablePointerRelocation: + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderPushConstant: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypePushConstant: + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderUniform: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypeUniform: + required_version = 3; + break; + case NonSemanticClspvReflectionArgumentStorageTexelBuffer: + case NonSemanticClspvReflectionArgumentUniformTexelBuffer: + required_version = 4; + break; + case NonSemanticClspvReflectionConstantDataPointerPushConstant: + case NonSemanticClspvReflectionProgramScopeVariablePointerPushConstant: + case NonSemanticClspvReflectionPrintfInfo: + case NonSemanticClspvReflectionPrintfBufferStorageBuffer: + case NonSemanticClspvReflectionPrintfBufferPointerPushConstant: + required_version = 5; + break; + default: + break; + } + if (version < required_version) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << ReflectionInstructionName(_, inst) << " requires version " + << required_version << ", but parsed version is " << version; + } + switch (ext_inst) { case NonSemanticClspvReflectionKernel: - return ValidateClspvReflectionKernel(_, inst); + return ValidateClspvReflectionKernel(_, inst, version); case NonSemanticClspvReflectionArgumentInfo: return ValidateClspvReflectionArgumentInfo(_, inst); case NonSemanticClspvReflectionArgumentStorageBuffer: @@ -669,12 +948,16 @@ spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _, case NonSemanticClspvReflectionArgumentSampledImage: case NonSemanticClspvReflectionArgumentStorageImage: case NonSemanticClspvReflectionArgumentSampler: + case NonSemanticClspvReflectionArgumentStorageTexelBuffer: + case NonSemanticClspvReflectionArgumentUniformTexelBuffer: return ValidateClspvReflectionArgumentBuffer(_, inst); case NonSemanticClspvReflectionArgumentPodStorageBuffer: case NonSemanticClspvReflectionArgumentPodUniform: - return ValidateClspvReflectionArgumentPodBuffer(_, inst); + case NonSemanticClspvReflectionArgumentPointerUniform: + return ValidateClspvReflectionArgumentOffsetBuffer(_, inst); case NonSemanticClspvReflectionArgumentPodPushConstant: - return ValidateClspvReflectionArgumentPodPushConstant(_, inst); + case NonSemanticClspvReflectionArgumentPointerPushConstant: + return ValidateClspvReflectionArgumentPushConstant(_, inst); case NonSemanticClspvReflectionArgumentWorkgroup: return ValidateClspvReflectionArgumentWorkgroup(_, inst); case NonSemanticClspvReflectionSpecConstantWorkgroupSize: @@ -691,11 +974,31 @@ spv_result_t ValidateClspvReflectionInstruction(ValidationState_t& _, return ValidateClspvReflectionPushConstant(_, inst); case NonSemanticClspvReflectionConstantDataStorageBuffer: case NonSemanticClspvReflectionConstantDataUniform: - return ValidateClspvReflectionConstantData(_, inst); + case NonSemanticClspvReflectionProgramScopeVariablesStorageBuffer: + return ValidateClspvReflectionInitializedData(_, inst); case NonSemanticClspvReflectionLiteralSampler: return ValidateClspvReflectionSampler(_, inst); case NonSemanticClspvReflectionPropertyRequiredWorkgroupSize: return ValidateClspvReflectionPropertyRequiredWorkgroupSize(_, inst); + case NonSemanticClspvReflectionSpecConstantSubgroupMaxSize: + return ValidateClspvReflectionSubgroupMaxSize(_, inst); + case NonSemanticClspvReflectionProgramScopeVariablePointerRelocation: + return ValidateClspvReflectionPointerRelocation(_, inst); + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderPushConstant: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypePushConstant: + return ValidateClspvReflectionImageMetadataPushConstant(_, inst); + case NonSemanticClspvReflectionImageArgumentInfoChannelOrderUniform: + case NonSemanticClspvReflectionImageArgumentInfoChannelDataTypeUniform: + return ValidateClspvReflectionImageMetadataUniform(_, inst); + case NonSemanticClspvReflectionConstantDataPointerPushConstant: + case NonSemanticClspvReflectionProgramScopeVariablePointerPushConstant: + return ValidateClspvReflectionPushConstantData(_, inst); + case NonSemanticClspvReflectionPrintfInfo: + return ValidateClspvReflectionPrintfInfo(_, inst); + case NonSemanticClspvReflectionPrintfBufferStorageBuffer: + return ValidateClspvReflectionPrintfStorageBuffer(_, inst); + case NonSemanticClspvReflectionPrintfBufferPointerPushConstant: + return ValidateClspvReflectionPrintfPushConstant(_, inst); default: break; } diff --git a/source/val/validate_memory.cpp b/source/val/validate_memory.cpp index 57fd23d532..5f7358c686 100644 --- a/source/val/validate_memory.cpp +++ b/source/val/validate_memory.cpp @@ -1398,7 +1398,7 @@ spv_result_t ValidateAccessChain(ValidationState_t& _, } default: { // Give an error. reached non-composite type while indexes still remain. - return _.diag(SPV_ERROR_INVALID_ID, cur_word_instr) + return _.diag(SPV_ERROR_INVALID_ID, inst) << instr_name << " reached non-composite type while indexes " "still remain to be traversed."; diff --git a/test/opt/inst_bindless_check_test.cpp b/test/opt/inst_bindless_check_test.cpp index 4f4b6681c3..3600d0d228 100644 --- a/test/opt/inst_bindless_check_test.cpp +++ b/test/opt/inst_bindless_check_test.cpp @@ -159,9 +159,9 @@ static const std::string kStreamWrite4Ray = kStreamWrite4Begin + R"( ; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} ; CHECK: OpStore {{%\w+}} {{%\w+}} ; CHECK: {{%\w+}} = OpLoad %v3uint {{%\w+}} -; CHECK: {{%\w+}} = OpCompositeExtract %uint %90 0 -; CHECK: {{%\w+}} = OpCompositeExtract %uint %90 1 -; CHECK: {{%\w+}} = OpCompositeExtract %uint %90 2 +; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 0 +; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 1 +; CHECK: {{%\w+}} = OpCompositeExtract %uint {{%\w+}} 2 ; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 ; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} ; CHECK: OpStore {{%\w+}} {{%\w+}} @@ -567,14 +567,12 @@ OpDecorate %_entryPointOutput_vColor Location 0 %_ptr_Output_v4float = OpTypePointer Output %v4float %_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output ; CHECK: %bool = OpTypeBool -; CHECK: %48 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %103 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -601,10 +599,10 @@ OpStore %_entryPointOutput_vColor %37 ; CHECK: %46 = OpImageSampleImplicitLod %v4float %45 %30 ; CHECK: OpBranch %41 ; CHECK: %43 = OpLabel -; CHECK: %102 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_56 %uint_0 %32 %uint_128 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_56 %uint_0 %32 %uint_128 ; CHECK: OpBranch %41 ; CHECK: %41 = OpLabel -; CHECK: %104 = OpPhi %v4float %46 %42 %103 %43 +; CHECK: %104 = OpPhi %v4float %46 %42 [[null_v4float]] %43 ; CHECK: OpStore %_entryPointOutput_vColor %104 OpReturn OpFunctionEnd @@ -706,14 +704,14 @@ OpDecorate %_entryPointOutput_vColor Location 0 %_ptr_Output_v4float = OpTypePointer Output %v4float %_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output ; CHECK: %bool = OpTypeBool -; CHECK: %56 = OpTypeFunction %void %uint %uint %uint %uint +; CHECK: {{%\w+}} = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %111 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -738,10 +736,10 @@ OpDecorate %_entryPointOutput_vColor Location 0 ; CHECK: %54 = OpImageSampleImplicitLod %v4float %53 %31 ; CHECK: OpBranch %49 ; CHECK: %51 = OpLabel -; CHECK: %110 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_58 %uint_0 %33 %uint_128 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_58 %uint_0 %33 %uint_128 ; CHECK: OpBranch %49 ; CHECK: %49 = OpLabel -; CHECK: %112 = OpPhi %v4float %54 %50 %111 %51 +; CHECK: %112 = OpPhi %v4float %54 %50 [[null_v4float]] %51 %39 = OpAccessChain %_ptr_PushConstant_uint %_ %int_1 %40 = OpLoad %uint %39 %41 = OpAccessChain %_ptr_UniformConstant_17 %g_tColor %40 @@ -763,7 +761,7 @@ OpDecorate %_entryPointOutput_vColor Location 0 ; CHECK: %121 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_64 %uint_0 %40 %uint_128 ; CHECK: OpBranch %114 ; CHECK: %114 = OpLabel -; CHECK: %122 = OpPhi %v4float %119 %115 %111 %116 +; CHECK: %122 = OpPhi %v4float %119 %115 [[null_v4float]] %116 ; CHECK: %45 = OpFAdd %v4float %112 %122 OpStore %_entryPointOutput_vColor %45 OpReturn @@ -835,14 +833,13 @@ OpDecorate %_entryPointOutput_vColor Location 0 %_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output ; CHECK: uint_0 = OpConstant %uint 0 ; CHECK: bool = OpTypeBool -; CHECK: %86 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %141 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -868,10 +865,10 @@ OpStore %_entryPointOutput_vColor %71 ; CHECK: %84 = OpImageRead %v4float %83 %53 ; CHECK: OpBranch %79 ; CHECK: %81 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %64 %uint_128 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %64 %uint_128 ; CHECK: OpBranch %79 ; CHECK: %79 = OpLabel -; CHECK: %142 = OpPhi %v4float %84 %80 %141 %81 +; CHECK: %142 = OpPhi %v4float %84 %80 [[null_v4float]] %81 ; CHECK: OpStore %_entryPointOutput_vColor %142 OpReturn OpFunctionEnd @@ -940,14 +937,13 @@ OpDecorate %_entryPointOutput_vColor Location 0 %_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output ; CHECK: uint_0 = OpConstant %uint 0 ; CHECK: bool = OpTypeBool -; CHECK: %81 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %136 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -971,10 +967,10 @@ OpStore %_entryPointOutput_vColor %71 ; CHECK: %79 = OpImageSampleImplicitLod %v4float %78 %53 ; CHECK: OpBranch %75 ; CHECK: %77 = OpLabel -; CHECK: %135 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_49 %uint_0 %64 %uint_128 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_49 %uint_0 %64 %uint_128 ; CHECK: OpBranch %75 ; CHECK: %75 = OpLabel -; CHECK: %137 = OpPhi %v4float %79 %76 %136 %77 +; CHECK: %137 = OpPhi %v4float %79 %76 [[null_v4float]] %77 ; CHECK: OpStore %_entryPointOutput_vColor %137 OpReturn OpFunctionEnd @@ -1167,14 +1163,13 @@ OpDecorate %coords2D Location 0 %_ptr_Input_v2float = OpTypePointer Input %v2float %coords2D = OpVariable %_ptr_Input_v2float Input ; CHECK: %bool = OpTypeBool -; CHECK: %54 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %_ptr_Input_uint = OpTypePointer Input %uint ; CHECK: %gl_VertexIndex = OpVariable %_ptr_Input_uint Input ; CHECK: %gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -; CHECK: %106 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -1205,11 +1200,11 @@ OpStore %40 %38 ; CHECK: %51 = OpImageSampleExplicitLod %v4float %50 %40 Lod %41 ; CHECK: OpBranch %47 ; CHECK: %49 = OpLabel -; CHECK: %52 = OpBitcast %uint %37 -; CHECK: %105 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_74 %uint_0 %52 %uint_128 +; CHECK: [[bitcast_result:%\w+]] = OpBitcast %uint %37 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_74 %uint_0 [[bitcast_result]] %uint_128 ; CHECK: OpBranch %47 ; CHECK: %47 = OpLabel -; CHECK: %107 = OpPhi %v4float %51 %48 %106 %49 +; CHECK: %107 = OpPhi %v4float %51 %48 [[null_v4float]] %49 ; CHECK: %43 = OpAccessChain %_ptr_Output_v4float %_ %int_0 ; CHECK: OpStore %43 %107 OpReturn @@ -1309,7 +1304,6 @@ OpDecorate %uniform_index_buffer Binding 0 %_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float %_ptr_Output_v4float = OpTypePointer Output %v4float ; CHECK: %bool = OpTypeBool -; CHECK: %40 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint @@ -1319,7 +1313,7 @@ OpDecorate %uniform_index_buffer Binding 0 ; CHECK: %_ptr_Input_v3float = OpTypePointer Input %v3float ; CHECK: %gl_TessCoord = OpVariable %_ptr_Input_v3float Input ; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %101 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -1338,10 +1332,10 @@ OpDecorate %uniform_index_buffer Binding 0 ; CHECK: %38 = OpLoad %v4float %29 ; CHECK: OpBranch %35 ; CHECK: %37 = OpLabel -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_63 %uint_0 %28 %uint_11 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_63 %uint_0 %28 %uint_11 ; CHECK: OpBranch %35 ; CHECK: %35 = OpLabel -; CHECK: %102 = OpPhi %v4float %38 %36 %101 %37 +; CHECK: %102 = OpPhi %v4float %38 %36 [[null_v4float]] %37 %31 = OpAccessChain %_ptr_Output_v4float %_ %int_0 OpStore %31 %29 ; CHECK-NOT: OpStore %31 %29 @@ -1435,14 +1429,13 @@ OpDecorate %_entryPointOutput_vColor Location 0 %_ptr_Output_v4float = OpTypePointer Output %v4float %_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output ; CHECK: %bool = OpTypeBool -; CHECK: %70 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %125 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -1492,13 +1485,16 @@ OpLine %1 24 0 ; CHECK: OpNoLine ; CHECK: OpBranch %63 ; CHECK: %65 = OpLabel -; CHECK: %124 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_109 %uint_0 %50 %uint_128 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_109 %uint_0 %50 %uint_128 ; CHECK: OpBranch %63 ; CHECK: %63 = OpLabel -; CHECK: %126 = OpPhi %v4float %68 %64 %125 %65 +; CHECK: [[phi_result:%\w+]] = OpPhi %v4float %68 %64 [[null_v4float]] %65 ; CHECK: OpLine %5 24 0 %47 = OpAccessChain %_ptr_Function_v4float %ps_output %int_0 OpStore %47 %45 +; CHECK-NOT: OpStore %47 %45 +; CHECK: [[store_loc:%\w+]] = OpAccessChain %_ptr_Function_v4float %ps_output %int_0 +; CHECK: OpStore [[store_loc]] [[phi_result]] OpLine %1 25 0 %48 = OpLoad %PS_OUTPUT %ps_output OpReturnValue %48 @@ -1580,13 +1576,11 @@ OpDecorate %_entryPointOutput_vColor Location 0 )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %65 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %116 = OpConstantNull %v4float -; CHECK: %119 = OpTypeFunction %uint %uint %uint %uint %uint +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -1624,14 +1618,14 @@ OpStore %_entryPointOutput_vColor %71 ; CHECK: %144 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_59 %uint_1 %32 %uint_0 ; CHECK: OpBranch %138 ; CHECK: %138 = OpLabel -; CHECK: %145 = OpPhi %v4float %143 %139 %116 %140 +; CHECK: [[phi_result_1:%\w+]] = OpPhi %v4float %143 %139 [[null_v4float]] %140 ; CHECK: OpBranch %58 ; CHECK: %60 = OpLabel -; CHECK: %115 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_59 %uint_0 %32 %55 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_59 %uint_0 %32 %55 ; CHECK: OpBranch %58 ; CHECK: %58 = OpLabel -; CHECK: %117 = OpPhi %v4float %145 %138 %116 %60 -; CHECK: OpStore %_entryPointOutput_vColor %117 +; CHECK: [[phi_result_2:%\w+]] = OpPhi %v4float [[phi_result_1]] %138 [[null_v4float]] %60 +; CHECK: OpStore %_entryPointOutput_vColor [[phi_result_2]] OpReturn OpFunctionEnd )"; @@ -1698,12 +1692,11 @@ OpDecorate %_entryPointOutput_vColor Location 0 )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %61 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %113 = OpConstantNull %v4float +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )"; // clang-format on @@ -1728,11 +1721,11 @@ OpStore %_entryPointOutput_vColor %24 ; CHECK: %59 = OpImageSampleImplicitLod %v4float %58 %20 ; CHECK: OpBranch %54 ; CHECK: %56 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_39 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_39 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %54 ; CHECK: %54 = OpLabel -; CHECK: %114 = OpPhi %v4float %59 %55 %113 %56 -; CHECK: OpStore %_entryPointOutput_vColor %114 +; CHECK: [[phi_result:%\w+]] = OpPhi %v4float %59 %55 [[null_v4float]] %56 +; CHECK: OpStore %_entryPointOutput_vColor [[phi_result]] OpReturn OpFunctionEnd )"; @@ -1932,14 +1925,12 @@ OpDecorate %20 NonUniform )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %49 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %v4float = OpTypeVector %float 4 ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %101 = OpConstantNull %float -; CHECK: %105 = OpTypeFunction %uint %uint %uint %uint %uint +; CHECK: [[null_float:%\w+]] = OpConstantNull %float )"; // clang-format on @@ -1970,15 +1961,15 @@ OpStore %b %20 ; CHECK: %129 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %128 %uint_0 ; CHECK: OpBranch %124 ; CHECK: %124 = OpLabel -; CHECK: %130 = OpPhi %float %127 %125 %101 %126 +; CHECK: [[phi_result_1:%\w+]] = OpPhi %float %127 %125 [[null_float]] %126 ; CHECK: OpBranch %43 ; CHECK: %45 = OpLabel -; CHECK: %47 = OpBitcast %uint %7 -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %47 %40 +; CHECK: [[bitcast_result:%\w+]] = OpBitcast %uint %7 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 [[bitcast_result]] %40 ; CHECK: OpBranch %43 ; CHECK: %43 = OpLabel -; CHECK: %102 = OpPhi %float %130 %124 %101 %45 -; CHECK: OpStore %b %102 +; CHECK: [[phi_result_2:%\w+]] = OpPhi %float [[phi_result_1]] %124 [[null_float]] %45 +; CHECK: OpStore %b [[phi_result_2]] OpReturn OpFunctionEnd )"; @@ -2062,14 +2053,12 @@ OpDecorate %20 NonUniform )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %49 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %v4float = OpTypeVector %float 4 ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %101 = OpConstantNull %float -; CHECK: %105 = OpTypeFunction %uint %uint %uint %uint %uint +; CHECK: [[null_float:%\w+]] = OpConstantNull %float )"; // clang-format on @@ -2087,8 +2076,8 @@ OpStore %b %20 ; CHECK: OpSelectionMerge %43 None ; CHECK: OpBranchConditional %42 %44 %45 ; CHECK: %44 = OpLabel -; CHECK: %103 = OpBitcast %uint %7 -; CHECK: %122 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 %103 +; CHECK: [[bitcast_result_1:%\w+]] = OpBitcast %uint %7 +; CHECK: %122 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_3 [[bitcast_result_1]] ; CHECK: %123 = OpULessThan %bool %uint_0 %122 ; CHECK: OpSelectionMerge %124 None ; CHECK: OpBranchConditional %123 %125 %126 @@ -2100,15 +2089,15 @@ OpStore %b %20 ; CHECK: %129 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %128 %uint_0 ; CHECK: OpBranch %124 ; CHECK: %124 = OpLabel -; CHECK: %130 = OpPhi %float %127 %125 %101 %126 +; CHECK: [[phi_result_1:%\w+]] = OpPhi %float %127 %125 [[null_float]] %126 ; CHECK: OpBranch %43 ; CHECK: %45 = OpLabel -; CHECK: %47 = OpBitcast %uint %7 -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %47 %40 +; CHECK: [[bitcast_result_2:%\w+]] = OpBitcast %uint %7 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 [[bitcast_result_2]] %40 ; CHECK: OpBranch %43 ; CHECK: %43 = OpLabel -; CHECK: %102 = OpPhi %float %130 %124 %101 %45 -; CHECK: OpStore %b %102 +; CHECK: [[phi_result_2:%\w+]] = OpPhi %float [[phi_result_1]] %124 [[null_float]] %45 +; CHECK: OpStore %b [[phi_result_2]] OpReturn OpFunctionEnd )"; @@ -2181,14 +2170,12 @@ OpDecorate %20 NonUniform )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %49 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %v4float = OpTypeVector %float 4 ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %101 = OpConstantNull %float -; CHECK: %105 = OpTypeFunction %uint %uint %uint %uint %uint +; CHECK: [[null_float:%\w+]] = OpConstantNull %float )"; // clang-format on @@ -2219,15 +2206,15 @@ OpStore %b %20 ; CHECK: %129 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_1 %128 %uint_0 ; CHECK: OpBranch %124 ; CHECK: %124 = OpLabel -; CHECK: %130 = OpPhi %float %127 %125 %101 %126 +; CHECK: [[phi_result_1:%\w+]] = OpPhi %float %127 %125 [[null_float]] %126 ; CHECK: OpBranch %43 ; CHECK: %45 = OpLabel -; CHECK: %47 = OpBitcast %uint %7 -; CHECK: %100 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 %47 %40 +; CHECK: [[bitcast_result:%\w+]] = OpBitcast %uint %7 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_45 %uint_0 [[bitcast_result]] %40 ; CHECK: OpBranch %43 ; CHECK: %43 = OpLabel -; CHECK: %102 = OpPhi %float %130 %124 %101 %45 -; CHECK: OpStore %b %102 +; CHECK: [[phi_result_2:%\w+]] = OpPhi %float [[phi_result_1]] %124 [[null_float]] %45 +; CHECK: OpStore %b [[phi_result_2]] OpReturn OpFunctionEnd )"; @@ -2296,13 +2283,12 @@ OpDecorate %uniformBuffer Binding 3 )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %52 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %v4float = OpTypeVector %float 4 ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %104 = OpConstantNull %float +; CHECK: [[null_float:%\w+]] = OpConstantNull %float )"; // clang-format on @@ -2322,11 +2308,11 @@ OpStore %b %16 ; CHECK: %50 = OpLoad %float %15 ; CHECK: OpBranch %47 ; CHECK: %49 = OpLabel -; CHECK: %103 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_32 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_32 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %47 ; CHECK: %47 = OpLabel -; CHECK: %105 = OpPhi %float %50 %48 %104 %49 -; CHECK: OpStore %b %105 +; CHECK: [[phi_result:%\w+]] = OpPhi %float %50 %48 [[null_float]] %49 +; CHECK: OpStore %b [[phi_result]] OpReturn OpFunctionEnd )"; @@ -2523,7 +2509,6 @@ OpDecorate %22 NonUniform %int_0 = OpConstant %int 0 %_ptr_Uniform_float = OpTypePointer Uniform %float ; CHECK: %bool = OpTypeBool -; CHECK: %32 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint @@ -2531,8 +2516,7 @@ OpDecorate %22 NonUniform ; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input ; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %88 = OpConstantNull %float -; CHECK: %92 = OpTypeFunction %uint %uint %uint %uint %uint +; CHECK: [[null_float:%\w+]] = OpConstantNull %float )" + kInputGlobals; // clang-format on @@ -2562,15 +2546,15 @@ OpStore %b %22 ; CHECK: %119 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_46 %uint_1 %118 %uint_0 ; CHECK: OpBranch %114 ; CHECK: %114 = OpLabel -; CHECK: %120 = OpPhi %float %117 %115 %88 %116 +; CHECK: [[phi_result_1:%\w+]] = OpPhi %float %117 %115 [[null_float]] %116 ; CHECK: OpBranch %26 ; CHECK: %28 = OpLabel -; CHECK: %30 = OpBitcast %uint %7 -; CHECK: %87 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_46 %uint_0 %30 %uint_128 +; CHECK: [[bitcast_result:%\w+]] = OpBitcast %uint %7 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_46 %uint_0 [[bitcast_result]] %uint_128 ; CHECK: OpBranch %26 ; CHECK: %26 = OpLabel -; CHECK: %89 = OpPhi %float %120 %114 %88 %28 -; CHECK: OpStore %b %89 +; CHECK: [[phi_result_2:%\w+]] = OpPhi %float [[phi_result_1]] %114 [[null_float]] %28 +; CHECK: OpStore %b [[phi_result_2]] OpReturn OpFunctionEnd )"; @@ -2653,19 +2637,16 @@ OpDecorate %images NonWritable %v4float = OpTypeVector %float 4 %uint_0 = OpConstant %uint 0 %_ptr_Uniform_float = OpTypePointer Uniform %float -; CHECK: %34 = OpTypeFunction %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( ; CHECK: %v3uint = OpTypeVector %uint 3 ; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint ; CHECK: %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input -; CHECK: %112 = OpConstantNull %v4float -; CHECK: %115 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %140 = OpConstantNull %uint +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -2689,10 +2670,10 @@ OpStore %31 %29 ; CHECK: %137 = OpLoad %uint %25 ; CHECK: OpBranch %134 ; CHECK: %136 = OpLabel -; CHECK: %139 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_47 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_47 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %134 ; CHECK: %134 = OpLabel -; CHECK: %141 = OpPhi %uint %137 %135 %140 %136 +; CHECK: [[phi_result_1:%\w+]] = OpPhi %uint %137 %135 [[null_uint]] %136 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %141 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -2701,7 +2682,7 @@ OpStore %31 %29 ; CHECK: OpBranchConditional %50 %52 %53 ; CHECK: %52 = OpLabel ; CHECK: %54 = OpLoad %13 %27 -; CHECK: %142 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 %141 +; CHECK: {{%\w+}} = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_1 [[phi_result_1]] ; CHECK: %143 = OpULessThan %bool %uint_0 %142 ; CHECK: OpSelectionMerge %144 None ; CHECK: OpBranchConditional %143 %145 %146 @@ -2713,13 +2694,13 @@ OpStore %31 %29 ; CHECK: %149 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_50 %uint_1 %141 %uint_0 ; CHECK: OpBranch %144 ; CHECK: %144 = OpLabel -; CHECK: %150 = OpPhi %v4float %148 %145 %112 %146 +; CHECK: [[phi_result_2:%\w+]] = OpPhi %v4float %148 %145 [[null_v4float]] %146 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %111 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_50 %uint_0 %141 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_50 %uint_0 %141 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %113 = OpPhi %v4float %150 %144 %112 %53 +; CHECK: %113 = OpPhi %v4float [[phi_result_2]] %144 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %113 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %151 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -2774,7 +2755,7 @@ OpExtension "SPV_NV_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint RayGenerationNV %main "main" -; CHECK: OpEntryPoint RayGenerationNV %main "main" %89 +; CHECK: OpEntryPoint RayGenerationNV %main "main" [[launch_id:%\w+]] OpSource GLSL 460 OpSourceExtension "GL_EXT_nonuniform_qualifier" OpSourceExtension "GL_NV_ray_tracing" @@ -2794,7 +2775,7 @@ OpDecorate %images Binding 1 OpDecorate %images NonWritable ; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 )" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV +; CHECK: OpDecorate [[launch_id]] BuiltIn LaunchIdNV %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 @@ -2821,14 +2802,9 @@ OpDecorate %images NonWritable )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -2852,10 +2828,10 @@ OpStore %31 %29 ; CHECK: %138 = OpLoad %uint %25 ; CHECK: OpBranch %135 ; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %135 ; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 +; CHECK: %142 = OpPhi %uint %138 %136 [[null_uint]] %137 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -2876,13 +2852,13 @@ OpStore %31 %29 ; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 ; CHECK: OpBranch %145 ; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 +; CHECK: %151 = OpPhi %v4float %149 %146 [[null_v4float]] %147 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 +; CHECK: %114 = OpPhi %v4float %151 %145 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %114 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -2936,7 +2912,7 @@ OpExtension "SPV_NV_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint IntersectionNV %main "main" -; CHECK: OpEntryPoint IntersectionNV %main "main" %89 +; CHECK: OpEntryPoint IntersectionNV %main "main" [[launch_id:%\w+]] OpSource GLSL 460 OpSourceExtension "GL_EXT_nonuniform_qualifier" OpSourceExtension "GL_NV_ray_tracing" @@ -2956,7 +2932,7 @@ OpDecorate %images Binding 1 OpDecorate %images NonWritable ; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 )" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV +; CHECK: OpDecorate [[launch_id]] BuiltIn LaunchIdNV %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 @@ -2984,12 +2960,9 @@ OpDecorate %images NonWritable ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool )" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint +; CHECK: [[launch_id]] = OpVariable %_ptr_Input_v3uint Input +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -3013,10 +2986,10 @@ OpStore %31 %29 ; CHECK: %138 = OpLoad %uint %25 ; CHECK: OpBranch %135 ; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %135 ; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 +; CHECK: %142 = OpPhi %uint %138 %136 [[null_uint]] %137 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -3037,13 +3010,13 @@ OpStore %31 %29 ; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 ; CHECK: OpBranch %145 ; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 +; CHECK: %151 = OpPhi %v4float %149 %146 [[null_v4float]] %147 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 +; CHECK: %114 = OpPhi %v4float %151 %145 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %114 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -3097,7 +3070,7 @@ OpExtension "SPV_NV_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint AnyHitNV %main "main" -; CHECK: OpEntryPoint AnyHitNV %main "main" %89 +; CHECK: OpEntryPoint AnyHitNV %main "main" [[launch_id:%\w+]] OpSource GLSL 460 OpSourceExtension "GL_EXT_nonuniform_qualifier" OpSourceExtension "GL_NV_ray_tracing" @@ -3117,7 +3090,7 @@ OpDecorate %images Binding 1 OpDecorate %images NonWritable ; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 )" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV +; CHECK: OpDecorate [[launch_id]] BuiltIn LaunchIdNV %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 @@ -3144,14 +3117,10 @@ OpDecorate %images NonWritable )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint +; CHECK: [[launch_id]] = OpVariable %_ptr_Input_v3uint Input +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -3175,10 +3144,10 @@ OpStore %31 %29 ; CHECK: %138 = OpLoad %uint %25 ; CHECK: OpBranch %135 ; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %135 ; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 +; CHECK: %142 = OpPhi %uint %138 %136 [[null_uint]] %137 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -3199,13 +3168,13 @@ OpStore %31 %29 ; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 ; CHECK: OpBranch %145 ; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 +; CHECK: %151 = OpPhi %v4float %149 %146 [[null_v4float]] %147 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 +; CHECK: %114 = OpPhi %v4float %151 %145 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %114 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -3259,7 +3228,7 @@ OpExtension "SPV_NV_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint ClosestHitNV %main "main" -; CHECK: OpEntryPoint ClosestHitNV %main "main" %89 +; CHECK: OpEntryPoint ClosestHitNV %main "main" [[launch_id:%\w+]] OpSource GLSL 460 OpSourceExtension "GL_EXT_nonuniform_qualifier" OpSourceExtension "GL_NV_ray_tracing" @@ -3279,7 +3248,7 @@ OpDecorate %images Binding 1 OpDecorate %images NonWritable ; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 )" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV +; CHECK: OpDecorate [[launch_id]] BuiltIn LaunchIdNV %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 @@ -3306,14 +3275,10 @@ OpDecorate %images NonWritable )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint +; CHECK: [[launch_id]] = OpVariable %_ptr_Input_v3uint Input +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -3337,10 +3302,10 @@ OpStore %31 %29 ; CHECK: %138 = OpLoad %uint %25 ; CHECK: OpBranch %135 ; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %135 ; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 +; CHECK: %142 = OpPhi %uint %138 %136 [[null_uint]] %137 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -3361,13 +3326,13 @@ OpStore %31 %29 ; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 ; CHECK: OpBranch %145 ; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 +; CHECK: %151 = OpPhi %v4float %149 %146 [[null_v4float]] %147 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 +; CHECK: %114 = OpPhi %v4float %151 %145 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %114 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -3421,7 +3386,7 @@ OpExtension "SPV_NV_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint MissNV %main "main" -; CHECK: OpEntryPoint MissNV %main "main" %89 +; CHECK: OpEntryPoint MissNV %main "main" [[launch_id:%\w+]] OpSource GLSL 460 OpSourceExtension "GL_EXT_nonuniform_qualifier" OpSourceExtension "GL_NV_ray_tracing" @@ -3441,7 +3406,7 @@ OpDecorate %images Binding 1 OpDecorate %images NonWritable ; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 )" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV +; CHECK: OpDecorate [[launch_id]] BuiltIn LaunchIdNV %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 @@ -3468,14 +3433,10 @@ OpDecorate %images NonWritable )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint +; CHECK: [[launch_id]] = OpVariable %_ptr_Input_v3uint Input +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -3499,10 +3460,10 @@ OpStore %31 %29 ; CHECK: %138 = OpLoad %uint %25 ; CHECK: OpBranch %135 ; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %135 ; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 +; CHECK: %142 = OpPhi %uint %138 %136 [[null_uint]] %137 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -3523,13 +3484,13 @@ OpStore %31 %29 ; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 ; CHECK: OpBranch %145 ; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 +; CHECK: %151 = OpPhi %v4float %149 %146 [[null_v4float]] %147 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 +; CHECK: %114 = OpPhi %v4float %151 %145 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %114 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -3583,7 +3544,7 @@ OpExtension "SPV_NV_ray_tracing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint CallableNV %main "main" -; CHECK: OpEntryPoint CallableNV %main "main" %89 +; CHECK: OpEntryPoint CallableNV %main "main" [[launch_id:%\w+]] OpSource GLSL 460 OpSourceExtension "GL_EXT_nonuniform_qualifier" OpSourceExtension "GL_NV_ray_tracing" @@ -3603,7 +3564,7 @@ OpDecorate %images Binding 1 OpDecorate %images NonWritable ; CHECK: OpDecorate %_runtimearr_uint ArrayStride 4 )" + kInputDecorations + kOutputDecorations + R"( -; CHECK: OpDecorate %89 BuiltIn LaunchIdNV +; CHECK: OpDecorate [[launch_id]] BuiltIn LaunchIdNV %void = OpTypeVoid %3 = OpTypeFunction %void %uint = OpTypeInt 32 0 @@ -3630,14 +3591,9 @@ OpDecorate %images NonWritable )" + kInputGlobals + R"( ; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ; CHECK: %bool = OpTypeBool -; CHECK: %57 = OpTypeFunction %void %uint %uint %uint %uint )" + kOutputGlobals + R"( -; CHECK: %v3uint = OpTypeVector %uint 3 -; CHECK: %_ptr_Input_v3uint = OpTypePointer Input %v3uint -; CHECK: %89 = OpVariable %_ptr_Input_v3uint Input -; CHECK: %113 = OpConstantNull %v4float -; CHECK: %116 = OpTypeFunction %uint %uint %uint %uint %uint -; CHECK: %141 = OpConstantNull %uint +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float +; CHECK: [[null_uint:%\w+]] = OpConstantNull %uint )"; // clang-format on @@ -3661,10 +3617,10 @@ OpStore %31 %29 ; CHECK: %138 = OpLoad %uint %25 ; CHECK: OpBranch %135 ; CHECK: %137 = OpLabel -; CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_48 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %135 ; CHECK: %135 = OpLabel -; CHECK: %142 = OpPhi %uint %138 %136 %141 %137 +; CHECK: %142 = OpPhi %uint %138 %136 [[null_uint]] %137 ; CHECK: %27 = OpAccessChain %_ptr_UniformConstant_13 %images %142 ; CHECK: %28 = OpLoad %13 %27 ; CHECK: %48 = OpFunctionCall %uint %inst_bindless_direct_read_2 %uint_1 %uint_1 @@ -3685,13 +3641,13 @@ OpStore %31 %29 ; CHECK: %150 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_1 %142 %uint_0 ; CHECK: OpBranch %145 ; CHECK: %145 = OpLabel -; CHECK: %151 = OpPhi %v4float %149 %146 %113 %147 +; CHECK: %151 = OpPhi %v4float %149 %146 [[null_v4float]] %147 ; CHECK: OpBranch %51 ; CHECK: %53 = OpLabel -; CHECK: %112 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_51 %uint_0 %142 %48 ; CHECK: OpBranch %51 ; CHECK: %51 = OpLabel -; CHECK: %114 = OpPhi %v4float %151 %145 %113 %53 +; CHECK: %114 = OpPhi %v4float %151 %145 [[null_v4float]] %53 ; CHECK: %30 = OpCompositeExtract %float %114 0 ; CHECK: %31 = OpAccessChain %_ptr_Uniform_float %sbo %int_1 ; CHECK: %152 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_0 %uint_0 @@ -3822,17 +3778,11 @@ OpDecorate %outColor Location 0 %outColor = OpVariable %_ptr_Output_v4float Output %float_0 = OpConstant %float 0 ; CHECK: %bool = OpTypeBool -; CHECK: %68 = OpTypeFunction %void %uint %uint %uint %uint ; CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( -; CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -; CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float -; CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -; CHECK: %v4uint = OpTypeVector %uint 4 -; CHECK: %122 = OpConstantNull %v4float -; CHECK: %126 = OpTypeFunction %uint %uint %uint %uint %uint +; CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )" + kInputGlobals + R"( -; CHECK: %165 = OpConstantNull %v2float +; CHECK: [[null_v2float:%\w+]] = OpConstantNull %v2float )"; // clang-format on @@ -3870,10 +3820,10 @@ OpStore %x %36 ; CHECK: %162 = OpLoad %v2float %47 ; CHECK: OpBranch %159 ; CHECK: %161 = OpLabel -; CHECK: %164 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_87 %uint_1 %uint_0 %uint_0 +; CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_87 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %159 ; CHECK: %159 = OpLabel -; CHECK: %166 = OpPhi %v2float %162 %160 %165 %161 +; CHECK: %166 = OpPhi %v2float %162 %160 [[null_v2float]] %161 ; CHECK: %49 = OpFMul %v2float %42 %166 ; CHECK: %167 = OpSampledImage %27 %39 %40 ; CHECK: %168 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_2 %uint_0 @@ -3889,7 +3839,7 @@ OpStore %x %36 ; CHECK: %177 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_89 %uint_1 %uint_0 %uint_0 ; CHECK: OpBranch %170 ; CHECK: %170 = OpLabel -; CHECK: %178 = OpPhi %v4float %175 %171 %122 %172 +; CHECK: %178 = OpPhi %v4float %175 %171 [[null_v4float]] %172 ; CHECK: %51 = OpCompositeExtract %float %178 0 OpStore %y %51 %54 = OpLoad %float %x @@ -4017,12 +3967,11 @@ TEST_F(InstBindlessTest, MultipleUniformNonAggregateRefsNoDescInit) { ;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kInputGlobals + R"( ;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint - ;CHECK: %148 = OpTypeFunction %void %uint %uint %uint %uint %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input ;CHECK: %v4uint = OpTypeVector %uint 4 - ;CHECK: %202 = OpConstantNull %v2float + ;CHECK: [[null_v2float:%\w+]] = OpConstantNull %v2float %MainPs = OpFunction %void None %3 %5 = OpLabel ;CHECK: %140 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_1 %uint_0 @@ -4048,10 +3997,10 @@ TEST_F(InstBindlessTest, MultipleUniformNonAggregateRefsNoDescInit) { ;CHECK: %146 = OpLoad %v2float %86 ;CHECK: OpBranch %143 ;CHECK: %145 = OpLabel - ;CHECK: %201 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_71 %uint_4 %uint_0 %119 %140 + ;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_71 %uint_4 %uint_0 %119 %140 ;CHECK: OpBranch %143 ;CHECK: %143 = OpLabel - ;CHECK: %203 = OpPhi %v2float %146 %144 %202 %145 + ;CHECK: %203 = OpPhi %v2float %146 %144 [[null_v2float]] %145 OpBranch %91 %88 = OpLabel %89 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_1 @@ -4068,7 +4017,7 @@ TEST_F(InstBindlessTest, MultipleUniformNonAggregateRefsNoDescInit) { ;CHECK: %211 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_75 %uint_4 %uint_0 %204 %140 ;CHECK: OpBranch %206 ;CHECK: %206 = OpLabel - ;CHECK: %212 = OpPhi %v2float %209 %207 %202 %208 + ;CHECK: %212 = OpPhi %v2float %209 %207 [[null_v2float]] %208 OpBranch %91 %91 = OpLabel %115 = OpPhi %v2float %87 %85 %90 %88 @@ -4210,12 +4159,11 @@ TEST_F(InstBindlessTest, UniformArrayRefNoDescInit) { )" + kInputGlobals + R"( ;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %bool = OpTypeBool -;CHECK: %132 = OpTypeFunction %void %uint %uint %uint %uint %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input ;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %185 = OpConstantNull %v2float +;CHECK: [[null_v2float:%\w+]] = OpConstantNull %v2float %MainPs = OpFunction %void None %3 %5 = OpLabel ;CHECK: %123 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_2 %uint_0 @@ -4240,10 +4188,10 @@ TEST_F(InstBindlessTest, UniformArrayRefNoDescInit) { ;CHECK: %130 = OpLoad %v2float %81 ;CHECK: OpBranch %127 ;CHECK: %129 = OpLabel -;CHECK: %184 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_78 %uint_4 %uint_0 %101 %123 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_78 %uint_4 %uint_0 %101 %123 ;CHECK: OpBranch %127 ;CHECK: %127 = OpLabel -;CHECK: %186 = OpPhi %v2float %130 %128 %185 %129 +;CHECK: %186 = OpPhi %v2float %130 %128 [[null_v2float]] %129 %86 = OpFAdd %v2float %66 %82 ;CHECK-NOT: %86 = OpFAdd %v2float %66 %82 ;CHECK: %86 = OpFAdd %v2float %66 %186 @@ -4353,13 +4301,12 @@ TEST_F(InstBindlessTest, UniformArrayRefWithDescInit) { )" + kInputGlobals + R"( ;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %bool = OpTypeBool -;CHECK: %135 = OpTypeFunction %void %uint %uint %uint %uint %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input ;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %189 = OpConstantNull %v2float -;CHECK: %201 = OpConstantNull %v4float +;CHECK: [[null_v2float:%\w+]] = OpConstantNull %v2float +;CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float %MainPs = OpFunction %void None %3 %5 = OpLabel ;CHECK: %126 = OpFunctionCall %uint %inst_bindless_direct_read_4 %uint_0 %uint_0 %uint_2 %uint_0 @@ -4387,10 +4334,10 @@ TEST_F(InstBindlessTest, UniformArrayRefWithDescInit) { ;CHECK: %133 = OpLoad %v2float %81 ;CHECK: OpBranch %130 ;CHECK: %132 = OpLabel -;CHECK: %188 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_78 %uint_4 %uint_0 %101 %126 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_78 %uint_4 %uint_0 %101 %126 ;CHECK: OpBranch %130 ;CHECK: %130 = OpLabel -;CHECK: %190 = OpPhi %v2float %133 %131 %189 %132 +;CHECK: %190 = OpPhi %v2float %133 %131 [[null_v2float]] %132 ;CHECK: %86 = OpFAdd %v2float %66 %190 %87 = OpLoad %46 %g_tColor %88 = OpLoad %50 %g_sAniso @@ -4408,10 +4355,10 @@ TEST_F(InstBindlessTest, UniformArrayRefWithDescInit) { ;CHECK: %198 = OpImageSampleImplicitLod %v4float %197 %86 ;CHECK: OpBranch %193 ;CHECK: %195 = OpLabel -;CHECK: %200 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_83 %uint_1 %uint_0 %uint_0 %uint_0 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_83 %uint_1 %uint_0 %uint_0 %uint_0 ;CHECK: OpBranch %193 ;CHECK: %193 = OpLabel -;CHECK: %202 = OpPhi %v4float %198 %194 %201 %195 +;CHECK: %202 = OpPhi %v4float %198 %194 [[null_v4float]] %195 ;CHECK: OpStore %_entryPointOutput_vColor %202 OpReturn OpFunctionEnd @@ -4490,15 +4437,12 @@ TEST_F(InstBindlessTest, Descriptor16BitIdxRef) { %_ptr_Output_v4float = OpTypePointer Output %v4float %_entryPointOutput_vColor = OpVariable %_ptr_Output_v4float Output ;CHECK: %bool = OpTypeBool -;CHECK: %51 = OpTypeFunction %void %uint %uint %uint %uint ;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %106 = OpConstantNull %v4float -;CHECK: %111 = OpTypeFunction %uint %uint %uint %uint %uint +;CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float )" + kInputGlobals + R"( %MainPs = OpFunction %void None %10 %30 = OpLabel @@ -4539,14 +4483,14 @@ TEST_F(InstBindlessTest, Descriptor16BitIdxRef) { ;CHECK: %140 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_60 %uint_1 %139 %uint_0 ;CHECK: OpBranch %133 ;CHECK: %133 = OpLabel -;CHECK: %141 = OpPhi %v4float %138 %134 %106 %135 +;CHECK: [[phi_result_1:%\w+]] = OpPhi %v4float %138 %134 [[null_v4float]] %135 ;CHECK: OpBranch %44 ;CHECK: %46 = OpLabel -;CHECK: %105 = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_60 %uint_0 %41 %uint_128 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_4 %uint_60 %uint_0 %41 %uint_128 ;CHECK: OpBranch %44 ;CHECK: %44 = OpLabel -;CHECK: %107 = OpPhi %v4float %141 %133 %106 %46 -;CHECK: OpStore %_entryPointOutput_vColor %107 +;CHECK: [[phi_result_2:%\w+]] = OpPhi %v4float [[phi_result_1]] %133 [[null_v4float]] %46 +;CHECK: OpStore %_entryPointOutput_vColor [[phi_result_2]] OpReturn OpFunctionEnd )" + kStreamWrite4Frag + kDirectRead4; @@ -4681,12 +4625,10 @@ TEST_F(InstBindlessTest, UniformArray16bitIdxRef) { )" + kInputGlobals + R"( ;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %bool = OpTypeBool -;CHECK: %88 = OpTypeFunction %void %uint %uint %uint %uint %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK:%gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %142 = OpConstantNull %v2float +;CHECK: [[null_v2float:%\w+]] = OpConstantNull %v2float %MainPs = OpFunction %void None %14 %37 = OpLabel ;CHECK: %79 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 @@ -4714,10 +4656,10 @@ TEST_F(InstBindlessTest, UniformArray16bitIdxRef) { ;CHECK: %86 = OpLoad %v2float %41 ;CHECK: OpBranch %83 ;CHECK: %85 = OpLabel -;CHECK: %141 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_81 %uint_4 %uint_0 %58 %79 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_81 %uint_4 %uint_0 %58 %79 ;CHECK: OpBranch %83 ;CHECK: %83 = OpLabel -;CHECK: %143 = OpPhi %v2float %86 %84 %142 %85 +;CHECK: %143 = OpPhi %v2float %86 %84 [[null_v2float]] %85 ;CHECK: %43 = OpFAdd %v2float %38 %143 %44 = OpLoad %30 %g_tColor %45 = OpLoad %32 %g_sAniso @@ -4808,23 +4750,16 @@ TEST_F(InstBindlessTest, UniformMatrixRefRowMajor) { %v4float = OpTypeVector %float 4 %_ptr_Input_v4float = OpTypePointer Input %v4float %a_position = OpVariable %_ptr_Input_v4float Input -;CHECK; %37 = OpTypeFunction %uint %uint %uint %uint -;CHECK;%_runtimearr_uint = OpTypeRuntimeArray %uint +;CHECK: %37 = OpTypeFunction %uint %uint %uint %uint +;CHECK:%_runtimearr_uint = OpTypeRuntimeArray %uint )" + kInputGlobals + R"( -;CHECK;%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint -;CHECK; %bool = OpTypeBool -;CHECK; %63 = OpTypeFunction %void %uint %uint %uint %uint %uint +;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint +;CHECK: %bool = OpTypeBool )" + kOutputGlobals + R"( -;CHECK;%_ptr_Input_uint = OpTypePointer Input %uint -;CHECK;%gl_VertexIndex = OpVariable %_ptr_Input_uint Input -;CHECK;%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -;CHECK; %uint_5 = OpConstant %uint 5 -;CHECK; %uint_7 = OpConstant %uint 7 -;CHECK; %uint_8 = OpConstant %uint 8 -;CHECK; %uint_9 = OpConstant %uint 9 -;CHECK; %uint_10 = OpConstant %uint 10 -;CHECK; %uint_45 = OpConstant %uint 45 -;CHECK; %115 = OpConstantNull %float +;CHECK:%_ptr_Input_uint = OpTypePointer Input %uint +;CHECK:%gl_VertexIndex = OpVariable %_ptr_Input_uint Input +;CHECK:%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input +;CHECK: [[null_float:%\w+]] = OpConstantNull %float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: %55 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 @@ -4847,10 +4782,10 @@ TEST_F(InstBindlessTest, UniformMatrixRefRowMajor) { ;CHECK: %61 = OpLoad %float %20 ;CHECK: OpBranch %58 ;CHECK: %60 = OpLabel -;CHECK: %114 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_45 %uint_4 %uint_0 %35 %55 +;CHECK: {{\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_45 %uint_4 %uint_0 %35 %55 ;CHECK: OpBranch %58 ;CHECK: %58 = OpLabel -;CHECK: %116 = OpPhi %float %61 %59 %115 %60 +;CHECK: %116 = OpPhi %float %61 %59 [[null_float]] %60 OpStore %v_vtxResult %21 ;CHECK-NOT: OpStore %v_vtxResult %21 ;CHECK: OpStore %v_vtxResult %116 @@ -4943,12 +4878,11 @@ TEST_F(InstBindlessTest, UniformMatrixRefColumnMajor) { )" + kInputGlobals + R"( ;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %bool = OpTypeBool -;CHECK: %63 = OpTypeFunction %void %uint %uint %uint %uint %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_Input_uint = OpTypePointer Input %uint ;CHECK:%gl_VertexIndex = OpVariable %_ptr_Input_uint Input ;CHECK:%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -;CHECK: %114 = OpConstantNull %float +;CHECK: [[null_float:%\w+]] = OpConstantNull %float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: %55 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 @@ -4971,10 +4905,10 @@ TEST_F(InstBindlessTest, UniformMatrixRefColumnMajor) { ;CHECK: %61 = OpLoad %float %20 ;CHECK: OpBranch %58 ;CHECK: %60 = OpLabel -;CHECK: %113 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_45 %uint_4 %uint_0 %35 %55 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_45 %uint_4 %uint_0 %35 %55 ;CHECK: OpBranch %58 ;CHECK: %58 = OpLabel -;CHECK: %115 = OpPhi %float %61 %59 %114 %60 +;CHECK: %115 = OpPhi %float %61 %59 [[null_float]] %60 OpStore %v_vtxResult %21 ;CHECK-NOT: OpStore %v_vtxResult %21 ;CHECK: OpStore %v_vtxResult %115 @@ -5074,12 +5008,11 @@ TEST_F(InstBindlessTest, UniformMatrixVecRefRowMajor) { )" + kInputGlobals + R"( ;CHECK:%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %bool = OpTypeBool -;CHECK: %72 = OpTypeFunction %void %uint %uint %uint %uint %uint )" + kOutputGlobals + R"( ;CHECK:%_ptr_Input_uint = OpTypePointer Input %uint ;CHECK:%gl_VertexIndex = OpVariable %_ptr_Input_uint Input ;CHECK:%gl_InstanceIndex = OpVariable %_ptr_Input_uint Input -;CHECK: %124 = OpConstantNull %v2float +;CHECK: [[null_v2float:%\w+]] = OpConstantNull %v2float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: %64 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 @@ -5106,10 +5039,10 @@ TEST_F(InstBindlessTest, UniformMatrixVecRefRowMajor) { ;CHECK: %70 = OpLoad %v2float %25 ;CHECK: OpBranch %67 ;CHECK: %69 = OpLabel -;CHECK: %123 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_51 %uint_4 %uint_0 %43 %64 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_51 %uint_4 %uint_0 %43 %64 ;CHECK: OpBranch %67 ;CHECK: %67 = OpLabel -;CHECK: %125 = OpPhi %v2float %70 %68 %124 %69 +;CHECK: %125 = OpPhi %v2float %70 %68 [[null_v2float]] %69 ;CHECK: OpStore %v_vtxResult %125 OpReturn OpFunctionEnd @@ -5172,14 +5105,12 @@ TEST_F(InstBindlessTest, ImageBufferOOBRead) { %ii = OpVariable %_ptr_Input_int Input ;CHECK: %uint = OpTypeInt 32 0 ;CHECK: %bool = OpTypeBool -;CHECK: %35 = OpTypeFunction %void %uint %uint %uint %uint %uint ;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %93 = OpConstantNull %v4float +;CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: OpBranch %21 @@ -5204,10 +5135,10 @@ TEST_F(InstBindlessTest, ImageBufferOOBRead) { ;CHECK: %33 = OpImageRead %v4float %32 %17 ;CHECK: OpBranch %29 ;CHECK: %31 = OpLabel -;CHECK: %92 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_33 %uint_7 %uint_0 %23 %25 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_33 %uint_7 %uint_0 %23 %25 ;CHECK: OpBranch %29 ;CHECK: %29 = OpLabel -;CHECK: %94 = OpPhi %v4float %33 %30 %93 %31 +;CHECK: %94 = OpPhi %v4float %33 %30 [[null_v4float]] %31 ;CHECK: OpStore %x %94 OpReturn OpFunctionEnd @@ -5365,14 +5296,12 @@ TEST_F(InstBindlessTest, TextureBufferOOBFetch) { %ii = OpVariable %_ptr_Input_int Input ;CHECK: %uint = OpTypeInt 32 0 ;CHECK: %bool = OpTypeBool -;CHECK: %35 = OpTypeFunction %void %uint %uint %uint %uint %uint ;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %94 = OpConstantNull %v4float +;CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: OpBranch %21 @@ -5397,10 +5326,10 @@ TEST_F(InstBindlessTest, TextureBufferOOBFetch) { ;CHECK: %33 = OpImageFetch %v4float %32 %17 ;CHECK: OpBranch %29 ;CHECK: %31 = OpLabel -;CHECK: %93 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_32 %uint_6 %uint_0 %23 %25 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_32 %uint_6 %uint_0 %23 %25 ;CHECK: OpBranch %29 ;CHECK: %29 = OpLabel -;CHECK: %95 = OpPhi %v4float %33 %30 %94 %31 +;CHECK: %95 = OpPhi %v4float %33 %30 [[null_v4float]] %31 ;CHECK: OpStore %x %95 OpReturn OpFunctionEnd @@ -5464,14 +5393,12 @@ TEST_F(InstBindlessTest, SamplerBufferOOBFetch) { %ii = OpVariable %_ptr_Input_int Input ;CHECK: %uint = OpTypeInt 32 0 ;CHECK: %bool = OpTypeBool -;CHECK: %38 = OpTypeFunction %void %uint %uint %uint %uint %uint ;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %97 = OpConstantNull %v4float +;CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: OpBranch %23 @@ -5498,10 +5425,10 @@ TEST_F(InstBindlessTest, SamplerBufferOOBFetch) { ;CHECK: %36 = OpImageFetch %v4float %35 %18 ;CHECK: OpBranch %31 ;CHECK: %33 = OpLabel -;CHECK: %96 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_34 %uint_6 %uint_0 %25 %27 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_34 %uint_6 %uint_0 %25 %27 ;CHECK: OpBranch %31 ;CHECK: %31 = OpLabel -;CHECK: %98 = OpPhi %v4float %36 %32 %97 %33 +;CHECK: %98 = OpPhi %v4float %36 %32 [[null_v4float]] %33 ;CHECK: OpStore %x %98 OpReturn OpFunctionEnd @@ -5572,14 +5499,12 @@ TEST_F(InstBindlessTest, SamplerBufferConstructorOOBFetch) { %ii = OpVariable %_ptr_Input_int Input ;CHECK: %uint = OpTypeInt 32 0 ;CHECK: %bool = OpTypeBool -;CHECK: %44 = OpTypeFunction %void %uint %uint %uint %uint %uint ;CHECK: %_runtimearr_uint = OpTypeRuntimeArray %uint )" + kOutputGlobals + R"( ;CHECK: %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint ;CHECK: %_ptr_Input_v4float = OpTypePointer Input %v4float ;CHECK: %gl_FragCoord = OpVariable %_ptr_Input_v4float Input -;CHECK: %v4uint = OpTypeVector %uint 4 -;CHECK: %103 = OpConstantNull %v4float +;CHECK: [[null_v4float:%\w+]] = OpConstantNull %v4float %main = OpFunction %void None %3 %5 = OpLabel ;CHECK: OpBranch %28 @@ -5609,10 +5534,10 @@ TEST_F(InstBindlessTest, SamplerBufferConstructorOOBFetch) { ;CHECK: %42 = OpImageFetch %v4float %41 %23 ;CHECK: OpBranch %36 ;CHECK: %38 = OpLabel -;CHECK: %102 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_42 %uint_6 %uint_0 %30 %32 +;CHECK: {{%\w+}} = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_42 %uint_6 %uint_0 %30 %32 ;CHECK: OpBranch %36 ;CHECK: %36 = OpLabel -;CHECK: %104 = OpPhi %v4float %42 %37 %103 %38 +;CHECK: %104 = OpPhi %v4float %42 %37 [[null_v4float]] %38 ;CHECK: OpStore %x %104 OpReturn OpFunctionEnd @@ -5625,6 +5550,148 @@ TEST_F(InstBindlessTest, SamplerBufferConstructorOOBFetch) { false, true, true, true); } +TEST_F(InstBindlessTest, DeviceBufferAddressOOB) { + // #version 450 + // #extension GL_EXT_buffer_reference : enable + // layout(buffer_reference, buffer_reference_align = 16) buffer bufStruct; + // layout(set = 0, binding = 0) uniform ufoo { + // bufStruct data; + // int nWrites; + // } u_info; + // layout(buffer_reference, std140) buffer bufStruct { + // int a[4]; + // }; + // void main() { + // for (int i=0; i < u_info.nWrites; ++i) { + // u_info.data.a[i] = 0xdeadca71; + // } + // } + + // clang-format off + const std::string text = R"( +OpCapability Shader +OpCapability PhysicalStorageBufferAddresses +;CHECK: OpCapability Int64 +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Vertex %main "main" %u_info +;CHECK: OpEntryPoint Vertex %main "main" %u_info %inst_bindless_input_buffer %inst_bindless_output_buffer %gl_VertexIndex %gl_InstanceIndex +OpSource GLSL 450 +OpSourceExtension "GL_EXT_buffer_reference" +OpName %main "main" +OpName %i "i" +OpName %ufoo "ufoo" +OpMemberName %ufoo 0 "data" +OpMemberName %ufoo 1 "nWrites" +OpName %bufStruct "bufStruct" +OpMemberName %bufStruct 0 "a" +OpName %u_info "u_info" +OpMemberDecorate %ufoo 0 Offset 0 +OpMemberDecorate %ufoo 1 Offset 8 +OpDecorate %ufoo Block +OpDecorate %_arr_int_uint_4 ArrayStride 16 +OpMemberDecorate %bufStruct 0 Offset 0 +OpDecorate %bufStruct Block +OpDecorate %u_info DescriptorSet 0 +OpDecorate %u_info Binding 0)" + + kInputDecorations + kOutputDecorations + +R"(%void = OpTypeVoid +%3 = OpTypeFunction %void +%int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int +%int_0 = OpConstant %int 0 +OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_bufStruct PhysicalStorageBuffer +%ufoo = OpTypeStruct %_ptr_PhysicalStorageBuffer_bufStruct %int +%uint = OpTypeInt 32 0 +%uint_4 = OpConstant %uint 4 +%_arr_int_uint_4 = OpTypeArray %int %uint_4 +%bufStruct = OpTypeStruct %_arr_int_uint_4 +%_ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer PhysicalStorageBuffer %bufStruct +%_ptr_Uniform_ufoo = OpTypePointer Uniform %ufoo +%u_info = OpVariable %_ptr_Uniform_ufoo Uniform +%int_1 = OpConstant %int 1 +%_ptr_Uniform_int = OpTypePointer Uniform %int +%bool = OpTypeBool +%_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer Uniform %_ptr_PhysicalStorageBuffer_bufStruct +%int_n559035791 = OpConstant %int -559035791 +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int)" + + kInputGlobals + kOutputGlobals + +R"(%main = OpFunction %void None %3 +%5 = OpLabel +%i = OpVariable %_ptr_Function_int Function +;CHECK: OpBranch %137 +;CHECK: %137 = OpLabel +;CHECK: 65 = OpFunctionCall %uint %inst_bindless_direct_read_3 %uint_1 %uint_0 %uint_0 +;CHECK: OpBranch %40 +;CHECK: 40 = OpLabel +;CHECK: OpBranch %39 +;CHECK: 39 = OpLabel +OpStore %i %int_0 +OpBranch %10 +%10 = OpLabel +OpLoopMerge %12 %13 None +OpBranch %14 +%14 = OpLabel +%15 = OpLoad %int %i +%26 = OpAccessChain %_ptr_Uniform_int %u_info %int_1 +%27 = OpLoad %int %26 +%29 = OpSLessThan %bool %15 %27 +;CHECK-NOT: %27 = OpLoad %int %26 +;CHECK-NOT: %29 = OpSLessThan %bool %15 %27 +;CHECK: 43 = OpIAdd %uint %uint_8 %uint_3 +;CHECK: 66 = OpULessThan %bool %43 %65 +;CHECK: OpSelectionMerge %67 None +;CHECK: OpBranchConditional %66 %68 %69 +;CHECK: 68 = OpLabel +;CHECK: 70 = OpLoad %int %26 +;CHECK: OpBranch %67 +;CHECK: 69 = OpLabel +;CHECK: 122 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_54 %uint_4 %uint_0 %43 %65 +;CHECK: OpBranch %67 +;CHECK: 67 = OpLabel +;CHECK: 124 = OpPhi %int %70 %68 %123 %69 +;CHECK: 29 = OpSLessThan %bool %15 %124 +OpBranchConditional %29 %11 %12 +%11 = OpLabel +%31 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 +%32 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %31 +;CHECK-NOT: %32 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %31 +;CHECK: 125 = OpIAdd %uint %uint_0 %uint_7 +;CHECK: 126 = OpULessThan %bool %125 %65 +;CHECK: OpSelectionMerge %127 None +;CHECK: OpBranchConditional %126 %128 %129 +;CHECK: 128 = OpLabel +;CHECK: 130 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %31 +;CHECK: OpBranch %127 +;CHECK: 129 = OpLabel +;CHECK: 132 = OpFunctionCall %void %inst_bindless_stream_write_5 %uint_59 %uint_4 %uint_0 %125 %65 +;CHECK: 135 = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_bufStruct %134 +;CHECK: OpBranch %127 +;CHECK: 127 = OpLabel +;CHECK: 136 = OpPhi %_ptr_PhysicalStorageBuffer_bufStruct %130 %128 %135 %129 +%33 = OpLoad %int %i +%36 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %32 %int_0 %33 +;CHECK-NOT: %36 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %32 %int_0 %33 +;CHECK: %36 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %136 %int_0 %33 +OpStore %36 %int_n559035791 Aligned 16 +OpBranch %13 +%13 = OpLabel +%37 = OpLoad %int %i +%38 = OpIAdd %int %37 %int_1 +OpStore %i %38 +OpBranch %10 +%12 = OpLabel +OpReturn +OpFunctionEnd)" + + kDirectRead3 + kStreamWrite5Vert; + // clang-format on + + SetTargetEnv(SPV_ENV_VULKAN_1_2); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true, 7u, 23u, false, true, + true, true, true); +} + // TODO(greg-lunarg): Add tests to verify handling of these cases: // // Compute shader diff --git a/test/opt/inst_buff_addr_check_test.cpp b/test/opt/inst_buff_addr_check_test.cpp index 7886ba7ea9..b08f7b0b42 100644 --- a/test/opt/inst_buff_addr_check_test.cpp +++ b/test/opt/inst_buff_addr_check_test.cpp @@ -120,6 +120,22 @@ static const std::string kStreamWrite4Compute = kStreamWrite4Begin + R"( )" + kStreamWrite4End; // clang-format on +// clang-format off +static const std::string kStreamWrite4Vert = kStreamWrite4Begin + R"( +; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_3 +; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} +; CHECK: OpStore {{%\w+}} %uint_0 +; CHECK: {{%\w+}} = OpLoad %uint %gl_VertexIndex +; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_4 +; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} +; CHECK: OpStore {{%\w+}} {{%\w+}} +; CHECK: {{%\w+}} = OpLoad %uint %gl_InstanceIndex +; CHECK: {{%\w+}} = OpIAdd %uint {{%\w+}} %uint_5 +; CHECK: {{%\w+}} = OpAccessChain %_ptr_StorageBuffer_uint [[output_buffer_var]] %uint_2 {{%\w+}} +; CHECK: OpStore {{%\w+}} {{%\w+}} +)" + kStreamWrite4End; +// clang-format on + static const std::string kInputDecorations = R"( ; CHECK: OpDecorate [[input_buffer_type:%inst_buff_addr_InputBuffer]] Block ; CHECK: OpMemberDecorate [[input_buffer_type]] 0 Offset 0 @@ -552,6 +568,118 @@ OpFunctionEnd defs + decorates + globals + main_func + output_funcs, true); } +TEST_F(InstBuffAddrTest, DeviceBufferAddressOOB) { + // #version 450 + // #extension GL_EXT_buffer_reference : enable + // layout(buffer_reference, buffer_reference_align = 16) buffer bufStruct; + // layout(set = 0, binding = 0) uniform ufoo { + // bufStruct data; + // int nWrites; + // } u_info; + // layout(buffer_reference, std140) buffer bufStruct { + // int a[4]; + // }; + // void main() { + // for (int i=0; i < u_info.nWrites; ++i) { + // u_info.data.a[i] = 0xdeadca71; + // } + // } + + // clang-format off + const std::string text = R"( +OpCapability Shader +OpCapability PhysicalStorageBufferAddresses +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint Vertex %main "main" %u_info +;CHECK: OpEntryPoint Vertex %main "main" %u_info %inst_buff_addr_input_buffer %inst_buff_addr_output_buffer %gl_VertexIndex %gl_InstanceIndex +OpSource GLSL 450 +OpSourceExtension "GL_EXT_buffer_reference" +OpName %main "main" +OpName %i "i" +OpName %ufoo "ufoo" +OpMemberName %ufoo 0 "data" +OpMemberName %ufoo 1 "nWrites" +OpName %bufStruct "bufStruct" +OpMemberName %bufStruct 0 "a" +OpName %u_info "u_info" +OpMemberDecorate %ufoo 0 Offset 0 +OpMemberDecorate %ufoo 1 Offset 8 +OpDecorate %ufoo Block +OpDecorate %_arr_int_uint_4 ArrayStride 16 +OpMemberDecorate %bufStruct 0 Offset 0 +OpDecorate %bufStruct Block +OpDecorate %u_info DescriptorSet 0 +OpDecorate %u_info Binding 0)" + kInputDecorations + kOutputDecorations + R"( +%void = OpTypeVoid +%3 = OpTypeFunction %void +%int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int +%int_0 = OpConstant %int 0 +OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_bufStruct PhysicalStorageBuffer +%ufoo = OpTypeStruct %_ptr_PhysicalStorageBuffer_bufStruct %int +%uint = OpTypeInt 32 0 +%uint_4 = OpConstant %uint 4 +%_arr_int_uint_4 = OpTypeArray %int %uint_4 +%bufStruct = OpTypeStruct %_arr_int_uint_4 +%_ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer PhysicalStorageBuffer %bufStruct +%_ptr_Uniform_ufoo = OpTypePointer Uniform %ufoo +%u_info = OpVariable %_ptr_Uniform_ufoo Uniform +%int_1 = OpConstant %int 1 +%_ptr_Uniform_int = OpTypePointer Uniform %int +%bool = OpTypeBool +%_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct = OpTypePointer Uniform %_ptr_PhysicalStorageBuffer_bufStruct +%int_n559035791 = OpConstant %int -559035791 +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int)" + kInputGlobals + kOutputGlobals + R"( +%main = OpFunction %void None %3 +%5 = OpLabel +%i = OpVariable %_ptr_Function_int Function +OpStore %i %int_0 +OpBranch %10 +%10 = OpLabel +OpLoopMerge %12 %13 None +OpBranch %14 +%14 = OpLabel +%15 = OpLoad %int %i +%26 = OpAccessChain %_ptr_Uniform_int %u_info %int_1 +%27 = OpLoad %int %26 +%29 = OpSLessThan %bool %15 %27 +OpBranchConditional %29 %11 %12 +%11 = OpLabel +%31 = OpAccessChain %_ptr_Uniform__ptr_PhysicalStorageBuffer_bufStruct %u_info %int_0 +%32 = OpLoad %_ptr_PhysicalStorageBuffer_bufStruct %31 +%33 = OpLoad %int %i +%36 = OpAccessChain %_ptr_PhysicalStorageBuffer_int %32 %int_0 %33 +;CHECK: %41 = OpConvertPtrToU %ulong %36 +;CHECK: %76 = OpFunctionCall %bool %inst_buff_addr_search_and_test %41 %uint_4 +;CHECK: OpSelectionMerge %77 None +;CHECK: OpBranchConditional %76 %78 %79 +;CHECK: %78 = OpLabel +OpStore %36 %int_n559035791 Aligned 16 +;CHECK: OpBranch %77 +;CHECK: 79 = OpLabel +;CHECK: 80 = OpUConvert %uint %41 +;CHECK: 82 = OpShiftRightLogical %ulong %41 %uint_32 +;CHECK: 83 = OpUConvert %uint %82 +;CHECK: 134 = OpFunctionCall %void %inst_buff_addr_stream_write_4 %uint_62 %uint_2 %80 %83 +;CHECK: OpBranch %77 +;CHECK: 77 = OpLabel +OpBranch %13 +%13 = OpLabel +%37 = OpLoad %int %i +%38 = OpIAdd %int %37 %int_1 +OpStore %i %38 +OpBranch %10 +%12 = OpLabel +OpReturn +OpFunctionEnd)" + kSearchAndTest + kStreamWrite4Vert; + // clang-format on + + SetTargetEnv(SPV_ENV_VULKAN_1_2); + SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS); + SinglePassRunAndMatch(text, true, 7, 23); +} + } // namespace } // namespace opt } // namespace spvtools diff --git a/test/val/val_ext_inst_test.cpp b/test/val/val_ext_inst_test.cpp index e685acde5d..8f0bcce14b 100644 --- a/test/val/val_ext_inst_test.cpp +++ b/test/val/val_ext_inst_test.cpp @@ -6239,6 +6239,197 @@ OpFunctionEnd HasSubstr("Name must match an entry-point for Kernel")); } +TEST_F(ValidateClspvReflection, KernelArgumentsVersionGood) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_1 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateClspvReflection, KernelArgumentsVersionBad) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.4" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_1 = OpConstant %int 1 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_1 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Version 4 of the Kernel instruction can only have 2 " + "additional operands")); +} + +TEST_F(ValidateClspvReflection, KernelNumArgumentsNotInt) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %float_0 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("NumArguments must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelNumArgumentsNotConstant) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%null = OpConstantNull %int +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %null +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("NumArguments must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelFlagsNotInt) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_0 %float_0 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Flags must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelFlagsNotConstant) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%null = OpConstantNull %int +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_0 %null +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Flags must be a 32-bit unsigned integer OpConstant")); +} + +TEST_F(ValidateClspvReflection, KernelAttributesNotString) { + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name %int_0 %int_0 %int_0 +)"; + + CompileSuccessfully(text); + ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("Attributes must be an OpString")); +} + using ArgumentBasics = spvtest::ValidateBase>; @@ -6254,7 +6445,11 @@ INSTANTIATE_TEST_SUITE_P( std::make_pair("ArgumentSampledImage", "%int_0 %int_0"), std::make_pair("ArgumentStorageImage", "%int_0 %int_0"), std::make_pair("ArgumentSampler", "%int_0 %int_0"), - std::make_pair("ArgumentWorkgroup", "%int_0 %int_0")})); + std::make_pair("ArgumentWorkgroup", "%int_0 %int_0"), + std::make_pair("ArgumentPointerPushConstant", "%int_0 %int_4"), + std::make_pair("ArgumentPointerUniform", "%int_0 %int_0 %int_0 %int_4"), + std::make_pair("ArgumentStorageTexelBuffer", "%int_0 %int_0"), + std::make_pair("ArgumentUniformTexelBuffer", "%int_0 %int_0")})); TEST_P(ArgumentBasics, KernelNotAnExtendedInstruction) { const std::string ext_inst = std::get<0>(GetParam()); @@ -6262,7 +6457,7 @@ TEST_P(ArgumentBasics, KernelNotAnExtendedInstruction) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6291,8 +6486,8 @@ TEST_P(ArgumentBasics, KernelFromDifferentImport) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" -%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6323,7 +6518,7 @@ TEST_P(ArgumentBasics, KernelWrongExtendedInstruction) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6353,7 +6548,7 @@ TEST_P(ArgumentBasics, ArgumentInfo) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6383,7 +6578,7 @@ TEST_P(ArgumentBasics, ArgumentInfoNotAnExtendedInstruction) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6414,8 +6609,8 @@ TEST_P(ArgumentBasics, ArgumentInfoFromDifferentImport) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" -%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +%ext2 = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6659,7 +6854,269 @@ INSTANTIATE_TEST_SUITE_P( std::make_pair( "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %float_0", "Z"), std::make_pair( - "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %null", "Z")})); + "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %null", "Z"), + std::make_pair("SpecConstantSubgroupMaxSize %float_0", "Size"), + std::make_pair("SpecConstantSubgroupMaxSize %null", "Size"), + std::make_pair( + "ArgumentPointerPushConstant %decl %float_0 %int_0 %int_0", + "Ordinal"), + std::make_pair("ArgumentPointerPushConstant %decl %null %int_0 %int_0", + "Ordinal"), + std::make_pair( + "ArgumentPointerPushConstant %decl %int_0 %float_0 %int_0", + "Offset"), + std::make_pair("ArgumentPointerPushConstant %decl %int_0 %null %int_0", + "Offset"), + std::make_pair( + "ArgumentPointerPushConstant %decl %int_0 %int_0 %float_0", "Size"), + std::make_pair("ArgumentPointerPushConstant %decl %int_0 %int_0 %null", + "Size"), + std::make_pair( + "ArgumentPointerUniform %decl %float_0 %int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair( + "ArgumentPointerUniform %decl %null %int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %float_0 %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %null %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %float_0 %int_0 %int_4", + "Binding"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %null %int_0 %int_4", + "Binding"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %float_0 %int_4", + "Offset"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %null %int_4", + "Offset"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %int_0 %float_0", + "Size"), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %int_0 %null", + "Size"), + std::make_pair( + "ProgramScopeVariablesStorageBuffer %float_0 %int_0 %data", + "DescriptorSet"), + std::make_pair("ProgramScopeVariablesStorageBuffer %null %int_0 %data", + "DescriptorSet"), + std::make_pair( + "ProgramScopeVariablesStorageBuffer %int_0 %float_0 %data", + "Binding"), + std::make_pair("ProgramScopeVariablesStorageBuffer %int_0 %null %data", + "Binding"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %float_0 %int_0 %int_4", + "ObjectOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %null %int_0 %int_4", + "ObjectOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %float_0 %int_4", + "PointerOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %null %int_4", + "PointerOffset"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %int_0 %float_0", + "PointerSize"), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %int_0 %null", + "PointerSize"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl " + "%float_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %null " + "%int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%int_0 %null", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%float_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%null %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %int_0 %null", + "Size"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %float_0 " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %null " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%float_0 %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%null %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %float_0 %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %null %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %null", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %float_0 " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %null " + "%int_0 %int_0 %int_0 %int_4", + "Ordinal"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%float_0 %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%null %int_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %float_0 %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %null %int_0 %int_4", + "Binding"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %float_0 %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %null %int_4", + "Offset"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %float_0", + "Size"), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %null", + "Size"), + std::make_pair( + "ArgumentStorageTexelBuffer %decl %float_0 %int_0 %int_0", + "Ordinal"), + std::make_pair("ArgumentStorageTexelBuffer %decl %null %int_0 %int_0", + "Ordinal"), + std::make_pair( + "ArgumentStorageTexelBuffer %decl %int_0 %float_0 %int_0", + "DescriptorSet"), + std::make_pair("ArgumentStorageTexelBuffer %decl %int_0 %null %int_0", + "DescriptorSet"), + std::make_pair( + "ArgumentStorageTexelBuffer %decl %int_0 %int_0 %float_0", + "Binding"), + std::make_pair("ArgumentStorageTexelBuffer %decl %int_0 %int_0 %null", + "Binding"), + std::make_pair( + "ArgumentUniformTexelBuffer %decl %float_0 %int_0 %int_0", + "Ordinal"), + std::make_pair("ArgumentUniformTexelBuffer %decl %null %int_0 %int_0", + "Ordinal"), + std::make_pair( + "ArgumentUniformTexelBuffer %decl %int_0 %float_0 %int_0", + "DescriptorSet"), + std::make_pair("ArgumentUniformTexelBuffer %decl %int_0 %null %int_0", + "DescriptorSet"), + std::make_pair( + "ArgumentUniformTexelBuffer %decl %int_0 %int_0 %float_0", + "Binding"), + std::make_pair("ArgumentUniformTexelBuffer %decl %int_0 %int_0 %null", + "Binding"), + std::make_pair("ConstantDataPointerPushConstant %float_0 %int_4 %data", + "Offset"), + std::make_pair("ConstantDataPointerPushConstant %null %int_4 %data", + "Offset"), + std::make_pair("ConstantDataPointerPushConstant %int_0 %float_0 %data", + "Size"), + std::make_pair("ConstantDataPointerPushConstant %int_0 %null %data", + "Size"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %float_0 %int_4 %data", + "Offset"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %null %int_4 %data", + "Offset"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %float_0 %data", + "Size"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %null %data", + "Size"), + std::make_pair("PrintfInfo %float_0 %data %int_0 %int_0 %int_0", + "PrintfID"), + std::make_pair("PrintfInfo %null %data %int_0 %int_0 %int_0", + "PrintfID"), + std::make_pair("PrintfInfo %int_0 %data %float_0 %int_0 %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %null %int_0 %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %float_0 %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %null %int_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %int_0 %null", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %int_0 %float_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %float_0", + "ArgumentSizes"), + std::make_pair("PrintfInfo %int_0 %data %int_0 %null", "ArgumentSizes"), + std::make_pair("PrintfBufferStorageBuffer %float_0 %int_0 %int_4", + "DescriptorSet"), + std::make_pair("PrintfBufferStorageBuffer %null %int_0 %int_4", + "DescriptorSet"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %float_0 %int_4", + "Binding"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %null %int_4", + "Binding"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %int_0 %float_0", + "Size"), + std::make_pair("PrintfBufferStorageBuffer %int_0 %int_0 %null", "Size"), + std::make_pair("PrintfBufferPointerPushConstant %float_0 %int_0 %int_4", + "Offset"), + std::make_pair("PrintfBufferPointerPushConstant %null %int_0 %int_4", + "Offset"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %float_0 %int_4", + "Size"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %null %int_4", + "Size"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %int_0 %float_0", + "BufferSize"), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %int_0 %null", + "BufferSize")})); TEST_P(Uint32Constant, Invalid) { const std::string ext_inst = std::get<0>(GetParam()); @@ -6667,7 +7124,7 @@ TEST_P(Uint32Constant, Invalid) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6705,7 +7162,15 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(std::vector>{ std::make_pair("ConstantDataStorageBuffer %int_0 %int_0 %int_0", "Data"), - std::make_pair("ConstantDataUniform %int_0 %int_0 %int_0", "Data")})); + std::make_pair("ConstantDataUniform %int_0 %int_0 %int_0", "Data"), + std::make_pair( + "ProgramScopeVariablesStorageBuffer %int_0 %int_0 %int_0", "Data"), + std::make_pair("ConstantDataPointerPushConstant %int_0 %int_0 %int_0", + "Data"), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %int_0 %int_0", + "Data"), + std::make_pair("PrintfInfo %int_0 %int_0", "FormatString")})); TEST_P(StringOperand, Invalid) { const std::string ext_inst = std::get<0>(GetParam()); @@ -6713,7 +7178,7 @@ TEST_P(StringOperand, Invalid) { const std::string text = R"( OpCapability Shader OpExtension "SPV_KHR_non_semantic_info" -%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %foo "foo" OpExecutionMode %foo LocalSize 1 1 1 @@ -6741,6 +7206,272 @@ OpFunctionEnd EXPECT_THAT(getDiagnosticString(), HasSubstr(name + " must be an OpString")); } +using VersionCheck = spvtest::ValidateBase>; + +INSTANTIATE_TEST_SUITE_P( + ValidateClspvReflectionVersionCheck, VersionCheck, + ::testing::ValuesIn(std::vector>{ + std::make_pair("ArgumentStorageBuffer %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentUniform %decl %int_0 %int_0 %int_0", 1), + std::make_pair( + "ArgumentPodStorageBuffer %decl %int_0 %int_0 %int_0 %int_0 %int_0", + 1), + std::make_pair( + "ArgumentPodUniform %decl %int_0 %int_0 %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentPodPushConstant %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentSampledImage %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentStorageImage %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentSampler %decl %int_0 %int_0 %int_0", 1), + std::make_pair("ArgumentWorkgroup %decl %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantWorkgroupSize %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantGlobalOffset %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantWorkDim %int_0", 1), + std::make_pair("PushConstantGlobalOffset %int_0 %int_0", 1), + std::make_pair("PushConstantEnqueuedLocalSize %int_0 %int_0", 1), + std::make_pair("PushConstantGlobalSize %int_0 %int_0", 1), + std::make_pair("PushConstantRegionOffset %int_0 %int_0", 1), + std::make_pair("PushConstantNumWorkgroups %int_0 %int_0", 1), + std::make_pair("PushConstantRegionGroupOffset %int_0 %int_0", 1), + std::make_pair("ConstantDataStorageBuffer %int_0 %int_0 %data", 1), + std::make_pair("ConstantDataUniform %int_0 %int_0 %data", 1), + std::make_pair("LiteralSampler %int_0 %int_0 %int_0", 1), + std::make_pair( + "PropertyRequiredWorkgroupSize %decl %int_0 %int_0 %int_0", 1), + std::make_pair("SpecConstantSubgroupMaxSize %int_0", 2), + std::make_pair("ArgumentPointerPushConstant %decl %int_0 %int_0 %int_0", + 3), + std::make_pair( + "ArgumentPointerUniform %decl %int_0 %int_0 %int_0 %int_0 %int_0", + 3), + std::make_pair("ProgramScopeVariablesStorageBuffer %int_0 %int_0 %data", + 3), + std::make_pair( + "ProgramScopeVariablePointerRelocation %int_0 %int_0 %int_0", 3), + std::make_pair("ImageArgumentInfoChannelOrderPushConstant %decl %int_0 " + "%int_0 %int_0", + 3), + std::make_pair("ImageArgumentInfoChannelDataTypePushConstant %decl " + "%int_0 %int_0 %int_0", + 3), + std::make_pair("ImageArgumentInfoChannelOrderUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %int_0", + 3), + std::make_pair("ImageArgumentInfoChannelDataTypeUniform %decl %int_0 " + "%int_0 %int_0 %int_0 %int_0", + 3), + std::make_pair("ArgumentStorageTexelBuffer %decl %int_0 %int_0 %int_0", + 4), + std::make_pair("ArgumentUniformTexelBuffer %decl %int_0 %int_0 %int_0", + 4), + std::make_pair("ConstantDataPointerPushConstant %int_0 %int_0 %data", + 5), + std::make_pair( + "ProgramScopeVariablePointerPushConstant %int_0 %int_0 %data", 5), + std::make_pair("PrintfInfo %int_0 %data", 5), + std::make_pair("PrintfBufferStorageBuffer %int_0 %int_0 %int_0", 5), + std::make_pair("PrintfBufferPointerPushConstant %int_0 %int_0 %int_0", + 5)})); + +TEST_P(VersionCheck, V1) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.1" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 1) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 1")); + } +} + +TEST_P(VersionCheck, V2) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.2" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 2) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 2")); + } +} + +TEST_P(VersionCheck, V3) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.3" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 3) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 3")); + } +} + +TEST_P(VersionCheck, V4) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.4" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 4) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 4")); + } +} + +TEST_P(VersionCheck, V5) { + const std::string ext_inst = std::get<0>(GetParam()); + const uint32_t version = std::get<1>(GetParam()); + const std::string text = R"( +OpCapability Shader +OpExtension "SPV_KHR_non_semantic_info" +%ext = OpExtInstImport "NonSemantic.ClspvReflection.5" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %foo "foo" +OpExecutionMode %foo LocalSize 1 1 1 +%foo_name = OpString "foo" +%data = OpString "1234" +%void = OpTypeVoid +%int = OpTypeInt 32 0 +%int_0 = OpConstant %int 0 +%int_1 = OpConstant %int 1 +%int_4 = OpConstant %int 4 +%null = OpConstantNull %int +%float = OpTypeFloat 32 +%float_0 = OpConstant %float 0 +%void_fn = OpTypeFunction %void +%foo = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +%decl = OpExtInst %void %ext Kernel %foo %foo_name +%inst = OpExtInst %void %ext )" + + ext_inst; + + CompileSuccessfully(text); + if (version <= 5) { + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); + } else { + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("requires version " + std::to_string(version) + + ", but parsed version is 1")); + } +} + } // namespace } // namespace val } // namespace spvtools diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index ad5f336fec..d272b08e71 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -69,10 +69,7 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES}) endif(SPIRV_BUILD_FUZZER) if(ENABLE_SPIRV_TOOLS_INSTALL) - install(TARGETS ${SPIRV_INSTALL_TARGETS} EXPORT SPIRV-Tools-toolsTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${SPIRV_INSTALL_TARGETS} EXPORT SPIRV-Tools-toolsTargets) export(EXPORT SPIRV-Tools-toolsTargets FILE SPIRV-Tools-toolsTargets.cmake) spvtools_config_package_dir(SPIRV-Tools-tools PACKAGE_DIR) diff --git a/utils/check_code_format.sh b/utils/check_code_format.sh index 7994740226..da5e019859 100755 --- a/utils/check_code_format.sh +++ b/utils/check_code_format.sh @@ -18,7 +18,7 @@ # # This script assumes to be invoked at the project root directory. -BASE_BRANCH=${1:-master} +BASE_BRANCH=${1:-main} FILES_TO_CHECK=$(git diff --name-only ${BASE_BRANCH} | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$") diff --git a/utils/roll_deps.sh b/utils/roll_deps.sh index 20c061fd86..03bdaceb50 100755 --- a/utils/roll_deps.sh +++ b/utils/roll_deps.sh @@ -27,7 +27,7 @@ googletest_trunk="origin/main" re2_dir="external/re2/" re2_trunk="origin/main" spirv_headers_dir="external/spirv-headers/" -spirv_headers_trunk="origin/master" +spirv_headers_trunk="origin/main" # This script assumes it's parent directory is the repo root. repo_path=$(dirname "$0")/..