data_descriptor.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_DATA_DESCRIPTOR_H_
  15. #define SOURCE_FUZZ_DATA_DESCRIPTOR_H_
  16. #include <ostream>
  17. #include <vector>
  18. #include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
  19. namespace spvtools {
  20. namespace fuzz {
  21. // Factory method to create a data descriptor message from an object id and a
  22. // list of indices.
  23. protobufs::DataDescriptor MakeDataDescriptor(
  24. uint32_t object, const std::vector<uint32_t>& indices);
  25. // Hash function for data descriptors.
  26. struct DataDescriptorHash {
  27. size_t operator()(const protobufs::DataDescriptor* data_descriptor) const;
  28. };
  29. // Equality function for data descriptors.
  30. struct DataDescriptorEquals {
  31. bool operator()(const protobufs::DataDescriptor* first,
  32. const protobufs::DataDescriptor* second) const;
  33. };
  34. std::ostream& operator<<(std::ostream& out,
  35. const protobufs::DataDescriptor& data_descriptor);
  36. } // namespace fuzz
  37. } // namespace spvtools
  38. #endif // SOURCE_FUZZ_DATA_DESCRIPTOR_H_