Diffusion Krita 47c0d27be7f6

Refactored shader system

Authored by Nim on Sep 8 2016, 12:21 PM.

Description

Refactored shader system

Details

Committed
NimSep 8 2016, 12:21 PM
Parents
R37:8ae151f3d744: Fix the calculation for hasOpenGL3
Branches
Unknown
Tags
Unknown
abrahams added a subscriber: abrahams.EditedSep 8 2016, 12:49 PM

Instead of doing multiple string comparisons every redraw, why not make an enum for the different shaders?

Nim added a comment.Sep 8 2016, 9:53 PM

I assume you are talking about the uniforms. It is a trade-off as far as I can see.

Advantages of enum:

  • You dont need to do string comparisons
  • You can't accidentally misspell a uniform name

Disadvantages of enum:

  • We need to keep track of updating the enum as we write new shaders to cover all names
  • We need to create another file and include it everywhere we use shaders

Advantages of string:

  • Needs no extra files or structures
  • It is immediately clear which uniform it is pointing to

Disadvantages of string:

  • Easy to misspell
  • Some negligible time is spent on comparing strings (could be bad if we have a lot of uniforms)

It is worth noting that a string comparison takes the equivalent of 0.0001 milliseconds for normal uniform string values though.

I might implement the enum approach now though, I find the argument for it stronger. This commit is pretty rough around the edges still I should note, certainly some stuff to fix, but it's in a separate branch so.