Roll external/abseil_cpp/ 8f739d18b..917bfee46 (2 commits) (#5887)
[KhronosGroup/SPIRV-Tools.git] / source / fuzz / uniform_buffer_element_descriptor.h
blobf5d7320a26d966dae2fc5b7cd252de68f1f8d04e
1 // Copyright (c) 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
16 #define SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
18 #include <vector>
20 #include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
21 #include "source/opt/instruction.h"
22 #include "source/opt/ir_context.h"
24 namespace spvtools {
25 namespace fuzz {
27 // Factory method to create a uniform buffer element descriptor message from
28 // descriptor set and binding ids and a list of indices.
29 protobufs::UniformBufferElementDescriptor MakeUniformBufferElementDescriptor(
30 uint32_t descriptor_set, uint32_t binding, std::vector<uint32_t>&& indices);
32 // Equality function for uniform buffer element descriptors.
33 struct UniformBufferElementDescriptorEquals {
34 bool operator()(
35 const protobufs::UniformBufferElementDescriptor* first,
36 const protobufs::UniformBufferElementDescriptor* second) const;
39 // Returns a pointer to an OpVariable in |context| that is decorated with the
40 // descriptor set and binding associated with |uniform_buffer_element|. Returns
41 // nullptr if no such variable exists. If multiple such variables exist, a
42 // pointer to an arbitrary one of the associated instructions is returned if
43 // |check_unique| is false, and nullptr is returned if |check_unique| is true.
44 opt::Instruction* FindUniformVariable(
45 const protobufs::UniformBufferElementDescriptor&
46 uniform_buffer_element_descriptor,
47 opt::IRContext* context, bool check_unique);
49 } // namespace fuzz
50 } // namespace spvtools
52 #endif // SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_