mirror of
https://github.com/yshui/picom.git
synced 2025-02-17 15:56:21 -05:00
backend: gl: don't use present shader for decoupling
Present shader optionally does dithering, but that's not needed for decoupling. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
c738400058
commit
9204426caf
2 changed files with 21 additions and 10 deletions
|
@ -885,24 +885,35 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
|
|||
glUseProgram(0);
|
||||
|
||||
gd->dithered_present = ps->o.dithered_present;
|
||||
gd->dummy_prog =
|
||||
gl_create_program_from_strv((const char *[]){present_vertex_shader, NULL},
|
||||
(const char *[]){dummy_frag, NULL});
|
||||
if (!gd->dummy_prog) {
|
||||
log_error("Failed to create the dummy shader");
|
||||
return false;
|
||||
}
|
||||
if (gd->dithered_present) {
|
||||
gd->present_prog = gl_create_program_from_strv(
|
||||
(const char *[]){present_vertex_shader, NULL},
|
||||
(const char *[]){present_frag, dither_glsl, NULL});
|
||||
} else {
|
||||
gd->present_prog = gl_create_program_from_strv(
|
||||
(const char *[]){present_vertex_shader, NULL},
|
||||
(const char *[]){dummy_frag, NULL});
|
||||
gd->present_prog = gd->dummy_prog;
|
||||
}
|
||||
if (!gd->present_prog) {
|
||||
log_error("Failed to create the present shader");
|
||||
return false;
|
||||
}
|
||||
pml = glGetUniformLocationChecked(gd->present_prog, "projection");
|
||||
glUseProgram(gd->present_prog);
|
||||
glUniform1i(glGetUniformLocationChecked(gd->present_prog, "tex"), 0);
|
||||
|
||||
pml = glGetUniformLocationChecked(gd->dummy_prog, "projection");
|
||||
glUseProgram(gd->dummy_prog);
|
||||
glUniform1i(glGetUniformLocationChecked(gd->dummy_prog, "tex"), 0);
|
||||
glUniformMatrix4fv(pml, 1, false, projection_matrix[0]);
|
||||
glUseProgram(0);
|
||||
if (gd->present_prog != gd->dummy_prog) {
|
||||
pml = glGetUniformLocationChecked(gd->present_prog, "projection");
|
||||
glUseProgram(gd->present_prog);
|
||||
glUniform1i(glGetUniformLocationChecked(gd->present_prog, "tex"), 0);
|
||||
glUniformMatrix4fv(pml, 1, false, projection_matrix[0]);
|
||||
}
|
||||
|
||||
gd->shadow_shader.prog =
|
||||
gl_create_program_from_str(present_vertex_shader, shadow_colorization_frag);
|
||||
|
@ -912,7 +923,6 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
|
|||
glUseProgram(gd->shadow_shader.prog);
|
||||
glUniform1i(glGetUniformLocationChecked(gd->shadow_shader.prog, "tex"), 0);
|
||||
glUniformMatrix4fv(pml, 1, false, projection_matrix[0]);
|
||||
glUseProgram(0);
|
||||
glBindFragDataLocation(gd->shadow_shader.prog, 0, "out_color");
|
||||
|
||||
gd->brightness_shader.prog =
|
||||
|
@ -925,6 +935,7 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
|
|||
glUseProgram(gd->brightness_shader.prog);
|
||||
glUniform1i(glGetUniformLocationChecked(gd->brightness_shader.prog, "tex"), 0);
|
||||
glUniformMatrix4fv(pml, 1, false, projection_matrix[0]);
|
||||
|
||||
glUseProgram(0);
|
||||
|
||||
// Set up the size and format of the back texture
|
||||
|
@ -1026,8 +1037,7 @@ static inline void gl_image_decouple(backend_t *base, struct backend_image *img)
|
|||
GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
assert(gd->present_prog);
|
||||
glUseProgram(gd->present_prog);
|
||||
glUseProgram(gd->dummy_prog);
|
||||
glBindTexture(GL_TEXTURE_2D, inner->texture);
|
||||
|
||||
GLuint fbo;
|
||||
|
|
|
@ -112,6 +112,7 @@ struct gl_data {
|
|||
GLuint frame_timing[2];
|
||||
int current_frame_timing;
|
||||
GLuint present_prog;
|
||||
GLuint dummy_prog;
|
||||
|
||||
bool dithered_present;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue