Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: gpu/command_buffer/service/gpu_timing.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gpu_state_tracer.cc ('k') | gpu/command_buffer/service/gpu_timing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gpu_timing.h
diff --git a/gpu/command_buffer/service/gpu_timing.h b/gpu/command_buffer/service/gpu_timing.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d9ecf690902e2725ff14f97a96f129ee95e1e2b
--- /dev/null
+++ b/gpu/command_buffer/service/gpu_timing.h
@@ -0,0 +1,85 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
+#define GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "gpu/gpu_export.h"
+#include "ui/gl/gl_bindings.h"
+
+namespace gpu {
+
+class GPUTiming;
+
+// Class to compute the amount of time it takes to fully
+// complete a set of GL commands
+class GPU_EXPORT GPUTimer {
+ public:
+ // gpu_timing must outlive GPUTimer instance we're creating.
+ explicit GPUTimer(GPUTiming* gpu_timing);
+ ~GPUTimer();
+
+ void Start();
+ void End();
+ bool IsAvailable();
+
+ void GetStartEndTimestamps(int64* start, int64* end);
+ int64 GetDeltaElapsed();
+
+ private:
+ GLuint queries_[2];
+ int64 offset_ = 0;
+ bool end_requested_ = false;
+ GPUTiming* gpu_timing_;
+
+ DISALLOW_COPY_AND_ASSIGN(GPUTimer);
+};
+
+// GPUTiming contains all the gl timing logic that is not specific
+// to a single GPUTimer.
+class GPU_EXPORT GPUTiming {
+ public:
+ enum TimerType {
+ kTimerTypeInvalid = -1,
+
+ kTimerTypeARB, // ARB_timer_query
+ kTimerTypeDisjoint // EXT_disjoint_timer_query
+ };
+
+ GPUTiming();
+ virtual ~GPUTiming();
+
+ bool Initialize(gfx::GLContext* context);
+ bool IsAvailable();
+
+ // CheckAndResetTimerErrors has to be called before reading timestamps
+ // from GPUTimers instances and after making sure all the timers
+ // were available.
+ // If the returned value is false, all the previous timers should be
+ // discarded.
+ bool CheckAndResetTimerErrors();
+
+ const char* GetTimerTypeName() const;
+
+ // Returns the offset between the current gpu time and the cpu time.
+ int64 CalculateTimerOffset();
+ void InvalidateTimerOffset();
+
+ void SetCpuTimeForTesting(const base::Callback<int64(void)>& cpu_time);
+ void SetOffsetForTesting(int64 offset, bool cache_it);
+ void SetTimerTypeForTesting(TimerType type);
+
+ private:
+ TimerType timer_type_ = kTimerTypeInvalid;
+ int64 offset_ = 0; // offset cache when timer_type_ == kTimerTypeARB
+ bool offset_valid_ = false;
+ base::Callback<int64(void)> cpu_time_for_testing_;
+ friend class GPUTimer;
+ DISALLOW_COPY_AND_ASSIGN(GPUTiming);
+};
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
« no previous file with comments | « gpu/command_buffer/service/gpu_state_tracer.cc ('k') | gpu/command_buffer/service/gpu_timing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698