2018-05-11 01:47:55 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <deque>
|
|
|
|
#include <limits.h>
|
2018-05-12 00:08:13 +02:00
|
|
|
#include "../../conffile.h"
|
2018-05-14 01:12:30 +02:00
|
|
|
#include "shader_platform.h"
|
2018-05-12 00:08:13 +02:00
|
|
|
|
|
|
|
static const unsigned int glsl_max_passes = 20;
|
2018-05-11 01:47:55 +02:00
|
|
|
|
2018-05-21 21:15:31 +02:00
|
|
|
typedef void (* GLSLViewportCallback) (int source_width, int source_height,
|
|
|
|
int viewport_x, int viewport_y,
|
|
|
|
int viewport_width, int viewport_height,
|
|
|
|
int *out_dst_x, int *out_dst_y,
|
|
|
|
int *out_dst_width, int *out_dst_height);
|
|
|
|
|
2018-05-11 01:47:55 +02:00
|
|
|
enum GLSLScaleType
|
|
|
|
{
|
|
|
|
GLSL_NONE = 0,
|
|
|
|
GLSL_SOURCE,
|
|
|
|
GLSL_VIEWPORT,
|
|
|
|
GLSL_ABSOLUTE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GLSLFilter
|
|
|
|
{
|
|
|
|
GLSL_UNDEFINED = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GLint Texture;
|
|
|
|
GLint InputSize;
|
|
|
|
GLint TextureSize;
|
|
|
|
GLint TexCoord;
|
|
|
|
|
|
|
|
} GLSLUniformMetrics;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GLint Texture;
|
|
|
|
GLint InputSize;
|
|
|
|
GLint OutputSize;
|
|
|
|
GLint TextureSize;
|
|
|
|
|
|
|
|
GLint FrameCount;
|
|
|
|
GLint FrameDirection;
|
|
|
|
|
|
|
|
GLint TexCoord;
|
|
|
|
GLint LUTTexCoord;
|
|
|
|
GLint VertexCoord;
|
|
|
|
|
|
|
|
GLint OrigTexture;
|
|
|
|
GLint OrigInputSize;
|
|
|
|
GLint OrigTextureSize;
|
|
|
|
GLint OrigTexCoord;
|
|
|
|
|
|
|
|
unsigned int max_pass;
|
|
|
|
unsigned int max_prevpass;
|
|
|
|
GLSLUniformMetrics Prev[7];
|
2018-05-12 00:08:13 +02:00
|
|
|
GLSLUniformMetrics Pass[glsl_max_passes];
|
|
|
|
GLSLUniformMetrics PassPrev[glsl_max_passes];
|
2018-05-11 01:47:55 +02:00
|
|
|
GLint Lut[9];
|
|
|
|
|
|
|
|
} GLSLUniforms;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char filename[PATH_MAX];
|
2018-05-11 22:56:58 +02:00
|
|
|
char alias[256];
|
2018-05-11 01:47:55 +02:00
|
|
|
int scale_type_x;
|
|
|
|
int scale_type_y;
|
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
|
|
|
bool fp;
|
2018-05-11 22:56:58 +02:00
|
|
|
bool srgb;
|
2018-05-11 01:47:55 +02:00
|
|
|
int frame_count_mod;
|
|
|
|
unsigned int frame_count;
|
|
|
|
|
|
|
|
GLuint program;
|
|
|
|
GLuint vertex_shader;
|
|
|
|
GLuint fragment_shader;
|
|
|
|
GLuint texture;
|
2018-05-14 21:27:07 +02:00
|
|
|
GLuint wrap_mode;
|
2018-05-11 01:47:55 +02:00
|
|
|
GLuint fbo;
|
|
|
|
GLuint width;
|
|
|
|
GLuint height;
|
|
|
|
GLuint filter;
|
|
|
|
|
|
|
|
GLSLUniforms unif;
|
|
|
|
} GLSLPass;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2018-05-12 00:08:13 +02:00
|
|
|
char id[256];
|
2018-05-11 01:47:55 +02:00
|
|
|
char filename[PATH_MAX];
|
|
|
|
GLuint filter;
|
|
|
|
GLuint texture;
|
2018-05-11 22:56:58 +02:00
|
|
|
GLuint wrap_mode;
|
|
|
|
bool mipmap;
|
2018-05-11 01:47:55 +02:00
|
|
|
} GLSLLut;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char name[PATH_MAX];
|
2018-05-12 00:08:13 +02:00
|
|
|
char id[256];
|
2018-05-11 01:47:55 +02:00
|
|
|
float min;
|
|
|
|
float max;
|
2018-05-12 00:08:13 +02:00
|
|
|
float val;
|
2018-05-11 01:47:55 +02:00
|
|
|
float step;
|
2018-05-12 00:08:13 +02:00
|
|
|
GLint unif[glsl_max_passes];
|
2018-05-11 01:47:55 +02:00
|
|
|
} GLSLParam;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
bool load_shader (char *filename);
|
|
|
|
bool load_shader_file (char *filename);
|
2018-05-22 01:08:22 +02:00
|
|
|
void render (GLuint &orig, int width, int height, int viewport_x, int viewport_y, int viewport_width, int viewport_height, GLSLViewportCallback vpcallback);
|
2018-05-14 00:31:25 +02:00
|
|
|
void set_shader_vars (unsigned int pass);
|
2018-05-11 01:47:55 +02:00
|
|
|
void clear_shader_vars (void);
|
2018-05-12 00:08:13 +02:00
|
|
|
void strip_parameter_pragmas(char *buffer);
|
|
|
|
GLuint compile_shader (char *program,
|
|
|
|
const char *aliases,
|
|
|
|
const char *defines,
|
|
|
|
GLuint type,
|
|
|
|
GLuint *out);
|
2018-05-13 18:02:52 +02:00
|
|
|
void save (const char *filename);
|
2018-05-12 00:08:13 +02:00
|
|
|
|
2018-05-11 01:47:55 +02:00
|
|
|
void destroy (void);
|
|
|
|
void register_uniforms (void);
|
|
|
|
|
2018-05-12 00:08:13 +02:00
|
|
|
ConfigFile conf;
|
|
|
|
|
2018-05-11 01:47:55 +02:00
|
|
|
std::vector<GLSLPass> pass;
|
|
|
|
std::vector<GLSLLut> lut;
|
|
|
|
std::vector<GLSLParam> param;
|
|
|
|
int max_prev_frame;
|
|
|
|
std::deque<GLSLPass> prev_frame;
|
|
|
|
std::vector<GLuint> vaos;
|
|
|
|
|
|
|
|
unsigned int frame_count;
|
|
|
|
GLuint vbo;
|
|
|
|
GLuint prev_fbo;
|
|
|
|
GLfloat *fa;
|
|
|
|
|
|
|
|
} GLSLShader;
|