diff --git a/include/renderer_gl/gl_driver.hpp b/include/renderer_gl/gl_driver.hpp index c8a1bf85..a15c061f 100644 --- a/include/renderer_gl/gl_driver.hpp +++ b/include/renderer_gl/gl_driver.hpp @@ -4,6 +4,9 @@ // Stuff like whether specific extensions are supported, and potentially things like OpenGL context information namespace OpenGL { struct Driver { - bool supportsFbFetch = false; + bool supportsExtFbFetch = false; + bool supportsArmFbFetch = false; + + bool supportFbFetch() const { return supportsExtFbFetch || supportsArmFbFetch; } }; } // namespace OpenGL \ No newline at end of file diff --git a/src/core/PICA/shader_gen_glsl.cpp b/src/core/PICA/shader_gen_glsl.cpp index b77f03dc..de406f53 100644 --- a/src/core/PICA/shader_gen_glsl.cpp +++ b/src/core/PICA/shader_gen_glsl.cpp @@ -108,11 +108,24 @@ std::string FragmentGenerator::generate(const FragmentConfig& config, void* driv } // For GLES we need to enable & use the framebuffer fetch extension in order to emulate logic ops - const bool emitLogicOps = api == API::GLES && config.outConfig.logicOpMode != PICA::LogicOpMode::Copy && driverInfo != nullptr && - static_cast(driverInfo)->supportsFbFetch; + bool emitLogicOps = api == API::GLES && config.outConfig.logicOpMode != PICA::LogicOpMode::Copy && driverInfo != nullptr; if (emitLogicOps) { - ret += "\n#extension GL_EXT_shader_framebuffer_fetch : enable\n"; + auto driver = static_cast(driverInfo); + + // If the driver does not support framebuffer fetch at all, don't emit logic op code + if (!driver->supportFbFetch()) { + emitLogicOps = false; + } + + // Figure out which fb fetch extension we have and enable it + else { + if (driver->supportsExtFbFetch) { + ret += "\n#extension GL_EXT_shader_framebuffer_fetch : enable\n"; + } else if (driver->supportsArmFbFetch) { + ret += "\n#extension GL_ARM_shader_framebuffer_fetch : enable\n#define gl_LastFragData gl_LastFragColorARM\n"; + } + } } bool unimplementedFlag = false; diff --git a/src/core/renderer_gl/renderer_gl.cpp b/src/core/renderer_gl/renderer_gl.cpp index 7c916122..ecbee3a2 100644 --- a/src/core/renderer_gl/renderer_gl.cpp +++ b/src/core/renderer_gl/renderer_gl.cpp @@ -168,7 +168,8 @@ void RendererGL::initGraphicsContextInternal() { reset(); // Populate our driver info structure - driverInfo.supportsFbFetch = GLAD_GL_EXT_shader_framebuffer_fetch != 0; + driverInfo.supportsExtFbFetch = GLAD_GL_EXT_shader_framebuffer_fetch != 0; + driverInfo.supportsArmFbFetch = GLAD_GL_ARM_shader_framebuffer_fetch != 0; // Initialize the default vertex shader used with shadergen std::string defaultShadergenVSSource = fragShaderGen.getDefaultVertexShader();