diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 655a9e62b..3cb0c0349 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -151,9 +151,10 @@ protected: TVBDrvInfoPtrList _VBDrvInfos; TIBDrvInfoPtrList _IBDrvInfos; TPolygonMode _PolygonMode; - TVtxPrgDrvInfoPtrList _VtxPrgDrvInfos; - TPixelPrgDrvInfoPtrList _PixelPrgDrvInfos; - TShaderDrvInfoPtrList _ShaderDrvInfos; + TGPUPrgDrvInfoPtrList _GPUPrgDrvInfos; + // TPixelPrgDrvInfoPtrList _PixelPrgDrvInfos; + // TGeomPrgDrvInfoPtrList _GeomPrgDrvInfos; + // TShaderDrvInfoPtrList _ShaderDrvInfos; uint _ResetCounter; @@ -317,11 +318,6 @@ public: virtual bool setupMaterial(CMaterial& mat)=0; - /** - * Activate a shader, NULL to disable the current shader. - */ - virtual bool activeShader(CShader *shd)=0; - /** Special for Faster Specular Setup. Call this between lot of primitives rendered with Specular Materials. * Visual Errors may arise if you don't correctly call endSpecularBatch(). */ @@ -1303,9 +1299,10 @@ protected: friend class CTextureDrvShare; friend class ITextureDrvInfos; friend class IMaterialDrvInfos; - friend class IVertexProgramDrvInfos; - friend class IPixelProgramDrvInfos; - friend class IShaderDrvInfos; + // friend class IVertexProgramDrvInfos; + // friend class IPixelProgramDrvInfos; + // friend class IShaderDrvInfos; + friend class IGPUProgramDrvInfos; /// remove ptr from the lists in the driver. void removeVBDrvInfoPtr(ItVBDrvInfoPtrList vbDrvInfoIt); @@ -1313,9 +1310,10 @@ protected: void removeTextureDrvInfoPtr(ItTexDrvInfoPtrMap texDrvInfoIt); void removeTextureDrvSharePtr(ItTexDrvSharePtrList texDrvShareIt); void removeMatDrvInfoPtr(ItMatDrvInfoPtrList shaderIt); - void removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt); - void removeVtxPrgDrvInfoPtr(ItVtxPrgDrvInfoPtrList vtxPrgDrvInfoIt); - void removePixelPrgDrvInfoPtr(ItPixelPrgDrvInfoPtrList pixelPrgDrvInfoIt); + // void removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt); + // void removeVtxPrgDrvInfoPtr(ItVtxPrgDrvInfoPtrList vtxPrgDrvInfoIt); + // void removePixelPrgDrvInfoPtr(ItPixelPrgDrvInfoPtrList pixelPrgDrvInfoIt); + void removeGPUPrgDrvInfoPtr(ItGPUPrgDrvInfoPtrList gpuPrgDrvInfoIt); private: bool _StaticMemoryToVRAM; diff --git a/code/nel/include/nel/3d/geometry_program.h b/code/nel/include/nel/3d/geometry_program.h new file mode 100644 index 000000000..ac9451b27 --- /dev/null +++ b/code/nel/include/nel/3d/geometry_program.h @@ -0,0 +1,83 @@ +/** \file geometry_program.h + * Geometry program definition + */ + +/* Copyright, 2000, 2001 Nevrax Ltd. + * + * This file is part of NEVRAX NEL. + * NEVRAX NEL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + + * NEVRAX NEL is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with NEVRAX NEL; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#ifndef NL_GEOMETRY_PROGRAM_H +#define NL_GEOMETRY_PROGRAM_H + +#include +#include +#include +#include + +#include + +namespace NL3D { + +/** + * \brief CGeometryProgramInfo + * \date 2013-09-07 15:00GMT + * \author Jan Boon (Kaetemi) + * Read-only information structure. + */ +struct CGeometryProgramInfo +{ +public: + std::string DisplayName; + + /*enum TFeatures + { + + };*/ + + // Bitfield containing features used by this geometry program + uint Features; + + // Indices of parameters used by features + // ... +}; + +class CGeometryProgram : public IGPUProgram +{ +public: + /// Constructor + CGeometryProgram(CGPUProgramSourceCont *programSource); + /// Destructor + virtual ~CGeometryProgram (); + + /// Build feature information + void buildInfo(const char *displayName, uint features); + /// Get feature information + inline const CGeometryProgramInfo *getInfo() const { return _Info; } + +private: + + /// Feature information + CGeometryProgramInfo *_Info; +}; + +} // NL3D + + +#endif // NL_GEOMETRY_PROGRAM_H + +/* End of vertex_program.h */ diff --git a/code/nel/include/nel/3d/gpu_program.h b/code/nel/include/nel/3d/gpu_program.h index 63d6eea88..3df13ac3d 100644 --- a/code/nel/include/nel/3d/gpu_program.h +++ b/code/nel/include/nel/3d/gpu_program.h @@ -1,6 +1,6 @@ /** * \file gpu_program.h - * \brief CGPUProgram + * \brief IGPUProgram * \date 2013-09-07 15:00GMT * \author Jan Boon (Kaetemi) * IGPUProgram @@ -38,110 +38,33 @@ namespace NL3D { -/** - * \brief CVertexProgramInfo - * \date 2013-09-07 15:00GMT - * \author Jan Boon (Kaetemi) - * Read-only information structure. - */ -struct CVertexProgramInfo +// List typedef. +class IDriver; +class IGPUProgramDrvInfos; +typedef std::list TGPUPrgDrvInfoPtrList; +typedef TGPUPrgDrvInfoPtrList::iterator ItGPUPrgDrvInfoPtrList; + +// Class for interaction of vertex program with Driver. +// IGPUProgramDrvInfos represent the real data of the GPU program, stored into the driver (eg: just a GLint for opengl). +class IGPUProgramDrvInfos : public NLMISC::CRefCount { +private: + IDriver *_Driver; + ItGPUPrgDrvInfoPtrList _DriverIterator; + public: - std::string DisplayName; + IGPUProgramDrvInfos (IDriver *drv, ItGPUPrgDrvInfoPtrList it); + // The virtual dtor is important. + virtual ~IGPUProgramDrvInfos(void); - enum TFeatures - { - // World - // transform - - // Lights - Ambient = 0x0001, - Sun = 0x0002, - PointLight0 = 0x0004, - PointLight1 = 0x0008, - PointLight2 = 0x0010, - - // Lights, additional parameters for user shaders - /// Adds an enabled/disabled parameter to all of the lights - DynamicLights = 0x0020, - }; - - /// Bitfield containing features used by this vertex program. - uint Features; - - /// Indices of parameters used by features. - - /// Lights, NeL supports: - /// - Ambient light - uint AmbientIdx; // (Ambient) - /// - One directional light - uint SunDirectionIdx; // (Sun) - uint SunDiffuseIdx; // (Sun) - /// - Zero to three point lights - uint PointLight0PositionIdx; // (PointLight0) - uint PointLight0DiffuseIdx; // (PointLight0) - uint PointLight1PositionIdx; // (PointLight1) - uint PointLight1DiffuseIdx; // (PointLight1) - uint PointLight2PositionIdx; // (PointLight2) - uint PointLight2DiffuseIdx; // (PointLight2) - - /// DynamicLights - uint SunEnabledIdx; // (DynamicLights && Sun) - uint PointLight0EnabledIdx; // (DynamicLights && PointLight0) - uint PointLight1EnabledIdx; // (DynamicLights && PointLight1) - uint PointLight2EnabledIdx; // (DynamicLights && PointLight2) + virtual uint getParamIdx(char *name) const { return ~0; }; // STEREO_TODO }; -/** - * \brief CPixelProgramInfo - * \date 2013-09-07 15:00GMT - * \author Jan Boon (Kaetemi) - * Read-only information structure. - */ -struct CPixelProgramInfo -{ -public: - std::string DisplayName; - - enum TFeatures - { - /// Use texture stages from CMaterial as texture parameters - MaterialTextures = 0x0001, - /// Set driver fog parameters on this program - Fog = 0x0002, - /// Adds an enabled/disabled parameter to the fog, for user shaders - DynamicFog = 0x0004, - }; - - // Bitfield containing features used by this pixel program - uint Features; - - // Indices of parameters used by features - uint FogEnabledIdx; // (Fog && DynamicFog) nlFogEnabled, fog enabled - uint FogStartEndIdx; // (Fog) nlFogStartEnd, start and end of fog - uint FogColorIdx; // (Fog) nlFogColor, fog color -}; +class CGPUProgramSource; +class CGPUProgramSourceCont; /** - * \brief CGeometryProgramInfo - * \date 2013-09-07 15:00GMT - * \author Jan Boon (Kaetemi) - * Read-only information structure. - */ -struct CGeometryProgramInfo -{ -public: - /*enum TFeatures - { - - };*/ - /// Bitfield containing features used by this pixel program. - // uint Features; - /// Indices of parameters used by features. -}; - -/** - * \brief CGPUProgram + * \brief IGPUProgram * \date 2013-09-07 15:00GMT * \author Jan Boon (Kaetemi) * A compiled GPU program @@ -202,28 +125,23 @@ public: public: IGPUProgram(); + IGPUProgram(CGPUProgramSourceCont *programSource); virtual ~IGPUProgram(); /// Get the idx of a parameter (ogl: uniform, d3d: constant, etcetera) by name. Invalid name returns ~0 - virtual uint getParamIdx(char *name) const = 0; + inline uint getParamIdx(char *name) const { return _DrvInfo->getParamIdx(name); }; - void buildVPInfo(const char *displayName, uint features); - void buildPPInfo(const char *displayName, uint features); - void buildGPInfo(const char *displayName, uint features); + /// Get the program + inline const CGPUProgramSourceCont *getProgramSource() const { return _ProgramSource; }; - inline const CVertexProgramInfo *getVPInfo() const { return Info.VertexProgram; } - inline const CPixelProgramInfo *getPPInfo() const { return Info.PixelProgram; } - inline const CGeometryProgramInfo *getGPInfo() const { return Info.GeometryProgram; } +protected: + /// The progam source + NLMISC::CSmartPtr _ProgramSource; + +public: + /// The driver information. For the driver implementation only. + NLMISC::CRefPtr _DrvInfo; -private: - union - { - CVertexProgramInfo *VertexProgram; - CPixelProgramInfo *PixelProgram; - CGeometryProgramInfo *GeometryProgram; - void *Ptr; - } Info; - }; /* class IGPUProgram */ } /* namespace NL3D */ diff --git a/code/nel/include/nel/3d/gpu_program_source.h b/code/nel/include/nel/3d/gpu_program_source.h index 7e6ba81fa..0484b28d2 100644 --- a/code/nel/include/nel/3d/gpu_program_source.h +++ b/code/nel/include/nel/3d/gpu_program_source.h @@ -45,7 +45,7 @@ namespace NL3D { * \author Jan Boon (Kaetemi) * A single GPU program with a specific profile. */ -struct CGPUProgramSource +struct CGPUProgramSource : public NLMISC::CRefCount { public: std::string DisplayName; @@ -53,11 +53,11 @@ public: /// Minimal required profile for this GPU program IGPUProgram::TProfile Profile; - char *SourcePtr; - /// Copy the source string - inline void setSource(char *source) { SourceCopy = source; SourcePtr = &source[0]; } - /// Set pointer to source string without copying the string - inline void setSourcePtr(char *sourcePtr) { SourceCopy.clear(); SourcePtr = sourcePtr; } + const char *CodePtr; + /// Copy the source code string + inline void setCode(const char *source) { CodeCopy = source; CodePtr = &source[0]; } + /// Set pointer to source code string without copying the string + inline void setCodePtr(const char *sourcePtr) { CodeCopy.clear(); CodePtr = sourcePtr; } /// CVertexProgramInfo/CPixelProgramInfo/... NeL features uint Features; @@ -66,7 +66,7 @@ public: std::map ParamIndices; private: - std::string SourceCopy; + std::string CodeCopy; }; /* class CGPUProgramSource */ @@ -77,10 +77,10 @@ private: * Container for the source code of a single GPU program, allowing * variations in different language profiles. */ -struct CGPUProgramSourceCont +struct CGPUProgramSourceCont : public NLMISC::CRefCount { -public: - std::vector Sources; +public: + std::vector > Sources; }; /* class CGPUProgramSourceCont */ diff --git a/code/nel/include/nel/3d/pixel_program.h b/code/nel/include/nel/3d/pixel_program.h index 183ad2d83..e006844aa 100644 --- a/code/nel/include/nel/3d/pixel_program.h +++ b/code/nel/include/nel/3d/pixel_program.h @@ -1,7 +1,5 @@ /** \file pixel_program.h * Pixel program definition - * - * $Id: pixel_program.h,v 1.1.2.3 2007/07/06 15:58:45 legallo Exp $ */ /* Copyright, 2000, 2001 Nevrax Ltd. @@ -28,81 +26,62 @@ #include #include +#include +#include #include namespace NL3D { -// List typedef. -class IDriver; -class IPixelProgramDrvInfos; -typedef std::list TPixelPrgDrvInfoPtrList; -typedef TPixelPrgDrvInfoPtrList::iterator ItPixelPrgDrvInfoPtrList; - -// Class for interaction of pixel program with Driver. -// IPixelProgramDrvInfos represent the real data of the pixel program, stored into the driver. -class IPixelProgramDrvInfos : public NLMISC::CRefCount -{ -private: - IDriver *_Driver; - ItPixelPrgDrvInfoPtrList _DriverIterator; - -public: - IPixelProgramDrvInfos (IDriver *drv, ItPixelPrgDrvInfoPtrList it); - // The virtual dtor is important. - virtual ~IPixelProgramDrvInfos(void); -}; - - -//------------------------------------------------------------------------------- -class CPixelProgram : public NLMISC::CRefCount +/** + * \brief CPixelProgramInfo + * \date 2013-09-07 15:00GMT + * \author Jan Boon (Kaetemi) + * Read-only information structure. + */ +struct CPixelProgramInfo { public: - - enum TProfile - { - // TODO: - // If it's more useful, change this to a flags bitfield and - // change the d3d (and gl) code to generate the bitfield of - // supported modes instead of doing a >= version check. - - // direct3d - 0xD3D0,major,minor - 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 - 0x0610,bitfield - // fp20 = 0x061B0001, // very limited and outdated, unnecessary - // fp30 = 0x06100002, // NV_fragment_program, now arbfp1, redundant - arbfp1 = 0x06100004, // ARB_fragment_program - fp40 = 0x06100008, // NV_fragment_program2, arbfp1 with "OPTION NV_fragment_program2;\n" - gp4fp = 0x06100010, // NV_gpu_program4 - gp5fp = 0x06100020, // NV_gpu_program5 + std::string DisplayName; + + enum TFeatures + { + /// Use texture stages from CMaterial as texture parameters + MaterialTextures = 0x0001, + /// Set driver fog parameters on this program + Fog = 0x0002, + /// Adds an enabled/disabled parameter to the fog, for user shaders + DynamicFog = 0x0004, }; - /// Constructor - CPixelProgram (const char* program); + // Bitfield containing features used by this pixel program + uint Features; + // Indices of parameters used by features + uint FogEnabledIdx; // (Fog && DynamicFog) nlFogEnabled, fog enabled + uint FogStartEndIdx; // (Fog) nlFogStartEnd, start and end of fog + uint FogColorIdx; // (Fog) nlFogColor, fog color +}; + +class CPixelProgram : public IGPUProgram +{ +public: + /// Constructor + CPixelProgram(CGPUProgramSourceCont *programSource); /// Destructor virtual ~CPixelProgram (); - /// Get the program - inline const std::string& getProgram() const { return _Program; }; + /// Build feature information + void buildInfo(const char *displayName, uint features); + /// Get feature information + inline const CPixelProgramInfo *getInfo() const { return _Info; } - /// The driver informations. For the driver implementation only. - NLMISC::CRefPtr _DrvInfo; +private: -protected: - - /// The progam - std::string _Program; + /// Feature information + CPixelProgramInfo *_Info; }; - } // NL3D diff --git a/code/nel/include/nel/3d/shader.h b/code/nel/include/nel/3d/shader.h index 3377c27d4..61956e8e1 100644 --- a/code/nel/include/nel/3d/shader.h +++ b/code/nel/include/nel/3d/shader.h @@ -24,73 +24,6 @@ namespace NL3D { -using NLMISC::CRefCount; - - -class IDriver; - -// List typedef. -class IShaderDrvInfos; -typedef std::list TShaderDrvInfoPtrList; -typedef TShaderDrvInfoPtrList::iterator ItShaderDrvInfoPtrList; - -/** - * Interface for shader driver infos. - */ -class IShaderDrvInfos : public CRefCount -{ -private: - IDriver *_Driver; - ItShaderDrvInfoPtrList _DriverIterator; - -public: - IShaderDrvInfos(IDriver *drv, ItShaderDrvInfoPtrList it) {_Driver= drv; _DriverIterator= it;} - // The virtual dtor is important. - virtual ~IShaderDrvInfos(); -}; - - -/** - * Shader resource for the driver. It is just a container for a ".fx" text file. - */ -/* *** IMPORTANT ******************** - * *** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL - * ********************************** - */ -// -------------------------------------------------- -class CShader -{ -public: - CShader(); - ~CShader(); - - // Load a shader file - bool loadShaderFile (const char *filename); - - // Set the shader text - void setText (const char *text); - - // Get the shader text - const char *getText () const { return _Text.c_str(); } - - // Set the shader name - void setName (const char *name); - - // Get the shader name - const char *getName () const { return _Name.c_str(); } - -public: - // Private. For Driver only. - bool _ShaderChanged; - NLMISC::CRefPtr _DrvInfo; -private: - // The shader - std::string _Text; - // The shader name - std::string _Name; -}; - - } // NL3D diff --git a/code/nel/include/nel/3d/vertex_program.h b/code/nel/include/nel/3d/vertex_program.h index 903e5ccf7..b8843e182 100644 --- a/code/nel/include/nel/3d/vertex_program.h +++ b/code/nel/include/nel/3d/vertex_program.h @@ -19,90 +19,87 @@ #include "nel/misc/types_nl.h" #include "nel/misc/smart_ptr.h" +#include "nel/3d/gpu_program.h" +#include "nel/3d/gpu_program_source.h" #include - namespace NL3D { -// List typedef. -class IDriver; -class IVertexProgramDrvInfos; -typedef std::list TVtxPrgDrvInfoPtrList; -typedef TVtxPrgDrvInfoPtrList::iterator ItVtxPrgDrvInfoPtrList; - -// Class for interaction of vertex program with Driver. -// IVertexProgramDrvInfos represent the real data of the vertex program, stored into the driver (eg: just a GLint for opengl). -class IVertexProgramDrvInfos : public NLMISC::CRefCount +/** + * \brief CVertexProgramInfo + * \date 2013-09-07 15:00GMT + * \author Jan Boon (Kaetemi) + * Read-only information structure. + */ +struct CVertexProgramInfo { -private: - IDriver *_Driver; - ItVtxPrgDrvInfoPtrList _DriverIterator; - public: - IVertexProgramDrvInfos (IDriver *drv, ItVtxPrgDrvInfoPtrList it); - // The virtual dtor is important. - virtual ~IVertexProgramDrvInfos(void); + std::string DisplayName; + + enum TFeatures + { + // World + // transform + + // Lights + Ambient = 0x0001, + Sun = 0x0002, + PointLight0 = 0x0004, + PointLight1 = 0x0008, + PointLight2 = 0x0010, + + // Lights, additional parameters for user shaders + /// Adds an enabled/disabled parameter to all of the lights + DynamicLights = 0x0020, + }; + + /// Bitfield containing features used by this vertex program. + uint Features; + + /// Indices of parameters used by features. + + /// Lights, NeL supports: + /// - Ambient light + uint AmbientIdx; // (Ambient) + /// - One directional light + uint SunDirectionIdx; // (Sun) + uint SunDiffuseIdx; // (Sun) + /// - Zero to three point lights + uint PointLight0PositionIdx; // (PointLight0) + uint PointLight0DiffuseIdx; // (PointLight0) + uint PointLight1PositionIdx; // (PointLight1) + uint PointLight1DiffuseIdx; // (PointLight1) + uint PointLight2PositionIdx; // (PointLight2) + uint PointLight2DiffuseIdx; // (PointLight2) + + /// DynamicLights + uint SunEnabledIdx; // (DynamicLights && Sun) + uint PointLight0EnabledIdx; // (DynamicLights && PointLight0) + uint PointLight1EnabledIdx; // (DynamicLights && PointLight1) + uint PointLight2EnabledIdx; // (DynamicLights && PointLight2) }; - -/** - * This class is a vertex program. - * - * D3D / OPENGL compatibility notes: - * --------------------------------- - * - * To make your program compatible with D3D and OPENGL nel drivers, please follow thoses directives to write your vertex programs - * - * - Use only v[0], v[1] etc.. syntax for input registers. Don't use v0, v1 or v[OPOS] etc.. - * - Use only c[0], c[1] etc.. syntax for constant registers. Don't use c0, c1 etc.. - * - Use only o[HPOS], o[COL0] etc.. syntax for output registers. Don't use oPos, oD0 etc.. - * - Use only uppercase for registers R1, R2 etc.. Don't use lowercase r1, r2 etc.. - * - Use a semicolon to delineate instructions. - * - Use ARL instruction to load the adress register and not MOV. - * - Don't use the NOP instruction. - * - Don't use macros. - * - * -> Thoses programs work without any change under OpenGL. - * -> Direct3D driver implementation will have to modify the syntax on the fly before the setup like this: - * - "v[0]" must be changed in "v0" etc.. - * - "o[HPOS]" must be changed in oPos etc.. - * - Semicolon must be changed in line return character. - * - ARL instruction must be changed in MOV. - * - * Behaviour of LOG may change depending on implementation: You can only expect to have dest.z = log2(abs(src.w)). - * LIT may or may not clamp the specular exponent to [-128, 128] (not done when EXT_vertex_shader is used for example ..) - * - * Depending on the implementation, some optimizations can be achieved by masking the unused output values of instructions - * as LIT, EXPP .. - * - * \author Cyril 'Hulud' Corvazier - * \author Nevrax France - * \date 2001 - */ -class CVertexProgram : public NLMISC::CRefCount +class CVertexProgram : public IGPUProgram { public: - /// Constructor - CVertexProgram (const char* program); - + CVertexProgram(CGPUProgramSourceCont *programSource); + CVertexProgram(const char *nelvp); /// Destructor virtual ~CVertexProgram (); - /// Get the program - const std::string& getProgram () const { return _Program; }; + /// Build feature information + void buildInfo(const char *displayName, uint features); + /// Get feature information + inline const CVertexProgramInfo *getInfo() const { return _Info; } private: - /// The progam - std::string _Program; -public: - /// The driver information. For the driver implementation only. - NLMISC::CRefPtr _DrvInfo; + /// Feature information + CVertexProgramInfo *_Info; }; - } // NL3D diff --git a/code/nel/include/nel/3d/vertex_program_parse.h b/code/nel/include/nel/3d/vertex_program_parse.h index cd9f414c9..88538da07 100644 --- a/code/nel/include/nel/3d/vertex_program_parse.h +++ b/code/nel/include/nel/3d/vertex_program_parse.h @@ -21,6 +21,40 @@ #include +/** + * This class is a vertex program. + * + * D3D / OPENGL compatibility notes: + * --------------------------------- + * + * To make your program compatible with D3D and OPENGL nel drivers, please follow thoses directives to write your vertex programs + * + * - Use only v[0], v[1] etc.. syntax for input registers. Don't use v0, v1 or v[OPOS] etc.. + * - Use only c[0], c[1] etc.. syntax for constant registers. Don't use c0, c1 etc.. + * - Use only o[HPOS], o[COL0] etc.. syntax for output registers. Don't use oPos, oD0 etc.. + * - Use only uppercase for registers R1, R2 etc.. Don't use lowercase r1, r2 etc.. + * - Use a semicolon to delineate instructions. + * - Use ARL instruction to load the adress register and not MOV. + * - Don't use the NOP instruction. + * - Don't use macros. + * + * -> Thoses programs work without any change under OpenGL. + * -> Direct3D driver implementation will have to modify the syntax on the fly before the setup like this: + * - "v[0]" must be changed in "v0" etc.. + * - "o[HPOS]" must be changed in oPos etc.. + * - Semicolon must be changed in line return character. + * - ARL instruction must be changed in MOV. + * + * Behaviour of LOG may change depending on implementation: You can only expect to have dest.z = log2(abs(src.w)). + * LIT may or may not clamp the specular exponent to [-128, 128] (not done when EXT_vertex_shader is used for example ..) + * + * Depending on the implementation, some optimizations can be achieved by masking the unused output values of instructions + * as LIT, EXPP .. + * + * \author Cyril 'Hulud' Corvazier + * \author Nevrax France + * \date 2001 + */ /// Swizzle of an operand in a vertex program struct CVPSwizzle diff --git a/code/nel/src/3d/CMakeLists.txt b/code/nel/src/3d/CMakeLists.txt index fb5d5851a..f469b3b62 100644 --- a/code/nel/src/3d/CMakeLists.txt +++ b/code/nel/src/3d/CMakeLists.txt @@ -167,6 +167,8 @@ SOURCE_GROUP(Driver FILES ../../include/nel/3d/vertex_program_parse.h pixel_program.cpp ../../include/nel/3d/pixel_program.h + geometry_program.cpp + ../../include/nel/3d/geometry_program.h gpu_program.cpp ../../include/nel/3d/gpu_program.h gpu_program_source.cpp diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 5a08da982..25c9afb63 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -58,7 +58,7 @@ IDriver::~IDriver() nlassert(_MatDrvInfos.size()==0); nlassert(_VBDrvInfos.size()==0); nlassert(_IBDrvInfos.size()==0); - nlassert(_VtxPrgDrvInfos.size()==0); + nlassert(_GPUPrgDrvInfos.size()==0); } @@ -94,14 +94,14 @@ bool IDriver::release(void) // NB: at IShader deletion, this->_MatDrvInfos is updated (entry deleted); delete *itmat; } - +/* // Release Shader drv. ItShaderDrvInfoPtrList itshd; while( (itshd = _ShaderDrvInfos.begin()) != _ShaderDrvInfos.end() ) { // NB: at IShader deletion, this->_MatDrvInfos is updated (entry deleted); delete *itshd; - } + }*/ // Release VBs drv. ItVBDrvInfoPtrList itvb; @@ -119,12 +119,12 @@ bool IDriver::release(void) delete *itib; } - // Release VtxPrg drv. - ItVtxPrgDrvInfoPtrList itVtxPrg; - while( (itVtxPrg = _VtxPrgDrvInfos.begin()) != _VtxPrgDrvInfos.end() ) + // Release GPUPrg drv. + ItGPUPrgDrvInfoPtrList itGPUPrg; + while( (itGPUPrg = _GPUPrgDrvInfos.begin()) != _GPUPrgDrvInfos.end() ) { - // NB: at IVertexProgramDrvInfos deletion, this->_VtxPrgDrvInfos is updated (entry deleted); - delete *itVtxPrg; + // NB: at IVertexProgramDrvInfos deletion, this->_GPUPrgDrvInfos is updated (entry deleted); + delete *itGPUPrg; } return true; @@ -249,7 +249,7 @@ void IDriver::removeMatDrvInfoPtr(ItMatDrvInfoPtrList shaderIt) _MatDrvInfos.erase(shaderIt); } // *************************************************************************** -void IDriver::removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt) +/*void IDriver::removeShaderDrvInfoPtr(ItShaderDrvInfoPtrList shaderIt) { _ShaderDrvInfos.erase(shaderIt); } @@ -262,6 +262,11 @@ void IDriver::removeVtxPrgDrvInfoPtr(ItVtxPrgDrvInfoPtrList vtxPrgDrvInfoIt) void IDriver::removePixelPrgDrvInfoPtr(ItPixelPrgDrvInfoPtrList pixelPrgDrvInfoIt) { _PixelPrgDrvInfos.erase(pixelPrgDrvInfoIt); +}*/ +// *************************************************************************** +void IDriver::removeGPUPrgDrvInfoPtr(ItGPUPrgDrvInfoPtrList vtxPrgDrvInfoIt) +{ + _GPUPrgDrvInfos.erase(vtxPrgDrvInfoIt); } // *************************************************************************** diff --git a/code/nel/src/3d/geometry_program.cpp b/code/nel/src/3d/geometry_program.cpp new file mode 100644 index 000000000..ae73d669f --- /dev/null +++ b/code/nel/src/3d/geometry_program.cpp @@ -0,0 +1,59 @@ +/** \file geometry_program.cpp + * Geometry program definition + */ + +/* Copyright, 2000, 2001 Nevrax Ltd. + * + * This file is part of NEVRAX NEL. + * NEVRAX NEL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + + * NEVRAX NEL is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with NEVRAX NEL; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +#include "std3d.h" + +#include + +#include + +namespace NL3D +{ + +// *************************************************************************** + +CGeometryProgram::CGeometryProgram(CGPUProgramSourceCont *programSource) : _Info(NULL), IGPUProgram(programSource) +{ + +} + +// *************************************************************************** + +CGeometryProgram::~CGeometryProgram () +{ + delete _Info; + _Info = NULL; +} + +// *************************************************************************** + +void CGeometryProgram::buildInfo(const char *displayName, uint features) +{ + nlassert(_Info == NULL); + _Info = new CGeometryProgramInfo(); + CGeometryProgramInfo *info = _Info; + info->DisplayName = displayName; + info->Features = features; +} + +} // NL3D diff --git a/code/nel/src/3d/gpu_program.cpp b/code/nel/src/3d/gpu_program.cpp index 457d8b1a1..fc75e44e4 100644 --- a/code/nel/src/3d/gpu_program.cpp +++ b/code/nel/src/3d/gpu_program.cpp @@ -1,9 +1,9 @@ /** * \file gpu_program.cpp - * \brief CGPUProgram + * \brief IGPUProgram * \date 2013-09-07 15:00GMT * \author Jan Boon (Kaetemi) - * CGPUProgram + * IGPUProgram */ /* @@ -35,157 +35,50 @@ #include // Project includes +#include using namespace std; // using namespace NLMISC; namespace NL3D { +// *************************************************************************** + +IGPUProgramDrvInfos::IGPUProgramDrvInfos(IDriver *drv, ItGPUPrgDrvInfoPtrList it) +{ + _Driver = drv; + _DriverIterator = it; +} + +// *************************************************************************** + +IGPUProgramDrvInfos::~IGPUProgramDrvInfos () +{ + _Driver->removeGPUPrgDrvInfoPtr(_DriverIterator); +} + +// *************************************************************************** + IGPUProgram::IGPUProgram() { - Info.Ptr = NULL; + } +// *************************************************************************** + +IGPUProgram::IGPUProgram(CGPUProgramSourceCont *programSource) : _ProgramSource(programSource) +{ + +} + +// *************************************************************************** + IGPUProgram::~IGPUProgram() { - delete Info.Ptr; - Info.Ptr = NULL; + // Must kill the drv mirror of this program. + _DrvInfo.kill(); } -void IGPUProgram::buildVPInfo(const char *displayName, uint features) -{ - nlassert(Info.VertexProgram == NULL); - Info.VertexProgram = new CVertexProgramInfo(); - CVertexProgramInfo *info = Info.VertexProgram; - info->DisplayName = displayName; - info->Features = features; - if (features & CVertexProgramInfo::Ambient) - { - info->AmbientIdx = getParamIdx("nlAmbient"); - if (info->AmbientIdx == ~0) - { - nlwarning("Missing 'nlAmbient' in gpu program '%s', Ambient disabled", displayName); - info->Features &= ~CVertexProgramInfo::Ambient; - } - } - if (features & CVertexProgramInfo::Sun) - { - if (features & CVertexProgramInfo::DynamicLights) - { - info->SunEnabledIdx = getParamIdx("nlSunEnabled"); - if (info->SunEnabledIdx == ~0) - { - nlwarning("Missing 'nlSunEnabled' in gpu program '%s', DynamicLights disabled", displayName); - info->Features &= ~CVertexProgramInfo::DynamicLights; - } - } - info->SunDirectionIdx = getParamIdx("nlSunDirection"); - info->SunDiffuseIdx = getParamIdx("nlSunDiffuse"); - if (info->SunDirectionIdx == ~0 - || info->SunDiffuseIdx == ~0) - { - nlwarning("Missing 'nlSunDirection/nlSunDiffuse' in gpu program '%s', Sun disabled", displayName); - info->Features &= ~CVertexProgramInfo::Sun; - } - } - if (features & CVertexProgramInfo::PointLight0) - { - if (features & CVertexProgramInfo::DynamicLights) - { - info->PointLight0EnabledIdx = getParamIdx("nlPointLight0Enabled"); - if (info->PointLight0EnabledIdx == ~0) - { - nlwarning("Missing 'nlPointLight0Enabled' in gpu program '%s', DynamicLights disabled", displayName); - info->Features &= ~CVertexProgramInfo::DynamicLights; - } - } - info->PointLight0PositionIdx = getParamIdx("nlPointLight0Position"); - info->PointLight0DiffuseIdx = getParamIdx("nlPointLight0Diffuse"); - if (info->PointLight0PositionIdx == ~0 - || info->PointLight0DiffuseIdx == ~0) - { - nlwarning("Missing 'nlPointLight0Position/nlPointLight0Diffuse' in gpu program '%s', PointLight0 disabled", displayName); - info->Features &= ~CVertexProgramInfo::PointLight0; - } - } - if (features & CVertexProgramInfo::PointLight1) - { - if (features & CVertexProgramInfo::DynamicLights) - { - info->PointLight1EnabledIdx = getParamIdx("nlPointLight1Enabled"); - if (info->PointLight1EnabledIdx == ~0) - { - nlwarning("Missing 'nlPointLight1Enabled' in gpu program '%s', DynamicLights disabled", displayName); - info->Features &= ~CVertexProgramInfo::DynamicLights; - } - } - info->PointLight1PositionIdx = getParamIdx("nlPointLight1Position"); - info->PointLight1DiffuseIdx = getParamIdx("nlPointLight1Diffuse"); - if (info->PointLight1PositionIdx == ~0 - || info->PointLight1DiffuseIdx == ~0) - { - nlwarning("Missing 'nlPointLight1Position/nlPointLight1Diffuse' in gpu program '%s', PointLight1 disabled", displayName); - info->Features &= ~CVertexProgramInfo::PointLight1; - } - } - if (features & CVertexProgramInfo::PointLight2) - { - if (features & CVertexProgramInfo::DynamicLights) - { - info->PointLight2EnabledIdx = getParamIdx("nlPointLight2Enabled"); - if (info->PointLight2EnabledIdx == ~0) - { - nlwarning("Missing 'nlPointLight2Enabled' in gpu program '%s', DynamicLights disabled", displayName); - info->Features &= ~CVertexProgramInfo::DynamicLights; - } - } - info->PointLight2PositionIdx = getParamIdx("nlPointLight2Position"); - info->PointLight2DiffuseIdx = getParamIdx("nlPointLight2Diffuse"); - if (info->PointLight2PositionIdx == ~0 - || info->PointLight2DiffuseIdx == ~0) - { - nlwarning("Missing 'nlPointLight2Position/nlPointLight2Diffuse' in gpu program '%s', PointLight2 disabled", displayName); - info->Features &= ~CVertexProgramInfo::PointLight2; - } - } -} - -void IGPUProgram::buildPPInfo(const char *displayName, uint features) -{ - nlassert(Info.PixelProgram == NULL); - Info.PixelProgram = new CPixelProgramInfo(); - CPixelProgramInfo *info = Info.PixelProgram; - info->DisplayName = displayName; - info->Features = features; - if (features & CPixelProgramInfo::Fog) - { - if (features & CPixelProgramInfo::DynamicFog) - { - info->FogEnabledIdx = getParamIdx("nlFogEnabled"); - if (info->FogEnabledIdx == ~0) - { - nlwarning("Missing 'nlFogEnabled' in gpu program '%s', DynamicFog disabled", displayName); - info->Features &= ~CPixelProgramInfo::DynamicFog; - } - } - info->FogStartEndIdx = getParamIdx("nlFogStartEnd"); - info->FogColorIdx = getParamIdx("nlFogColor"); - if (info->FogStartEndIdx == ~0 - || info->FogStartEndIdx == ~0) - { - nlwarning("Missing 'nlFogStartEnd/nlFogColor' in gpu program '%s', Fog disabled", displayName); - info->Features &= ~CPixelProgramInfo::Fog; - } - } -} - -void IGPUProgram::buildGPInfo(const char *displayName, uint features) -{ - nlassert(Info.GeometryProgram == NULL); - Info.GeometryProgram = new CGeometryProgramInfo(); -} - - } /* namespace NL3D */ /* end of file */ diff --git a/code/nel/src/3d/pixel_program.cpp b/code/nel/src/3d/pixel_program.cpp index 320bfa541..8fbe8c0cf 100644 --- a/code/nel/src/3d/pixel_program.cpp +++ b/code/nel/src/3d/pixel_program.cpp @@ -1,7 +1,5 @@ /** \file pixel_program.cpp * Pixel program definition - * - * $Id: pixel_program.cpp,v 1.1.2.1 2007/04/27 17:35:07 legallo Exp $ */ /* Copyright, 2000, 2001 Nevrax Ltd. @@ -33,31 +31,49 @@ namespace NL3D { // *************************************************************************** -IPixelProgramDrvInfos::IPixelProgramDrvInfos (IDriver *drv, ItPixelPrgDrvInfoPtrList it) + +CPixelProgram::CPixelProgram(CGPUProgramSourceCont *programSource) : _Info(NULL), IGPUProgram(programSource) { - _Driver= drv; - _DriverIterator= it; + } - // *************************************************************************** -IPixelProgramDrvInfos::~IPixelProgramDrvInfos () + +CPixelProgram::~CPixelProgram () { - _Driver->removePixelPrgDrvInfoPtr (_DriverIterator); + delete _Info; + _Info = NULL; } - // *************************************************************************** -CPixelProgram::CPixelProgram(const char* program) : _Program(program) + +void CPixelProgram::buildInfo(const char *displayName, uint features) { - -} - - -// *************************************************************************** -CPixelProgram::~CPixelProgram() -{ - + nlassert(_Info == NULL); + _Info = new CPixelProgramInfo(); + CPixelProgramInfo *info = _Info; + info->DisplayName = displayName; + info->Features = features; + if (features & CPixelProgramInfo::Fog) + { + if (features & CPixelProgramInfo::DynamicFog) + { + info->FogEnabledIdx = getParamIdx("nlFogEnabled"); + if (info->FogEnabledIdx == ~0) + { + nlwarning("Missing 'nlFogEnabled' in gpu program '%s', DynamicFog disabled", displayName); + info->Features &= ~CPixelProgramInfo::DynamicFog; + } + } + info->FogStartEndIdx = getParamIdx("nlFogStartEnd"); + info->FogColorIdx = getParamIdx("nlFogColor"); + if (info->FogStartEndIdx == ~0 + || info->FogStartEndIdx == ~0) + { + nlwarning("Missing 'nlFogStartEnd/nlFogColor' in gpu program '%s', Fog disabled", displayName); + info->Features &= ~CPixelProgramInfo::Fog; + } + } } } // NL3D diff --git a/code/nel/src/3d/shader.cpp b/code/nel/src/3d/shader.cpp index a0d0c3172..9c08e9980 100644 --- a/code/nel/src/3d/shader.cpp +++ b/code/nel/src/3d/shader.cpp @@ -27,85 +27,4 @@ using namespace NLMISC; namespace NL3D { -// *************************************************************************** - -CShader::~CShader() -{ - // Must kill the drv mirror of this shader. - _DrvInfo.kill(); -} - -// *************************************************************************** - -CShader::CShader() -{ - _ShaderChanged = true; -} - -// *************************************************************************** - -void CShader::setText (const char *text) -{ - _Text = text; - _ShaderChanged = true; -} - -// *************************************************************************** - -void CShader::setName (const char *name) -{ - _Name = name; - _ShaderChanged = true; -} - -// *************************************************************************** - -bool CShader::loadShaderFile (const char *filename) -{ - _Text = ""; - // Lookup - string _filename = CPath::lookup(filename, false, true, true); - if (!_filename.empty()) - { - // File length - uint size = CFile::getFileSize (_filename); - _Text.reserve (size+1); - - try - { - CIFile file; - if (file.open (_filename)) - { - // Read it - while (!file.eof ()) - { - char line[512]; - file.getline (line, 512); - _Text += line; - } - - // Set the shader name - _Name = CFile::getFilename (filename); - return true; - } - else - { - nlwarning ("Can't open the file %s for reading", _filename.c_str()); - } - } - catch (const Exception &e) - { - nlwarning ("Error while reading %s : %s", _filename.c_str(), e.what()); - } - } - return false; -} - -// *************************************************************************** - -IShaderDrvInfos::~IShaderDrvInfos() -{ - _Driver->removeShaderDrvInfoPtr(_DriverIterator); -} - } // NL3D diff --git a/code/nel/src/3d/stereo_debugger.cpp b/code/nel/src/3d/stereo_debugger.cpp index 6be97d42a..17c5c8c98 100644 --- a/code/nel/src/3d/stereo_debugger.cpp +++ b/code/nel/src/3d/stereo_debugger.cpp @@ -114,7 +114,13 @@ void CStereoDebugger::setDriver(NL3D::UDriver *driver) { nlassert(!m_PixelProgram); - NL3D::IDriver *drvInternal = (static_cast(driver))->getDriver(); + NL3D::IDriver *drvInternal = (static_cast(driver))->getDriver(); + + CGPUProgramSource *source = new CGPUProgramSource(); + CGPUProgramSourceCont *sourceCont = new CGPUProgramSourceCont(); + sourceCont->Sources.push_back(source); + source->Features = CPixelProgramInfo::MaterialTextures; + /*if (drvInternal->supportPixelProgram(CPixelProgram::fp40) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) { nldebug("VR: fp40"); @@ -122,8 +128,10 @@ void CStereoDebugger::setDriver(NL3D::UDriver *driver) } else*/ if (drvInternal->supportPixelProgram(CPixelProgram::arbfp1) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) { - nldebug("VR: arbfp1"); - m_PixelProgram = new CPixelProgram(a_arbfp1); + nldebug("VR: arbfp1"); + source->Profile = IGPUProgram::arbfp1; + source->setCodePtr(a_arbfp1); + m_PixelProgram = new CPixelProgram(sourceCont); } /*else if (drvInternal->supportPixelProgram(CPixelProgram::ps_2_0)) { diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index a57a0ffcb..00db2020e 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -237,21 +237,33 @@ void CStereoOVR::setDriver(NL3D::UDriver *driver) { nlassert(!m_PixelProgram); - NL3D::IDriver *drvInternal = (static_cast(driver))->getDriver(); + NL3D::IDriver *drvInternal = (static_cast(driver))->getDriver(); + + CGPUProgramSource *source = new CGPUProgramSource(); + CGPUProgramSourceCont *sourceCont = new CGPUProgramSourceCont(); + sourceCont->Sources.push_back(source); + source->Features = CPixelProgramInfo::MaterialTextures; + if (drvInternal->supportPixelProgram(CPixelProgram::fp40) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) { nldebug("VR: fp40"); - m_PixelProgram = new CPixelProgram(g_StereoOVR_fp40); + source->Profile = IGPUProgram::fp40; + source->setCodePtr(g_StereoOVR_fp40); + m_PixelProgram = new CPixelProgram(sourceCont); } else if (drvInternal->supportPixelProgram(CPixelProgram::arbfp1) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) { nldebug("VR: arbfp1"); - m_PixelProgram = new CPixelProgram(g_StereoOVR_arbfp1); + source->Profile = IGPUProgram::arbfp1; + source->setCodePtr(g_StereoOVR_arbfp1); + m_PixelProgram = new CPixelProgram(sourceCont); } else if (drvInternal->supportPixelProgram(CPixelProgram::ps_2_0)) { nldebug("VR: ps_2_0"); - m_PixelProgram = new CPixelProgram(g_StereoOVR_ps_2_0); + source->Profile = IGPUProgram::ps_2_0; + source->setCodePtr(g_StereoOVR_ps_2_0); + m_PixelProgram = new CPixelProgram(sourceCont); } if (m_PixelProgram) diff --git a/code/nel/src/3d/vertex_program.cpp b/code/nel/src/3d/vertex_program.cpp index 9e7587069..2f70d51af 100644 --- a/code/nel/src/3d/vertex_program.cpp +++ b/code/nel/src/3d/vertex_program.cpp @@ -24,34 +24,131 @@ namespace NL3D { - // *************************************************************************** -IVertexProgramDrvInfos::IVertexProgramDrvInfos (IDriver *drv, ItVtxPrgDrvInfoPtrList it) + +CVertexProgram::CVertexProgram(CGPUProgramSourceCont *programSource) : _Info(NULL), IGPUProgram(programSource) { - _Driver= drv; - _DriverIterator= it; + } - // *************************************************************************** -IVertexProgramDrvInfos::~IVertexProgramDrvInfos () + +CVertexProgram::CVertexProgram(const char *nelvp) : _Info(NULL) { - _Driver->removeVtxPrgDrvInfoPtr (_DriverIterator); + CGPUProgramSource *source = new CGPUProgramSource(); + _ProgramSource = new CGPUProgramSourceCont(); + _ProgramSource->Sources.push_back(source); + source->Profile = IGPUProgram::nelvp; + source->setCode(nelvp); + source->Features = 0; } - // *************************************************************************** -CVertexProgram::CVertexProgram (const char* program) -{ - _Program=program; -} - -// *************************************************************************** CVertexProgram::~CVertexProgram () { - // Must kill the drv mirror of this VB. - _DrvInfo.kill(); + delete _Info; + _Info = NULL; +} + +// *************************************************************************** + +void CVertexProgram::buildInfo(const char *displayName, uint features) +{ + nlassert(_Info == NULL); + _Info = new CVertexProgramInfo(); + CVertexProgramInfo *info = _Info; + info->DisplayName = displayName; + info->Features = features; + if (features & CVertexProgramInfo::Ambient) + { + info->AmbientIdx = getParamIdx("nlAmbient"); + if (info->AmbientIdx == ~0) + { + nlwarning("Missing 'nlAmbient' in gpu program '%s', Ambient disabled", displayName); + info->Features &= ~CVertexProgramInfo::Ambient; + } + } + if (features & CVertexProgramInfo::Sun) + { + if (features & CVertexProgramInfo::DynamicLights) + { + info->SunEnabledIdx = getParamIdx("nlSunEnabled"); + if (info->SunEnabledIdx == ~0) + { + nlwarning("Missing 'nlSunEnabled' in gpu program '%s', DynamicLights disabled", displayName); + info->Features &= ~CVertexProgramInfo::DynamicLights; + } + } + info->SunDirectionIdx = getParamIdx("nlSunDirection"); + info->SunDiffuseIdx = getParamIdx("nlSunDiffuse"); + if (info->SunDirectionIdx == ~0 + || info->SunDiffuseIdx == ~0) + { + nlwarning("Missing 'nlSunDirection/nlSunDiffuse' in gpu program '%s', Sun disabled", displayName); + info->Features &= ~CVertexProgramInfo::Sun; + } + } + if (features & CVertexProgramInfo::PointLight0) + { + if (features & CVertexProgramInfo::DynamicLights) + { + info->PointLight0EnabledIdx = getParamIdx("nlPointLight0Enabled"); + if (info->PointLight0EnabledIdx == ~0) + { + nlwarning("Missing 'nlPointLight0Enabled' in gpu program '%s', DynamicLights disabled", displayName); + info->Features &= ~CVertexProgramInfo::DynamicLights; + } + } + info->PointLight0PositionIdx = getParamIdx("nlPointLight0Position"); + info->PointLight0DiffuseIdx = getParamIdx("nlPointLight0Diffuse"); + if (info->PointLight0PositionIdx == ~0 + || info->PointLight0DiffuseIdx == ~0) + { + nlwarning("Missing 'nlPointLight0Position/nlPointLight0Diffuse' in gpu program '%s', PointLight0 disabled", displayName); + info->Features &= ~CVertexProgramInfo::PointLight0; + } + } + if (features & CVertexProgramInfo::PointLight1) + { + if (features & CVertexProgramInfo::DynamicLights) + { + info->PointLight1EnabledIdx = getParamIdx("nlPointLight1Enabled"); + if (info->PointLight1EnabledIdx == ~0) + { + nlwarning("Missing 'nlPointLight1Enabled' in gpu program '%s', DynamicLights disabled", displayName); + info->Features &= ~CVertexProgramInfo::DynamicLights; + } + } + info->PointLight1PositionIdx = getParamIdx("nlPointLight1Position"); + info->PointLight1DiffuseIdx = getParamIdx("nlPointLight1Diffuse"); + if (info->PointLight1PositionIdx == ~0 + || info->PointLight1DiffuseIdx == ~0) + { + nlwarning("Missing 'nlPointLight1Position/nlPointLight1Diffuse' in gpu program '%s', PointLight1 disabled", displayName); + info->Features &= ~CVertexProgramInfo::PointLight1; + } + } + if (features & CVertexProgramInfo::PointLight2) + { + if (features & CVertexProgramInfo::DynamicLights) + { + info->PointLight2EnabledIdx = getParamIdx("nlPointLight2Enabled"); + if (info->PointLight2EnabledIdx == ~0) + { + nlwarning("Missing 'nlPointLight2Enabled' in gpu program '%s', DynamicLights disabled", displayName); + info->Features &= ~CVertexProgramInfo::DynamicLights; + } + } + info->PointLight2PositionIdx = getParamIdx("nlPointLight2Position"); + info->PointLight2DiffuseIdx = getParamIdx("nlPointLight2Diffuse"); + if (info->PointLight2PositionIdx == ~0 + || info->PointLight2DiffuseIdx == ~0) + { + nlwarning("Missing 'nlPointLight2Position/nlPointLight2Diffuse' in gpu program '%s', PointLight2 disabled", displayName); + info->Features &= ~CVertexProgramInfo::PointLight2; + } + } } } // NL3D