mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-10 13:02:27 +00:00
Merge pull request #4242 from loganmc10/texstore
Simplify glTexImage2D/glTexStorage2D calls
This commit is contained in:
commit
c12fd9c125
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
#include <gfx/gl_capabilities.h>
|
||||
|
||||
#include "../drivers/gl_symlinks.h"
|
||||
#include "../video_coord_array.h"
|
||||
@ -49,3 +50,28 @@ void gl_ff_matrix(const math_matrix_4x4 *mat)
|
||||
glLoadMatrixf(ident.data);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function should only be used without mipmaps
|
||||
and when data == NULL */
|
||||
void loadTexture(GLenum target,
|
||||
GLint level,
|
||||
GLint internalFormat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLint border,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const GLvoid * data)
|
||||
{
|
||||
#ifndef HAVE_PSGL
|
||||
#ifdef HAVE_OPENGLES2
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE_EXT))
|
||||
glTexStorage2DEXT(target, 1, internalFormat, width, height);
|
||||
#else
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
||||
glTexStorage2D(target, 1, internalFormat, width, height);
|
||||
#endif
|
||||
else
|
||||
#endif
|
||||
glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
|
||||
}
|
||||
|
@ -177,5 +177,14 @@ static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type)
|
||||
bool gl_query_core_context_in_use(void);
|
||||
void gl_ff_vertex(const struct video_coords *coords);
|
||||
void gl_ff_matrix(const math_matrix_4x4 *mat);
|
||||
void loadTexture(GLenum target,
|
||||
GLint level,
|
||||
GLint internalFormat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLint border,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const GLvoid * data);
|
||||
|
||||
#endif
|
||||
|
@ -606,14 +606,9 @@ static void gl_init_textures_reference(gl_t *gl, unsigned i,
|
||||
if (gl->egl_images)
|
||||
return;
|
||||
|
||||
#ifndef HAVE_OPENGLES2
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, internal_fmt, gl->tex_w, gl->tex_h);
|
||||
else
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, internal_fmt, gl->tex_w, gl->tex_h, 0, texture_type,
|
||||
texture_fmt, gl->empty_buf ? gl->empty_buf : NULL);
|
||||
loadTexture(GL_TEXTURE_2D,
|
||||
0, internal_fmt, gl->tex_w, gl->tex_h, 0, texture_type,
|
||||
texture_fmt, gl->empty_buf ? gl->empty_buf : NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -163,18 +163,12 @@ static bool gl_recreate_fbo(
|
||||
glDeleteTextures(1, texture);
|
||||
glGenTextures(1, texture);
|
||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
#if !defined(HAVE_OPENGLES2) && !defined(HAVE_PSGL)
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, RARCH_GL_INTERNAL_FORMAT32,
|
||||
fbo_rect->width, fbo_rect->height);
|
||||
else
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, RARCH_GL_INTERNAL_FORMAT32,
|
||||
fbo_rect->width,
|
||||
fbo_rect->height,
|
||||
0, RARCH_GL_TEXTURE_TYPE32,
|
||||
RARCH_GL_FORMAT32, NULL);
|
||||
loadTexture(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,
|
||||
@ -530,15 +524,9 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture)
|
||||
if (fp_fbo && gl->has_fp_fbo)
|
||||
{
|
||||
RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i);
|
||||
#if !defined(HAVE_PSGL)
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height);
|
||||
else
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height,
|
||||
0, GL_RGBA, GL_FLOAT, NULL);
|
||||
loadTexture(GL_TEXTURE_2D, 0, GL_RGBA32F,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height,
|
||||
0, GL_RGBA, GL_FLOAT, NULL);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -567,14 +555,10 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture)
|
||||
gl->has_srgb_fbo_gles3 ? GL_RGBA : GL_SRGB_ALPHA_EXT,
|
||||
GL_UNSIGNED_BYTE, NULL);
|
||||
#else
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_SRGB8_ALPHA8,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height);
|
||||
else
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, GL_SRGB8_ALPHA8,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
loadTexture(GL_TEXTURE_2D,
|
||||
0, GL_SRGB8_ALPHA8,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -588,14 +572,10 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture)
|
||||
#else
|
||||
/* Avoid potential performance
|
||||
* reductions on particular platforms. */
|
||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, RARCH_GL_INTERNAL_FORMAT32,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height);
|
||||
else
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0, RARCH_GL_INTERNAL_FORMAT32,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
||||
RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, NULL);
|
||||
loadTexture(GL_TEXTURE_2D,
|
||||
0, RARCH_GL_INTERNAL_FORMAT32,
|
||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
||||
RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -315,6 +315,10 @@ bool gl_check_capability(enum gl_capability_enum enum_idx)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_TEX_STORAGE_EXT:
|
||||
if (gl_query_extension("EXT_texture_storage"))
|
||||
return true;
|
||||
break;
|
||||
case GL_CAPS_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -45,7 +45,8 @@ enum gl_capability_enum
|
||||
GL_CAPS_FP_FBO,
|
||||
GL_CAPS_BGRA8888,
|
||||
GL_CAPS_GLES3_SUPPORTED,
|
||||
GL_CAPS_TEX_STORAGE
|
||||
GL_CAPS_TEX_STORAGE,
|
||||
GL_CAPS_TEX_STORAGE_EXT
|
||||
};
|
||||
|
||||
bool gl_check_error(char **error_string);
|
||||
|
Loading…
Reference in New Issue
Block a user