mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
Added diff to opengl driver for old nevrax pixel program code, marked todos in comments
This commit is contained in:
parent
cb966505cc
commit
acf8ec653c
6 changed files with 90 additions and 26 deletions
|
@ -1293,9 +1293,6 @@ public:
|
|||
virtual void stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass) = 0;
|
||||
virtual void stencilMask(uint mask) = 0;
|
||||
|
||||
// get the number of texture samplers available for pû•el programs
|
||||
virtual uint getMaxTexturesForEffects() const = 0;
|
||||
|
||||
protected:
|
||||
friend class IVBDrvInfos;
|
||||
friend class IIBDrvInfos;
|
||||
|
|
|
@ -482,6 +482,7 @@ bool CDriverGL::setupDisplay()
|
|||
}
|
||||
|
||||
_VertexProgramEnabled= false;
|
||||
_PixelProgramEnabled= false;
|
||||
_LastSetupGLArrayVertexProgram= false;
|
||||
|
||||
// Init VertexArrayRange according to supported extenstion.
|
||||
|
@ -737,6 +738,12 @@ void CDriverGL::disableHardwareVertexProgram()
|
|||
_Extensions.DisableHardwareVertexProgram= true;
|
||||
}
|
||||
|
||||
void CDriverGL::disableHardwarePixelProgram()
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_disableHardwarePixelProgram)
|
||||
_Extensions.DisableHardwarePixelProgram= true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDriverGL::disableHardwareVertexArrayAGP()
|
||||
{
|
||||
|
@ -854,6 +861,7 @@ bool CDriverGL::swapBuffers()
|
|||
// Reset texture shaders
|
||||
//resetTextureShaders();
|
||||
activeVertexProgram(NULL);
|
||||
activePixelProgram(NULL);
|
||||
|
||||
#ifndef USE_OPENGLES
|
||||
/* Yoyo: must do this (GeForce bug ??) else weird results if end render with a VBHard.
|
||||
|
|
|
@ -306,6 +306,7 @@ public:
|
|||
virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0);
|
||||
|
||||
virtual void disableHardwareVertexProgram();
|
||||
virtual void disableHardwarePixelProgram();
|
||||
virtual void disableHardwareVertexArrayAGP();
|
||||
virtual void disableHardwareTextureShader();
|
||||
|
||||
|
@ -692,6 +693,7 @@ private:
|
|||
virtual class IVertexBufferHardGL *createVertexBufferHard(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb);
|
||||
friend class CTextureDrvInfosGL;
|
||||
friend class CVertexProgamDrvInfosGL;
|
||||
friend class CPixelProgamDrvInfosGL;
|
||||
|
||||
private:
|
||||
// Version of the driver. Not the interface version!! Increment when implementation of the driver change.
|
||||
|
@ -1302,8 +1304,10 @@ private:
|
|||
// @{
|
||||
|
||||
bool isVertexProgramSupported () const;
|
||||
bool isPixelProgramSupported () const;
|
||||
bool isVertexProgramEmulated () const;
|
||||
bool activeVertexProgram (CVertexProgram *program);
|
||||
bool activePixelProgram (CPixelProgram *program);
|
||||
void setConstant (uint index, float, float, float, float);
|
||||
void setConstant (uint index, double, double, double, double);
|
||||
void setConstant (uint indexStart, const NLMISC::CVector& value);
|
||||
|
@ -1314,6 +1318,15 @@ private:
|
|||
void setConstantFog (uint index);
|
||||
void enableVertexProgramDoubleSidedColor(bool doubleSided);
|
||||
bool supportVertexProgramDoubleSidedColor() const;
|
||||
|
||||
// Pixel program
|
||||
virtual void setPixelProgramConstant (uint index, float, float, float, float);
|
||||
virtual void setPixelProgramConstant (uint index, double, double, double, double);
|
||||
virtual void setPixelProgramConstant (uint index, const NLMISC::CVector& value);
|
||||
virtual void setPixelProgramConstant (uint index, const NLMISC::CVectorD& value);
|
||||
virtual void setPixelProgramConstant (uint index, uint num, const float *src);
|
||||
virtual void setPixelProgramConstant (uint index, uint num, const double *src);
|
||||
virtual void setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver::TTransform transform);
|
||||
|
||||
virtual bool supportMADOperator() const ;
|
||||
|
||||
|
@ -1328,6 +1341,12 @@ private:
|
|||
//@}
|
||||
|
||||
|
||||
/// \name Pixel program implementation
|
||||
// @{
|
||||
bool activeARBPixelProgram (CPixelProgram *program);
|
||||
// TODO_REMOVE_PARSER bool setupARBPixelProgram (const CPixelProgramParser::CPProgram &parsedProgram, GLuint id/*, bool &specularWritten*/);
|
||||
//@}
|
||||
|
||||
|
||||
/// \fallback for material shaders
|
||||
// @{
|
||||
|
@ -1340,15 +1359,27 @@ private:
|
|||
// Don't use glIsEnabled, too slow.
|
||||
return _VertexProgramEnabled;
|
||||
}
|
||||
|
||||
bool isPixelProgramEnabled () const
|
||||
{
|
||||
// Don't use glIsEnabled, too slow.
|
||||
return _PixelProgramEnabled;
|
||||
}
|
||||
|
||||
// Track state of activeVertexProgram()
|
||||
bool _VertexProgramEnabled;
|
||||
// Track state of activePixelProgram()
|
||||
bool _PixelProgramEnabled;
|
||||
|
||||
// Say if last setupGlArrays() was a VertexProgram setup.
|
||||
bool _LastSetupGLArrayVertexProgram;
|
||||
|
||||
// The last vertex program that was setupped
|
||||
NLMISC::CRefPtr<CVertexProgram> _LastSetuppedVP;
|
||||
|
||||
// The last pixel program that was setupped
|
||||
NLMISC::CRefPtr<CPixelProgram> _LastSetuppedPP;
|
||||
|
||||
bool _ForceDXTCCompression;
|
||||
/// Divisor for textureResize (power).
|
||||
uint _ForceTextureResizePower;
|
||||
|
@ -1518,6 +1549,17 @@ public:
|
|||
CVertexProgamDrvInfosGL (CDriverGL *drv, ItVtxPrgDrvInfoPtrList it);
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
class CPixelProgamDrvInfosGL : public IPixelProgramDrvInfos
|
||||
{
|
||||
public:
|
||||
// The GL Id.
|
||||
GLuint ID;
|
||||
|
||||
// The gl id is auto created here.
|
||||
CPixelProgamDrvInfosGL (CDriverGL *drv, ItPixelPrgDrvInfoPtrList it);
|
||||
};
|
||||
|
||||
#ifdef NL_STATIC
|
||||
} // NLDRIVERGL/ES
|
||||
#endif
|
||||
|
|
|
@ -1560,6 +1560,17 @@ void registerGlExtensions(CGlExtensions &ext)
|
|||
ext.EXTVertexShader = false;
|
||||
ext.ARBVertexProgram = false;
|
||||
}
|
||||
|
||||
// Check pixel program
|
||||
// Disable feature ???
|
||||
if(!ext.DisableHardwarePixelProgram)
|
||||
{
|
||||
ext.ARBFragmentProgram= setupARBFragmentProgram(glext);
|
||||
}
|
||||
else
|
||||
{
|
||||
ext.ARBFragmentProgram = false;
|
||||
}
|
||||
|
||||
ext.OESDrawTexture = setupOESDrawTexture(glext);
|
||||
ext.OESMapBuffer = setupOESMapBuffer(glext);
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
/// \name Disable Hardware feature. False by default. setuped by IDriver
|
||||
// @{
|
||||
bool DisableHardwareVertexProgram;
|
||||
bool DisableHardwarePixelProgram;
|
||||
bool DisableHardwareVertexArrayAGP;
|
||||
bool DisableHardwareTextureShader;
|
||||
// @}
|
||||
|
@ -174,6 +175,7 @@ public:
|
|||
|
||||
/// \name Disable Hardware feature. False by default. setuped by IDriver
|
||||
DisableHardwareVertexProgram= false;
|
||||
DisableHardwarePixelProgram= false;
|
||||
DisableHardwareVertexArrayAGP= false;
|
||||
DisableHardwareTextureShader= false;
|
||||
}
|
||||
|
|
|
@ -28,10 +28,8 @@
|
|||
#include "stdopengl.h"
|
||||
|
||||
#include "driver_opengl.h"
|
||||
#include "../../index_buffer.h"
|
||||
#include "../../vertex_program.h"
|
||||
//#include "../../vertex_program_parse.h"
|
||||
#include "../../program_parse_D3D.h"
|
||||
#include <nel/3d/index_buffer.h>
|
||||
#include <nel/3d/vertex_program.h>
|
||||
#include <algorithm>
|
||||
|
||||
// tmp
|
||||
|
@ -92,6 +90,8 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
|
|||
// Program setuped ?
|
||||
if (program->_DrvInfo==NULL)
|
||||
{
|
||||
/* TODO_REMOVE_PARSER
|
||||
|
||||
// Insert into driver list. (so it is deleted when driver is deleted).
|
||||
ItPixelPrgDrvInfoPtrList it= _PixelPrgDrvInfos.insert(_PixelPrgDrvInfos.end());
|
||||
|
||||
|
@ -127,6 +127,8 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
|
|||
_PixelPrgDrvInfos.erase(it);
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -150,7 +152,8 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO_REMOVE_PARSER
|
||||
#if 0
|
||||
// ***************************************************************************
|
||||
bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inParsedProgram, GLuint id/*, bool &specularWritten*/)
|
||||
{
|
||||
|
@ -206,6 +209,7 @@ bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inPa
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
|
@ -213,7 +217,8 @@ void CDriverGL::setPixelProgramConstant (uint index, float f0, float f1, float f
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
//if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, f0, f1, f2, f3);
|
||||
|
@ -227,7 +232,8 @@ void CDriverGL::setPixelProgramConstant (uint index, double d0, double d1, doubl
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, d0, d1, d2, d3);
|
||||
|
@ -241,7 +247,8 @@ void CDriverGL::setPixelProgramConstant (uint index, const NLMISC::CVector& valu
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0);
|
||||
|
@ -255,7 +262,8 @@ void CDriverGL::setPixelProgramConstant (uint index, const NLMISC::CVectorD& val
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0);
|
||||
|
@ -268,7 +276,8 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const float *src)
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
{
|
||||
|
@ -285,7 +294,8 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const double *src
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
{
|
||||
|
@ -303,7 +313,8 @@ void CDriverGL::setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matr
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_setPixelProgramConstantMatrix)
|
||||
|
||||
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
|
||||
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
|
||||
{
|
||||
if (_Extensions.ARBFragmentProgram)
|
||||
{
|
||||
|
@ -358,17 +369,8 @@ void CDriverGL::setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matr
|
|||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
uint CDriverGL::getMaxTexturesForEffects() const
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_getMaxTexturesForEffects)
|
||||
|
||||
uint texSamplerNb = 0;
|
||||
if (_Extensions.ARBFragmentProgram) // ARB implementation
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, (int*)(&texSamplerNb));
|
||||
|
||||
return texSamplerNb;
|
||||
}
|
||||
// TODO_REMOVE_PARSER
|
||||
#if 0
|
||||
|
||||
// ***************************************************************************
|
||||
// ***************** CPixelProgramConversionARB *****************************
|
||||
|
@ -550,4 +552,6 @@ void CPixelProgramConversionARB::ARBPixelProgramDumpOperand(const CPPOperand &op
|
|||
ARBProgramSuffix(op, destOperand, out);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // NL3D
|
||||
|
|
Loading…
Reference in a new issue