(gl core shaders) Simplification

This commit is contained in:
twinaphex 2019-04-24 22:10:21 +02:00
parent 3225876f0b
commit 51a69dff44

View File

@ -679,10 +679,13 @@ void Framebuffer::set_size(const Size2D &size_, GLenum format_)
void Framebuffer::init() void Framebuffer::init()
{ {
GLenum status;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
if (image != 0) if (image != 0)
{ {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); glFramebufferTexture2D(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
glDeleteTextures(1, &image); glDeleteTextures(1, &image);
} }
@ -704,12 +707,16 @@ void Framebuffer::init()
format, format,
size.width, size.height); size.width, size.height);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, image, 0); glFramebufferTexture2D(GL_FRAMEBUFFER,
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER); GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, image, 0);
bool fallback = false;
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
complete = true;
if (status != GL_FRAMEBUFFER_COMPLETE) if (status != GL_FRAMEBUFFER_COMPLETE)
{ {
complete = false;
switch (status) switch (status)
{ {
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
@ -721,34 +728,27 @@ void Framebuffer::init()
break; break;
case GL_FRAMEBUFFER_UNSUPPORTED: case GL_FRAMEBUFFER_UNSUPPORTED:
RARCH_ERR("[GLCore]: Unsupported FBO, falling back to RGBA8.\n"); {
fallback = true; unsigned levels;
break;
}
complete = false; RARCH_ERR("[GLCore]: Unsupported FBO, falling back to RGBA8.\n");
}
else
complete = true;
if (fallback) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
{ glDeleteTextures(1, &image);
unsigned levels; glGenTextures(1, &image);
glBindTexture(GL_TEXTURE_2D, image);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); levels = num_miplevels(size.width, size.height);
glDeleteTextures(1, &image); if (max_levels < levels)
glGenTextures(1, &image); levels = max_levels;
glBindTexture(GL_TEXTURE_2D, image); glTexStorage2D(GL_TEXTURE_2D, levels,
levels = num_miplevels(size.width, size.height);
if (max_levels < levels)
levels = max_levels;
glTexStorage2D(GL_TEXTURE_2D, levels,
GL_RGBA8, GL_RGBA8,
size.width, size.height); size.width, size.height);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, image, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, image, 0);
status = glCheckFramebufferStatus(GL_FRAMEBUFFER); complete = glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
complete = status == GL_FRAMEBUFFER_COMPLETE; }
break;
}
} }
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);