summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_query_cache.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_query_cache.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_query_cache.h b/src/video_core/renderer_opengl/gl_query_cache.h
new file mode 100644
index 000000000..52c6546bf
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_query_cache.h
@@ -0,0 +1,41 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <glad/glad.h>
+
+#include "common/common_types.h"
+#include "video_core/renderer_opengl/gl_resource_manager.h"
+
+namespace OpenGL {
+
+class HostCounter final {
+public:
+ explicit HostCounter(GLenum target);
+ ~HostCounter();
+
+ /// Enables or disables the counter as required.
+ void UpdateState(bool enabled);
+
+ /// Resets the counter disabling it if needed.
+ void Reset();
+
+ /// Returns the current value of the query.
+ /// @note It may harm precision of future queries if the counter is not disabled.
+ u64 Query();
+
+private:
+ /// Enables the counter when disabled.
+ void Enable();
+
+ /// Disables the counter when enabled.
+ void Disable();
+
+ OGLQuery query; ///< OpenGL query.
+ u64 counter{}; ///< Added values of the counter.
+ bool is_beginned{}; ///< True when the OpenGL query is beginned.
+};
+
+} // namespace OpenGL