private void initBloomStuff() { mBloomTextureID = loadTexture("textures/empty128.png"); mBloomVertTextureID = loadTexture("textures/empty128.png"); mBloomFBHeight = 128; mBloomFBWidth = 128; float blurSize = 1.0f; // Texel offset for blur filter kernel m_fTexelOffset = 1.0f / mBloomFBWidth / blurSize; ByteBuffer tmpFB, tmpRB; IntBuffer handle, renderbuffers; int result; tmpFB = ByteBuffer.allocateDirect(4); tmpFB.order(ByteOrder.nativeOrder()); handle = tmpFB.asIntBuffer(); GLES20.glGenFramebuffers(1, handle); framebufferHandle = handle.get(0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomTextureID); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferHandle); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mBloomTextureID, 0); checkGlError("FB 1"); tmpRB = ByteBuffer.allocateDirect(4); renderbuffers = tmpRB.asIntBuffer(); GLES20.glGenRenderbuffers(1, renderbuffers); checkGlError("FB 1 - glGenRenderbuffers"); depthbufferHandle = renderbuffers.get(0); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthbufferHandle); checkGlError("FB 1 - glBindRenderbuffer"); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, mBloomFBWidth, mBloomFBHeight); checkGlError("FB 1 - glRenderbufferStorage"); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthbufferHandle); checkGlError("FB 1 - glFramebufferRenderbuffer"); result = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (result != GLES20.GL_FRAMEBUFFER_COMPLETE) { Log.d(TAG, "Error creating framebufer 1: " + result); } else { Log.d(TAG, "Created framebufer 1: " + result); } GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); tmpFB = ByteBuffer.allocateDirect(4); tmpFB.order(ByteOrder.nativeOrder()); handle = tmpFB.asIntBuffer(); GLES20.glGenFramebuffers(1, handle); framebufferVertHandle = handle.get(0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomVertTextureID); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferVertHandle); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mBloomVertTextureID, 0); checkGlError("FB 2"); tmpRB = ByteBuffer.allocateDirect(4); renderbuffers = tmpRB.asIntBuffer(); GLES20.glGenRenderbuffers(1, renderbuffers); checkGlError("FB 2 - glGenRenderbuffers"); depthbufferVertHandle = renderbuffers.get(0); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthbufferVertHandle); checkGlError("FB 2 - glBindRenderbuffer"); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, mBloomFBWidth, mBloomFBHeight); checkGlError("FB 2 - glRenderbufferStorage"); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthbufferVertHandle); checkGlError("FB 2 - glFramebufferRenderbuffer"); result = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (result != GLES20.GL_FRAMEBUFFER_COMPLETE) { Log.d(TAG, "Error creating framebufer 2: " + result); } else { Log.d(TAG, "Created framebufer 2: " + result); } GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); mTriangleVerticesVignette = ByteBuffer.allocateDirect(mQuadTriangles.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer(); mTriangleVerticesVignette.put(mQuadTriangles).position(0); }
GLES20.glUseProgram(mProgram); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mStemTextureID); drawBird(); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mSphereTextureID); drawSphere(); GLES20.glViewport(0, 0, mBloomFBWidth, mBloomFBHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferHandle); // GLES20.glBindRenderbuffer(GLES20.GL_FRAMEBUFFER, depthbufferHandle); GLES20.glClearColor(1.0f, 0.5f, 0.5f, 1.0f); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mStemTextureID); drawBird(); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mSphereTextureID); drawSphere(); GLES20.glViewport(0, 0, screenWidth, screenHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); // GLES20.glBindRenderbuffer(GLES20.GL_FRAMEBUFFER, 0);
GLES20.glUseProgram(mBloomProgram); GLES20.glUniform1i(mBloom_sTexture, 0); GLES20.glUniform1f(mBloom_bloomFactor, 0.8f); GLES20.glActiveTexture(GL10.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomTextureID); GLES20.glViewport(0, 0, mBloomFBWidth, mBloomFBHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferVertHandle); GLES20.glUniform1f(mBloom_TexelOffsetX, m_fTexelOffset); GLES20.glUniform1f(mBloom_TexelOffsetY, 0.0f); GLES20.glActiveTexture(GL10.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomTextureID); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); drawBloom(); GLES20.glViewport(0, 0, screenWidth, screenHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); GLES20.glActiveTexture(GL10.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomVertTextureID); GLES20.glViewport(0, 0, mBloomFBWidth, mBloomFBHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferHandle); GLES20.glUniform1f(mBloom_TexelOffsetX, 0.0f); GLES20.glUniform1f(mBloom_TexelOffsetY, m_fTexelOffset); GLES20.glActiveTexture(GL10.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomVertTextureID); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); drawBloom(); GLES20.glViewport(0, 0, screenWidth, screenHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); GLES20.glActiveTexture(GL10.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomTextureID); GLES20.glViewport(0, 0, mBloomFBWidth, mBloomFBHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferVertHandle); GLES20.glUniform1f(mBloom_TexelOffsetX, m_fTexelOffset / 2); GLES20.glUniform1f(mBloom_TexelOffsetY, m_fTexelOffset / 2); GLES20.glActiveTexture(GL10.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mBloomTextureID); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); drawBloom(); GLES20.glViewport(0, 0, screenWidth, screenHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
We have identified the issue and will have a fix in our next driver release; how soon this gets picked up by device manufacturers downstream is somewhat out of our control unfortunately.We have a workaround from the application side for existing devices, which is to call glViewport after glBindFramebuffer.Hope that helps and thanks again for reporting.Iso