diff --git a/client/render/gl_postprocess.cpp b/client/render/gl_postprocess.cpp index 7361341f2..047c86a2c 100644 --- a/client/render/gl_postprocess.cpp +++ b/client/render/gl_postprocess.cpp @@ -794,13 +794,13 @@ void RenderBloom() int w = glState.width; int h = glState.height; glsl_program_t *shader = RI->currentshader; - const int mipCount = 1 + floor(log2(Q_max(glState.width, glState.height))); + const int mipCount = GL_TextureMipCount(w, h); // render and blur mips - for (int i = 0; i < mipCount; i++) + for (int i = 0; i < (mipCount - 1); i++) { - w /= 2; - h /= 2; + w = Q_max(1, w / 2); + h = Q_max(1, h / 2); pglViewport(0, 0, w, h); for (int j = 0; j < shader->numUniforms; j++) diff --git a/client/render/gl_rmisc.cpp b/client/render/gl_rmisc.cpp index acfe7dc53..185fabddf 100644 --- a/client/render/gl_rmisc.cpp +++ b/client/render/gl_rmisc.cpp @@ -810,17 +810,18 @@ void GL_InitTempScreenFBO() GL_CheckFBOStatus(tr.screen_hdr_fbo); // generate screen fbo texture mips - const int mipCount = 1 + floor(log2(Q_max(glState.width, glState.height))); + const int mipCount = GL_TextureMipCount(glState.width, glState.height); + const int fboCount = mipCount - 1; // don't take mip 0 into account if (tr.screen_hdr_fbo_mip) { - pglDeleteFramebuffers(mipCount, tr.screen_hdr_fbo_mip); + pglDeleteFramebuffers(fboCount, tr.screen_hdr_fbo_mip); delete[] tr.screen_hdr_fbo_mip; tr.screen_hdr_fbo_mip = nullptr; } - tr.screen_hdr_fbo_mip = new uint32_t[mipCount]; - for (int i = 0; i < mipCount; i++) + tr.screen_hdr_fbo_mip = new uint32_t[fboCount]; + for (int i = 0; i < fboCount; i++) { pglGenFramebuffers(1, &tr.screen_hdr_fbo_mip[i]); pglBindFramebuffer(GL_FRAMEBUFFER_EXT, tr.screen_hdr_fbo_mip[i]);