From c651919ffb9af4e95c6baa8fdc2c5a24e24d115f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Thu, 12 Mar 2015 13:38:33 -0700 Subject: [PATCH] Add extra state reset for draw buffers indexed state. Some drivers have bugs with GL_EXT_draw_buffers_indexed state. Common functions, e.g. glBlendFunc(), fail to reset indexed state. These extra function calls make sure that state gets reset to initial values. Change-Id: I06b709ef81efb0ecfdbe1f88ac94dca49f39d7dc --- framework/opengl/gluStateReset.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/framework/opengl/gluStateReset.cpp b/framework/opengl/gluStateReset.cpp index ac2962b..3902bd0 100644 --- a/framework/opengl/gluStateReset.cpp +++ b/framework/opengl/gluStateReset.cpp @@ -306,6 +306,26 @@ void resetStateES (const RenderContext& renderCtx) GLU_EXPECT_NO_ERROR(gl.getError(), "Texture state reset failed"); } + // Resetting state using non-indexed variants should be enough, but some + // implementations have bugs so we need to make sure indexed state gets + // set back to initial values. + if (ctxInfo->isExtensionSupported("GL_EXT_draw_buffers_indexed")) + { + int numDrawBuffers = 0; + + gl.getIntegerv(GL_MAX_DRAW_BUFFERS, &numDrawBuffers); + + for (int drawBufferNdx = 0; drawBufferNdx < numDrawBuffers; drawBufferNdx++) + { + gl.disablei (GL_BLEND, drawBufferNdx); + gl.blendFunci (drawBufferNdx, GL_ONE, GL_ZERO); + gl.blendEquationi (drawBufferNdx, GL_FUNC_ADD); + gl.colorMaski (drawBufferNdx, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } + + GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to reset indexed draw buffer state"); + } + // Pixel operations. { const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget(); -- 2.7.4