Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions test/RenderingFramework/AndroidTestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -329,17 +329,14 @@ AndroidTestContext::AndroidTestContext(int w, int h) : TestContext(w, h)

void AndroidTestContext::init()
{
std::string localAppPath = getenv("HVT_TEST_ASSETS");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously android impl had been using symlinks - not sure if this is what that was. If things work now, great! Thanks for tidying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestHelpers::getAssetsDataFolder() is doing that.

_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<TestHelpers::VulkanRendererContext>(_width, _height);
if (!_backend)
{
throw std::runtime_error("Failed to initialize the unit test backend!");
}

_backend->setDataPath(localAppPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this was a scoping-like action (should've been RAII). If we no longer need it, great, but sanity check that its all good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, validated locally on macOS & Windows.

}

} // namespace TestHelpers
9 changes: 3 additions & 6 deletions test/RenderingFramework/MetalTestContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -404,16 +403,14 @@ 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<TestHelpers::MetalRendererContext>(_width, _height);
if (!_backend)
{
throw std::runtime_error("Failed to initialize the unit test backend!");
}

_backend->setDataPath(mainBundlePath() + "/data/");
}

} // namespace TestHelpers
13 changes: 3 additions & 10 deletions test/RenderingFramework/OpenGLTestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No static in case there is a need to change it for a specific unit test.

const std::filesystem::path screenShotPath = getFilename(filePath, fileName + "_computed");

// Make sure the parent directory exists.
Expand All @@ -308,6 +307,7 @@ bool OpenGLRendererContext::saveImage(const std::string& fileName)

std::vector<unsigned char> image(width() * height() * 4, 100);
glReadPixels(0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, image.data());

// Write image.

std::filesystem::remove(screenShotPath);
Expand All @@ -333,21 +333,14 @@ 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<TestHelpers::OpenGLRendererContext>(_width, _height);
if (!_backend)
{
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
6 changes: 0 additions & 6 deletions test/RenderingFramework/TestHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -168,8 +165,6 @@ class HydraRendererContext
int _width = 1;
int _height = 1;

std::filesystem::path _dataPath;

pxr::HdDriver _hgiDriver;
};

Expand Down Expand Up @@ -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(); }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used.

std::shared_ptr<TestHelpers::HydraRendererContext>& backend() { return _backend; }

// Render a single frame pass.
Expand Down
12 changes: 3 additions & 9 deletions test/RenderingFramework/VulkanTestContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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<TestHelpers::VulkanRendererContext>(_width, _height);
Expand All @@ -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
Expand Down