1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "GLESShader.h"
#include "rendering/RenderSystem.h"
#include "utils/ColorUtils.h"
#include "utils/Map.h"
#include <map>
#include <fmt/format.h>
#include "system_gl.h"
enum class ShaderMethodGLES
{
SM_DEFAULT,
SM_TEXTURE,
SM_MULTI,
SM_FONTS,
SM_TEXTURE_NOBLEND,
SM_MULTI_BLENDCOLOR,
SM_TEXTURE_RGBA,
SM_TEXTURE_RGBA_OES,
SM_TEXTURE_RGBA_BLENDCOLOR,
SM_TEXTURE_RGBA_BOB,
SM_TEXTURE_RGBA_BOB_OES,
SM_TEXTURE_NOALPHA,
SM_MAX
};
template<>
struct fmt::formatter<ShaderMethodGLES> : fmt::formatter<std::string_view>
{
template<typename FormatContext>
constexpr auto format(const ShaderMethodGLES& shaderMethod, FormatContext& ctx)
{
const auto it = ShaderMethodGLESMap.find(shaderMethod);
if (it == ShaderMethodGLESMap.cend())
throw std::range_error("no string mapping found for shader method");
return fmt::formatter<string_view>::format(it->second, ctx);
}
private:
static constexpr auto ShaderMethodGLESMap = make_map<ShaderMethodGLES, std::string_view>({
{ShaderMethodGLES::SM_DEFAULT, "default"},
{ShaderMethodGLES::SM_TEXTURE, "texture"},
{ShaderMethodGLES::SM_MULTI, "multi"},
{ShaderMethodGLES::SM_FONTS, "fonts"},
{ShaderMethodGLES::SM_TEXTURE_NOBLEND, "texture no blending"},
{ShaderMethodGLES::SM_MULTI_BLENDCOLOR, "multi blend colour"},
{ShaderMethodGLES::SM_TEXTURE_RGBA, "texure rgba"},
{ShaderMethodGLES::SM_TEXTURE_RGBA_OES, "texture rgba OES"},
{ShaderMethodGLES::SM_TEXTURE_RGBA_BLENDCOLOR, "texture rgba blend colour"},
{ShaderMethodGLES::SM_TEXTURE_RGBA_BOB, "texture rgba bob"},
{ShaderMethodGLES::SM_TEXTURE_RGBA_BOB_OES, "texture rgba bob OES"},
{ShaderMethodGLES::SM_TEXTURE_NOALPHA, "texture no alpha"},
});
static_assert(static_cast<size_t>(ShaderMethodGLES::SM_MAX) == ShaderMethodGLESMap.size(),
"ShaderMethodGLESMap doesn't match the size of ShaderMethodGLES, did you forget to "
"add/remove a mapping?");
};
class CRenderSystemGLES : public CRenderSystemBase
{
public:
CRenderSystemGLES();
~CRenderSystemGLES() override = default;
bool InitRenderSystem() override;
bool DestroyRenderSystem() override;
bool ResetRenderSystem(int width, int height) override;
bool BeginRender() override;
bool EndRender() override;
void PresentRender(bool rendered, bool videoLayer) override;
bool ClearBuffers(UTILS::COLOR::Color color) override;
bool IsExtSupported(const char* extension) const override;
void SetVSync(bool vsync);
void ResetVSync() { m_bVsyncInit = false; }
void SetViewPort(const CRect& viewPort) override;
void GetViewPort(CRect& viewPort) override;
bool ScissorsCanEffectClipping() override;
CRect ClipRectToScissorRect(const CRect &rect) override;
void SetScissors(const CRect& rect) override;
void ResetScissors() override;
void CaptureStateBlock() override;
void ApplyStateBlock() override;
void SetCameraPosition(const CPoint &camera, int screenWidth, int screenHeight, float stereoFactor = 0.0f) override;
bool SupportsStereo(RENDER_STEREO_MODE mode) const override;
void Project(float &x, float &y, float &z) override;
std::string GetShaderPath(const std::string &filename) override { return "GLES/2.0/"; }
void InitialiseShaders();
void ReleaseShaders();
void EnableGUIShader(ShaderMethodGLES method);
void DisableGUIShader();
GLint GUIShaderGetPos();
GLint GUIShaderGetCol();
GLint GUIShaderGetCoord0();
GLint GUIShaderGetCoord1();
GLint GUIShaderGetUniCol();
GLint GUIShaderGetCoord0Matrix();
GLint GUIShaderGetField();
GLint GUIShaderGetStep();
GLint GUIShaderGetContrast();
GLint GUIShaderGetBrightness();
GLint GUIShaderGetModel();
protected:
virtual void SetVSyncImpl(bool enable) = 0;
virtual void PresentRenderImpl(bool rendered) = 0;
void CalculateMaxTexturesize();
bool m_bVsyncInit{false};
int m_width;
int m_height;
std::string m_RenderExtensions;
std::map<ShaderMethodGLES, std::unique_ptr<CGLESShader>> m_pShader;
ShaderMethodGLES m_method = ShaderMethodGLES::SM_DEFAULT;
GLint m_viewPort[4];
};
|