blob: 161a80862a07c89c0bfb814b4057998944f92d13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BLI_map.hh"
#include "BLI_string_ref.hh"
#include "GPU_shader.h"
namespace blender::realtime_compositor {
/* -------------------------------------------------------------------------------------------------
* Static Shader Manager
*
* A static shader manager is a map of shaders identified by their info name that can be acquired
* and reused throughout the evaluation of the compositor and are only freed when the shader
* manager is destroyed. Once a shader is acquired for the first time, it will be cached in the
* manager to be potentially acquired later if needed without the shader creation overhead. */
class StaticShaderManager {
private:
/* The set of shaders identified by their info name that are currently available in the manager
* to be acquired. */
Map<StringRef, GPUShader *> shaders_;
public:
~StaticShaderManager();
/* Check if there is an available shader with the given info name in the manager, if such shader
* exists, return it, otherwise, return a newly created shader and add it to the manager. */
GPUShader *get(const char *info_name);
};
} // namespace blender::realtime_compositor
|