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-08-21 09:27:53 +02:00
|
|
|
|
2020-08-24 02:23:54 +02:00
|
|
|
#include <string_view>
|
2015-09-11 13:20:02 +02:00
|
|
|
#include <vector>
|
2016-04-30 17:34:51 +02:00
|
|
|
#include <glad/glad.h>
|
2021-06-06 06:28:22 +02:00
|
|
|
|
2015-09-11 13:20:02 +02:00
|
|
|
#include "common/logging/log.h"
|
2021-06-06 06:28:22 +02:00
|
|
|
#include "common/settings.h"
|
2016-09-21 08:52:38 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_shader_util.h"
|
2014-08-21 09:27:53 +02:00
|
|
|
|
2021-06-06 06:28:22 +02:00
|
|
|
namespace OpenGL {
|
2020-08-24 02:23:54 +02:00
|
|
|
|
2021-07-14 08:48:30 +02:00
|
|
|
static OGLProgram LinkSeparableProgram(GLuint shader) {
|
|
|
|
OGLProgram program;
|
|
|
|
program.handle = glCreateProgram();
|
|
|
|
glProgramParameteri(program.handle, GL_PROGRAM_SEPARABLE, GL_TRUE);
|
|
|
|
glAttachShader(program.handle, shader);
|
|
|
|
glLinkProgram(program.handle);
|
|
|
|
if (!Settings::values.renderer_debug) {
|
|
|
|
return program;
|
|
|
|
}
|
|
|
|
GLint link_status{};
|
|
|
|
glGetProgramiv(program.handle, GL_LINK_STATUS, &link_status);
|
|
|
|
|
|
|
|
GLint log_length{};
|
|
|
|
glGetProgramiv(program.handle, GL_INFO_LOG_LENGTH, &log_length);
|
|
|
|
if (log_length == 0) {
|
|
|
|
return program;
|
|
|
|
}
|
|
|
|
std::string log(log_length, 0);
|
|
|
|
glGetProgramInfoLog(program.handle, log_length, nullptr, log.data());
|
|
|
|
if (link_status == GL_FALSE) {
|
|
|
|
LOG_ERROR(Render_OpenGL, "{}", log);
|
|
|
|
} else {
|
|
|
|
LOG_WARNING(Render_OpenGL, "{}", log);
|
|
|
|
}
|
|
|
|
return program;
|
|
|
|
}
|
|
|
|
|
2021-06-11 08:50:30 +02:00
|
|
|
static void LogShader(GLuint shader, std::string_view code = {}) {
|
2021-06-06 06:28:22 +02:00
|
|
|
GLint shader_status{};
|
|
|
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_status);
|
|
|
|
if (shader_status == GL_FALSE) {
|
|
|
|
LOG_ERROR(Render_OpenGL, "Failed to build shader");
|
|
|
|
}
|
|
|
|
GLint log_length{};
|
|
|
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
|
|
|
|
if (log_length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string log(log_length, 0);
|
|
|
|
glGetShaderInfoLog(shader, log_length, nullptr, log.data());
|
|
|
|
if (shader_status == GL_FALSE) {
|
|
|
|
LOG_ERROR(Render_OpenGL, "{}", log);
|
2021-06-11 08:50:30 +02:00
|
|
|
if (!code.empty()) {
|
|
|
|
LOG_INFO(Render_OpenGL, "\n{}", code);
|
2021-06-08 01:05:11 +02:00
|
|
|
}
|
2021-06-06 06:28:22 +02:00
|
|
|
} else {
|
|
|
|
LOG_WARNING(Render_OpenGL, "{}", log);
|
2018-04-07 05:54:44 +02:00
|
|
|
}
|
2019-07-15 03:25:13 +02:00
|
|
|
}
|
2020-08-24 02:23:54 +02:00
|
|
|
|
2021-07-14 08:48:30 +02:00
|
|
|
OGLProgram CreateProgram(std::string_view code, GLenum stage) {
|
2021-06-06 06:28:22 +02:00
|
|
|
OGLShader shader;
|
|
|
|
shader.handle = glCreateShader(stage);
|
2019-07-15 03:25:13 +02:00
|
|
|
|
2021-06-06 06:28:22 +02:00
|
|
|
const GLint length = static_cast<GLint>(code.size());
|
|
|
|
const GLchar* const code_ptr = code.data();
|
|
|
|
glShaderSource(shader.handle, 1, &code_ptr, &length);
|
|
|
|
glCompileShader(shader.handle);
|
|
|
|
if (Settings::values.renderer_debug) {
|
2021-06-08 01:05:11 +02:00
|
|
|
LogShader(shader.handle, code);
|
2021-06-06 06:28:22 +02:00
|
|
|
}
|
2021-07-14 08:48:30 +02:00
|
|
|
return LinkSeparableProgram(shader.handle);
|
2021-06-06 06:28:22 +02:00
|
|
|
}
|
2020-08-24 02:23:54 +02:00
|
|
|
|
2021-07-14 08:48:30 +02:00
|
|
|
OGLProgram CreateProgram(std::span<const u32> code, GLenum stage) {
|
2021-06-06 06:28:22 +02:00
|
|
|
OGLShader shader;
|
|
|
|
shader.handle = glCreateShader(stage);
|
2020-08-24 02:23:54 +02:00
|
|
|
|
2021-06-06 06:28:22 +02:00
|
|
|
glShaderBinary(1, &shader.handle, GL_SHADER_BINARY_FORMAT_SPIR_V_ARB, code.data(),
|
|
|
|
static_cast<GLsizei>(code.size_bytes()));
|
|
|
|
glSpecializeShader(shader.handle, "main", 0, nullptr, nullptr);
|
|
|
|
if (Settings::values.renderer_debug) {
|
|
|
|
LogShader(shader.handle);
|
|
|
|
}
|
2021-07-14 08:48:30 +02:00
|
|
|
return LinkSeparableProgram(shader.handle);
|
2021-06-06 06:28:22 +02:00
|
|
|
}
|
2014-08-21 09:27:53 +02:00
|
|
|
|
2021-06-06 06:28:22 +02:00
|
|
|
OGLAssemblyProgram CompileProgram(std::string_view code, GLenum target) {
|
|
|
|
OGLAssemblyProgram program;
|
|
|
|
glGenProgramsARB(1, &program.handle);
|
|
|
|
glNamedProgramStringEXT(program.handle, target, GL_PROGRAM_FORMAT_ASCII_ARB,
|
|
|
|
static_cast<GLsizei>(code.size()), code.data());
|
|
|
|
if (Settings::values.renderer_debug) {
|
|
|
|
const auto err = reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_NV));
|
|
|
|
if (err && *err) {
|
|
|
|
if (std::strstr(err, "error")) {
|
|
|
|
LOG_CRITICAL(Render_OpenGL, "\n{}", err);
|
|
|
|
LOG_INFO(Render_OpenGL, "\n{}", code);
|
|
|
|
} else {
|
|
|
|
LOG_WARNING(Render_OpenGL, "\n{}", err);
|
|
|
|
}
|
2014-12-06 02:53:49 +01:00
|
|
|
}
|
2014-08-21 09:27:53 +02:00
|
|
|
}
|
2021-06-06 06:28:22 +02:00
|
|
|
return program;
|
2014-08-21 09:27:53 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 06:28:22 +02:00
|
|
|
} // namespace OpenGL
|