From 64643e564b253d23fb13ced00abd89ccd3372654 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 10 Sep 2013 01:29:53 +0200 Subject: [PATCH] Some fixes --HG-- branch : multipass-stereo --- code/nel/include/nel/3d/driver.h | 2 +- code/nel/include/nel/3d/gpu_program.h | 4 ++-- code/nel/src/3d/driver/direct3d/driver_direct3d.h | 6 +++--- .../src/3d/driver/direct3d/driver_direct3d_uniform.cpp | 2 +- code/nel/src/3d/driver/opengl/driver_opengl.h | 6 +++--- code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp | 2 +- code/nel/src/3d/gpu_program_params.cpp | 8 ++++++++ 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 36bbae255..9ad704f81 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -1201,7 +1201,7 @@ public: // Set feature parameters virtual bool setUniformDriver(TProgram program) = 0; // set all driver-specific features params (based on program->features->DriverFlags) (called automatically when rendering with cmaterial and using a user program) virtual bool setUniformMaterial(TProgram program, CMaterial &material) = 0; // set all material-specific feature params (based on program->features->MaterialFlags) (called automatically when rendering with cmaterial and using a user program) - virtual void setUniformParams(TProgram program, const CGPUProgramParams ¶ms) = 0; // set all user-provided params from the storage + virtual void setUniformParams(TProgram program, CGPUProgramParams ¶ms) = 0; // set all user-provided params from the storage // @} diff --git a/code/nel/include/nel/3d/gpu_program.h b/code/nel/include/nel/3d/gpu_program.h index 6ff2ed940..01a48614b 100644 --- a/code/nel/include/nel/3d/gpu_program.h +++ b/code/nel/include/nel/3d/gpu_program.h @@ -57,7 +57,7 @@ public: // The virtual dtor is important. virtual ~IGPUProgramDrvInfos(void); - virtual uint getUniformIndex(char *name) const = 0; + virtual uint getUniformIndex(const char *name) const = 0; }; #define NL_GPU_PROGRAM_LIGHTS 8 @@ -261,7 +261,7 @@ public: inline void removeSource(size_t i) { nlassert(!m_Source); m_Sources.erase(m_Sources.begin() + i); } // Get the idx of a parameter (ogl: uniform, d3d: constant, etcetera) by name. Invalid name returns ~0 - inline uint getUniformIndex(char *name) const { return m_DrvInfo->getUniformIndex(name); }; + inline uint getUniformIndex(const char *name) const { return m_DrvInfo->getUniformIndex(name); }; // Get feature information of the current program inline CSource *source() const { return m_Source; }; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index d360fb915..a7567f0f8 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -309,7 +309,7 @@ public: CVertexProgamDrvInfosD3D(IDriver *drv, ItGPUPrgDrvInfoPtrList it); ~CVertexProgamDrvInfosD3D(); - virtual uint getUniformIndex(char *name) const + virtual uint getUniformIndex(const char *name) const { std::map::const_iterator it = ParamIndices.find(name); if (it != ParamIndices.end()) return it->second; @@ -331,7 +331,7 @@ public: CPixelProgramDrvInfosD3D(IDriver *drv, ItGPUPrgDrvInfoPtrList it); ~CPixelProgramDrvInfosD3D(); - virtual uint getUniformIndex(char *name) const + virtual uint getUniformIndex(const char *name) const { std::map::const_iterator it = ParamIndices.find(name); if (it != ParamIndices.end()) return it->second; @@ -1210,7 +1210,7 @@ public: // Set feature parameters virtual bool setUniformDriver(TProgram program); // set all driver-specific features params (based on program->features->DriverFlags) virtual bool setUniformMaterial(TProgram program, CMaterial &material); // set all material-specific feature params (based on program->features->MaterialFlags) - virtual void setUniformParams(TProgram program, const CGPUProgramParams ¶ms); // set all user-provided params from the storage + virtual void setUniformParams(TProgram program, CGPUProgramParams ¶ms); // set all user-provided params from the storage // @} diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp index 2ade8cfb4..78799584d 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_uniform.cpp @@ -229,7 +229,7 @@ bool CDriverD3D::setUniformMaterial(TProgram program, const CMaterial &material) return true; } -void CDriverD3D::setUniformParams(TProgram program, const CGPUProgramParams ¶ms) +void CDriverD3D::setUniformParams(TProgram program, CGPUProgramParams ¶ms) { // todo } diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 48e50ab8e..aea5b825b 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -1417,7 +1417,7 @@ private: virtual bool setUniformDriver(TProgram program); // set all driver-specific features params (based on program->features->DriverFlags) virtual bool setUniformMaterial(TProgram program, CMaterial &material); // set all material-specific feature params (based on program->features->MaterialFlags) bool setUniformMaterialInternal(TProgram program, CMaterial &material); // set all material-specific feature params (based on program->features->MaterialFlags) - virtual void setUniformParams(TProgram program, const CGPUProgramParams ¶ms); // set all user-provided params from the storage + virtual void setUniformParams(TProgram program, CGPUProgramParams ¶ms); // set all user-provided params from the storage // @} @@ -1650,7 +1650,7 @@ public: // The gl id is auto created here. CVertexProgamDrvInfosGL (CDriverGL *drv, ItGPUPrgDrvInfoPtrList it); - virtual uint getUniformIndex(char *name) const + virtual uint getUniformIndex(const char *name) const { std::map::const_iterator it = ParamIndices.find(name); if (it != ParamIndices.end()) return it->second; @@ -1670,7 +1670,7 @@ public: // The gl id is auto created here. CPixelProgamDrvInfosGL (CDriverGL *drv, ItGPUPrgDrvInfoPtrList it); - virtual uint getUniformIndex(char *name) const + virtual uint getUniformIndex(const char *name) const { std::map::const_iterator it = ParamIndices.find(name); if (it != ParamIndices.end()) return it->second; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp index 6fe7e1f1c..164a40558 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_uniform.cpp @@ -387,7 +387,7 @@ bool CDriverGL::setUniformMaterialInternal(TProgram program, CMaterial &material return true; } -void CDriverGL::setUniformParams(TProgram program, const CGPUProgramParams ¶ms) +void CDriverGL::setUniformParams(TProgram program, CGPUProgramParams ¶ms) { IGPUProgram *prog = NULL; switch (program) diff --git a/code/nel/src/3d/gpu_program_params.cpp b/code/nel/src/3d/gpu_program_params.cpp index 55b14d41f..e196154f8 100644 --- a/code/nel/src/3d/gpu_program_params.cpp +++ b/code/nel/src/3d/gpu_program_params.cpp @@ -533,6 +533,14 @@ size_t CGPUProgramParams::getOffset(uint index) const return m_Map[index]; } +size_t CGPUProgramParams::getOffset(const std::string &name) const +{ + std::map::const_iterator it = m_MapName.find(name); + if (it == m_MapName.end()) + return s_End; + return it->second; +} + /// Remove by offset void CGPUProgramParams::freeOffset(size_t offset) {