query_cache.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-3.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include <deque>
  6. #include <memory>
  7. #include <mutex>
  8. #include <unordered_map>
  9. #include <utility>
  10. #include "common/assert.h"
  11. #include "common/common_types.h"
  12. #include "common/logging/log.h"
  13. #include "common/scope_exit.h"
  14. #include "common/settings.h"
  15. #include "core/memory.h"
  16. #include "video_core/engines/maxwell_3d.h"
  17. #include "video_core/gpu.h"
  18. #include "video_core/memory_manager.h"
  19. #include "video_core/query_cache/bank_base.h"
  20. #include "video_core/query_cache/query_base.h"
  21. #include "video_core/query_cache/query_cache_base.h"
  22. #include "video_core/query_cache/query_stream.h"
  23. #include "video_core/query_cache/types.h"
  24. namespace VideoCommon {
  25. using Maxwell = Tegra::Engines::Maxwell3D;
  26. struct SyncValuesStruct {
  27. VAddr address;
  28. u64 value;
  29. u64 size;
  30. static constexpr bool GeneratesBaseBuffer = true;
  31. };
  32. template <typename Traits>
  33. class GuestStreamer : public SimpleStreamer<GuestQuery> {
  34. public:
  35. using RuntimeType = typename Traits::RuntimeType;
  36. GuestStreamer(size_t id_, RuntimeType& runtime_)
  37. : SimpleStreamer<GuestQuery>(id_), runtime{runtime_} {}
  38. virtual ~GuestStreamer() = default;
  39. size_t WriteCounter(VAddr address, bool has_timestamp, u32 value,
  40. std::optional<u32> subreport = std::nullopt) override {
  41. auto new_id = BuildQuery(has_timestamp, address, static_cast<u64>(value));
  42. pending_sync.push_back(new_id);
  43. return new_id;
  44. }
  45. bool HasPendingSync() const override {
  46. return !pending_sync.empty();
  47. }
  48. void SyncWrites() override {
  49. if (pending_sync.empty()) {
  50. return;
  51. }
  52. std::vector<SyncValuesStruct> sync_values;
  53. sync_values.reserve(pending_sync.size());
  54. for (size_t pending_id : pending_sync) {
  55. auto& query = slot_queries[pending_id];
  56. if (True(query.flags & QueryFlagBits::IsRewritten) ||
  57. True(query.flags & QueryFlagBits::IsInvalidated)) {
  58. continue;
  59. }
  60. query.flags |= QueryFlagBits::IsHostSynced;
  61. sync_values.emplace_back(SyncValuesStruct{
  62. .address = query.guest_address,
  63. .value = query.value,
  64. .size = static_cast<u64>(True(query.flags & QueryFlagBits::HasTimestamp) ? 8 : 4)});
  65. }
  66. pending_sync.clear();
  67. if (sync_values.size() > 0) {
  68. runtime.template SyncValues<SyncValuesStruct>(sync_values);
  69. }
  70. }
  71. private:
  72. RuntimeType& runtime;
  73. std::deque<size_t> pending_sync;
  74. };
  75. template <typename Traits>
  76. class StubStreamer : public GuestStreamer<Traits> {
  77. public:
  78. using RuntimeType = typename Traits::RuntimeType;
  79. StubStreamer(size_t id_, RuntimeType& runtime_, u32 stub_value_)
  80. : GuestStreamer<Traits>(id_, runtime_), stub_value{stub_value_} {}
  81. ~StubStreamer() override = default;
  82. size_t WriteCounter(VAddr address, bool has_timestamp, [[maybe_unused]] u32 value,
  83. std::optional<u32> subreport = std::nullopt) override {
  84. size_t new_id =
  85. GuestStreamer<Traits>::WriteCounter(address, has_timestamp, stub_value, subreport);
  86. return new_id;
  87. }
  88. private:
  89. u32 stub_value;
  90. };
  91. template <typename Traits>
  92. struct QueryCacheBase<Traits>::QueryCacheBaseImpl {
  93. using RuntimeType = typename Traits::RuntimeType;
  94. QueryCacheBaseImpl(QueryCacheBase<Traits>* owner_, VideoCore::RasterizerInterface& rasterizer_,
  95. Core::Memory::Memory& cpu_memory_, RuntimeType& runtime_, Tegra::GPU& gpu_)
  96. : owner{owner_}, rasterizer{rasterizer_},
  97. cpu_memory{cpu_memory_}, runtime{runtime_}, gpu{gpu_} {
  98. streamer_mask = 0;
  99. for (size_t i = 0; i < static_cast<size_t>(QueryType::MaxQueryTypes); i++) {
  100. streamers[i] = runtime.GetStreamerInterface(static_cast<QueryType>(i));
  101. if (streamers[i]) {
  102. streamer_mask |= 1ULL << streamers[i]->GetId();
  103. }
  104. }
  105. }
  106. template <typename Func>
  107. void ForEachStreamerIn(u64 mask, Func&& func) {
  108. static constexpr bool RETURNS_BOOL =
  109. std::is_same_v<std::invoke_result<Func, StreamerInterface*>, bool>;
  110. while (mask != 0) {
  111. size_t position = std::countr_zero(mask);
  112. mask &= ~(1ULL << position);
  113. if constexpr (RETURNS_BOOL) {
  114. if (func(streamers[position])) {
  115. return;
  116. }
  117. } else {
  118. func(streamers[position]);
  119. }
  120. }
  121. }
  122. template <typename Func>
  123. void ForEachStreamer(Func&& func) {
  124. ForEachStreamerIn(streamer_mask, func);
  125. }
  126. QueryBase* ObtainQuery(QueryCacheBase<Traits>::QueryLocation location) {
  127. size_t which_stream = location.stream_id.Value();
  128. auto* streamer = streamers[which_stream];
  129. if (!streamer) {
  130. return nullptr;
  131. }
  132. return streamer->GetQuery(location.query_id.Value());
  133. }
  134. QueryCacheBase<Traits>* owner;
  135. VideoCore::RasterizerInterface& rasterizer;
  136. Core::Memory::Memory& cpu_memory;
  137. RuntimeType& runtime;
  138. Tegra::GPU& gpu;
  139. std::array<StreamerInterface*, static_cast<size_t>(QueryType::MaxQueryTypes)> streamers;
  140. u64 streamer_mask;
  141. std::mutex flush_guard;
  142. std::deque<u64> flushes_pending;
  143. std::vector<QueryCacheBase<Traits>::QueryLocation> pending_unregister;
  144. };
  145. template <typename Traits>
  146. QueryCacheBase<Traits>::QueryCacheBase(Tegra::GPU& gpu_,
  147. VideoCore::RasterizerInterface& rasterizer_,
  148. Core::Memory::Memory& cpu_memory_, RuntimeType& runtime_)
  149. : cached_queries{} {
  150. impl = std::make_unique<QueryCacheBase<Traits>::QueryCacheBaseImpl>(
  151. this, rasterizer_, cpu_memory_, runtime_, gpu_);
  152. }
  153. template <typename Traits>
  154. QueryCacheBase<Traits>::~QueryCacheBase() = default;
  155. template <typename Traits>
  156. void QueryCacheBase<Traits>::CounterEnable(QueryType counter_type, bool is_enabled) {
  157. size_t index = static_cast<size_t>(counter_type);
  158. StreamerInterface* streamer = impl->streamers[index];
  159. if (!streamer) [[unlikely]] {
  160. UNREACHABLE();
  161. return;
  162. }
  163. if (is_enabled) {
  164. streamer->StartCounter();
  165. } else {
  166. streamer->PauseCounter();
  167. }
  168. }
  169. template <typename Traits>
  170. void QueryCacheBase<Traits>::CounterClose(QueryType counter_type) {
  171. size_t index = static_cast<size_t>(counter_type);
  172. StreamerInterface* streamer = impl->streamers[index];
  173. if (!streamer) [[unlikely]] {
  174. UNREACHABLE();
  175. return;
  176. }
  177. streamer->CloseCounter();
  178. }
  179. template <typename Traits>
  180. void QueryCacheBase<Traits>::CounterReset(QueryType counter_type) {
  181. size_t index = static_cast<size_t>(counter_type);
  182. StreamerInterface* streamer = impl->streamers[index];
  183. if (!streamer) [[unlikely]] {
  184. UNIMPLEMENTED();
  185. return;
  186. }
  187. streamer->ResetCounter();
  188. }
  189. template <typename Traits>
  190. void QueryCacheBase<Traits>::BindToChannel(s32 id) {
  191. VideoCommon::ChannelSetupCaches<VideoCommon::ChannelInfo>::BindToChannel(id);
  192. impl->runtime.Bind3DEngine(maxwell3d);
  193. }
  194. template <typename Traits>
  195. void QueryCacheBase<Traits>::CounterReport(GPUVAddr addr, QueryType counter_type,
  196. QueryPropertiesFlags flags, u32 payload, u32 subreport) {
  197. const bool has_timestamp = True(flags & QueryPropertiesFlags::HasTimeout);
  198. const bool is_fence = True(flags & QueryPropertiesFlags::IsAFence);
  199. size_t streamer_id = static_cast<size_t>(counter_type);
  200. auto* streamer = impl->streamers[streamer_id];
  201. if (streamer == nullptr) [[unlikely]] {
  202. counter_type = QueryType::Payload;
  203. payload = 1U;
  204. streamer_id = static_cast<size_t>(counter_type);
  205. streamer = impl->streamers[streamer_id];
  206. }
  207. auto cpu_addr_opt = gpu_memory->GpuToCpuAddress(addr);
  208. if (!cpu_addr_opt) [[unlikely]] {
  209. return;
  210. }
  211. VAddr cpu_addr = *cpu_addr_opt;
  212. const size_t new_query_id = streamer->WriteCounter(cpu_addr, has_timestamp, payload, subreport);
  213. auto* query = streamer->GetQuery(new_query_id);
  214. if (is_fence) {
  215. query->flags |= QueryFlagBits::IsFence;
  216. }
  217. QueryLocation query_location{};
  218. query_location.stream_id.Assign(static_cast<u32>(streamer_id));
  219. query_location.query_id.Assign(static_cast<u32>(new_query_id));
  220. const auto gen_caching_indexing = [](VAddr cur_addr) {
  221. return std::make_pair<u64, u32>(cur_addr >> Core::Memory::YUZU_PAGEBITS,
  222. static_cast<u32>(cur_addr & Core::Memory::YUZU_PAGEMASK));
  223. };
  224. u8* pointer = impl->cpu_memory.GetPointer(cpu_addr);
  225. u8* pointer_timestamp = impl->cpu_memory.GetPointer(cpu_addr + 8);
  226. bool is_synced = !Settings::IsGPULevelHigh() && is_fence;
  227. std::function<void()> operation([this, is_synced, streamer, query_base = query, query_location,
  228. pointer, pointer_timestamp] {
  229. if (True(query_base->flags & QueryFlagBits::IsInvalidated)) {
  230. if (!is_synced) [[likely]] {
  231. impl->pending_unregister.push_back(query_location);
  232. }
  233. return;
  234. }
  235. if (False(query_base->flags & QueryFlagBits::IsFinalValueSynced)) [[unlikely]] {
  236. ASSERT(false);
  237. return;
  238. }
  239. query_base->value += streamer->GetAmmendValue();
  240. streamer->SetAccumulationValue(query_base->value);
  241. if (True(query_base->flags & QueryFlagBits::HasTimestamp)) {
  242. u64 timestamp = impl->gpu.GetTicks();
  243. std::memcpy(pointer_timestamp, &timestamp, sizeof(timestamp));
  244. std::memcpy(pointer, &query_base->value, sizeof(query_base->value));
  245. } else {
  246. u32 value = static_cast<u32>(query_base->value);
  247. std::memcpy(pointer, &value, sizeof(value));
  248. }
  249. if (!is_synced) [[likely]] {
  250. impl->pending_unregister.push_back(query_location);
  251. }
  252. });
  253. if (is_fence) {
  254. impl->rasterizer.SignalFence(std::move(operation));
  255. } else {
  256. if (!Settings::IsGPULevelHigh() && counter_type == QueryType::Payload) {
  257. if (has_timestamp) {
  258. u64 timestamp = impl->gpu.GetTicks();
  259. u64 value = static_cast<u64>(payload);
  260. std::memcpy(pointer_timestamp, &timestamp, sizeof(timestamp));
  261. std::memcpy(pointer, &value, sizeof(value));
  262. } else {
  263. std::memcpy(pointer, &payload, sizeof(payload));
  264. }
  265. streamer->Free(new_query_id);
  266. return;
  267. }
  268. impl->rasterizer.SyncOperation(std::move(operation));
  269. }
  270. if (is_synced) {
  271. streamer->Free(new_query_id);
  272. return;
  273. }
  274. auto [cont_addr, base] = gen_caching_indexing(cpu_addr);
  275. {
  276. std::scoped_lock lock(cache_mutex);
  277. auto it1 = cached_queries.try_emplace(cont_addr);
  278. auto& sub_container = it1.first->second;
  279. auto it_current = sub_container.find(base);
  280. if (it_current == sub_container.end()) {
  281. sub_container.insert_or_assign(base, query_location);
  282. return;
  283. }
  284. auto* old_query = impl->ObtainQuery(it_current->second);
  285. old_query->flags |= QueryFlagBits::IsRewritten;
  286. sub_container.insert_or_assign(base, query_location);
  287. }
  288. }
  289. template <typename Traits>
  290. void QueryCacheBase<Traits>::UnregisterPending() {
  291. const auto gen_caching_indexing = [](VAddr cur_addr) {
  292. return std::make_pair<u64, u32>(cur_addr >> Core::Memory::YUZU_PAGEBITS,
  293. static_cast<u32>(cur_addr & Core::Memory::YUZU_PAGEMASK));
  294. };
  295. std::scoped_lock lock(cache_mutex);
  296. for (QueryLocation loc : impl->pending_unregister) {
  297. const auto [streamer_id, query_id] = loc.unpack();
  298. auto* streamer = impl->streamers[streamer_id];
  299. if (!streamer) [[unlikely]] {
  300. continue;
  301. }
  302. auto* query = streamer->GetQuery(query_id);
  303. auto [cont_addr, base] = gen_caching_indexing(query->guest_address);
  304. auto it1 = cached_queries.find(cont_addr);
  305. if (it1 != cached_queries.end()) {
  306. auto it2 = it1->second.find(base);
  307. if (it2 != it1->second.end()) {
  308. if (it2->second.raw == loc.raw) {
  309. it1->second.erase(it2);
  310. }
  311. }
  312. }
  313. streamer->Free(query_id);
  314. }
  315. impl->pending_unregister.clear();
  316. }
  317. template <typename Traits>
  318. void QueryCacheBase<Traits>::NotifyWFI() {
  319. bool should_sync = false;
  320. impl->ForEachStreamer(
  321. [&should_sync](StreamerInterface* streamer) { should_sync |= streamer->HasPendingSync(); });
  322. if (!should_sync) {
  323. return;
  324. }
  325. impl->ForEachStreamer([](StreamerInterface* streamer) { streamer->PresyncWrites(); });
  326. impl->runtime.Barriers(true);
  327. impl->ForEachStreamer([](StreamerInterface* streamer) { streamer->SyncWrites(); });
  328. impl->runtime.Barriers(false);
  329. }
  330. template <typename Traits>
  331. void QueryCacheBase<Traits>::NotifySegment(bool resume) {
  332. if (resume) {
  333. impl->runtime.ResumeHostConditionalRendering();
  334. } else {
  335. CounterClose(VideoCommon::QueryType::ZPassPixelCount64);
  336. CounterClose(VideoCommon::QueryType::StreamingByteCount);
  337. impl->runtime.PauseHostConditionalRendering();
  338. }
  339. }
  340. template <typename Traits>
  341. bool QueryCacheBase<Traits>::AccelerateHostConditionalRendering() {
  342. bool qc_dirty = false;
  343. const auto gen_lookup = [this, &qc_dirty](GPUVAddr address) -> VideoCommon::LookupData {
  344. auto cpu_addr_opt = gpu_memory->GpuToCpuAddress(address);
  345. if (!cpu_addr_opt) [[unlikely]] {
  346. return VideoCommon::LookupData{
  347. .address = 0,
  348. .found_query = nullptr,
  349. };
  350. }
  351. VAddr cpu_addr = *cpu_addr_opt;
  352. std::scoped_lock lock(cache_mutex);
  353. auto it1 = cached_queries.find(cpu_addr >> Core::Memory::YUZU_PAGEBITS);
  354. if (it1 == cached_queries.end()) {
  355. return VideoCommon::LookupData{
  356. .address = cpu_addr,
  357. .found_query = nullptr,
  358. };
  359. }
  360. auto& sub_container = it1->second;
  361. auto it_current = sub_container.find(cpu_addr & Core::Memory::YUZU_PAGEMASK);
  362. if (it_current == sub_container.end()) {
  363. auto it_current_2 = sub_container.find((cpu_addr & Core::Memory::YUZU_PAGEMASK) + 4);
  364. if (it_current_2 == sub_container.end()) {
  365. return VideoCommon::LookupData{
  366. .address = cpu_addr,
  367. .found_query = nullptr,
  368. };
  369. }
  370. }
  371. auto* query = impl->ObtainQuery(it_current->second);
  372. qc_dirty |= True(query->flags & QueryFlagBits::IsHostManaged) &&
  373. False(query->flags & QueryFlagBits::IsGuestSynced);
  374. return VideoCommon::LookupData{
  375. .address = cpu_addr,
  376. .found_query = query,
  377. };
  378. };
  379. auto& regs = maxwell3d->regs;
  380. if (regs.render_enable_override != Maxwell::Regs::RenderEnable::Override::UseRenderEnable) {
  381. impl->runtime.EndHostConditionalRendering();
  382. return false;
  383. }
  384. const ComparisonMode mode = static_cast<ComparisonMode>(regs.render_enable.mode);
  385. const GPUVAddr address = regs.render_enable.Address();
  386. switch (mode) {
  387. case ComparisonMode::True:
  388. impl->runtime.EndHostConditionalRendering();
  389. return false;
  390. case ComparisonMode::False:
  391. impl->runtime.EndHostConditionalRendering();
  392. return false;
  393. case ComparisonMode::Conditional: {
  394. VideoCommon::LookupData object_1{gen_lookup(address)};
  395. return impl->runtime.HostConditionalRenderingCompareValue(object_1, qc_dirty);
  396. }
  397. case ComparisonMode::IfEqual: {
  398. VideoCommon::LookupData object_1{gen_lookup(address)};
  399. VideoCommon::LookupData object_2{gen_lookup(address + 16)};
  400. return impl->runtime.HostConditionalRenderingCompareValues(object_1, object_2, qc_dirty,
  401. true);
  402. }
  403. case ComparisonMode::IfNotEqual: {
  404. VideoCommon::LookupData object_1{gen_lookup(address)};
  405. VideoCommon::LookupData object_2{gen_lookup(address + 16)};
  406. return impl->runtime.HostConditionalRenderingCompareValues(object_1, object_2, qc_dirty,
  407. false);
  408. }
  409. default:
  410. return false;
  411. }
  412. }
  413. // Async downloads
  414. template <typename Traits>
  415. void QueryCacheBase<Traits>::CommitAsyncFlushes() {
  416. // Make sure to have the results synced in Host.
  417. NotifyWFI();
  418. u64 mask{};
  419. {
  420. std::scoped_lock lk(impl->flush_guard);
  421. impl->ForEachStreamer([&mask](StreamerInterface* streamer) {
  422. bool local_result = streamer->HasUnsyncedQueries();
  423. if (local_result) {
  424. mask |= 1ULL << streamer->GetId();
  425. }
  426. });
  427. impl->flushes_pending.push_back(mask);
  428. }
  429. std::function<void()> func([this] { UnregisterPending(); });
  430. impl->rasterizer.SyncOperation(std::move(func));
  431. if (mask == 0) {
  432. return;
  433. }
  434. u64 ran_mask = ~mask;
  435. while (mask) {
  436. impl->ForEachStreamerIn(mask, [&mask, &ran_mask](StreamerInterface* streamer) {
  437. u64 dep_mask = streamer->GetDependentMask();
  438. if ((dep_mask & ~ran_mask) != 0) {
  439. return;
  440. }
  441. u64 index = streamer->GetId();
  442. ran_mask |= (1ULL << index);
  443. mask &= ~(1ULL << index);
  444. streamer->PushUnsyncedQueries();
  445. });
  446. }
  447. }
  448. template <typename Traits>
  449. bool QueryCacheBase<Traits>::HasUncommittedFlushes() const {
  450. bool result = false;
  451. impl->ForEachStreamer([&result](StreamerInterface* streamer) {
  452. result |= streamer->HasUnsyncedQueries();
  453. return result;
  454. });
  455. return result;
  456. }
  457. template <typename Traits>
  458. bool QueryCacheBase<Traits>::ShouldWaitAsyncFlushes() {
  459. std::scoped_lock lk(impl->flush_guard);
  460. return !impl->flushes_pending.empty() && impl->flushes_pending.front() != 0ULL;
  461. }
  462. template <typename Traits>
  463. void QueryCacheBase<Traits>::PopAsyncFlushes() {
  464. u64 mask;
  465. {
  466. std::scoped_lock lk(impl->flush_guard);
  467. mask = impl->flushes_pending.front();
  468. impl->flushes_pending.pop_front();
  469. }
  470. if (mask == 0) {
  471. return;
  472. }
  473. u64 ran_mask = ~mask;
  474. while (mask) {
  475. impl->ForEachStreamerIn(mask, [&mask, &ran_mask](StreamerInterface* streamer) {
  476. u64 dep_mask = streamer->GetDependenceMask();
  477. if ((dep_mask & ~ran_mask) != 0) {
  478. return;
  479. }
  480. u64 index = streamer->GetId();
  481. ran_mask |= (1ULL << index);
  482. mask &= ~(1ULL << index);
  483. streamer->PopUnsyncedQueries();
  484. });
  485. }
  486. }
  487. // Invalidation
  488. template <typename Traits>
  489. void QueryCacheBase<Traits>::InvalidateQuery(QueryCacheBase<Traits>::QueryLocation location) {
  490. auto* query_base = impl->ObtainQuery(location);
  491. if (!query_base) {
  492. return;
  493. }
  494. query_base->flags |= QueryFlagBits::IsInvalidated;
  495. }
  496. template <typename Traits>
  497. bool QueryCacheBase<Traits>::IsQueryDirty(QueryCacheBase<Traits>::QueryLocation location) {
  498. auto* query_base = impl->ObtainQuery(location);
  499. if (!query_base) {
  500. return false;
  501. }
  502. return True(query_base->flags & QueryFlagBits::IsHostManaged) &&
  503. False(query_base->flags & QueryFlagBits::IsGuestSynced);
  504. }
  505. template <typename Traits>
  506. bool QueryCacheBase<Traits>::SemiFlushQueryDirty(QueryCacheBase<Traits>::QueryLocation location) {
  507. auto* query_base = impl->ObtainQuery(location);
  508. if (!query_base) {
  509. return false;
  510. }
  511. if (True(query_base->flags & QueryFlagBits::IsFinalValueSynced) &&
  512. False(query_base->flags & QueryFlagBits::IsGuestSynced)) {
  513. auto* ptr = impl->cpu_memory.GetPointer(query_base->guest_address);
  514. if (True(query_base->flags & QueryFlagBits::HasTimestamp)) {
  515. std::memcpy(ptr, &query_base->value, sizeof(query_base->value));
  516. return false;
  517. }
  518. u32 value_l = static_cast<u32>(query_base->value);
  519. std::memcpy(ptr, &value_l, sizeof(value_l));
  520. return false;
  521. }
  522. return True(query_base->flags & QueryFlagBits::IsHostManaged) &&
  523. False(query_base->flags & QueryFlagBits::IsGuestSynced);
  524. }
  525. template <typename Traits>
  526. void QueryCacheBase<Traits>::RequestGuestHostSync() {
  527. impl->rasterizer.ReleaseFences();
  528. }
  529. } // namespace VideoCommon