query_base.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 tiemstamp.
  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() : guest_address(0), flags{}, value{} {}
  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()
  45. : QueryBase(0, QueryFlagBits::IsHostManaged | QueryFlagBits::IsOrphan, 0), start_bank_id{},
  46. size_banks{}, start_slot{}, size_slots{} {}
  47. // Parameterized constructor
  48. HostQueryBase(bool isLong, VAddr address)
  49. : QueryBase(address, QueryFlagBits::IsHostManaged, 0), start_bank_id{}, size_banks{},
  50. start_slot{}, size_slots{} {
  51. if (isLong) {
  52. flags |= QueryFlagBits::HasTimestamp;
  53. }
  54. }
  55. u32 start_bank_id;
  56. u32 size_banks;
  57. size_t start_slot;
  58. size_t size_slots;
  59. };
  60. } // namespace VideoCommon