diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-09-08 12:31:47 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-09-08 14:23:10 +0300 |
commit | ab6f59ff3b8c7e821b4cb486c83ab1faada42e5e (patch) | |
tree | 28076199f2a70df56f5d458287a9f259a5803102 /source/blender/gpu | |
parent | 0d68f55789aff106bdf9e038812d358ca55c060f (diff) |
GPU: Extract GPU Base Test case
The draw manager test case initialized ghost, gpu and draw manager. This
change splits the base test case to GPU specific and draw manager
specific test case.
The GPU test base test case will be used for low level GPU tests.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 16 | ||||
-rw-r--r-- | source/blender/gpu/tests/gpu_testing.cc | 31 | ||||
-rw-r--r-- | source/blender/gpu/tests/gpu_testing.hh | 27 |
3 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 0a372125391..bb50cd3744f 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -379,3 +379,19 @@ if(WITH_IMAGE_DDS) endif() blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") + +if(WITH_GTESTS) + if(WITH_OPENGL_DRAW_TESTS) + set(TEST_SRC + tests/gpu_testing.cc + ) + set(TEST_INC + "../../../intern/ghost/" + ) + set(TEST_LIB + + ) + include(GTestTesting) + blender_add_test_lib(bf_gpu_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}") + endif() +endif() diff --git a/source/blender/gpu/tests/gpu_testing.cc b/source/blender/gpu/tests/gpu_testing.cc new file mode 100644 index 00000000000..2772139b8f6 --- /dev/null +++ b/source/blender/gpu/tests/gpu_testing.cc @@ -0,0 +1,31 @@ +/* Apache License, Version 2.0 */ + +#include "testing/testing.h" + +#include "GPU_context.h" +#include "GPU_init_exit.h" +#include "gpu_testing.hh" + +#include "GHOST_C-api.h" + +namespace blender::gpu { + +void GPUTest::SetUp() +{ + GHOST_GLSettings glSettings = {0}; + ghost_system = GHOST_CreateSystem(); + ghost_context = GHOST_CreateOpenGLContext(ghost_system, glSettings); + context = GPU_context_create(NULL); + GPU_init(); +} + +void GPUTest::TearDown() +{ + GPU_exit(); + GPU_backend_exit(); + GPU_context_discard(context); + GHOST_DisposeOpenGLContext(ghost_system, ghost_context); + GHOST_DisposeSystem(ghost_system); +} + +} // namespace blender::gpu
\ No newline at end of file diff --git a/source/blender/gpu/tests/gpu_testing.hh b/source/blender/gpu/tests/gpu_testing.hh new file mode 100644 index 00000000000..7e9203d2d7c --- /dev/null +++ b/source/blender/gpu/tests/gpu_testing.hh @@ -0,0 +1,27 @@ +#include "testing/testing.h" + +#include "GHOST_C-api.h" + +struct GPUContext; + +namespace blender::gpu { + +/* Test class that setups a GPUContext for test cases. + * + * Usage: + * TEST_F(GPUTest, my_gpu_test) { + * ... + * } + */ +class GPUTest : public ::testing::Test { + private: + GHOST_SystemHandle ghost_system; + GHOST_ContextHandle ghost_context; + struct GPUContext *context; + + protected: + void SetUp() override; + void TearDown() override; +}; + +} // namespace blender::gpu
\ No newline at end of file |