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/math/matrix_4x4.h>
|
||||||
|
#include <gfx/gl_capabilities.h>
|
||||||
|
|
||||||
#include "../drivers/gl_symlinks.h"
|
#include "../drivers/gl_symlinks.h"
|
||||||
#include "../video_coord_array.h"
|
#include "../video_coord_array.h"
|
||||||
|
@ -49,3 +50,28 @@ void gl_ff_matrix(const math_matrix_4x4 *mat)
|
||||||
glLoadMatrixf(ident.data);
|
glLoadMatrixf(ident.data);
|
||||||
#endif
|
#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);
|
bool gl_query_core_context_in_use(void);
|
||||||
void gl_ff_vertex(const struct video_coords *coords);
|
void gl_ff_vertex(const struct video_coords *coords);
|
||||||
void gl_ff_matrix(const math_matrix_4x4 *mat);
|
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
|
#endif
|
||||||
|
|
|
@ -606,12 +606,7 @@ static void gl_init_textures_reference(gl_t *gl, unsigned i,
|
||||||
if (gl->egl_images)
|
if (gl->egl_images)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef HAVE_OPENGLES2
|
loadTexture(GL_TEXTURE_2D,
|
||||||
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,
|
0, internal_fmt, gl->tex_w, gl->tex_h, 0, texture_type,
|
||||||
texture_fmt, gl->empty_buf ? gl->empty_buf : NULL);
|
texture_fmt, gl->empty_buf ? gl->empty_buf : NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -163,13 +163,7 @@ static bool gl_recreate_fbo(
|
||||||
glDeleteTextures(1, texture);
|
glDeleteTextures(1, texture);
|
||||||
glGenTextures(1, texture);
|
glGenTextures(1, texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
#if !defined(HAVE_OPENGLES2) && !defined(HAVE_PSGL)
|
loadTexture(GL_TEXTURE_2D,
|
||||||
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,
|
0, RARCH_GL_INTERNAL_FORMAT32,
|
||||||
fbo_rect->width,
|
fbo_rect->width,
|
||||||
fbo_rect->height,
|
fbo_rect->height,
|
||||||
|
@ -530,13 +524,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture)
|
||||||
if (fp_fbo && gl->has_fp_fbo)
|
if (fp_fbo && gl->has_fp_fbo)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i);
|
RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i);
|
||||||
#if !defined(HAVE_PSGL)
|
loadTexture(GL_TEXTURE_2D, 0, GL_RGBA32F,
|
||||||
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,
|
gl->fbo_rect[i].width, gl->fbo_rect[i].height,
|
||||||
0, GL_RGBA, GL_FLOAT, NULL);
|
0, GL_RGBA, GL_FLOAT, NULL);
|
||||||
}
|
}
|
||||||
|
@ -567,11 +555,7 @@ 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->has_srgb_fbo_gles3 ? GL_RGBA : GL_SRGB_ALPHA_EXT,
|
||||||
GL_UNSIGNED_BYTE, NULL);
|
GL_UNSIGNED_BYTE, NULL);
|
||||||
#else
|
#else
|
||||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
loadTexture(GL_TEXTURE_2D,
|
||||||
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,
|
0, GL_SRGB8_ALPHA8,
|
||||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
@ -588,11 +572,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture)
|
||||||
#else
|
#else
|
||||||
/* Avoid potential performance
|
/* Avoid potential performance
|
||||||
* reductions on particular platforms. */
|
* reductions on particular platforms. */
|
||||||
if (gl_check_capability(GL_CAPS_TEX_STORAGE))
|
loadTexture(GL_TEXTURE_2D,
|
||||||
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,
|
0, RARCH_GL_INTERNAL_FORMAT32,
|
||||||
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0,
|
||||||
RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, NULL);
|
RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, NULL);
|
||||||
|
|
|
@ -315,6 +315,10 @@ bool gl_check_capability(enum gl_capability_enum enum_idx)
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
case GL_CAPS_TEX_STORAGE_EXT:
|
||||||
|
if (gl_query_extension("EXT_texture_storage"))
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
case GL_CAPS_NONE:
|
case GL_CAPS_NONE:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -45,7 +45,8 @@ enum gl_capability_enum
|
||||||
GL_CAPS_FP_FBO,
|
GL_CAPS_FP_FBO,
|
||||||
GL_CAPS_BGRA8888,
|
GL_CAPS_BGRA8888,
|
||||||
GL_CAPS_GLES3_SUPPORTED,
|
GL_CAPS_GLES3_SUPPORTED,
|
||||||
GL_CAPS_TEX_STORAGE
|
GL_CAPS_TEX_STORAGE,
|
||||||
|
GL_CAPS_TEX_STORAGE_EXT
|
||||||
};
|
};
|
||||||
|
|
||||||
bool gl_check_error(char **error_string);
|
bool gl_check_error(char **error_string);
|
||||||
|
|
Loading…
Reference in New Issue