From c7ac70a923260cca8365ca4c78d911c79aee50e5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 12 Jun 2017 15:45:43 +0200 Subject: [PATCH] Combine video_renderchain_driver.c and video_driver.c --- Makefile.common | 1 - gfx/drivers/d3d.cpp | 2 +- gfx/drivers/d3d.h | 1 - .../d3d9_cg_renderchain.cpp | 1 - .../gl_legacy_renderchain.c | 2 +- gfx/drivers_renderchain/null_renderchain.c | 3 +- gfx/drivers_renderchain/xdk_renderchain.cpp | 1 - gfx/video_driver.c | 31 ++++ gfx/video_driver.h | 174 ++++++++++++------ gfx/video_renderchain_driver.c | 49 ----- gfx/video_renderchain_driver.h | 84 --------- griffin/griffin.c | 1 - 12 files changed, 149 insertions(+), 201 deletions(-) delete mode 100644 gfx/video_renderchain_driver.c delete mode 100644 gfx/video_renderchain_driver.h diff --git a/Makefile.common b/Makefile.common index 9aee4e5307..51f5b44c30 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1033,7 +1033,6 @@ endif ifeq ($(HAVE_D3D9), 1) OBJ += gfx/drivers/d3d.o \ - gfx/video_renderchain_driver.o \ gfx/common/d3d_common.o \ gfx/drivers_font/d3d_w32_font.o \ gfx/drivers_context/d3d_ctx.o diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 72a3dbf37e..2911e82028 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -30,7 +30,7 @@ #include "../video_coord_array.h" #include "../../configuration.h" #include "../../dynamic.h" -#include "../video_renderchain_driver.h" +#include "../video_driver.h" #ifdef HAVE_THREADS #include "../video_thread_wrapper.h" diff --git a/gfx/drivers/d3d.h b/gfx/drivers/d3d.h index 2822ad12ff..c1d520b629 100644 --- a/gfx/drivers/d3d.h +++ b/gfx/drivers/d3d.h @@ -49,7 +49,6 @@ #include "../font_driver.h" #include "../video_driver.h" #include "../common/d3d_common.h" -#include "../video_renderchain_driver.h" #ifdef _XBOX #include "../../defines/xdk_defines.h" #endif diff --git a/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp b/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp index 70a990b39c..6d49409214 100644 --- a/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp +++ b/gfx/drivers_renderchain/d3d9_cg_renderchain.cpp @@ -34,7 +34,6 @@ #include "../drivers/d3d.h" #include "../drivers/d3d_shaders/opaque.cg.d3d9.h" -#include "../video_renderchain_driver.h" #include "../video_driver.h" #include "../../configuration.h" #include "../../verbosity.h" diff --git a/gfx/drivers_renderchain/gl_legacy_renderchain.c b/gfx/drivers_renderchain/gl_legacy_renderchain.c index 452abdca90..5fab3a743d 100644 --- a/gfx/drivers_renderchain/gl_legacy_renderchain.c +++ b/gfx/drivers_renderchain/gl_legacy_renderchain.c @@ -39,7 +39,7 @@ #include #include "gl_legacy_renderchain.h" -#include "../video_renderchain_driver.h" +#include "../video_driver.h" #include "../common/gl_common.h" #include "../../driver.h" diff --git a/gfx/drivers_renderchain/null_renderchain.c b/gfx/drivers_renderchain/null_renderchain.c index 70ab14cfb9..a9ccdaf7cb 100644 --- a/gfx/drivers_renderchain/null_renderchain.c +++ b/gfx/drivers_renderchain/null_renderchain.c @@ -17,7 +17,8 @@ #include #include #include -#include "../video_renderchain_driver.h" + +#include "../video_driver.h" typedef struct null_renderchain { diff --git a/gfx/drivers_renderchain/xdk_renderchain.cpp b/gfx/drivers_renderchain/xdk_renderchain.cpp index f3c22e1ba3..69a3cfe8d9 100644 --- a/gfx/drivers_renderchain/xdk_renderchain.cpp +++ b/gfx/drivers_renderchain/xdk_renderchain.cpp @@ -16,7 +16,6 @@ #include #include -#include "../../video_renderchain_driver.h" #include "../drivers/d3d.h" #include "../common/d3d_common.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 9183b826da..2aa04cb16c 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -390,6 +390,17 @@ static const shader_backend_t *shader_ctx_drivers[] = { NULL }; +static const renderchain_driver_t *renderchain_drivers[] = { +#if defined(_WIN32) && defined(HAVE_D3D9) && defined(HAVE_CG) + &cg_d3d9_renderchain, +#endif +#ifdef _XBOX + &xdk_d3d_renderchain, +#endif + &null_renderchain, + NULL +}; + /* Stub functions */ static void update_window_title_null(void *data, void *data2) @@ -3352,3 +3363,23 @@ bool video_shader_driver_wrap_type(video_shader_ctx_wrap_t *wrap) wrap->type = current_shader->wrap_type(shader_data, wrap->idx); return true; } + +bool renderchain_init_first(const renderchain_driver_t **renderchain_driver, + void **renderchain_handle) +{ + unsigned i; + + for (i = 0; renderchain_drivers[i]; i++) + { + void *data = renderchain_drivers[i]->chain_new(); + + if (!data) + continue; + + *renderchain_driver = renderchain_drivers[i]; + *renderchain_handle = data; + return true; + } + + return false; +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 384aaf4bef..cb816346a5 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -37,6 +37,7 @@ #include "video_coord_array.h" #include "video_filter.h" #include "video_shader_parse.h" +#include "video_state_tracker.h" #include "../input/input_driver.h" @@ -74,6 +75,20 @@ RETRO_BEGIN_DECLS #define MAX_EGLIMAGE_TEXTURES 32 #endif +#define MAX_VARIABLES 64 + +enum +{ + TEXTURES = 8, + TEXTURESMASK = TEXTURES - 1 +}; + +struct LinkInfo +{ + unsigned tex_w, tex_h; + struct video_shader_pass *pass; +}; + enum gfx_ctx_api { GFX_CTX_NONE = 0, @@ -632,6 +647,22 @@ typedef struct gfx_ctx_ident const char *ident; } gfx_ctx_ident_t; +typedef struct video_viewport +{ + int x; + int y; + unsigned width; + unsigned height; + unsigned full_width; + unsigned full_height; +} video_viewport_t; + +struct aspect_ratio_elem +{ + char name[64]; + float value; +}; + /* Optionally implemented interface to poke more * deeply into video driver. */ @@ -678,15 +709,6 @@ typedef struct video_poke_interface const struct retro_hw_render_interface **iface); } video_poke_interface_t; -typedef struct video_viewport -{ - int x; - int y; - unsigned width; - unsigned height; - unsigned full_width; - unsigned full_height; -} video_viewport_t; /* msg is for showing a message on the screen * along with the video frame. */ @@ -770,11 +792,35 @@ typedef struct video_driver unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type); } video_driver_t; -struct aspect_ratio_elem +typedef struct renderchain_driver { - char name[64]; - float value; -}; + void (*chain_free)(void *data); + void *(*chain_new)(void); + bool (*reinit)(void *data, const void *info_data); + bool (*init)(void *data, + const void *video_info_data, + void *dev_data, + const void *final_viewport_data, + const void *info_data, + bool rgb32); + void (*set_final_viewport)(void *data, + void *renderchain_data, const void *viewport_data); + bool (*add_pass)(void *data, const void *info_data); + bool (*add_lut)(void *data, + const char *id, const char *path, + bool smooth); + void (*add_state_tracker)(void *data, void *tracker_data); + bool (*render)(void *chain_data, const void *data, + unsigned width, unsigned height, unsigned pitch, unsigned rotation); + void (*convert_geometry)(void *data, const void *info_data, + unsigned *out_width, unsigned *out_height, + unsigned width, unsigned height, + void *final_viewport); + void (*set_font_rect)(void *data, const void *param_data); + bool (*read_viewport)(void *data, uint8_t *buffer, bool is_idle); + void (*viewport_info)(void *data, struct video_viewport *vp); + const char *ident; +} renderchain_driver_t; extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; @@ -1070,53 +1116,6 @@ void video_driver_get_status(uint64_t *frame_count, bool * is_alive, void video_driver_set_resize(unsigned width, unsigned height); -extern video_driver_t video_gl; -extern video_driver_t video_vulkan; -extern video_driver_t video_psp1; -extern video_driver_t video_vita2d; -extern video_driver_t video_ctr; -extern video_driver_t video_d3d; -extern video_driver_t video_gx; -extern video_driver_t video_wiiu; -extern video_driver_t video_xenon360; -extern video_driver_t video_xvideo; -extern video_driver_t video_xdk_d3d; -extern video_driver_t video_sdl; -extern video_driver_t video_sdl2; -extern video_driver_t video_vg; -extern video_driver_t video_omap; -extern video_driver_t video_exynos; -extern video_driver_t video_dispmanx; -extern video_driver_t video_sunxi; -extern video_driver_t video_drm; -extern video_driver_t video_xshm; -extern video_driver_t video_caca; -extern video_driver_t video_gdi; -extern video_driver_t video_vga; -extern video_driver_t video_null; - -extern const gfx_ctx_driver_t gfx_ctx_osmesa; -extern const gfx_ctx_driver_t gfx_ctx_sdl_gl; -extern const gfx_ctx_driver_t gfx_ctx_x_egl; -extern const gfx_ctx_driver_t gfx_ctx_wayland; -extern const gfx_ctx_driver_t gfx_ctx_x; -extern const gfx_ctx_driver_t gfx_ctx_d3d; -extern const gfx_ctx_driver_t gfx_ctx_drm; -extern const gfx_ctx_driver_t gfx_ctx_mali_fbdev; -extern const gfx_ctx_driver_t gfx_ctx_vivante_fbdev; -extern const gfx_ctx_driver_t gfx_ctx_android; -extern const gfx_ctx_driver_t gfx_ctx_ps3; -extern const gfx_ctx_driver_t gfx_ctx_wgl; -extern const gfx_ctx_driver_t gfx_ctx_videocore; -extern const gfx_ctx_driver_t gfx_ctx_qnx; -extern const gfx_ctx_driver_t gfx_ctx_cgl; -extern const gfx_ctx_driver_t gfx_ctx_cocoagl; -extern const gfx_ctx_driver_t gfx_ctx_emscripten; -extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev; -extern const gfx_ctx_driver_t gfx_ctx_khr_display; -extern const gfx_ctx_driver_t gfx_ctx_gdi; -extern const gfx_ctx_driver_t gfx_ctx_null; - /** * video_context_driver_init_first: * @data : Input data. @@ -1234,16 +1233,71 @@ bool video_shader_driver_compile_program(struct shader_program_info *program_inf bool video_shader_driver_wrap_type(video_shader_ctx_wrap_t *wrap); +bool renderchain_init_first(const renderchain_driver_t **renderchain_driver, + void **renderchain_handle); + extern bool (*video_driver_cb_has_focus)(void); extern shader_backend_t *current_shader; extern void *shader_data; +extern video_driver_t video_gl; +extern video_driver_t video_vulkan; +extern video_driver_t video_psp1; +extern video_driver_t video_vita2d; +extern video_driver_t video_ctr; +extern video_driver_t video_d3d; +extern video_driver_t video_gx; +extern video_driver_t video_wiiu; +extern video_driver_t video_xenon360; +extern video_driver_t video_xvideo; +extern video_driver_t video_xdk_d3d; +extern video_driver_t video_sdl; +extern video_driver_t video_sdl2; +extern video_driver_t video_vg; +extern video_driver_t video_omap; +extern video_driver_t video_exynos; +extern video_driver_t video_dispmanx; +extern video_driver_t video_sunxi; +extern video_driver_t video_drm; +extern video_driver_t video_xshm; +extern video_driver_t video_caca; +extern video_driver_t video_gdi; +extern video_driver_t video_vga; +extern video_driver_t video_null; + +extern const gfx_ctx_driver_t gfx_ctx_osmesa; +extern const gfx_ctx_driver_t gfx_ctx_sdl_gl; +extern const gfx_ctx_driver_t gfx_ctx_x_egl; +extern const gfx_ctx_driver_t gfx_ctx_wayland; +extern const gfx_ctx_driver_t gfx_ctx_x; +extern const gfx_ctx_driver_t gfx_ctx_d3d; +extern const gfx_ctx_driver_t gfx_ctx_drm; +extern const gfx_ctx_driver_t gfx_ctx_mali_fbdev; +extern const gfx_ctx_driver_t gfx_ctx_vivante_fbdev; +extern const gfx_ctx_driver_t gfx_ctx_android; +extern const gfx_ctx_driver_t gfx_ctx_ps3; +extern const gfx_ctx_driver_t gfx_ctx_wgl; +extern const gfx_ctx_driver_t gfx_ctx_videocore; +extern const gfx_ctx_driver_t gfx_ctx_qnx; +extern const gfx_ctx_driver_t gfx_ctx_cgl; +extern const gfx_ctx_driver_t gfx_ctx_cocoagl; +extern const gfx_ctx_driver_t gfx_ctx_emscripten; +extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev; +extern const gfx_ctx_driver_t gfx_ctx_khr_display; +extern const gfx_ctx_driver_t gfx_ctx_gdi; +extern const gfx_ctx_driver_t gfx_ctx_null; + + extern const shader_backend_t gl_glsl_backend; extern const shader_backend_t hlsl_backend; extern const shader_backend_t gl_cg_backend; extern const shader_backend_t shader_null_backend; +extern renderchain_driver_t cg_d3d9_renderchain; +extern renderchain_driver_t xdk_d3d_renderchain; +extern renderchain_driver_t null_renderchain; + RETRO_END_DECLS #endif diff --git a/gfx/video_renderchain_driver.c b/gfx/video_renderchain_driver.c deleted file mode 100644 index 9c61b0725c..0000000000 --- a/gfx/video_renderchain_driver.c +++ /dev/null @@ -1,49 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * 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 . - */ - -#include - -#include "video_renderchain_driver.h" - -static const renderchain_driver_t *renderchain_drivers[] = { -#if defined(_WIN32) && defined(HAVE_D3D9) && defined(HAVE_CG) - &cg_d3d9_renderchain, -#endif -#ifdef _XBOX - &xdk_d3d_renderchain, -#endif - &null_renderchain, - NULL -}; - -bool renderchain_init_first(const renderchain_driver_t **renderchain_driver, - void **renderchain_handle) -{ - unsigned i; - - for (i = 0; renderchain_drivers[i]; i++) - { - void *data = renderchain_drivers[i]->chain_new(); - - if (!data) - continue; - - *renderchain_driver = renderchain_drivers[i]; - *renderchain_handle = data; - return true; - } - - return false; -} diff --git a/gfx/video_renderchain_driver.h b/gfx/video_renderchain_driver.h deleted file mode 100644 index 00cf6fa28c..0000000000 --- a/gfx/video_renderchain_driver.h +++ /dev/null @@ -1,84 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * 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 . - */ - -#ifndef __VIDEO_RENDER_CHAIN_H -#define __VIDEO_RENDER_CHAIN_H - -#include -#include - -#include "video_driver.h" -#include "video_shader_parse.h" -#include "video_state_tracker.h" -#include "../defines/d3d_defines.h" - -RETRO_BEGIN_DECLS - -struct LinkInfo -{ - unsigned tex_w, tex_h; - struct video_shader_pass *pass; -}; - -#define MAX_VARIABLES 64 - -enum -{ - TEXTURES = 8, - TEXTURESMASK = TEXTURES - 1 -}; - -typedef struct renderchain_driver -{ - void (*chain_free)(void *data); - void *(*chain_new)(void); - bool (*reinit)(void *data, const void *info_data); - bool (*init)(void *data, - const void *video_info_data, - void *dev_data, - const void *final_viewport_data, - const void *info_data, - bool rgb32); - void (*set_final_viewport)(void *data, - void *renderchain_data, const void *viewport_data); - bool (*add_pass)(void *data, const void *info_data); - bool (*add_lut)(void *data, - const char *id, const char *path, - bool smooth); - void (*add_state_tracker)(void *data, void *tracker_data); - bool (*render)(void *chain_data, const void *data, - unsigned width, unsigned height, unsigned pitch, unsigned rotation); - void (*convert_geometry)(void *data, const void *info_data, - unsigned *out_width, unsigned *out_height, - unsigned width, unsigned height, - void *final_viewport); - void (*set_font_rect)(void *data, const void *param_data); - bool (*read_viewport)(void *data, uint8_t *buffer, bool is_idle); - void (*viewport_info)(void *data, struct video_viewport *vp); - const char *ident; -} renderchain_driver_t; - -extern renderchain_driver_t cg_d3d9_renderchain; -extern renderchain_driver_t xdk_d3d_renderchain; -extern renderchain_driver_t null_renderchain; - -bool renderchain_init_first(const renderchain_driver_t **renderchain_driver, - void **renderchain_handle); - -RETRO_END_DECLS - -#endif - diff --git a/griffin/griffin.c b/griffin/griffin.c index 9e71fbc748..5b3fd5b417 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -301,7 +301,6 @@ VIDEO DRIVER #include "../gfx/drivers/drm_gfx.c" #endif -#include "../gfx/video_renderchain_driver.c" #include "../gfx/drivers_renderchain/null_renderchain.c" #ifdef HAVE_OPENGL