Add 'ident' to shader driver - add shader context functions

This commit is contained in:
twinaphex 2014-10-02 13:42:40 +02:00
parent 7bfde3df63
commit 64c2305017
6 changed files with 53 additions and 1 deletions

View File

@ -1012,5 +1012,6 @@ const shader_backend_t gl_cg_backend = {
gl_cg_get_current_shader,
RARCH_SHADER_CG,
"cg"
};

View File

@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2014 - 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-
@ -15,3 +15,43 @@
#include "shader_context.h"
#include "../../retroarch_logger.h"
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
static const shader_backend_t *shader_ctx_drivers[] = {
#ifdef HAVE_CG
&gl_cg_backend,
#endif
#ifdef HAVE_GLSL
&gl_glsl_backend,
#endif
#ifdef HAVE_HLSL
&hlsl_backend,
#endif
&shader_null_backend,
NULL
};
const shader_backend_t *shader_ctx_find_driver(const char *ident)
{
unsigned i;
for (i = 0; shader_ctx_drivers[i]; i++)
{
if (strcmp(shader_ctx_drivers[i]->ident, ident) == 0)
return shader_ctx_drivers[i];
}
return NULL;
}
const shader_backend_t *shader_ctx_init_first(void)
{
unsigned i;
for (i = 0; shader_ctx_drivers[i]; i++)
return shader_ctx_drivers[i];
return NULL;
}

View File

@ -51,6 +51,9 @@ typedef struct shader_backend
struct gfx_shader *(*get_current_shader)(void);
enum rarch_shader_type type;
/* Human readable string. */
const char *ident;
} shader_backend_t;
extern const shader_backend_t gl_glsl_backend;
@ -71,6 +74,7 @@ extern const shader_backend_t shader_null_backend;
#endif
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
#ifndef HAVE_SHADER_MANAGER
#define HAVE_SHADER_MANAGER
#endif
@ -81,4 +85,8 @@ extern const shader_backend_t shader_null_backend;
#endif
const shader_backend_t *shader_ctx_find_driver(const char *ident);
const shader_backend_t *shader_ctx_init_first(void);
#endif

View File

@ -1261,5 +1261,6 @@ const shader_backend_t gl_glsl_backend = {
gl_glsl_get_current_shader,
RARCH_SHADER_GLSL,
"glsl"
};

View File

@ -453,4 +453,5 @@ const shader_backend_t hlsl_backend = {
hlsl_get_current_shader,
RARCH_SHADER_HLSL,
"hlsl"
};

View File

@ -119,4 +119,5 @@ const shader_backend_t shader_null_backend = {
shader_null_get_current_shader,
RARCH_SHADER_NONE,
"nullshader"
};