mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 09:58:46 +00:00
Cleanup driver interface
This commit is contained in:
parent
879fe9da61
commit
b0079c38be
11 changed files with 661 additions and 518 deletions
File diff suppressed because it is too large
Load diff
|
@ -474,7 +474,6 @@ public:
|
|||
virtual void forceDXTCCompression(bool dxtcComp);
|
||||
virtual void setAnisotropicFilter(sint filter);
|
||||
virtual void forceTextureResize(uint divisor);
|
||||
virtual void forceNativeFragmentPrograms(bool nativeOnly);
|
||||
virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties);
|
||||
// @}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace NL3D {
|
|||
* \brief CGPUProgramParams
|
||||
* \date 2013-09-07 22:17GMT
|
||||
* \author Jan Boon (Kaetemi)
|
||||
* A storage for user-provided parameters for GPU programs.
|
||||
* A storage for USERCODE-PROVIDED parameters for GPU programs.
|
||||
* Allows for fast updating and iteration of parameters.
|
||||
* NOTE TO DRIVER IMPLEMENTORS: DO NOT USE FOR STORING COPIES
|
||||
* OF HARDCODED MATERIAL PARAMETERS OR DRIVER PARAMETERS!!!
|
||||
* OF HARDCODED DRIVER MATERIAL PARAMETERS OR DRIVER PARAMETERS!!!
|
||||
*/
|
||||
class CGPUProgramParams
|
||||
{
|
||||
|
@ -66,36 +66,70 @@ public:
|
|||
CGPUProgramParams();
|
||||
virtual ~CGPUProgramParams();
|
||||
|
||||
void setF(uint index, float f0);
|
||||
void setF(uint index, float f0, float f1);
|
||||
void setF(uint index, float f0, float f1, float f2);
|
||||
void setF(uint index, float f0, float f1, float f2, float f3);
|
||||
void setI(uint index, int i0);
|
||||
void setI(uint index, int i0, int i1);
|
||||
void setI(uint index, int i0, int i1, int i2);
|
||||
void setI(uint index, int i0, int i1, int i2, int i3);
|
||||
void setF(uint index, const NLMISC::CVector& v);
|
||||
void setF(uint index, const NLMISC::CMatrix& m);
|
||||
void setF(uint index, uint num, const float *src);
|
||||
// Copy from another params storage
|
||||
void copy(CGPUProgramParams *params);
|
||||
|
||||
// Set by index, available only when the associated program has been compiled
|
||||
void set1f(uint index, float f0);
|
||||
void set2f(uint index, float f0, float f1);
|
||||
void set3f(uint index, float f0, float f1, float f2);
|
||||
void set4f(uint index, float f0, float f1, float f2, float f3);
|
||||
void set1i(uint index, sint32 i0);
|
||||
void set2i(uint index, sint32 i0, sint32 i1);
|
||||
void set3i(uint index, sint32 i0, sint32 i1, sint32 i2);
|
||||
void set4i(uint index, sint32 i0, sint32 i1, sint32 i2, sint32 i3);
|
||||
void set3f(uint index, const NLMISC::CVector& v);
|
||||
void set4f(uint index, const NLMISC::CVector& v, float f3);
|
||||
void set4x4f(uint index, const NLMISC::CMatrix& m);
|
||||
void set1fv(uint index, size_t num, const float *src);
|
||||
void set2fv(uint index, size_t num, const float *src);
|
||||
void set3fv(uint index, size_t num, const float *src);
|
||||
void set4fv(uint index, size_t num, const float *src);
|
||||
void unset(uint index);
|
||||
|
||||
// Set by name, it is recommended to use index when repeatedly setting an element
|
||||
void set1f(const std::string &name, float f0);
|
||||
void set2f(const std::string &name, float f0, float f1);
|
||||
void set3f(const std::string &name, float f0, float f1, float f2);
|
||||
void set4f(const std::string &name, float f0, float f1, float f2, float f3);
|
||||
void set1i(const std::string &name, sint32 i0);
|
||||
void set2i(const std::string &name, sint32 i0, sint32 i1);
|
||||
void set3i(const std::string &name, sint32 i0, sint32 i1, sint32 i2);
|
||||
void set4i(const std::string &name, sint32 i0, sint32 i1, sint32 i2, sint32 i3);
|
||||
void set3f(const std::string &name, const NLMISC::CVector& v);
|
||||
void set4f(const std::string &name, const NLMISC::CVector& v, float f3);
|
||||
void set4x4f(const std::string &name, const NLMISC::CMatrix& m);
|
||||
void set1fv(const std::string &name, size_t num, const float *src);
|
||||
void set2fv(const std::string &name, size_t num, const float *src);
|
||||
void set3fv(const std::string &name, size_t num, const float *src);
|
||||
void set4fv(const std::string &name, size_t num, const float *src);
|
||||
void unset(const std::string &name);
|
||||
|
||||
/// Maps the given name to the given index, on duplicate entry the data set by name will be prefered as it can be assumed to have been set after the data set by index
|
||||
void map(uint index, const std::string &name);
|
||||
|
||||
// Internal
|
||||
/// Allocate specified number of components if necessary
|
||||
size_t allocOffset(uint index, uint count, TType type);
|
||||
size_t allocOffset(const std::string &name, uint count, TType type);
|
||||
/// Return offset for specified index
|
||||
size_t getOffset(uint index) const;
|
||||
size_t getOffset(const std::string &name) const;
|
||||
/// Remove by offset
|
||||
void freeOffset(size_t offset);
|
||||
|
||||
// Iteration
|
||||
// Iteration (returns the offsets for access using getFooByOffset)
|
||||
size_t getBegin() const { return m_Meta.size() ? m_First : s_End; }
|
||||
size_t getNext(size_t offset) const { return m_Meta[offset].Next; }
|
||||
size_t getEnd() const { return s_End; }
|
||||
|
||||
// Data access
|
||||
uint getCountByOffset(size_t offset) { return m_Meta[offset].Count; }
|
||||
uint getCountByOffset(size_t offset) { return m_Meta[offset].Count; } // component count (number of floats or ints)
|
||||
float *getPtrFByOffset(size_t offset) { return m_Vec[offset].F; }
|
||||
int *getPtrIByOffset(size_t offset) { return m_Vec[offset].I; }
|
||||
TType getTypeByOffset(size_t offset) { return m_Meta[offset].Type; }
|
||||
uint getIndexByOffset(size_t offset) { return m_Meta[offset].Index; }
|
||||
const std::string *getNameByOffset(size_t offset); // non-optimized for dev tools only, may return NULL if name unknown
|
||||
|
||||
// Utility
|
||||
static inline uint getNbRegistersByComponents(uint count) { return (count + 3) >> 2; } // vector register per 4 components
|
||||
|
@ -103,7 +137,8 @@ public:
|
|||
private:
|
||||
std::vector<CVec> m_Vec;
|
||||
std::vector<CMeta> m_Meta;
|
||||
std::vector<size_t> m_Map; // map from index to buffer index
|
||||
std::vector<size_t> m_Map; // map from index to offset
|
||||
std::map<std::string, size_t> m_MapName; // map from name to offset
|
||||
size_t m_First;
|
||||
size_t m_Last;
|
||||
static const size_t s_End = -1;
|
||||
|
|
|
@ -673,13 +673,6 @@ public:
|
|||
*/
|
||||
virtual void forceTextureResize(uint divisor)=0;
|
||||
|
||||
/** Sets enforcement of native fragment programs. This is by default enabled.
|
||||
*
|
||||
* \param nativeOnly If set to false, fragment programs don't need to be native to stay loaded,
|
||||
* otherwise (aka if true) they will be purged.
|
||||
*/
|
||||
virtual void forceNativeFragmentPrograms(bool nativeOnly) = 0;
|
||||
|
||||
/** Setup monitor color properties.
|
||||
*
|
||||
* Return false if setup failed.
|
||||
|
|
|
@ -240,24 +240,9 @@ void IDriver::removeMatDrvInfoPtr(ItMatDrvInfoPtrList shaderIt)
|
|||
_MatDrvInfos.erase(shaderIt);
|
||||
}
|
||||
// ***************************************************************************
|
||||
/*void IDriver::removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt)
|
||||
void IDriver::removeGPUPrgDrvInfoPtr(ItGPUPrgDrvInfoPtrList gpuPrgDrvInfoIt)
|
||||
{
|
||||
_ShaderDrvInfos.erase(shaderIt);
|
||||
}
|
||||
// ***************************************************************************
|
||||
void IDriver::removeVtxPrgDrvInfoPtr(ItVtxPrgDrvInfoPtrList vtxPrgDrvInfoIt)
|
||||
{
|
||||
_VtxPrgDrvInfos.erase(vtxPrgDrvInfoIt);
|
||||
}
|
||||
// ***************************************************************************
|
||||
void IDriver::removePixelPrgDrvInfoPtr(ItPixelPrgDrvInfoPtrList pixelPrgDrvInfoIt)
|
||||
{
|
||||
_PixelPrgDrvInfos.erase(pixelPrgDrvInfoIt);
|
||||
}*/
|
||||
// ***************************************************************************
|
||||
void IDriver::removeGPUPrgDrvInfoPtr(ItGPUPrgDrvInfoPtrList vtxPrgDrvInfoIt)
|
||||
{
|
||||
_GPUPrgDrvInfos.erase(vtxPrgDrvInfoIt);
|
||||
_GPUPrgDrvInfos.erase(gpuPrgDrvInfoIt);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
|
|
@ -880,7 +880,6 @@ public:
|
|||
virtual void forceDXTCCompression(bool dxtcComp);
|
||||
virtual void setAnisotropicFilter(sint filter);
|
||||
virtual void forceTextureResize(uint divisor);
|
||||
virtual void forceNativeFragmentPrograms(bool /* nativeOnly */) {} // ignored
|
||||
|
||||
// Driver information
|
||||
virtual uint getNumAdapter() const;
|
||||
|
|
|
@ -1993,12 +1993,6 @@ static void fetchPerturbedEnvMapR200()
|
|||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDriverGL::forceNativeFragmentPrograms(bool nativeOnly)
|
||||
{
|
||||
_ForceNativeFragmentPrograms = nativeOnly;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDriverGL::initFragmentShaders()
|
||||
{
|
||||
|
|
|
@ -370,8 +370,6 @@ public:
|
|||
|
||||
virtual void forceTextureResize(uint divisor);
|
||||
|
||||
virtual void forceNativeFragmentPrograms(bool nativeOnly);
|
||||
|
||||
/// Setup texture env functions. Used by setupMaterial
|
||||
void setTextureEnvFunction(uint stage, CMaterial& mat);
|
||||
|
||||
|
|
|
@ -1496,12 +1496,6 @@ void CDriverUser::forceTextureResize(uint divisor)
|
|||
|
||||
_Driver->forceTextureResize(divisor);
|
||||
}
|
||||
void CDriverUser::forceNativeFragmentPrograms(bool nativeOnly)
|
||||
{
|
||||
NL3D_HAUTO_UI_DRIVER;
|
||||
|
||||
_Driver->forceNativeFragmentPrograms(nativeOnly);
|
||||
}
|
||||
bool CDriverUser::setMonitorColorProperties (const CMonitorColorProperties &properties)
|
||||
{
|
||||
NL3D_HAUTO_UI_DRIVER;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <nel/misc/matrix.h>
|
||||
|
||||
// Project includes
|
||||
#include <nel/3d/driver.h>
|
||||
|
||||
using namespace std;
|
||||
// using namespace NLMISC;
|
||||
|
@ -52,20 +53,20 @@ CGPUProgramParams::~CGPUProgramParams()
|
|||
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, float f0)
|
||||
void CGPUProgramParams::set(uint index, float f0)
|
||||
{
|
||||
float *f = getPtrFByOffset(allocOffset(index, 1, Float));
|
||||
f[0] = f0;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, float f0, float f1)
|
||||
void CGPUProgramParams::set(uint index, float f0, float f1)
|
||||
{
|
||||
float *f = getPtrFByOffset(allocOffset(index, 2, Float));
|
||||
f[0] = f0;
|
||||
f[1] = f1;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, float f0, float f1, float f2)
|
||||
void CGPUProgramParams::set(uint index, float f0, float f1, float f2)
|
||||
{
|
||||
float *f = getPtrFByOffset(allocOffset(index, 3, Float));
|
||||
f[0] = f0;
|
||||
|
@ -73,7 +74,7 @@ void CGPUProgramParams::setF(uint index, float f0, float f1, float f2)
|
|||
f[2] = f2;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, float f0, float f1, float f2, float f3)
|
||||
void CGPUProgramParams::set(uint index, float f0, float f1, float f2, float f3)
|
||||
{
|
||||
float *f = getPtrFByOffset(allocOffset(index, 4, Float));
|
||||
f[0] = f0;
|
||||
|
@ -82,20 +83,20 @@ void CGPUProgramParams::setF(uint index, float f0, float f1, float f2, float f3)
|
|||
f[3] = f3;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setI(uint index, int i0)
|
||||
void CGPUProgramParams::set(uint index, int i0)
|
||||
{
|
||||
int *i = getPtrIByOffset(allocOffset(index, 1, Int));
|
||||
i[0] = i0;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setI(uint index, int i0, int i1)
|
||||
void CGPUProgramParams::set(uint index, int i0, int i1)
|
||||
{
|
||||
int *i = getPtrIByOffset(allocOffset(index, 2, Int));
|
||||
i[0] = i0;
|
||||
i[1] = i1;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setI(uint index, int i0, int i1, int i2)
|
||||
void CGPUProgramParams::set(uint index, int i0, int i1, int i2)
|
||||
{
|
||||
int *i = getPtrIByOffset(allocOffset(index, 3, Int));
|
||||
i[0] = i0;
|
||||
|
@ -103,7 +104,7 @@ void CGPUProgramParams::setI(uint index, int i0, int i1, int i2)
|
|||
i[2] = i2;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setI(uint index, int i0, int i1, int i2, int i3)
|
||||
void CGPUProgramParams::set(uint index, int i0, int i1, int i2, int i3)
|
||||
{
|
||||
int *i = getPtrIByOffset(allocOffset(index, 4, Int));
|
||||
i[0] = i0;
|
||||
|
@ -112,7 +113,7 @@ void CGPUProgramParams::setI(uint index, int i0, int i1, int i2, int i3)
|
|||
i[3] = i3;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, const NLMISC::CVector& v)
|
||||
void CGPUProgramParams::set(uint index, const NLMISC::CVector& v)
|
||||
{
|
||||
float *f = getPtrFByOffset(allocOffset(index, 3, Float));
|
||||
f[0] = v.x;
|
||||
|
@ -120,7 +121,7 @@ void CGPUProgramParams::setF(uint index, const NLMISC::CVector& v)
|
|||
f[2] = v.z;
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, const NLMISC::CMatrix& m)
|
||||
void CGPUProgramParams::set(uint index, const NLMISC::CMatrix& m)
|
||||
{
|
||||
// TODO: Verify this!
|
||||
float *f = getPtrFByOffset(allocOffset(index, 16, Float));
|
||||
|
@ -129,11 +130,18 @@ void CGPUProgramParams::setF(uint index, const NLMISC::CMatrix& m)
|
|||
mt.get(f);
|
||||
}
|
||||
|
||||
void CGPUProgramParams::setF(uint index, uint num, const float *src)
|
||||
void CGPUProgramParams::set(uint index, const float *arr, size_t sz)
|
||||
{
|
||||
float *f = getPtrFByOffset(allocOffset(index, num, Float));
|
||||
for (uint i = 0; i < num; ++i)
|
||||
f[i] = src[i];
|
||||
float *f = getPtrFByOffset(allocOffset(index, sz, Float));
|
||||
for (uint c = 0; c < sz; ++c)
|
||||
f[c] = arr[c];
|
||||
}
|
||||
|
||||
void CGPUProgramParams::set(uint index, const sint32 *arr, size_t sz)
|
||||
{
|
||||
int *i = getPtrIByOffset(allocOffset(index, sz, Int));
|
||||
for (uint c = 0; c < sz; ++c)
|
||||
i[c] = arr[c];
|
||||
}
|
||||
|
||||
/// Allocate specified number of components if necessary
|
||||
|
|
|
@ -563,6 +563,7 @@ bool CStereoOVR::endRenderTarget()
|
|||
NL3D::IDriver *drvInternal = (static_cast<CDriverUser *>(m_Driver))->getDriver();
|
||||
NL3D::CMaterial *barrelMat = m_BarrelMat.getObjectPtr();
|
||||
barrelMat->setTexture(0, m_BarrelTex);
|
||||
|
||||
drvInternal->activePixelProgram(m_PixelProgram);
|
||||
|
||||
float w = float(m_BarrelQuadLeft.V1.x),// / float(width),
|
||||
|
@ -582,20 +583,21 @@ bool CStereoOVR::endRenderTarget()
|
|||
float scaleY = (h / 2);
|
||||
float scaleInX = (2 / w);
|
||||
float scaleInY = (2 / h);
|
||||
drvInternal->setPixelProgramConstant(0, lensCenterX, lensCenterY, 0.f, 0.f);
|
||||
drvInternal->setPixelProgramConstant(1, screenCenterX, screenCenterY, 0.f, 0.f);
|
||||
drvInternal->setPixelProgramConstant(2, scaleX, scaleY, 0.f, 0.f);
|
||||
drvInternal->setPixelProgramConstant(3, scaleInX, scaleInY, 0.f, 0.f);
|
||||
drvInternal->setPixelProgramConstant(4, 1, m_DevicePtr->HMDInfo.DistortionK);
|
||||
|
||||
|
||||
drvInternal->setPixelProgram2f(0, lensCenterX, lensCenterY);
|
||||
drvInternal->setPixelProgram2f(1, screenCenterX, screenCenterY);
|
||||
drvInternal->setPixelProgram2f(2, scaleX, scaleY);
|
||||
drvInternal->setPixelProgram2f(3, scaleInX, scaleInY);
|
||||
drvInternal->setPixelProgram4fv(4, 1, m_DevicePtr->HMDInfo.DistortionK);
|
||||
|
||||
m_Driver->drawQuad(m_BarrelQuadLeft, m_BarrelMat);
|
||||
|
||||
x = w;
|
||||
lensCenterX = x + (w - lensViewportShift * 0.5f) * 0.5f;
|
||||
screenCenterX = x + w * 0.5f;
|
||||
drvInternal->setPixelProgramConstant(0, lensCenterX, lensCenterY, 0.f, 0.f);
|
||||
drvInternal->setPixelProgramConstant(1, screenCenterX, screenCenterY, 0.f, 0.f);
|
||||
|
||||
drvInternal->setPixelProgram2f(0, lensCenterX, lensCenterY);
|
||||
drvInternal->setPixelProgram2f(1, screenCenterX, screenCenterY);
|
||||
|
||||
m_Driver->drawQuad(m_BarrelQuadRight, m_BarrelMat);
|
||||
|
||||
|
|
Loading…
Reference in a new issue