diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index e1c0953247..d5a4454aef 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -61,6 +61,7 @@ jobs: CMAKE_UNITY_BUILD=OFF CODECOV=1 CTEST_TEST_TIMEOUT=1200 + OIIO_CMAKE_FLAGS="-DOIIO_TEX_IMPLEMENT_VARYINGREF=OFF" runs-on: ${{ matrix.os }} container: diff --git a/CMakeLists.txt b/CMakeLists.txt index bd54df8301..eef27d3f75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,10 @@ set (TEX_BATCH_SIZE "" CACHE STRING "Force TextureSystem SIMD batch size (e.g. 1 if (TEX_BATCH_SIZE) add_definitions ("-DOIIO_TEXTURE_SIMD_BATCH_WIDTH=${TEX_BATCH_SIZE}") endif () +option (OIIO_TEX_IMPLEMENT_VARYINGREF "Implement the deprecated batch texture functions taking VaryingRef params" ON) +if (NOT OIIO_TEX_IMPLEMENT_VARYINGREF) + add_definitions (-DOIIO_TEX_NO_IMPLEMENT_VARYINGREF=1) +endif () # Set the default namespace set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING diff --git a/src/cmake/testing.cmake b/src/cmake/testing.cmake index 4b307e24a9..ac2520692a 100644 --- a/src/cmake/testing.cmake +++ b/src/cmake/testing.cmake @@ -182,6 +182,7 @@ macro (oiio_add_all_tests) texture-wrapfill texture-fat texture-skinny texture-stats + texture-env ) oiio_add_tests (${all_texture_tests}) # Duplicate texture tests with batch mode diff --git a/src/libtexture/environment.cpp b/src/libtexture/environment.cpp index 576b9e0296..1637913857 100644 --- a/src/libtexture/environment.cpp +++ b/src/libtexture/environment.cpp @@ -216,11 +216,15 @@ TextureSystemImpl::environment(ustring filename, TextureOptions& options, float* result, float* dresultds, float* dresultdt) { +#ifdef OIIO_TEX_NO_IMPLEMENT_VARYINGREF + return false; +#else Perthread* thread_info = get_perthread_info(); TextureHandle* texture_handle = get_texture_handle(filename, thread_info); return environment(texture_handle, thread_info, options, runflags, beginactive, endactive, R, dRdx, dRdy, nchannels, result, dresultds, dresultdt); +#endif } @@ -235,6 +239,9 @@ TextureSystemImpl::environment(TextureHandle* texture_handle, float* result, float* dresultds, float* dresultdt) { +#ifdef OIIO_TEX_NO_IMPLEMENT_VARYINGREF + return false; +#else if (!texture_handle) return false; bool ok = true; @@ -256,6 +263,7 @@ TextureSystemImpl::environment(TextureHandle* texture_handle, } } return ok; +#endif } @@ -597,8 +605,10 @@ TextureSystemImpl::environment(TextureHandle* texture_handle, bool ok = true; Tex::RunMask bit = 1; + float* r = OIIO_ALLOCA(float, 3 * nchannels * Tex::BatchWidth); + float* drds = r + nchannels * Tex::BatchWidth; + float* drdt = r + 2 * nchannels * Tex::BatchWidth; for (int i = 0; i < Tex::BatchWidth; ++i, bit <<= 1) { - float r[4], drds[4], drdt[4]; // temp result if (mask & bit) { opt.sblur = options.sblur[i]; opt.tblur = options.tblur[i]; diff --git a/src/libtexture/imagecache_pvt.h b/src/libtexture/imagecache_pvt.h index 2828ca9bc3..2d1b40a598 100644 --- a/src/libtexture/imagecache_pvt.h +++ b/src/libtexture/imagecache_pvt.h @@ -489,7 +489,7 @@ struct TileID { /// Initialize a TileID based on full elaboration of image file, /// subimage, and tile x,y,z indices. TileID(ImageCacheFile& file, int subimage, int miplevel, int x, int y, - int z = 0, int chbegin = 0, int chend = -1) + int z, int chbegin, int chend) : m_x(x) , m_y(y) , m_z(z) @@ -499,9 +499,10 @@ struct TileID { , m_chend(chend) , m_file(&file) { - int nc = file.spec(subimage, miplevel).nchannels; - if (chend < chbegin || chend > nc) + if (chend < chbegin) { + int nc = file.spec(subimage, miplevel).nchannels; m_chend = nc; + } } /// Destructor is trivial, because we don't hold any resources diff --git a/src/libtexture/texture3d.cpp b/src/libtexture/texture3d.cpp index 2e606a622c..7a39b9869f 100644 --- a/src/libtexture/texture3d.cpp +++ b/src/libtexture/texture3d.cpp @@ -197,11 +197,15 @@ TextureSystemImpl::texture3d(ustring filename, TextureOptions& options, float* result, float* dresultds, float* dresultdt, float* dresultdr) { +#ifdef OIIO_TEX_NO_IMPLEMENT_VARYINGREF + return false; +#else Perthread* thread_info = get_perthread_info(); TextureHandle* texture_handle = get_texture_handle(filename, thread_info); return texture3d(texture_handle, thread_info, options, runflags, beginactive, endactive, P, dPdx, dPdy, dPdz, nchannels, result, dresultds, dresultdt, dresultdr); +#endif } @@ -214,6 +218,9 @@ TextureSystemImpl::texture3d( VaryingRef dPdy, VaryingRef dPdz, int nchannels, float* result, float* dresultds, float* dresultdt, float* dresultdr) { +#ifdef OIIO_TEX_NO_IMPLEMENT_VARYINGREF + return false; +#else bool ok = true; result += beginactive * nchannels; if (dresultds) { @@ -235,6 +242,7 @@ TextureSystemImpl::texture3d( } } return ok; +#endif } diff --git a/src/libtexture/texturesys.cpp b/src/libtexture/texturesys.cpp index d2d64dbdba..b0ed6f179d 100644 --- a/src/libtexture/texturesys.cpp +++ b/src/libtexture/texturesys.cpp @@ -1024,11 +1024,15 @@ TextureSystemImpl::texture(ustring filename, TextureOptions& options, int nchannels, float* result, float* dresultds, float* dresultdt) { +#ifdef OIIO_TEX_NO_IMPLEMENT_VARYINGREF + return false; +#else Perthread* thread_info = get_perthread_info(); TextureHandle* texture_handle = get_texture_handle(filename, thread_info); return texture(texture_handle, thread_info, options, runflags, beginactive, endactive, s, t, dsdx, dtdx, dsdy, dtdy, nchannels, result, dresultds, dresultdt); +#endif } @@ -1043,6 +1047,9 @@ TextureSystemImpl::texture(TextureHandle* texture_handle, int nchannels, float* result, float* dresultds, float* dresultdt) { +#ifdef OIIO_TEX_NO_IMPLEMENT_VARYINGREF + return false; +#else if (!texture_handle) return false; bool ok = true; @@ -1065,6 +1072,7 @@ TextureSystemImpl::texture(TextureHandle* texture_handle, } } return ok; +#endif } diff --git a/src/testtex/testtex.cpp b/src/testtex/testtex.cpp index f2d5fa7e0d..ce1c09288f 100644 --- a/src/testtex/testtex.cpp +++ b/src/testtex/testtex.cpp @@ -88,6 +88,9 @@ static bool invalidate_before_iter = true; static bool close_before_iter = false; static bool runstats = false; static bool udim_tests = false; +static bool do_gettextureinfo = true; +static int subimage = -1; +static std::string subimagename; static Imath::M33f xform; static std::string texoptions; static std::string gtiname; @@ -106,6 +109,9 @@ typedef void (*Mapping2D)(const int&, const int&, float&, float&, float&, typedef void (*Mapping3D)(const int&, const int&, Imath::V3f&, Imath::V3f&, Imath::V3f&, Imath::V3f&); +typedef void (*MappingEnv)(const int&, const int&, Imath::V3f&, Imath::V3f&, + Imath::V3f&); + typedef void (*Mapping2DWide)(const Tex::IntWide&, const Tex::IntWide&, Tex::FloatWide&, Tex::FloatWide&, Tex::FloatWide&, Tex::FloatWide&, Tex::FloatWide&, @@ -116,6 +122,11 @@ typedef void (*Mapping3DWide)(const Tex::IntWide&, const Tex::IntWide&, Imath::Vec3&, Imath::Vec3&); +typedef void (*MappingEnvWide)(const Tex::IntWide&, const Tex::IntWide&, + Imath::Vec3&, + Imath::Vec3&, + Imath::Vec3&); + static void @@ -251,6 +262,12 @@ getargs(int argc, const char* argv[]) .help("Do udim-oriented tests"); ap.arg("--bluenoise", &use_bluenoise) .help("Use blue noise for stochastic choices"); + ap.arg("--no-gettextureinfo %!", &do_gettextureinfo) + .help("Do not test gettextureinfo"); + ap.arg("--subimage %d:INDEX", &subimage) + .help("Use the specified subimage (by index)"); + ap.arg("--subimagename %s:NAME", &subimagename) + .help("Use the specified subimage (by name)"); // clang-format on ap.parse(argc, argv); @@ -282,6 +299,10 @@ initialize_opt(TextureOpt& opt) opt.anisotropic = anisomax; opt.mipmode = (TextureOpt::MipMode)mipmode; opt.interpmode = (TextureOpt::InterpMode)interpmode; + if (subimage >= 0) + opt.subimage = subimage; + else if (!subimagename.empty()) + opt.subimagename = ustring(subimagename); } @@ -307,6 +328,10 @@ initialize_opt(TextureOptBatch& opt) opt.anisotropic = anisomax; opt.mipmode = MipMode(mipmode); opt.interpmode = InterpMode(interpmode); + if (subimage >= 0) + opt.subimage = subimage; + else if (!subimagename.empty()) + opt.subimagename = ustring(subimagename); } @@ -628,6 +653,64 @@ map_warp_3D(const Int& x, const Int& y, Imath::Vec3& P, +// Just map pixels to environment direction +void +map_env_latlong(const int& x, const int& y, Imath::Vec3& R, + Imath::Vec3& dRdx, Imath::Vec3& dRdy) +{ + float u = (x + 0.5f) / output_xres; + float v = (y + 0.5f) / output_yres; + float du_dx = float(1.0f / output_xres); // du_dy = 0 + float dv_dy = float(1.0f / output_yres); // dv_dx = 0 + float theta = float(2.0 * M_PI) * u; + float dtheta_dx = float(2.0 * M_PI) * du_dx; // dtheta_dy = 0 + float phi = float(M_PI) * v; + float dphi_dy = float(M_PI) * dv_dy; // dphi_dx = 0 + + R = Imath::Vec3(fast_sin(phi) * fast_sin(theta), fast_cos(phi), + -fast_sin(phi) * fast_cos(theta)); + dRdx = Imath::Vec3(fast_sin(phi) * fast_cos(theta) * dtheta_dx, + float(0.0f), + fast_sin(phi) * fast_sin(theta) * dtheta_dx); + dRdy = Imath::Vec3(-fast_cos(phi) * fast_sin(theta) * dphi_dy, + -fast_sin(phi) * dphi_dy, + -fast_cos(phi) * fast_cos(theta) * dphi_dy); +} + + + +// Turn v3f[lanes] into simd[3] +inline Imath::Vec3 +soa(const Imath::V3f v[]) +{ + Imath::Vec3 result; + for (int i = 0; i < Tex::BatchWidth; ++i) { + result[0][i] = v[i].x; + result[1][i] = v[i].y; + result[2][i] = v[i].z; + } + return result; +} + + + +// FIXME -- templatize map_env_latlong. For now, just loop over scalar version. +void +map_env_latlong(const Tex::IntWide& x, const Tex::IntWide& y, + Imath::Vec3& R, + Imath::Vec3& dRdx, + Imath::Vec3& dRdy) +{ + Imath::V3f r[Tex::BatchWidth], drdx[Tex::BatchWidth], drdy[Tex::BatchWidth]; + for (int i = 0; i < Tex::BatchWidth; ++i) + map_env_latlong(x[i], y[i], r[i], drdx[i], drdy[i]); + R = soa(r); + dRdx = soa(drdx); + dRdy = soa(drdy); +} + + + void plain_tex_region(ImageBuf& image, ustring filename, Mapping2D mapping, ImageBuf* image_ds, ImageBuf* image_dt, ROI roi) @@ -1071,7 +1154,224 @@ static void test_shadow(ustring /*filename*/) {} -static void test_environment(ustring /*filename*/) {} +void +env_region(ImageBuf& image, ustring filename, MappingEnv mapping, + ImageBuf* image_ds, ImageBuf* image_dt, ROI roi) +{ + TextureSystem::Perthread* perthread_info = texsys->get_perthread_info(); + TextureSystem::TextureHandle* texture_handle = texsys->get_texture_handle( + filename); + int nchannels = nchannels_override ? nchannels_override : image.nchannels(); + + TextureOpt opt; + initialize_opt(opt); + + float* result = OIIO_ALLOCA(float, nchannels); + float* dresultds = test_derivs ? OIIO_ALLOCA(float, nchannels) : NULL; + float* dresultdt = test_derivs ? OIIO_ALLOCA(float, nchannels) : NULL; + for (ImageBuf::Iterator p(image, roi); !p.done(); ++p) { + Imath::V3f R, dRdx, dRdy; + mapping(p.x(), p.y(), R, dRdx, dRdy); + // if (p.x() == 0 && p.y() == 0) + // Strutil::print("R = {}\n", R); + // Call the texture system to do the filtering. + bool ok = use_handle + ? texsys->environment(texture_handle, perthread_info, opt, + R, dRdx, dRdy, nchannels, result, + dresultds, dresultdt) + : texsys->environment(filename, opt, R, dRdx, dRdy, + nchannels, result, dresultds, + dresultdt); + if (!ok) { + std::string e = texsys->geterror(); + if (!e.empty()) + Strutil::print(std::cerr, "ERROR: {}\n", e); + } + + // Save filtered pixels back to the image. + for (int i = 0; i < nchannels; ++i) + result[i] *= scalefactor; + image.setpixel(p.x(), p.y(), result); + if (image_ds) + image_ds->setpixel(p.x(), p.y(), dresultds); + if (image_dt) + image_dt->setpixel(p.x(), p.y(), dresultdt); + } +} + + + +void +env_region_batch(ImageBuf& image, ustring filename, MappingEnvWide mapping, + ImageBuf* image_ds, ImageBuf* image_dt, ROI roi) +{ + using namespace Tex; + TextureSystem::Perthread* perthread_info = texsys->get_perthread_info(); + TextureSystem::TextureHandle* texture_handle = texsys->get_texture_handle( + filename); + int nchannels_img = image.nchannels(); + int nchannels = nchannels_override ? nchannels_override : image.nchannels(); + + TextureOptBatch opt; + initialize_opt(opt); + + FloatWide* result = OIIO_ALLOCA(FloatWide, nchannels); + FloatWide* dresultds = test_derivs ? OIIO_ALLOCA(FloatWide, nchannels) + : nullptr; + FloatWide* dresultdt = test_derivs ? OIIO_ALLOCA(FloatWide, nchannels) + : nullptr; + for (int y = roi.ybegin; y < roi.yend; ++y) { + for (int x = roi.xbegin; x < roi.xend; x += BatchWidth) { + Imath::Vec3 R, dRdx, dRdy; + mapping(IntWide::Iota(x), y, R, dRdx, dRdy); + int npoints = std::min(BatchWidth, roi.xend - x); + RunMask mask = RunMaskOn >> (BatchWidth - npoints); + + // Call the texture system to do the filtering. + // if (y == 0 && x == 0) + // Strutil::print("R = {}\n", R); + bool ok + = use_handle + ? texsys->environment(texture_handle, perthread_info, opt, + mask, (const float*)&R, + (const float*)&dRdx, + (const float*)&dRdy, nchannels, + (float*)result, (float*)dresultds, + (float*)dresultdt) + : texsys->environment(filename, opt, mask, + (const float*)&R, + (const float*)&dRdx, + (const float*)&dRdy, nchannels, + (float*)result, (float*)dresultds, + (float*)dresultdt); + + if (!ok) { + std::string e = texsys->geterror(); + if (!e.empty()) + Strutil::print(std::cerr, "ERROR: {}\n", e); + } + + // Save filtered pixels back to the image. + for (int i = 0; i < nchannels; ++i) + result[i] *= scalefactor; + float* resultptr = (float*)image.pixeladdr(x, y); + // FIXME: simplify by using SIMD scatter + for (int i = 0; i < npoints; ++i) + for (int c = 0; c < nchannels; ++c) + resultptr[c + i * nchannels_img] = result[c][i]; + if (test_derivs) { + float* resultdsptr = (float*)image_ds->pixeladdr(x, y); + float* resultdtptr = (float*)image_dt->pixeladdr(x, y); + for (int c = 0; c < nchannels; ++c) { + for (int i = 0; i < npoints; ++i) { + resultdsptr[c + i * nchannels_img] = dresultds[c][i]; + resultdtptr[c + i * nchannels_img] = dresultdt[c][i]; + } + } + } + } + } +} + + + +static void +test_environment(ustring filename, MappingEnv mapping) +{ + Strutil::print("Testing environment {}, output = {}\n", filename, + output_filename); + int nchannels = nchannels_override ? nchannels_override : 4; + ImageSpec outspec(output_xres, output_yres, nchannels, TypeDesc::FLOAT); + ImageBuf image(outspec); + TypeDesc fmt(dataformatname); + image.set_write_format(fmt); + OIIO::ImageBufAlgo::zero(image); + ImageBuf image_ds, image_dt; + if (test_derivs) { + image_ds.reset(outspec); + image_ds.set_write_format(fmt); + OIIO::ImageBufAlgo::zero(image_ds); + image_dt.reset(outspec); + image_dt.set_write_format(fmt); + OIIO::ImageBufAlgo::zero(image_dt); + } + + for (int iter = 0; iter < iters; ++iter) { + // Trick: switch to second texture, if given, for second iteration + if (iter && filenames.size() > 1) + filename = filenames[1]; + if (close_before_iter) + texsys->close_all(); + ImageBufAlgo::parallel_image( + get_roi(image.spec()), nthreads, [&](ROI roi) { + env_region(image, filename, mapping, + test_derivs ? &image_ds : nullptr, + test_derivs ? &image_dt : nullptr, roi); + }); + } + + if (!image.write(output_filename)) + Strutil::print(std::cerr, "Error writing {} : {}\n", output_filename, + image.geterror()); + if (test_derivs) { + if (!image_ds.write(output_filename + "-ds.exr")) + Strutil::print(std::cerr, "Error writing {} : {}\n", + (output_filename + "-ds.exr"), image_ds.geterror()); + if (!image_dt.write(output_filename + "-dt.exr")) + Strutil::print(std::cerr, "Error writing {} : {}\n", + (output_filename + "-dt.exr"), image_dt.geterror()); + } +} + + + +static void +test_environment_batch(ustring filename, MappingEnvWide mapping) +{ + Strutil::print("Testing BATCHED environment {}, output = {}\n", filename, + output_filename); + int nchannels = nchannels_override ? nchannels_override : 4; + ImageSpec outspec(output_xres, output_yres, nchannels, TypeDesc::FLOAT); + ImageBuf image(outspec); + TypeDesc fmt(dataformatname); + image.set_write_format(fmt); + OIIO::ImageBufAlgo::zero(image); + ImageBuf image_ds, image_dt; + if (test_derivs) { + image_ds.reset(outspec); + image_ds.set_write_format(fmt); + OIIO::ImageBufAlgo::zero(image_ds); + image_dt.reset(outspec); + image_dt.set_write_format(fmt); + OIIO::ImageBufAlgo::zero(image_dt); + } + + for (int iter = 0; iter < iters; ++iter) { + // Trick: switch to second texture, if given, for second iteration + if (iter && filenames.size() > 1) + filename = filenames[1]; + if (close_before_iter) + texsys->close_all(); + ImageBufAlgo::parallel_image( + get_roi(image.spec()), nthreads, [&](ROI roi) { + env_region_batch(image, filename, mapping, + test_derivs ? &image_ds : nullptr, + test_derivs ? &image_dt : nullptr, roi); + }); + } + + if (!image.write(output_filename)) + Strutil::print(std::cerr, "Error writing {} : {}\n", output_filename, + image.geterror()); + if (test_derivs) { + if (!image_ds.write(output_filename + "-ds.exr")) + Strutil::print(std::cerr, "Error writing {} : {}\n", + (output_filename + "-ds.exr"), image_ds.geterror()); + if (!image_dt.write(output_filename + "-dt.exr")) + Strutil::print(std::cerr, "Error writing {} : {}\n", + (output_filename + "-dt.exr"), image_dt.geterror()); + } +} @@ -1121,6 +1421,7 @@ test_getimagespec_gettexels(ustring filename) +#ifndef CODECOV static void test_hash() { @@ -1155,7 +1456,7 @@ test_hash() for (int f = 0; f < nfiles; ++f) { for (int y = 0; y < res; y += tilesize) { for (int x = 0; x < res; x += tilesize, ++i) { - OIIO::pvt::TileID id(*icf[f], 0, 0, x, y, 0); + OIIO::pvt::TileID id(*icf[f], 0, 0, x, y, 0, 0, 1); size_t h = id.hash(); hh += h; } @@ -1173,7 +1474,7 @@ test_hash() for (int f = 0; f < nfiles; ++f) { for (int y = 0; y < res; y += tilesize) { for (int x = 0; x < res; x += tilesize, ++i) { - OIIO::pvt::TileID id(*icf[f], 0, 0, x, y, 0); + OIIO::pvt::TileID id(*icf[f], 0, 0, x, y, 0, 0, 1); size_t h = id.hash(); ++fourbits[h & 0xf]; ++eightbits[h & 0xff]; @@ -1229,6 +1530,7 @@ test_hash() ImageCache::destroy(imagecache); } +#endif @@ -1710,9 +2012,11 @@ main(int argc, const char* argv[]) iters = 0; } +#ifndef CODECOV if (testhash) { test_hash(); } +#endif Imath::M33f scale; scale.scale(Imath::V2f(0.3, 0.3)); @@ -1769,7 +2073,8 @@ main(int argc, const char* argv[]) Strutil::print("\n"); } else if (iters > 0 && filenames.size()) { ustring filename(filenames[0]); - test_gettextureinfo(filenames[0]); + if (do_gettextureinfo) + test_gettextureinfo(filenames[0]); const char* texturetype = "Plain Texture"; texsys->get_texture_info(filename, 0, ustring("texturetype"), TypeDesc::STRING, &texturetype); @@ -1813,10 +2118,13 @@ main(int argc, const char* argv[]) test_shadow(filename); } if (!strcmp(texturetype, "Environment")) { - test_environment(filename); + if (batch) { + test_environment_batch(filename, map_env_latlong); + } else { + test_environment(filename, map_env_latlong); + } } - if (!udim_tests) - test_getimagespec_gettexels(filename); + test_getimagespec_gettexels(filename); if (runstats || verbose) Strutil::print("Time: {}\n", Strutil::timeintervalformat(timer())); } diff --git a/testsuite/maketx/ref/out.txt b/testsuite/maketx/ref/out.txt index e706f43635..2c644b3d9d 100644 --- a/testsuite/maketx/ref/out.txt +++ b/testsuite/maketx/ref/out.txt @@ -263,6 +263,7 @@ checker-prman.tx : 128 x 128, 4 channel, int16 tiff tiff:Compression: 8 tiff:PhotometricInterpretation: 2 tiff:PlanarConfiguration: 2 +make_texture ERROR: maketx ERROR: Nan/Inf at 2 pixels Reading nan.exr nan.exr : 64 x 64, 3 channel, half openexr SHA-1: 47A8E8F3E8B2C3B6B032FCC8C39D3C5FC1AAA390 diff --git a/testsuite/maketx/run.py b/testsuite/maketx/run.py index 3ed6e9dbb9..ae5d122918 100755 --- a/testsuite/maketx/run.py +++ b/testsuite/maketx/run.py @@ -1,5 +1,8 @@ #!/usr/bin/env python +failureok = 1 + + # Just for simplicity, make a checkerboard with a solid alpha command += oiiotool (" --pattern checker 128x128 4 --ch R,G,B,=1.0" + " -d uint8 -o " + make_relpath("checker.tif") ) @@ -66,10 +69,13 @@ command += maketx_command ("checker.tif", "checker-prman.tx", "-d uint16 --prman", showinfo=True) +# Test --checknan : take advantage of the bad.exr images in +# testsuite/oiiotool-fixnan. (Use --nomipmap to cut down on stats output) +command += maketx_command (OIIO_TESTSUITE_ROOT+"/oiiotool-fixnan/src/bad.exr", + "nan.exr", "--checknan --nomipmap") + # Test --fixnan : take advantage of the bad.exr images in # testsuite/oiiotool-fixnan. (Use --nomipmap to cut down on stats output) -# FIXME: would also like to test --checknan, but the problem with that is -# that is actually FAILS if there's a nan. command += maketx_command (OIIO_TESTSUITE_ROOT+"/oiiotool-fixnan/src/bad.exr", "nan.exr", "--fixnan box3 --nomipmap", showinfo=True, showinfo_extra="--stats") @@ -121,7 +127,7 @@ -# To do: --filter --checknan --fullpixels +# To do: --filter --fullpixels # --prman-metadata --ignore-unassoc # --mipimage # --envlatl TIFF, --envlatl EXR diff --git a/testsuite/runtest.py b/testsuite/runtest.py index cc2e4fce97..b889723715 100755 --- a/testsuite/runtest.py +++ b/testsuite/runtest.py @@ -382,10 +382,11 @@ def checkref (name, refdirlist) : pattern = "*.*" else : pattern = prefix+"-*"+extension+"*" + print("comparisons are", ([defaulttest] + glob.glob (os.path.join (ref, pattern)))) for testfile in ([defaulttest] + glob.glob (os.path.join (ref, pattern))) : if not os.path.exists(testfile) : continue - # print ("comparing " + name + " to " + testfile) + print ("comparing " + name + " to " + testfile) if extension in image_extensions : # images -- use idiff cmpcommand = diff_command (name, testfile, concat=False, silent=True) diff --git a/testsuite/texture-env/ref/5chan.exr b/testsuite/texture-env/ref/5chan.exr new file mode 100644 index 0000000000..594f84c12b Binary files /dev/null and b/testsuite/texture-env/ref/5chan.exr differ diff --git a/testsuite/texture-env/ref/bicubic-trilinear.exr b/testsuite/texture-env/ref/bicubic-trilinear.exr new file mode 100644 index 0000000000..c6ac96ee1b Binary files /dev/null and b/testsuite/texture-env/ref/bicubic-trilinear.exr differ diff --git a/testsuite/texture-env/ref/bilinear-onelevel.exr b/testsuite/texture-env/ref/bilinear-onelevel.exr new file mode 100644 index 0000000000..2132363da6 Binary files /dev/null and b/testsuite/texture-env/ref/bilinear-onelevel.exr differ diff --git a/testsuite/texture-env/ref/closest-nomip.exr b/testsuite/texture-env/ref/closest-nomip.exr new file mode 100644 index 0000000000..a0871a80df Binary files /dev/null and b/testsuite/texture-env/ref/closest-nomip.exr differ diff --git a/testsuite/texture-env/ref/env-handle.exr b/testsuite/texture-env/ref/env-handle.exr new file mode 100644 index 0000000000..a05a75df20 Binary files /dev/null and b/testsuite/texture-env/ref/env-handle.exr differ diff --git a/testsuite/texture-env/ref/env-handle.exr-ds.exr b/testsuite/texture-env/ref/env-handle.exr-ds.exr new file mode 100644 index 0000000000..ed9feb01b4 Binary files /dev/null and b/testsuite/texture-env/ref/env-handle.exr-ds.exr differ diff --git a/testsuite/texture-env/ref/env-handle.exr-dt.exr b/testsuite/texture-env/ref/env-handle.exr-dt.exr new file mode 100644 index 0000000000..b53ff5fd18 Binary files /dev/null and b/testsuite/texture-env/ref/env-handle.exr-dt.exr differ diff --git a/testsuite/texture-env/ref/env.exr b/testsuite/texture-env/ref/env.exr new file mode 100644 index 0000000000..e07b56e2c8 Binary files /dev/null and b/testsuite/texture-env/ref/env.exr differ diff --git a/testsuite/texture-env/ref/out-batch.txt b/testsuite/texture-env/ref/out-batch.txt new file mode 100644 index 0000000000..a8e4f47c3a --- /dev/null +++ b/testsuite/texture-env/ref/out-batch.txt @@ -0,0 +1,54 @@ +Created texture system +Result of get_texture_info resolution (as int[2]) = true 256x128 +Result of get_texture_info resolution (as int[3]) = true 256x128x1 +Result of get_texture_info channels = true 4 +Result of get_texture_info channels = true 4 +Result of get_texture_info data format = true half +Result of get_texture_info datawindow (as int[4]) = true [0 0 255 127] +Result of get_texture_info datawindow (as int[6]) = true [0 0 0 255 127 0] +Result of get_texture_info displaywindow (as int[4]) = true [0 0 255 127] +Result of get_texture_info displaywindow (as int[6]) = true [0 0 0 255 127 0] +Result of get_texture_info datetime = true 2022-11-11 11:11:11 +Result of get_texture_info averagecolor = yes 0.375 0.375 0 1 +Result of get_texture_info averagealpha = yes 1 +Result of get_texture_info constantcolor = no +Result of get_texture_info constantalpha = no +Texture type is true LatLong Environment + +Testing BATCHED environment rampenv.exr, output = env.exr +Created texture system +Testing BATCHED environment rampenv.exr, output = env-handle.exr +Created texture system +Testing BATCHED environment env5chan.exr, output = 5chan.exr +Created texture system +Testing BATCHED environment rampenv.exr, output = subimage0.exr +Created texture system +Testing BATCHED environment rampenv.exr, output = subimagefred.exr +Created texture system +Testing BATCHED environment rampenv.exr, output = subimagemissing.exr +ERROR: Unknown subimage "missing" in texture "rampenv.exr" +Unknown subimage "missing" in texture "rampenv.exr" +Created texture system +Testing BATCHED environment rampenv.exr, output = closest-nomip.exr +Created texture system +Testing BATCHED environment rampenv.exr, output = bilinear-onelevel.exr +Created texture system +Testing BATCHED environment rampenv.exr, output = bicubic-trilinear.exr +Comparing "env.exr" and "ref/env.exr" +PASS +Comparing "env-handle.exr" and "ref/env-handle.exr" +PASS +Comparing "5chan.exr" and "ref/5chan.exr" +PASS +Comparing "subimage0.exr" and "ref/subimage0.exr" +PASS +Comparing "subimagefred.exr" and "ref/subimagefred.exr" +PASS +Comparing "subimagemissing.exr" and "ref/subimagemissing.exr" +PASS +Comparing "closest-nomip.exr" and "ref/closest-nomip.exr" +PASS +Comparing "bilinear-onelevel.exr" and "ref/bilinear-onelevel.exr" +PASS +Comparing "bicubic-trilinear.exr" and "ref/bicubic-trilinear.exr" +PASS diff --git a/testsuite/texture-env/ref/out.txt b/testsuite/texture-env/ref/out.txt new file mode 100644 index 0000000000..b0357da282 --- /dev/null +++ b/testsuite/texture-env/ref/out.txt @@ -0,0 +1,54 @@ +Created texture system +Result of get_texture_info resolution (as int[2]) = true 256x128 +Result of get_texture_info resolution (as int[3]) = true 256x128x1 +Result of get_texture_info channels = true 4 +Result of get_texture_info channels = true 4 +Result of get_texture_info data format = true half +Result of get_texture_info datawindow (as int[4]) = true [0 0 255 127] +Result of get_texture_info datawindow (as int[6]) = true [0 0 0 255 127 0] +Result of get_texture_info displaywindow (as int[4]) = true [0 0 255 127] +Result of get_texture_info displaywindow (as int[6]) = true [0 0 0 255 127 0] +Result of get_texture_info datetime = true 2022-11-11 11:11:11 +Result of get_texture_info averagecolor = yes 0.375 0.375 0 1 +Result of get_texture_info averagealpha = yes 1 +Result of get_texture_info constantcolor = no +Result of get_texture_info constantalpha = no +Texture type is true LatLong Environment + +Testing environment rampenv.exr, output = env.exr +Created texture system +Testing environment rampenv.exr, output = env-handle.exr +Created texture system +Testing environment env5chan.exr, output = 5chan.exr +Created texture system +Testing environment rampenv.exr, output = subimage0.exr +Created texture system +Testing environment rampenv.exr, output = subimagefred.exr +Created texture system +Testing environment rampenv.exr, output = subimagemissing.exr +ERROR: Unknown subimage "missing" in texture "rampenv.exr" +ERROR: Unknown subimage "missing" in texture "rampenv.exr" +Created texture system +Testing environment rampenv.exr, output = closest-nomip.exr +Created texture system +Testing environment rampenv.exr, output = bilinear-onelevel.exr +Created texture system +Testing environment rampenv.exr, output = bicubic-trilinear.exr +Comparing "env.exr" and "ref/env.exr" +PASS +Comparing "env-handle.exr" and "ref/env-handle.exr" +PASS +Comparing "5chan.exr" and "ref/5chan.exr" +PASS +Comparing "subimage0.exr" and "ref/subimage0.exr" +PASS +Comparing "subimagefred.exr" and "ref/subimagefred.exr" +PASS +Comparing "subimagemissing.exr" and "ref/subimagemissing.exr" +PASS +Comparing "closest-nomip.exr" and "ref/closest-nomip.exr" +PASS +Comparing "bilinear-onelevel.exr" and "ref/bilinear-onelevel.exr" +PASS +Comparing "bicubic-trilinear.exr" and "ref/bicubic-trilinear.exr" +PASS diff --git a/testsuite/texture-env/ref/subimage0.exr b/testsuite/texture-env/ref/subimage0.exr new file mode 100644 index 0000000000..e28ed7de19 Binary files /dev/null and b/testsuite/texture-env/ref/subimage0.exr differ diff --git a/testsuite/texture-env/ref/subimagefred.exr b/testsuite/texture-env/ref/subimagefred.exr new file mode 100644 index 0000000000..e28ed7de19 Binary files /dev/null and b/testsuite/texture-env/ref/subimagefred.exr differ diff --git a/testsuite/texture-env/ref/subimagemissing.exr b/testsuite/texture-env/ref/subimagemissing.exr new file mode 100644 index 0000000000..6248cdc97c Binary files /dev/null and b/testsuite/texture-env/ref/subimagemissing.exr differ diff --git a/testsuite/texture-env/run.py b/testsuite/texture-env/run.py new file mode 100755 index 0000000000..3cc61f48f2 --- /dev/null +++ b/testsuite/texture-env/run.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +redirect = ">> out.txt 2>&1" +# Create a ramped checker +command += oiiotool("-pattern fill:topleft=0,0,0,1:topright=1,0,0,1:bottomleft=0,1,0,1:bottomright=1,1,0,1 256x128 4 " + "-pattern checker:color1=1,1,1,1:color2=0.5,0.5,0.5,1:width=16:height=16 256x128 4 -mul " + "-attrib DateTime \"2022-11-11 11:11:11\" -attrib oiio:subimagename Fred " + "-d half -oenv rampenv.exr") + +command += testtex_command("--res 64 32 -d half -o env.exr rampenv.exr") + +# This time, use handles, exercise derivatives +command += testtex_command("--handle --derivs --no-gettextureinfo " + "--res 64 32 -d half -o env-handle.exr rampenv.exr") + +# more channels +command += oiiotool("-pattern fill:topleft=0,0,0,1,1:topright=1,0,0,1,1:bottomleft=0,1,0,1,1:bottomright=1,1,0,1,1 256x128 5 " + "-pattern checker:color1=1,1,1,1,1:color2=0.5,0.5,0.5,1,0.5:width=16:height=16 256x128 5 -mul " + "-attrib DateTime \"2022-11-11 11:11:11\" -d half -oenv env5chan.exr") +command += testtex_command("--nchannels 5 --derivs --no-gettextureinfo --res 64 32 -d half -o 5chan.exr env5chan.exr") + +# subimages +command += testtex_command("--nchannels 4 --no-gettextureinfo -subimage 0 --res 64 32 -d half -o subimage0.exr rampenv.exr") +command += testtex_command("--nchannels 4 --no-gettextureinfo -subimagename Fred --res 64 32 -d half -o subimagefred.exr rampenv.exr") +command += testtex_command("--nchannels 4 --no-gettextureinfo -subimagename missing --res 2 1 -d half -o subimagemissing.exr rampenv.exr") + +# interp and mip modes +command += testtex_command("-interpmode 0 -mipmode 1 --no-gettextureinfo --res 64 32 -d half -o closest-nomip.exr rampenv.exr") +command += testtex_command("-interpmode 1 -mipmode 2 --no-gettextureinfo --res 64 32 -d half -o bilinear-onelevel.exr rampenv.exr") +command += testtex_command("-interpmode 2 -mipmode 3 --no-gettextureinfo --res 64 32 -d half -o bicubic-trilinear.exr rampenv.exr") + +outputs = [ "env.exr", + "env-handle.exr", + "5chan.exr", + "subimage0.exr", + "subimagefred.exr", + "subimagemissing.exr", + "closest-nomip.exr", + "bilinear-onelevel.exr", + "bicubic-trilinear.exr", + "out.txt" ]