Port yuzu-emu/yuzu#1137: "renderer_opengl: Namespace OpenGL code" (#4423)
* renderer_opengl: Namespace OpenGL code Namespaces all OpenGL code under the OpenGL namespace. Prevents polluting the global namespace and allows clear distinction between other renderers' code in the future. * Also namespace TextureCubeConfig
This commit is contained in:
parent
7f727177bf
commit
46e8237e7e
22 changed files with 166 additions and 125 deletions
|
@ -7,7 +7,9 @@
|
|||
#include "common/common_types.h"
|
||||
#include "core/hw/gpu.h"
|
||||
|
||||
namespace OpenGL {
|
||||
struct ScreenInfo;
|
||||
}
|
||||
|
||||
namespace Pica {
|
||||
namespace Shader {
|
||||
|
@ -63,7 +65,7 @@ public:
|
|||
/// Attempt to use a faster method to display the framebuffer to screen
|
||||
virtual bool AccelerateDisplay(const GPU::Regs::FramebufferConfig& config,
|
||||
PAddr framebuffer_addr, u32 pixel_stride,
|
||||
ScreenInfo& screen_info) {
|
||||
OpenGL::ScreenInfo& screen_info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ void RendererBase::RefreshRasterizerSetting() {
|
|||
opengl_rasterizer_active = hw_renderer_enabled;
|
||||
|
||||
if (hw_renderer_enabled) {
|
||||
rasterizer = std::make_unique<RasterizerOpenGL>(render_window);
|
||||
rasterizer = std::make_unique<OpenGL::RasterizerOpenGL>(render_window);
|
||||
} else {
|
||||
rasterizer = std::make_unique<VideoCore::SWRasterizer>();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "video_core/renderer_opengl/pica_to_gl.h"
|
||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
using PixelFormat = SurfaceParams::PixelFormat;
|
||||
using SurfaceType = SurfaceParams::SurfaceType;
|
||||
|
||||
|
@ -102,35 +104,35 @@ RasterizerOpenGL::RasterizerOpenGL(EmuWindow& window)
|
|||
state.draw.vertex_buffer = vertex_buffer.GetHandle();
|
||||
state.Apply();
|
||||
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_POSITION, 4, GL_FLOAT, GL_FALSE,
|
||||
sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, position));
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_POSITION);
|
||||
glVertexAttribPointer(ATTRIBUTE_POSITION, 4, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, position));
|
||||
glEnableVertexAttribArray(ATTRIBUTE_POSITION);
|
||||
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
glVertexAttribPointer(ATTRIBUTE_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, color));
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_COLOR);
|
||||
glEnableVertexAttribArray(ATTRIBUTE_COLOR);
|
||||
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_TEXCOORD0, 2, GL_FLOAT, GL_FALSE,
|
||||
sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, tex_coord0));
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_TEXCOORD1, 2, GL_FLOAT, GL_FALSE,
|
||||
sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, tex_coord1));
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_TEXCOORD2, 2, GL_FLOAT, GL_FALSE,
|
||||
sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, tex_coord2));
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD0);
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD1);
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD2);
|
||||
glVertexAttribPointer(ATTRIBUTE_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, tex_coord0));
|
||||
glVertexAttribPointer(ATTRIBUTE_TEXCOORD1, 2, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, tex_coord1));
|
||||
glVertexAttribPointer(ATTRIBUTE_TEXCOORD2, 2, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, tex_coord2));
|
||||
glEnableVertexAttribArray(ATTRIBUTE_TEXCOORD0);
|
||||
glEnableVertexAttribArray(ATTRIBUTE_TEXCOORD1);
|
||||
glEnableVertexAttribArray(ATTRIBUTE_TEXCOORD2);
|
||||
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_TEXCOORD0_W, 1, GL_FLOAT, GL_FALSE,
|
||||
sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, tex_coord0_w));
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD0_W);
|
||||
glVertexAttribPointer(ATTRIBUTE_TEXCOORD0_W, 1, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, tex_coord0_w));
|
||||
glEnableVertexAttribArray(ATTRIBUTE_TEXCOORD0_W);
|
||||
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_NORMQUAT, 4, GL_FLOAT, GL_FALSE,
|
||||
sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, normquat));
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_NORMQUAT);
|
||||
glVertexAttribPointer(ATTRIBUTE_NORMQUAT, 4, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, normquat));
|
||||
glEnableVertexAttribArray(ATTRIBUTE_NORMQUAT);
|
||||
|
||||
glVertexAttribPointer(GLShader::ATTRIBUTE_VIEW, 3, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
glVertexAttribPointer(ATTRIBUTE_VIEW, 3, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex),
|
||||
(GLvoid*)offsetof(HardwareVertex, view));
|
||||
glEnableVertexAttribArray(GLShader::ATTRIBUTE_VIEW);
|
||||
glEnableVertexAttribArray(ATTRIBUTE_VIEW);
|
||||
|
||||
// Create render framebuffer
|
||||
framebuffer.Create();
|
||||
|
@ -367,7 +369,7 @@ void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset,
|
|||
|
||||
bool RasterizerOpenGL::SetupVertexShader() {
|
||||
MICROPROFILE_SCOPE(OpenGL_VS);
|
||||
GLShader::PicaVSConfig vs_config(Pica::g_state.regs, Pica::g_state.vs);
|
||||
PicaVSConfig vs_config(Pica::g_state.regs, Pica::g_state.vs);
|
||||
return shader_program_manager->UseProgrammableVertexShader(vs_config, Pica::g_state.vs);
|
||||
}
|
||||
|
||||
|
@ -375,11 +377,11 @@ bool RasterizerOpenGL::SetupGeometryShader() {
|
|||
MICROPROFILE_SCOPE(OpenGL_GS);
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
if (regs.pipeline.use_gs == Pica::PipelineRegs::UseGS::No) {
|
||||
GLShader::PicaFixedGSConfig gs_config(regs);
|
||||
PicaFixedGSConfig gs_config(regs);
|
||||
shader_program_manager->UseFixedGeometryShader(gs_config);
|
||||
return true;
|
||||
} else {
|
||||
GLShader::PicaGSConfig gs_config(regs, Pica::g_state.gs);
|
||||
PicaGSConfig gs_config(regs, Pica::g_state.gs);
|
||||
return shader_program_manager->UseProgrammableGeometryShader(gs_config, Pica::g_state.gs);
|
||||
}
|
||||
}
|
||||
|
@ -1588,7 +1590,7 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(
|
|||
}
|
||||
|
||||
void RasterizerOpenGL::SetShader() {
|
||||
auto config = GLShader::PicaFSConfig::BuildFromRegs(Pica::g_state.regs);
|
||||
auto config = PicaFSConfig::BuildFromRegs(Pica::g_state.regs);
|
||||
shader_program_manager->UseFragmentShader(config);
|
||||
}
|
||||
|
||||
|
@ -2105,3 +2107,5 @@ void RasterizerOpenGL::UploadUniforms(bool accelerate_draw, bool use_gs) {
|
|||
|
||||
uniform_buffer.Unmap(used_bytes);
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -30,9 +30,10 @@
|
|||
#include "video_core/shader/shader.h"
|
||||
|
||||
class EmuWindow;
|
||||
struct ScreenInfo;
|
||||
class ShaderProgramManager;
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
class RasterizerOpenGL : public VideoCore::RasterizerInterface {
|
||||
public:
|
||||
explicit RasterizerOpenGL(EmuWindow& renderer);
|
||||
|
@ -307,3 +308,5 @@ private:
|
|||
|
||||
bool allow_shadow;
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "video_core/utils.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
using SurfaceType = SurfaceParams::SurfaceType;
|
||||
using PixelFormat = SurfaceParams::PixelFormat;
|
||||
|
||||
|
@ -1727,3 +1729,5 @@ void RasterizerCacheOpenGL::UpdatePagesCachedCount(PAddr addr, u32 size, int del
|
|||
if (delta < 0)
|
||||
cached_pages.add({pages_interval, delta});
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -31,6 +31,50 @@
|
|||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/texture/texture_decode.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
struct TextureCubeConfig {
|
||||
PAddr px;
|
||||
PAddr nx;
|
||||
PAddr py;
|
||||
PAddr ny;
|
||||
PAddr pz;
|
||||
PAddr nz;
|
||||
u32 width;
|
||||
Pica::TexturingRegs::TextureFormat format;
|
||||
|
||||
bool operator==(const TextureCubeConfig& rhs) const {
|
||||
return std::tie(px, nx, py, ny, pz, nz, width, format) ==
|
||||
std::tie(rhs.px, rhs.nx, rhs.py, rhs.ny, rhs.pz, rhs.nz, rhs.width, rhs.format);
|
||||
}
|
||||
|
||||
bool operator!=(const TextureCubeConfig& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<OpenGL::TextureCubeConfig> {
|
||||
std::size_t operator()(const OpenGL::TextureCubeConfig& config) const {
|
||||
std::size_t hash = 0;
|
||||
boost::hash_combine(hash, config.px);
|
||||
boost::hash_combine(hash, config.nx);
|
||||
boost::hash_combine(hash, config.py);
|
||||
boost::hash_combine(hash, config.ny);
|
||||
boost::hash_combine(hash, config.pz);
|
||||
boost::hash_combine(hash, config.nz);
|
||||
boost::hash_combine(hash, config.width);
|
||||
boost::hash_combine(hash, static_cast<u32>(config.format));
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
struct CachedSurface;
|
||||
using Surface = std::shared_ptr<CachedSurface>;
|
||||
using SurfaceSet = std::set<Surface>;
|
||||
|
@ -351,44 +395,6 @@ private:
|
|||
std::list<std::weak_ptr<SurfaceWatcher>> watchers;
|
||||
};
|
||||
|
||||
struct TextureCubeConfig {
|
||||
PAddr px;
|
||||
PAddr nx;
|
||||
PAddr py;
|
||||
PAddr ny;
|
||||
PAddr pz;
|
||||
PAddr nz;
|
||||
u32 width;
|
||||
Pica::TexturingRegs::TextureFormat format;
|
||||
|
||||
bool operator==(const TextureCubeConfig& rhs) const {
|
||||
return std::tie(px, nx, py, ny, pz, nz, width, format) ==
|
||||
std::tie(rhs.px, rhs.nx, rhs.py, rhs.ny, rhs.pz, rhs.nz, rhs.width, rhs.format);
|
||||
}
|
||||
|
||||
bool operator!=(const TextureCubeConfig& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<TextureCubeConfig> {
|
||||
std::size_t operator()(const TextureCubeConfig& config) const {
|
||||
std::size_t hash = 0;
|
||||
boost::hash_combine(hash, config.px);
|
||||
boost::hash_combine(hash, config.nx);
|
||||
boost::hash_combine(hash, config.py);
|
||||
boost::hash_combine(hash, config.ny);
|
||||
boost::hash_combine(hash, config.pz);
|
||||
boost::hash_combine(hash, config.nz);
|
||||
boost::hash_combine(hash, config.width);
|
||||
boost::hash_combine(hash, static_cast<u32>(config.format));
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
struct CachedTextureCube {
|
||||
OGLTexture texture;
|
||||
u16 res_scale = 1;
|
||||
|
@ -486,3 +492,4 @@ private:
|
|||
|
||||
std::unordered_map<TextureCubeConfig, CachedTextureCube> texture_cube_cache;
|
||||
};
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "video_core/renderer_opengl/gl_shader_util.h"
|
||||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
class OGLTexture : private NonCopyable {
|
||||
public:
|
||||
OGLTexture() = default;
|
||||
|
@ -102,7 +104,7 @@ public:
|
|||
return;
|
||||
if (source == nullptr)
|
||||
return;
|
||||
handle = GLShader::LoadShader(source, type);
|
||||
handle = LoadShader(source, type);
|
||||
}
|
||||
|
||||
void Release() {
|
||||
|
@ -135,7 +137,7 @@ public:
|
|||
void Create(bool separable_program, const std::vector<GLuint>& shaders) {
|
||||
if (handle != 0)
|
||||
return;
|
||||
handle = GLShader::LoadProgram(separable_program, shaders);
|
||||
handle = LoadProgram(separable_program, shaders);
|
||||
}
|
||||
|
||||
/// Creates a new program from given shader soruce code
|
||||
|
@ -294,3 +296,5 @@ public:
|
|||
|
||||
GLuint handle = 0;
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
#include "common/common_types.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
||||
|
||||
namespace Pica {
|
||||
namespace Shader {
|
||||
namespace Decompiler {
|
||||
namespace OpenGL::ShaderDecompiler {
|
||||
|
||||
using nihstro::Instruction;
|
||||
using nihstro::OpCode;
|
||||
|
@ -23,7 +21,7 @@ using nihstro::RegisterType;
|
|||
using nihstro::SourceRegister;
|
||||
using nihstro::SwizzlePattern;
|
||||
|
||||
constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH;
|
||||
constexpr u32 PROGRAM_END = Pica::Shader::MAX_PROGRAM_CODE_LENGTH;
|
||||
|
||||
class DecompileFail : public std::runtime_error {
|
||||
public:
|
||||
|
@ -927,6 +925,4 @@ std::optional<std::string> DecompileProgram(const ProgramCode& program_code,
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace Decompiler
|
||||
} // namespace Shader
|
||||
} // namespace Pica
|
||||
} // namespace OpenGL::ShaderDecompiler
|
||||
|
|
|
@ -9,12 +9,10 @@
|
|||
#include "common/common_types.h"
|
||||
#include "video_core/shader/shader.h"
|
||||
|
||||
namespace Pica {
|
||||
namespace Shader {
|
||||
namespace Decompiler {
|
||||
namespace OpenGL::ShaderDecompiler {
|
||||
|
||||
using ProgramCode = std::array<u32, MAX_PROGRAM_CODE_LENGTH>;
|
||||
using SwizzleData = std::array<u32, MAX_SWIZZLE_DATA_LENGTH>;
|
||||
using ProgramCode = std::array<u32, Pica::Shader::MAX_PROGRAM_CODE_LENGTH>;
|
||||
using SwizzleData = std::array<u32, Pica::Shader::MAX_SWIZZLE_DATA_LENGTH>;
|
||||
using RegGetter = std::function<std::string(u32)>;
|
||||
|
||||
std::string GetCommonDeclarations();
|
||||
|
@ -25,6 +23,4 @@ std::optional<std::string> DecompileProgram(const ProgramCode& program_code,
|
|||
const RegGetter& outputreg_getter, bool sanitize_mul,
|
||||
bool is_gs);
|
||||
|
||||
} // namespace Decompiler
|
||||
} // namespace Shader
|
||||
} // namespace Pica
|
||||
} // namespace OpenGL::ShaderDecompiler
|
||||
|
|
|
@ -27,7 +27,7 @@ using Pica::TexturingRegs;
|
|||
using TevStageConfig = TexturingRegs::TevStageConfig;
|
||||
using VSOutputAttributes = RasterizerRegs::VSOutputAttributes;
|
||||
|
||||
namespace GLShader {
|
||||
namespace OpenGL {
|
||||
|
||||
static const std::string UniformBlockDef = R"(
|
||||
#define NUM_TEV_STAGES 6
|
||||
|
@ -118,7 +118,7 @@ PicaFSConfig PicaFSConfig::BuildFromRegs(const Pica::Regs& regs) {
|
|||
|
||||
state.alpha_test_func = regs.framebuffer.output_merger.alpha_test.enable
|
||||
? regs.framebuffer.output_merger.alpha_test.func.Value()
|
||||
: Pica::FramebufferRegs::CompareFunc::Always;
|
||||
: FramebufferRegs::CompareFunc::Always;
|
||||
|
||||
state.texture0_type = regs.texturing.texture0.type;
|
||||
|
||||
|
@ -237,7 +237,7 @@ PicaFSConfig PicaFSConfig::BuildFromRegs(const Pica::Regs& regs) {
|
|||
}
|
||||
|
||||
state.shadow_rendering = regs.framebuffer.output_merger.fragment_operation_mode ==
|
||||
Pica::FramebufferRegs::FragmentOperationMode::Shadow;
|
||||
FramebufferRegs::FragmentOperationMode::Shadow;
|
||||
|
||||
state.shadow_texture_orthographic = regs.texturing.shadow.orthographic != 0;
|
||||
state.shadow_texture_bias = regs.texturing.shadow.bias << 1;
|
||||
|
@ -1641,7 +1641,7 @@ std::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetup&
|
|||
out += "#extension GL_ARB_separate_shader_objects : enable\n";
|
||||
}
|
||||
|
||||
out += Pica::Shader::Decompiler::GetCommonDeclarations();
|
||||
out += ShaderDecompiler::GetCommonDeclarations();
|
||||
|
||||
std::array<bool, 16> used_regs{};
|
||||
auto get_input_reg = [&](u32 reg) -> std::string {
|
||||
|
@ -1658,7 +1658,7 @@ std::optional<std::string> GenerateVertexShader(const Pica::Shader::ShaderSetup&
|
|||
return "";
|
||||
};
|
||||
|
||||
auto program_source_opt = Pica::Shader::Decompiler::DecompileProgram(
|
||||
auto program_source_opt = ShaderDecompiler::DecompileProgram(
|
||||
setup.program_code, setup.swizzle_data, config.state.main_offset, get_input_reg,
|
||||
get_output_reg, config.state.sanitize_mul, false);
|
||||
|
||||
|
@ -1703,7 +1703,7 @@ layout (std140) uniform vs_config {
|
|||
static std::string GetGSCommonSource(const PicaGSConfigCommonRaw& config, bool separable_shader) {
|
||||
std::string out = GetVertexInterfaceDeclaration(true, separable_shader);
|
||||
out += UniformBlockDef;
|
||||
out += Pica::Shader::Decompiler::GetCommonDeclarations();
|
||||
out += ShaderDecompiler::GetCommonDeclarations();
|
||||
|
||||
out += '\n';
|
||||
for (u32 i = 0; i < config.vs_output_attributes; ++i) {
|
||||
|
@ -1873,7 +1873,7 @@ std::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSetu
|
|||
return "";
|
||||
};
|
||||
|
||||
auto program_source_opt = Pica::Shader::Decompiler::DecompileProgram(
|
||||
auto program_source_opt = ShaderDecompiler::DecompileProgram(
|
||||
setup.program_code, setup.swizzle_data, config.state.main_offset, get_input_reg,
|
||||
get_output_reg, config.state.sanitize_mul, true);
|
||||
|
||||
|
@ -1932,4 +1932,4 @@ void emit() {
|
|||
return out;
|
||||
}
|
||||
|
||||
} // namespace GLShader
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "video_core/regs.h"
|
||||
#include "video_core/shader/shader.h"
|
||||
|
||||
namespace GLShader {
|
||||
namespace OpenGL {
|
||||
|
||||
enum Attributes {
|
||||
ATTRIBUTE_POSITION,
|
||||
|
@ -255,33 +255,33 @@ std::optional<std::string> GenerateGeometryShader(const Pica::Shader::ShaderSetu
|
|||
*/
|
||||
std::string GenerateFragmentShader(const PicaFSConfig& config, bool separable_shader);
|
||||
|
||||
} // namespace GLShader
|
||||
} // namespace OpenGL
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<GLShader::PicaFSConfig> {
|
||||
std::size_t operator()(const GLShader::PicaFSConfig& k) const {
|
||||
struct hash<OpenGL::PicaFSConfig> {
|
||||
std::size_t operator()(const OpenGL::PicaFSConfig& k) const {
|
||||
return k.Hash();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<GLShader::PicaVSConfig> {
|
||||
std::size_t operator()(const GLShader::PicaVSConfig& k) const {
|
||||
struct hash<OpenGL::PicaVSConfig> {
|
||||
std::size_t operator()(const OpenGL::PicaVSConfig& k) const {
|
||||
return k.Hash();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<GLShader::PicaFixedGSConfig> {
|
||||
std::size_t operator()(const GLShader::PicaFixedGSConfig& k) const {
|
||||
struct hash<OpenGL::PicaFixedGSConfig> {
|
||||
std::size_t operator()(const OpenGL::PicaFixedGSConfig& k) const {
|
||||
return k.Hash();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<GLShader::PicaGSConfig> {
|
||||
std::size_t operator()(const GLShader::PicaGSConfig& k) const {
|
||||
struct hash<OpenGL::PicaGSConfig> {
|
||||
std::size_t operator()(const OpenGL::PicaGSConfig& k) const {
|
||||
return k.Hash();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
#include <boost/variant.hpp>
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
static void SetShaderUniformBlockBinding(GLuint shader, const char* name, UniformBindings binding,
|
||||
std::size_t expected_size) {
|
||||
GLuint ub_index = glGetUniformBlockIndex(shader, name);
|
||||
const GLuint ub_index = glGetUniformBlockIndex(shader, name);
|
||||
if (ub_index == GL_INVALID_INDEX) {
|
||||
return;
|
||||
}
|
||||
|
@ -127,7 +129,7 @@ private:
|
|||
class TrivialVertexShader {
|
||||
public:
|
||||
explicit TrivialVertexShader(bool separable) : program(separable) {
|
||||
program.Create(GLShader::GenerateTrivialVertexShader(separable).c_str(), GL_VERTEX_SHADER);
|
||||
program.Create(GenerateTrivialVertexShader(separable).c_str(), GL_VERTEX_SHADER);
|
||||
}
|
||||
GLuint Get() const {
|
||||
return program.GetHandle();
|
||||
|
@ -201,18 +203,15 @@ private:
|
|||
};
|
||||
|
||||
using ProgrammableVertexShaders =
|
||||
ShaderDoubleCache<GLShader::PicaVSConfig, &GLShader::GenerateVertexShader, GL_VERTEX_SHADER>;
|
||||
ShaderDoubleCache<PicaVSConfig, &GenerateVertexShader, GL_VERTEX_SHADER>;
|
||||
|
||||
using ProgrammableGeometryShaders =
|
||||
ShaderDoubleCache<GLShader::PicaGSConfig, &GLShader::GenerateGeometryShader,
|
||||
GL_GEOMETRY_SHADER>;
|
||||
ShaderDoubleCache<PicaGSConfig, &GenerateGeometryShader, GL_GEOMETRY_SHADER>;
|
||||
|
||||
using FixedGeometryShaders =
|
||||
ShaderCache<GLShader::PicaFixedGSConfig, &GLShader::GenerateFixedGeometryShader,
|
||||
GL_GEOMETRY_SHADER>;
|
||||
ShaderCache<PicaFixedGSConfig, &GenerateFixedGeometryShader, GL_GEOMETRY_SHADER>;
|
||||
|
||||
using FragmentShaders =
|
||||
ShaderCache<GLShader::PicaFSConfig, &GLShader::GenerateFragmentShader, GL_FRAGMENT_SHADER>;
|
||||
using FragmentShaders = ShaderCache<PicaFSConfig, &GenerateFragmentShader, GL_FRAGMENT_SHADER>;
|
||||
|
||||
class ShaderProgramManager::Impl {
|
||||
public:
|
||||
|
@ -270,7 +269,7 @@ ShaderProgramManager::ShaderProgramManager(bool separable, bool is_amd)
|
|||
|
||||
ShaderProgramManager::~ShaderProgramManager() = default;
|
||||
|
||||
bool ShaderProgramManager::UseProgrammableVertexShader(const GLShader::PicaVSConfig& config,
|
||||
bool ShaderProgramManager::UseProgrammableVertexShader(const PicaVSConfig& config,
|
||||
const Pica::Shader::ShaderSetup setup) {
|
||||
GLuint handle = impl->programmable_vertex_shaders.Get(config, setup);
|
||||
if (handle == 0)
|
||||
|
@ -283,7 +282,7 @@ void ShaderProgramManager::UseTrivialVertexShader() {
|
|||
impl->current.vs = impl->trivial_vertex_shader.Get();
|
||||
}
|
||||
|
||||
bool ShaderProgramManager::UseProgrammableGeometryShader(const GLShader::PicaGSConfig& config,
|
||||
bool ShaderProgramManager::UseProgrammableGeometryShader(const PicaGSConfig& config,
|
||||
const Pica::Shader::ShaderSetup setup) {
|
||||
GLuint handle = impl->programmable_geometry_shaders.Get(config, setup);
|
||||
if (handle == 0)
|
||||
|
@ -292,7 +291,7 @@ bool ShaderProgramManager::UseProgrammableGeometryShader(const GLShader::PicaGSC
|
|||
return true;
|
||||
}
|
||||
|
||||
void ShaderProgramManager::UseFixedGeometryShader(const GLShader::PicaFixedGSConfig& config) {
|
||||
void ShaderProgramManager::UseFixedGeometryShader(const PicaFixedGSConfig& config) {
|
||||
impl->current.gs = impl->fixed_geometry_shaders.Get(config);
|
||||
}
|
||||
|
||||
|
@ -300,7 +299,7 @@ void ShaderProgramManager::UseTrivialGeometryShader() {
|
|||
impl->current.gs = 0;
|
||||
}
|
||||
|
||||
void ShaderProgramManager::UseFragmentShader(const GLShader::PicaFSConfig& config) {
|
||||
void ShaderProgramManager::UseFragmentShader(const PicaFSConfig& config) {
|
||||
impl->current.fs = impl->fragment_shaders.Get(config);
|
||||
}
|
||||
|
||||
|
@ -331,3 +330,4 @@ void ShaderProgramManager::ApplyTo(OpenGLState& state) {
|
|||
state.draw.shader_program = cached_program.handle;
|
||||
}
|
||||
}
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "video_core/renderer_opengl/gl_shader_gen.h"
|
||||
#include "video_core/renderer_opengl/pica_to_gl.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
enum class UniformBindings : GLuint { Common, VS, GS };
|
||||
|
||||
struct LightSrc {
|
||||
|
@ -102,19 +104,19 @@ public:
|
|||
ShaderProgramManager(bool separable, bool is_amd);
|
||||
~ShaderProgramManager();
|
||||
|
||||
bool UseProgrammableVertexShader(const GLShader::PicaVSConfig& config,
|
||||
bool UseProgrammableVertexShader(const PicaVSConfig& config,
|
||||
const Pica::Shader::ShaderSetup setup);
|
||||
|
||||
void UseTrivialVertexShader();
|
||||
|
||||
bool UseProgrammableGeometryShader(const GLShader::PicaGSConfig& config,
|
||||
bool UseProgrammableGeometryShader(const PicaGSConfig& config,
|
||||
const Pica::Shader::ShaderSetup setup);
|
||||
|
||||
void UseFixedGeometryShader(const GLShader::PicaFixedGSConfig& config);
|
||||
void UseFixedGeometryShader(const PicaFixedGSConfig& config);
|
||||
|
||||
void UseTrivialGeometryShader();
|
||||
|
||||
void UseFragmentShader(const GLShader::PicaFSConfig& config);
|
||||
void UseFragmentShader(const PicaFSConfig& config);
|
||||
|
||||
void ApplyTo(OpenGLState& state);
|
||||
|
||||
|
@ -122,3 +124,4 @@ private:
|
|||
class Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "common/logging/log.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_util.h"
|
||||
|
||||
namespace GLShader {
|
||||
namespace OpenGL {
|
||||
|
||||
GLuint LoadShader(const char* source, GLenum type) {
|
||||
const char* debug_type;
|
||||
|
@ -95,4 +95,4 @@ GLuint LoadProgram(bool separable_program, const std::vector<GLuint>& shaders) {
|
|||
return program_id;
|
||||
}
|
||||
|
||||
} // namespace GLShader
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <vector>
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace GLShader {
|
||||
namespace OpenGL {
|
||||
|
||||
/**
|
||||
* Utility function to create and compile an OpenGL GLSL shader
|
||||
|
@ -24,4 +24,4 @@ GLuint LoadShader(const char* source, GLenum type);
|
|||
*/
|
||||
GLuint LoadProgram(bool separable_program, const std::vector<GLuint>& shaders);
|
||||
|
||||
} // namespace GLShader
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "common/logging/log.h"
|
||||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
OpenGLState OpenGLState::cur_state;
|
||||
|
||||
OpenGLState::OpenGLState() {
|
||||
|
@ -411,3 +413,5 @@ OpenGLState& OpenGLState::ResetFramebuffer(GLuint handle) {
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <array>
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
namespace TextureUnits {
|
||||
|
||||
struct TextureUnit {
|
||||
|
@ -164,3 +166,5 @@ public:
|
|||
private:
|
||||
static OpenGLState cur_state;
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
OGLStreamBuffer::OGLStreamBuffer(GLenum target, GLsizeiptr size, bool array_buffer_for_amd,
|
||||
bool prefer_coherent)
|
||||
: gl_target(target), buffer_size(size) {
|
||||
|
@ -98,3 +100,5 @@ void OGLStreamBuffer::Unmap(GLsizeiptr size) {
|
|||
|
||||
buffer_pos += size;
|
||||
}
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "common/common_types.h"
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
class OGLStreamBuffer : private NonCopyable {
|
||||
public:
|
||||
explicit OGLStreamBuffer(GLenum target, GLsizeiptr size, bool array_buffer_for_amd,
|
||||
|
@ -43,3 +45,5 @@ private:
|
|||
GLsizeiptr mapped_size = 0;
|
||||
u8* mapped_ptr = nullptr;
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
static const char vertex_shader[] = R"(
|
||||
#version 150 core
|
||||
|
||||
|
@ -535,3 +537,5 @@ Core::System::ResultStatus RendererOpenGL::Init() {
|
|||
|
||||
/// Shutdown the renderer
|
||||
void RendererOpenGL::ShutDown() {}
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
|
||||
class EmuWindow;
|
||||
namespace OpenGL {
|
||||
|
||||
/// Structure used for storing information about the textures for each 3DS screen
|
||||
struct TextureInfo {
|
||||
|
@ -78,3 +78,5 @@ private:
|
|||
GLuint attrib_position;
|
||||
GLuint attrib_tex_coord;
|
||||
};
|
||||
|
||||
} // namespace OpenGL
|
||||
|
|
|
@ -27,7 +27,7 @@ std::atomic<bool> g_renderer_bg_color_update_requested;
|
|||
Core::System::ResultStatus Init(EmuWindow& emu_window) {
|
||||
Pica::Init();
|
||||
|
||||
g_renderer = std::make_unique<RendererOpenGL>(emu_window);
|
||||
g_renderer = std::make_unique<OpenGL::RendererOpenGL>(emu_window);
|
||||
Core::System::ResultStatus result = g_renderer->Init();
|
||||
|
||||
if (result != Core::System::ResultStatus::Success) {
|
||||
|
|
Loading…
Reference in a new issue