opengl: combined shaders to reduce shader switching

Desktop / LibreOffice - Tomaž Vajngerl [collabora.co.uk] - 23 May 2016 18:34 UTC

Combine most common shaders for non-texture drawing and texture drawing into two combined shaders. Inside the shader we switch between the code paths with if statements.

Using if statements (or any other branching statements) is discouraged inside shaders but on the other hand we reduce program state changes if we have less shader changes - which is more important for us as we want to push more work to the GPU.

Change-Id: I6701b93faa9b0f55dd0af6d983ce4c2de4539c70 Reviewed-on: https://gerrit.libreoffice.org/25357

3cac38b opengl: combined shaders to reduce shader switching
vcl/Package_opengl.mk | 4 ++
vcl/inc/opengl/program.hxx | 19 +++++++
vcl/opengl/combinedFragmentShader.glsl | 45 ++++++++++++++++
vcl/opengl/combinedTextureFragmentShader.glsl | 64 +++++++++++++++++++++++
vcl/opengl/combinedTextureVertexShader.glsl | 32 ++++++++++++
vcl/opengl/combinedVertexShader.glsl | 47 +++++++++++++++++
vcl/opengl/gdiimpl.cxx | 69 ++++++++++++++++---------
vcl/opengl/program.cxx | 18 +++++++
8 files changed, 273 insertions(+), 25 deletions(-)

Upstream: cgit.freedesktop.org


  • Share