diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index ab352c2cd..2166d94b6 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -6509,7 +6509,9 @@ namespace bgfx { namespace gl uint32_t fragData = 0; - if (!bx::findIdentifierMatch(code, "gl_FragData").isEmpty() ) + bool patchedFragData = s_renderGL->m_gles3 && !bx::findIdentifierMatch(code, "bgfx_FragData").isEmpty(); + + if (!patchedFragData && !bx::findIdentifierMatch(code, "gl_FragData").isEmpty() ) { for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii) { @@ -6540,16 +6542,22 @@ namespace bgfx { namespace gl if (0 != fragData) { - bx::write(&writer, &err, "out vec4 bgfx_FragData[%d];\n", fragData); - bx::write(&writer, "#define gl_FragData bgfx_FragData\n", &err); + if (!patchedFragData) + { + bx::write(&writer, &err, "out vec4 bgfx_FragData[%d];\n", fragData); + bx::write(&writer, "#define gl_FragData bgfx_FragData\n", &err); + } } - else + else if (!patchedFragData) { - bx::write(&writer - , "out vec4 bgfx_FragColor;\n" - "#define gl_FragColor bgfx_FragColor\n" - , &err - ); + if (bx::findIdentifierMatch(code, "bgfx_FragColor").isEmpty() ) + { + bx::write(&writer + , "out vec4 bgfx_FragColor;\n" + "#define gl_FragColor bgfx_FragColor\n" + , &err + ); + } } } else diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 0c81240c1..8cdc23266 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -1728,8 +1728,8 @@ namespace bgfx } if (hasFragColor) { - preprocessor.writef("#define gl_FragColor bgfx_FragData0\n"); - preprocessor.writef("out mediump vec4 bgfx_FragData0;\n"); + preprocessor.writef("#define gl_FragColor bgfx_FragColor\n"); + preprocessor.writef("out mediump vec4 bgfx_FragColor;\n"); } else if (numFragData) {