mirror of https://github.com/yuzu-mirror/yuzu
maxwell_3d: Slow implementation of passed samples (query 21)
Implements GL_SAMPLES_PASSED by waiting immediately for queries.pull/8/head
parent
3217400dd1
commit
2b58652f08
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright 2019 yuzu Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <glad/glad.h>
|
||||||
|
|
||||||
|
#include "video_core/renderer_opengl/gl_query_cache.h"
|
||||||
|
|
||||||
|
namespace OpenGL {
|
||||||
|
|
||||||
|
HostCounter::HostCounter(GLenum target) {
|
||||||
|
query.Create(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
HostCounter::~HostCounter() = default;
|
||||||
|
|
||||||
|
void HostCounter::UpdateState(bool enabled) {
|
||||||
|
if (enabled) {
|
||||||
|
Enable();
|
||||||
|
} else {
|
||||||
|
Disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HostCounter::Reset() {
|
||||||
|
counter = 0;
|
||||||
|
Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 HostCounter::Query() {
|
||||||
|
if (!is_beginned) {
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
Disable();
|
||||||
|
u64 value;
|
||||||
|
glGetQueryObjectui64v(query.handle, GL_QUERY_RESULT, &value);
|
||||||
|
Enable();
|
||||||
|
|
||||||
|
counter += value;
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HostCounter::Enable() {
|
||||||
|
if (is_beginned) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
is_beginned = true;
|
||||||
|
glBeginQuery(GL_SAMPLES_PASSED, query.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HostCounter::Disable() {
|
||||||
|
if (!is_beginned) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glEndQuery(GL_SAMPLES_PASSED);
|
||||||
|
is_beginned = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace OpenGL
|
@ -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
|
Loading…
Reference in New Issue