Commit fc972282 authored by Thomas Guillem's avatar Thomas Guillem

opengl: "-vvvv" to dump shaders

parent f56b5e2f
......@@ -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,
......
......@@ -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;
......
......@@ -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",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment