mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +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;
|
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_gles2_renderer {
|
||||||
struct wlr_renderer wlr_renderer;
|
struct wlr_renderer wlr_renderer;
|
||||||
|
|
||||||
|
@ -42,27 +50,9 @@ struct wlr_gles2_renderer {
|
||||||
GLint proj;
|
GLint proj;
|
||||||
GLint color;
|
GLint color;
|
||||||
} ellipse;
|
} ellipse;
|
||||||
struct {
|
struct wlr_gles2_tex_shader tex_rgba;
|
||||||
GLuint program;
|
struct wlr_gles2_tex_shader tex_rgbx;
|
||||||
GLint proj;
|
struct wlr_gles2_tex_shader tex_ext;
|
||||||
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;
|
|
||||||
} shaders;
|
} shaders;
|
||||||
|
|
||||||
uint32_t viewport_width, viewport_height;
|
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 =
|
struct wlr_gles2_texture *texture =
|
||||||
get_gles2_texture_in_context(wlr_texture);
|
get_gles2_texture_in_context(wlr_texture);
|
||||||
|
|
||||||
GLuint prog = 0;
|
struct wlr_gles2_tex_shader *shader = NULL;
|
||||||
GLenum target = 0;
|
GLenum target = 0;
|
||||||
GLint proj_loc = 0;
|
|
||||||
GLint invert_y_loc = 0;
|
|
||||||
GLint tex_loc = 0;
|
|
||||||
GLint alpha_loc = 0;
|
|
||||||
|
|
||||||
switch (texture->type) {
|
switch (texture->type) {
|
||||||
case WLR_GLES2_TEXTURE_GLTEX:
|
case WLR_GLES2_TEXTURE_GLTEX:
|
||||||
case WLR_GLES2_TEXTURE_WL_DRM_GL:
|
case WLR_GLES2_TEXTURE_WL_DRM_GL:
|
||||||
if (texture->has_alpha) {
|
if (texture->has_alpha) {
|
||||||
prog = renderer->shaders.tex_rgba.program;
|
shader = &renderer->shaders.tex_rgba;
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
prog = renderer->shaders.tex_rgbx.program;
|
shader = &renderer->shaders.tex_rgbx;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
target = GL_TEXTURE_2D;
|
target = GL_TEXTURE_2D;
|
||||||
break;
|
break;
|
||||||
case WLR_GLES2_TEXTURE_WL_DRM_EXT:
|
case WLR_GLES2_TEXTURE_WL_DRM_EXT:
|
||||||
case WLR_GLES2_TEXTURE_DMABUF:
|
case WLR_GLES2_TEXTURE_DMABUF:
|
||||||
prog = renderer->shaders.tex_ext.program;
|
shader = &renderer->shaders.tex_ext;
|
||||||
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;
|
|
||||||
target = GL_TEXTURE_EXTERNAL_OES;
|
target = GL_TEXTURE_EXTERNAL_OES;
|
||||||
break;
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glUseProgram(prog);
|
glUseProgram(shader->program);
|
||||||
|
|
||||||
glUniformMatrix3fv(proj_loc, 1, GL_FALSE, transposition);
|
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, transposition);
|
||||||
glUniform1i(invert_y_loc, texture->inverted_y);
|
glUniform1i(shader->invert_y, texture->inverted_y);
|
||||||
glUniform1f(alpha_loc, alpha);
|
glUniform1i(shader->tex, 0);
|
||||||
glUniform1i(tex_loc, 0);
|
glUniform1f(shader->alpha, alpha);
|
||||||
|
|
||||||
draw_quad();
|
draw_quad();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue