20 #include "../gpu/recycle_bin.h"
33 auto& cache = enableExternalTextures ? programsWithExtTex : programs;
35 auto search = cache.find(code);
36 if (search != cache.end()) {
37 auto& holder = search->second;
39 holder.program->
enable(gpu);
40 return holder.program;
47 cache.emplace(std::make_pair(code,
ProgramHolder{ program, 1 }));
53 for (
auto it = cache.begin(); it != cache.end(); ++it) {
54 auto& holder = it->second;
55 if (holder.program == program) {
57 if (holder.userCount == 0) {
69 if (!releaseProgram(program, programs) && !releaseProgram(program, programsWithExtTex))
70 throw RuntimeError(
"No program found in a program bank");
GL::RecycleBin * getGpuRecycleBin() const
void enable(const GraphicPipeline &gpu)
GL::RenderingProgram * operator()(GraphicPipeline &gpu, const std::string &code, bool enableExternalTextures=false)
Provides a program given a fragment shader source code.
std::map< std::string, ProgramHolder > programs
map of source code to programs without external texture extension
bool releaseProgram(GL::RenderingProgram *program, std::map< std::string, ProgramHolder > &cache)
void release(GraphicPipeline &gpu, GL::RenderingProgram *program)
Marks a program as unused any more.
void put(Item *item)
Puts an item into the recycle bin.
GLSL program to render images Makes use of default vertex attributes to pass the texture coordinates ...
Internal low-level GPU control API.
Extensions
Supported OpenGL estensions.
@ BEATMUP_DIALECT
pseudo-extension enabling Beatmup GLSL dialect
@ EXTERNAL_TEXTURE
GL_OES_EGL_image_external_essl3 if available or GL_OES_EGL_image_external.