summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp3
-rw-r--r--src/video_core/gpu.cpp14
-rw-r--r--src/video_core/gpu.h2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 2a5855795..a7e1dee04 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -9,6 +9,7 @@
9#include "core/core_timing.h" 9#include "core/core_timing.h"
10#include "video_core/engines/maxwell_3d.h" 10#include "video_core/engines/maxwell_3d.h"
11#include "video_core/engines/shader_type.h" 11#include "video_core/engines/shader_type.h"
12#include "video_core/gpu.h"
12#include "video_core/memory_manager.h" 13#include "video_core/memory_manager.h"
13#include "video_core/rasterizer_interface.h" 14#include "video_core/rasterizer_interface.h"
14#include "video_core/textures/texture.h" 15#include "video_core/textures/texture.h"
@@ -533,7 +534,7 @@ void Maxwell3D::StampQueryResult(u64 payload, bool long_query) {
533 LongQueryResult query_result{}; 534 LongQueryResult query_result{};
534 query_result.value = payload; 535 query_result.value = payload;
535 // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming 536 // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming
536 query_result.timestamp = system.CoreTiming().GetTicks(); 537 query_result.timestamp = system.GPU().GetTicks();
537 memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result)); 538 memory_manager.WriteBlock(sequence_address, &query_result, sizeof(query_result));
538 } else { 539 } else {
539 memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload)); 540 memory_manager.Write<u32>(sequence_address, static_cast<u32>(payload));
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 062ca83b8..4aca39faf 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -6,6 +6,7 @@
6#include "common/microprofile.h" 6#include "common/microprofile.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/core_timing.h" 8#include "core/core_timing.h"
9#include "core/core_timing_util.h"
9#include "core/memory.h" 10#include "core/memory.h"
10#include "video_core/engines/fermi_2d.h" 11#include "video_core/engines/fermi_2d.h"
11#include "video_core/engines/kepler_compute.h" 12#include "video_core/engines/kepler_compute.h"
@@ -122,6 +123,17 @@ bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
122 return true; 123 return true;
123} 124}
124 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 {
132 const u64 cpu_ticks = system.CoreTiming().GetTicks();
133 const u64 nanoseconds = Core::Timing::CyclesToNs(cpu_ticks).count();
134 return (nanoseconds * gpu_ticks_num) / gpu_ticks_den;
135}
136
125void GPU::FlushCommands() { 137void GPU::FlushCommands() {
126 renderer.Rasterizer().FlushCommands(); 138 renderer.Rasterizer().FlushCommands();
127} 139}
@@ -340,7 +352,7 @@ void GPU::ProcessSemaphoreTriggerMethod() {
340 block.sequence = regs.semaphore_sequence; 352 block.sequence = regs.semaphore_sequence;
341 // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of 353 // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of
342 // CoreTiming 354 // CoreTiming
343 block.timestamp = system.CoreTiming().GetTicks(); 355 block.timestamp = GetTicks();
344 memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, 356 memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block,
345 sizeof(block)); 357 sizeof(block));
346 } else { 358 } else {
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index b648317bb..07727210c 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -192,6 +192,8 @@ public:
192 192
193 bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value); 193 bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value);
194 194
195 u64 GetTicks() const;
196
195 std::unique_lock<std::mutex> LockSync() { 197 std::unique_lock<std::mutex> LockSync() {
196 return std::unique_lock{sync_mutex}; 198 return std::unique_lock{sync_mutex};
197 } 199 }