20 #if !defined(__MITSUBA_HW_GPUPROGRAM_H_)
21 #define __MITSUBA_HW_GPUPROGRAM_H_
50 GPUProgram(
const std::string &name =
"default");
53 inline void setName(
const std::string &name) { m_name = name; }
56 inline const std::string &
getName()
const {
return m_name; }
59 inline void setSource(
EType type,
const std::string &source) { m_source[type] = source; }
62 void setSourceFile(EType type,
const fs::path &path);
65 inline const std::string &
getSource(
EType type)
const {
return m_source[type]; }
68 virtual void init() = 0;
71 virtual void bind() = 0;
74 virtual void unbind() = 0;
77 virtual void cleanup() = 0;
80 virtual int getParameterID(
const std::string &name,
bool failIfMissing =
true)
const = 0;
84 bool failIfMissing =
true) {
85 setParameter(getParameterID(name, failIfMissing), value);
90 bool failIfMissing =
true) {
91 setParameter(getParameterID(name, failIfMissing), value);
96 bool failIfMissing =
true) {
97 setParameter(getParameterID(name, failIfMissing), value);
102 bool failIfMissing =
true) {
103 setParameter(getParameterID(name, failIfMissing), value);
108 bool failIfMissing =
true) {
109 setParameter(getParameterID(name, failIfMissing), value);
114 bool failIfMissing =
true) {
115 setParameter(getParameterID(name, failIfMissing), value);
120 bool failIfMissing =
true) {
121 setParameter(getParameterID(name, failIfMissing), value);
126 bool failIfMissing =
true) {
127 setParameter(getParameterID(name, failIfMissing), value);
132 bool failIfMissing =
true) {
133 setParameter(getParameterID(name, failIfMissing), value);
138 bool failIfMissing =
true) {
139 setParameter(getParameterID(name, failIfMissing), value);
144 bool failIfMissing =
true) {
145 setParameter(getParameterID(name, failIfMissing), value);
150 bool failIfMissing =
true) {
151 setParameter(getParameterID(name, failIfMissing), value);
156 bool failIfMissing =
true) {
157 setParameter(getParameterID(name, failIfMissing), value);
162 bool failIfMissing =
true) {
163 setParameter(getParameterID(name, failIfMissing), value);
168 bool failIfMissing =
true) {
169 setParameter(getParameterID(name, failIfMissing), value);
174 bool failIfMissing =
true) {
175 setParameter(getParameterID(name, failIfMissing), value);
180 bool failIfMissing =
true) {
181 setParameter(getParameterID(name, failIfMissing), value);
186 bool failIfMissing =
true) {
187 setParameter(getParameterID(name, failIfMissing), value.
getMatrix());
192 bool failIfMissing =
true) {
193 setParameter(getParameterID(name, failIfMissing), value);
198 bool failIfMissing =
true) {
199 setParameter(getParameterID(name, failIfMissing), value);
205 bool failIfMissing =
true) {
206 setParameter(getParameterID(name, failIfMissing), value);
210 virtual void setParameter(
int id,
bool value) = 0;
213 virtual void setParameter(
int id,
Float value) = 0;
216 virtual void setParameter(
int id,
int value) = 0;
219 virtual void setParameter(
int id,
uint32_t value) = 0;
222 virtual void setParameter(
int id,
const Vector &value) = 0;
225 virtual void setParameter(
int id,
const Vector3i &value) = 0;
228 virtual void setParameter(
int id,
const Vector2 &value) = 0;
231 virtual void setParameter(
int id,
const Vector2i &value) = 0;
234 virtual void setParameter(
int id,
const Vector4 &value) = 0;
237 virtual void setParameter(
int id,
const Point &value) = 0;
240 virtual void setParameter(
int id,
const Point3i &value) = 0;
243 virtual void setParameter(
int id,
const Point2 &value) = 0;
246 virtual void setParameter(
int id,
const Point2i &value) = 0;
249 virtual void setParameter(
int id,
const Point4 &value) = 0;
252 virtual void setParameter(
int id,
const Matrix2x2 &value) = 0;
255 virtual void setParameter(
int id,
const Matrix3x3 &value) = 0;
258 virtual void setParameter(
int id,
const Matrix4x4 &value) = 0;
266 virtual void setParameter(
int id,
const Color3 &value) = 0;
269 virtual void setParameter(
int id,
const Spectrum &value) = 0;
273 virtual void setParameter(
int id,
const GPUTexture *value) = 0;
297 inline bool isBound()
const {
return m_bound; }
300 inline void define(
const std::string &key,
const std::string &value =
"") {
301 m_definitions[key] = value;
310 std::
string m_source[3];
315 std::map<std::
string, std::
string> m_definitions;
void setOutputGeometryType(EGeometryType type)
Set the output type of the geometry shader.
Definition: gpuprogram.h:291
Definition: gpuprogram.h:45
void setParameter(const std::string &name, const Point &value, bool failIfMissing=true)
Set a Point parameter by name.
Definition: gpuprogram.h:137
void define(const std::string &key, const std::string &value="")
Create a preprocessor definition (must be used before 'init')
Definition: gpuprogram.h:300
EGeometryType getOutputGeometryType() const
Return the output type of the geometry shader.
Definition: gpuprogram.h:294
Definition: gpuprogram.h:42
void setName(const std::string &name)
Set the name of this program.
Definition: gpuprogram.h:53
void setParameter(const std::string &name, const Vector3i &value, bool failIfMissing=true)
Set a Vector3i parameter by name.
Definition: gpuprogram.h:113
void setParameter(const std::string &name, const Point3i &value, bool failIfMissing=true)
Set a Point3i parameter by name.
Definition: gpuprogram.h:143
EGeometryType getInputGeometryType() const
Return the input type of the geometry shader.
Definition: gpuprogram.h:288
Basic 2x2 matrix data type.
Definition: matrix.h:455
void setParameter(const std::string &name, const Vector2i &value, bool failIfMissing=true)
Set a Vector2i parameter by name.
Definition: gpuprogram.h:125
Abstract shader program (for fragment/vertex shading)
Definition: gpuprogram.h:30
RGB color data type.
Definition: spectrum.h:612
void setInputGeometryType(EGeometryType type)
Set the input type of the geometry shader.
Definition: gpuprogram.h:285
EType
Denotes the different components of this program.
Definition: gpuprogram.h:33
void setParameter(const std::string &name, const Point4 &value, bool failIfMissing=true)
Set a Point4 parameter by name.
Definition: gpuprogram.h:161
void setParameter(const std::string &name, const Matrix4x4 &value, bool failIfMissing=true)
Set a Matrix4x4 parameter by name.
Definition: gpuprogram.h:179
void setParameter(const std::string &name, uint32_t value, bool failIfMissing=true)
Set an unsigned integer parameter by name.
Definition: gpuprogram.h:95
const std::string & getName() const
Return the name of this program.
Definition: gpuprogram.h:56
void setParameter(int id, const Transform &value)
Set a Transform parameter.
Definition: gpuprogram.h:261
void setParameter(const std::string &name, const Matrix2x2 &value, bool failIfMissing=true)
Set a Matrix2x2 parameter by name.
Definition: gpuprogram.h:167
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
int getMaxVertices() const
Returns the max. number of vertices generated by the geometry shader.
Definition: gpuprogram.h:279
void setParameter(const std::string &name, const Point2 &value, bool failIfMissing=true)
Set a Point2 parameter by name.
Definition: gpuprogram.h:149
void setParameter(const std::string &name, const Spectrum &value, bool failIfMissing=true)
Set a Spectrum parameter (will be converted to linear RGB) by name.
Definition: gpuprogram.h:197
Definition: gpuprogram.h:41
Definition: gpuprogram.h:43
EGeometryType
Common geometry shader input/output types.
Definition: gpuprogram.h:40
void setParameter(const std::string &name, int value, bool failIfMissing=true)
Set a integer parameter by name.
Definition: gpuprogram.h:89
A data structure for 1/2/3D and cube texture mapping. Also has optional render-to-texture functionali...
Definition: gputexture.h:32
void setMaxVertices(int maxVertices)
Set the max. number of vertices generated by the geometry shader.
Definition: gpuprogram.h:282
void setParameter(const std::string &name, bool value, bool failIfMissing=true)
Set a boolean parameter by name.
Definition: gpuprogram.h:83
void setParameter(const std::string &name, const Color3 &value, bool failIfMissing=true)
Set a Color3 parameter by name.
Definition: gpuprogram.h:191
const std::string & getSource(EType type) const
Get the source code of this program.
Definition: gpuprogram.h:65
Basic 4x4 matrix data type.
Definition: matrix.h:656
void setParameter(const std::string &name, Float value, bool failIfMissing=true)
Set a float parameter by name.
Definition: gpuprogram.h:101
void setParameter(const std::string &name, const GPUTexture *value, bool failIfMissing=true)
Definition: gpuprogram.h:204
void setSource(EType type, const std::string &source)
Set the source code of this program.
Definition: gpuprogram.h:59
Parent of all Mitsuba classes.
Definition: object.h:38
bool isBound() const
Definition: gpuprogram.h:297
Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range...
Definition: spectrum.h:663
virtual std::string toString() const
Return a human-readable string representation of the object's contents.
void setParameter(const std::string &name, const Vector &value, bool failIfMissing=true)
Set a Vector parameter by name.
Definition: gpuprogram.h:107
Definition: gpuprogram.h:35
void setParameter(const std::string &name, const Matrix3x3 &value, bool failIfMissing=true)
Set a Matrix3x3 parameter by name.
Definition: gpuprogram.h:173
Definition: gpuprogram.h:44
void setParameter(const std::string &name, const Transform &value, bool failIfMissing=true)
Set a Transform parameter by name.
Definition: gpuprogram.h:185
Basic 3x3 matrix data type.
Definition: matrix.h:560
void setParameter(const std::string &name, const Point2i &value, bool failIfMissing=true)
Set a Point2i parameter by name.
Definition: gpuprogram.h:155
void setParameter(const std::string &name, const Vector2 &value, bool failIfMissing=true)
Set a Vector2 parameter by name.
Definition: gpuprogram.h:119
void setParameter(const std::string &name, const Vector4 &value, bool failIfMissing=true)
Set a Vector4 parameter by name.
Definition: gpuprogram.h:131