Skip to content

Commit

Permalink
Fix Python test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiyun Wang committed Jun 5, 2024
1 parent b6ea842 commit 1b2664e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@
.. py:property:: Texture3D.interpolation
:module: PyOpenColorIO.GpuShaderDesc

.. py:property:: Texture3D.channel
:module: PyOpenColorIO.GpuShaderDesc

.. py:property:: Texture3D.samplerName
:module: PyOpenColorIO.GpuShaderDesc
Expand Down
6 changes: 4 additions & 2 deletions src/bindings/python/PyGpuShaderDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct Texture3D
std::string m_textureName;
std::string m_samplerName;
unsigned m_edgelen;
GpuShaderDesc::TextureType m_channel;
Interpolation m_interpolation;
GpuShaderDescRcPtr m_shaderDesc;
int m_index;
Expand Down Expand Up @@ -331,6 +332,7 @@ void bindPyGpuShaderDesc(py::module & m)
.def_readonly("textureName", &Texture3D::m_textureName)
.def_readonly("samplerName", &Texture3D::m_samplerName)
.def_readonly("edgeLen", &Texture3D::m_edgelen)
.def_readonly("channel", &Texture3D::m_channel)
.def_readonly("interpolation", &Texture3D::m_interpolation)
.def("getValues", [](Texture3D & self)
{
Expand Down Expand Up @@ -362,7 +364,7 @@ void bindPyGpuShaderDesc(py::module & m)
Interpolation interpolation;
it.m_obj->get3DTexture(i, textureName, samplerName, edgelen, channel, interpolation);

return { textureName, samplerName, edgelen, interpolation, it.m_obj, i };
return { textureName, samplerName, edgelen, channel, interpolation, it.m_obj, i };
})
.def("__iter__", [](Texture3DIterator & it) -> Texture3DIterator &
{
Expand All @@ -379,7 +381,7 @@ void bindPyGpuShaderDesc(py::module & m)
Interpolation interpolation;
it.m_obj->get3DTexture(i, textureName, samplerName, edgelen, channel, interpolation);

return { textureName, samplerName, edgelen, interpolation, it.m_obj, i };
return { textureName, samplerName, edgelen, channel, interpolation, it.m_obj, i };
});
}

Expand Down
6 changes: 4 additions & 2 deletions tests/python/GpuShaderDescTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ def test_texture_3d(self):
buf = np.linspace(0, 1, num=8*3).astype(np.float32)
bufTest1 = buf[3]
desc.add3DTexture('tex', 'sampler', 2,
OCIO.INTERP_DEFAULT, buf)
OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL, OCIO.INTERP_DEFAULT, buf)
buf = np.linspace(0, 1, num=27*3).astype(np.float32)
bufTest2 = buf[42]
desc.add3DTexture('tex2', 'sampler2', 3,
OCIO.INTERP_DEFAULT, buf)
OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL, OCIO.INTERP_DEFAULT, buf)

textures = desc.get3DTextures()
self.assertEqual(len(textures), 2)
Expand All @@ -197,6 +197,7 @@ def test_texture_3d(self):
self.assertEqual(t1.samplerName, 'sampler')
self.assertEqual(t1.edgeLen, 2)
self.assertEqual(t1.interpolation, OCIO.INTERP_DEFAULT)
self.assertEqual(t1.channel, OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL)
v1 = t1.getValues()
self.assertEqual(len(v1), 3*8)
self.assertEqual(v1[3], bufTest1)
Expand All @@ -205,6 +206,7 @@ def test_texture_3d(self):
self.assertEqual(t2.samplerName, 'sampler2')
self.assertEqual(t2.edgeLen, 3)
self.assertEqual(t2.interpolation, OCIO.INTERP_DEFAULT)
self.assertEqual(t2.channel, OCIO.GpuShaderDesc.TEXTURE_RGB_CHANNEL)
v2 = t2.getValues()
self.assertEqual(len(v2), 3*27)
self.assertEqual(v2[42], bufTest2)

0 comments on commit 1b2664e

Please sign in to comment.