refactor: deduplicate vertex shaders
This commit is contained in:
parent
2f3e039029
commit
c0d490e3cb
|
@ -18,13 +18,12 @@
|
||||||
#include "sway/server.h"
|
#include "sway/server.h"
|
||||||
|
|
||||||
// shaders
|
// shaders
|
||||||
#include "quad_vert_src.h"
|
#include "common_vert_src.h"
|
||||||
#include "quad_frag_src.h"
|
#include "quad_frag_src.h"
|
||||||
#include "quad_round_frag_src.h"
|
#include "quad_round_frag_src.h"
|
||||||
#include "quad_round_tl_frag_src.h"
|
#include "quad_round_tl_frag_src.h"
|
||||||
#include "quad_round_tr_frag_src.h"
|
#include "quad_round_tr_frag_src.h"
|
||||||
#include "corner_frag_src.h"
|
#include "corner_frag_src.h"
|
||||||
#include "tex_vert_src.h"
|
|
||||||
#include "tex_rgba_frag_src.h"
|
#include "tex_rgba_frag_src.h"
|
||||||
#include "tex_rgbx_frag_src.h"
|
#include "tex_rgbx_frag_src.h"
|
||||||
#include "tex_external_frag_src.h"
|
#include "tex_external_frag_src.h"
|
||||||
|
@ -188,7 +187,7 @@ struct fx_renderer *fx_renderer_create(struct wlr_egl *egl) {
|
||||||
GLuint prog;
|
GLuint prog;
|
||||||
|
|
||||||
// quad fragment shader
|
// quad fragment shader
|
||||||
prog = link_program(quad_vert_src, quad_frag_src);
|
prog = link_program(common_vert_src, quad_frag_src);
|
||||||
renderer->shaders.quad.program = prog;
|
renderer->shaders.quad.program = prog;
|
||||||
if (!renderer->shaders.quad.program) {
|
if (!renderer->shaders.quad.program) {
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -198,21 +197,21 @@ struct fx_renderer *fx_renderer_create(struct wlr_egl *egl) {
|
||||||
renderer->shaders.quad.pos_attrib = glGetAttribLocation(prog, "pos");
|
renderer->shaders.quad.pos_attrib = glGetAttribLocation(prog, "pos");
|
||||||
|
|
||||||
// rounded quad fragment shaders
|
// rounded quad fragment shaders
|
||||||
prog = link_program(quad_vert_src, quad_round_frag_src);
|
prog = link_program(common_vert_src, quad_round_frag_src);
|
||||||
if (!init_rounded_quad_shader(&renderer->shaders.rounded_quad, prog)) {
|
if (!init_rounded_quad_shader(&renderer->shaders.rounded_quad, prog)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
prog = link_program(quad_vert_src, quad_round_tl_frag_src);
|
prog = link_program(common_vert_src, quad_round_tl_frag_src);
|
||||||
if (!init_rounded_quad_shader(&renderer->shaders.rounded_tl_quad, prog)) {
|
if (!init_rounded_quad_shader(&renderer->shaders.rounded_tl_quad, prog)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
prog = link_program(quad_vert_src, quad_round_tr_frag_src);
|
prog = link_program(common_vert_src, quad_round_tr_frag_src);
|
||||||
if (!init_rounded_quad_shader(&renderer->shaders.rounded_tr_quad, prog)) {
|
if (!init_rounded_quad_shader(&renderer->shaders.rounded_tr_quad, prog)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Border corner shader
|
// Border corner shader
|
||||||
prog = link_program(quad_vert_src, corner_frag_src);
|
prog = link_program(common_vert_src, corner_frag_src);
|
||||||
renderer->shaders.corner.program = prog;
|
renderer->shaders.corner.program = prog;
|
||||||
if (!renderer->shaders.corner.program) {
|
if (!renderer->shaders.corner.program) {
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -230,15 +229,15 @@ struct fx_renderer *fx_renderer_create(struct wlr_egl *egl) {
|
||||||
renderer->shaders.corner.half_thickness = glGetUniformLocation(prog, "half_thickness");
|
renderer->shaders.corner.half_thickness = glGetUniformLocation(prog, "half_thickness");
|
||||||
|
|
||||||
// fragment shaders
|
// fragment shaders
|
||||||
prog = link_program(tex_vert_src, tex_rgba_frag_src);
|
prog = link_program(common_vert_src, tex_rgba_frag_src);
|
||||||
if (!init_frag_shader(&renderer->shaders.tex_rgba, prog)) {
|
if (!init_frag_shader(&renderer->shaders.tex_rgba, prog)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
prog = link_program(tex_vert_src, tex_rgbx_frag_src);
|
prog = link_program(common_vert_src, tex_rgbx_frag_src);
|
||||||
if (!init_frag_shader(&renderer->shaders.tex_rgbx, prog)) {
|
if (!init_frag_shader(&renderer->shaders.tex_rgbx, prog)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
prog = link_program(tex_vert_src, tex_external_frag_src);
|
prog = link_program(common_vert_src, tex_external_frag_src);
|
||||||
if (!init_frag_shader(&renderer->shaders.tex_ext, prog)) {
|
if (!init_frag_shader(&renderer->shaders.tex_ext, prog)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
embed = find_program('./embed.sh', native: true)
|
embed = find_program('./embed.sh', native: true)
|
||||||
|
|
||||||
shaders = [
|
shaders = [
|
||||||
'quad.vert',
|
'common.vert',
|
||||||
'quad.frag',
|
'quad.frag',
|
||||||
'quad_round.frag',
|
'quad_round.frag',
|
||||||
'quad_round_tl.frag',
|
'quad_round_tl.frag',
|
||||||
'quad_round_tr.frag',
|
'quad_round_tr.frag',
|
||||||
'corner.frag',
|
'corner.frag',
|
||||||
'tex.vert',
|
|
||||||
'tex_rgba.frag',
|
'tex_rgba.frag',
|
||||||
'tex_rgbx.frag',
|
'tex_rgbx.frag',
|
||||||
'tex_external.frag',
|
'tex_external.frag',
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
uniform mat3 proj;
|
|
||||||
attribute vec2 pos;
|
|
||||||
attribute vec2 texcoord;
|
|
||||||
varying vec2 v_texcoord;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);
|
|
||||||
v_texcoord = texcoord;
|
|
||||||
}
|
|
Loading…
Reference in a new issue