From fa984953da3aa068fc8a25cc850c11f7685d8b24 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 19 Apr 2022 12:39:14 +0100 Subject: [PATCH] IECoreGL::Shader : Add support for integer sampler parameters --- src/IECoreGL/Shader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/IECoreGL/Shader.cpp b/src/IECoreGL/Shader.cpp index 8aff2ef9a6..410c0edee0 100644 --- a/src/IECoreGL/Shader.cpp +++ b/src/IECoreGL/Shader.cpp @@ -181,7 +181,11 @@ class Shader::Implementation : public IECore::RefCounted } } - if( p.type == GL_SAMPLER_1D || p.type == GL_SAMPLER_2D || p.type == GL_SAMPLER_3D ) + if( + p.type == GL_SAMPLER_1D || p.type == GL_SAMPLER_2D || p.type == GL_SAMPLER_3D || + p.type == GL_INT_SAMPLER_1D || p.type == GL_INT_SAMPLER_2D || p.type == GL_INT_SAMPLER_3D || + p.type == GL_UNSIGNED_INT_SAMPLER_1D || p.type == GL_UNSIGNED_INT_SAMPLER_2D || p.type == GL_UNSIGNED_INT_SAMPLER_3D + ) { // we assign a specific texture unit to each individual // sampler parameter - this makes it much easier to save @@ -663,8 +667,10 @@ const Shader *Shader::Setup::shader() const void Shader::Setup::addUniformParameter( const std::string &name, ConstTexturePtr value ) { const Parameter *p = m_memberData->shader->uniformParameter( name ); - if( !p || p->type != GL_SAMPLER_2D ) + if( !p || ( p->type != GL_SAMPLER_2D && p->type != GL_INT_SAMPLER_2D && p->type != GL_UNSIGNED_INT_SAMPLER_2D ) ) { + // We can only support 2D samplers, because `Texture::bind()` + // unconditionally uses the GL_TEXTURE_2D target. return; }