[Bf-blender-cvs] [f53bd31690a] master: Cleanup GPU/Draw test cases.

Jeroen Bakker noreply at git.blender.org
Mon Jun 28 08:55:20 CEST 2021


Commit: f53bd31690ad9e1ba91f0a23d8a3cdd6519c9cf7
Author: Jeroen Bakker
Date:   Mon Jun 28 08:28:56 2021 +0200
Branches: master
https://developer.blender.org/rBf53bd31690ad9e1ba91f0a23d8a3cdd6519c9cf7

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.

===================================================================

M	source/blender/draw/tests/draw_testing.cc
M	source/blender/draw/tests/draw_testing.hh
M	source/blender/draw/tests/shaders_test.cc
M	source/blender/gpu/tests/gpu_index_buffer_test.cc
M	source/blender/gpu/tests/gpu_shader_test.cc
M	source/blender/gpu/tests/gpu_testing.hh

===================================================================

diff --git a/source/blender/draw/tests/draw_testing.cc b/source/blender/draw/tests/draw_testing.cc
index 0104437e921..45a857e7577 100644
--- a/source/blender/draw/tests/draw_testing.cc
+++ b/source/blender/draw/tests/draw_testing.cc
@@ -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);
 }
 
diff --git a/source/blender/draw/tests/draw_testing.hh b/source/blender/draw/tests/draw_testing.hh
index ec0b15b611e..00f0ac5bab7 100644
--- a/source/blender/draw/tests/draw_testing.hh
+++ b/source/blender/draw/tests/draw_testing.hh
@@ -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
diff --git a/source/blender/draw/tests/shaders_test.cc b/source/blender/draw/tests/shaders_test.cc
index cce69714f5e..0c7cbd4dac8 100644
--- a/source/blender/draw/tests/shaders_test.cc
+++ b/source/blender/draw/tests/shaders_test.cc
@@ -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
diff --git a/source/blender/gpu/tests/gpu_index_buffer_test.cc b/source/blender/gpu/tests/gpu_index_buffer_test.cc
index 78e351af7f1..9d767b58a7b 100644
--- a/source/blender/gpu/tests/gpu_index_buffer_test.cc
+++ b/source/blender/gpu/tests/gpu_index_buffer_test.cc
@@ -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
diff --git a/source/blender/gpu/tests/gpu_shader_test.cc b/source/blender/gpu/tests/gpu_shader_test.cc
index e8645b89e41..43ff86ebbd8 100644
--- a/source/blender/gpu/tests/gpu_shader_test.cc
+++ b/source/blender/gpu/tests/gpu_shader_test.cc
@@ -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
diff --git a/source/blender/gpu/tests/gpu_testing.hh b/source/blender/gpu/tests/gpu_testing.hh
index cf902a91264..c45770cb94e 100644
--- a/source/blender/gpu/tests/gpu_testing.hh
+++ b/source/blender/gpu/tests/gpu_testing.hh
@@ -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



More information about the Bf-blender-cvs mailing list