| 68 | } |
| 69 | |
| 70 | bool ShaderProgram::is_shader_outdated(const TexelChannels texel_format, |
| 71 | const std::vector<std::string>& uniforms, |
| 72 | const std::string& pixel_layout) const { |
| 73 | // If the texel format or the uniform container size changed, |
| 74 | // the program must be created again |
| 75 | if (texel_format != texel_format_ || uniforms.size() != uniforms_.size()) { |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | // The program must also be created again if a uniform name |
| 80 | // changed |
| 81 | for (const auto& uniform_name : uniforms) { |
| 82 | if (!uniforms_.contains(uniform_name)) { |
| 83 | return true; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | for (int i = 0; i < 4; ++i) { |
| 88 | if (pixel_layout[i] != pixel_layout_[i]) { |
| 89 | return true; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // Otherwise, it must not change |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | bool ShaderProgram::create(const std::string_view v_source, |
| 98 | const std::string_view f_source, |