mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
Create video driver poke load_texture / unload_texture
This commit is contained in:
parent
f64fc93c44
commit
aa488dda25
@ -574,13 +574,6 @@ OBJ += gfx/video_context_driver.o \
|
||||
libretro-common/gfx/math/matrix_4x4.o \
|
||||
libretro-common/gfx/math/matrix_3x3.o
|
||||
|
||||
ifneq ($(findstring Win32,$(OS)),)
|
||||
OBJ += gfx/video_texture.o
|
||||
else
|
||||
OBJ += gfx/video_texture_c.o
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(HAVE_GL_CONTEXT), 1)
|
||||
DEFINES += -DHAVE_OPENGL -DHAVE_GLSL
|
||||
OBJ += gfx/drivers/gl.o \
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <glsym/glsym.h>
|
||||
|
||||
#include "../camera_driver.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
|
||||
typedef struct android_camera
|
||||
{
|
||||
@ -151,7 +150,7 @@ static void android_camera_stop(void *data)
|
||||
androidcamera->onCameraStop);
|
||||
|
||||
if (androidcamera->tex)
|
||||
video_texture_unload(TEXTURE_BACKEND_OPENGL, (uintptr_t*)&androidcamera->tex);
|
||||
video_driver_texture_unload((uintptr_t*)&androidcamera->tex);
|
||||
}
|
||||
|
||||
static bool android_camera_poll(void *data,
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
#include "gl_common.h"
|
||||
#include "../video_texture.h"
|
||||
|
||||
void gl_ff_vertex(const void *data)
|
||||
{
|
||||
|
@ -1686,7 +1686,62 @@ static void d3d_set_menu_texture_enable(void *data,
|
||||
}
|
||||
#endif
|
||||
|
||||
static void video_texture_load_d3d(struct texture_image *ti,
|
||||
enum texture_filter_type filter_type,
|
||||
uintptr_t *id)
|
||||
{
|
||||
id = (uintptr_t*)d3d_texture_new(NULL, NULL,
|
||||
ti->width, ti->height, 1,
|
||||
0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static int video_texture_load_wrap_d3d_mipmap(void *data)
|
||||
{
|
||||
return video_texture_load_d3d(data, TEXTURE_BACKEND_DIRECT3D,
|
||||
TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||
}
|
||||
|
||||
static int video_texture_load_wrap_d3d(void *data)
|
||||
{
|
||||
return video_texture_load_d3d(data, TEXTURE_BACKEND_DIRECT3D,
|
||||
TEXTURE_FILTER_LINEAR);
|
||||
}
|
||||
|
||||
static unsigned d3d_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
if (threaded)
|
||||
{
|
||||
custom_command_method_t func = video_texture_load_wrap_d3d;
|
||||
|
||||
switch (filter_type)
|
||||
{
|
||||
#ifdef HAVE_D3D
|
||||
case TEXTURE_FILTER_MIPMAP_LINEAR:
|
||||
case TEXTURE_FILTER_MIPMAP_NEAREST:
|
||||
func = video_texture_load_wrap_d3d_mipmap;
|
||||
break;
|
||||
default:
|
||||
func = video_texture_load_wrap_d3d;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return rarch_threaded_video_texture_load(data, func);
|
||||
}
|
||||
|
||||
return video_texture_load_d3d(data, type, filter_type);
|
||||
}
|
||||
|
||||
static void d3d_unload_texture(void *data, uintptr_t *id)
|
||||
{
|
||||
d3d_texture_free((LPDIRECT3DTEXTURE)id);
|
||||
}
|
||||
|
||||
static const video_poke_interface_t d3d_poke_interface = {
|
||||
d3d_load_texture,
|
||||
d3d_unload_texture,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -825,8 +825,9 @@ static void ctr_viewport_info(void* data, struct video_viewport* vp)
|
||||
*vp = ctr->vp;
|
||||
}
|
||||
|
||||
static const video_poke_interface_t ctr_poke_interface =
|
||||
{
|
||||
static const video_poke_interface_t ctr_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
ctr_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -604,6 +604,8 @@ static void dispmanx_set_aspect_ratio (void *data, unsigned aspect_ratio_idx)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t dispmanx_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* set_video_mode */
|
||||
NULL, /* set_filtering */
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -1486,6 +1486,8 @@ static void exynos_show_mouse(void *data, bool state)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t exynos_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* set_video_mode */
|
||||
NULL, /* set_filtering */
|
||||
NULL, /* get_video_output_size */
|
||||
|
141
gfx/drivers/gl.c
141
gfx/drivers/gl.c
@ -38,6 +38,12 @@
|
||||
#include "../../libretro.h"
|
||||
#include "../../general.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../common/gl_common.h"
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#include "../video_thread_wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -45,7 +51,6 @@
|
||||
|
||||
#include "../font_driver.h"
|
||||
#include "../video_context_driver.h"
|
||||
#include "../video_texture.h"
|
||||
|
||||
#ifdef HAVE_GLSL
|
||||
#include "../drivers_shader/shader_glsl.h"
|
||||
@ -3409,7 +3414,141 @@ static void gl_get_video_output_next(void *data)
|
||||
gfx_ctx_get_video_output_next();
|
||||
}
|
||||
|
||||
void gl_load_texture_data(uint32_t id_data,
|
||||
enum gfx_wrap_type wrap_type,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned alignment,
|
||||
unsigned width, unsigned height,
|
||||
const void *frame, unsigned base_size)
|
||||
{
|
||||
GLint mag_filter, min_filter;
|
||||
bool want_mipmap = false;
|
||||
bool use_rgba = video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL);
|
||||
bool rgb32 = (base_size == (sizeof(uint32_t)));
|
||||
GLenum wrap = gl_wrap_type_to_enum(wrap_type);
|
||||
GLuint id = (GLuint)id_data;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap);
|
||||
|
||||
#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC)
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR)
|
||||
filter_type = TEXTURE_FILTER_LINEAR;
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST)
|
||||
filter_type = TEXTURE_FILTER_NEAREST;
|
||||
#endif
|
||||
|
||||
switch (filter_type)
|
||||
{
|
||||
case TEXTURE_FILTER_MIPMAP_LINEAR:
|
||||
min_filter = GL_LINEAR_MIPMAP_NEAREST;
|
||||
mag_filter = GL_LINEAR;
|
||||
want_mipmap = true;
|
||||
break;
|
||||
case TEXTURE_FILTER_MIPMAP_NEAREST:
|
||||
min_filter = GL_NEAREST_MIPMAP_NEAREST;
|
||||
mag_filter = GL_NEAREST;
|
||||
want_mipmap = true;
|
||||
break;
|
||||
case TEXTURE_FILTER_NEAREST:
|
||||
min_filter = GL_NEAREST;
|
||||
mag_filter = GL_NEAREST;
|
||||
break;
|
||||
case TEXTURE_FILTER_LINEAR:
|
||||
default:
|
||||
min_filter = GL_LINEAR;
|
||||
mag_filter = GL_LINEAR;
|
||||
break;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||
width, height, 0,
|
||||
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
(rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame);
|
||||
|
||||
if (want_mipmap)
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
static void video_texture_load_gl(
|
||||
struct texture_image *ti,
|
||||
enum texture_filter_type filter_type,
|
||||
uintptr_t *id)
|
||||
{
|
||||
/* Generate the OpenGL texture object */
|
||||
glGenTextures(1, (GLuint*)id);
|
||||
gl_load_texture_data((GLuint)*id,
|
||||
RARCH_WRAP_EDGE, filter_type,
|
||||
4 /* TODO/FIXME - dehardcode */,
|
||||
ti->width, ti->height, ti->pixels,
|
||||
sizeof(uint32_t) /* TODO/FIXME - dehardcode */
|
||||
);
|
||||
}
|
||||
|
||||
static int video_texture_load_wrap_gl_mipmap(void *data)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
video_texture_load_gl(data, TEXTURE_FILTER_MIPMAP_LINEAR, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static int video_texture_load_wrap_gl(void *data)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
video_texture_load_gl(data, TEXTURE_FILTER_LINEAR, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static unsigned gl_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
|
||||
if (threaded)
|
||||
{
|
||||
custom_command_method_t func = video_texture_load_wrap_gl;
|
||||
|
||||
switch (filter_type)
|
||||
{
|
||||
case TEXTURE_FILTER_MIPMAP_LINEAR:
|
||||
case TEXTURE_FILTER_MIPMAP_NEAREST:
|
||||
func = video_texture_load_wrap_gl_mipmap;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rarch_threaded_video_texture_load(data, func);
|
||||
}
|
||||
|
||||
video_texture_load_gl(data, filter_type, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static void gl_unload_texture(void *data, uintptr_t *id)
|
||||
{
|
||||
if (!id)
|
||||
return;
|
||||
|
||||
glDeleteTextures(1, (const GLuint*)id);
|
||||
*id = 0;
|
||||
}
|
||||
|
||||
static const video_poke_interface_t gl_poke_interface = {
|
||||
gl_load_texture,
|
||||
gl_unload_texture,
|
||||
gl_set_video_mode,
|
||||
NULL,
|
||||
gl_get_video_output_size,
|
||||
|
@ -1338,6 +1338,8 @@ static void gx_get_video_output_next(void *data)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t gx_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
gx_set_video_mode,
|
||||
NULL,
|
||||
gx_get_video_output_size,
|
||||
|
@ -1134,6 +1134,8 @@ static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen
|
||||
}
|
||||
|
||||
static const video_poke_interface_t omap_gfx_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* set_filtering */
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -838,6 +838,8 @@ static void psp_viewport_info(void *data, struct video_viewport *vp)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t psp_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
psp_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -744,6 +744,8 @@ static void sdl2_grab_mouse_toggle(void *data)
|
||||
#endif
|
||||
|
||||
static video_poke_interface_t sdl2_video_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
sdl2_poke_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -512,6 +512,8 @@ static void sdl_grab_mouse_toggle(void *data)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t sdl_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
sdl_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -924,6 +924,8 @@ static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t sunxi_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* set_video_mode */
|
||||
NULL, /* set_filtering */
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -595,6 +595,8 @@ static void vita_set_texture_enable(void *data, bool state, bool full_screen)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t vita_poke_interface = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
vita_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "../common/gl_common.h"
|
||||
#include "../font_driver.h"
|
||||
#include "../video_shader_driver.h"
|
||||
#include "../video_texture.h"
|
||||
|
||||
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
|
||||
|
||||
@ -186,7 +185,7 @@ static void gl_raster_font_free_font(void *data)
|
||||
if (font->font_driver && font->font_data)
|
||||
font->font_driver->free(font->font_data);
|
||||
|
||||
video_texture_unload(TEXTURE_BACKEND_OPENGL, (uintptr_t*)&font->tex);
|
||||
video_driver_texture_unload((uintptr_t*)&font->tex);
|
||||
free(font);
|
||||
}
|
||||
|
||||
|
@ -1941,3 +1941,38 @@ uintptr_t video_driver_window_get(void)
|
||||
{
|
||||
return video_driver_window;
|
||||
}
|
||||
|
||||
bool video_driver_texture_load(void *data,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned *id)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
if (!video_driver_poke || !video_driver_poke->load_texture)
|
||||
return false;
|
||||
|
||||
*id = video_driver_poke->load_texture(video_driver_data, data,
|
||||
#ifdef HAVE_THREADS
|
||||
settings->video.threaded && !hw_render->context_type,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
filter_type);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool video_driver_texture_unload(uintptr_t *id)
|
||||
{
|
||||
if (!video_driver_poke || !video_driver_poke->unload_texture)
|
||||
return false;
|
||||
|
||||
video_driver_poke->unload_texture(video_driver_data, id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -190,6 +190,9 @@ typedef struct video_info
|
||||
|
||||
typedef struct video_poke_interface
|
||||
{
|
||||
unsigned (*load_texture)(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type);
|
||||
void (*unload_texture)(void *data, uintptr_t *id);
|
||||
void (*set_video_mode)(void *data, unsigned width, unsigned height, bool fullscreen);
|
||||
void (*set_filtering)(void *data, unsigned index, bool smooth);
|
||||
void (*get_video_output_size)(void *data, unsigned *width, unsigned *height);
|
||||
@ -524,6 +527,21 @@ void video_driver_display_set(uintptr_t idx);
|
||||
|
||||
void video_driver_window_set(uintptr_t idx);
|
||||
|
||||
bool video_driver_texture_load(void *data,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned *id);
|
||||
|
||||
bool video_driver_texture_unload(uintptr_t *id);
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
void gl_load_texture_data(uint32_t id,
|
||||
enum gfx_wrap_type wrap_type,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned alignment,
|
||||
unsigned width, unsigned height,
|
||||
const void *frame,
|
||||
unsigned base_size);
|
||||
#endif
|
||||
|
||||
extern video_driver_t video_gl;
|
||||
extern video_driver_t video_psp1;
|
||||
|
@ -1 +0,0 @@
|
||||
#include "video_texture_c.c"
|
@ -1,55 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2015 - Jean-André Santoni
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _VIDEO_TEXTURE_H
|
||||
#define _VIDEO_TEXTURE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum texture_backend_type
|
||||
{
|
||||
TEXTURE_BACKEND_DEFAULT = 0,
|
||||
TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_BACKEND_DIRECT3D
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "common/gl_common.h"
|
||||
|
||||
void gl_load_texture_data(GLuint id,
|
||||
enum gfx_wrap_type wrap_type,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned alignment,
|
||||
unsigned width, unsigned height,
|
||||
const void *frame,
|
||||
unsigned base_size);
|
||||
#endif
|
||||
|
||||
unsigned video_texture_load(void *data,
|
||||
enum texture_backend_type type,
|
||||
enum texture_filter_type filter_type);
|
||||
|
||||
void video_texture_unload(enum texture_backend_type type, uintptr_t *id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,272 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2015 - Jean-André Santoni
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <formats/image.h>
|
||||
|
||||
#include "video_driver.h"
|
||||
#include "video_texture.h"
|
||||
#include "video_thread_wrapper.h"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void gl_load_texture_data(GLuint id,
|
||||
enum gfx_wrap_type wrap_type,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned alignment,
|
||||
unsigned width, unsigned height,
|
||||
const void *frame, unsigned base_size)
|
||||
{
|
||||
GLint mag_filter, min_filter;
|
||||
bool want_mipmap = false;
|
||||
bool use_rgba = video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL);
|
||||
bool rgb32 = (base_size == (sizeof(uint32_t)));
|
||||
GLenum wrap = gl_wrap_type_to_enum(wrap_type);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap);
|
||||
|
||||
#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC)
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR)
|
||||
filter_type = TEXTURE_FILTER_LINEAR;
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST)
|
||||
filter_type = TEXTURE_FILTER_NEAREST;
|
||||
#endif
|
||||
|
||||
switch (filter_type)
|
||||
{
|
||||
case TEXTURE_FILTER_MIPMAP_LINEAR:
|
||||
min_filter = GL_LINEAR_MIPMAP_NEAREST;
|
||||
mag_filter = GL_LINEAR;
|
||||
want_mipmap = true;
|
||||
break;
|
||||
case TEXTURE_FILTER_MIPMAP_NEAREST:
|
||||
min_filter = GL_NEAREST_MIPMAP_NEAREST;
|
||||
mag_filter = GL_NEAREST;
|
||||
want_mipmap = true;
|
||||
break;
|
||||
case TEXTURE_FILTER_NEAREST:
|
||||
min_filter = GL_NEAREST;
|
||||
mag_filter = GL_NEAREST;
|
||||
break;
|
||||
case TEXTURE_FILTER_LINEAR:
|
||||
default:
|
||||
min_filter = GL_LINEAR;
|
||||
mag_filter = GL_LINEAR;
|
||||
break;
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||
width, height, 0,
|
||||
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
(rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame);
|
||||
|
||||
if (want_mipmap)
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void video_texture_png_load_gl(struct texture_image *ti,
|
||||
enum texture_filter_type filter_type,
|
||||
uintptr_t *id)
|
||||
{
|
||||
/* Generate the OpenGL texture object */
|
||||
glGenTextures(1, (GLuint*)id);
|
||||
gl_load_texture_data((GLuint)*id,
|
||||
RARCH_WRAP_EDGE, filter_type,
|
||||
4 /* TODO/FIXME - dehardcode */,
|
||||
ti->width, ti->height, ti->pixels,
|
||||
sizeof(uint32_t) /* TODO/FIXME - dehardcode */
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_D3D
|
||||
#include "common/d3d_common.h"
|
||||
|
||||
static void video_texture_png_load_d3d(struct texture_image *ti,
|
||||
enum texture_filter_type filter_type,
|
||||
uintptr_t *id)
|
||||
{
|
||||
id = (uintptr_t*)d3d_texture_new(NULL, NULL,
|
||||
ti->width, ti->height, 1,
|
||||
0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0,
|
||||
NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned video_texture_png_load(void *data,
|
||||
enum texture_backend_type type,
|
||||
enum texture_filter_type filter_type)
|
||||
{
|
||||
uintptr_t id = 0;
|
||||
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TEXTURE_BACKEND_OPENGL:
|
||||
#ifdef HAVE_OPENGL
|
||||
video_texture_png_load_gl((struct texture_image*)data, filter_type, &id);
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DIRECT3D:
|
||||
#ifdef HAVE_D3D
|
||||
video_texture_png_load_d3d((struct texture_image*)data, filter_type, &id);
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DEFAULT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
static int video_texture_png_load_wrap(void *data)
|
||||
{
|
||||
return video_texture_png_load(data, TEXTURE_BACKEND_DEFAULT,
|
||||
TEXTURE_FILTER_LINEAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
static int video_texture_png_load_wrap_gl_mipmap(void *data)
|
||||
{
|
||||
return video_texture_png_load(data, TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||
}
|
||||
|
||||
static int video_texture_png_load_wrap_gl(void *data)
|
||||
{
|
||||
return video_texture_png_load(data, TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_FILTER_LINEAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_D3D
|
||||
static int video_texture_png_load_wrap_d3d_mipmap(void *data)
|
||||
{
|
||||
return video_texture_png_load(data, TEXTURE_BACKEND_DIRECT3D,
|
||||
TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||
}
|
||||
|
||||
static int video_texture_png_load_wrap_d3d(void *data)
|
||||
{
|
||||
return video_texture_png_load(data, TEXTURE_BACKEND_DIRECT3D,
|
||||
TEXTURE_FILTER_LINEAR);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned video_texture_load(void *data,
|
||||
enum texture_backend_type type,
|
||||
enum texture_filter_type filter_type)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
|
||||
if (settings->video.threaded && !hw_render->context_type)
|
||||
{
|
||||
custom_command_method_t func = video_texture_png_load_wrap;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TEXTURE_BACKEND_OPENGL:
|
||||
#ifdef HAVE_OPENGL
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR ||
|
||||
filter_type == TEXTURE_FILTER_MIPMAP_NEAREST)
|
||||
func = video_texture_png_load_wrap_gl_mipmap;
|
||||
else
|
||||
func = video_texture_png_load_wrap_gl;
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DIRECT3D:
|
||||
#ifdef HAVE_D3D
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR ||
|
||||
filter_type == TEXTURE_FILTER_MIPMAP_NEAREST)
|
||||
func = video_texture_png_load_wrap_d3d_mipmap;
|
||||
else
|
||||
func = video_texture_png_load_wrap_d3d;
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DEFAULT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rarch_threaded_video_texture_load(data, func);
|
||||
}
|
||||
#endif
|
||||
|
||||
return video_texture_png_load(data, type, filter_type);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
static void video_texture_gl_unload(uintptr_t *id)
|
||||
{
|
||||
if (id)
|
||||
{
|
||||
glDeleteTextures(1, (const GLuint*)id);
|
||||
*id = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void video_texture_unload(enum texture_backend_type type, uintptr_t *id)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TEXTURE_BACKEND_OPENGL:
|
||||
#ifdef HAVE_OPENGL
|
||||
video_texture_gl_unload(id);
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DIRECT3D:
|
||||
#ifdef HAVE_D3D
|
||||
d3d_texture_free((LPDIRECT3DTEXTURE)id);
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DEFAULT:
|
||||
break;
|
||||
}
|
||||
}
|
@ -1135,6 +1135,28 @@ static void thread_set_osd_msg(void *data, const char *msg,
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned thread_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)video_data;
|
||||
|
||||
if (!thr || !thr->poke || !thr->poke->load_texture)
|
||||
return 0;
|
||||
|
||||
return thr->poke->load_texture(thr->driver_data, data, threaded, filter_type);
|
||||
}
|
||||
|
||||
static void thread_unload_texture(void *video_data, uintptr_t *id)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)video_data;
|
||||
|
||||
if (!thr)
|
||||
return;
|
||||
|
||||
if (thr->poke && thr->poke->unload_texture)
|
||||
thr->poke->unload_texture(thr->driver_data, id);
|
||||
}
|
||||
|
||||
static void thread_apply_state_changes(void *data)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)data;
|
||||
@ -1158,6 +1180,8 @@ static struct video_shader *thread_get_current_shader(void *data)
|
||||
}
|
||||
|
||||
static const video_poke_interface_t thread_poke = {
|
||||
thread_load_texture,
|
||||
thread_unload_texture,
|
||||
thread_set_video_mode,
|
||||
thread_set_filtering,
|
||||
thread_get_video_output_size,
|
||||
|
@ -193,10 +193,6 @@ VIDEO IMAGE
|
||||
|
||||
#include "../gfx/image/image.c"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include "../gfx/video_texture_c.c"
|
||||
#endif
|
||||
|
||||
#include "../libretro-common/formats/tga/rtga.c"
|
||||
|
||||
#ifdef HAVE_IMAGEVIEWER
|
||||
|
@ -77,9 +77,6 @@ VIDEO DRIVER
|
||||
#ifdef _XBOX
|
||||
#include "../frontend/drivers/platform_xdk.cpp"
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include "../gfx/video_texture.cpp"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_D3D)
|
||||
#include "../gfx/common/d3d_common.cpp"
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "../../config.def.h"
|
||||
#include "../../gfx/font_driver.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
#include "../../gfx/d3d/d3d.h"
|
||||
#include "../../gfx/common/d3d_common.h"
|
||||
|
||||
@ -217,14 +216,16 @@ static void menu_display_d3d_clear_color(float r, float g, float b, float a)
|
||||
|
||||
static unsigned menu_display_d3d_texture_load(void *data, enum texture_filter_type type)
|
||||
{
|
||||
return video_texture_load(data, TEXTURE_BACKEND_DIRECT3D, type);
|
||||
unsigned id;
|
||||
video_driver_texture_load(data, type, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static void menu_display_d3d_texture_unload(uintptr_t *id)
|
||||
{
|
||||
if (!id)
|
||||
return;
|
||||
video_texture_unload(TEXTURE_BACKEND_DIRECT3D, id);
|
||||
video_driver_texture_unload(id);
|
||||
}
|
||||
|
||||
static const float *menu_display_d3d_get_tex_coords(void)
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "../../gfx/font_driver.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
#include "../../gfx/video_shader_driver.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
#include "../../gfx/common/gl_common.h"
|
||||
|
||||
#include "../menu_display.h"
|
||||
@ -193,14 +192,16 @@ static void menu_display_gl_clear_color(float r, float g, float b, float a)
|
||||
|
||||
static unsigned menu_display_gl_texture_load(void *data, enum texture_filter_type type)
|
||||
{
|
||||
return video_texture_load(data, TEXTURE_BACKEND_OPENGL, type);
|
||||
unsigned id;
|
||||
video_driver_texture_load(data, type, &id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static void menu_display_gl_texture_unload(uintptr_t *id)
|
||||
{
|
||||
if (!id)
|
||||
return;
|
||||
video_texture_unload(TEXTURE_BACKEND_OPENGL, id);
|
||||
video_driver_texture_unload(id);
|
||||
}
|
||||
|
||||
static const float *menu_display_gl_get_tex_coords(void)
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "../../config.def.h"
|
||||
#include "../../gfx/font_driver.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
|
||||
#include "../menu_display.h"
|
||||
|
||||
|
@ -15,13 +15,17 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <retro_assert.h>
|
||||
#include <queues/message_queue.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
#include <formats/image.h>
|
||||
|
||||
#include "../config.def.h"
|
||||
#include "../configuration.h"
|
||||
#include "../runloop.h"
|
||||
#include "../gfx/video_thread_wrapper.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
#include "menu_driver.h"
|
||||
#include "menu_animation.h"
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#include "../gfx/video_texture.h"
|
||||
#include "../gfx/video_context_driver.h"
|
||||
#include "../gfx/font_driver.h"
|
||||
#include "../gfx/video_common.h"
|
||||
|
@ -25,11 +25,13 @@
|
||||
#include "menu_hash.h"
|
||||
#include "menu_shader.h"
|
||||
|
||||
#include "../general.h"
|
||||
#include "../system.h"
|
||||
#include "../defaults.h"
|
||||
#include "../frontend/frontend.h"
|
||||
#include "../string_list_special.h"
|
||||
#include "../tasks/tasks.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
static const menu_ctx_driver_t *menu_ctx_drivers[] = {
|
||||
#if defined(HAVE_RMENU)
|
||||
|
Loading…
x
Reference in New Issue
Block a user