renderer: Move shader setup into render()

shader-damage-experiments
Andri Yngvason 2020-03-24 22:57:02 +00:00
parent 4da96d0dc1
commit 49c584f80d
3 changed files with 11 additions and 18 deletions

View File

@ -73,4 +73,4 @@ void render_copy_pixels(struct renderer* self, void* dst, uint32_t y,
GLuint renderer_next_tex(struct renderer* self);
GLuint renderer_last_tex(const struct renderer* self);
void render(void);
void render(struct renderer* self);

View File

@ -518,7 +518,7 @@ void wayvnc_process_frame(struct wayvnc* self)
GLuint tex = renderer_next_tex(&self->renderer);
renderer_import_dmabuf_frame(&self->renderer, tex, frame);
render();
render(&self->renderer);
render_copy_pixels(&self->renderer, addr, 0, fb_height);
wayvnc_update_vnc(self, fb);
@ -545,7 +545,7 @@ void wayvnc_process_screen(struct wayvnc* self)
GLuint tex = renderer_next_tex(&self->renderer);
renderer_import_framebuffer(&self->renderer, tex, pixels, frame_format,
width, height, stride);
render();
render(&self->renderer);
render_copy_pixels(&self->renderer, addr, 0, fb_height);
wayvnc_update_vnc(self, fb);

View File

@ -342,8 +342,15 @@ void gl_clear(void)
glClear(GL_COLOR_BUFFER_BIT);
}
void render(void)
void render(struct renderer* self)
{
glUseProgram(self->shader.program);
glUniform1i(self->shader.u_tex, 0);
const float* proj = transforms[self->output->transform];
glUniformMatrix2fv(self->shader.u_proj, 1, GL_FALSE, proj);
static const GLfloat s_vertices[4][2] = {
{ -1.0, 1.0 },
{ 1.0, 1.0 },
@ -576,13 +583,6 @@ int renderer_import_dmabuf_frame(struct renderer* self, GLuint tex,
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image);
eglDestroyImageKHR(self->display, image);
glUseProgram(self->shader.program);
glUniform1i(self->shader.u_tex, 0);
const float* proj = transforms[self->output->transform];
glUniformMatrix2fv(self->shader.u_proj, 1, GL_FALSE, proj);
return 0;
}
@ -604,13 +604,6 @@ int renderer_import_framebuffer(struct renderer* self, GLuint tex,
glGenerateMipmap(GL_TEXTURE_2D);
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
glUseProgram(self->shader.program);
glUniform1i(self->shader.u_tex, 0);
const float* proj = transforms[self->output->transform];
glUniformMatrix2fv(self->shader.u_proj, 1, GL_FALSE, proj);
return 0;
}