mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(GL) Refactor gl_check_fbo_dimensions
This commit is contained in:
parent
748556dd57
commit
fafd472b2f
@ -891,39 +891,50 @@ static void gl_check_fbo_dimensions(gl_t *gl)
|
|||||||
/* Check if we have to recreate our FBO textures. */
|
/* Check if we have to recreate our FBO textures. */
|
||||||
for (i = 0; i < gl->fbo_pass; i++)
|
for (i = 0; i < gl->fbo_pass; i++)
|
||||||
{
|
{
|
||||||
if (gl->fbo_rect[i].max_img_width > gl->fbo_rect[i].width ||
|
GLenum status;
|
||||||
gl->fbo_rect[i].max_img_height > gl->fbo_rect[i].height)
|
unsigned img_width, img_height, max, pow2_size;
|
||||||
{
|
bool check_dimensions = false;
|
||||||
/* Check proactively since we might suddently
|
struct gl_fbo_rect *fbo_rect = &gl->fbo_rect[i];
|
||||||
* get sizes of tex_w width or tex_h height. */
|
|
||||||
unsigned img_width = gl->fbo_rect[i].max_img_width;
|
|
||||||
unsigned img_height = gl->fbo_rect[i].max_img_height;
|
|
||||||
unsigned max = img_width > img_height ? img_width : img_height;
|
|
||||||
unsigned pow2_size = next_pow2(max);
|
|
||||||
|
|
||||||
gl->fbo_rect[i].width = gl->fbo_rect[i].height = pow2_size;
|
if (!fbo_rect)
|
||||||
|
continue;
|
||||||
|
|
||||||
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[i]);
|
check_dimensions =
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i]);
|
(fbo_rect->max_img_width > fbo_rect->width) ||
|
||||||
|
(fbo_rect->max_img_height > fbo_rect->height);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
if (!check_dimensions)
|
||||||
0, RARCH_GL_INTERNAL_FORMAT32,
|
continue;
|
||||||
gl->fbo_rect[i].width,
|
|
||||||
gl->fbo_rect[i].height,
|
|
||||||
0, RARCH_GL_TEXTURE_TYPE32,
|
|
||||||
RARCH_GL_FORMAT32, NULL);
|
|
||||||
|
|
||||||
glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER,
|
/* Check proactively since we might suddently
|
||||||
RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
* get sizes of tex_w width or tex_h height. */
|
||||||
gl->fbo_texture[i], 0);
|
img_width = fbo_rect->max_img_width;
|
||||||
|
img_height = fbo_rect->max_img_height;
|
||||||
|
max = img_width > img_height ? img_width : img_height;
|
||||||
|
pow2_size = next_pow2(max);
|
||||||
|
|
||||||
GLenum status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER);
|
fbo_rect->width = fbo_rect->height = pow2_size;
|
||||||
if (status != RARCH_GL_FRAMEBUFFER_COMPLETE)
|
|
||||||
RARCH_WARN("Failed to reinitialize FBO texture.\n");
|
|
||||||
|
|
||||||
RARCH_LOG("[GL]: Recreating FBO texture #%d: %ux%u\n",
|
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[i]);
|
||||||
i, gl->fbo_rect[i].width, gl->fbo_rect[i].height);
|
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i]);
|
||||||
}
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
|
0, RARCH_GL_INTERNAL_FORMAT32,
|
||||||
|
fbo_rect->width,
|
||||||
|
fbo_rect->height,
|
||||||
|
0, RARCH_GL_TEXTURE_TYPE32,
|
||||||
|
RARCH_GL_FORMAT32, NULL);
|
||||||
|
|
||||||
|
glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER,
|
||||||
|
RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||||
|
gl->fbo_texture[i], 0);
|
||||||
|
|
||||||
|
status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER);
|
||||||
|
if (status != RARCH_GL_FRAMEBUFFER_COMPLETE)
|
||||||
|
RARCH_WARN("Failed to reinitialize FBO texture.\n");
|
||||||
|
|
||||||
|
RARCH_LOG("[GL]: Recreating FBO texture #%d: %ux%u\n",
|
||||||
|
i, fbo_rect->width, fbo_rect->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user