mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
gles2 renderer: introduce struct wlr_gles2_tex_shader
This commit is contained in:
parent
de91c55ea9
commit
6f29db1044
2 changed files with 20 additions and 46 deletions
|
@ -25,6 +25,14 @@ struct wlr_gles2_pixel_format {
|
|||
bool has_alpha;
|
||||
};
|
||||
|
||||
struct wlr_gles2_tex_shader {
|
||||
GLuint program;
|
||||
GLint proj;
|
||||
GLint invert_y;
|
||||
GLint tex;
|
||||
GLint alpha;
|
||||
};
|
||||
|
||||
struct wlr_gles2_renderer {
|
||||
struct wlr_renderer wlr_renderer;
|
||||
|
||||
|
@ -42,27 +50,9 @@ struct wlr_gles2_renderer {
|
|||
GLint proj;
|
||||
GLint color;
|
||||
} ellipse;
|
||||
struct {
|
||||
GLuint program;
|
||||
GLint proj;
|
||||
GLint invert_y;
|
||||
GLint tex;
|
||||
GLint alpha;
|
||||
} tex_rgba;
|
||||
struct {
|
||||
GLuint program;
|
||||
GLint proj;
|
||||
GLint invert_y;
|
||||
GLint tex;
|
||||
GLint alpha;
|
||||
} tex_rgbx;
|
||||
struct {
|
||||
GLuint program;
|
||||
GLint proj;
|
||||
GLint invert_y;
|
||||
GLint tex;
|
||||
GLint alpha;
|
||||
} tex_ext;
|
||||
struct wlr_gles2_tex_shader tex_rgba;
|
||||
struct wlr_gles2_tex_shader tex_rgbx;
|
||||
struct wlr_gles2_tex_shader tex_ext;
|
||||
} shaders;
|
||||
|
||||
uint32_t viewport_width, viewport_height;
|
||||
|
|
|
@ -118,38 +118,22 @@ static bool gles2_render_texture_with_matrix(struct wlr_renderer *wlr_renderer,
|
|||
struct wlr_gles2_texture *texture =
|
||||
get_gles2_texture_in_context(wlr_texture);
|
||||
|
||||
GLuint prog = 0;
|
||||
struct wlr_gles2_tex_shader *shader = NULL;
|
||||
GLenum target = 0;
|
||||
GLint proj_loc = 0;
|
||||
GLint invert_y_loc = 0;
|
||||
GLint tex_loc = 0;
|
||||
GLint alpha_loc = 0;
|
||||
|
||||
switch (texture->type) {
|
||||
case WLR_GLES2_TEXTURE_GLTEX:
|
||||
case WLR_GLES2_TEXTURE_WL_DRM_GL:
|
||||
if (texture->has_alpha) {
|
||||
prog = renderer->shaders.tex_rgba.program;
|
||||
proj_loc = renderer->shaders.tex_rgba.proj;
|
||||
invert_y_loc = renderer->shaders.tex_rgba.invert_y;
|
||||
tex_loc = renderer->shaders.tex_rgba.tex;
|
||||
alpha_loc = renderer->shaders.tex_rgba.alpha;
|
||||
shader = &renderer->shaders.tex_rgba;
|
||||
} else {
|
||||
prog = renderer->shaders.tex_rgbx.program;
|
||||
proj_loc = renderer->shaders.tex_rgbx.proj;
|
||||
invert_y_loc = renderer->shaders.tex_rgbx.invert_y;
|
||||
tex_loc = renderer->shaders.tex_rgbx.tex;
|
||||
alpha_loc = renderer->shaders.tex_rgbx.alpha;
|
||||
shader = &renderer->shaders.tex_rgbx;
|
||||
}
|
||||
target = GL_TEXTURE_2D;
|
||||
break;
|
||||
case WLR_GLES2_TEXTURE_WL_DRM_EXT:
|
||||
case WLR_GLES2_TEXTURE_DMABUF:
|
||||
prog = renderer->shaders.tex_ext.program;
|
||||
proj_loc = renderer->shaders.tex_ext.proj;
|
||||
invert_y_loc = renderer->shaders.tex_ext.invert_y;
|
||||
tex_loc = renderer->shaders.tex_ext.tex;
|
||||
alpha_loc = renderer->shaders.tex_ext.alpha;
|
||||
shader = &renderer->shaders.tex_ext;
|
||||
target = GL_TEXTURE_EXTERNAL_OES;
|
||||
break;
|
||||
}
|
||||
|
@ -169,12 +153,12 @@ static bool gles2_render_texture_with_matrix(struct wlr_renderer *wlr_renderer,
|
|||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glUseProgram(prog);
|
||||
glUseProgram(shader->program);
|
||||
|
||||
glUniformMatrix3fv(proj_loc, 1, GL_FALSE, transposition);
|
||||
glUniform1i(invert_y_loc, texture->inverted_y);
|
||||
glUniform1f(alpha_loc, alpha);
|
||||
glUniform1i(tex_loc, 0);
|
||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, transposition);
|
||||
glUniform1i(shader->invert_y, texture->inverted_y);
|
||||
glUniform1i(shader->tex, 0);
|
||||
glUniform1f(shader->alpha, alpha);
|
||||
|
||||
draw_quad();
|
||||
|
||||
|
|
Loading…
Reference in a new issue