Skip to content
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

Autodesk: usdImagingGL: support for Hgi specific variants of tests #3479

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions pxr/imaging/hgi/hgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ _MakeNewPlatformDefaultHgi()
#elif defined(ARCH_OS_WINDOWS)
"HgiGL";
#else
"";
#error Unknown Platform
return nullptr;
#error Unsupported Platform
#endif

if (TfGetEnvSetting(HGI_ENABLE_VULKAN)) {
#if defined(PXR_VULKAN_SUPPORT_ENABLED)
hgiType = "HgiVulkan";
#else
TF_CODING_ERROR(
"Build requires PXR_VULKAN_SUPPORT_ENABLED=true to use Vulkan");
"Build requires PXR_VULKAN_SUPPORT_ENABLED=1 to use Vulkan");
#endif
}

Expand Down
172 changes: 147 additions & 25 deletions pxr/usdImaging/usdImagingGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,132 @@ pxr_install_test_dir(
# Register tests that don't depend on build configuration or external libraries
# (such as MaterialX, OpenVDB, PTEX).
#
pxr_register_test(testUsdImagingGLBasicDrawing
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -stage basicDrawing/basicDrawing.usda -write testUsdImagingGLBasicDrawing.png"
IMAGE_DIFF_COMPARE
testUsdImagingGLBasicDrawing.png

# Given the list of arguments for pxr_register_test(), register a test specific
# to the given Hgi when called with VARIANT_TEST. If VARIANT_BASELINE is also
# used, then the test also uses an Hgi specific baseline. If neither are used,
# this is just a pass-through to pxr_register_test(). Tests and baselines are
# made specific by adding a "_<hgiName>" part in the name. For test names it's
# a always suffix, for baselines (and result files), use the "@hgi_suffix@"
# placeholder to indicate where to insert the Hgi name part. Pass-through tests
# will not suffix tests, and will entirely remove "@hgi_suffix@".
# The test's "ENV" is automatically appended with the correct "HGI_ENABLE_*"
# flags for the given Hgi.
function(register_test_hgi_variant test_name hgi_name)
cmake_parse_arguments(arg
"VARIANT_TEST;VARIANT_BASELINE"
"COMMAND"
"IMAGE_DIFF_COMPARE;ENV"
${ARGN}
)

if(arg_VARIANT_TEST)
set(hgi_suffix "_${hgi_name}")
if(hgi_name STREQUAL GL)
set(hgi_env "HGI_ENABLE_VULKAN=0;")
elseif(hgi_name STREQUAL Metal)
set(hgi_env "HGI_ENABLE_VULKAN=0;")
elseif(hgi_name STREQUAL Vulkan)
set(hgi_env "HGI_ENABLE_VULKAN=1;")
else()
message(FATAL_ERROR "Unknown Hgi: ${hgi_name}")
endif()
else()
set(hgi_suffix "")
set(hgi_env "")
endif()

if(arg_VARIANT_BASELINE)
set(baseline_suffix "_${hgi_name}")
else()
set(baseline_suffix "")
endif()

string(REPLACE "@hgi_suffix@" "${baseline_suffix}"
arg_COMMAND "${arg_COMMAND}")
list(TRANSFORM arg_IMAGE_DIFF_COMPARE REPLACE
"@hgi_suffix@" "${baseline_suffix}")
list(APPEND arg_ENV ${hgi_env})

pxr_register_test("${test_name}${hgi_suffix}"
COMMAND ${arg_COMMAND}
IMAGE_DIFF_COMPARE ${arg_IMAGE_DIFF_COMPARE}
${arg_UNPARSED_ARGUMENTS}
ENV ${arg_ENV}
)
endfunction()

# Like pxr_register_test(), but with an extra HGI_VARIANT argument. It takes a
# list of Hgi names (without the "Hgi" prefix, ex:. "Metal", "GL", "Vulkan"),
# and registers one test per supported Hgi, each with an Hgi specific baseline.
# For example "testUsdImagingGLExample" with "HGI_VARIANT Vulkan", when built
# with support for Vulkan and OpenGL, will register:
# "testUsdImagingGLExample_Vulkan" and "testUsdImagingGLExample_GL", each with
# a different baseline. To match a baseline with an Hgi, use the "@hgi_suffix@"
# placeholder in the baseline and result file name:
# "testUsdImagingGLExample@[email protected]". It will be automatically replaced:
# "testUsdImagingGLExample_Vulkan.png". Since "GL" is not listed as a variant,
# it will use the generic baseline: "testUsdImagingGLExample.png". If none of
# the listed Hgis in "HGI_VARIANT" are supported, this behaves just
# like pxr_register_test().
function(register_test_with_hgi_variants test_name)
cmake_parse_arguments(arg "" "" "HGI_VARIANT" ${ARGN})
set(test_args ${arg_UNPARSED_ARGUMENTS})

if(NOT arg_HGI_VARIANT)
message(WARNING "No arguments given for HGI_VARIANT, use pxr_register_test() instead")
endif()

# Unsupported Hgis are ignored.
set(supported_hgis)
if(PXR_ENABLE_GL_SUPPORT AND NOT APPLE)
list(APPEND supported_hgis GL)
endif()
if(PXR_ENABLE_METAL_SUPPORT)
list(APPEND supported_hgis Metal)
endif()
if(PXR_ENABLE_VULKAN_SUPPORT)
list(APPEND supported_hgis Vulkan)
endif()

# For all listed Hgi variants supported, register a suffixed test with a
# suffixed baseline.
foreach(hgi ${arg_HGI_VARIANT})
if(hgi IN_LIST supported_hgis)
register_test_hgi_variant(${test_name} ${hgi} ${test_args}
VARIANT_TEST VARIANT_BASELINE)
set(has_hgi_variant TRUE)
endif()
endforeach()

if(has_hgi_variant)
# Other supported Hgis are also register with a suffix, but use a
# non-suffixed baseline.
list(REMOVE_ITEM supported_hgis ${arg_HGI_VARIANT})
foreach(hgi ${supported_hgis})
register_test_hgi_variant(${test_name} ${hgi} ${test_args}
VARIANT_TEST)
endforeach()
else()
# If none of the Hgi variants are supported, then register a single
# test like normal.
register_test_hgi_variant(${test_name} "" ${test_args})
endif()
endfunction()

register_test_with_hgi_variants(testUsdImagingGLBasicDrawing
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -stage basicDrawing/basicDrawing.usda -write testUsdImagingGLBasicDrawing@[email protected]"
IMAGE_DIFF_COMPARE
testUsdImagingGLBasicDrawing@[email protected]
FAIL 0.2
FAIL_PERCENT 0.5
PERCEPTUAL
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLBasicDrawing
ENV
HGIGL_ENABLE_BINDLESS_TEXTURE=1
HGI_VARIANT
Metal
)

pxr_register_test(testUsdImagingGLBasicDrawing_refined
Expand Down Expand Up @@ -800,15 +916,17 @@ pxr_register_test(testUsdImagingGLBasicDrawingNonBindless_batch
HGIGL_ENABLE_BINDLESS_TEXTURE=0
)

pxr_register_test(testUsdImagingGLBasicLighting
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -lighting -stage basicDrawing.usda -write testUsdImagingGLBasicLighting.png"
register_test_with_hgi_variants(testUsdImagingGLBasicLighting
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -lighting -stage basicDrawing.usda -write testUsdImagingGLBasicLighting@hgi_suffix@.png"
IMAGE_DIFF_COMPARE
testUsdImagingGLBasicLighting.png
testUsdImagingGLBasicLighting@hgi_suffix@.png
FAIL 0.5
FAIL_PERCENT 0.1
PERCEPTUAL
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLBasicLighting
HGI_VARIANT
Metal
)

pxr_register_test(testUsdImagingGLBasicLighting_refined
Expand Down Expand Up @@ -1205,7 +1323,7 @@ pxr_register_test(testUsdImagingGLBasisCurvesWithScale
IMAGE_DIFF_COMPARE
testUsdImagingGLBasisCurvesWithScale_1.1.png
FAIL .05
FAIL_PERCENT .03
FAIL_PERCENT .25
PERCEPTUAL
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLBasisCurvesWithScale
Expand Down Expand Up @@ -1385,17 +1503,19 @@ pxr_register_test(testUsdImagingGLSphereWithFloatRadius
TESTENV testUsdImagingGLSphere
)

pxr_register_test(testUsdImagingGLNurbsCurves
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -frameAll -offscreen -times 0 50 150 -stage testCurves.usda -write testUsdImagingGLNurbsCurves.png"
register_test_with_hgi_variants(testUsdImagingGLNurbsCurves
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -frameAll -offscreen -times 0 50 150 -stage testCurves.usda -write testUsdImagingGLNurbsCurves@hgi_suffix@.png"
IMAGE_DIFF_COMPARE
testUsdImagingGLNurbsCurves_000.png
testUsdImagingGLNurbsCurves_050.png
testUsdImagingGLNurbsCurves_150.png
testUsdImagingGLNurbsCurves@hgi_suffix@_000.png
testUsdImagingGLNurbsCurves@hgi_suffix@_050.png
testUsdImagingGLNurbsCurves@hgi_suffix@_150.png
FAIL .05
FAIL_PERCENT .03
PERCEPTUAL
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLNurbsCurves
HGI_VARIANT
Metal
)

pxr_register_test(testUsdImagingGLNurbsCurves_refined
Expand Down Expand Up @@ -3991,17 +4111,19 @@ pxr_register_test(testUsdImagingGLVolumeMaterial
TESTENV testUsdImagingGLVolumeMaterial
)

pxr_register_test(testUsdImagingGLBasisCurvesVaryingTopology
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -frameAll -offscreen -lighting -times 1 3 4 5 4 -stage bunnyCurves.usda -write testUsdImagingGLBasisCurvesVaryingTopology.png"
register_test_with_hgi_variants(testUsdImagingGLBasisCurvesVaryingTopology
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -frameAll -offscreen -lighting -times 1 3 4 5 4 -stage bunnyCurves.usda -write testUsdImagingGLBasisCurvesVaryingTopology@hgi_suffix@.png"
IMAGE_DIFF_COMPARE
testUsdImagingGLBasisCurvesVaryingTopology_003.png
testUsdImagingGLBasisCurvesVaryingTopology_004.png
testUsdImagingGLBasisCurvesVaryingTopology_005.png
testUsdImagingGLBasisCurvesVaryingTopology@hgi_suffix@_003.png
testUsdImagingGLBasisCurvesVaryingTopology@hgi_suffix@_004.png
testUsdImagingGLBasisCurvesVaryingTopology@hgi_suffix@_005.png
FAIL .05
FAIL_PERCENT .03
PERCEPTUAL
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLBasisCurvesVaryingTopology
HGI_VARIANT
Metal
)

# Disable this test temporarily due to issue where test runs forever
Expand Down Expand Up @@ -4951,7 +5073,7 @@ if (MaterialX_FOUND AND ${PXR_ENABLE_MATERIALX_SUPPORT})
IMAGE_DIFF_COMPARE
mxTexcoord.png
FAIL 0.1
FAIL_PERCENT 0.005
FAIL_PERCENT 0.01
WARN 0.05
WARN_PERCENT 0.02
EXPECTED_RETURN_CODE 0
Expand Down Expand Up @@ -5790,10 +5912,10 @@ if (OPENVDB_FOUND AND ${PXR_ENABLE_OPENVDB_SUPPORT})
IMAGE_DIFF_COMPARE
testUsdImagingGLVdbVolumeInside_001.png
testUsdImagingGLVdbVolumeInside_013.png
FAIL 0.005
FAIL_PERCENT 0.001
FAIL 0.01
FAIL_PERCENT 0.025
WARN 0.005
WARN_PERCENT 0.0005
WARN_PERCENT 0.0125
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLVdbVolume
ENV
Expand Down Expand Up @@ -5917,10 +6039,10 @@ if (OPENVDB_FOUND AND ${PXR_ENABLE_OPENVDB_SUPPORT})
IMAGE_DIFF_COMPARE
testUsdImagingGLVdbVolumeInside_001.png
testUsdImagingGLVdbVolumeInside_013.png
FAIL 0.005
FAIL_PERCENT 0.001
FAIL 0.01
FAIL_PERCENT 0.025
WARN 0.005
WARN_PERCENT 0.0005
WARN_PERCENT 0.0125
EXPECTED_RETURN_CODE 0
TESTENV testUsdImagingGLVdbVolume
ENV
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.