@@ -70,6 +70,7 @@ class PrivateImpl
7070 GpuShaderDesc::TextureType channel,
7171 unsigned dimensions,
7272 Interpolation interpolation,
73+ unsigned textureShaderBindingIndex,
7374 const float * v)
7475 : m_textureName(textureName)
7576 , m_samplerName(samplerName)
@@ -79,6 +80,7 @@ class PrivateImpl
7980 , m_type(channel)
8081 , m_dimensions(dimensions)
8182 , m_interp(interpolation)
83+ , m_textureShaderBindingIndex(textureShaderBindingIndex)
8284 {
8385 if (!textureName || !*textureName)
8486 {
@@ -113,6 +115,7 @@ class PrivateImpl
113115 GpuShaderDesc::TextureType m_type;
114116 unsigned m_dimensions;
115117 Interpolation m_interp;
118+ unsigned m_textureShaderBindingIndex;
116119
117120 std::vector<float > m_values;
118121
@@ -214,11 +217,13 @@ class PrivateImpl
214217 << width << " > " << get1dLutMaxWidth ();
215218 throw Exception (ss.str ().c_str ());
216219 }
217- unsigned textureIndex = static_cast <unsigned >(m_textures.size ());
220+ unsigned textureShaderBindingIndex = static_cast <unsigned >(m_textures.size ())
221+ + static_cast <unsigned >(m_textures3D.size ());
218222 unsigned numDimensions = static_cast <unsigned >(dimensions);
219- Texture t (textureName, samplerName, width, height, 1 , channel, numDimensions, interpolation, values);
223+ Texture t (textureName, samplerName, width, height, 1 , channel, numDimensions, interpolation,
224+ textureShaderBindingIndex, values);
220225 m_textures.push_back (t);
221- return textureIndex ;
226+ return textureShaderBindingIndex ;
222227 }
223228
224229 void getTexture (unsigned index,
@@ -268,6 +273,20 @@ class PrivateImpl
268273 values = &t.m_values [0 ];
269274 }
270275
276+ unsigned getTextureShaderBindingIndex (unsigned index) const
277+ {
278+ if (index >= m_textures.size ())
279+ {
280+ std::ostringstream ss;
281+ ss << " 1D LUT access error: index = " << index
282+ << " where size = " << m_textures.size ();
283+ throw Exception (ss.str ().c_str ());
284+ }
285+
286+ const Texture & t = m_textures[index];
287+ return t.m_textureShaderBindingIndex ;
288+ }
289+
271290 unsigned add3DTexture (const char * textureName,
272291 const char * samplerName,
273292 unsigned edgelen,
@@ -282,12 +301,13 @@ class PrivateImpl
282301 throw Exception (ss.str ().c_str ());
283302 }
284303
285- unsigned textureIndex = static_cast <unsigned >(m_textures3D.size ());
304+ unsigned textureShaderBindingIndex = static_cast <unsigned >(m_textures.size ())
305+ + static_cast <unsigned >(m_textures3D.size ());
286306 Texture t (textureName, samplerName, edgelen, edgelen, edgelen,
287307 GpuShaderDesc::TEXTURE_RGB_CHANNEL, 3 ,
288- interpolation, values);
308+ interpolation, textureShaderBindingIndex, values);
289309 m_textures3D.push_back (t);
290- return textureIndex ;
310+ return textureShaderBindingIndex ;
291311 }
292312
293313 void get3DTexture (unsigned index,
@@ -325,6 +345,20 @@ class PrivateImpl
325345 values = &t.m_values [0 ];
326346 }
327347
348+ unsigned get3DTextureShaderBindingIndex (unsigned index) const
349+ {
350+ if (index >= m_textures3D.size ())
351+ {
352+ std::ostringstream ss;
353+ ss << " 3D LUT access error: index = " << index
354+ << " where size = " << m_textures3D.size ();
355+ throw Exception (ss.str ().c_str ());
356+ }
357+
358+ const Texture & t = m_textures3D[index];
359+ return t.m_textureShaderBindingIndex ;
360+ }
361+
328362 unsigned getNumUniforms () const
329363 {
330364 return (unsigned )m_uniforms.size ();
@@ -544,7 +578,9 @@ unsigned GenericGpuShaderDesc::addTexture(const char * textureName,
544578 Interpolation interpolation,
545579 const float * values)
546580{
547- return getImplGeneric ()->addTexture (textureName, samplerName, width, height, channel, dimensions, interpolation, values);
581+ return getImplGeneric ()->addTexture (textureName, samplerName, width, height, channel,
582+ dimensions, interpolation, values)
583+ + getTextureBindingStart ();
548584}
549585
550586void GenericGpuShaderDesc::getTexture (unsigned index,
@@ -555,14 +591,20 @@ void GenericGpuShaderDesc::getTexture(unsigned index,
555591 TextureDimensions & dimensions,
556592 Interpolation & interpolation) const
557593{
558- getImplGeneric ()->getTexture (index, textureName, samplerName, width, height, channel, dimensions, interpolation);
594+ getImplGeneric ()->getTexture (index, textureName, samplerName, width, height, channel,
595+ dimensions, interpolation);
559596}
560597
561598void GenericGpuShaderDesc::getTextureValues (unsigned index, const float *& values) const
562599{
563600 getImplGeneric ()->getTextureValues (index, values);
564601}
565602
603+ unsigned GenericGpuShaderDesc::getTextureShaderBindingIndex (unsigned index) const
604+ {
605+ return getImplGeneric ()->getTextureShaderBindingIndex (index) + getTextureBindingStart ();
606+ }
607+
566608unsigned GenericGpuShaderDesc::getNum3DTextures () const noexcept
567609{
568610 return unsigned (getImplGeneric ()->m_textures3D .size ());
@@ -574,7 +616,8 @@ unsigned GenericGpuShaderDesc::add3DTexture(const char * textureName,
574616 Interpolation interpolation,
575617 const float * values)
576618{
577- return getImplGeneric ()->add3DTexture (textureName, samplerName, edgelen, interpolation, values);
619+ return getImplGeneric ()->add3DTexture (textureName, samplerName, edgelen, interpolation, values)
620+ + getTextureBindingStart ();
578621}
579622
580623void GenericGpuShaderDesc::get3DTexture (unsigned index,
@@ -591,6 +634,11 @@ void GenericGpuShaderDesc::get3DTextureValues(unsigned index, const float *& val
591634 getImplGeneric ()->get3DTextureValues (index, values);
592635}
593636
637+ unsigned GenericGpuShaderDesc::get3DTextureShaderBindingIndex (unsigned index) const
638+ {
639+ return getImplGeneric ()->get3DTextureShaderBindingIndex (index) + getTextureBindingStart ();
640+ }
641+
594642void GenericGpuShaderDesc::Deleter (GenericGpuShaderDesc* c)
595643{
596644 delete c;
0 commit comments