Beatmup
storage.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, 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 "../basic_types.h"
21 #include "../memory.h"
22 #include "../bitmap/internal_bitmap.h"
23 #include "../gpu/pipeline.h"
24 #include "../gpu/program.h"
25 #include "../gpu/texture_handler.h"
26 #include "../utils/fixed_point.h"
27 #include "../utils/string_utils.h"
28 #include <vector>
29 
30 
31 namespace Beatmup {
32  namespace NNets {
33  /**
34  Operation 3D input/output size.
35  Dimensions are X (width), Y (height), Z (depth).
36  */
37  class Size {
38  private:
39  int dim[3];
40 
41  public:
42  /**
43  Zero padding specification
44  */
45  enum class Padding {
46  SAME, //!< operation output size matches its input size for unit strides
47  VALID //!< no zero padding
48  };
49 
50  static const Size EMPTY;
51  static const Size ONES;
52 
53  inline Size() { dim[0] = dim[1] = dim[2] = 0; }
54  inline Size(const Size& size, int depth) : Size(size[0], size[1], depth) {}
55  Size(int width, int height, int depth);
56 
57  inline bool operator==(const Size& size) const {
58  return (dim[0] == size.dim[0]) && (dim[1] == size.dim[1]) && (dim[2] == size.dim[2]);
59  }
60 
61  inline bool operator!=(const Size& size) const {
62  return (dim[0] != size.dim[0]) || (dim[1] != size.dim[1]) || (dim[2] != size.dim[2]);
63  }
64 
65  inline int& operator[](int di) {
66  BEATMUP_ASSERT_DEBUG(0 <= di && di < 3);
67  return dim[di];
68  }
69 
70  inline int operator[](int di) const {
71  BEATMUP_ASSERT_DEBUG(0 <= di && di < 3);
72  return dim[di];
73  }
74 
75  inline int getWidth() const { return dim[0]; }
76  inline int getHeight() const { return dim[1]; }
77  inline int getDepth() const { return dim[2]; }
78 
79  inline int volume() const {
80  return dim[0] * dim[1] * dim[2];
81  }
82 
83  inline bool zero() const {
84  return dim[0] == 0 || dim[1] == 0 || dim[2] == 0;
85  }
86 
87  /**
88  Computes operation output size in function of operation kernel, padding, stride and depth,
89  assuming that the current Size is the input size.
90  \param[in] kernel The operation kernel size
91  \param[in] stride The stride
92  \param[in] padding The padding
93  \param[in] depth The output depth. If zero, the input depth is taken.
94  \return the output size.
95  */
96  Size transform(Size kernel, Size stride, Padding padding, int depth = 0) const;
97 
98  /**
99  Computes operation origin in function of operation kernel, padding and stride, assuming that the current
100  Size instance is the input size.
101  \param[in] kernel The operation kernel size
102  \param[in] stride The stride
103  \param[in] padding The padding
104  \return the origin.
105  */
106  Size getOrigin(Size kernel, Size stride, Padding padding) const;
107 
108  Size operator+(const Size& size) const { return Size(dim[0] + size[0], dim[1] + size[1], dim[2] + size[2]); }
109  Size operator-(const Size& size) const { return Size(dim[0] - size[0], dim[1] - size[1], dim[2] - size[2]); }
110  Size operator*(const Size& size) const { return Size(dim[0] * size[0], dim[1] * size[1], dim[2] * size[2]); }
111  Size operator/(const Size& size) const { return Size(dim[0] / size[0], dim[1] / size[1], dim[2] / size[2]); }
112  Size operator+(int scalar) const { return Size(dim[0] + scalar, dim[1] + scalar, dim[2] + scalar); }
113  Size operator-(int scalar) const { return Size(dim[0] - scalar, dim[1] - scalar, dim[2] - scalar); }
114  Size operator*(int scalar) const { return Size(dim[0] * scalar, dim[1] * scalar, dim[2] * scalar); }
115  Size operator/(int scalar) const { return Size(dim[0] / scalar, dim[1] / scalar, dim[2] / scalar); }
116  };
117 
118  /**
119  3D tensor stored in a set of textures.
120  Constraints:
121  * The tensor entries are in [0, 1] range and sampled in 8 bits.
122  * The tensor depth is a multiple of 4.
123  Feature maps are stored as RGBA textures (at least four channels per texture). More feature maps can be packed in the same texture.
124  The textures are all of the same size though.
125  */
126  class Storage : public Beatmup::Object {
127  public:
128  class Binder;
129  class View;
130  class Scanner;
131  class TextureHandler;
132 
133  private:
134  friend class Binder;
135  friend class View;
136  Storage(const Storage&) = delete; //!< disabling copying constructor
137 
138  typedef struct {
140  bool dirty; //!< if `true`, the texture needs to be cleared before use
141  } Texture;
142 
145  AlignedMemory memory; //!< data storage in RAM
146  const Size size;
147  const int pad; //!< padding in pixels added along width and height dimensions
148  int packX, packY; //!< number of blocks of 4 channels per texture (spatial packing)
149  bool upToDate[2];
150 
151  void push(GraphicPipeline& gpu, const void* data);
152 
153  public:
154  /**
155  Creates a storage.
156  \param[in] ctx A context
157  \param[in] gpu A graphic pipeline instance
158  \param[in] size Storage size
159  \param[in] pad Additional padding to add to the texture dimensions
160  \param[in] reservedChannels Number of depth dimensions that may be sampled together with this storage
161  */
162  Storage(Context& ctx, GraphicPipeline& gpu, const Size size, const int pad, const int reservedChannels = 0);
163 
164  /**
165  Creates a flat storage.
166  It uses only one texture stacking all the feature maps in a column and has no padding.
167  \param[in] ctx A context
168  \param[in] gpu A graphic pipeline instance
169  \param[in] size Storage size
170  */
171  Storage(Context& ctx, GraphicPipeline& gpu, const Size size);
172 
173  ~Storage();
174 
175  /**
176  Allocates the storage in GPU memory.
177  \param[in] gpu A graphic pipeline instance
178  */
179  void allocate(GraphicPipeline& gpu);
180 
181  /**
182  Allocates the storage in RAM.
183  */
184  void allocate();
185 
186  /**
187  Frees the allocated memory immediately.
188  \param[in] gpu A graphic pipeline instance
189  */
190  void free(GraphicPipeline& gpu);
191 
192  /**
193  Deferred storage disposal: the textures are put into the GPU recycle bin associated with the context.
194  */
195  void free();
196 
197  /**
198  Pulls storage data from GPU memory to RAM
199  \param[in] gpu A graphic pipeline instance
200  */
201  void pull(GraphicPipeline& gpu);
202 
203  /**
204  Pushes storage data from RAM to CPU memory
205  \param[in] gpu A graphic pipeline instance
206  */
207  void push(GraphicPipeline& gpu);
208 
209  /**
210  \brief Pushes a given data to GPU memory.
211  The data is stored as a 3D array of (height, width, channels) layout (n and n+1 channel values are next to each other in memory).
212  If the array length does not match the storage capacity, an exception is thrown.
213  \param[in] gpu A graphic pipeline instance
214  \param[in] hwcData The data to push.
215  \param[in] numSamples The data array length (number of floating point values to push).
216  */
217  void push(GraphicPipeline& gpu, const float* hwcData, const size_t numSamples);
218 
219  /**
220  Checks if the storage is up to date for a given processing target (CPU or GPU).
221  \param[in] target The target (CPU or GPU)
222  \return `true` if the data is up-to-date.
223  */
224  inline bool isUpToDate(ProcessingTarget target) const { return upToDate[target]; }
225 
226  /**
227  Returns `true` if the storage is allocated
228  */
229  inline bool isAllocated() const { return textures != nullptr || memory; }
230 
231  /**
232  Converts a feature channel into a bitmap for debugging purposes.
233  \param[in] ctx A context
234  \param[in] gpu A graphic pipeline instance
235  \param[in] channel Feature channel number to export
236  */
237  InternalBitmap* getImage(Context& ctx, GraphicPipeline& gpu, int channel) const;
238 
239  /**
240  Returns total number of textures in the storage.
241  */
242  int getNumberOfTextures() const;
243 
244  /**
245  Returns number of texture containing a given channel.
246  */
247  int getChannelTextureNumber(int channel) const;
248 
249  /**
250  Returns origin in pixels of a given channel within the texture containing it.
251  */
252  IntPoint getChannelOrigin(int channel) const;
253 
254  /**
255  Returns width in pixels of all the textures.
256  */
257  int getTextureWidth() const;
258 
259  /**
260  Returns height in pixels of all the textures.
261  */
262  int getTextureHeight() const;
263 
264  /**
265  Returns storage padding.
266  Padding is zero-valued pixels on each side of the storage.
267  */
268  inline int getPadding() const { return pad; }
269 
270  /**
271  Returns storage size in pixels.
272  */
273  inline Size getSize() const { return size; }
274 
275  /*
276  Returns storage memory size in bytes.
277  If the storage is allocated on GPU and on CPU at the same time, the used memory size is twice the returned value.
278  */
279  inline size_t getMemorySize() const { return (size_t)getTextureWidth() * getTextureHeight() * getNumberOfTextures() * 4; }
280 
281  /**
282  Returns the storage memory, if allocated in RAM (for CPU).
283  */
284  inline AlignedMemory& getMemory() { return memory; }
285  inline const AlignedMemory& getMemory() const { return memory; }
286 
287  /**
288  Checks whether a channel number points to the first channel in a texture. Throws an exception otherwise.
289  */
290  inline static void checkChannelNumber(int channel) {
291  class InvalidChannelNumber : public Exception {
292  public:
293  InvalidChannelNumber(int channel): Exception("Invalid channel number / number of channels: %d", channel) {}
294  };
295  if (channel % 4 != 0)
296  throw InvalidChannelNumber(channel);
297  }
298 
300  public:
302  };
303 
304  /**
305  Maps a 3D tensor onto a storage.
306  Set of storage slices along the depth dimension.
307  */
308  class View {
309  friend class Binder;
310  friend class Scanner;
311  friend class TextureHandler;
312  private:
313  typedef struct {
314  int channelIdx; //!< channel number in its corresponding storage
315  int textureIdx; //!< texture number in the current view
316  } Channel;
317 
318  std::vector<Channel> channels; //!< channels of the view
319  std::vector<int> textures; //!< indices of textures in the storage
321 
322  public:
323  View(): storage(nullptr) {}
324  View(View&&);
325  View(const View&);
326  View& operator=(View&&);
327 
328  View(Storage& storage);
329 
330  /**
331  Creates a slice of another view.
332  \param[in] view The input storage view
333  \param[in] firstChannel First view channel index in the storage
334  \param[in] numChannels Number of channels in the view
335  */
336  View(View&& view, const int firstChannel, const int numChannels);
337 
338  /**
339  \brief Creates a view by shuffling storage channels.
340  For shuffling step n, the view will contain the storage channel quads in the following order:
341  0, 1, 2, 3, 4n, 4n+1, 4n+2, 4n+3, 8n, 8n+1, 8n+2, 8n+3, ..., 4, 5, 6, 7, 4n+4, 4n+5, 4n+6, 4n+7, 8n+4, ...
342  \param[in] storage The storage
343  \param[in] shuffleStep Shuffling step (n)
344  */
345  View(Storage& storage, const int shuffleStep);
346 
347  inline Storage& getStorage() { return *storage; }
348  inline const Storage& getStorage() const { return *storage; }
349 
350  InternalBitmap* getImage(Context& ctx, GraphicPipeline& gpu, int channel) const;
351 
352  /**
353  Returns total number of textures in the storage view.
354  */
355  inline int getNumberOfTextures() const { return (int)textures.size(); }
356 
357  /**
358  Returns number of the texture containing a given channel.
359  */
360  int getChannelTextureNumber(int channel) const;
361 
362  /**
363  Returns origin in pixels of a given channel within the texture containing it.
364  */
365  IntPoint getChannelOrigin(int channel) const;
366 
367  /**
368  Returns width in pixels of all the textures.
369  */
370  inline int getTextureWidth() const { return storage->getTextureWidth(); }
371 
372  /**
373  Returns height in pixels of all the textures.
374  */
375  inline int getTextureHeight() const { return storage->getTextureHeight(); }
376 
378 
379  /**
380  Conversion operator to a boolean expression (`true` if the view is not empty).
381  */
382  inline operator bool() const { return storage != nullptr; }
383 
384  inline Size getSize() const { return storage->getSize(); }
385 
386  /**
387  Returns the spatial size (width and height) of the storage in pixels.
388  */
389  inline IntPoint getSpatialSize() const {
390  const Size size = storage->getSize();
391  return IntPoint(size[0], size[1]);
392  };
393 
394  inline int getWidth() const { return storage->size[0]; }
395  inline int getHeight() const { return storage->size[1]; }
396  inline int getDepth() const { return 4 * (int)channels.size(); }
397  };
398 
399  /**
400  TextureHandler representation of a pack of 4 channels from a non-empty View.
401  Does not copy any data, only stores a reference to an existing texture.
402  */
404  private:
405  const int width, height;
406  void prepare(GraphicPipeline& gpu);
407  public:
408  TextureHandler(const View&, int channel);
409  ~TextureHandler();
410  const int getWidth() const { return width; }
411  const int getHeight() const { return height; }
412  const int getDepth() const { return 1; }
413  const GL::TextureHandler::TextureFormat getTextureFormat() const { return GL::TextureHandler::TextureFormat::RGBAx8; }
414  };
415 
416  /**
417  Binding of different input/output storages/texture handlers to a GLSL program
418  */
419  class Binder {
420  private:
424  int unit;
425  public:
427 
428  /**
429  Starts binding things to a program.
430  \param[in,out] program The program
431  \param[in,out] output Output storage
432  \param[in] channel Output storage channel to be filled
433  \return `true` if the program and the output texture are already bound, i.e. are the same as in previous binding.
434  */
435  bool begin(GL::Program& program, Storage::View& output, int channel);
436 
437  /**
438  Starts binding things to a program which renders to a bitmap.
439  \param[in,out] program The program
440  \param[in,out] output The output bitmap
441  */
442  void begin(GL::Program& program, AbstractBitmap& output);
443 
444  /**
445  Binds a storage (all of its textures) to a uniform sampler array variable.
446  \param[in] input The storage
447  \param[in] name The variable name
448  */
449  void operator()(Storage::View& input, const char* name);
450 
451  /**
452  Binds a single texture from a storage to a uniform sampler variable.
453  \param[in] input The storage
454  \param[in] name The variable name
455  \param[in] channel The channel number
456  */
457  void operator()(Storage::View& input, const char* name, int channel);
458 
459  void operator()(GL::TextureHandler& input, const char* name);
460  };
461 
462  /**
463  Scans a storageview in RAM for further computations on CPU.
464  A piece of an ancient civilization technology used when neural networks were still inferred with CPU.
465  */
466  class Scanner {
467  protected:
468  typedef uint8_t sample_t[4]; //!< four unsigned 8-bit scalars
469  Storage::View* view; //!< a view to sample
470  sample_t** ptr; //!< pointers at current position per channel
471  size_t ptrSize;
472  sample_t* data; //!< the texture data pointer
473 
474  public:
475  Scanner(): view(nullptr), ptr(nullptr), ptrSize(0) {}
477  ~Scanner();
478 
479  /**
480  Binds a view to the scanner
481  */
482  void bind(Storage::View& view);
483 
484  /**
485  Unbinds the current view from the scanner
486  */
487  void unbind();
488 
489  /**
490  Sets the pointer to a specific spatial position.
491  \param[in] x horizontal position in pixels
492  \param[in] y vertical position in pixels
493  */
494  void move(int x, int y);
495 
496  /**
497  Advances pointer by one pixel in scanline order (along the horizontal axis).
498  */
499  Scanner& operator++();
500 
501  /**
502  Extracts the content of feature maps at the current position.
503  Accepts iterators of floating point STL containers, e.g. std::vector<float>::begin() and std::vector<float>::end().
504  \param[in] begin Iterator to copy to
505  \param[in] limit Limiting iterator position. If reached, no more samples are copied.
506  */
507  template<typename T>
508  inline void fill(T begin, T limit) {
509  size_t i = 0;
510  const float factor = 1.0f / 255;
511  for (T it = begin; it != limit && i < ptrSize; ++i) {
512  *it++ = factor * (*ptr[i])[0];
513  if (it == limit) return;
514  *it++ = factor * (*ptr[i])[1];
515  if (it == limit) return;
516  *it++ = factor * (*ptr[i])[2];
517  if (it == limit) return;
518  *it++ = factor * (*ptr[i])[3];
519  }
520  }
521  };
522  };
523 
524 
525  /**
526  Returns a zero padding value from a string.
527  The conversion is case-insensitive. Raises an exception if cannot interpret the string.
528  \param[in] str The input string.
529  */
530  Size::Padding paddingFromString(const std::string& str);
531  }
532 }
533 
534 namespace std {
535  std::string to_string(const Beatmup::NNets::Size::Padding& padding);
536 }
A very basic class for any image.
Aligned memory buffer.
Definition: memory.h:27
Basic class: task and memory management, any kind of static data.
Definition: context.h:59
Base class for all exceptions.
Definition: exception.h:37
std::string message
Definition: exception.h:39
Regular OpenGL program.
Definition: program.h:229
TextureFormat
Texture format, specifies how the texture should be interpreted on the shader side.
Internal low-level GPU control API.
Definition: pipeline.h:33
Bitmap whose memory is managed by the Beatmup engine.
Operation 3D input/output size.
Definition: storage.h:37
Size operator+(int scalar) const
Definition: storage.h:112
int getHeight() const
Definition: storage.h:76
int & operator[](int di)
Definition: storage.h:65
Size operator*(const Size &size) const
Definition: storage.h:110
Size operator-(int scalar) const
Definition: storage.h:113
bool operator==(const Size &size) const
Definition: storage.h:57
Size operator+(const Size &size) const
Definition: storage.h:108
bool zero() const
Definition: storage.h:83
Size operator*(int scalar) const
Definition: storage.h:114
Size getOrigin(Size kernel, Size stride, Padding padding) const
Computes operation origin in function of operation kernel, padding and stride, assuming that the curr...
Definition: storage.cpp:72
static const Size ONES
Definition: storage.h:51
Padding
Zero padding specification.
Definition: storage.h:45
@ SAME
operation output size matches its input size for unit strides
Size operator-(const Size &size) const
Definition: storage.h:109
int volume() const
Definition: storage.h:79
Size operator/(const Size &size) const
Definition: storage.h:111
static const Size EMPTY
Definition: storage.h:50
int getWidth() const
Definition: storage.h:75
Size operator/(int scalar) const
Definition: storage.h:115
int operator[](int di) const
Definition: storage.h:70
bool operator!=(const Size &size) const
Definition: storage.h:61
Size transform(Size kernel, Size stride, Padding padding, int depth=0) const
Computes operation output size in function of operation kernel, padding, stride and depth,...
Definition: storage.cpp:58
int getDepth() const
Definition: storage.h:77
Size(const Size &size, int depth)
Definition: storage.h:54
Binding of different input/output storages/texture handlers to a GLSL program.
Definition: storage.h:419
Binder(GraphicPipeline &gpu)
Definition: storage.h:426
GraphicPipeline & gpu
Definition: storage.h:421
bool begin(GL::Program &program, Storage::View &output, int channel)
Starts binding things to a program.
Definition: storage.cpp:543
void operator()(Storage::View &input, const char *name)
Binds a storage (all of its textures) to a uniform sampler array variable.
Definition: storage.cpp:597
Scans a storageview in RAM for further computations on CPU.
Definition: storage.h:466
Scanner(Storage::View &view)
Definition: storage.h:476
uint8_t sample_t[4]
four unsigned 8-bit scalars
Definition: storage.h:468
Scanner & operator++()
Advances pointer by one pixel in scanline order (along the horizontal axis).
Definition: storage.cpp:676
sample_t * data
the texture data pointer
Definition: storage.h:472
sample_t ** ptr
pointers at current position per channel
Definition: storage.h:470
void move(int x, int y)
Sets the pointer to a specific spatial position.
Definition: storage.cpp:663
void fill(T begin, T limit)
Extracts the content of feature maps at the current position.
Definition: storage.h:508
void unbind()
Unbinds the current view from the scanner.
Definition: storage.cpp:657
Storage::View * view
a view to sample
Definition: storage.h:469
void bind(Storage::View &view)
Binds a view to the scanner.
Definition: storage.cpp:638
TextureHandler representation of a pack of 4 channels from a non-empty View.
Definition: storage.h:403
const int getHeight() const
Height of the texture in pixels.
Definition: storage.h:411
const GL::TextureHandler::TextureFormat getTextureFormat() const
Returns the texture format specifying how the shader must interpret the data.
Definition: storage.h:413
const int getWidth() const
Width of the texture in pixels.
Definition: storage.h:410
const int getDepth() const
Depth of the texture in pixels.
Definition: storage.h:412
void prepare(GraphicPipeline &gpu)
Prepares (eventually uploads) texture data on GPU.
Definition: storage.cpp:538
Maps a 3D tensor onto a storage.
Definition: storage.h:308
int getTextureHeight() const
Returns height in pixels of all the textures.
Definition: storage.h:375
View & operator=(View &&)
Definition: storage.cpp:417
IntPoint getChannelOrigin(int channel) const
Returns origin in pixels of a given channel within the texture containing it.
Definition: storage.cpp:509
InternalBitmap * getImage(Context &ctx, GraphicPipeline &gpu, int channel) const
Definition: storage.cpp:491
const Storage & getStorage() const
Definition: storage.h:348
std::vector< Channel > channels
channels of the view
Definition: storage.h:318
IntPoint getTextureSize() const
Definition: storage.h:377
IntPoint getSpatialSize() const
Returns the spatial size (width and height) of the storage in pixels.
Definition: storage.h:389
int getChannelTextureNumber(int channel) const
Returns number of the texture containing a given channel.
Definition: storage.cpp:500
int getNumberOfTextures() const
Returns total number of textures in the storage view.
Definition: storage.h:355
int getTextureWidth() const
Returns width in pixels of all the textures.
Definition: storage.h:370
std::vector< int > textures
indices of textures in the storage
Definition: storage.h:319
3D tensor stored in a set of textures.
Definition: storage.h:126
bool isUpToDate(ProcessingTarget target) const
Checks if the storage is up to date for a given processing target (CPU or GPU).
Definition: storage.h:224
int getTextureWidth() const
Returns width in pixels of all the textures.
Definition: storage.cpp:390
void push(GraphicPipeline &gpu, const void *data)
Definition: storage.cpp:86
static void checkChannelNumber(int channel)
Checks whether a channel number points to the first channel in a texture.
Definition: storage.h:290
int getNumberOfTextures() const
Returns total number of textures in the storage.
Definition: storage.cpp:365
InternalBitmap * getImage(Context &ctx, GraphicPipeline &gpu, int channel) const
Converts a feature channel into a bitmap for debugging purposes.
Definition: storage.cpp:312
AlignedMemory memory
data storage in RAM
Definition: storage.h:145
const int pad
padding in pixels added along width and height dimensions
Definition: storage.h:147
Size getSize() const
Returns storage size in pixels.
Definition: storage.h:273
const AlignedMemory & getMemory() const
Definition: storage.h:285
int getTextureHeight() const
Returns height in pixels of all the textures.
Definition: storage.cpp:395
int getPadding() const
Returns storage padding.
Definition: storage.h:268
void free()
Deferred storage disposal: the textures are put into the GPU recycle bin associated with the context.
Definition: storage.cpp:204
AlignedMemory & getMemory()
Returns the storage memory, if allocated in RAM (for CPU).
Definition: storage.h:284
size_t getMemorySize() const
Definition: storage.h:279
Storage(const Storage &)=delete
disabling copying constructor
int packY
number of blocks of 4 channels per texture (spatial packing)
Definition: storage.h:148
bool isAllocated() const
Returns true if the storage is allocated.
Definition: storage.h:229
int getChannelTextureNumber(int channel) const
Returns number of texture containing a given channel.
Definition: storage.cpp:370
IntPoint getChannelOrigin(int channel) const
Returns origin in pixels of a given channel within the texture containing it.
Definition: storage.cpp:379
void allocate()
Allocates the storage in RAM.
Definition: storage.cpp:181
void pull(GraphicPipeline &gpu)
Pulls storage data from GPU memory to RAM.
Definition: storage.cpp:233
Beatmup object base class
Definition: basic_types.h:67
#define BEATMUP_ASSERT_DEBUG(C)
Definition: exception.h:163
unsigned int handle_t
A reference to a GPU resource.
Definition: basic_types.h:61
Size::Padding paddingFromString(const std::string &str)
Returns a zero padding value from a string.
Definition: storage.cpp:703
CustomPoint< int > IntPoint
Definition: geometry.h:629
ProcessingTarget
Definition: basic_types.h:55
Definition: geometry.h:721
std::string to_string(Beatmup::NNets::ActivationFunction function)
bool dirty
if true, the texture needs to be cleared before use
Definition: storage.h:140
int channelIdx
channel number in its corresponding storage
Definition: storage.h:314
int textureIdx
texture number in the current view
Definition: storage.h:315
return(jlong) new Beatmup jlong jstring name
jobject jlong jint jint y
Beatmup::Context * ctx
jlong jint width
jlong jint jint height
jobject jlong jint x
jlong jobject size
layer getMapping().setCenterPosition(Beatmup jlong jfloat factor
JNIEnv jobject jstring str