summaryrefslogtreecommitdiffstats
path: root/video/out/gl_utils.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-12 21:57:54 +0100
committerwm4 <wm4@nowhere>2015-03-12 23:20:20 +0100
commite74a4d5bc0b101fbfb371942c00d3a77267dc4a6 (patch)
treea9cc46910567eaf32ba0b47c9539f47418565d41 /video/out/gl_utils.h
parentae6019cbc98cfad2613e89a80bee79ce6b2f1319 (diff)
downloadmpv-e74a4d5bc0b101fbfb371942c00d3a77267dc4a6.tar.bz2
mpv-e74a4d5bc0b101fbfb371942c00d3a77267dc4a6.tar.xz
vo_opengl: refactor shader generation (part 1)
The basic idea is to use dynamically generated shaders instead of a single monolithic file + a ton of ifdefs. Instead of having to setup every aspect of it separately (like compiling shaders, setting uniforms, perfoming the actual rendering steps, the GLSL parts), we generate the GLSL on the fly, and perform the rendering at the same time. The GLSL is regenerated every frame, but the actual compiled OpenGL-level shaders are cached, which makes it fast again. Almost all logic can be in a single place. The new code is significantly more flexible, which allows us to improve the code clarity, performance and add more features easily. This commit is incomplete. It drops almost all previous code, and readds only the most important things (some of them actually buggy). The next commit will complete it - it's separate to preserve authorship information.
Diffstat (limited to 'video/out/gl_utils.h')
-rw-r--r--video/out/gl_utils.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/video/out/gl_utils.h b/video/out/gl_utils.h
index 1934396afe..a1bb2ecafb 100644
--- a/video/out/gl_utils.h
+++ b/video/out/gl_utils.h
@@ -66,23 +66,54 @@ void gl_vao_init(struct gl_vao *vao, GL *gl, int stride,
void gl_vao_uninit(struct gl_vao *vao);
void gl_vao_bind(struct gl_vao *vao);
void gl_vao_unbind(struct gl_vao *vao);
-void gl_vao_bind_attribs(struct gl_vao *vao, GLuint program);
void gl_vao_draw_data(struct gl_vao *vao, GLenum prim, void *ptr, size_t num);
struct fbotex {
GL *gl;
GLuint fbo;
GLuint texture;
- int tex_w, tex_h; // size of .texture
- int vp_x, vp_y, vp_w, vp_h; // viewport of fbo / used part of the texture
+ GLenum iformat;
+ GLenum tex_filter;
+ int tex_w, tex_h; // size of .texture
};
bool fbotex_init(struct fbotex *fbo, GL *gl, struct mp_log *log, int w, int h,
- GLenum gl_target, GLenum gl_filter, GLenum iformat);
+ GLenum iformat);
void fbotex_uninit(struct fbotex *fbo);
+bool fbotex_change(struct fbotex *fbo, GL *gl, struct mp_log *log, int w, int h,
+ GLenum iformat, int flags);
+#define FBOTEX_FUZZY_W 1
+#define FBOTEX_FUZZY_H 2
+void fbotex_set_filter(struct fbotex *fbo, GLenum gl_filter);
void gl_matrix_ortho2d(float m[3][3], float x0, float x1, float y0, float y1);
+static inline void gl_matrix_mul_vec(float m[3][3], float *x, float *y)
+{
+ float vx = *x, vy = *y;
+ *x = vx * m[0][0] + vy * m[1][0] + m[2][0];
+ *y = vx * m[0][1] + vy * m[1][1] + m[2][1];
+}
+
void gl_set_debug_logger(GL *gl, struct mp_log *log);
+struct gl_shader_cache;
+
+struct gl_shader_cache *gl_sc_create(GL *gl, struct mp_log *log);
+void gl_sc_destroy(struct gl_shader_cache *sc);
+void gl_sc_add(struct gl_shader_cache *sc, const char *text);
+void gl_sc_addf(struct gl_shader_cache *sc, const char *textf, ...);
+void gl_sc_uniform_sampler(struct gl_shader_cache *sc, char *name, GLenum target,
+ int unit);
+void gl_sc_uniform_f(struct gl_shader_cache *sc, char *name, GLfloat f);
+void gl_sc_uniform_vec2(struct gl_shader_cache *sc, char *name, GLfloat f[2]);
+void gl_sc_uniform_vec3(struct gl_shader_cache *sc, char *name, GLfloat f[3]);
+void gl_sc_uniform_mat2(struct gl_shader_cache *sc, char *name,
+ bool transpose, GLfloat *v);
+void gl_sc_uniform_mat3(struct gl_shader_cache *sc, char *name,
+ bool transpose, GLfloat *v);
+void gl_sc_set_vao(struct gl_shader_cache *sc, struct gl_vao *vao);
+void gl_sc_gen_shader_and_reset(struct gl_shader_cache *sc);
+void gl_sc_reset(struct gl_shader_cache *sc);
+
#endif