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.
This commit is contained in:
parent
0d68f55789
commit
ab6f59ff3b
|
@ -437,9 +437,9 @@ if(WITH_GTESTS)
|
|||
)
|
||||
set(TEST_INC
|
||||
"../../../intern/ghost/"
|
||||
"../gpu/tests/"
|
||||
)
|
||||
set(TEST_LIB
|
||||
bf_draw
|
||||
)
|
||||
include(GTestTesting)
|
||||
blender_add_test_lib(bf_draw_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
|
||||
|
|
|
@ -7,41 +7,22 @@
|
|||
#include "GPU_context.h"
|
||||
#include "GPU_init_exit.h"
|
||||
#include "GPU_shader.h"
|
||||
|
||||
#include "GHOST_C-api.h"
|
||||
#include "gpu_testing.hh"
|
||||
|
||||
#include "engines/eevee/eevee_private.h"
|
||||
#include "engines/gpencil/gpencil_engine.h"
|
||||
#include "engines/overlay/overlay_private.h"
|
||||
#include "engines/workbench/workbench_private.h"
|
||||
|
||||
namespace blender::draw::tests {
|
||||
namespace blender::draw {
|
||||
|
||||
/* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
|
||||
class DrawTest : public ::testing::Test {
|
||||
private:
|
||||
GHOST_SystemHandle ghost_system;
|
||||
GHOST_ContextHandle ghost_context;
|
||||
GPUContext *context;
|
||||
|
||||
class DrawTest : public blender::gpu::GPUTest {
|
||||
void SetUp() override
|
||||
{
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
ghost_system = GHOST_CreateSystem();
|
||||
ghost_context = GHOST_CreateOpenGLContext(ghost_system, glSettings);
|
||||
context = GPU_context_create(NULL);
|
||||
GPU_init();
|
||||
GPUTest::SetUp();
|
||||
DRW_draw_state_init_gtests(GPU_SHADER_CFG_DEFAULT);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
GPU_exit();
|
||||
GPU_backend_exit();
|
||||
GPU_context_discard(context);
|
||||
GHOST_DisposeOpenGLContext(ghost_system, ghost_context);
|
||||
GHOST_DisposeSystem(ghost_system);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DrawTest, workbench_glsl_shaders)
|
||||
|
@ -324,4 +305,4 @@ TEST_F(DrawTest, eevee_glsl_shaders_static)
|
|||
EEVEE_shaders_free();
|
||||
}
|
||||
|
||||
} // namespace blender::draw::tests
|
||||
} // namespace blender::draw
|
|
@ -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()
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue