Files
test/source/blender/gpu/tests/gpu_testing.hh
Jeroen Bakker efc1094d6a Metal: Enable Shader Validation on Buildbot
This PR enables shader validation testing on buildbot for Metal.

OpenGL isn't enabled as OpenGL requires an actual driver and GPU
attached to the build bot infrastructure. Also the OpenGL backend
caches data (glsl_patch) globally and requires a restart in order to
create the correct one.

Vulkan isn't enabled as it requires some changes:
* For windows it requires to install more recent vulkan software versions as
  part of the buildbot windows configuration
* For Linux it requires to start a GHOST System without any X11/Wayland
  This currently fails on the buildbot. We should check if we can use
  `GHOST_SystemHeadless` with `GHOST_ContextVK`

Each shaders are compiled twice. Once based on the
actual features of the installed GPU/backend. And once with all
the work-arounds enabled, simulating a platform close to the
minimum requirements of Blender.

Pull Request: https://projects.blender.org/blender/blender/pulls/116040
2023-12-12 10:14:13 +01:00

131 lines
2.9 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: Apache-2.0 */
#include "testing/testing.h"
#include "BKE_global.h"
#include "GHOST_C-api.h"
#include "GPU_platform.h"
struct GPUContext;
namespace blender::gpu {
/**
* Test class that setups a GPUContext for test cases.
*/
class GPUTest : public ::testing::Test {
private:
GHOST_TDrawingContextType draw_context_type = GHOST_kDrawingContextTypeNone;
eGPUBackendType gpu_backend_type;
GHOST_SystemHandle ghost_system;
GHOST_ContextHandle ghost_context;
GPUContext *context;
int32_t g_debug_flags_;
int32_t prev_g_debug_;
protected:
GPUTest(GHOST_TDrawingContextType draw_context_type,
eGPUBackendType gpu_backend_type,
int32_t g_debug_flags)
: draw_context_type(draw_context_type),
gpu_backend_type(gpu_backend_type),
g_debug_flags_(g_debug_flags)
{
}
void SetUp() override;
void TearDown() override;
};
#ifdef WITH_OPENGL_BACKEND
class GPUOpenGLTest : public GPUTest {
public:
GPUOpenGLTest()
: GPUTest(GHOST_kDrawingContextTypeOpenGL,
GPU_BACKEND_OPENGL,
G_DEBUG_GPU | G_DEBUG_GPU_RENDERDOC)
{
}
};
# define GPU_OPENGL_TEST(test_name) \
TEST_F(GPUOpenGLTest, test_name) \
{ \
test_##test_name(); \
}
#else
# define GPU_OPENGL_TEST(test_name)
#endif
#ifdef WITH_METAL_BACKEND
class GPUMetalTest : public GPUTest {
public:
GPUMetalTest() : GPUTest(GHOST_kDrawingContextTypeMetal, GPU_BACKEND_METAL, G_DEBUG_GPU) {}
};
class GPUMetalWorkaroundsTest : public GPUTest {
public:
GPUMetalWorkaroundsTest()
: GPUTest(GHOST_kDrawingContextTypeMetal,
GPU_BACKEND_METAL,
G_DEBUG_GPU | G_DEBUG_GPU_FORCE_WORKAROUNDS)
{
}
};
# define GPU_METAL_TEST(test_name) \
TEST_F(GPUMetalTest, test_name) \
{ \
test_##test_name(); \
} \
TEST_F(GPUMetalWorkaroundsTest, test_name) \
{ \
test_##test_name(); \
}
#else
# define GPU_METAL_TEST(test_name)
#endif
#ifdef WITH_VULKAN_BACKEND
class GPUVulkanTest : public GPUTest {
public:
GPUVulkanTest()
: GPUTest(GHOST_kDrawingContextTypeVulkan,
GPU_BACKEND_VULKAN,
G_DEBUG_GPU | G_DEBUG_GPU_RENDERDOC)
{
}
};
class GPUVulkanWorkaroundsTest : public GPUTest {
public:
GPUVulkanWorkaroundsTest()
: GPUTest(GHOST_kDrawingContextTypeVulkan,
GPU_BACKEND_VULKAN,
G_DEBUG_GPU | G_DEBUG_GPU_RENDERDOC | G_DEBUG_GPU_FORCE_WORKAROUNDS)
{
}
};
# define GPU_VULKAN_TEST(test_name) \
TEST_F(GPUVulkanTest, test_name) \
{ \
test_##test_name(); \
} \
TEST_F(GPUVulkanWorkaroundsTest, test_name) \
{ \
test_##test_name(); \
}
#else
# define GPU_VULKAN_TEST(test_name)
#endif
#define GPU_TEST(test_name) \
GPU_OPENGL_TEST(test_name) \
GPU_METAL_TEST(test_name) \
GPU_VULKAN_TEST(test_name)
} // namespace blender::gpu