Beatmup
program_bank.h
Go to the documentation of this file.
1
/*
2
Beatmup image and signal processing library
3
Copyright (C) 2020, lnstadrum
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
#include "../gpu/pipeline.h"
21
#include "../gpu/program.h"
22
#include "../context.h"
23
#include <string>
24
#include <map>
25
26
namespace
Beatmup
{
27
namespace
GL {
28
/**
29
Stores linked GLSL programs and their associated fragment shader codes.
30
*/
31
class
ProgramBank
:
public
Object
{
32
private
:
33
typedef
struct
{
34
GL::RenderingProgram
*
program
;
35
unsigned
int
userCount
;
36
}
ProgramHolder
;
37
38
std::map<std::string, ProgramHolder>
programs
;
//!< map of source code to programs without external texture extension
39
std::map<std::string, ProgramHolder>
programsWithExtTex
;
//!< map of source code to programs with external texture extension
40
41
bool
releaseProgram
(
GL::RenderingProgram
* program, std::map<std::string, ProgramHolder>& cache);
42
43
protected
:
44
Context
&
context
;
45
public
:
46
ProgramBank
(
Context
&
context
) :
context
(
context
) {}
47
~ProgramBank
();
48
49
/**
50
Provides a program given a fragment shader source code.
51
Creates a new program or returns an available one increasing its user count (do not call this too often).
52
\param[in] gpu A graphic pipeline instance
53
\param[in] code The fragment shader code of the program
54
\param[in] enableExternalTextures If `true`, external texture extension is enabled in the program, for example, to access camera image in Android
55
\return Linked program.
56
*/
57
GL::RenderingProgram
*
operator()
(
GraphicPipeline
& gpu,
const
std::string& code,
bool
enableExternalTextures =
false
);
58
59
/**
60
Marks a program as unused any more. If the program has no other users, its is destroyed.
61
\param[in] gpu A graphic pipeline instance
62
\param[in] program The program
63
*/
64
void
release
(
GraphicPipeline
& gpu,
GL::RenderingProgram
* program);
65
};
66
}
67
}
Beatmup::Context
Basic class: task and memory management, any kind of static data.
Definition:
context.h:59
Beatmup::GL::ProgramBank
Stores linked GLSL programs and their associated fragment shader codes.
Definition:
program_bank.h:31
Beatmup::GL::ProgramBank::operator()
GL::RenderingProgram * operator()(GraphicPipeline &gpu, const std::string &code, bool enableExternalTextures=false)
Provides a program given a fragment shader source code.
Definition:
program_bank.cpp:32
Beatmup::GL::ProgramBank::programs
std::map< std::string, ProgramHolder > programs
map of source code to programs without external texture extension
Definition:
program_bank.h:38
Beatmup::GL::ProgramBank::releaseProgram
bool releaseProgram(GL::RenderingProgram *program, std::map< std::string, ProgramHolder > &cache)
Definition:
program_bank.cpp:52
Beatmup::GL::ProgramBank::context
Context & context
Definition:
program_bank.h:44
Beatmup::GL::ProgramBank::~ProgramBank
~ProgramBank()
Definition:
program_bank.cpp:26
Beatmup::GL::ProgramBank::release
void release(GraphicPipeline &gpu, GL::RenderingProgram *program)
Marks a program as unused any more.
Definition:
program_bank.cpp:68
Beatmup::GL::ProgramBank::programsWithExtTex
std::map< std::string, ProgramHolder > programsWithExtTex
map of source code to programs with external texture extension
Definition:
program_bank.h:39
Beatmup::GL::ProgramBank::ProgramBank
ProgramBank(Context &context)
Definition:
program_bank.h:46
Beatmup::GL::RenderingProgram
GLSL program to render images Makes use of default vertex attributes to pass the texture coordinates ...
Definition:
program.h:240
Beatmup::GraphicPipeline
Internal low-level GPU control API.
Definition:
pipeline.h:33
Beatmup::Object
Beatmup object base class
Definition:
basic_types.h:67
Beatmup
Definition:
basic_types.h:22
Beatmup::GL::ProgramBank::ProgramHolder
Definition:
program_bank.h:33
Beatmup::GL::ProgramBank::ProgramHolder::program
GL::RenderingProgram * program
Definition:
program_bank.h:34
Beatmup::GL::ProgramBank::ProgramHolder::userCount
unsigned int userCount
Definition:
program_bank.h:35
core
gpu
program_bank.h
Generated on Tue Nov 21 2023 13:54:26 for Beatmup by
1.9.1