2014-04-09 01:04:25 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-04-09 01:04:25 +02:00
|
|
|
// Refer to the license.txt file included.
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2015-06-21 18:47:21 +02:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdlib>
|
2020-03-16 07:59:08 +01:00
|
|
|
#include <cstring>
|
2016-04-30 17:34:51 +02:00
|
|
|
#include <memory>
|
2020-03-25 05:57:36 +01:00
|
|
|
|
2016-04-30 17:34:51 +02:00
|
|
|
#include <glad/glad.h>
|
2020-03-25 05:57:36 +01:00
|
|
|
|
2015-06-21 18:47:21 +02:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/log.h"
|
2020-02-17 20:31:14 +01:00
|
|
|
#include "common/microprofile.h"
|
2018-08-31 18:21:34 +02:00
|
|
|
#include "common/telemetry.h"
|
2017-02-19 23:34:47 +01:00
|
|
|
#include "core/core.h"
|
2017-02-21 01:31:59 +01:00
|
|
|
#include "core/core_timing.h"
|
2016-12-23 14:37:40 +01:00
|
|
|
#include "core/frontend/emu_window.h"
|
2016-04-30 17:34:51 +02:00
|
|
|
#include "core/memory.h"
|
2018-08-30 16:50:54 +02:00
|
|
|
#include "core/perf_stats.h"
|
2016-04-30 17:34:51 +02:00
|
|
|
#include "core/settings.h"
|
2018-08-31 18:21:34 +02:00
|
|
|
#include "core/telemetry_session.h"
|
2018-11-25 03:53:17 +01:00
|
|
|
#include "video_core/morton.h"
|
2018-08-21 01:22:43 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
2019-12-26 20:04:41 +01:00
|
|
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
2016-09-21 08:52:38 +02:00
|
|
|
#include "video_core/renderer_opengl/renderer_opengl.h"
|
2015-04-04 12:57:31 +02:00
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
namespace OpenGL {
|
|
|
|
|
2020-03-16 08:03:16 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr std::size_t SWAP_CHAIN_SIZE = 3;
|
|
|
|
|
|
|
|
struct Frame {
|
|
|
|
u32 width{}; /// Width of the frame (to detect resize)
|
|
|
|
u32 height{}; /// Height of the frame
|
|
|
|
bool color_reloaded{}; /// Texture attachment was recreated (ie: resized)
|
|
|
|
OpenGL::OGLRenderbuffer color{}; /// Buffer shared between the render/present FBO
|
|
|
|
OpenGL::OGLFramebuffer render{}; /// FBO created on the render thread
|
|
|
|
OpenGL::OGLFramebuffer present{}; /// FBO created on the present thread
|
|
|
|
GLsync render_fence{}; /// Fence created on the render thread
|
|
|
|
GLsync present_fence{}; /// Fence created on the presentation thread
|
|
|
|
bool is_srgb{}; /// Framebuffer is sRGB or RGB
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char VERTEX_SHADER[] = R"(
|
|
|
|
#version 430 core
|
|
|
|
|
|
|
|
out gl_PerVertex {
|
|
|
|
vec4 gl_Position;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout (location = 0) in vec2 vert_position;
|
|
|
|
layout (location = 1) in vec2 vert_tex_coord;
|
|
|
|
layout (location = 0) out vec2 frag_tex_coord;
|
|
|
|
|
|
|
|
// This is a truncated 3x3 matrix for 2D transformations:
|
|
|
|
// The upper-left 2x2 submatrix performs scaling/rotation/mirroring.
|
|
|
|
// The third column performs translation.
|
|
|
|
// The third row could be used for projection, which we don't need in 2D. It hence is assumed to
|
|
|
|
// implicitly be [0, 0, 1]
|
|
|
|
layout (location = 0) uniform mat3x2 modelview_matrix;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
// Multiply input position by the rotscale part of the matrix and then manually translate by
|
|
|
|
// the last column. This is equivalent to using a full 3x3 matrix and expanding the vector
|
|
|
|
// to `vec3(vert_position.xy, 1.0)`
|
|
|
|
gl_Position = vec4(mat2(modelview_matrix) * vert_position + modelview_matrix[2], 0.0, 1.0);
|
|
|
|
frag_tex_coord = vert_tex_coord;
|
|
|
|
}
|
|
|
|
)";
|
|
|
|
|
|
|
|
constexpr char FRAGMENT_SHADER[] = R"(
|
|
|
|
#version 430 core
|
|
|
|
|
|
|
|
layout (location = 0) in vec2 frag_tex_coord;
|
|
|
|
layout (location = 0) out vec4 color;
|
|
|
|
|
|
|
|
layout (binding = 0) uniform sampler2D color_texture;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
color = vec4(texture(color_texture, frag_tex_coord).rgb, 1.0f);
|
|
|
|
}
|
|
|
|
)";
|
|
|
|
|
|
|
|
constexpr GLint PositionLocation = 0;
|
|
|
|
constexpr GLint TexCoordLocation = 1;
|
|
|
|
constexpr GLint ModelViewMatrixLocation = 0;
|
|
|
|
|
|
|
|
struct ScreenRectVertex {
|
|
|
|
constexpr ScreenRectVertex(u32 x, u32 y, GLfloat u, GLfloat v)
|
|
|
|
: position{{static_cast<GLfloat>(x), static_cast<GLfloat>(y)}}, tex_coord{{u, v}} {}
|
|
|
|
|
|
|
|
std::array<GLfloat, 2> position;
|
|
|
|
std::array<GLfloat, 2> tex_coord;
|
|
|
|
};
|
|
|
|
|
2020-03-16 07:59:08 +01:00
|
|
|
/// Returns true if any debug tool is attached
|
|
|
|
bool HasDebugTool() {
|
|
|
|
const bool nsight = std::getenv("NVTX_INJECTION64_PATH") || std::getenv("NSIGHT_LAUNCHED");
|
|
|
|
if (nsight) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLint num_extensions;
|
|
|
|
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
|
|
|
for (GLuint index = 0; index < static_cast<GLuint>(num_extensions); ++index) {
|
|
|
|
const auto name = reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, index));
|
|
|
|
if (!std::strcmp(name, "GL_EXT_debug_tool")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-16 08:03:16 +01:00
|
|
|
/**
|
|
|
|
* Defines a 1:1 pixel ortographic projection matrix with (0,0) on the top-left
|
|
|
|
* corner and (width, height) on the lower-bottom.
|
|
|
|
*
|
|
|
|
* The projection part of the matrix is trivial, hence these operations are represented
|
|
|
|
* by a 3x2 matrix.
|
|
|
|
*/
|
|
|
|
std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(float width, float height) {
|
|
|
|
std::array<GLfloat, 3 * 2> matrix; // Laid out in column-major order
|
2020-02-17 20:31:14 +01:00
|
|
|
|
2020-03-16 08:03:16 +01:00
|
|
|
// 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;
|
|
|
|
// Last matrix row is implicitly assumed to be [0, 0, 1].
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
return matrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* GetSource(GLenum source) {
|
|
|
|
switch (source) {
|
|
|
|
case GL_DEBUG_SOURCE_API:
|
|
|
|
return "API";
|
|
|
|
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
|
|
|
|
return "WINDOW_SYSTEM";
|
|
|
|
case GL_DEBUG_SOURCE_SHADER_COMPILER:
|
|
|
|
return "SHADER_COMPILER";
|
|
|
|
case GL_DEBUG_SOURCE_THIRD_PARTY:
|
|
|
|
return "THIRD_PARTY";
|
|
|
|
case GL_DEBUG_SOURCE_APPLICATION:
|
|
|
|
return "APPLICATION";
|
|
|
|
case GL_DEBUG_SOURCE_OTHER:
|
|
|
|
return "OTHER";
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return "Unknown source";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* GetType(GLenum type) {
|
|
|
|
switch (type) {
|
|
|
|
case GL_DEBUG_TYPE_ERROR:
|
|
|
|
return "ERROR";
|
|
|
|
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
|
|
|
return "DEPRECATED_BEHAVIOR";
|
|
|
|
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
|
|
|
return "UNDEFINED_BEHAVIOR";
|
|
|
|
case GL_DEBUG_TYPE_PORTABILITY:
|
|
|
|
return "PORTABILITY";
|
|
|
|
case GL_DEBUG_TYPE_PERFORMANCE:
|
|
|
|
return "PERFORMANCE";
|
|
|
|
case GL_DEBUG_TYPE_OTHER:
|
|
|
|
return "OTHER";
|
|
|
|
case GL_DEBUG_TYPE_MARKER:
|
|
|
|
return "MARKER";
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return "Unknown type";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2020-02-17 20:31:14 +01:00
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
/**
|
|
|
|
* For smooth Vsync rendering, we want to always present the latest frame that the core generates,
|
|
|
|
* but also make sure that rendering happens at the pace that the frontend dictates. This is a
|
|
|
|
* helper class that the renderer uses to sync frames between the render thread and the presentation
|
|
|
|
* thread
|
|
|
|
*/
|
|
|
|
class FrameMailbox {
|
2020-02-17 20:31:14 +01:00
|
|
|
public:
|
|
|
|
std::mutex swap_chain_lock;
|
|
|
|
std::condition_variable present_cv;
|
2020-02-27 00:28:50 +01:00
|
|
|
std::array<Frame, SWAP_CHAIN_SIZE> swap_chain{};
|
|
|
|
std::queue<Frame*> free_queue;
|
|
|
|
std::deque<Frame*> present_queue;
|
|
|
|
Frame* previous_frame{};
|
2020-02-17 20:31:14 +01:00
|
|
|
|
2020-03-25 03:58:49 +01:00
|
|
|
FrameMailbox() {
|
2020-02-17 20:31:14 +01:00
|
|
|
for (auto& frame : swap_chain) {
|
|
|
|
free_queue.push(&frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
~FrameMailbox() {
|
2020-02-17 20:31:14 +01:00
|
|
|
// lock the mutex and clear out the present and free_queues and notify any people who are
|
|
|
|
// blocked to prevent deadlock on shutdown
|
2020-02-27 00:35:35 +01:00
|
|
|
std::scoped_lock lock{swap_chain_lock};
|
2020-02-27 00:28:50 +01:00
|
|
|
std::queue<Frame*>().swap(free_queue);
|
2020-02-17 20:31:14 +01:00
|
|
|
present_queue.clear();
|
|
|
|
present_cv.notify_all();
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
void ReloadPresentFrame(Frame* frame, u32 height, u32 width) {
|
2020-02-17 20:31:14 +01:00
|
|
|
frame->present.Release();
|
|
|
|
frame->present.Create();
|
|
|
|
GLint previous_draw_fbo{};
|
|
|
|
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previous_draw_fbo);
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, frame->present.handle);
|
|
|
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
|
|
|
|
frame->color.handle);
|
|
|
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
|
|
|
LOG_CRITICAL(Render_OpenGL, "Failed to recreate present FBO!");
|
|
|
|
}
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, previous_draw_fbo);
|
|
|
|
frame->color_reloaded = false;
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
void ReloadRenderFrame(Frame* frame, u32 width, u32 height) {
|
2020-02-17 20:31:14 +01:00
|
|
|
// Recreate the color texture attachment
|
|
|
|
frame->color.Release();
|
|
|
|
frame->color.Create();
|
2019-12-26 09:01:43 +01:00
|
|
|
const GLenum internal_format = frame->is_srgb ? GL_SRGB8 : GL_RGB8;
|
|
|
|
glNamedRenderbufferStorage(frame->color.handle, internal_format, width, height);
|
2020-02-17 20:31:14 +01:00
|
|
|
|
|
|
|
// Recreate the FBO for the render target
|
|
|
|
frame->render.Release();
|
|
|
|
frame->render.Create();
|
2019-12-26 09:01:43 +01:00
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, frame->render.handle);
|
2020-02-17 20:31:14 +01:00
|
|
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
|
|
|
|
frame->color.handle);
|
2020-02-27 00:28:50 +01:00
|
|
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
2020-02-17 20:31:14 +01:00
|
|
|
LOG_CRITICAL(Render_OpenGL, "Failed to recreate render FBO!");
|
|
|
|
}
|
2019-12-26 09:01:43 +01:00
|
|
|
|
2020-02-17 20:31:14 +01:00
|
|
|
frame->width = width;
|
|
|
|
frame->height = height;
|
|
|
|
frame->color_reloaded = true;
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
Frame* GetRenderFrame() {
|
2020-02-27 00:35:35 +01:00
|
|
|
std::unique_lock lock{swap_chain_lock};
|
2020-02-17 20:31:14 +01:00
|
|
|
|
|
|
|
// If theres no free frames, we will reuse the oldest render frame
|
|
|
|
if (free_queue.empty()) {
|
|
|
|
auto frame = present_queue.back();
|
|
|
|
present_queue.pop_back();
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
Frame* frame = free_queue.front();
|
2020-02-17 20:31:14 +01:00
|
|
|
free_queue.pop();
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
void ReleaseRenderFrame(Frame* frame) {
|
2020-02-27 00:35:35 +01:00
|
|
|
std::unique_lock lock{swap_chain_lock};
|
2020-02-17 20:31:14 +01:00
|
|
|
present_queue.push_front(frame);
|
|
|
|
present_cv.notify_one();
|
|
|
|
}
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
Frame* TryGetPresentFrame(int timeout_ms) {
|
2020-02-27 00:35:35 +01:00
|
|
|
std::unique_lock lock{swap_chain_lock};
|
2020-02-17 20:31:14 +01:00
|
|
|
// wait for new entries in the present_queue
|
|
|
|
present_cv.wait_for(lock, std::chrono::milliseconds(timeout_ms),
|
|
|
|
[&] { return !present_queue.empty(); });
|
|
|
|
if (present_queue.empty()) {
|
|
|
|
// timed out waiting for a frame to draw so return the previous frame
|
|
|
|
return previous_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// free the previous frame and add it back to the free queue
|
|
|
|
if (previous_frame) {
|
|
|
|
free_queue.push(previous_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// the newest entries are pushed to the front of the queue
|
2020-02-27 00:28:50 +01:00
|
|
|
Frame* frame = present_queue.front();
|
2020-02-17 20:31:14 +01:00
|
|
|
present_queue.pop_front();
|
|
|
|
// remove all old entries from the present queue and move them back to the free_queue
|
|
|
|
for (auto f : present_queue) {
|
|
|
|
free_queue.push(f);
|
|
|
|
}
|
|
|
|
present_queue.clear();
|
|
|
|
previous_frame = frame;
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-03-25 03:58:49 +01:00
|
|
|
RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::System& system,
|
|
|
|
Core::Frontend::GraphicsContext& context)
|
2020-04-15 19:28:28 +02:00
|
|
|
: RendererBase{emu_window}, emu_window{emu_window}, system{system}, context{context},
|
2020-05-18 03:32:49 +02:00
|
|
|
program_manager{device}, has_debug_tool{HasDebugTool()} {}
|
2018-08-12 02:20:19 +02:00
|
|
|
|
2017-05-28 03:02:46 +02:00
|
|
|
RendererOpenGL::~RendererOpenGL() = default;
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2020-02-17 20:31:14 +01:00
|
|
|
MICROPROFILE_DEFINE(OpenGL_RenderFrame, "OpenGL", "Render Frame", MP_RGB(128, 128, 64));
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_WaitPresent, "OpenGL", "Wait For Present", MP_RGB(128, 128, 128));
|
|
|
|
|
2019-08-21 06:55:25 +02:00
|
|
|
void RendererOpenGL::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
2020-02-17 20:31:14 +01:00
|
|
|
if (!framebuffer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrepareRendertarget(framebuffer);
|
|
|
|
RenderScreenshot();
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
Frame* frame;
|
2020-02-17 20:31:14 +01:00
|
|
|
{
|
|
|
|
MICROPROFILE_SCOPE(OpenGL_WaitPresent);
|
|
|
|
|
2020-02-27 00:28:50 +01:00
|
|
|
frame = frame_mailbox->GetRenderFrame();
|
2020-02-17 20:31:14 +01:00
|
|
|
|
|
|
|
// Clean up sync objects before drawing
|
|
|
|
|
|
|
|
// INTEL driver workaround. We can't delete the previous render sync object until we are
|
|
|
|
// sure that the presentation is done
|
|
|
|
if (frame->present_fence) {
|
|
|
|
glClientWaitSync(frame->present_fence, 0, GL_TIMEOUT_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete the draw fence if the frame wasn't presented
|
|
|
|
if (frame->render_fence) {
|
|
|
|
glDeleteSync(frame->render_fence);
|
|
|
|
frame->render_fence = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// wait for the presentation to be done
|
|
|
|
if (frame->present_fence) {
|
|
|
|
glWaitSync(frame->present_fence, 0, GL_TIMEOUT_IGNORED);
|
|
|
|
glDeleteSync(frame->present_fence);
|
|
|
|
frame->present_fence = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
MICROPROFILE_SCOPE(OpenGL_RenderFrame);
|
|
|
|
const auto& layout = render_window.GetFramebufferLayout();
|
|
|
|
|
|
|
|
// Recreate the frame if the size of the window has changed
|
|
|
|
if (layout.width != frame->width || layout.height != frame->height ||
|
2020-02-28 07:10:41 +01:00
|
|
|
screen_info.display_srgb != frame->is_srgb) {
|
2020-02-17 20:31:14 +01:00
|
|
|
LOG_DEBUG(Render_OpenGL, "Reloading render frame");
|
2020-02-28 07:10:41 +01:00
|
|
|
frame->is_srgb = screen_info.display_srgb;
|
2020-02-27 00:28:50 +01:00
|
|
|
frame_mailbox->ReloadRenderFrame(frame, layout.width, layout.height);
|
2020-02-17 20:31:14 +01:00
|
|
|
}
|
2019-12-26 09:01:43 +01:00
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frame->render.handle);
|
2020-02-17 20:31:14 +01:00
|
|
|
DrawScreen(layout);
|
|
|
|
// Create a fence for the frontend to wait on and swap this frame to OffTex
|
|
|
|
frame->render_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
|
|
glFlush();
|
2020-02-27 00:28:50 +01:00
|
|
|
frame_mailbox->ReleaseRenderFrame(frame);
|
2020-02-17 20:31:14 +01:00
|
|
|
m_current_frame++;
|
|
|
|
rasterizer->TickFrame();
|
|
|
|
}
|
2020-03-25 03:58:49 +01:00
|
|
|
|
|
|
|
render_window.PollEvents();
|
|
|
|
if (has_debug_tool) {
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
|
|
|
Present(0);
|
|
|
|
context.SwapBuffers();
|
|
|
|
}
|
2020-02-17 20:31:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RendererOpenGL::PrepareRendertarget(const Tegra::FramebufferConfig* framebuffer) {
|
2018-10-30 05:03:25 +01:00
|
|
|
if (framebuffer) {
|
2018-03-23 02:04:30 +01:00
|
|
|
// If framebuffer is provided, reload it from memory to a texture
|
2019-08-21 06:55:25 +02:00
|
|
|
if (screen_info.texture.width != static_cast<GLsizei>(framebuffer->width) ||
|
|
|
|
screen_info.texture.height != static_cast<GLsizei>(framebuffer->height) ||
|
2020-02-21 03:07:17 +01:00
|
|
|
screen_info.texture.pixel_format != framebuffer->pixel_format ||
|
|
|
|
gl_framebuffer_data.empty()) {
|
2018-01-15 05:51:54 +01:00
|
|
|
// Reallocate texture if the framebuffer size has changed.
|
|
|
|
// This is expected to not happen very often and hence should not be a
|
|
|
|
// performance problem.
|
2018-03-23 02:04:30 +01:00
|
|
|
ConfigureFramebufferTexture(screen_info.texture, *framebuffer);
|
2018-01-15 05:51:54 +01:00
|
|
|
}
|
2018-03-27 02:04:35 +02:00
|
|
|
|
|
|
|
// Load the framebuffer from memory, draw it to the screen, and swap buffers
|
2018-08-21 01:34:02 +02:00
|
|
|
LoadFBToScreenInfo(*framebuffer);
|
2014-08-28 20:21:54 +02:00
|
|
|
}
|
2014-04-09 00:59:02 +02:00
|
|
|
}
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2018-08-21 01:34:02 +02:00
|
|
|
void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer) {
|
2018-03-23 19:58:27 +01:00
|
|
|
// Framebuffer orientation handling
|
|
|
|
framebuffer_transform_flags = framebuffer.transform_flags;
|
2018-07-18 02:11:41 +02:00
|
|
|
framebuffer_crop_rect = framebuffer.crop_rect;
|
2018-03-23 19:58:27 +01:00
|
|
|
|
2019-08-21 07:17:14 +02:00
|
|
|
const VAddr framebuffer_addr{framebuffer.address + framebuffer.offset};
|
|
|
|
if (rasterizer->AccelerateDisplay(framebuffer, framebuffer_addr, framebuffer.stride)) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-17 00:57:57 +02:00
|
|
|
|
2019-08-21 07:17:14 +02:00
|
|
|
// Reset the screen info's display texture to its own permanent texture
|
|
|
|
screen_info.display_texture = screen_info.texture.resource.handle;
|
2016-04-17 00:57:57 +02:00
|
|
|
|
2019-08-21 07:17:14 +02:00
|
|
|
const auto pixel_format{
|
|
|
|
VideoCore::Surface::PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)};
|
|
|
|
const u32 bytes_per_pixel{VideoCore::Surface::GetBytesPerPixel(pixel_format)};
|
|
|
|
const u64 size_in_bytes{framebuffer.stride * framebuffer.height * bytes_per_pixel};
|
2019-11-26 21:19:15 +01:00
|
|
|
u8* const host_ptr{system.Memory().GetPointer(framebuffer_addr)};
|
2019-08-21 07:17:14 +02:00
|
|
|
rasterizer->FlushRegion(ToCacheAddr(host_ptr), size_in_bytes);
|
|
|
|
|
|
|
|
// TODO(Rodrigo): Read this from HLE
|
|
|
|
constexpr u32 block_height_log2 = 4;
|
|
|
|
VideoCore::MortonSwizzle(VideoCore::MortonSwizzleMode::MortonToLinear, pixel_format,
|
|
|
|
framebuffer.stride, block_height_log2, framebuffer.height, 0, 1, 1,
|
|
|
|
gl_framebuffer_data.data(), host_ptr);
|
|
|
|
|
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(framebuffer.stride));
|
|
|
|
|
|
|
|
// Update existing texture
|
|
|
|
// TODO: Test what happens on hardware when you change the framebuffer dimensions so that
|
|
|
|
// they differ from the LCD resolution.
|
|
|
|
// TODO: Applications could theoretically crash yuzu here by specifying too large
|
|
|
|
// framebuffer sizes. We should make sure that this cannot happen.
|
|
|
|
glTextureSubImage2D(screen_info.texture.resource.handle, 0, 0, 0, framebuffer.width,
|
|
|
|
framebuffer.height, screen_info.texture.gl_format,
|
|
|
|
screen_info.texture.gl_type, gl_framebuffer_data.data());
|
|
|
|
|
|
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
2014-10-13 07:40:26 +02:00
|
|
|
}
|
2014-04-07 06:52:34 +02:00
|
|
|
|
2018-01-15 06:20:19 +01:00
|
|
|
void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, u8 color_a,
|
2014-10-13 07:40:26 +02:00
|
|
|
const TextureInfo& texture) {
|
2019-01-06 22:49:23 +01:00
|
|
|
const u8 framebuffer_data[4] = {color_a, color_b, color_g, color_r};
|
|
|
|
glClearTexImage(texture.resource.handle, 0, GL_RGBA, GL_UNSIGNED_BYTE, framebuffer_data);
|
2014-08-21 09:27:53 +02:00
|
|
|
}
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2014-08-28 11:34:47 +02:00
|
|
|
void RendererOpenGL::InitOpenGLObjects() {
|
2020-03-25 03:58:49 +01:00
|
|
|
frame_mailbox = std::make_unique<FrameMailbox>();
|
|
|
|
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-10 04:42:09 +02:00
|
|
|
glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
|
|
|
|
Settings::values.bg_blue.GetValue(), 0.0f);
|
2014-08-28 11:34:47 +02:00
|
|
|
|
2019-12-26 20:04:41 +01:00
|
|
|
// Create shader programs
|
|
|
|
OGLShader vertex_shader;
|
|
|
|
vertex_shader.Create(VERTEX_SHADER, GL_VERTEX_SHADER);
|
|
|
|
|
|
|
|
OGLShader fragment_shader;
|
|
|
|
fragment_shader.Create(FRAGMENT_SHADER, GL_FRAGMENT_SHADER);
|
|
|
|
|
|
|
|
vertex_program.Create(true, false, vertex_shader.handle);
|
|
|
|
fragment_program.Create(true, false, fragment_shader.handle);
|
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
pipeline.Create();
|
|
|
|
glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, vertex_program.handle);
|
|
|
|
glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, fragment_program.handle);
|
2014-08-28 20:21:54 +02:00
|
|
|
|
|
|
|
// Generate VBO handle for drawing
|
2016-04-17 00:57:57 +02:00
|
|
|
vertex_buffer.Create();
|
2014-08-28 20:21:54 +02:00
|
|
|
|
|
|
|
// Attach vertex data to VAO
|
2019-01-06 05:53:27 +01:00
|
|
|
glNamedBufferData(vertex_buffer.handle, sizeof(ScreenRectVertex) * 4, nullptr, GL_STREAM_DRAW);
|
2014-04-07 06:52:34 +02:00
|
|
|
|
2018-01-11 04:43:17 +01:00
|
|
|
// Allocate textures for the screen
|
2019-01-06 22:49:23 +01:00
|
|
|
screen_info.texture.resource.Create(GL_TEXTURE_2D);
|
2014-04-07 06:52:34 +02:00
|
|
|
|
2019-01-06 22:49:23 +01:00
|
|
|
const GLuint texture = screen_info.texture.resource.handle;
|
|
|
|
glTextureStorage2D(texture, 1, GL_RGBA8, 1, 1);
|
2016-04-17 00:57:57 +02:00
|
|
|
|
2018-01-11 04:43:17 +01:00
|
|
|
screen_info.display_texture = screen_info.texture.resource.handle;
|
2015-05-19 06:21:33 +02:00
|
|
|
|
2018-01-15 06:20:19 +01:00
|
|
|
// Clear screen to black
|
|
|
|
LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture);
|
gl_rasterizer: Use NV_vertex_buffer_unified_memory for vertex buffer robustness
Switch games are allowed to bind less data than what they use in a
vertex buffer, the expected behavior here is that these values are read
as zero. At the moment of writing this only D3D12, OpenGL and NVN through
NV_vertex_buffer_unified_memory support vertex buffer with a size limit.
In theory this could be emulated on Vulkan creating a new VkBuffer for
each (handle, offset, length) tuple and binding the expected data to it.
This is likely going to be slow and memory expensive when used on the
vertex buffer and we have to do it on all draws because we can't know
without analyzing indices when a game is going to read vertex data out
of bounds.
This is not a problem on OpenGL's BufferAddressRangeNV because it takes
a length parameter, unlike Vulkan's CmdBindVertexBuffers that only takes
buffers and offsets (the length is implicit in VkBuffer). It isn't a
problem on D3D12 either, because D3D12_VERTEX_BUFFER_VIEW on
IASetVertexBuffers takes SizeInBytes as a parameter (although I am not
familiar with robustness on D3D12).
Currently this only implements buffer ranges for vertex buffers,
although indices can also be affected. A KHR_robustness profile is not
created, but Nvidia's driver reads out of bound vertex data as zero
anyway, this might have to be changed in the future.
- Fixes SMO random triangles when capturing an enemy, getting hit, or
looking at the environment on certain maps.
2020-06-18 08:56:31 +02:00
|
|
|
|
|
|
|
// Enable unified vertex attributes and query vertex buffer address when the driver supports it
|
|
|
|
if (device.HasVertexBufferUnifiedMemory()) {
|
|
|
|
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
|
|
|
|
|
|
|
|
glMakeNamedBufferResidentNV(vertex_buffer.handle, GL_READ_ONLY);
|
|
|
|
glGetNamedBufferParameterui64vNV(vertex_buffer.handle, GL_BUFFER_GPU_ADDRESS_NV,
|
|
|
|
&vertex_buffer_address);
|
|
|
|
}
|
2014-04-06 22:55:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-02 21:08:11 +01:00
|
|
|
void RendererOpenGL::AddTelemetryFields() {
|
|
|
|
const char* const gl_version{reinterpret_cast<char const*>(glGetString(GL_VERSION))};
|
|
|
|
const char* const gpu_vendor{reinterpret_cast<char const*>(glGetString(GL_VENDOR))};
|
|
|
|
const char* const gpu_model{reinterpret_cast<char const*>(glGetString(GL_RENDERER))};
|
|
|
|
|
|
|
|
LOG_INFO(Render_OpenGL, "GL_VERSION: {}", gl_version);
|
|
|
|
LOG_INFO(Render_OpenGL, "GL_VENDOR: {}", gpu_vendor);
|
|
|
|
LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model);
|
|
|
|
|
|
|
|
auto& telemetry_session = system.TelemetrySession();
|
2020-08-18 20:21:50 +02:00
|
|
|
constexpr auto user_system = Common::Telemetry::FieldType::UserSystem;
|
|
|
|
telemetry_session.AddField(user_system, "GPU_Vendor", gpu_vendor);
|
|
|
|
telemetry_session.AddField(user_system, "GPU_Model", gpu_model);
|
|
|
|
telemetry_session.AddField(user_system, "GPU_OpenGL_Version", gl_version);
|
2019-03-02 21:08:11 +01:00
|
|
|
}
|
|
|
|
|
2018-08-21 01:22:43 +02:00
|
|
|
void RendererOpenGL::CreateRasterizer() {
|
|
|
|
if (rasterizer) {
|
|
|
|
return;
|
|
|
|
}
|
2020-05-18 03:32:49 +02:00
|
|
|
rasterizer = std::make_unique<RasterizerOpenGL>(system, emu_window, device, screen_info,
|
2019-12-29 01:45:56 +01:00
|
|
|
program_manager, state_tracker);
|
2018-08-21 01:22:43 +02:00
|
|
|
}
|
|
|
|
|
2015-02-05 15:15:42 +01:00
|
|
|
void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
|
2018-03-23 02:04:30 +01:00
|
|
|
const Tegra::FramebufferConfig& framebuffer) {
|
|
|
|
texture.width = framebuffer.width;
|
|
|
|
texture.height = framebuffer.height;
|
2019-02-26 07:47:16 +01:00
|
|
|
texture.pixel_format = framebuffer.pixel_format;
|
2015-02-05 15:15:42 +01:00
|
|
|
|
2019-08-21 07:07:56 +02:00
|
|
|
const auto pixel_format{
|
|
|
|
VideoCore::Surface::PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)};
|
|
|
|
const u32 bytes_per_pixel{VideoCore::Surface::GetBytesPerPixel(pixel_format)};
|
|
|
|
gl_framebuffer_data.resize(texture.width * texture.height * bytes_per_pixel);
|
|
|
|
|
2018-01-11 04:43:17 +01:00
|
|
|
GLint internal_format;
|
2018-03-23 02:04:30 +01:00
|
|
|
switch (framebuffer.pixel_format) {
|
2020-07-01 07:28:53 +02:00
|
|
|
case Tegra::FramebufferConfig::PixelFormat::A8B8G8R8_UNORM:
|
2019-01-06 22:49:23 +01:00
|
|
|
internal_format = GL_RGBA8;
|
2015-02-05 15:15:42 +01:00
|
|
|
texture.gl_format = GL_RGBA;
|
2018-04-25 01:44:09 +02:00
|
|
|
texture.gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
2019-08-21 07:22:54 +02:00
|
|
|
break;
|
2020-07-01 07:28:53 +02:00
|
|
|
case Tegra::FramebufferConfig::PixelFormat::RGB565_UNORM:
|
2019-08-21 07:22:54 +02:00
|
|
|
internal_format = GL_RGB565;
|
|
|
|
texture.gl_format = GL_RGB;
|
|
|
|
texture.gl_type = GL_UNSIGNED_SHORT_5_6_5;
|
2015-02-05 15:15:42 +01:00
|
|
|
break;
|
|
|
|
default:
|
2019-01-06 22:49:23 +01:00
|
|
|
internal_format = GL_RGBA8;
|
2018-11-21 02:27:34 +01:00
|
|
|
texture.gl_format = GL_RGBA;
|
|
|
|
texture.gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
2019-08-21 07:07:56 +02:00
|
|
|
UNIMPLEMENTED_MSG("Unknown framebuffer pixel format: {}",
|
|
|
|
static_cast<u32>(framebuffer.pixel_format));
|
2015-02-05 15:15:42 +01:00
|
|
|
}
|
|
|
|
|
2019-01-06 22:49:23 +01:00
|
|
|
texture.resource.Release();
|
|
|
|
texture.resource.Create(GL_TEXTURE_2D);
|
|
|
|
glTextureStorage2D(texture.resource.handle, 1, internal_format, texture.width, texture.height);
|
2015-02-05 15:15:42 +01:00
|
|
|
}
|
|
|
|
|
2019-12-26 05:50:38 +01:00
|
|
|
void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
|
|
|
|
if (renderer_settings.set_background_color) {
|
|
|
|
// Update background color before drawing
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-10 04:42:09 +02:00
|
|
|
glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
|
|
|
|
Settings::values.bg_blue.GetValue(), 0.0f);
|
2019-12-26 05:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set projection matrix
|
|
|
|
const std::array ortho_matrix =
|
|
|
|
MakeOrthographicMatrix(static_cast<float>(layout.width), static_cast<float>(layout.height));
|
2019-12-26 20:04:41 +01:00
|
|
|
glProgramUniformMatrix3x2fv(vertex_program.handle, ModelViewMatrixLocation, 1, GL_FALSE,
|
|
|
|
std::data(ortho_matrix));
|
2019-12-26 05:50:38 +01:00
|
|
|
|
2018-02-12 01:04:27 +01:00
|
|
|
const auto& texcoords = screen_info.display_texcoords;
|
2018-03-23 19:58:27 +01:00
|
|
|
auto left = texcoords.left;
|
|
|
|
auto right = texcoords.right;
|
2018-04-24 17:12:11 +02:00
|
|
|
if (framebuffer_transform_flags != Tegra::FramebufferConfig::TransformFlags::Unset) {
|
2018-03-23 19:58:27 +01:00
|
|
|
if (framebuffer_transform_flags == Tegra::FramebufferConfig::TransformFlags::FlipV) {
|
|
|
|
// Flip the framebuffer vertically
|
|
|
|
left = texcoords.right;
|
|
|
|
right = texcoords.left;
|
|
|
|
} else {
|
|
|
|
// Other transformations are unsupported
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_CRITICAL(Render_OpenGL, "Unsupported framebuffer_transform_flags={}",
|
2018-07-02 18:20:50 +02:00
|
|
|
static_cast<u32>(framebuffer_transform_flags));
|
2018-03-23 19:58:27 +01:00
|
|
|
UNIMPLEMENTED();
|
|
|
|
}
|
2018-04-24 17:12:11 +02:00
|
|
|
}
|
2016-04-17 00:57:57 +02:00
|
|
|
|
2018-07-18 02:11:41 +02:00
|
|
|
ASSERT_MSG(framebuffer_crop_rect.top == 0, "Unimplemented");
|
|
|
|
ASSERT_MSG(framebuffer_crop_rect.left == 0, "Unimplemented");
|
|
|
|
|
|
|
|
// Scale the output by the crop width/height. This is commonly used with 1280x720 rendering
|
|
|
|
// (e.g. handheld mode) on a 1920x1080 framebuffer.
|
|
|
|
f32 scale_u = 1.f, scale_v = 1.f;
|
|
|
|
if (framebuffer_crop_rect.GetWidth() > 0) {
|
2019-11-08 21:08:07 +01:00
|
|
|
scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) /
|
|
|
|
static_cast<f32>(screen_info.texture.width);
|
2018-07-18 02:11:41 +02:00
|
|
|
}
|
|
|
|
if (framebuffer_crop_rect.GetHeight() > 0) {
|
2019-11-08 21:08:07 +01:00
|
|
|
scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) /
|
|
|
|
static_cast<f32>(screen_info.texture.height);
|
2018-07-18 02:11:41 +02:00
|
|
|
}
|
|
|
|
|
2019-12-26 05:50:38 +01:00
|
|
|
const auto& screen = layout.screen;
|
2019-11-29 00:36:02 +01:00
|
|
|
const std::array vertices = {
|
2019-12-26 05:50:38 +01:00
|
|
|
ScreenRectVertex(screen.left, screen.top, texcoords.top * scale_u, left * scale_v),
|
|
|
|
ScreenRectVertex(screen.right, screen.top, texcoords.bottom * scale_u, left * scale_v),
|
|
|
|
ScreenRectVertex(screen.left, screen.bottom, texcoords.top * scale_u, right * scale_v),
|
|
|
|
ScreenRectVertex(screen.right, screen.bottom, texcoords.bottom * scale_u, right * scale_v),
|
2019-11-29 00:36:02 +01:00
|
|
|
};
|
2019-12-26 05:50:38 +01:00
|
|
|
glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices));
|
2014-08-28 20:21:54 +02:00
|
|
|
|
2019-12-25 23:46:04 +01:00
|
|
|
// TODO: Signal state tracker about these changes
|
2019-12-29 03:08:40 +01:00
|
|
|
state_tracker.NotifyScreenDrawVertexArray();
|
2020-02-24 23:43:57 +01:00
|
|
|
state_tracker.NotifyPolygonModes();
|
2019-12-29 02:12:12 +01:00
|
|
|
state_tracker.NotifyViewport0();
|
2019-12-29 02:31:00 +01:00
|
|
|
state_tracker.NotifyScissor0();
|
2019-12-29 02:51:04 +01:00
|
|
|
state_tracker.NotifyColorMask0();
|
2019-12-29 22:14:40 +01:00
|
|
|
state_tracker.NotifyBlend0();
|
2019-12-29 01:45:56 +01:00
|
|
|
state_tracker.NotifyFramebuffer();
|
2019-12-29 23:23:40 +01:00
|
|
|
state_tracker.NotifyFrontFace();
|
|
|
|
state_tracker.NotifyCullTest();
|
2019-12-30 02:56:21 +01:00
|
|
|
state_tracker.NotifyDepthTest();
|
2019-12-30 03:08:32 +01:00
|
|
|
state_tracker.NotifyStencilTest();
|
2019-12-30 04:22:43 +01:00
|
|
|
state_tracker.NotifyPolygonOffset();
|
2019-12-30 04:49:19 +01:00
|
|
|
state_tracker.NotifyRasterizeEnable();
|
2019-12-30 04:53:53 +01:00
|
|
|
state_tracker.NotifyFramebufferSRGB();
|
2019-12-30 04:57:50 +01:00
|
|
|
state_tracker.NotifyLogicOp();
|
2019-12-30 05:40:27 +01:00
|
|
|
state_tracker.NotifyClipControl();
|
2020-02-21 07:29:24 +01:00
|
|
|
state_tracker.NotifyAlphaTest();
|
2019-12-29 01:45:56 +01:00
|
|
|
|
2020-05-18 03:32:49 +02:00
|
|
|
program_manager.BindHostPipeline(pipeline.handle);
|
2019-12-26 20:04:41 +01:00
|
|
|
|
2019-12-25 23:56:17 +01:00
|
|
|
glEnable(GL_CULL_FACE);
|
2019-12-26 05:01:41 +01:00
|
|
|
if (screen_info.display_srgb) {
|
|
|
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
|
|
|
} else {
|
|
|
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
|
|
|
}
|
2019-12-26 00:21:53 +01:00
|
|
|
glDisable(GL_COLOR_LOGIC_OP);
|
2019-12-26 01:52:39 +01:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
2019-12-26 07:34:29 +01:00
|
|
|
glDisable(GL_STENCIL_TEST);
|
2019-12-26 04:25:53 +01:00
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
2019-12-26 06:11:01 +01:00
|
|
|
glDisable(GL_RASTERIZER_DISCARD);
|
2020-02-21 07:29:24 +01:00
|
|
|
glDisable(GL_ALPHA_TEST);
|
2019-12-26 07:51:50 +01:00
|
|
|
glDisablei(GL_BLEND, 0);
|
2019-12-26 05:28:17 +01:00
|
|
|
glDisablei(GL_SCISSOR_TEST, 0);
|
2020-02-24 23:43:57 +01:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
2019-12-25 23:56:17 +01:00
|
|
|
glCullFace(GL_BACK);
|
2019-12-25 23:46:04 +01:00
|
|
|
glFrontFace(GL_CW);
|
2019-12-26 05:19:15 +01:00
|
|
|
glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
2019-12-26 06:27:26 +01:00
|
|
|
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
2019-12-29 02:12:12 +01:00
|
|
|
glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(layout.width),
|
|
|
|
static_cast<GLfloat>(layout.height));
|
|
|
|
glDepthRangeIndexed(0, 0.0, 0.0);
|
2019-12-25 23:46:04 +01:00
|
|
|
|
2019-12-29 03:08:40 +01:00
|
|
|
glEnableVertexAttribArray(PositionLocation);
|
|
|
|
glEnableVertexAttribArray(TexCoordLocation);
|
2019-12-29 05:28:53 +01:00
|
|
|
glVertexAttribDivisor(PositionLocation, 0);
|
|
|
|
glVertexAttribDivisor(TexCoordLocation, 0);
|
2019-12-26 04:16:52 +01:00
|
|
|
glVertexAttribFormat(PositionLocation, 2, GL_FLOAT, GL_FALSE,
|
|
|
|
offsetof(ScreenRectVertex, position));
|
|
|
|
glVertexAttribFormat(TexCoordLocation, 2, GL_FLOAT, GL_FALSE,
|
|
|
|
offsetof(ScreenRectVertex, tex_coord));
|
|
|
|
glVertexAttribBinding(PositionLocation, 0);
|
|
|
|
glVertexAttribBinding(TexCoordLocation, 0);
|
gl_rasterizer: Use NV_vertex_buffer_unified_memory for vertex buffer robustness
Switch games are allowed to bind less data than what they use in a
vertex buffer, the expected behavior here is that these values are read
as zero. At the moment of writing this only D3D12, OpenGL and NVN through
NV_vertex_buffer_unified_memory support vertex buffer with a size limit.
In theory this could be emulated on Vulkan creating a new VkBuffer for
each (handle, offset, length) tuple and binding the expected data to it.
This is likely going to be slow and memory expensive when used on the
vertex buffer and we have to do it on all draws because we can't know
without analyzing indices when a game is going to read vertex data out
of bounds.
This is not a problem on OpenGL's BufferAddressRangeNV because it takes
a length parameter, unlike Vulkan's CmdBindVertexBuffers that only takes
buffers and offsets (the length is implicit in VkBuffer). It isn't a
problem on D3D12 either, because D3D12_VERTEX_BUFFER_VIEW on
IASetVertexBuffers takes SizeInBytes as a parameter (although I am not
familiar with robustness on D3D12).
Currently this only implements buffer ranges for vertex buffers,
although indices can also be affected. A KHR_robustness profile is not
created, but Nvidia's driver reads out of bound vertex data as zero
anyway, this might have to be changed in the future.
- Fixes SMO random triangles when capturing an enemy, getting hit, or
looking at the environment on certain maps.
2020-06-18 08:56:31 +02:00
|
|
|
if (device.HasVertexBufferUnifiedMemory()) {
|
|
|
|
glBindVertexBuffer(0, 0, 0, sizeof(ScreenRectVertex));
|
|
|
|
glBufferAddressRangeNV(GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV, 0, vertex_buffer_address,
|
|
|
|
sizeof(vertices));
|
|
|
|
} else {
|
|
|
|
glBindVertexBuffer(0, vertex_buffer.handle, 0, sizeof(ScreenRectVertex));
|
|
|
|
}
|
2019-12-26 04:16:52 +01:00
|
|
|
|
2019-12-26 08:01:11 +01:00
|
|
|
glBindTextureUnit(0, screen_info.display_texture);
|
|
|
|
glBindSampler(0, 0);
|
|
|
|
|
2019-12-26 05:50:38 +01:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
2014-08-28 20:21:54 +02:00
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
2020-05-18 03:32:49 +02:00
|
|
|
|
|
|
|
program_manager.RestoreGuestPipeline();
|
2014-08-28 20:21:54 +02:00
|
|
|
}
|
|
|
|
|
2020-03-25 03:58:49 +01:00
|
|
|
bool RendererOpenGL::TryPresent(int timeout_ms) {
|
|
|
|
if (has_debug_tool) {
|
|
|
|
LOG_DEBUG(Render_OpenGL,
|
|
|
|
"Skipping presentation because we are presenting on the main context");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return Present(timeout_ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RendererOpenGL::Present(int timeout_ms) {
|
2020-02-17 20:31:14 +01:00
|
|
|
const auto& layout = render_window.GetFramebufferLayout();
|
2020-02-27 00:28:50 +01:00
|
|
|
auto frame = frame_mailbox->TryGetPresentFrame(timeout_ms);
|
2020-02-17 20:31:14 +01:00
|
|
|
if (!frame) {
|
|
|
|
LOG_DEBUG(Render_OpenGL, "TryGetPresentFrame returned no frame to present");
|
2020-03-25 03:58:49 +01:00
|
|
|
return false;
|
2020-02-17 20:31:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clearing before a full overwrite of a fbo can signal to drivers that they can avoid a
|
|
|
|
// readback since we won't be doing any blending
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
// Recreate the presentation FBO if the color attachment was changed
|
|
|
|
if (frame->color_reloaded) {
|
|
|
|
LOG_DEBUG(Render_OpenGL, "Reloading present frame");
|
2020-02-27 00:28:50 +01:00
|
|
|
frame_mailbox->ReloadPresentFrame(frame, layout.width, layout.height);
|
2020-02-17 20:31:14 +01:00
|
|
|
}
|
|
|
|
glWaitSync(frame->render_fence, 0, GL_TIMEOUT_IGNORED);
|
|
|
|
// INTEL workaround.
|
|
|
|
// Normally we could just delete the draw fence here, but due to driver bugs, we can just delete
|
|
|
|
// it on the emulation thread without too much penalty
|
|
|
|
// glDeleteSync(frame.render_sync);
|
|
|
|
// frame.render_sync = 0;
|
|
|
|
|
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, frame->present.handle);
|
|
|
|
glBlitFramebuffer(0, 0, frame->width, frame->height, 0, 0, layout.width, layout.height,
|
|
|
|
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
|
|
|
|
|
|
|
// Insert fence for the main thread to block on
|
|
|
|
frame->present_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
|
|
glFlush();
|
|
|
|
|
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
2020-03-25 03:58:49 +01:00
|
|
|
return true;
|
2014-04-06 22:55:39 +02:00
|
|
|
}
|
|
|
|
|
2020-02-17 20:31:14 +01:00
|
|
|
void RendererOpenGL::RenderScreenshot() {
|
|
|
|
if (!renderer_settings.screenshot_requested) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2019-12-26 09:01:43 +01:00
|
|
|
GLint old_read_fb;
|
|
|
|
GLint old_draw_fb;
|
|
|
|
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &old_read_fb);
|
|
|
|
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &old_draw_fb);
|
|
|
|
|
2018-08-31 08:16:16 +02:00
|
|
|
// Draw the current frame to the screenshot framebuffer
|
|
|
|
screenshot_framebuffer.Create();
|
2019-12-26 09:01:43 +01:00
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, screenshot_framebuffer.handle);
|
2018-08-31 08:16:16 +02:00
|
|
|
|
|
|
|
Layout::FramebufferLayout layout{renderer_settings.screenshot_framebuffer_layout};
|
|
|
|
|
|
|
|
GLuint renderbuffer;
|
|
|
|
glGenRenderbuffers(1, &renderbuffer);
|
|
|
|
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
|
2019-09-03 06:05:23 +02:00
|
|
|
glRenderbufferStorage(GL_RENDERBUFFER, screen_info.display_srgb ? GL_SRGB8 : GL_RGB8,
|
|
|
|
layout.width, layout.height);
|
2018-08-31 08:16:16 +02:00
|
|
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
|
|
|
|
|
|
|
|
DrawScreen(layout);
|
|
|
|
|
|
|
|
glReadPixels(0, 0, layout.width, layout.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
|
|
|
renderer_settings.screenshot_bits);
|
|
|
|
|
|
|
|
screenshot_framebuffer.Release();
|
|
|
|
glDeleteRenderbuffers(1, &renderbuffer);
|
|
|
|
|
2019-12-26 09:01:43 +01:00
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, old_read_fb);
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, old_draw_fb);
|
|
|
|
|
2018-08-31 08:16:16 +02:00
|
|
|
renderer_settings.screenshot_complete_callback();
|
|
|
|
renderer_settings.screenshot_requested = false;
|
|
|
|
}
|
|
|
|
|
2016-01-07 20:33:54 +01:00
|
|
|
bool RendererOpenGL::Init() {
|
2020-06-06 02:18:22 +02:00
|
|
|
if (Settings::values.renderer_debug && GLAD_GL_KHR_debug) {
|
2015-10-10 01:32:40 +02:00
|
|
|
glEnable(GL_DEBUG_OUTPUT);
|
2020-06-06 02:18:22 +02:00
|
|
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
2015-10-10 01:32:40 +02:00
|
|
|
glDebugMessageCallback(DebugHandler, nullptr);
|
|
|
|
}
|
|
|
|
|
2019-03-02 21:08:11 +01:00
|
|
|
AddTelemetryFields();
|
2017-07-13 04:19:34 +02:00
|
|
|
|
2018-11-18 01:28:14 +01:00
|
|
|
if (!GLAD_GL_VERSION_4_3) {
|
2016-01-07 20:33:54 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-28 11:34:47 +02:00
|
|
|
InitOpenGLObjects();
|
2018-08-21 01:22:43 +02:00
|
|
|
CreateRasterizer();
|
2016-01-07 20:33:54 +01:00
|
|
|
|
|
|
|
return true;
|
2014-04-06 22:55:39 +02:00
|
|
|
}
|
|
|
|
|
2016-09-19 03:01:46 +02:00
|
|
|
void RendererOpenGL::ShutDown() {}
|
2018-08-21 10:18:27 +02:00
|
|
|
|
|
|
|
} // namespace OpenGL
|