From 1b2664e91da73b8b2479dc2a6864d12fd8b39048 Mon Sep 17 00:00:00 2001 From: Yiyun Wang Date: Wed, 5 Jun 2024 13:57:23 -0400 Subject: [PATCH] Fix Python test --- docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst | 2 ++ src/bindings/python/PyGpuShaderDesc.cpp | 6 ++++-- tests/python/GpuShaderDescTest.py | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst b/docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst index 7a5f9bd116..5f8234b523 100644 --- a/docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst +++ b/docs/api/python/frozen/pyopencolorio_gpushaderdesc.rst @@ -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 diff --git a/src/bindings/python/PyGpuShaderDesc.cpp b/src/bindings/python/PyGpuShaderDesc.cpp index 44aa389702..ae5e435019 100644 --- a/src/bindings/python/PyGpuShaderDesc.cpp +++ b/src/bindings/python/PyGpuShaderDesc.cpp @@ -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; @@ -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) { @@ -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 & { @@ -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 }; }); } diff --git a/tests/python/GpuShaderDescTest.py b/tests/python/GpuShaderDescTest.py index a81dc4c2c1..9ce11deb5d 100644 --- a/tests/python/GpuShaderDescTest.py +++ b/tests/python/GpuShaderDescTest.py @@ -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) @@ -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) @@ -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)