Cleanup GPU/Draw test cases.
In preparation of supporting vulkan. Draw/GPU tests should use GPU_TEST or DRAW_TEST macros. These macros will run the test on available drawing context backends like OpenGL or Vulkan. As in master there is only an OpenGL backend nothing changed.
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
namespace blender::draw {
|
||||
|
||||
/* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
|
||||
void DrawTest::SetUp()
|
||||
void DrawOpenGLTest::SetUp()
|
||||
{
|
||||
GPUTest::SetUp();
|
||||
GPUOpenGLTest::SetUp();
|
||||
DRW_draw_state_init_gtests(GPU_SHADER_CFG_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,15 @@
|
||||
namespace blender::draw {
|
||||
|
||||
/* Base class for draw test cases. It will setup and tear down the GPU part around each test. */
|
||||
class DrawTest : public blender::gpu::GPUTest {
|
||||
class DrawOpenGLTest : public blender::gpu::GPUOpenGLTest {
|
||||
public:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
#define DRAW_TEST(test_name) \
|
||||
TEST_F(DrawOpenGLTest, test_name) \
|
||||
{ \
|
||||
test_##test_name(); \
|
||||
}
|
||||
|
||||
} // namespace blender::draw
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace blender::draw {
|
||||
|
||||
TEST_F(DrawTest, workbench_glsl_shaders)
|
||||
static void test_workbench_glsl_shaders()
|
||||
{
|
||||
workbench_shader_library_ensure();
|
||||
|
||||
@@ -155,8 +155,9 @@ TEST_F(DrawTest, workbench_glsl_shaders)
|
||||
|
||||
workbench_shader_free();
|
||||
}
|
||||
DRAW_TEST(workbench_glsl_shaders)
|
||||
|
||||
TEST_F(DrawTest, gpencil_glsl_shaders)
|
||||
static void test_gpencil_glsl_shaders()
|
||||
{
|
||||
EXPECT_NE(GPENCIL_shader_antialiasing(0), nullptr);
|
||||
EXPECT_NE(GPENCIL_shader_antialiasing(1), nullptr);
|
||||
@@ -177,8 +178,9 @@ TEST_F(DrawTest, gpencil_glsl_shaders)
|
||||
|
||||
GPENCIL_shader_free();
|
||||
}
|
||||
DRAW_TEST(gpencil_glsl_shaders)
|
||||
|
||||
TEST_F(DrawTest, image_glsl_shaders)
|
||||
static void test_image_glsl_shaders()
|
||||
{
|
||||
IMAGE_shader_library_ensure();
|
||||
|
||||
@@ -187,8 +189,9 @@ TEST_F(DrawTest, image_glsl_shaders)
|
||||
|
||||
IMAGE_shader_free();
|
||||
}
|
||||
DRAW_TEST(image_glsl_shaders)
|
||||
|
||||
TEST_F(DrawTest, overlay_glsl_shaders)
|
||||
static void test_overlay_glsl_shaders()
|
||||
{
|
||||
OVERLAY_shader_library_ensure();
|
||||
|
||||
@@ -280,8 +283,9 @@ TEST_F(DrawTest, overlay_glsl_shaders)
|
||||
|
||||
OVERLAY_shader_free();
|
||||
}
|
||||
DRAW_TEST(overlay_glsl_shaders)
|
||||
|
||||
TEST_F(DrawTest, eevee_glsl_shaders_static)
|
||||
static void test_eevee_glsl_shaders_static()
|
||||
{
|
||||
EEVEE_shaders_material_shaders_init();
|
||||
|
||||
@@ -370,6 +374,7 @@ TEST_F(DrawTest, eevee_glsl_shaders_static)
|
||||
EXPECT_NE(EEVEE_shaders_effect_reflection_resolve_sh_get(), nullptr);
|
||||
EEVEE_shaders_free();
|
||||
}
|
||||
DRAW_TEST(eevee_glsl_shaders_static)
|
||||
|
||||
static void test_draw_shaders(eParticleRefineShaderType sh_type)
|
||||
{
|
||||
@@ -378,7 +383,7 @@ static void test_draw_shaders(eParticleRefineShaderType sh_type)
|
||||
DRW_shaders_free();
|
||||
}
|
||||
|
||||
TEST_F(DrawTest, draw_glsl_shaders)
|
||||
static void test_draw_glsl_shaders()
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
test_draw_shaders(PART_REFINE_SHADER_TRANSFORM_FEEDBACK);
|
||||
@@ -386,5 +391,6 @@ TEST_F(DrawTest, draw_glsl_shaders)
|
||||
#endif
|
||||
test_draw_shaders(PART_REFINE_SHADER_TRANSFORM_FEEDBACK_WORKAROUND);
|
||||
}
|
||||
DRAW_TEST(draw_glsl_shaders)
|
||||
|
||||
} // namespace blender::draw
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace blender::gpu::tests {
|
||||
|
||||
TEST_F(GPUTest, gpu_index_buffer_subbuilders)
|
||||
static void test_gpu_index_buffer_subbuilders()
|
||||
{
|
||||
const uint num_subbuilders = 10;
|
||||
const uint verts_per_subbuilders = 100;
|
||||
@@ -44,4 +44,6 @@ TEST_F(GPUTest, gpu_index_buffer_subbuilders)
|
||||
GPU_INDEXBUF_DISCARD_SAFE(index_buffer);
|
||||
}
|
||||
|
||||
GPU_TEST(gpu_index_buffer_subbuilders)
|
||||
|
||||
} // namespace blender::gpu::tests
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
namespace blender::gpu::tests {
|
||||
|
||||
TEST_F(GPUTest, gpu_shader_compute_2d)
|
||||
static void test_gpu_shader_compute_2d()
|
||||
{
|
||||
|
||||
if (!GPU_compute_shader_support()) {
|
||||
@@ -75,8 +75,9 @@ void main() {
|
||||
GPU_texture_free(texture);
|
||||
GPU_shader_free(shader);
|
||||
}
|
||||
GPU_TEST(gpu_shader_compute_2d)
|
||||
|
||||
TEST_F(GPUTest, gpu_shader_compute_1d)
|
||||
static void test_gpu_shader_compute_1d()
|
||||
{
|
||||
|
||||
if (!GPU_compute_shader_support()) {
|
||||
@@ -137,8 +138,9 @@ void main() {
|
||||
GPU_texture_free(texture);
|
||||
GPU_shader_free(shader);
|
||||
}
|
||||
GPU_TEST(gpu_shader_compute_1d)
|
||||
|
||||
TEST_F(GPUTest, gpu_shader_compute_vbo)
|
||||
static void test_gpu_shader_compute_vbo()
|
||||
{
|
||||
|
||||
if (!GPU_compute_shader_support()) {
|
||||
@@ -201,8 +203,9 @@ void main() {
|
||||
GPU_vertbuf_discard(vbo);
|
||||
GPU_shader_free(shader);
|
||||
}
|
||||
GPU_TEST(gpu_shader_compute_vbo)
|
||||
|
||||
TEST_F(GPUTest, gpu_shader_compute_ibo)
|
||||
static void test_gpu_shader_compute_ibo()
|
||||
{
|
||||
|
||||
if (!GPU_compute_shader_support()) {
|
||||
@@ -258,8 +261,9 @@ void main() {
|
||||
GPU_indexbuf_discard(ibo);
|
||||
GPU_shader_free(shader);
|
||||
}
|
||||
GPU_TEST(gpu_shader_compute_ibo)
|
||||
|
||||
TEST_F(GPUTest, gpu_shader_ssbo_binding)
|
||||
static void test_gpu_shader_ssbo_binding()
|
||||
{
|
||||
if (!GPU_compute_shader_support()) {
|
||||
/* We can't test as a the platform does not support compute shaders. */
|
||||
@@ -297,5 +301,6 @@ void main() {
|
||||
GPU_shader_unbind();
|
||||
GPU_shader_free(shader);
|
||||
}
|
||||
GPU_TEST(gpu_shader_ssbo_binding)
|
||||
|
||||
} // namespace blender::gpu::tests
|
||||
|
||||
@@ -15,13 +15,31 @@ namespace blender::gpu {
|
||||
*/
|
||||
class GPUTest : public ::testing::Test {
|
||||
private:
|
||||
GHOST_TDrawingContextType draw_context_type = GHOST_kDrawingContextTypeNone;
|
||||
GHOST_SystemHandle ghost_system;
|
||||
GHOST_ContextHandle ghost_context;
|
||||
struct GPUContext *context;
|
||||
|
||||
protected:
|
||||
GPUTest(GHOST_TDrawingContextType draw_context_type) : draw_context_type(draw_context_type)
|
||||
{
|
||||
}
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
class GPUOpenGLTest : public GPUTest {
|
||||
public:
|
||||
GPUOpenGLTest() : GPUTest(GHOST_kDrawingContextTypeOpenGL)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#define GPU_TEST(test_name) \
|
||||
TEST_F(GPUOpenGLTest, test_name) \
|
||||
{ \
|
||||
test_##test_name(); \
|
||||
}
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
||||
Reference in New Issue
Block a user