summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-11-29 00:14:40 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-11-29 00:14:40 +0100
commit056f049b269f7f6397c9aa1e736b0d03d31f186d (patch)
tree4578ec167e1e21d5cade10193d182e1482bcaf37 /src/video_core
parentrenderer_opengl: Move commentaries to header file (diff)
downloadyuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.tar
yuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.tar.gz
yuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.tar.bz2
yuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.tar.lz
yuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.tar.xz
yuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.tar.zst
yuzu-056f049b269f7f6397c9aa1e736b0d03d31f186d.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp128
1 files changed, 66 insertions, 62 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 69fd735bd..82b426223 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -24,7 +24,9 @@
namespace OpenGL {
-static const char vertex_shader[] = R"(
+namespace {
+
+constexpr char vertex_shader[] = R"(
#version 150 core
in vec2 vert_position;
@@ -47,7 +49,7 @@ void main() {
}
)";
-static const char fragment_shader[] = R"(
+constexpr char fragment_shader[] = R"(
#version 150 core
in vec2 frag_tex_coord;
@@ -82,18 +84,77 @@ struct ScreenRectVertex {
* The projection part of the matrix is trivial, hence these operations are represented
* by a 3x2 matrix.
*/
-static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, const float height) {
+std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(float width, float height) {
std::array<GLfloat, 3 * 2> matrix; // Laid out in column-major order
// clang-format off
- matrix[0] = 2.f / width; matrix[2] = 0.f; matrix[4] = -1.f;
- matrix[1] = 0.f; matrix[3] = -2.f / height; matrix[5] = 1.f;
+ matrix[0] = 2.f / width; matrix[2] = 0.f; matrix[4] = -1.f;
+ matrix[1] = 0.f; matrix[3] = -2.f / height; matrix[5] = 1.f;
// Last matrix row is implicitly assumed to be [0, 0, 1].
// clang-format on
return matrix;
}
+const char* GetSource(GLenum source) {
+#define RET(s) \
+ case GL_DEBUG_SOURCE_##s: \
+ return #s
+ switch (source) {
+ RET(API);
+ RET(WINDOW_SYSTEM);
+ RET(SHADER_COMPILER);
+ RET(THIRD_PARTY);
+ RET(APPLICATION);
+ RET(OTHER);
+ default:
+ UNREACHABLE();
+ return "Unknown source";
+ }
+#undef RET
+}
+
+const char* GetType(GLenum type) {
+#define RET(t) \
+ case GL_DEBUG_TYPE_##t: \
+ return #t
+ switch (type) {
+ RET(ERROR);
+ RET(DEPRECATED_BEHAVIOR);
+ RET(UNDEFINED_BEHAVIOR);
+ RET(PORTABILITY);
+ RET(PERFORMANCE);
+ RET(OTHER);
+ RET(MARKER);
+ default:
+ UNREACHABLE();
+ return "Unknown type";
+ }
+#undef RET
+}
+
+void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
+ const GLchar* message, const void* user_param) {
+ const char format[] = "{} {} {}: {}";
+ const char* const str_source = GetSource(source);
+ const char* const str_type = GetType(type);
+
+ switch (severity) {
+ case GL_DEBUG_SEVERITY_HIGH:
+ LOG_CRITICAL(Render_OpenGL, format, str_source, str_type, id, message);
+ break;
+ case GL_DEBUG_SEVERITY_MEDIUM:
+ LOG_WARNING(Render_OpenGL, format, str_source, str_type, id, message);
+ break;
+ case GL_DEBUG_SEVERITY_NOTIFICATION:
+ case GL_DEBUG_SEVERITY_LOW:
+ LOG_DEBUG(Render_OpenGL, format, str_source, str_type, id, message);
+ break;
+ }
+}
+
+} // Anonymous namespace
+
RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::System& system)
: VideoCore::RendererBase{emu_window}, emu_window{emu_window}, system{system} {}
@@ -402,63 +463,6 @@ void RendererOpenGL::CaptureScreenshot() {
renderer_settings.screenshot_requested = false;
}
-static const char* GetSource(GLenum source) {
-#define RET(s) \
- case GL_DEBUG_SOURCE_##s: \
- return #s
- switch (source) {
- RET(API);
- RET(WINDOW_SYSTEM);
- RET(SHADER_COMPILER);
- RET(THIRD_PARTY);
- RET(APPLICATION);
- RET(OTHER);
- default:
- UNREACHABLE();
- return "Unknown source";
- }
-#undef RET
-}
-
-static const char* GetType(GLenum type) {
-#define RET(t) \
- case GL_DEBUG_TYPE_##t: \
- return #t
- switch (type) {
- RET(ERROR);
- RET(DEPRECATED_BEHAVIOR);
- RET(UNDEFINED_BEHAVIOR);
- RET(PORTABILITY);
- RET(PERFORMANCE);
- RET(OTHER);
- RET(MARKER);
- default:
- UNREACHABLE();
- return "Unknown type";
- }
-#undef RET
-}
-
-static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity,
- GLsizei length, const GLchar* message, const void* user_param) {
- const char format[] = "{} {} {}: {}";
- const char* const str_source = GetSource(source);
- const char* const str_type = GetType(type);
-
- switch (severity) {
- case GL_DEBUG_SEVERITY_HIGH:
- LOG_CRITICAL(Render_OpenGL, format, str_source, str_type, id, message);
- break;
- case GL_DEBUG_SEVERITY_MEDIUM:
- LOG_WARNING(Render_OpenGL, format, str_source, str_type, id, message);
- break;
- case GL_DEBUG_SEVERITY_NOTIFICATION:
- case GL_DEBUG_SEVERITY_LOW:
- LOG_DEBUG(Render_OpenGL, format, str_source, str_type, id, message);
- break;
- }
-}
-
bool RendererOpenGL::Init() {
Core::Frontend::ScopeAcquireWindowContext acquire_context{render_window};