Added diff to opengl driver for old nevrax pixel program code, marked todos in comments

This commit is contained in:
kaetemi 2013-06-19 02:01:12 +02:00
parent cb966505cc
commit acf8ec653c
6 changed files with 90 additions and 26 deletions

View file

@ -1293,9 +1293,6 @@ public:
virtual void stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass) = 0; virtual void stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass) = 0;
virtual void stencilMask(uint mask) = 0; virtual void stencilMask(uint mask) = 0;
// get the number of texture samplers available for pû•el programs
virtual uint getMaxTexturesForEffects() const = 0;
protected: protected:
friend class IVBDrvInfos; friend class IVBDrvInfos;
friend class IIBDrvInfos; friend class IIBDrvInfos;

View file

@ -482,6 +482,7 @@ bool CDriverGL::setupDisplay()
} }
_VertexProgramEnabled= false; _VertexProgramEnabled= false;
_PixelProgramEnabled= false;
_LastSetupGLArrayVertexProgram= false; _LastSetupGLArrayVertexProgram= false;
// Init VertexArrayRange according to supported extenstion. // Init VertexArrayRange according to supported extenstion.
@ -737,6 +738,12 @@ void CDriverGL::disableHardwareVertexProgram()
_Extensions.DisableHardwareVertexProgram= true; _Extensions.DisableHardwareVertexProgram= true;
} }
void CDriverGL::disableHardwarePixelProgram()
{
H_AUTO_OGL(CDriverGL_disableHardwarePixelProgram)
_Extensions.DisableHardwarePixelProgram= true;
}
// *************************************************************************** // ***************************************************************************
void CDriverGL::disableHardwareVertexArrayAGP() void CDriverGL::disableHardwareVertexArrayAGP()
{ {
@ -854,6 +861,7 @@ bool CDriverGL::swapBuffers()
// Reset texture shaders // Reset texture shaders
//resetTextureShaders(); //resetTextureShaders();
activeVertexProgram(NULL); activeVertexProgram(NULL);
activePixelProgram(NULL);
#ifndef USE_OPENGLES #ifndef USE_OPENGLES
/* Yoyo: must do this (GeForce bug ??) else weird results if end render with a VBHard. /* Yoyo: must do this (GeForce bug ??) else weird results if end render with a VBHard.

View file

@ -306,6 +306,7 @@ public:
virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0);
virtual void disableHardwareVertexProgram(); virtual void disableHardwareVertexProgram();
virtual void disableHardwarePixelProgram();
virtual void disableHardwareVertexArrayAGP(); virtual void disableHardwareVertexArrayAGP();
virtual void disableHardwareTextureShader(); virtual void disableHardwareTextureShader();
@ -692,6 +693,7 @@ private:
virtual class IVertexBufferHardGL *createVertexBufferHard(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb); virtual class IVertexBufferHardGL *createVertexBufferHard(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb);
friend class CTextureDrvInfosGL; friend class CTextureDrvInfosGL;
friend class CVertexProgamDrvInfosGL; friend class CVertexProgamDrvInfosGL;
friend class CPixelProgamDrvInfosGL;
private: private:
// Version of the driver. Not the interface version!! Increment when implementation of the driver change. // Version of the driver. Not the interface version!! Increment when implementation of the driver change.
@ -1302,8 +1304,10 @@ private:
// @{ // @{
bool isVertexProgramSupported () const; bool isVertexProgramSupported () const;
bool isPixelProgramSupported () const;
bool isVertexProgramEmulated () const; bool isVertexProgramEmulated () const;
bool activeVertexProgram (CVertexProgram *program); bool activeVertexProgram (CVertexProgram *program);
bool activePixelProgram (CPixelProgram *program);
void setConstant (uint index, float, float, float, float); void setConstant (uint index, float, float, float, float);
void setConstant (uint index, double, double, double, double); void setConstant (uint index, double, double, double, double);
void setConstant (uint indexStart, const NLMISC::CVector& value); void setConstant (uint indexStart, const NLMISC::CVector& value);
@ -1314,6 +1318,15 @@ private:
void setConstantFog (uint index); void setConstantFog (uint index);
void enableVertexProgramDoubleSidedColor(bool doubleSided); void enableVertexProgramDoubleSidedColor(bool doubleSided);
bool supportVertexProgramDoubleSidedColor() const; 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 ; 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 /// \fallback for material shaders
// @{ // @{
@ -1340,15 +1359,27 @@ private:
// Don't use glIsEnabled, too slow. // Don't use glIsEnabled, too slow.
return _VertexProgramEnabled; return _VertexProgramEnabled;
} }
bool isPixelProgramEnabled () const
{
// Don't use glIsEnabled, too slow.
return _PixelProgramEnabled;
}
// Track state of activeVertexProgram() // Track state of activeVertexProgram()
bool _VertexProgramEnabled; bool _VertexProgramEnabled;
// Track state of activePixelProgram()
bool _PixelProgramEnabled;
// Say if last setupGlArrays() was a VertexProgram setup. // Say if last setupGlArrays() was a VertexProgram setup.
bool _LastSetupGLArrayVertexProgram; bool _LastSetupGLArrayVertexProgram;
// The last vertex program that was setupped // The last vertex program that was setupped
NLMISC::CRefPtr<CVertexProgram> _LastSetuppedVP; NLMISC::CRefPtr<CVertexProgram> _LastSetuppedVP;
// The last pixel program that was setupped
NLMISC::CRefPtr<CPixelProgram> _LastSetuppedPP;
bool _ForceDXTCCompression; bool _ForceDXTCCompression;
/// Divisor for textureResize (power). /// Divisor for textureResize (power).
uint _ForceTextureResizePower; uint _ForceTextureResizePower;
@ -1518,6 +1549,17 @@ public:
CVertexProgamDrvInfosGL (CDriverGL *drv, ItVtxPrgDrvInfoPtrList it); 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 #ifdef NL_STATIC
} // NLDRIVERGL/ES } // NLDRIVERGL/ES
#endif #endif

View file

@ -1560,6 +1560,17 @@ void registerGlExtensions(CGlExtensions &ext)
ext.EXTVertexShader = false; ext.EXTVertexShader = false;
ext.ARBVertexProgram = 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.OESDrawTexture = setupOESDrawTexture(glext);
ext.OESMapBuffer = setupOESMapBuffer(glext); ext.OESMapBuffer = setupOESMapBuffer(glext);

View file

@ -111,6 +111,7 @@ public:
/// \name Disable Hardware feature. False by default. setuped by IDriver /// \name Disable Hardware feature. False by default. setuped by IDriver
// @{ // @{
bool DisableHardwareVertexProgram; bool DisableHardwareVertexProgram;
bool DisableHardwarePixelProgram;
bool DisableHardwareVertexArrayAGP; bool DisableHardwareVertexArrayAGP;
bool DisableHardwareTextureShader; bool DisableHardwareTextureShader;
// @} // @}
@ -174,6 +175,7 @@ public:
/// \name Disable Hardware feature. False by default. setuped by IDriver /// \name Disable Hardware feature. False by default. setuped by IDriver
DisableHardwareVertexProgram= false; DisableHardwareVertexProgram= false;
DisableHardwarePixelProgram= false;
DisableHardwareVertexArrayAGP= false; DisableHardwareVertexArrayAGP= false;
DisableHardwareTextureShader= false; DisableHardwareTextureShader= false;
} }

View file

@ -28,10 +28,8 @@
#include "stdopengl.h" #include "stdopengl.h"
#include "driver_opengl.h" #include "driver_opengl.h"
#include "../../index_buffer.h" #include <nel/3d/index_buffer.h>
#include "../../vertex_program.h" #include <nel/3d/vertex_program.h>
//#include "../../vertex_program_parse.h"
#include "../../program_parse_D3D.h"
#include <algorithm> #include <algorithm>
// tmp // tmp
@ -92,6 +90,8 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
// Program setuped ? // Program setuped ?
if (program->_DrvInfo==NULL) if (program->_DrvInfo==NULL)
{ {
/* TODO_REMOVE_PARSER
// Insert into driver list. (so it is deleted when driver is deleted). // Insert into driver list. (so it is deleted when driver is deleted).
ItPixelPrgDrvInfoPtrList it= _PixelPrgDrvInfos.insert(_PixelPrgDrvInfos.end()); ItPixelPrgDrvInfoPtrList it= _PixelPrgDrvInfos.insert(_PixelPrgDrvInfos.end());
@ -127,6 +127,8 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
_PixelPrgDrvInfos.erase(it); _PixelPrgDrvInfos.erase(it);
return false; return false;
} }
*/
} }
else else
{ {
@ -150,7 +152,8 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
return true; return true;
} }
// TODO_REMOVE_PARSER
#if 0
// *************************************************************************** // ***************************************************************************
bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inParsedProgram, GLuint id/*, bool &specularWritten*/) bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inParsedProgram, GLuint id/*, bool &specularWritten*/)
{ {
@ -206,6 +209,7 @@ bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inPa
} }
return true; return true;
} }
#endif
// *************************************************************************** // ***************************************************************************
@ -213,7 +217,8 @@ void CDriverGL::setPixelProgramConstant (uint index, float f0, float f1, float f
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) //if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, f0, f1, f2, f3); 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) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) // if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, d0, d1, d2, d3); 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) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) // if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0); 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) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) // if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0); 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) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) // if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
{ {
@ -285,7 +294,8 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const double *src
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) // if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
{ {
@ -303,7 +313,8 @@ void CDriverGL::setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matr
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstantMatrix) H_AUTO_OGL(CDriverGL_setPixelProgramConstantMatrix)
if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram()) // if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{ {
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
{ {
@ -358,17 +369,8 @@ void CDriverGL::setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matr
} }
} }
// *************************************************************************** // TODO_REMOVE_PARSER
uint CDriverGL::getMaxTexturesForEffects() const #if 0
{
H_AUTO_OGL(CDriverGL_getMaxTexturesForEffects)
uint texSamplerNb = 0;
if (_Extensions.ARBFragmentProgram) // ARB implementation
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, (int*)(&texSamplerNb));
return texSamplerNb;
}
// *************************************************************************** // ***************************************************************************
// ***************** CPixelProgramConversionARB ***************************** // ***************** CPixelProgramConversionARB *****************************
@ -550,4 +552,6 @@ void CPixelProgramConversionARB::ARBPixelProgramDumpOperand(const CPPOperand &op
ARBProgramSuffix(op, destOperand, out); ARBProgramSuffix(op, destOperand, out);
} }
#endif
} // NL3D } // NL3D