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

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

Issue 940633004: Added disjoint context class which manages disjoints within gpu timing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize disjoint value to proper value 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
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
index 1d9ecf690902e2725ff14f97a96f129ee95e1e2b..9c8b8cc40d0b2656568108d3ff8bf12d7e610ee5 100644
--- a/gpu/command_buffer/service/gpu_timing.h
+++ b/gpu/command_buffer/service/gpu_timing.h
@@ -5,6 +5,8 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
#define GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
+#include <vector>
+
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "gpu/gpu_export.h"
@@ -38,6 +40,33 @@ class GPU_EXPORT GPUTimer {
DISALLOW_COPY_AND_ASSIGN(GPUTimer);
};
+// DisjointContext keeps track of disjoint conditions which invalidate
+// timing values. Each GPUTiming class can keep track of multiple
+// DisjointContexts so that a single GL Context can support multiple
+// tracings.
+class GPU_EXPORT DisjointContext : public base::RefCounted<DisjointContext> {
+ public:
+ // 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();
+
+ protected:
+ DisjointContext(GPUTiming* gpu_timing, bool disjoint_value);
+ virtual ~DisjointContext();
+ friend class base::RefCounted<DisjointContext>;
+
+ private:
+ void ResetParentGPUTiming();
+ void SetDisjoint();
+
+ GPUTiming* gpu_timing_;
+ bool disjoint_value_;
+ friend class GPUTiming;
+};
+
// GPUTiming contains all the gl timing logic that is not specific
// to a single GPUTimer.
class GPU_EXPORT GPUTiming {
@@ -55,12 +84,8 @@ class GPU_EXPORT 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();
+ scoped_refptr<DisjointContext> CreateDisjointContext();
+ size_t GetDisjointContextsCount() { return disjoint_contexts_.size(); }
const char* GetTimerTypeName() const;
@@ -73,11 +98,17 @@ class GPU_EXPORT GPUTiming {
void SetTimerTypeForTesting(TimerType type);
private:
+ void UpdateDisjointContexts();
+ void RemoveDisjointContext(DisjointContext* context);
+
TimerType timer_type_ = kTimerTypeInvalid;
int64 offset_ = 0; // offset cache when timer_type_ == kTimerTypeARB
bool offset_valid_ = false;
+ bool disjoint_occurred_ = false;
+ std::vector<DisjointContext*> disjoint_contexts_;
Daniele Castagna 2015/02/19 18:15:32 How many disjoint contexts do you think there are
David Yen 2015/02/19 19:00:47 Most likely only a few, but going from 2 to n does
base::Callback<int64(void)> cpu_time_for_testing_;
friend class GPUTimer;
+ friend class DisjointContext;
DISALLOW_COPY_AND_ASSIGN(GPUTiming);
};
} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698