GLRenderer: The default fragment shader is sub-optimal for alpha=1.0
Bug #1350674 reported by
Daniel van Vugt
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mir |
Fix Released
|
Medium
|
Daniel van Vugt | ||
mir (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
GLRenderer: The default fragment shader is sub-optimal for alpha=1.0. It needlessly multiplies all four colour components on every fragment...
const GLchar* fragment_shader_src =
{
"precision mediump float;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"varying vec2 v_texcoord;\n"
"void main() {\n"
" vec4 frag = texture2D(tex, v_texcoord);\n"
" gl_FragColor = alpha*frag;\n"
"}\n"
};
If alpha is 1.0 (as it usually is) then we should take a more efficient shader than that.
Related branches
lp://staging/~vanvugt/mir/fix-1350674
- Robert Carr (community): Approve
- PS Jenkins bot (community): Approve (continuous-integration)
- Kevin DuBois (community): Needs Fixing
- Alan Griffiths: Approve
-
Diff: 1016 lines (+341/-177)18 files modifiedplayground/demo-shell/demo_compositor.cpp (+0/-2)
playground/demo-shell/demo_compositor.h (+0/-1)
playground/demo-shell/demo_renderer.cpp (+1/-2)
playground/demo-shell/demo_renderer.h (+0/-1)
playground/demo-shell/demo_shell.cpp (+1/-5)
src/include/server/mir/compositor/gl_program_family.h (+67/-0)
src/include/server/mir/compositor/gl_renderer.h (+18/-10)
src/server/compositor/CMakeLists.txt (+1/-0)
src/server/compositor/default_configuration.cpp (+1/-1)
src/server/compositor/gl_program_family.cpp (+105/-0)
src/server/compositor/gl_renderer.cpp (+74/-40)
src/server/compositor/gl_renderer_factory.cpp (+1/-6)
src/server/compositor/gl_renderer_factory.h (+0/-7)
src/server/symbols.map (+1/-0)
tests/unit-tests/compositor/test_gl_renderer.cpp (+27/-65)
tests/unit-tests/examples/test_demo_compositor.cpp (+17/-7)
tests/unit-tests/examples/test_demo_renderer.cpp (+14/-3)
tests/unit-tests/graphics/test_program_factory.cpp (+13/-27)
Changed in mir: | |
importance: | Undecided → High |
Changed in mir: | |
assignee: | nobody → Mirco Müller (macslow) |
Changed in mir: | |
status: | New → In Progress |
Changed in mir: | |
milestone: | none → 0.8.0 |
Changed in mir: | |
assignee: | nobody → Daniel van Vugt (vanvugt) |
milestone: | none → 0.10.0 |
status: | Triaged → In Progress |
Changed in mir: | |
milestone: | 0.10.0 → 0.11.0 |
Changed in mir: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
@Mirco
I don't think replacing a multiply with a branch will be faster. It most likely will be slower specially in embedded devices.
Instead I would create two separate shaders, one that does not do alpha multiplies and the default one and activate the respective shader by testing renderable.alpha() == 1.0