📄 densematrixongpu.h
字号:
// DenseMatrixOnGPU.h: interface for the DenseMatrixOnGPU class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DENSEMATRIXONGPU_H__863248F1_EA85_4FA1_89BE_C05A14BE02FB__INCLUDED_)
#define AFX_DENSEMATRIXONGPU_H__863248F1_EA85_4FA1_89BE_C05A14BE02FB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "extgl.h"
///////////////////////////////////////
// General Matrix represent on GPU
///////////////////////////////////////
class CDenseMatrixOnGPU
{
private:
int _iDim;
int _iWidth, _iHeight; //Texture size
unsigned int *_iTexID; //for matrix*vector
unsigned int _iWholeTexID; //for matrix*matrix
GLenum _iTextureTarget;
public:
bool _bInitialized;
bool _bFloat;
int _iChannelsNum;
public:
CDenseMatrixOnGPU();
virtual ~CDenseMatrixOnGPU();
/////////////////////////////////////////////////////
//// save matrix as N textures
//// each diagonal is a squad texture
/////////////////////////////////////////////////////
void SetData(float *M, int DimSize);
float* GetData(int &DimSize);
// Returns the texture ID for matrix*vector operation
inline unsigned int GetTextureID(int i) const { if(i<_iDim)return _iTexID[i];else return 0; }
// Returns the texture size.
inline int GetHeight() const { return _iHeight; }
inline int GetWidth() const {return _iWidth; }
inline int GetChannelsNum() const {return _iChannelsNum;}
// Returns the Matrix's size
inline int GetDim() const { return _iDim;}
// Returns the texture target this texture is bound to.
unsigned int GetTextureTarget() const { return _iTextureTarget; }
/////////////////////////////////////////////////////
//// This one save the matrix as a rectangle_texture,
//// which NOT require (size = pow of 2)
//// Prepare for matrix-matrix multiply
/////////////////////////////////////////////////////
void SetData(float *M, int m, int n);
float* GetData(int &m, int &n);
// Returns the texture ID for matrix*matrix operation
inline unsigned int GetWholeTextureID() const { return _iWholeTexID; }
/////////////////////////////////////////////////////
//// USE multi textures
//// Just modify DenseMatVecFP and Fragment Program
//// Don't modify the data arrangement
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
//// Arrange multi-diagonal data into ONE texture RGBA
//// Need to re-arrange the diagonal data
////
/////////////////////////////////////////////////////
int MaxTexNum;
int LeftNum;
void SetMultiData(float *M, int DimSize);
float* GetMultiData(int &DimSize);
};
#endif // !defined(AFX_DENSEMATRIXONGPU_H__863248F1_EA85_4FA1_89BE_C05A14BE02FB__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -