render_targets.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <algorithm>
  5. #include <span>
  6. #include "common/bit_cast.h"
  7. #include "video_core/texture_cache/types.h"
  8. namespace VideoCommon {
  9. /// Framebuffer properties used to lookup a framebuffer
  10. struct RenderTargets {
  11. constexpr auto operator<=>(const RenderTargets&) const noexcept = default;
  12. constexpr bool Contains(std::span<const ImageViewId> elements) const noexcept {
  13. const auto contains = [elements](ImageViewId item) {
  14. return std::ranges::find(elements, item) != elements.end();
  15. };
  16. return std::ranges::any_of(color_buffer_ids, contains) || contains(depth_buffer_id);
  17. }
  18. std::array<ImageViewId, NUM_RT> color_buffer_ids{};
  19. ImageViewId depth_buffer_id{};
  20. std::array<u8, NUM_RT> draw_buffers{};
  21. Extent2D size{};
  22. };
  23. } // namespace VideoCommon
  24. namespace std {
  25. template <>
  26. struct hash<VideoCommon::RenderTargets> {
  27. size_t operator()(const VideoCommon::RenderTargets& rt) const noexcept {
  28. using VideoCommon::ImageViewId;
  29. size_t value = std::hash<ImageViewId>{}(rt.depth_buffer_id);
  30. for (const ImageViewId color_buffer_id : rt.color_buffer_ids) {
  31. value ^= std::hash<ImageViewId>{}(color_buffer_id);
  32. }
  33. value ^= Common::BitCast<u64>(rt.draw_buffers);
  34. value ^= Common::BitCast<u64>(rt.size);
  35. return value;
  36. }
  37. };
  38. } // namespace std