forked from Mirrorlandia_minetest/irrlicht
Added 'uint' GLSL uniform support.
Thanks @devsh for the patch. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6073 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
dbf03c296c
commit
7b1ee6468d
@ -71,6 +71,10 @@ public:
|
||||
//! Int interface for the above.
|
||||
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) = 0;
|
||||
|
||||
//! Uint interface for the above.
|
||||
/* NOTE: UINT only works with GLSL, not supported for other shaders */
|
||||
virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) = 0;
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
/** Can be used if you created a shader using pixel/vertex shader
|
||||
assembler or ARB_fragment_program or ARB_vertex_program.
|
||||
@ -95,6 +99,10 @@ public:
|
||||
//! Int interface for the above.
|
||||
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) = 0;
|
||||
|
||||
//! Uint interface for the above.
|
||||
/* NOTE: UINT only works with GLSL, not supported for other shaders */
|
||||
virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) = 0;
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
/** Can be used if you created a shader using pixel/vertex shader
|
||||
assembler or ARB_fragment_program or ARB_vertex_program.
|
||||
|
@ -3176,6 +3176,19 @@ bool CD3D9Driver::setVertexShaderConstant(s32 index, const s32* ints, int count)
|
||||
}
|
||||
|
||||
|
||||
//! Uint interface for the above.
|
||||
bool CD3D9Driver::setVertexShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size())
|
||||
{
|
||||
CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer;
|
||||
return r->setVariable(true, index, ints, count);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Sets a constant for the pixel shader based on an index.
|
||||
bool CD3D9Driver::setPixelShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
@ -3202,6 +3215,20 @@ bool CD3D9Driver::setPixelShaderConstant(s32 index, const s32* ints, int count)
|
||||
}
|
||||
|
||||
|
||||
//! Uint interface for the above.
|
||||
bool CD3D9Driver::setPixelShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size())
|
||||
{
|
||||
CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Material.MaterialType].Renderer;
|
||||
return r->setVariable(false, index, ints, count);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
s32 CD3D9Driver::addShaderMaterial(const c8* vertexShaderProgram,
|
||||
|
@ -252,12 +252,18 @@ namespace video
|
||||
//! Int interface for the above.
|
||||
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Uint interface for the above.
|
||||
virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a constant for the pixel shader based on an index.
|
||||
virtual bool setPixelShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Int interface for the above.
|
||||
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Uint interface for the above.
|
||||
virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Returns a pointer to the IVideoDriver interface. (Implementation for
|
||||
//! IMaterialRendererServices)
|
||||
virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_;
|
||||
|
@ -370,6 +370,14 @@ bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, s32 index,
|
||||
}
|
||||
|
||||
|
||||
bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, s32 index,
|
||||
const u32* ints, int count)
|
||||
{
|
||||
os::Printer::log("Error DirectX 9 does not support unsigned integer constants in shaders.", ELL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CD3D9HLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
|
||||
{
|
||||
if (VSConstantsTable)
|
||||
|
@ -56,6 +56,9 @@ public:
|
||||
//! Int interface for the above.
|
||||
virtual bool setVariable(bool vertexShader, s32 index, const s32* ints, int count);
|
||||
|
||||
//! Uint interface for the above.
|
||||
virtual bool setVariable(bool vertexShader, s32 index, const u32* ints, int count);
|
||||
|
||||
bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
|
@ -89,6 +89,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Uint interface for the above.
|
||||
virtual bool setVariable(bool vertexShader, s32 index, const u32* ints, int count)
|
||||
{
|
||||
os::Printer::log("Invalid material to set variable in.");
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
IDirect3DDevice9* pID3DDevice;
|
||||
|
@ -3664,19 +3664,15 @@ s32 COpenGLDriver::getPixelShaderConstantID(const c8* name)
|
||||
//! Sets a vertex shader constant.
|
||||
void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
#ifdef GL_ARB_vertex_program
|
||||
for (s32 i=0; i<constantAmount; ++i)
|
||||
extGlProgramLocalParameter4fv(GL_VERTEX_PROGRAM_ARB, startRegister+i, &data[i*4]);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void COpenGLDriver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
#ifdef GL_ARB_fragment_program
|
||||
for (s32 i=0; i<constantAmount; ++i)
|
||||
extGlProgramLocalParameter4fv(GL_FRAGMENT_PROGRAM_ARB, startRegister+i, &data[i*4]);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Sets a constant for the vertex shader based on an index.
|
||||
@ -3692,6 +3688,12 @@ bool COpenGLDriver::setVertexShaderConstant(s32 index, const s32* ints, int coun
|
||||
return setPixelShaderConstant(index, ints, count);
|
||||
}
|
||||
|
||||
//! Uint interface for the above.
|
||||
bool COpenGLDriver::setVertexShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, ints, count);
|
||||
}
|
||||
|
||||
//! Sets a constant for the pixel shader based on an index.
|
||||
bool COpenGLDriver::setPixelShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
@ -3706,6 +3708,12 @@ bool COpenGLDriver::setPixelShaderConstant(s32 index, const s32* ints, int count
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COpenGLDriver::setPixelShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant().");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
|
@ -292,12 +292,18 @@ namespace video
|
||||
//! Int interface for the above.
|
||||
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Uint interface for the above.
|
||||
virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Sets a constant for the pixel shader based on an index.
|
||||
virtual bool setPixelShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Int interface for the above.
|
||||
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! Uint interface for the above.
|
||||
virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
|
||||
|
||||
//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.
|
||||
//! Returns whether disabling was successful or not.
|
||||
bool disableTextures(u32 fromStage=0);
|
||||
|
@ -44,6 +44,7 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
||||
pGlGetUniformLocationARB(0), pGlGetUniformLocation(0),
|
||||
pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0),
|
||||
pGlUniform1ivARB(0), pGlUniform2ivARB(0), pGlUniform3ivARB(0), pGlUniform4ivARB(0),
|
||||
pGlUniform1uiv(0), pGlUniform2uiv(0), pGlUniform3uiv(0), pGlUniform4uiv(0),
|
||||
pGlUniformMatrix2fvARB(0), pGlUniformMatrix2x3fv(0), pGlUniformMatrix2x4fv(0),
|
||||
pGlUniformMatrix3x2fv(0), pGlUniformMatrix3fvARB(0), pGlUniformMatrix3x4fv(0),
|
||||
pGlUniformMatrix4x2fv(0), pGlUniformMatrix4x3fv(0), pGlUniformMatrix4fvARB(0),
|
||||
@ -466,6 +467,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
pGlUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform2ivARB");
|
||||
pGlUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform3ivARB");
|
||||
pGlUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform4ivARB");
|
||||
pGlUniform1uiv = (PFNGLUNIFORM1UIVPROC) IRR_OGL_LOAD_EXTENSION("glUniform1uiv");
|
||||
pGlUniform2uiv = (PFNGLUNIFORM2UIVPROC) IRR_OGL_LOAD_EXTENSION("glUniform2uiv");
|
||||
pGlUniform3uiv = (PFNGLUNIFORM3UIVPROC) IRR_OGL_LOAD_EXTENSION("glUniform3uiv");
|
||||
pGlUniform4uiv = (PFNGLUNIFORM4UIVPROC) IRR_OGL_LOAD_EXTENSION("glUniform4uiv");
|
||||
pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix2fvARB");
|
||||
pGlUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix2x3fv");
|
||||
pGlUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix2x4fv");
|
||||
|
@ -1127,6 +1127,10 @@ class COpenGLExtensionHandler
|
||||
void extGlUniform2iv(GLint loc, GLsizei count, const GLint *v);
|
||||
void extGlUniform3iv(GLint loc, GLsizei count, const GLint *v);
|
||||
void extGlUniform4iv(GLint loc, GLsizei count, const GLint *v);
|
||||
void extGlUniform1uiv(GLint loc, GLsizei count, const GLuint *v);
|
||||
void extGlUniform2uiv(GLint loc, GLsizei count, const GLuint *v);
|
||||
void extGlUniform3uiv(GLint loc, GLsizei count, const GLuint *v);
|
||||
void extGlUniform4uiv(GLint loc, GLsizei count, const GLuint *v);
|
||||
void extGlUniformMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix2x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix2x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
@ -1262,6 +1266,10 @@ class COpenGLExtensionHandler
|
||||
PFNGLUNIFORM2IVARBPROC pGlUniform2ivARB;
|
||||
PFNGLUNIFORM3IVARBPROC pGlUniform3ivARB;
|
||||
PFNGLUNIFORM4IVARBPROC pGlUniform4ivARB;
|
||||
PFNGLUNIFORM1UIVPROC pGlUniform1uiv;
|
||||
PFNGLUNIFORM2UIVPROC pGlUniform2uiv;
|
||||
PFNGLUNIFORM3UIVPROC pGlUniform3uiv;
|
||||
PFNGLUNIFORM4UIVPROC pGlUniform4uiv;
|
||||
PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB;
|
||||
PFNGLUNIFORMMATRIX2X3FVPROC pGlUniformMatrix2x3fv;
|
||||
PFNGLUNIFORMMATRIX2X4FVPROC pGlUniformMatrix2x4fv;
|
||||
@ -1895,6 +1903,46 @@ inline void COpenGLExtensionHandler::extGlUniform4fv(GLint loc, GLsizei count, c
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniform1uiv(GLint loc, GLsizei count, const GLuint *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniform1uiv)
|
||||
pGlUniform1uiv(loc, count, v);
|
||||
#else
|
||||
glUniform1uiv(loc, count, v);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniform2uiv(GLint loc, GLsizei count, const GLuint *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniform2uiv)
|
||||
pGlUniform2uiv(loc, count, v);
|
||||
#else
|
||||
glUniform2uiv(loc, count, v);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniform3uiv(GLint loc, GLsizei count, const GLuint *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniform3uiv)
|
||||
pGlUniform3uiv(loc, count, v);
|
||||
#else
|
||||
glUniform3uiv(loc, count, v);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniform4uiv(GLint loc, GLsizei count, const GLuint *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniform4uiv)
|
||||
pGlUniform4uiv(loc, count, v);
|
||||
#else
|
||||
glUniform4uiv(loc, count, v);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniform1iv(GLint loc, GLsizei count, const GLint *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
|
@ -608,9 +608,13 @@ bool COpenGLSLMaterialRenderer::setVertexShaderConstant(s32 index, const s32* in
|
||||
return setPixelShaderConstant(index, ints, count);
|
||||
}
|
||||
|
||||
bool COpenGLSLMaterialRenderer::setVertexShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, ints, count);
|
||||
}
|
||||
|
||||
bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
#ifdef GL_ARB_shader_objects
|
||||
if(index < 0 || UniformInfo[index].location < 0)
|
||||
return false;
|
||||
|
||||
@ -678,14 +682,10 @@ bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const f32* flo
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const s32* ints, int count)
|
||||
{
|
||||
#ifdef GL_ARB_shader_objects
|
||||
if(index < 0 || UniformInfo[index].location < 0)
|
||||
return false;
|
||||
|
||||
@ -722,9 +722,34 @@ bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const s32* int
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
#else
|
||||
}
|
||||
|
||||
bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
if(index < 0 || UniformInfo[index].location < 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
bool status = true;
|
||||
|
||||
switch (UniformInfo[index].type)
|
||||
{
|
||||
case GL_UNSIGNED_INT:
|
||||
Driver->extGlUniform1uiv(UniformInfo[index].location, count, reinterpret_cast<const GLuint*>(ints));
|
||||
break;
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
Driver->extGlUniform2uiv(UniformInfo[index].location, count/2, reinterpret_cast<const GLuint*>(ints));
|
||||
break;
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
Driver->extGlUniform3uiv(UniformInfo[index].location, count/3, reinterpret_cast<const GLuint*>(ints));
|
||||
break;
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
Driver->extGlUniform4uiv(UniformInfo[index].location, count/4, reinterpret_cast<const GLuint*>(ints));
|
||||
break;
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
IVideoDriver* COpenGLSLMaterialRenderer::getVideoDriver()
|
||||
|
@ -79,8 +79,10 @@ public:
|
||||
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;
|
||||
virtual bool setVertexShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;
|
||||
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
|
||||
virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
|
||||
virtual bool setPixelShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;
|
||||
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
|
||||
virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
|
||||
virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
|
@ -1,4 +1,4 @@
|
||||
Tests finished. 72 tests of 72 passed.
|
||||
Compiled as DEBUG
|
||||
Test suite pass at GMT Fri Jan 3 17:05:41 2020
|
||||
Test suite pass at GMT Mon Feb 10 14:59:56 2020
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user