1 // Copyright (c) 2019 Google LLC
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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_
20 #include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
21 #include "source/opt/instruction.h"
22 #include "source/opt/ir_context.h"
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
{
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
);
50 } // namespace spvtools
52 #endif // SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_