2013-04-06 09:30:56 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 17:06:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2013-04-06 09:30:56 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-12 22:42:50 +00:00
|
|
|
#ifndef __VIDEO_SHADER_PARSE_H
|
|
|
|
#define __VIDEO_SHADER_PARSE_H
|
2013-04-06 09:30:56 +00:00
|
|
|
|
2014-10-21 03:05:52 +00:00
|
|
|
#include <boolean.h>
|
2014-10-22 01:35:04 +00:00
|
|
|
#include <file/config_file.h>
|
2015-01-12 22:42:50 +00:00
|
|
|
#include "video_state_tracker.h"
|
2014-10-21 06:39:37 +00:00
|
|
|
#include <retro_miscellaneous.h>
|
2013-04-06 09:30:56 +00:00
|
|
|
|
2013-04-07 00:02:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-05-31 19:23:53 +00:00
|
|
|
#ifndef GFX_MAX_SHADERS
|
2013-04-06 09:30:56 +00:00
|
|
|
#define GFX_MAX_SHADERS 16
|
2014-05-31 19:23:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GFX_MAX_TEXTURES
|
2013-04-06 09:30:56 +00:00
|
|
|
#define GFX_MAX_TEXTURES 8
|
2014-05-31 19:23:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GFX_MAX_VARIABLES
|
2013-04-06 09:30:56 +00:00
|
|
|
#define GFX_MAX_VARIABLES 64
|
2014-05-31 19:23:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GFX_MAX_PARAMETERS
|
2014-05-24 11:30:30 +00:00
|
|
|
#define GFX_MAX_PARAMETERS 64
|
2014-05-31 19:23:53 +00:00
|
|
|
#endif
|
2013-04-06 09:30:56 +00:00
|
|
|
|
2014-06-17 14:41:06 +00:00
|
|
|
enum rarch_shader_type
|
|
|
|
{
|
2014-09-15 19:54:03 +00:00
|
|
|
RARCH_SHADER_NONE = 0,
|
2014-06-17 14:41:06 +00:00
|
|
|
RARCH_SHADER_CG,
|
|
|
|
RARCH_SHADER_HLSL,
|
2014-09-15 19:54:03 +00:00
|
|
|
RARCH_SHADER_GLSL
|
2014-06-17 14:41:06 +00:00
|
|
|
};
|
|
|
|
|
2013-04-06 09:30:56 +00:00
|
|
|
enum gfx_scale_type
|
|
|
|
{
|
|
|
|
RARCH_SCALE_INPUT = 0,
|
|
|
|
RARCH_SCALE_ABSOLUTE,
|
|
|
|
RARCH_SCALE_VIEWPORT
|
|
|
|
};
|
|
|
|
|
2014-08-17 17:02:03 +00:00
|
|
|
enum
|
2013-04-06 09:30:56 +00:00
|
|
|
{
|
|
|
|
RARCH_FILTER_UNSPEC = 0,
|
|
|
|
RARCH_FILTER_LINEAR,
|
2013-08-15 22:30:54 +00:00
|
|
|
RARCH_FILTER_NEAREST
|
|
|
|
};
|
|
|
|
|
|
|
|
enum gfx_wrap_type
|
|
|
|
{
|
2014-09-08 15:57:18 +00:00
|
|
|
RARCH_WRAP_BORDER = 0, /* Kinda deprecated, but keep as default.
|
|
|
|
Will be translated to EDGE in GLES. */
|
2013-08-15 22:30:54 +00:00
|
|
|
RARCH_WRAP_DEFAULT = RARCH_WRAP_BORDER,
|
|
|
|
RARCH_WRAP_EDGE,
|
|
|
|
RARCH_WRAP_REPEAT,
|
|
|
|
RARCH_WRAP_MIRRORED_REPEAT
|
2013-04-06 09:30:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gfx_fbo_scale
|
|
|
|
{
|
|
|
|
enum gfx_scale_type type_x;
|
|
|
|
enum gfx_scale_type type_y;
|
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
|
|
|
unsigned abs_x;
|
|
|
|
unsigned abs_y;
|
|
|
|
bool fp_fbo;
|
2014-05-11 17:35:54 +00:00
|
|
|
bool srgb_fbo;
|
2013-11-04 04:57:41 +00:00
|
|
|
bool valid;
|
2013-04-06 09:30:56 +00:00
|
|
|
};
|
|
|
|
|
2014-05-22 19:24:52 +00:00
|
|
|
struct gfx_shader_parameter
|
|
|
|
{
|
|
|
|
char id[64];
|
|
|
|
char desc[64];
|
|
|
|
float current;
|
|
|
|
float minimum;
|
|
|
|
float initial;
|
|
|
|
float maximum;
|
|
|
|
float step;
|
|
|
|
};
|
|
|
|
|
2013-04-06 09:30:56 +00:00
|
|
|
struct gfx_shader_pass
|
|
|
|
{
|
2013-04-07 10:41:05 +00:00
|
|
|
struct
|
2013-04-06 09:30:56 +00:00
|
|
|
{
|
2015-01-07 19:42:36 +00:00
|
|
|
char path[PATH_MAX_LENGTH];
|
2013-04-07 10:41:05 +00:00
|
|
|
struct
|
|
|
|
{
|
2014-12-21 19:41:26 +00:00
|
|
|
char *vertex; /* Dynamically allocated. Must be free'd. */
|
|
|
|
char *fragment; /* Dynamically allocated. Must be free'd. */
|
2014-05-25 15:16:33 +00:00
|
|
|
} string;
|
2013-04-06 09:30:56 +00:00
|
|
|
} source;
|
|
|
|
|
2014-05-23 13:02:12 +00:00
|
|
|
char alias[64];
|
2013-04-06 09:30:56 +00:00
|
|
|
struct gfx_fbo_scale fbo;
|
2014-08-17 17:02:03 +00:00
|
|
|
unsigned filter;
|
2013-08-15 22:30:54 +00:00
|
|
|
enum gfx_wrap_type wrap;
|
2013-04-06 09:30:56 +00:00
|
|
|
unsigned frame_count_mod;
|
2014-05-11 11:13:38 +00:00
|
|
|
bool mipmap;
|
2013-04-06 09:30:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gfx_shader_lut
|
|
|
|
{
|
|
|
|
char id[64];
|
2015-01-07 19:42:36 +00:00
|
|
|
char path[PATH_MAX_LENGTH];
|
2014-08-17 17:02:03 +00:00
|
|
|
unsigned filter;
|
2013-08-15 22:30:54 +00:00
|
|
|
enum gfx_wrap_type wrap;
|
2014-05-08 17:39:12 +00:00
|
|
|
bool mipmap;
|
2013-04-06 09:30:56 +00:00
|
|
|
};
|
|
|
|
|
2014-09-08 15:57:18 +00:00
|
|
|
/* This is pretty big, shouldn't be put on the stack.
|
|
|
|
* Avoid lots of allocation for convenience. */
|
2013-04-06 09:30:56 +00:00
|
|
|
struct gfx_shader
|
|
|
|
{
|
2013-04-07 10:41:05 +00:00
|
|
|
enum rarch_shader_type type;
|
|
|
|
|
2014-09-08 15:57:18 +00:00
|
|
|
bool modern; /* Only used for XML shaders. */
|
2013-04-07 10:41:05 +00:00
|
|
|
char prefix[64];
|
|
|
|
|
2013-04-06 09:30:56 +00:00
|
|
|
unsigned passes;
|
|
|
|
struct gfx_shader_pass pass[GFX_MAX_SHADERS];
|
|
|
|
|
|
|
|
unsigned luts;
|
|
|
|
struct gfx_shader_lut lut[GFX_MAX_TEXTURES];
|
|
|
|
|
2014-05-24 11:30:30 +00:00
|
|
|
struct gfx_shader_parameter parameters[GFX_MAX_PARAMETERS];
|
2014-05-22 19:24:52 +00:00
|
|
|
unsigned num_parameters;
|
|
|
|
|
2013-04-06 09:30:56 +00:00
|
|
|
unsigned variables;
|
|
|
|
struct state_tracker_uniform_info variable[GFX_MAX_VARIABLES];
|
2015-01-07 19:42:36 +00:00
|
|
|
char script_path[PATH_MAX_LENGTH];
|
2014-09-08 15:57:18 +00:00
|
|
|
char *script; /* Dynamically allocated. Must be free'd. Only used by XML. */
|
2013-04-06 09:30:56 +00:00
|
|
|
char script_class[512];
|
|
|
|
};
|
|
|
|
|
2015-01-11 19:17:45 +00:00
|
|
|
/**
|
2015-01-19 20:09:39 +00:00
|
|
|
* video_shader_read_conf_cgp:
|
2015-01-11 19:17:45 +00:00
|
|
|
* @conf : Preset file to read from.
|
|
|
|
* @shader : Shader passes handle.
|
|
|
|
*
|
|
|
|
* Loads preset file and all associated state (passes,
|
|
|
|
* textures, imports, etc).
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
2015-01-19 20:09:39 +00:00
|
|
|
bool video_shader_read_conf_cgp(config_file_t *conf,
|
2014-09-08 15:57:18 +00:00
|
|
|
struct gfx_shader *shader);
|
2013-04-06 09:30:56 +00:00
|
|
|
|
2015-01-11 19:17:45 +00:00
|
|
|
/**
|
2015-01-19 20:09:39 +00:00
|
|
|
* video_shader_write_conf_cgp:
|
2015-01-11 19:17:45 +00:00
|
|
|
* @conf : Preset file to read from.
|
|
|
|
* @shader : Shader passes handle.
|
|
|
|
*
|
|
|
|
* Saves preset and all associated state (passes,
|
|
|
|
* textures, imports, etc) to disk.
|
|
|
|
**/
|
2015-01-19 20:09:39 +00:00
|
|
|
void video_shader_write_conf_cgp(config_file_t *conf,
|
2014-09-08 15:57:18 +00:00
|
|
|
struct gfx_shader *shader);
|
2013-04-15 21:45:11 +00:00
|
|
|
|
2015-01-11 19:10:01 +00:00
|
|
|
/**
|
2015-01-19 20:09:39 +00:00
|
|
|
* video_shader_resolve_relative:
|
2015-01-11 19:10:01 +00:00
|
|
|
* @shader : Shader pass handle.
|
|
|
|
* @ref_path : Relative shader path.
|
|
|
|
*
|
|
|
|
* Resolves relative shader path (@ref_path) into absolute
|
|
|
|
* shader paths.
|
|
|
|
**/
|
2015-01-19 20:09:39 +00:00
|
|
|
void video_shader_resolve_relative(struct gfx_shader *shader,
|
2014-09-08 15:57:18 +00:00
|
|
|
const char *ref_path);
|
|
|
|
|
2015-01-11 18:59:59 +00:00
|
|
|
/**
|
2015-01-19 20:09:39 +00:00
|
|
|
* video_shader_resolve_parameters:
|
2015-01-11 18:59:59 +00:00
|
|
|
* @conf : Preset file to read from.
|
|
|
|
* @shader : Shader passes handle.
|
|
|
|
*
|
|
|
|
* Resolves all shader parameters belonging to shaders.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if successful, otherwise false (0).
|
|
|
|
**/
|
2015-01-19 20:09:39 +00:00
|
|
|
bool video_shader_resolve_parameters(config_file_t *conf,
|
2014-09-08 15:57:18 +00:00
|
|
|
struct gfx_shader *shader);
|
|
|
|
|
2015-01-11 19:10:01 +00:00
|
|
|
/**
|
2015-01-19 20:09:39 +00:00
|
|
|
* video_shader_parse_type:
|
2015-01-11 19:10:01 +00:00
|
|
|
* @path : Shader path.
|
|
|
|
* @fallback : Fallback shader type in case no
|
|
|
|
* type could be found.
|
|
|
|
*
|
|
|
|
* Parses type of shader.
|
|
|
|
*
|
|
|
|
* Returns: value of shader type on success, otherwise will return
|
|
|
|
* user-supplied @fallback value.
|
|
|
|
**/
|
2015-01-19 20:09:39 +00:00
|
|
|
enum rarch_shader_type video_shader_parse_type(const char *path,
|
2014-09-08 15:57:18 +00:00
|
|
|
enum rarch_shader_type fallback);
|
2013-04-06 23:38:11 +00:00
|
|
|
|
2013-04-07 00:02:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-06 09:30:56 +00:00
|
|
|
#endif
|
|
|
|
|