diff --git a/Makefile.common b/Makefile.common
index cd819e1ea7..9c9e03e329 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -235,7 +235,6 @@ OBJ += frontend/frontend.o \
tasks/task_screenshot.o \
tasks/task_powerstate.o \
$(LIBRETRO_COMM_DIR)/gfx/scaler/scaler.o \
- gfx/drivers_shader/shader_null.o \
gfx/video_shader_parse.o \
$(LIBRETRO_COMM_DIR)/gfx/scaler/pixconv.o \
$(LIBRETRO_COMM_DIR)/gfx/scaler/scaler_int.o \
diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c
index b324fad0f2..d8888b14cd 100644
--- a/gfx/drivers/gl.c
+++ b/gfx/drivers/gl.c
@@ -82,6 +82,16 @@
coords[5] = yamt; \
coords[7] = yamt
+static const shader_backend_t *shader_ctx_drivers[] = {
+#ifdef HAVE_GLSL
+ &gl_glsl_backend,
+#endif
+#ifdef HAVE_CG
+ &gl_cg_backend,
+#endif
+ NULL
+};
+
static struct video_ortho default_ortho = {0, 1, 0, 1, -1, 1};
/* Used for the last pass when rendering to the back buffer. */
@@ -230,6 +240,37 @@ void cocoagl_bind_game_view_fbo(void);
#define gl2_renderchain_bind_backbuffer() gl2_bind_fb(0)
#endif
+static bool gl_shader_info(gl_t *gl,
+ video_shader_ctx_info_t *shader_info)
+{
+ if (!shader_info)
+ return false;
+
+ shader_info->num = gl->shader->num_shaders(gl->shader_data);
+
+ return true;
+}
+
+static bool gl_shader_scale(gl_t *gl,
+ video_shader_ctx_scale_t *scaler)
+{
+ if (!scaler || !scaler->scale)
+ return false;
+
+ scaler->scale->valid = false;
+
+ gl->shader->shader_scale(gl->shader_data,
+ scaler->idx, scaler->scale);
+ return true;
+}
+
+static const char *gl_shader_get_ident(gl_t *gl)
+{
+ if (!gl || !gl->shader)
+ return "N/A";
+ return gl->shader->ident;
+}
+
static void gl2_renderchain_convert_geometry(
struct video_fbo_rect *fbo_rect,
struct gfx_fbo_scale *fbo_scale,
@@ -1091,7 +1132,7 @@ static void gl2_renderchain_init(
video_shader_ctx_info_t shader_info;
struct gfx_fbo_scale scale, scale_last;
- if (!video_shader_driver_info(&shader_info))
+ if (!gl_shader_info(gl, &shader_info))
return;
if (!gl || shader_info.num == 0)
@@ -1102,12 +1143,12 @@ static void gl2_renderchain_init(
scaler.idx = 1;
scaler.scale = &scale;
- video_shader_driver_scale(&scaler);
+ gl_shader_scale(gl, &scaler);
scaler.idx = shader_info.num;
scaler.scale = &scale_last;
- video_shader_driver_scale(&scaler);
+ gl_shader_scale(gl, &scaler);
/* we always want FBO to be at least initialized on startup for consoles */
if (shader_info.num == 1 && !scale.valid)
@@ -1138,7 +1179,7 @@ static void gl2_renderchain_init(
scaler.idx = i + 1;
scaler.scale = &chain->fbo_scale[i];
- video_shader_driver_scale(&scaler);
+ gl_shader_scale(gl, &scaler);
if (!chain->fbo_scale[i].valid)
{
@@ -3231,7 +3272,6 @@ static void *gl_init(const video_info_t *video,
gfx_ctx_input_t inp;
unsigned full_x, full_y;
video_shader_ctx_info_t shader_info;
- video_shader_ctx_ident_t ident_info;
settings_t *settings = config_get_ptr();
int interval = 0;
unsigned mip_level = 0;
@@ -3404,15 +3444,17 @@ static void *gl_init(const video_info_t *video,
gl->white_color_ptr = white_color;
- if (!video_shader_driver_init_first())
+ gl->shader = (shader_backend_t*)shader_ctx_drivers[0];
+
+ if (!video_shader_driver_init_first(gl->shader))
{
RARCH_ERR("[GL:]: Shader driver initialization failed.\n");
goto error;
}
- video_shader_driver_get_ident(&ident_info);
+ gl_shader_get_ident(gl);
- RARCH_LOG("[GL]: Default shader backend found: %s.\n", ident_info.ident);
+ RARCH_LOG("[GL]: Default shader backend found: %s.\n", gl_shader_get_ident(gl));
if (!gl_shader_init(gl, ctx_driver, hwr))
{
@@ -3426,7 +3468,7 @@ static void *gl_init(const video_info_t *video,
gl->textures = MAX(minimum + 1, gl->textures);
}
- if (!video_shader_driver_info(&shader_info))
+ if (!gl_shader_info(gl, &shader_info))
{
RARCH_ERR("[GL]: Shader driver info check failed.\n");
goto error;
diff --git a/gfx/drivers_shader/shader_null.c b/gfx/drivers_shader/shader_null.c
deleted file mode 100644
index 792c03f759..0000000000
--- a/gfx/drivers_shader/shader_null.c
+++ /dev/null
@@ -1,99 +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 .
- */
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#ifdef HAVE_CONFIG_H
-#include "../../config.h"
-#endif
-
-#include "../video_driver.h"
-
-typedef struct null_shader_data
-{
- void *empty;
-} null_shader_data_t;
-
-static void shader_null_deinit(void *data)
-{
- null_shader_data_t *null_shader = (null_shader_data_t*)data;
- if (!null_shader)
- return;
-
- free(null_shader);
-}
-
-static void *shader_null_init(void *data, const char *path)
-{
- null_shader_data_t *null_shader = (null_shader_data_t*)
- calloc(1, sizeof(*null_shader));
-
- if (!null_shader)
- return NULL;
-
- return null_shader;
-}
-
-static void shader_null_set_uniform_parameter(
- void *data,
- struct uniform_info *param,
- void *uniform_data)
-{
-}
-
-static unsigned shader_null_get_prev_textures(void *data)
-{
- return 0;
-}
-
-static bool shader_null_compile_program(
- void *data,
- unsigned idx,
- void *program_data,
- struct shader_program_info *program_info)
-{
- return true;
-}
-
-const shader_backend_t shader_null_backend = {
- shader_null_init,
- NULL,
- shader_null_deinit,
- NULL,
- shader_null_set_uniform_parameter,
- shader_null_compile_program,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- shader_null_get_prev_textures,
- NULL,
- NULL,
- NULL,
-
- RARCH_SHADER_NONE,
- "nullshader"
-};
diff --git a/gfx/video_driver.c b/gfx/video_driver.c
index c38d4ec55e..a479137405 100644
--- a/gfx/video_driver.c
+++ b/gfx/video_driver.c
@@ -425,16 +425,6 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
NULL
};
-static const shader_backend_t *shader_ctx_drivers[] = {
-#ifdef HAVE_GLSL
- &gl_glsl_backend,
-#endif
-#ifdef HAVE_CG
- &gl_cg_backend,
-#endif
- &shader_null_backend,
- NULL
-};
bool video_driver_started_fullscreen(void)
{
@@ -3458,14 +3448,6 @@ static const shader_backend_t *video_shader_set_backend(
return NULL;
}
-bool video_shader_driver_get_ident(video_shader_ctx_ident_t *ident)
-{
- if (!ident || !current_shader)
- return false;
- ident->ident = current_shader->ident;
- return true;
-}
-
bool video_shader_driver_get_current_shader(video_shader_ctx_t *shader)
{
void *video_driver = video_driver_get_ptr(true);
@@ -3529,9 +3511,12 @@ static void video_shader_driver_reset_to_defaults(void)
}
/* Finds first suitable shader context driver. */
-bool video_shader_driver_init_first(void)
+bool video_shader_driver_init_first(const void *data)
{
- current_shader = (shader_backend_t*)shader_ctx_drivers[0];
+ shader_backend_t *ptr = (shader_backend_t*)data;
+ if (!ptr)
+ return false;
+ current_shader = ptr;
video_shader_driver_reset_to_defaults();
return true;
}
@@ -3572,28 +3557,6 @@ bool video_shader_driver_init(video_shader_ctx_init_t *init)
return true;
}
-bool video_shader_driver_scale(video_shader_ctx_scale_t *scaler)
-{
- if (!scaler || !scaler->scale)
- return false;
-
- scaler->scale->valid = false;
-
- current_shader->shader_scale(current_shader_data,
- scaler->idx, scaler->scale);
- return true;
-}
-
-bool video_shader_driver_info(video_shader_ctx_info_t *shader_info)
-{
- if (!shader_info)
- return false;
-
- shader_info->num = current_shader->num_shaders(current_shader_data);
-
- return true;
-}
-
void video_driver_set_coords(video_shader_ctx_coords_t *coords)
{
if (current_shader && current_shader->set_coords)
diff --git a/gfx/video_driver.h b/gfx/video_driver.h
index 5b65e83b8f..6fac9d2dd1 100644
--- a/gfx/video_driver.h
+++ b/gfx/video_driver.h
@@ -311,11 +311,6 @@ typedef struct video_shader_ctx
struct video_shader *data;
} video_shader_ctx_t;
-typedef struct video_shader_ctx_ident
-{
- const char *ident;
-} video_shader_ctx_ident_t;
-
typedef struct video_shader_ctx_texture
{
unsigned id;
@@ -1180,22 +1175,16 @@ enum gfx_ctx_api video_context_driver_get_api(void);
void video_context_driver_free(void);
-bool video_shader_driver_get_ident(video_shader_ctx_ident_t *ident);
-
bool video_shader_driver_get_current_shader(video_shader_ctx_t *shader);
bool video_shader_driver_deinit(void);
-bool video_shader_driver_init_first(void);
+bool video_shader_driver_init_first(const void *data);
bool video_shader_driver_init(video_shader_ctx_init_t *init);
void video_driver_set_coords(video_shader_ctx_coords_t *coords);
-bool video_shader_driver_scale(video_shader_ctx_scale_t *scaler);
-
-bool video_shader_driver_info(video_shader_ctx_info_t *shader_info);
-
void video_driver_set_mvp(video_shader_ctx_mvp_t *mvp);
float video_driver_get_refresh_rate(void);
@@ -1267,7 +1256,6 @@ extern const gfx_ctx_driver_t gfx_ctx_null;
extern const shader_backend_t gl_glsl_backend;
extern const shader_backend_t gl_cg_backend;
-extern const shader_backend_t shader_null_backend;
RETRO_END_DECLS
diff --git a/griffin/griffin.c b/griffin/griffin.c
index 9b6d1e089b..d9e08c34dd 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -289,7 +289,6 @@ VIDEO CONTEXT
VIDEO SHADERS
============================================================ */
#include "../gfx/video_shader_parse.c"
-#include "../gfx/drivers_shader/shader_null.c"
#ifdef HAVE_CG
#ifdef HAVE_OPENGL