chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-15 02:06:02 +02:00
|
|
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-04-06 22:55:39 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-01-11 04:43:17 +01:00
|
|
|
#include <vector>
|
2015-08-30 08:37:42 +02:00
|
|
|
#include <glad/glad.h>
|
2016-04-30 17:34:51 +02:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/math_util.h"
|
2022-03-19 05:06:57 +01:00
|
|
|
|
2014-11-13 19:33:29 +01:00
|
|
|
#include "video_core/renderer_base.h"
|
2020-05-18 03:32:49 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_device.h"
|
2023-01-01 19:22:46 +01:00
|
|
|
#include "video_core/renderer_opengl/gl_fsr.h"
|
2021-01-05 08:09:39 +01:00
|
|
|
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
2016-04-17 00:57:57 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
2022-03-19 05:06:57 +01:00
|
|
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
2019-12-29 01:45:56 +01:00
|
|
|
#include "video_core/renderer_opengl/gl_state_tracker.h"
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2019-01-15 20:28:42 +01:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
2020-06-12 02:24:45 +02:00
|
|
|
class TelemetrySession;
|
|
|
|
} // namespace Core
|
2019-01-15 20:28:42 +01:00
|
|
|
|
2018-08-12 02:20:19 +02:00
|
|
|
namespace Core::Frontend {
|
2014-08-28 20:21:54 +02:00
|
|
|
class EmuWindow;
|
2018-08-12 02:20:19 +02:00
|
|
|
}
|
2014-08-28 20:21:54 +02:00
|
|
|
|
2020-06-12 02:24:45 +02:00
|
|
|
namespace Core::Memory {
|
|
|
|
class Memory;
|
|
|
|
}
|
|
|
|
|
2018-08-31 08:16:16 +02:00
|
|
|
namespace Layout {
|
2018-12-26 23:32:30 +01:00
|
|
|
struct FramebufferLayout;
|
2018-08-31 08:16:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 02:24:45 +02:00
|
|
|
namespace Tegra {
|
|
|
|
class GPU;
|
|
|
|
}
|
|
|
|
|
2018-08-21 10:18:27 +02:00
|
|
|
namespace OpenGL {
|
|
|
|
|
2018-04-04 23:03:02 +02:00
|
|
|
/// Structure used for storing information about the textures for the Switch screen
|
2016-04-17 00:57:57 +02:00
|
|
|
struct TextureInfo {
|
|
|
|
OGLTexture resource;
|
|
|
|
GLsizei width;
|
|
|
|
GLsizei height;
|
|
|
|
GLenum gl_format;
|
|
|
|
GLenum gl_type;
|
2022-03-20 05:51:16 +01:00
|
|
|
Service::android::PixelFormat pixel_format;
|
2016-04-17 00:57:57 +02:00
|
|
|
};
|
|
|
|
|
2018-04-04 23:03:02 +02:00
|
|
|
/// Structure used for storing information about the display target for the Switch screen
|
2016-04-17 00:57:57 +02:00
|
|
|
struct ScreenInfo {
|
2019-09-03 06:05:23 +02:00
|
|
|
GLuint display_texture{};
|
2021-10-21 04:40:02 +02:00
|
|
|
bool was_accelerated = false;
|
2019-09-03 06:05:23 +02:00
|
|
|
bool display_srgb{};
|
2019-02-27 04:47:49 +01:00
|
|
|
const Common::Rectangle<float> display_texcoords{0.0f, 0.0f, 1.0f, 1.0f};
|
2016-04-17 00:57:57 +02:00
|
|
|
TextureInfo texture;
|
|
|
|
};
|
|
|
|
|
2019-08-21 06:55:25 +02:00
|
|
|
class RendererOpenGL final : public VideoCore::RendererBase {
|
2014-04-06 22:55:39 +02:00
|
|
|
public:
|
2020-12-05 17:40:14 +01:00
|
|
|
explicit RendererOpenGL(Core::TelemetrySession& telemetry_session_,
|
|
|
|
Core::Frontend::EmuWindow& emu_window_,
|
|
|
|
Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
|
|
|
|
std::unique_ptr<Core::Frontend::GraphicsContext> context_);
|
2014-08-28 10:51:57 +02:00
|
|
|
~RendererOpenGL() override;
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2020-02-17 20:31:14 +01:00
|
|
|
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override;
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2021-01-05 08:09:39 +01:00
|
|
|
VideoCore::RasterizerInterface* ReadRasterizer() override {
|
|
|
|
return &rasterizer;
|
|
|
|
}
|
|
|
|
|
2021-06-20 23:26:55 +02:00
|
|
|
[[nodiscard]] std::string GetDeviceVendor() const override {
|
|
|
|
return device.GetVendorName();
|
|
|
|
}
|
|
|
|
|
2014-04-06 22:55:39 +02:00
|
|
|
private:
|
2019-11-29 00:11:03 +01:00
|
|
|
/// Initializes the OpenGL state and creates persistent objects.
|
2014-08-28 11:34:47 +02:00
|
|
|
void InitOpenGLObjects();
|
2019-11-29 00:11:03 +01:00
|
|
|
|
2019-03-02 21:08:11 +01:00
|
|
|
void AddTelemetryFields();
|
2019-11-29 00:11:03 +01:00
|
|
|
|
2018-03-23 02:04:30 +01:00
|
|
|
void ConfigureFramebufferTexture(TextureInfo& texture,
|
|
|
|
const Tegra::FramebufferConfig& framebuffer);
|
2019-11-29 00:11:03 +01:00
|
|
|
|
|
|
|
/// Draws the emulated screens to the emulator window.
|
2018-08-31 08:16:16 +02:00
|
|
|
void DrawScreen(const Layout::FramebufferLayout& layout);
|
2019-11-29 00:11:03 +01:00
|
|
|
|
2020-02-17 20:31:14 +01:00
|
|
|
void RenderScreenshot();
|
2018-08-31 08:16:16 +02:00
|
|
|
|
2019-11-29 00:11:03 +01:00
|
|
|
/// Loads framebuffer from emulated memory into the active OpenGL texture.
|
2018-08-21 01:34:02 +02:00
|
|
|
void LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer);
|
2019-11-29 00:11:03 +01:00
|
|
|
|
|
|
|
/// Fills active OpenGL texture with the given RGB color.Since the color is solid, the texture
|
|
|
|
/// can be 1x1 but will stretch across whatever it's rendered on.
|
2018-01-16 19:05:21 +01:00
|
|
|
void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, u8 color_a,
|
|
|
|
const TextureInfo& texture);
|
2014-04-06 22:55:39 +02:00
|
|
|
|
2020-02-17 20:31:14 +01:00
|
|
|
void PrepareRendertarget(const Tegra::FramebufferConfig* framebuffer);
|
|
|
|
|
2020-06-12 02:24:45 +02:00
|
|
|
Core::TelemetrySession& telemetry_session;
|
2020-06-11 05:58:57 +02:00
|
|
|
Core::Frontend::EmuWindow& emu_window;
|
2020-06-12 02:24:45 +02:00
|
|
|
Core::Memory::Memory& cpu_memory;
|
2020-06-11 05:58:57 +02:00
|
|
|
Tegra::GPU& gpu;
|
2019-01-15 20:28:42 +01:00
|
|
|
|
2021-01-17 00:48:58 +01:00
|
|
|
Device device;
|
|
|
|
StateTracker state_tracker;
|
|
|
|
ProgramManager program_manager;
|
|
|
|
RasterizerOpenGL rasterizer;
|
2019-12-29 01:45:56 +01:00
|
|
|
|
2014-08-28 20:21:54 +02:00
|
|
|
// OpenGL object IDs
|
2020-12-30 06:25:23 +01:00
|
|
|
OGLSampler present_sampler;
|
2021-10-17 17:22:16 +02:00
|
|
|
OGLSampler present_sampler_nn;
|
2016-04-17 00:57:57 +02:00
|
|
|
OGLBuffer vertex_buffer;
|
2021-10-21 01:36:06 +02:00
|
|
|
OGLProgram fxaa_vertex;
|
|
|
|
OGLProgram fxaa_fragment;
|
2021-07-14 08:48:30 +02:00
|
|
|
OGLProgram present_vertex;
|
2021-08-17 00:12:52 +02:00
|
|
|
OGLProgram present_bilinear_fragment;
|
|
|
|
OGLProgram present_bicubic_fragment;
|
2021-10-21 01:27:54 +02:00
|
|
|
OGLProgram present_gaussian_fragment;
|
2021-08-17 00:12:52 +02:00
|
|
|
OGLProgram present_scaleforce_fragment;
|
2018-08-31 08:16:16 +02:00
|
|
|
OGLFramebuffer screenshot_framebuffer;
|
2016-09-19 03:01:46 +02:00
|
|
|
|
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
|
|
|
// GPU address of the vertex buffer
|
|
|
|
GLuint64EXT vertex_buffer_address = 0;
|
|
|
|
|
2018-01-11 04:43:17 +01:00
|
|
|
/// Display information for Switch screen
|
|
|
|
ScreenInfo screen_info;
|
2022-12-08 22:52:29 +01:00
|
|
|
OGLTexture aa_texture;
|
|
|
|
OGLFramebuffer aa_framebuffer;
|
|
|
|
|
|
|
|
OGLProgram smaa_edge_detection_vert;
|
|
|
|
OGLProgram smaa_blending_weight_calculation_vert;
|
|
|
|
OGLProgram smaa_neighborhood_blending_vert;
|
|
|
|
OGLProgram smaa_edge_detection_frag;
|
|
|
|
OGLProgram smaa_blending_weight_calculation_frag;
|
|
|
|
OGLProgram smaa_neighborhood_blending_frag;
|
|
|
|
OGLTexture smaa_area_tex;
|
|
|
|
OGLTexture smaa_search_tex;
|
|
|
|
OGLTexture smaa_edges_tex;
|
|
|
|
OGLTexture smaa_blend_tex;
|
2018-01-11 04:43:17 +01:00
|
|
|
|
2023-01-01 19:22:46 +01:00
|
|
|
std::unique_ptr<FSR> fsr;
|
|
|
|
|
2018-01-11 04:43:17 +01:00
|
|
|
/// OpenGL framebuffer data
|
|
|
|
std::vector<u8> gl_framebuffer_data;
|
2016-09-19 03:01:46 +02:00
|
|
|
|
2018-03-23 19:59:14 +01:00
|
|
|
/// Used for transforming the framebuffer orientation
|
2022-03-20 05:51:16 +01:00
|
|
|
Service::android::BufferTransformFlags framebuffer_transform_flags{};
|
2019-02-27 04:47:49 +01:00
|
|
|
Common::Rectangle<int> framebuffer_crop_rect;
|
2022-04-04 18:51:09 +02:00
|
|
|
u32 framebuffer_width;
|
|
|
|
u32 framebuffer_height;
|
2014-07-11 19:40:34 +02:00
|
|
|
};
|
2018-08-21 10:18:27 +02:00
|
|
|
|
|
|
|
} // namespace OpenGL
|