diff options
| author | x2048 <codeforsmile@gmail.com> | 2022-09-06 08:25:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-06 08:25:18 +0200 |
| commit | ff6dcfea82974df6db5a557e31aaddb6bdb7a71f (patch) | |
| tree | 18bafaedcfdff36a0c0719653b99370b7434b344 /src/client/shader.h | |
| parent | 464043b8abdbd936640757604ecb21662592043b (diff) | |
| download | minetest-ff6dcfea82974df6db5a557e31aaddb6bdb7a71f.tar.xz | |
Implement rendering pipeline and post-processing (#12465)
Co-authored-by: Lars Mueller <appgurulars@gmx.de>
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: lhofhansl <lhofhansl@yahoo.com>
Diffstat (limited to 'src/client/shader.h')
| -rw-r--r-- | src/client/shader.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/client/shader.h b/src/client/shader.h index 49a563115..8f1ba1e41 100644 --- a/src/client/shader.h +++ b/src/client/shader.h @@ -80,7 +80,7 @@ public: }; -template <typename T, std::size_t count=1> +template <typename T, std::size_t count, bool cache> class CachedShaderSetting { const char *m_name; T m_sent[count]; @@ -93,30 +93,32 @@ protected: public: void set(const T value[count], video::IMaterialRendererServices *services) { - if (has_been_set && std::equal(m_sent, m_sent + count, value)) + if (cache && has_been_set && std::equal(m_sent, m_sent + count, value)) return; if (is_pixel) services->setPixelShaderConstant(services->getPixelShaderConstantID(m_name), value, count); else services->setVertexShaderConstant(services->getVertexShaderConstantID(m_name), value, count); - std::copy(value, value + count, m_sent); - has_been_set = true; + if (cache) { + std::copy(value, value + count, m_sent); + has_been_set = true; + } } }; -template <typename T, std::size_t count = 1> -class CachedPixelShaderSetting : public CachedShaderSetting<T, count> { +template <typename T, std::size_t count = 1, bool cache=true> +class CachedPixelShaderSetting : public CachedShaderSetting<T, count, cache> { public: CachedPixelShaderSetting(const char *name) : - CachedShaderSetting<T, count>(name, true){} + CachedShaderSetting<T, count, cache>(name, true){} }; -template <typename T, std::size_t count = 1> -class CachedVertexShaderSetting : public CachedShaderSetting<T, count> { +template <typename T, std::size_t count = 1, bool cache=true> +class CachedVertexShaderSetting : public CachedShaderSetting<T, count, cache> { public: CachedVertexShaderSetting(const char *name) : - CachedShaderSetting<T, count>(name, false){} + CachedShaderSetting<T, count, cache>(name, false){} }; |
