summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/maxwell_3d.cpp7
-rw-r--r--src/video_core/gpu.cpp14
2 files changed, 10 insertions, 11 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index a7e1dee04..0b3e8749b 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -531,10 +531,7 @@ void Maxwell3D::StampQueryResult(u64 payload, bool long_query) {
531 // Write the 128-bit result structure in long mode. Note: We emulate an infinitely fast 531 // Write the 128-bit result structure in long mode. Note: We emulate an infinitely fast
532 // GPU, this command may actually take a while to complete in real hardware due to GPU 532 // GPU, this command may actually take a while to complete in real hardware due to GPU
533 // wait queues. 533 // wait queues.
534 LongQueryResult query_result{}; 534 LongQueryResult query_result{payload, system.GPU().GetTicks()};
535 query_result.value = payload;
536 // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming
537 query_result.timestamp = system.GPU().GetTicks();
538 memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result)); 535 memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result));
539 } else { 536 } else {
540 memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload)); 537 memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload));
@@ -548,7 +545,7 @@ void Maxwell3D::ProcessQueryGet() {
548 545
549 switch (regs.query.query_get.operation) { 546 switch (regs.query.query_get.operation) {
550 case Regs::QueryOperation::Release: { 547 case Regs::QueryOperation::Release: {
551 u64 result = regs.query.query_sequence; 548 const u64 result = regs.query.query_sequence;
552 StampQueryResult(result, regs.query.query_get.short_query == 0); 549 StampQueryResult(result, regs.query.query_get.short_query == 0);
553 break; 550 break;
554 } 551 }
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 4aca39faf..4419ab735 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -123,15 +123,17 @@ bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
123 return true; 123 return true;
124} 124}
125 125
126// This values were reversed engineered by fincs from NVN
127// The gpu clock is reported in units of 385/625 nanoseconds
128constexpr u64 gpu_ticks_num = 384;
129constexpr u64 gpu_ticks_den = 625;
130
131u64 GPU::GetTicks() const { 126u64 GPU::GetTicks() const {
127 // This values were reversed engineered by fincs from NVN
128 // The gpu clock is reported in units of 385/625 nanoseconds
129 constexpr u64 gpu_ticks_num = 384;
130 constexpr u64 gpu_ticks_den = 625;
131
132 const u64 cpu_ticks = system.CoreTiming().GetTicks(); 132 const u64 cpu_ticks = system.CoreTiming().GetTicks();
133 const u64 nanoseconds = Core::Timing::CyclesToNs(cpu_ticks).count(); 133 const u64 nanoseconds = Core::Timing::CyclesToNs(cpu_ticks).count();
134 return (nanoseconds * gpu_ticks_num) / gpu_ticks_den; 134 const u64 nanoseconds_num = nanoseconds / gpu_ticks_den;
135 const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den;
136 return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den;
135} 137}
136 138
137void GPU::FlushCommands() { 139void GPU::FlushCommands() {