Browse Source
maxwell_3d: Slow implementation of passed samples (query 21)
maxwell_3d: Slow implementation of passed samples (query 21)
Implements GL_SAMPLES_PASSED by waiting immediately for queries.nce_cpp
8 changed files with 201 additions and 17 deletions
-
2src/video_core/CMakeLists.txt
-
39src/video_core/engines/maxwell_3d.cpp
-
38src/video_core/engines/maxwell_3d.h
-
10src/video_core/rasterizer_interface.h
-
59src/video_core/renderer_opengl/gl_query_cache.cpp
-
41src/video_core/renderer_opengl/gl_query_cache.h
-
24src/video_core/renderer_opengl/gl_rasterizer.cpp
-
5src/video_core/renderer_opengl/gl_rasterizer.h
@ -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 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue