De-opaque shader_parse.

This commit is contained in:
Themaister 2014-06-17 16:41:06 +02:00
parent 270bb930d6
commit 76292f873a
3 changed files with 22 additions and 28 deletions

View File

@ -27,6 +27,7 @@
#include "gfx/scaler/scaler.h"
#include "gfx/image/image.h"
#include "gfx/filters/softfilter.h"
#include "gfx/shader_parse.h"
#include "audio/dsp_filter.h"
#include "input/overlay.h"
#include "frontend/frontend_context.h"
@ -167,14 +168,6 @@ struct platform_bind
char desc[64];
};
enum rarch_shader_type
{
RARCH_SHADER_CG,
RARCH_SHADER_HLSL,
RARCH_SHADER_GLSL,
RARCH_SHADER_NONE
};
#if defined(_XBOX360)
#define DEFAULT_SHADER_TYPE RARCH_SHADER_HLSL
#elif defined(__PSL1GHT__)
@ -538,7 +531,7 @@ typedef struct
struct retro_system_info info;
bool load_no_rom;
void *shader;
struct gfx_shader *shader;
void *parameter_shader; // Points to either shader or graphics driver current shader.
unsigned current_pad;

View File

@ -58,9 +58,8 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode)
}
// CGP
static bool shader_parse_pass(config_file_t *conf, void *data, unsigned i)
static bool shader_parse_pass(config_file_t *conf, struct gfx_shader_pass *pass, unsigned i)
{
struct gfx_shader_pass *pass = (struct gfx_shader_pass*)data;
// Source
char shader_name[64];
print_buf(shader_name, "shader%u", i);
@ -228,12 +227,11 @@ static bool shader_parse_pass(config_file_t *conf, void *data, unsigned i)
return true;
}
static bool shader_parse_textures(config_file_t *conf, void *data)
static bool shader_parse_textures(config_file_t *conf, struct gfx_shader *shader)
{
const char *id;
char *save;
char textures[1024];
struct gfx_shader *shader = (struct gfx_shader*)data;
if (!config_get_array(conf, "textures", textures, sizeof(textures)))
return true;
@ -287,10 +285,9 @@ static struct gfx_shader_parameter *find_parameter(struct gfx_shader_parameter *
return NULL;
}
bool gfx_shader_resolve_parameters(config_file_t *conf, void *data)
bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shader)
{
unsigned i;
struct gfx_shader *shader = (struct gfx_shader*)data;
shader->num_parameters = 0;
struct gfx_shader_parameter *param = &shader->parameters[shader->num_parameters];
@ -453,13 +450,10 @@ static bool shader_parse_imports(config_file_t *conf, struct gfx_shader *shader)
return true;
}
bool gfx_shader_read_conf_cgp(config_file_t *conf, void *data)
bool gfx_shader_read_conf_cgp(config_file_t *conf, struct gfx_shader *shader)
{
unsigned shaders, i;
struct gfx_shader *shader = (struct gfx_shader*)data;
memset(shader, 0, sizeof(*shader));
shader->type = RARCH_SHADER_CG;
shaders = 0;
@ -597,10 +591,9 @@ static void shader_write_variable(config_file_t *conf, const struct state_tracke
}
}
void gfx_shader_write_conf_cgp(config_file_t *conf, void *data)
void gfx_shader_write_conf_cgp(config_file_t *conf, struct gfx_shader *shader)
{
unsigned i;
struct gfx_shader *shader = (struct gfx_shader*)data;
config_set_int(conf, "shaders", shader->passes);
for (i = 0; i < shader->passes; i++)
{
@ -721,11 +714,10 @@ enum rarch_shader_type gfx_shader_parse_type(const char *path, enum rarch_shader
return fallback;
}
void gfx_shader_resolve_relative(void *data, const char *ref_path)
void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path)
{
unsigned i;
char tmp_path[PATH_MAX];
struct gfx_shader *shader = (struct gfx_shader*)data;
for (i = 0; i < shader->passes; i++)
{

View File

@ -18,7 +18,8 @@
#include "../boolean.h"
#include "state_tracker.h"
#include "../general.h"
#include "../conf/config_file.h"
#include "../miscellaneous.h"
#ifdef __cplusplus
extern "C" {
@ -40,6 +41,14 @@ extern "C" {
#define GFX_MAX_PARAMETERS 64
#endif
enum rarch_shader_type
{
RARCH_SHADER_CG,
RARCH_SHADER_HLSL,
RARCH_SHADER_GLSL,
RARCH_SHADER_NONE
};
enum gfx_scale_type
{
RARCH_SCALE_INPUT = 0,
@ -141,11 +150,11 @@ struct gfx_shader
char script_class[512];
};
bool gfx_shader_read_conf_cgp(config_file_t *conf, void *data);
void gfx_shader_write_conf_cgp(config_file_t *conf, void *data);
bool gfx_shader_read_conf_cgp(config_file_t *conf, struct gfx_shader *shader);
void gfx_shader_write_conf_cgp(config_file_t *conf, struct gfx_shader *shader);
void gfx_shader_resolve_relative(void *data, const char *ref_path);
bool gfx_shader_resolve_parameters(config_file_t *conf, void *data);
void gfx_shader_resolve_relative(struct gfx_shader *shader, const char *ref_path);
bool gfx_shader_resolve_parameters(config_file_t *conf, struct gfx_shader *shader);
enum rarch_shader_type gfx_shader_parse_type(const char *path, enum rarch_shader_type fallback);