GPU/OpenGL: Fix GLES again

This commit is contained in:
Connor McLaughlin 2020-05-03 19:38:27 +10:00
parent 8139230d05
commit 257c86930f
3 changed files with 23 additions and 14 deletions

View File

@ -39,7 +39,7 @@ bool GPU_HW_OpenGL::Initialize(HostDisplay* host_display, System* system, DMA* d
SetCapabilities(host_display);
m_shader_cache.Open(m_is_gles, system->GetHostInterface()->GetUserDirectoryRelativePath("cache"));
m_shader_cache.Open(IsGLES(), system->GetHostInterface()->GetUserDirectoryRelativePath("cache"));
if (!GPU_HW::Initialize(host_display, system, dma, interrupt_controller, timers))
return false;
@ -155,8 +155,7 @@ std::tuple<s32, s32> GPU_HW_OpenGL::ConvertToFramebufferCoordinates(s32 x, s32 y
void GPU_HW_OpenGL::SetCapabilities(HostDisplay* host_display)
{
m_is_gles = (host_display->GetRenderAPI() == HostDisplay::RenderAPI::OpenGLES);
Log_InfoPrintf("Context Type: %s", m_is_gles ? "OpenGL ES" : "OpenGL");
Log_InfoPrintf("Context Type: %s", IsGLES() ? "OpenGL ES" : "OpenGL");
const char* gl_vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
const char* gl_renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
@ -266,7 +265,7 @@ void GPU_HW_OpenGL::ClearFramebuffer()
{
glDisable(GL_SCISSOR_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(0.0f);
IsGLES() ? glClearDepthf(0.0f) : glClearDepth(0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_SCISSOR_TEST);
SetFullVRAMDirtyRectangle();
@ -358,7 +357,7 @@ bool GPU_HW_OpenGL::CompilePrograms()
prog.BindAttribute(3, "a_texpage");
}
if (!m_is_gles || m_supports_dual_source_blend)
if (!IsGLES() || m_supports_dual_source_blend)
{
if (m_supports_dual_source_blend)
{
@ -416,7 +415,7 @@ bool GPU_HW_OpenGL::CompilePrograms()
std::optional<GL::Program> prog =
m_shader_cache.GetProgram(vs, {}, fs, [this, use_binding_layout](GL::Program& prog) {
if (!m_is_gles && !use_binding_layout)
if (!IsGLES() && !use_binding_layout)
prog.BindFragData(0, "o_col0");
});
if (!prog)
@ -435,7 +434,7 @@ bool GPU_HW_OpenGL::CompilePrograms()
std::optional<GL::Program> prog = m_shader_cache.GetProgram(shadergen.GenerateScreenQuadVertexShader(), {},
shadergen.GenerateInterlacedFillFragmentShader(),
[this, use_binding_layout](GL::Program& prog) {
if (!m_is_gles && !use_binding_layout)
if (!IsGLES() && !use_binding_layout)
prog.BindFragData(0, "o_col0");
});
if (!prog)
@ -449,7 +448,7 @@ bool GPU_HW_OpenGL::CompilePrograms()
prog = m_shader_cache.GetProgram(shadergen.GenerateScreenQuadVertexShader(), {},
shadergen.GenerateVRAMReadFragmentShader(),
[this, use_binding_layout](GL::Program& prog) {
if (!m_is_gles && !use_binding_layout)
if (!IsGLES() && !use_binding_layout)
prog.BindFragData(0, "o_col0");
});
if (!prog)
@ -466,7 +465,7 @@ bool GPU_HW_OpenGL::CompilePrograms()
prog = m_shader_cache.GetProgram(shadergen.GenerateScreenQuadVertexShader(), {},
shadergen.GenerateVRAMCopyFragmentShader(),
[this, use_binding_layout](GL::Program& prog) {
if (!m_is_gles && !use_binding_layout)
if (!IsGLES() && !use_binding_layout)
prog.BindFragData(0, "o_col0");
});
if (!prog)
@ -494,7 +493,7 @@ bool GPU_HW_OpenGL::CompilePrograms()
prog = m_shader_cache.GetProgram(shadergen.GenerateScreenQuadVertexShader(), {},
shadergen.GenerateVRAMWriteFragmentShader(),
[this, use_binding_layout](GL::Program& prog) {
if (!m_is_gles && !use_binding_layout)
if (!IsGLES() && !use_binding_layout)
prog.BindFragData(0, "o_col0");
});
if (!prog)
@ -714,7 +713,7 @@ void GPU_HW_OpenGL::FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color)
{
const auto [r, g, b, a] = RGBA8ToFloat(color);
glClearColor(r, g, b, a);
glClearDepth(a);
IsGLES() ? glClearDepthf(a) : glClearDepth(a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetScissorFromDrawingArea();
}

View File

@ -48,6 +48,8 @@ private:
u32 num_uniform_buffer_updates;
};
ALWAYS_INLINE bool IsGLES() const { return (m_render_api == HostDisplay::RenderAPI::OpenGLES); }
std::tuple<s32, s32> ConvertToFramebufferCoordinates(s32 x, s32 y);
void SetCapabilities(HostDisplay* host_display);
@ -93,7 +95,6 @@ private:
u32 m_uniform_buffer_alignment = 1;
u32 m_max_texture_buffer_size = 0;
bool m_is_gles = false;
bool m_supports_texture_buffer = false;
bool m_supports_geometry_shaders = false;
};

View File

@ -394,8 +394,17 @@ void GPU_HW_ShaderGen::DeclareFragmentEntryPoint(
if (m_use_glsl_binding_layout)
{
for (u32 i = 0; i < num_color_outputs; i++)
ss << "layout(location = 0, index = " << i << ") out float4 o_col" << i << ";\n";
if (m_supports_dual_source_blend)
{
for (u32 i = 0; i < num_color_outputs; i++)
ss << "layout(location = 0, index = " << i << ") out float4 o_col" << i << ";\n";
}
else
{
Assert(num_color_outputs <= 1);
for (u32 i = 0; i < num_color_outputs; i++)
ss << "layout(location = 0" << i << ") out float4 o_col" << i << ";\n";
}
}
else
{