mirror of
https://github.com/libretro/RetroArch
synced 2025-03-26 02:37:23 +00:00
Reuse gl_load_texture_data some more
This commit is contained in:
parent
f19339eb38
commit
77f6b98aa9
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "../gl_common.h"
|
#include "../gl_common.h"
|
||||||
#include "../video_viewport.h"
|
#include "../video_viewport.h"
|
||||||
|
#include "../video_pixel_converter.h"
|
||||||
#include "../video_context_driver.h"
|
#include "../video_context_driver.h"
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
|
|
||||||
@ -87,17 +88,6 @@ static const GLfloat white_color[] = {
|
|||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline unsigned get_alignment(unsigned pitch)
|
|
||||||
{
|
|
||||||
if (pitch & 1)
|
|
||||||
return 1;
|
|
||||||
if (pitch & 2)
|
|
||||||
return 2;
|
|
||||||
if (pitch & 4)
|
|
||||||
return 4;
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool gl_query_extension(gl_t *gl, const char *ext)
|
static inline bool gl_query_extension(gl_t *gl, const char *ext)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@ -1084,7 +1074,7 @@ static void gl_update_input_size(gl_t *gl, unsigned width,
|
|||||||
if (clear)
|
if (clear)
|
||||||
{
|
{
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT,
|
glPixelStorei(GL_UNPACK_ALIGNMENT,
|
||||||
get_alignment(width * sizeof(uint32_t)));
|
video_pixel_get_alignment(width * sizeof(uint32_t)));
|
||||||
#if defined(HAVE_PSGL)
|
#if defined(HAVE_PSGL)
|
||||||
glBufferSubData(GL_TEXTURE_REFERENCE_BUFFER_SCE,
|
glBufferSubData(GL_TEXTURE_REFERENCE_BUFFER_SCE,
|
||||||
gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size,
|
gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size,
|
||||||
@ -1292,7 +1282,7 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(width * gl->base_size));
|
glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * gl->base_size));
|
||||||
|
|
||||||
/* Fallback for GLES devices without GL_BGRA_EXT. */
|
/* Fallback for GLES devices without GL_BGRA_EXT. */
|
||||||
if (gl->base_size == 4 && driver.gfx_use_rgba)
|
if (gl->base_size == 4 && driver.gfx_use_rgba)
|
||||||
@ -1355,7 +1345,7 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame,
|
|||||||
glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE);
|
glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE);
|
||||||
#else
|
#else
|
||||||
const GLvoid *data_buf = frame;
|
const GLvoid *data_buf = frame;
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(pitch));
|
glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(pitch));
|
||||||
|
|
||||||
if (gl->base_size == 2 && !gl->have_es2_compat)
|
if (gl->base_size == 2 && !gl->have_es2_compat)
|
||||||
{
|
{
|
||||||
@ -1403,7 +1393,7 @@ static void gl_pbo_async_readback(gl_t *gl)
|
|||||||
|
|
||||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT,
|
glPixelStorei(GL_PACK_ALIGNMENT,
|
||||||
get_alignment(gl->vp.width * sizeof(uint32_t)));
|
video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)));
|
||||||
|
|
||||||
/* Read asynchronously into PBO buffer. */
|
/* Read asynchronously into PBO buffer. */
|
||||||
RARCH_PERFORMANCE_INIT(async_readback);
|
RARCH_PERFORMANCE_INIT(async_readback);
|
||||||
@ -2789,20 +2779,13 @@ static bool gl_overlay_load(void *data,
|
|||||||
|
|
||||||
for (i = 0; i < num_images; i++)
|
for (i = 0; i < num_images; i++)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->overlay_tex[i]);
|
unsigned alignment = video_pixel_get_alignment(images[i].width
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
* sizeof(uint32_t));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT,
|
gl_load_texture_data(gl->overlay_tex[i],
|
||||||
get_alignment(images[i].width * sizeof(uint32_t)));
|
&images[i],
|
||||||
|
RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR,
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ?
|
alignment);
|
||||||
GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
|
||||||
images[i].width, images[i].height, 0,
|
|
||||||
driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
|
||||||
RARCH_GL_FORMAT32, images[i].pixels);
|
|
||||||
|
|
||||||
/* Default. Stretch to whole screen. */
|
/* Default. Stretch to whole screen. */
|
||||||
gl_overlay_tex_geom(gl, i, 0, 0, 1, 1);
|
gl_overlay_tex_geom(gl, i, 0, 0, 1, 1);
|
||||||
@ -3030,7 +3013,7 @@ static void gl_set_texture_frame(void *data,
|
|||||||
gl->menu_texture_alpha = alpha;
|
gl->menu_texture_alpha = alpha;
|
||||||
|
|
||||||
base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(width * base_size));
|
glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * base_size));
|
||||||
|
|
||||||
if (rgb32)
|
if (rgb32)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
void gl_load_texture_data(GLuint id,
|
void gl_load_texture_data(GLuint id,
|
||||||
const struct texture_image *img,
|
const struct texture_image *img,
|
||||||
enum gfx_wrap_type wrap_type,
|
enum gfx_wrap_type wrap_type,
|
||||||
enum texture_filter_type filter_type)
|
enum texture_filter_type filter_type,
|
||||||
|
unsigned alignment)
|
||||||
{
|
{
|
||||||
GLint mag_filter, min_filter;
|
GLint mag_filter, min_filter;
|
||||||
GLenum wrap;
|
GLenum wrap;
|
||||||
@ -63,7 +64,7 @@ void gl_load_texture_data(GLuint id,
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||||
|
|
||||||
#ifndef HAVE_PSGL
|
#ifndef HAVE_PSGL
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
||||||
#endif
|
#endif
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
@ -118,7 +119,7 @@ bool gl_load_luts(const struct video_shader *generic_shader,
|
|||||||
|
|
||||||
gl_load_texture_data(textures_lut[i], &img,
|
gl_load_texture_data(textures_lut[i], &img,
|
||||||
generic_shader->lut[i].wrap,
|
generic_shader->lut[i].wrap,
|
||||||
filter_type);
|
filter_type, 4);
|
||||||
texture_image_free(&img);
|
texture_image_free(&img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,8 @@ void gl_set_viewport(gl_t *gl, unsigned width, unsigned height,
|
|||||||
void gl_load_texture_data(GLuint id,
|
void gl_load_texture_data(GLuint id,
|
||||||
const struct texture_image *img,
|
const struct texture_image *img,
|
||||||
enum gfx_wrap_type wrap_type,
|
enum gfx_wrap_type wrap_type,
|
||||||
enum texture_filter_type filter_type);
|
enum texture_filter_type filter_type,
|
||||||
|
unsigned alignment);
|
||||||
|
|
||||||
bool gl_load_luts(const struct video_shader *generic_shader,
|
bool gl_load_luts(const struct video_shader *generic_shader,
|
||||||
GLuint *lut_textures);
|
GLuint *lut_textures);
|
||||||
|
@ -52,3 +52,14 @@ bool init_video_pixel_converter(unsigned size)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned video_pixel_get_alignment(unsigned pitch)
|
||||||
|
{
|
||||||
|
if (pitch & 1)
|
||||||
|
return 1;
|
||||||
|
if (pitch & 2)
|
||||||
|
return 2;
|
||||||
|
if (pitch & 4)
|
||||||
|
return 4;
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
@ -27,6 +27,8 @@ void deinit_pixel_converter(void);
|
|||||||
|
|
||||||
bool init_video_pixel_converter(unsigned size);
|
bool init_video_pixel_converter(unsigned size);
|
||||||
|
|
||||||
|
unsigned video_pixel_get_alignment(unsigned pitch);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "menu_texture.h"
|
#include "menu_texture.h"
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
|
#include "../gfx/video_pixel_converter.h"
|
||||||
#include "../gfx/video_thread_wrapper.h"
|
#include "../gfx/video_thread_wrapper.h"
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
@ -29,7 +30,7 @@ static void menu_texture_png_load_gl(struct texture_image *ti,
|
|||||||
/* Generate the OpenGL texture object */
|
/* Generate the OpenGL texture object */
|
||||||
glGenTextures(1, id);
|
glGenTextures(1, id);
|
||||||
gl_load_texture_data((GLuint)*id,
|
gl_load_texture_data((GLuint)*id,
|
||||||
ti, RARCH_WRAP_EDGE, filter_type);
|
ti, RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user