uniform_buffer_element_descriptor.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.
  14. #ifndef SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
  15. #define SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
  16. #include <vector>
  17. #include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
  18. #include "source/opt/instruction.h"
  19. #include "source/opt/ir_context.h"
  20. namespace spvtools {
  21. namespace fuzz {
  22. // Factory method to create a uniform buffer element descriptor message from
  23. // descriptor set and binding ids and a list of indices.
  24. protobufs::UniformBufferElementDescriptor MakeUniformBufferElementDescriptor(
  25. uint32_t descriptor_set, uint32_t binding, std::vector<uint32_t>&& indices);
  26. // Equality function for uniform buffer element descriptors.
  27. struct UniformBufferElementDescriptorEquals {
  28. bool operator()(
  29. const protobufs::UniformBufferElementDescriptor* first,
  30. const protobufs::UniformBufferElementDescriptor* second) const;
  31. };
  32. // Returns a pointer to an OpVariable in |context| that is decorated with the
  33. // descriptor set and binding associated with |uniform_buffer_element|. Returns
  34. // nullptr if no such variable exists. If multiple such variables exist, a
  35. // pointer to an arbitrary one of the associated instructions is returned if
  36. // |check_unique| is false, and nullptr is returned if |check_unique| is true.
  37. opt::Instruction* FindUniformVariable(
  38. const protobufs::UniformBufferElementDescriptor&
  39. uniform_buffer_element_descriptor,
  40. opt::IRContext* context, bool check_unique);
  41. } // namespace fuzz
  42. } // namespace spvtools
  43. #endif // SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_