20 #include "../gpu/pipeline.h"
21 #include "../gpu/program_bank.h"
85 inline const int getWidth()
const {
return 1; }
87 inline const int getDepth()
const {
return 1; }
Basic class: task and memory management, any kind of static data.
Evaluates expression A*x + b = y for a matrix A and vectors x and b using GPU.
Matrix * matrix
the matrix ("A")
RenderingProgram * lastSumStage
last summation stage program: adding bias and clamping output
Vector * bias
optional bias vector ("b")
LinearMapping(Context &context, bool forceFixed16=false)
Instantiates LinearMapping.
const int leftPadding
zero pixels added on the left side in the buffers to sum for whatever the input size is
const bool forceFixed16Storage
if true, 16 bit fixed-point storages are used even if floating point compute is supported by the GPU
bool fixed16Output
if true, the output vector y is stored using 16 bit fixed-point format (float or texture otherwise)
void setBias(GraphicPipeline &gpu, const int height, const float *values)
Matrix * buffer[2]
intermediate buffers used at summation stage in a circular fashion
void prepare(GraphicPipeline &gpu, TextureHandler &output, TextureHandler &input, ProgramBank *bank=nullptr)
Prepares the mapping for application (builds its GPU programs).
RenderingProgram * multStage
multiplication stage program: small pieces of the vector are multiplied by small pieces of the matrix
void process(GraphicPipeline &gpu, TextureHandler &output, TextureHandler &input)
static const int SUM_STAGE_STEPS
number of vectors summed per shader at the summation stage
ProgramBank * programBank
if not null, manages the programs
RenderingProgram * sumStage
summation stage program: the pieces are collected together (repeated multiple times)
bool fixed16Input
if true, the input vector x is stored using 16 bit fixed-point format (float or texture otherwise)
std::vector< std::array< float, SUM_STAGE_STEPS > > sumStageDelta
static const int MULT_STAGE_STEPS
number of 4*4 blocks processed at the multiplication stage
std::vector< Beatmup::Rectangle > sumStageTexCoords
void setMatrix(GraphicPipeline &gpu, const int width, const int height, const float *values)
void operator()(GraphicPipeline &gpu, TextureHandler &result, TextureHandler &input)
Beatmup::Rectangle multStageTexCoords
std::array< float, 4 > multStageDelta
Stores linked GLSL programs and their associated fragment shader codes.
GLSL program to render images Makes use of default vertex attributes to pass the texture coordinates ...
TextureFormat
Texture format, specifies how the texture should be interpreted on the shader side.
Real-valued vector usable by GPU.
const int getHeight() const
Height of the texture in pixels.
const TextureFormat getTextureFormat() const
Returns the texture format specifying how the shader must interpret the data.
const Format format
data format
const int size
number of samples in the vector
void fetch(GraphicPipeline &gpu, std::vector< float > &output) const
Grabs vector values back from GPU to user memory.
float getMappingOffset() const
Provides the constant offset added to the vector values sent to GPU.
const int getWidth() const
Width of the texture in pixels.
float getMappingScale() const
Provides the scale factor applied to the vector values sent to GPU.
int getSize() const
Returns the length of the vector.
Vector(Context &context, GraphicPipeline &gpu, const int size, const Format format)
const int getDepth() const
Depth of the texture in pixels.
Format
Vector data format.
@ FIXED16
16 bit per element
@ TEXTURE
8 bit per element covering [0, 1] range
@ FLOAT
32 bit per element, floating point
Format getDataFormat() const
const TextureFormat texFormat
texture format of the texture handler
size_t getMemorySize() const
Returns memory size in bytes taken by the vector.
static const Format DEFAULT_FORMAT
void prepare(GraphicPipeline &gpu)
Prepares (eventually uploads) texture data on GPU.
Internal low-level GPU control API.
Real-valued matrix usable by GPU.