[vlc-commits] opengl: "-vvvv" to dump shaders
Thomas Guillem
git at videolan.org
Thu Nov 16 21:34:41 CET 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Nov 16 21:34:21 2017 +0100| [fc9722824abda23ee90c538e11d104418391b2f9] | committer: Thomas Guillem
opengl: "-vvvv" to dump shaders
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fc9722824abda23ee90c538e11d104418391b2f9
---
modules/video_output/opengl/converter.h | 3 +++
modules/video_output/opengl/fragment_shaders.c | 11 +++--------
modules/video_output/opengl/vout_helper.c | 15 ++++++++++++---
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index efb423ae69..c367ad6a67 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -210,6 +210,9 @@ struct opengl_tex_converter_t
/* Function pointers to OpenGL functions, set by the caller */
const opengl_vtable_t *vt;
+ /* True to dump shaders, set by the caller */
+ bool b_dump_shaders;
+
/* Function pointer to the shader init command, set by the caller, see
* opengl_fragment_shader_init() documentation. */
GLuint (*pf_fragment_shader_init)(opengl_tex_converter_t *, GLenum,
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index c3fe2d85b7..cc6dbc7a48 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -59,10 +59,6 @@
# define GL_TEXTURE_LUMINANCE_SIZE 0x8060
#endif
-#if 0
-#define DUMP_SHADERS
-#endif
-
static int GetTexFormatSize(opengl_tex_converter_t *tc, int target,
int tex_format, int tex_internal, int tex_type)
{
@@ -736,10 +732,9 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
GLint length = ms.length;
tc->vt->ShaderSource(fragment_shader, 1, (const char **)&ms.ptr, &length);
tc->vt->CompileShader(fragment_shader);
-#ifdef DUMP_SHADERS
- fprintf(stderr, "\n=== Fragment shader for fourcc: %4.4s, colorspace: %d ===\n%s\n\n",
- (const char *)&chroma, yuv_space, ms.ptr);
-#endif
+ if (tc->b_dump_shaders)
+ fprintf(stderr, "\n=== Fragment shader for fourcc: %4.4s, colorspace: %d ===\n%s\n",
+ (const char *)&chroma, yuv_space, ms.ptr);
free(ms.ptr);
tc->tex_target = tex_target;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index d5eb573b5e..52a07cb8c6 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -398,6 +398,9 @@ static GLuint BuildVertexShader(const opengl_tex_converter_t *tc,
GLuint shader = tc->vt->CreateShader(GL_VERTEX_SHADER);
tc->vt->ShaderSource(shader, 1, (const char **) &code, NULL);
+ if (tc->b_dump_shaders)
+ fprintf(stderr, "\n=== Vertex shader for fourcc: %4.4s ===\n%s\n",
+ (const char *)&tc->fmt.i_chroma, code);
tc->vt->CompileShader(shader);
free(code);
return shader;
@@ -590,7 +593,8 @@ log_cb(void *priv, enum pl_log_level level, const char *msg)
static int
opengl_init_program(vout_display_opengl_t *vgl, struct prgm *prgm,
- const char *glexts, const video_format_t *fmt, bool subpics)
+ const char *glexts, const video_format_t *fmt, bool subpics,
+ bool b_dump_shaders)
{
opengl_tex_converter_t *tc =
vlc_object_create(vgl->gl, sizeof(opengl_tex_converter_t));
@@ -599,6 +603,7 @@ opengl_init_program(vout_display_opengl_t *vgl, struct prgm *prgm,
tc->gl = vgl->gl;
tc->vt = &vgl->vt;
+ tc->b_dump_shaders = b_dump_shaders;
tc->pf_fragment_shader_init = opengl_fragment_shader_init_impl;
tc->glexts = glexts;
#if defined(USE_OPENGL_ES2)
@@ -844,12 +849,15 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
HasExtension(extensions, "GL_APPLE_texture_2D_limited_npot");
#endif
+ bool b_dump_shaders = var_InheritInteger(gl, "verbose") >= 4;
+
vgl->prgm = &vgl->prgms[0];
vgl->sub_prgm = &vgl->prgms[1];
GL_ASSERT_NOERROR();
int ret;
- ret = opengl_init_program(vgl, vgl->prgm, extensions, fmt, false);
+ ret = opengl_init_program(vgl, vgl->prgm, extensions, fmt, false,
+ b_dump_shaders);
if (ret != VLC_SUCCESS)
{
msg_Warn(gl, "could not init tex converter for %4.4s",
@@ -859,7 +867,8 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
}
GL_ASSERT_NOERROR();
- ret = opengl_init_program(vgl, vgl->sub_prgm, extensions, fmt, true);
+ ret = opengl_init_program(vgl, vgl->sub_prgm, extensions, fmt, true,
+ b_dump_shaders);
if (ret != VLC_SUCCESS)
{
msg_Warn(gl, "could not init subpictures tex converter for %4.4s",
More information about the vlc-commits
mailing list