render: rename shader_program -> dmabuf_shader_program

shader-damage
Andri Yngvason 2019-10-09 22:00:01 +00:00
parent 36e7bde860
commit 8cc00dd5eb
2 changed files with 26 additions and 22 deletions

View File

@ -25,7 +25,7 @@ struct renderer {
EGLDisplay display;
EGLSurface surface;
EGLContext context;
GLuint shader_program;
GLuint dmabuf_shader_program;
uint32_t width;
uint32_t height;
GLint read_format;

View File

@ -148,9 +148,7 @@ static int gl_load_shader(GLuint* dst, const char* source, GLenum type)
return 0;
}
static int gl_compile_shader_program(GLuint* dst)
{
static const char vertex_src[] =
static const char dmabuf_vertex_src[] =
"attribute vec2 pos;\n"
"attribute vec2 texture;\n"
"varying vec2 v_texture;\n"
@ -159,7 +157,7 @@ static int gl_compile_shader_program(GLuint* dst)
" gl_Position = vec4(pos, 0, 1);\n"
"}\n";
static const char fragment_src[] =
static const char dmabuf_fragment_src[] =
"#extension GL_OES_EGL_image_external: require\n\n"
"precision mediump float;\n"
"uniform samplerExternalOES u_tex;\n"
@ -168,6 +166,10 @@ static int gl_compile_shader_program(GLuint* dst)
" gl_FragColor = texture2D(u_tex, v_texture);\n"
"}\n";
static int gl_compile_shader_program(GLuint* dst, const char* vertex_src,
const char* fragment_src)
{
int rc = -1;
GLuint vertex, fragment;
@ -244,7 +246,7 @@ void renderer_destroy(struct renderer* self)
{
eglDestroySurface(self->display, self->surface);
eglDestroyContext(self->display, self->context);
glDeleteProgram(self->shader_program);
glDeleteProgram(self->dmabuf_shader_program);
}
int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
@ -310,10 +312,12 @@ int renderer_init(struct renderer* self, uint32_t width, uint32_t height)
if (gl_load_late_extensions() < 0)
goto late_extension_failure;
if (gl_compile_shader_program(&self->shader_program) < 0)
if (gl_compile_shader_program(&self->dmabuf_shader_program,
dmabuf_vertex_src,
dmabuf_fragment_src) < 0)
goto shader_failure;
glUseProgram(self->shader_program);
glUseProgram(self->dmabuf_shader_program);
self->width = width;
self->height = height;