Fix: Compositor file output tests not using Vulkan

The issue was the `--gpu-backend` argument was passed to the python
script and not to Blender. This is because `blender_test` calls blender
first and then runs the test script inside it, whereas a `python_test`
calls blender with the provided python arguments.

The command `gpu.platform.backend_type_get()` was used to verify the
correct gpu backend was used.

Pull Request: https://projects.blender.org/blender/blender/pulls/151478
This commit is contained in:
Habib Gahbiche 2025-12-11 15:40:50 +01:00
parent 1e1c1b5b95
commit fa7291e22e
2 changed files with 9 additions and 5 deletions

View file

@ -1008,6 +1008,7 @@ if(TEST_SRC_DIR_EXISTS)
--
--testdir "${TEST_SRC_DIR}/compositor/file_output/"
--outdir "${TEST_OUT_DIR}/compositor_cpu/file_output"
--device "CPU"
)
endif()
@ -1042,11 +1043,12 @@ if(WITH_GPU_COMPOSITOR_TESTS AND TEST_SRC_DIR_EXISTS)
endforeach()
add_blender_test(
compositor_opengl_file_output
--gpu-backend opengl
--python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
--
--testdir "${TEST_SRC_DIR}/compositor/file_output/"
--outdir "${TEST_OUT_DIR}/compositor_opengl/file_output"
--gpu-backend opengl
--device "GPU"
)
endif()
if(WITH_METAL_BACKEND)
@ -1061,11 +1063,12 @@ if(WITH_GPU_COMPOSITOR_TESTS AND TEST_SRC_DIR_EXISTS)
endforeach()
add_blender_test(
compositor_metal_file_output
--gpu-backend metal
--python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
--
--testdir "${TEST_SRC_DIR}/compositor/file_output/"
--outdir "${TEST_OUT_DIR}/compositor_metal/file_output"
--gpu-backend metal
--device "GPU"
)
endif()
if(WITH_VULKAN_BACKEND)
@ -1080,11 +1083,12 @@ if(WITH_GPU_COMPOSITOR_TESTS AND TEST_SRC_DIR_EXISTS)
endforeach()
add_blender_test(
compositor_vulkan_file_output
--gpu-backend vulkan
--python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
--
--testdir "${TEST_SRC_DIR}/compositor/file_output/"
--outdir "${TEST_OUT_DIR}/compositor_vulkan/file_output"
--gpu-backend vulkan
--device "GPU"
)
endif()
endif()

View file

@ -32,7 +32,7 @@ class FileOutputTest(unittest.TestCase):
def setUpClass(cls):
cls.testdir = pathlib.Path(args.testdir)
cls.outdir = pathlib.Path(args.outdir)
cls.execution_device = "GPU" if args.gpu_backend else "CPU"
cls.execution_device = args.device
cls.update = os.getenv("BLENDER_TEST_UPDATE") is not None
# Images that look similar enough should pass the test
@ -244,7 +244,7 @@ if __name__ == "__main__":
)
parser.add_argument("--testdir", required=True)
parser.add_argument("--outdir", required=True)
parser.add_argument("--gpu-backend", required=False)
parser.add_argument("--device", required=True)
args, remaining = parser.parse_known_args(argv)
unittest.main(argv=remaining)