query_base.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-3.0-or-later
  3. #pragma once
  4. #include "common/common_funcs.h"
  5. #include "common/common_types.h"
  6. namespace VideoCommon {
  7. enum class QueryFlagBits : u32 {
  8. HasTimestamp = 1 << 0, ///< Indicates if this query has a timestamp.
  9. IsFinalValueSynced = 1 << 1, ///< Indicates if the query has been synced in the host
  10. IsHostSynced = 1 << 2, ///< Indicates if the query has been synced in the host
  11. IsGuestSynced = 1 << 3, ///< Indicates if the query has been synced with the guest.
  12. IsHostManaged = 1 << 4, ///< Indicates if this query points to a host query
  13. IsRewritten = 1 << 5, ///< Indicates if this query was rewritten by another query
  14. IsInvalidated = 1 << 6, ///< Indicates the value of th query has been nullified.
  15. IsOrphan = 1 << 7, ///< Indicates the query has not been set by a guest query.
  16. IsFence = 1 << 8, ///< Indicates the query is a fence.
  17. };
  18. DECLARE_ENUM_FLAG_OPERATORS(QueryFlagBits)
  19. class QueryBase {
  20. public:
  21. VAddr guest_address{};
  22. QueryFlagBits flags{};
  23. u64 value{};
  24. protected:
  25. // Default constructor
  26. QueryBase() = default;
  27. // Parameterized constructor
  28. QueryBase(VAddr address, QueryFlagBits flags_, u64 value_)
  29. : guest_address(address), flags(flags_), value{value_} {}
  30. };
  31. class GuestQuery : public QueryBase {
  32. public:
  33. // Parameterized constructor
  34. GuestQuery(bool isLong, VAddr address, u64 queryValue)
  35. : QueryBase(address, QueryFlagBits::IsFinalValueSynced, queryValue) {
  36. if (isLong) {
  37. flags |= QueryFlagBits::HasTimestamp;
  38. }
  39. }
  40. };
  41. class HostQueryBase : public QueryBase {
  42. public:
  43. // Default constructor
  44. HostQueryBase() : QueryBase(0, QueryFlagBits::IsHostManaged | QueryFlagBits::IsOrphan, 0) {}
  45. // Parameterized constructor
  46. HostQueryBase(bool has_timestamp, VAddr address)
  47. : QueryBase(address, QueryFlagBits::IsHostManaged, 0), start_bank_id{}, size_banks{},
  48. start_slot{}, size_slots{} {
  49. if (has_timestamp) {
  50. flags |= QueryFlagBits::HasTimestamp;
  51. }
  52. }
  53. u32 start_bank_id{};
  54. u32 size_banks{};
  55. size_t start_slot{};
  56. size_t size_slots{};
  57. };
  58. } // namespace VideoCommon