/* Copyright (c) 2022-2023 The Khronos Group Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <sstream> #include "state_tracker/shader_instruction.h" #include "generated/spirv_grammar_helper.h" namespace spirv { Instruction::Instruction(std::vector<uint32_t>::const_iterator it) { … } Instruction::Instruction(const uint32_t* it) { … } void Instruction::SetResultTypeIndex() { … } void Instruction::UpdateDebugInfo() { … } std::string Instruction::Describe() const { … } // While simple, function name provides a more human readable description why Word(3) is used. // // The current various uses for constant values (OpAccessChain, OpTypeArray, LocalSize, etc) all have spec langauge making sure they // are scalar ints. It is also not valid for any of these use cases to have a negative value. While it is valid SPIR-V to use 64-bit // int, found writting test there is no way to create something valid that also calls this function. So until a use-case is found, // we can safely assume returning a uint32_t is ok. uint32_t Instruction::GetConstantValue() const { … } // The idea of this function is to not have to constantly lookup which operand for the width // inst.Word(2) -> inst.GetBitWidth() uint32_t Instruction::GetBitWidth() const { … } spv::BuiltIn Instruction::GetBuiltIn() const { … } bool Instruction::IsArray() const { … } spv::Dim Instruction::FindImageDim() const { … } bool Instruction::IsImageArray() const { … } bool Instruction::IsImageMultisampled() const { … } spv::StorageClass Instruction::StorageClass() const { … } } // namespace spirv