Beatmup
Beatmup::GLES20X2UpsamplingNetwork::Layer Class Reference

Public Types

typedef InternalBitmapStorage
 

Public Member Functions

 Layer (GL::RecycleBin &recycleBin, GraphicPipeline &gpu, Storage &outputStorage, const char *sourceCode)
 
void process (Context &ctx, GraphicPipeline &gpu, GL::TextureHandler &input)
 
void process (Context &ctx, GraphicPipeline &gpu, Layer **inputs, int inputsCount)
 
InternalBitmapgetOutput ()
 

Private Attributes

ImageShader shader
 
Storageoutput
 

Detailed Description

Definition at line 31 of file cnn.h.

Member Typedef Documentation

◆ Storage

Constructor & Destructor Documentation

◆ Layer()

GLES20X2UpsamplingNetwork::Layer::Layer ( GL::RecycleBin recycleBin,
GraphicPipeline gpu,
Storage outputStorage,
const char *  sourceCode 
)

Definition at line 29 of file cnn.cpp.

29  :
30  shader(recycleBin), output(outputStorage)
31 {
32  shader.setSourceCode(sourceCode);
33 }
void setSourceCode(const std::string &sourceCode)
Passes new source code to the fragment shader.

Member Function Documentation

◆ process() [1/2]

void GLES20X2UpsamplingNetwork::Layer::process ( Context ctx,
GraphicPipeline gpu,
GL::TextureHandler input 
)

Definition at line 36 of file cnn.cpp.

36  {
37  // reshape or instantiate output if needed
38  bool sizeChange = false;
39  if (output && (output->getWidth() != input.getWidth() || output->getHeight() != input.getHeight())) {
40  output->reshape(input.getWidth(), input.getHeight());
41  sizeChange = true;
42  }
43  else if (!output) {
44  output = new InternalBitmap(ctx, PixelFormat::QuadByte, input.getWidth(), input.getHeight(), false);
45  sizeChange = true;
46  }
47 
48  // reset size if needed
49  if (sizeChange) {
50  shader.setFloat("d1", 1.0f / input.getWidth(), 1.0f / input.getHeight());
51  shader.setFloat("d2", 2.0f / input.getWidth(), 2.0f / input.getHeight());
52  }
53 
54  // process
55  {
58  shader.process(gpu);
59  }
60 }
Makes a bitmap writable for a specific target device.
static const AffineMapping IDENTITY
Definition: geometry.h:717
virtual const int getHeight() const =0
Height of the texture in pixels.
virtual const int getWidth() const =0
Width of the texture in pixels.
void setFloat(std::string name, float value)
Sets a scalar float uniform value.
void process(GraphicPipeline &gpu)
Apply the shader to produce an image.
void prepare(GraphicPipeline &gpu, GL::TextureHandler *input, const TextureParam texParam, AbstractBitmap *output, const AffineMapping &mapping)
Conducts required preparations for blending.
Bitmap whose memory is managed by the Beatmup engine.
const int getHeight() const
Height of the texture in pixels.
const int getWidth() const
Width of the texture in pixels.
void reshape(int width, int height)
Changes bitmap size.
@ QuadByte
4 channels of 8 bits per pixel (like RGBA), unsigned integer values
@ INTERP_NEAREST
nearest neighbor pixel interpolation
Beatmup::Context * ctx

◆ process() [2/2]

void GLES20X2UpsamplingNetwork::Layer::process ( Context ctx,
GraphicPipeline gpu,
Layer **  inputs,
int  inputsCount 
)

Definition at line 63 of file cnn.cpp.

63  {
64  const InternalBitmap& input = inputs[0]->getOutput();
65  if (output && (output->getWidth() != input.getWidth() || output->getHeight() != input.getHeight()))
66  output->reshape(input.getWidth(), input.getHeight());
67  else if (!output)
68  output = new InternalBitmap(ctx, PixelFormat::QuadByte, input.getWidth(), input.getHeight(), false);
69 
70  // prepare and process
71  {
73  shader.setFloat("d1", 1.0f / input.getWidth(), 1.0f / input.getHeight());
74  shader.prepare(gpu, nullptr, output);
75 
76  // bind images
77  for (int i = 0; i < inputsCount; ++i)
78  gpu.bind(inputs[i]->getOutput(), i, TextureParam::INTERP_NEAREST);
79  shader.bindSamplerArray("images", 0, inputsCount);
80 
81  // process
82  shader.process(gpu);
83  }
84 }
void bind(GL::TextureHandler &texture, size_t texUnit, const TextureParam param)
Definition: pipeline.cpp:881
void bindSamplerArray(const char *uniformId, int startingUnit, int numUnits)
Binds a bunch of texture units to a uniform sampler array variable.

◆ getOutput()

InternalBitmap& Beatmup::GLES20X2UpsamplingNetwork::Layer::getOutput ( )
inline

Definition at line 43 of file cnn.h.

43  {
44  return *output;
45  }

Member Data Documentation

◆ shader

ImageShader Beatmup::GLES20X2UpsamplingNetwork::Layer::shader
private

Definition at line 35 of file cnn.h.

◆ output

Storage& Beatmup::GLES20X2UpsamplingNetwork::Layer::output
private

Definition at line 36 of file cnn.h.


The documentation for this class was generated from the following files: