ShaderCache.hpp
1 #pragma once
2 #include <Gfx/Graph/RenderState.hpp>
3 
4 #include <score/gfx/OpenGL.hpp>
5 #include <score/tools/std/StringHash.hpp>
6 
7 #include <ossia/detail/hash_map.hpp>
8 
9 #if __has_include(<QtShaderTools/rhi/qshaderbaker.h>)
10 #include <QtShaderTools/rhi/qshaderbaker.h>
11 #else
12 #include <QtShaderTools/private/qshaderbaker_p.h>
13 #endif
14 
15 namespace score::gfx
16 {
21 {
22 public:
28  static const std::pair<QShader, QString>&
29  get(const RenderState& v, const QByteArray& shader, QShader::Stage stage);
30  static const std::pair<QShader, QString>&
31  get(GraphicsApi api, const QShaderVersion& v, const QByteArray& shader,
32  QShader::Stage stage);
33 
34 private:
35  ShaderCache();
36 
37  struct Baker
38  {
39  explicit Baker(GraphicsApi api, const QShaderVersion& v);
40 
41  GraphicsApi api;
42  QShaderVersion version;
43  QShaderBaker baker;
44  ossia::hash_map<QByteArray, std::pair<QShader, QString>> shaders;
45  };
46 
47  std::vector<std::unique_ptr<Baker>> m_bakers;
48 };
49 }
Graphics rendering pipeline for ossia score.
Definition: Filter/PreviewWidget.hpp:12
GraphicsApi
Available graphics APIs to use.
Definition: RenderState.hpp:17
Global state associated to a rendering context.
Definition: RenderState.hpp:31
Cache of baked QShader instances.
Definition: ShaderCache.hpp:21
static const std::pair< QShader, QString > & get(const RenderState &v, const QByteArray &shader, QShader::Stage stage)
Get a QShader from a source string.
Definition: ShaderCache.cpp:45