mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-25 08:36:14 +00:00
Add function to check which pixel program profiles are available on a driver
This commit is contained in:
parent
52b9637167
commit
e1176c3198
9 changed files with 53 additions and 18 deletions
|
@ -142,6 +142,23 @@ public:
|
||||||
*/
|
*/
|
||||||
enum TMatrixCount { MaxModelMatrix= 16 };
|
enum TMatrixCount { MaxModelMatrix= 16 };
|
||||||
|
|
||||||
|
enum TPixelProgramProfile
|
||||||
|
{
|
||||||
|
// direct3d
|
||||||
|
ps_1_1 = 0xD3D00101,
|
||||||
|
ps_1_2 = 0xD3D00102,
|
||||||
|
ps_1_3 = 0xD3D00103,
|
||||||
|
ps_1_4 = 0xD3D00104,
|
||||||
|
ps_2_0 = 0xD3D00200,
|
||||||
|
ps_2_x = 0xD3D00201, // not sure...
|
||||||
|
ps_3_0 = 0xD3D00300,
|
||||||
|
|
||||||
|
// opengl
|
||||||
|
arbfp1 = 0x061A0100, // made up values
|
||||||
|
fp20 = 0x06100200,
|
||||||
|
fp30 = 0x06100300,
|
||||||
|
fp40 = 0x06100400,
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -1015,7 +1032,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* Does the driver supports pixel programs ?
|
* Does the driver supports pixel programs ?
|
||||||
*/
|
*/
|
||||||
virtual bool isPixelProgramSupported () const =0;
|
virtual bool isPixelProgramSupported() const =0;
|
||||||
|
virtual bool isPixelProgramSupported(TPixelProgramProfile profile) const =0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace NL3D
|
||||||
{
|
{
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
const uint32 IDriver::InterfaceVersion = 0x6b; // added anisotropic filter
|
const uint32 IDriver::InterfaceVersion = 0x6c; // pixel program interface
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )
|
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )
|
||||||
|
|
|
@ -1551,14 +1551,15 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
|
||||||
#endif // NL_FORCE_TEXTURE_STAGE_COUNT
|
#endif // NL_FORCE_TEXTURE_STAGE_COUNT
|
||||||
|
|
||||||
_VertexProgram = !_DisableHardwareVertexProgram && ((caps.VertexShaderVersion&0xffff) >= 0x0100);
|
_VertexProgram = !_DisableHardwareVertexProgram && ((caps.VertexShaderVersion&0xffff) >= 0x0100);
|
||||||
_PixelProgram = !_DisableHardwarePixelProgram && (caps.PixelShaderVersion&0xffff) >= 0x0101;
|
_PixelProgramVersion = _DisableHardwareVertexProgram ? 0x0000 : caps.PixelShaderVersion & 0xffff;
|
||||||
_PixelShader = !_DisableHardwarePixelShader && (caps.PixelShaderVersion&0xffff) >= 0x0101;
|
nldebug("Pixel Program Version: %i.%i", (uint32)((_PixelProgramVersion & 0xFF00) >> 8), (uint32)(_PixelProgramVersion & 0xFF));
|
||||||
|
_PixelProgram = _PixelProgramVersion >= 0x0101;
|
||||||
_MaxVerticesByVertexBufferHard = caps.MaxVertexIndex;
|
_MaxVerticesByVertexBufferHard = caps.MaxVertexIndex;
|
||||||
_MaxLight = caps.MaxActiveLights;
|
_MaxLight = caps.MaxActiveLights;
|
||||||
|
|
||||||
if(_MaxLight > 0xFF) _MaxLight = 3;
|
if(_MaxLight > 0xFF) _MaxLight = 3;
|
||||||
|
|
||||||
if (_PixelShader)
|
if (_PixelProgram)
|
||||||
{
|
{
|
||||||
_MaxNumPerStageConstantLighted = _NbNeLTextureStages;
|
_MaxNumPerStageConstantLighted = _NbNeLTextureStages;
|
||||||
_MaxNumPerStageConstantUnlighted = _NbNeLTextureStages;
|
_MaxNumPerStageConstantUnlighted = _NbNeLTextureStages;
|
||||||
|
@ -3626,7 +3627,7 @@ void CDriverD3D::CVertexProgramPtrState::apply(CDriverD3D *driver)
|
||||||
void CDriverD3D::CPixelShaderPtrState::apply(CDriverD3D *driver)
|
void CDriverD3D::CPixelShaderPtrState::apply(CDriverD3D *driver)
|
||||||
{
|
{
|
||||||
H_AUTO_D3D(CDriverD3D_CPixelShaderPtrState);
|
H_AUTO_D3D(CDriverD3D_CPixelShaderPtrState);
|
||||||
if (!driver->supportPixelShaders()) return;
|
if (!driver->isPixelProgramSupported()) return;
|
||||||
driver->_DeviceInterface->SetPixelShader(PixelShader);
|
driver->_DeviceInterface->SetPixelShader(PixelShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1008,6 +1008,7 @@ public:
|
||||||
// Vertex program
|
// Vertex program
|
||||||
virtual bool isVertexProgramSupported () const;
|
virtual bool isVertexProgramSupported () const;
|
||||||
virtual bool isPixelProgramSupported () const;
|
virtual bool isPixelProgramSupported () const;
|
||||||
|
virtual bool isPixelProgramSupported (TPixelProgramProfile profile) const;
|
||||||
virtual bool isVertexProgramEmulated () const;
|
virtual bool isVertexProgramEmulated () const;
|
||||||
virtual bool activeVertexProgram (CVertexProgram *program);
|
virtual bool activeVertexProgram (CVertexProgram *program);
|
||||||
virtual bool activePixelProgram (CPixelProgram *program);
|
virtual bool activePixelProgram (CPixelProgram *program);
|
||||||
|
@ -1065,8 +1066,6 @@ public:
|
||||||
|
|
||||||
uint32 getMaxVertexIndex() const { return _MaxVertexIndex; }
|
uint32 getMaxVertexIndex() const { return _MaxVertexIndex; }
|
||||||
|
|
||||||
bool supportPixelShaders() const { return _PixelShader; }
|
|
||||||
|
|
||||||
// *** Inline info
|
// *** Inline info
|
||||||
uint inlGetNumTextStages() const { return _NbNeLTextureStages; }
|
uint inlGetNumTextStages() const { return _NbNeLTextureStages; }
|
||||||
|
|
||||||
|
@ -2232,7 +2231,7 @@ private:
|
||||||
bool _TextureCubeSupported;
|
bool _TextureCubeSupported;
|
||||||
bool _VertexProgram;
|
bool _VertexProgram;
|
||||||
bool _PixelProgram;
|
bool _PixelProgram;
|
||||||
bool _PixelShader;
|
uint16 _PixelProgramVersion;
|
||||||
bool _DisableHardwareVertexProgram;
|
bool _DisableHardwareVertexProgram;
|
||||||
bool _DisableHardwarePixelProgram;
|
bool _DisableHardwarePixelProgram;
|
||||||
bool _DisableHardwareVertexArrayAGP;
|
bool _DisableHardwareVertexArrayAGP;
|
||||||
|
|
|
@ -567,7 +567,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
|
||||||
normalShaderDesc.TexEnvMode[stage] = mat.getTexEnvMode(uint8(stage));
|
normalShaderDesc.TexEnvMode[stage] = mat.getTexEnvMode(uint8(stage));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_PixelShader)
|
if (_PixelProgram)
|
||||||
{
|
{
|
||||||
#ifdef NL_DEBUG_D3D
|
#ifdef NL_DEBUG_D3D
|
||||||
// Check, should not occured
|
// Check, should not occured
|
||||||
|
@ -933,7 +933,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
|
||||||
activeShader (NULL);
|
activeShader (NULL);
|
||||||
|
|
||||||
/* If unlighted trick is needed, set the shader later */
|
/* If unlighted trick is needed, set the shader later */
|
||||||
if (!pShader->NeedsConstantForDiffuse && _PixelShader)
|
if (!pShader->NeedsConstantForDiffuse && _PixelProgram)
|
||||||
setPixelShader (pShader->PixelShader);
|
setPixelShader (pShader->PixelShader);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2019,7 +2019,7 @@ void CDriverD3D::endMaterialMultiPass()
|
||||||
bool CDriverD3D::supportCloudRenderSinglePass () const
|
bool CDriverD3D::supportCloudRenderSinglePass () const
|
||||||
{
|
{
|
||||||
H_AUTO_D3D(CDriver3D_supportCloudRenderSinglePass);
|
H_AUTO_D3D(CDriver3D_supportCloudRenderSinglePass);
|
||||||
return _PixelShader;
|
return _PixelProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -56,10 +56,17 @@ CPixelProgramDrvInfosD3D::~CPixelProgramDrvInfosD3D()
|
||||||
|
|
||||||
bool CDriverD3D::isPixelProgramSupported () const
|
bool CDriverD3D::isPixelProgramSupported () const
|
||||||
{
|
{
|
||||||
H_AUTO_D3D(CDriverD3D_isPixelProgramSupported )
|
H_AUTO_D3D(CDriverD3D_isPixelProgramSupported)
|
||||||
return _PixelProgram;
|
return _PixelProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDriverD3D::isPixelProgramSupported (TPixelProgramProfile profile) const
|
||||||
|
{
|
||||||
|
H_AUTO_D3D(CDriverD3D_isPixelProgramSupported_profile)
|
||||||
|
return ((profile & 0xFFFF0000) == 0xD3D00000)
|
||||||
|
&& (_PixelProgramVersion >= (uint16)(profile & 0x0000FFFF));
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
bool CDriverD3D::activePixelProgram(CPixelProgram *program)
|
bool CDriverD3D::activePixelProgram(CPixelProgram *program)
|
||||||
|
|
|
@ -1305,6 +1305,7 @@ private:
|
||||||
|
|
||||||
bool isVertexProgramSupported () const;
|
bool isVertexProgramSupported () const;
|
||||||
bool isPixelProgramSupported () const;
|
bool isPixelProgramSupported () const;
|
||||||
|
bool isPixelProgramSupported (TPixelProgramProfile profile) const;
|
||||||
bool isVertexProgramEmulated () const;
|
bool isVertexProgramEmulated () const;
|
||||||
bool activeVertexProgram (CVertexProgram *program);
|
bool activeVertexProgram (CVertexProgram *program);
|
||||||
bool activePixelProgram (CPixelProgram *program);
|
bool activePixelProgram (CPixelProgram *program);
|
||||||
|
|
|
@ -57,11 +57,16 @@ CPixelProgamDrvInfosGL::CPixelProgamDrvInfosGL (CDriverGL *drv, ItPixelPrgDrvInf
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CDriverGL::isPixelProgramSupported () const
|
bool CDriverGL::isPixelProgramSupported() const
|
||||||
{
|
{
|
||||||
H_AUTO_OGL(CPixelProgamDrvInfosGL_isPixelProgramSupported)
|
H_AUTO_OGL(CPixelProgamDrvInfosGL_isPixelProgramSupported)
|
||||||
return _Extensions.ARBFragmentProgram;
|
return _Extensions.ARBFragmentProgram;
|
||||||
}
|
}
|
||||||
|
bool CDriverGL::isPixelProgramSupported(TPixelProgramProfile profile) const
|
||||||
|
{
|
||||||
|
H_AUTO_OGL(CPixelProgamDrvInfosGL_isPixelProgramSupported_profile)
|
||||||
|
return profile == arbfp1 && _Extensions.ARBFragmentProgram;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CDriverGL::activePixelProgram(CPixelProgram *program)
|
bool CDriverGL::activePixelProgram(CPixelProgram *program)
|
||||||
|
|
|
@ -246,7 +246,7 @@ void cbUpdateCommands (CConfigFile::CVar &var)
|
||||||
|
|
||||||
#if SBCLIENT_DEV_PIXEL_PROGRAM
|
#if SBCLIENT_DEV_PIXEL_PROGRAM
|
||||||
namespace {
|
namespace {
|
||||||
CPixelProgram *a_DevPixelProgram;
|
CPixelProgram *a_DevPixelProgram = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -294,16 +294,20 @@ void initCommands()
|
||||||
|
|
||||||
#if SBCLIENT_DEV_PIXEL_PROGRAM
|
#if SBCLIENT_DEV_PIXEL_PROGRAM
|
||||||
CommandsMaterial.getObjectPtr()->setShader(NL3D::CMaterial::PostProcessing);
|
CommandsMaterial.getObjectPtr()->setShader(NL3D::CMaterial::PostProcessing);
|
||||||
static const char *program_arbfp10 =
|
static const char *program_arbfp1 =
|
||||||
"!!ARBfp1.0\n"
|
"!!ARBfp1.0\n"
|
||||||
"PARAM red = {1.0, 0.0, 0.0, 1.0};\n"
|
"PARAM red = {1.0, 0.0, 0.0, 1.0};\n"
|
||||||
"MOV result.color, red;\n"
|
"MOV result.color, red;\n"
|
||||||
"END\n";
|
"END\n";
|
||||||
static const char *program_ps10 =
|
static const char *program_ps_1_1 =
|
||||||
"ps.1.1\n"
|
"ps.1.1\n"
|
||||||
"def c0, 1.0, 0.0, 0.0, 1.0\n"
|
"def c0, 1.0, 0.0, 0.0, 1.0\n"
|
||||||
"mov r0, c0\n";
|
"mov r0, c0\n";
|
||||||
a_DevPixelProgram = new CPixelProgram(program_ps10);
|
NL3D::IDriver *d = dynamic_cast<NL3D::CDriverUser *>(Driver)->getDriver();
|
||||||
|
if (d->isPixelProgramSupported(IDriver::arbfp1))
|
||||||
|
a_DevPixelProgram = new CPixelProgram(program_arbfp1);
|
||||||
|
if (d->isPixelProgramSupported(IDriver::ps_1_1))
|
||||||
|
a_DevPixelProgram = new CPixelProgram(program_ps_1_1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue