-
Notifications
You must be signed in to change notification settings - Fork 0
OGSMOD-6769: Run Vulkan unit tests after OpenGL for Viewport Toolbox #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9786129
to
ed8c718
Compare
Global comments:
|
return fullFilepath; | ||
}; | ||
|
||
bool HydraRendererContext::compareImages( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still used by other functions.
return compareImages(computed, baseLine, threshold, 1); | ||
} | ||
|
||
bool HydraRendererContext::compareOutputImages(const std::string& fileName1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this method be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still used in other places.
#include <gtest/gtest.h> | ||
|
||
TEST(TestViewportToolbox, framePassUID) | ||
#include <RenderingFramework/TestFlags.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include is already in RenderingFramework/TestContextCreator.h
(at line 25)
|
||
#include <gtest/gtest.h> | ||
|
||
#include <RenderingFramework/TestFlags.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already included in #include <RenderingFramework/TestContextCreator.h>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hodoulp True, but isn't it good practice to include what is used in a cpp?
This makes the code of this file more robust to future changes in TestContextCreator.h, and it is also clearer, in my opinion.
That being said, this file will compile without the include, so you are right about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle yes. In that specific case it adds useless changes everywhere.
Anyway, that's really minor.
test/RenderingFramework/TestFlags.h
Outdated
TestHelpers::getTestNames(::testing::UnitTest::GetInstance()->current_test_info()); \ | ||
AGPTestDefaultBackend##TestName(); \ | ||
} \ | ||
void AGPTestDefaultBackend##TestName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a method is created the name must be unique but TestName
could not be unique.
To be safe it should be:
void HVTTestDefaultBackend##TestSuiteName##TestName();
test/RenderingFramework/TestFlags.h
Outdated
{ \ | ||
TestHelpers::gParameterizedTests = false; \ | ||
TestHelpers::gTestNames = TestHelpers::getTestNames( \ | ||
::testing::UnitTest::GetInstance()->current_test_info()); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few missing spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
test/RenderingFramework/TestFlags.h
Outdated
// If parameterized tests are used, test_suite_name and name returns | ||
// SuiteName/TestName/Param. Hence the following filtering is | ||
// needed. | ||
if (TestHelpers::gParameterizedTests == true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (TestHelpers::gParameterizedTests == true)
-> if (TestHelpers::gParameterizedTests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces the HVT_TEST macro system to enable parameterized testing for different rendering backends (OpenGL, Vulkan, etc.) in the Viewport Toolbox, laying groundwork for future Vulkan test enablement while currently only testing OpenGL.
- Replaces standard
TEST
macros withHVT_TEST
andHVT_TEST_DEFAULT_BACKEND
macros - Updates image comparison logic to use new helper functions for parameterized test naming
- Adds backend parameterization infrastructure in TestFlags.h
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/tests/testTaskManager.cpp | Converts TEST macros to HVT_TEST variants and updates image comparison calls |
test/tests/testSearches.cpp | Converts TEST macros to HVT_TEST variants and updates image comparison calls |
test/tests/testFramePasses.cpp | Converts TEST macros to HVT_TEST variants and updates image comparison calls |
test/tests/testFramePass.cpp | Converts TEST macros to HVT_TEST variants, adds TestFlags.h include, and updates image comparison calls |
test/howTos/*.cpp | Converts TEST macros to HVT_TEST variants, adds TestFlags.h includes, and updates image comparison calls |
test/RenderingFramework/TestHelpers.h | Adds compareImage method declaration |
test/RenderingFramework/TestHelpers.cpp | Implements compareImage method |
test/RenderingFramework/TestFlags.h | Adds HVT_TEST macro definitions and test naming helper functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
test/RenderingFramework/TestFlags.h
Outdated
{ \ | ||
public: \ | ||
void AGPTest##TestName(); \ | ||
}; \ |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commented out 'Vulkan' parameter suggests incomplete implementation. Consider adding a TODO comment explaining when Vulkan will be enabled or use a more explicit conditional compilation approach.
}; \ | |
}; \ | |
/* TODO: Enable "Vulkan" backend when Vulkan support is complete and stable. | |
Currently, only "OpenGL" is enabled for testing. */ |
Copilot uses AI. Check for mistakes.
test/tests/testSearches.cpp
Outdated
// Validates the rendering result. | ||
|
||
std::string imageFile = std::string(test_info_->name()); | ||
const std::string computedFileName = TestHelpers::getComputedImagePath(); |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment to const variable 'computedFileName' will not compile. The variable should be declared as non-const or the logic should be restructured.
const std::string computedFileName = TestHelpers::getComputedImagePath(); | |
std::string computedFileName = TestHelpers::getComputedImagePath(); |
Copilot uses AI. Check for mistakes.
test/RenderingFramework/TestFlags.h
Outdated
public: \ | ||
void AGPTest##TestName(); \ | ||
}; \ | ||
INSTANTIATE_TEST_SUITE_P(TestSuiteName, TestName, ::testing::Values(/*"Vulkan",*/ "OpenGL"), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this is the line that will need to be changed to activate Vulkan:
INSTANTIATE_TEST_SUITE_P(TestSuiteName, TestName, ::testing::Values(/*"Vulkan",*/ "OpenGL"),
->
INSTANTIATE_TEST_SUITE_P(TestSuiteName, TestName, ::testing::Values("Vulkan", "OpenGL"),
|
||
#include <gtest/gtest.h> | ||
|
||
#include <RenderingFramework/TestFlags.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hodoulp True, but isn't it good practice to include what is used in a cpp?
This makes the code of this file more robust to future changes in TestContextCreator.h, and it is also clearer, in my opinion.
That being said, this file will compile without the include, so you are right about that.
test/RenderingFramework/TestFlags.h
Outdated
::testing::UnitTest::GetInstance()->current_test_info()); \ | ||
AGPTestDefaultBackend##TestName(); \ | ||
} \ | ||
void AGPTestDefaultBackend##TestName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: The block is the exact same as, defined above:
#define HVT_TEST_DEFAULT_BACKEND(TestSuiteName, TestName) \
void AGPTestDefaultBackend##TestName(); \
TEST(TestSuiteName, TestName) \
{ \
TestHelpers::gParameterizedTests = false; \
TestHelpers::gTestNames = TestHelpers::getTestNames( \
::testing::UnitTest::GetInstance()->current_test_info()); \
AGPTestDefaultBackend##TestName(); \
} \
void AGPTestDefaultBackend##TestName()
The only difference is the name.
I am guessing you could define it as follow to prevent repetition:
#define HVT_TEST(TestSuiteName, TestName) HVT_TEST_DEFAULT_BACKEND(TestSuiteName, TestName)
@sm-adsk |
ed8c718
to
9e6bc1d
Compare
@sm-adsk do not squash your commits because I cannot see what you changed. |
These links do not highlight any code section i.e., seem to be invalid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main questions/comments are:
- https://github.com/Autodesk/hydra-viewport-toolbox/pull/76/files#r2388661106
- https://github.com/Autodesk/hydra-viewport-toolbox/pull/76/files#r2388664816
- https://github.com/Autodesk/hydra-viewport-toolbox/pull/76/files#r2388677525
- https://github.com/Autodesk/hydra-viewport-toolbox/pull/76/files#r2388706072
The squash commit might have invalidated these links.
|
test/RenderingFramework/TestFlags.h
Outdated
{ \ | ||
return info.param; \ | ||
} \ | ||
class TestName : public ::testing::TestWithParam<std::string> \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed:
Param##TestSuiteName##TestName
-> Param##TestSuiteName##TestName
class TestName
-> class UnitTest##TestSuiteName##TestName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, the method can be a static method from class UnitTest##TestSuiteName##TestName
class UnitTest##TestSuiteName##TestName : public ::testing::TestWithParam<std::string>
{
public:
std::string GetParam(testing::TestParamInfo<std::string> const& info)
{
return info.param;
}
void execute();
};
|
||
inline bool gRunVulkanTests = false; | ||
inline bool gParameterizedTests = false; | ||
inline TestNames gTestNames = TestNames {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three declarations are 'strange' i.e., inline
!?
Does it mean that they will be created every time this file header is included?
My current understand is that they must be static
to have only one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing inline with static gives the following error on Jenkins:
'TestHelpers::gRunVulkanTests' defined but not used [-Werror=unused-variable]
{ | ||
std::string suiteName; | ||
std::string fixtureName; | ||
std::string paramName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Doxygen comments to explain these three data members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/RenderingFramework/TestFlags.h
Outdated
TestHelpers::gTestNames = TestHelpers::getTestNames( \ | ||
::testing::UnitTest::GetInstance()->current_test_info()); \ | ||
HVTTest##TestName(); \ | ||
} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a global data for gRunVulkanTests
& gTestNames
when you can change the code to be:
const auto backendIsVulkan = (GetParam() == "Vulkan");
const auto testInfo = (::testing::UnitTest::GetInstance()->current_test_info());
HVTTest##TestName(backendIsVulkan, testInfo);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I don't understand gParameterizedTests
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gParameterizedTests has been deprecated and is now removed.
961b6d1
to
86dfd10
Compare
public: \ | ||
void HVTTest##TestName( \ | ||
[[maybe_unused]] const std::string& computedImageName, \ | ||
[[maybe_unused]] const std::string& imageFile); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] We missed perhaps something to limit changes and/or build issues. The parameter names are those used everywhere by default, but in some case some utests customize their content for specific needs. If you rename computedImageName
-> defaultComputedImageName
& imageFile
-> defaultImageFile
it could perhaps ease the refactoring work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we can do it in a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direction is the right one but I understand that it could take some time to finalize HVT
& the other dependent repos & I don't want to block you so I approve the pull request to unlock it. But it must still have an explicit @sebastienberube-adsk approval before merging.
93fad29
to
0f86209
Compare
The Vulkan tests are currently disabled. This PR introduces the HVT_TEST macro that will allow to parameterize which backends (OpenGL, Vulkan, etc...) are to be tested in a future PR.
Currently only OpenGL is tested.