diff --git a/test/RenderingFramework/AndroidTestContext.cpp b/test/RenderingFramework/AndroidTestContext.cpp index e68c5e3..3aea844 100644 --- a/test/RenderingFramework/AndroidTestContext.cpp +++ b/test/RenderingFramework/AndroidTestContext.cpp @@ -99,7 +99,7 @@ void VulkanRendererContext::waitForGPUIdle() bool VulkanRendererContext::saveImage(const std::string& fileName) { - static const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); + const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed"); const std::filesystem::path directory = screenShotPath.parent_path(); if (!std::filesystem::exists(directory)) @@ -329,8 +329,7 @@ AndroidTestContext::AndroidTestContext(int w, int h) : TestContext(w, h) void AndroidTestContext::init() { - std::string localAppPath = getenv("HVT_TEST_ASSETS"); - _sceneFilepath = localAppPath + "/usd/test_fixed.usda"; + _sceneFilepath = (TestHelpers::getAssetsDataFolder() / "usd/test_fixed.usda").string(); // Create the renderer context required for Hydra. _backend = std::make_shared(_width, _height); @@ -338,8 +337,6 @@ void AndroidTestContext::init() { throw std::runtime_error("Failed to initialize the unit test backend!"); } - - _backend->setDataPath(localAppPath); } } // namespace TestHelpers diff --git a/test/RenderingFramework/MetalTestContext.mm b/test/RenderingFramework/MetalTestContext.mm index 6b871d5..3828f05 100644 --- a/test/RenderingFramework/MetalTestContext.mm +++ b/test/RenderingFramework/MetalTestContext.mm @@ -358,9 +358,8 @@ void composeToFrameBuffer( { // Creates the root destination path if needed. - const std::filesystem::path dirPath = documentDirectoryPath() + "/Data"; - // The fileName could contain part of the directory path. - const std::filesystem::path fullFilePath = getFilename(dirPath, fileName + "_computed"); + const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); + const std::filesystem::path fullFilePath = getFilename(filePath, fileName + "_computed"); const std::filesystem::path directory = fullFilePath.parent_path(); NSFileManager* fileManager = [[NSFileManager alloc] init]; @@ -404,7 +403,7 @@ void composeToFrameBuffer( void MetalTestContext::init() { - _sceneFilepath = mainBundlePath() + "/data/assets/usd/test_fixed.usda"; + _sceneFilepath = (TestHelpers::getAssetsDataFolder() / "usd/test_fixed.usda").string(); // Create the renderer context required for Hydra. _backend = std::make_shared(_width, _height); @@ -412,8 +411,6 @@ void composeToFrameBuffer( { throw std::runtime_error("Failed to initialize the unit test backend!"); } - - _backend->setDataPath(mainBundlePath() + "/data/"); } } // namespace TestHelpers diff --git a/test/RenderingFramework/OpenGLTestContext.cpp b/test/RenderingFramework/OpenGLTestContext.cpp index ee5d374..9b0c676 100644 --- a/test/RenderingFramework/OpenGLTestContext.cpp +++ b/test/RenderingFramework/OpenGLTestContext.cpp @@ -296,8 +296,7 @@ void OpenGLRendererContext::run( bool OpenGLRendererContext::saveImage(const std::string& fileName) { - static const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); - + const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed"); // Make sure the parent directory exists. @@ -308,6 +307,7 @@ bool OpenGLRendererContext::saveImage(const std::string& fileName) std::vector image(width() * height() * 4, 100); glReadPixels(0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, image.data()); + // Write image. std::filesystem::remove(screenShotPath); @@ -333,9 +333,7 @@ OpenGLTestContext::OpenGLTestContext(int w, int h) : TestContext(w, h) void OpenGLTestContext::init() { - namespace fs = std::filesystem; - - _sceneFilepath = TOSTRING(HVT_TEST_DATA_PATH) + "/data/assets/usd/test_fixed.usda"; + _sceneFilepath = (TestHelpers::getAssetsDataFolder() / "usd/test_fixed.usda").string(); // Create the renderer context required for Hydra. _backend = std::make_shared(_width, _height); @@ -343,11 +341,6 @@ void OpenGLTestContext::init() { throw std::runtime_error("Failed to initialize the unit test backend!"); } - - fs::path dataPath = - std::filesystem::path(TOSTRING(HVT_TEST_DATA_PATH), fs::path::native_format); - dataPath.append("data/assets"); - _backend->setDataPath(dataPath); } } // namespace TestHelpers diff --git a/test/RenderingFramework/TestHelpers.h b/test/RenderingFramework/TestHelpers.h index e652404..901f4c9 100644 --- a/test/RenderingFramework/TestHelpers.h +++ b/test/RenderingFramework/TestHelpers.h @@ -142,9 +142,6 @@ class HydraRendererContext virtual bool compareOutputImages(const std::string& fileName1, const std::string& fileName2, const uint8_t threshold = 1, const uint16_t pixelCountThreshold = 0); - virtual void setDataPath(const std::filesystem::path& path) { _dataPath = path; } - virtual const std::filesystem::path& dataPath() const { return _dataPath; } - protected: pxr::HgiUniquePtr _hgi; bool _presentationEnabled = true; @@ -168,8 +165,6 @@ class HydraRendererContext int _width = 1; int _height = 1; - std::filesystem::path _dataPath; - pxr::HdDriver _hgiDriver; }; @@ -241,7 +236,6 @@ class TestContext int width() const { return _width; } int height() const { return _height; } bool presentationEnabled() const { return _usePresentationTask; } - const std::filesystem::path& dataPath() const { return _backend->dataPath(); } std::shared_ptr& backend() { return _backend; } // Render a single frame pass. diff --git a/test/RenderingFramework/VulkanTestContext.cpp b/test/RenderingFramework/VulkanTestContext.cpp index b9ccd45..18f6e69 100644 --- a/test/RenderingFramework/VulkanTestContext.cpp +++ b/test/RenderingFramework/VulkanTestContext.cpp @@ -369,9 +369,8 @@ void VulkanRendererContext::waitForGPUIdle() bool VulkanRendererContext::saveImage(const std::string& fileName) { static const std::filesystem::path filePath = TestHelpers::getOutputDataFolder(); - - const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed"); - const std::filesystem::path directory = screenShotPath.parent_path(); + const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed"); + const std::filesystem::path directory = screenShotPath.parent_path(); if (!std::filesystem::exists(directory)) { if (!std::filesystem::create_directories(directory)) @@ -914,9 +913,7 @@ VulkanTestContext::VulkanTestContext(int w, int h) : TestContext(w, h) void VulkanTestContext::init() { - namespace fs = std::filesystem; - - _sceneFilepath = (fs::path(TOSTRING(HVT_TEST_DATA_PATH)) / "data/assets/usd/test_fixed.usda").string(); + _sceneFilepath = (TestHelpers::getAssetsDataFolder() / "usd/test_fixed.usda").string(); // Create the renderer context required for Hydra. _backend = std::make_shared(_width, _height); @@ -925,9 +922,6 @@ void VulkanTestContext::init() throw std::runtime_error("Failed to initialize the unit test backend!"); } - fs::path dataPath = fs::path(TOSTRING(TEST_HVT_DATA_PATH)) / "Data"; - _backend->setDataPath(dataPath); - // If the presentation task is enabled, interop-present task get involved. // Which for the Vulkan backend involves copying a Vulkan image to OpenGL // before presenting to an OpenGL context. This is against the intended