Skip to content

Commit 1b2664e

Browse files
author
Yiyun Wang
committed
Fix Python test
1 parent b6ea842 commit 1b2664e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@
477477
.. py:property:: Texture3D.interpolation
478478
:module: PyOpenColorIO.GpuShaderDesc
479479

480+
.. py:property:: Texture3D.channel
481+
:module: PyOpenColorIO.GpuShaderDesc
480482

481483
.. py:property:: Texture3D.samplerName
482484
:module: PyOpenColorIO.GpuShaderDesc

src/bindings/python/PyGpuShaderDesc.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct Texture3D
3838
std::string m_textureName;
3939
std::string m_samplerName;
4040
unsigned m_edgelen;
41+
GpuShaderDesc::TextureType m_channel;
4142
Interpolation m_interpolation;
4243
GpuShaderDescRcPtr m_shaderDesc;
4344
int m_index;
@@ -331,6 +332,7 @@ void bindPyGpuShaderDesc(py::module & m)
331332
.def_readonly("textureName", &Texture3D::m_textureName)
332333
.def_readonly("samplerName", &Texture3D::m_samplerName)
333334
.def_readonly("edgeLen", &Texture3D::m_edgelen)
335+
.def_readonly("channel", &Texture3D::m_channel)
334336
.def_readonly("interpolation", &Texture3D::m_interpolation)
335337
.def("getValues", [](Texture3D & self)
336338
{
@@ -362,7 +364,7 @@ void bindPyGpuShaderDesc(py::module & m)
362364
Interpolation interpolation;
363365
it.m_obj->get3DTexture(i, textureName, samplerName, edgelen, channel, interpolation);
364366

365-
return { textureName, samplerName, edgelen, interpolation, it.m_obj, i };
367+
return { textureName, samplerName, edgelen, channel, interpolation, it.m_obj, i };
366368
})
367369
.def("__iter__", [](Texture3DIterator & it) -> Texture3DIterator &
368370
{
@@ -379,7 +381,7 @@ void bindPyGpuShaderDesc(py::module & m)
379381
Interpolation interpolation;
380382
it.m_obj->get3DTexture(i, textureName, samplerName, edgelen, channel, interpolation);
381383

382-
return { textureName, samplerName, edgelen, interpolation, it.m_obj, i };
384+
return { textureName, samplerName, edgelen, channel, interpolation, it.m_obj, i };
383385
});
384386
}
385387

tests/python/GpuShaderDescTest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ def test_texture_3d(self):
184184
buf = np.linspace(0, 1, num=8*3).astype(np.float32)
185185
bufTest1 = buf[3]
186186
desc.add3DTexture('tex', 'sampler', 2,
187-
OCIO.INTERP_DEFAULT, buf)
187+
OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL, OCIO.INTERP_DEFAULT, buf)
188188
buf = np.linspace(0, 1, num=27*3).astype(np.float32)
189189
bufTest2 = buf[42]
190190
desc.add3DTexture('tex2', 'sampler2', 3,
191-
OCIO.INTERP_DEFAULT, buf)
191+
OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL, OCIO.INTERP_DEFAULT, buf)
192192

193193
textures = desc.get3DTextures()
194194
self.assertEqual(len(textures), 2)
@@ -197,6 +197,7 @@ def test_texture_3d(self):
197197
self.assertEqual(t1.samplerName, 'sampler')
198198
self.assertEqual(t1.edgeLen, 2)
199199
self.assertEqual(t1.interpolation, OCIO.INTERP_DEFAULT)
200+
self.assertEqual(t1.channel, OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL)
200201
v1 = t1.getValues()
201202
self.assertEqual(len(v1), 3*8)
202203
self.assertEqual(v1[3], bufTest1)
@@ -205,6 +206,7 @@ def test_texture_3d(self):
205206
self.assertEqual(t2.samplerName, 'sampler2')
206207
self.assertEqual(t2.edgeLen, 3)
207208
self.assertEqual(t2.interpolation, OCIO.INTERP_DEFAULT)
209+
self.assertEqual(t2.channel, OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL)
208210
v2 = t2.getValues()
209211
self.assertEqual(len(v2), 3*27)
210212
self.assertEqual(v2[42], bufTest2)

0 commit comments

Comments
 (0)