summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_query_cache.h
blob: 52c6546bf9160378eca990a63309e42c89314263 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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