A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.
This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.
Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.
Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:
https://reuse.software/faq/
86 lines
1.9 KiB
C++
86 lines
1.9 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "testing/testing.h"
|
|
|
|
#include "GHOST_C-api.h"
|
|
#include "GPU_platform.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_TDrawingContextType draw_context_type = GHOST_kDrawingContextTypeNone;
|
|
eGPUBackendType gpu_backend_type;
|
|
GHOST_SystemHandle ghost_system;
|
|
GHOST_ContextHandle ghost_context;
|
|
struct GPUContext *context;
|
|
|
|
int32_t prev_g_debug_;
|
|
|
|
protected:
|
|
GPUTest(GHOST_TDrawingContextType draw_context_type, eGPUBackendType gpu_backend_type)
|
|
: draw_context_type(draw_context_type), gpu_backend_type(gpu_backend_type)
|
|
{
|
|
}
|
|
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
};
|
|
|
|
class GPUOpenGLTest : public GPUTest {
|
|
public:
|
|
GPUOpenGLTest() : GPUTest(GHOST_kDrawingContextTypeOpenGL, GPU_BACKEND_OPENGL) {}
|
|
};
|
|
|
|
#define GPU_OPENGL_TEST(test_name) \
|
|
TEST_F(GPUOpenGLTest, test_name) \
|
|
{ \
|
|
test_##test_name(); \
|
|
}
|
|
|
|
#ifdef WITH_METAL_BACKEND
|
|
class GPUMetalTest : public GPUTest {
|
|
public:
|
|
GPUMetalTest() : GPUTest(GHOST_kDrawingContextTypeMetal, GPU_BACKEND_METAL) {}
|
|
};
|
|
# define GPU_METAL_TEST(test_name) \
|
|
TEST_F(GPUMetalTest, 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) {}
|
|
};
|
|
# define GPU_VULKAN_TEST(test_name) \
|
|
TEST_F(GPUVulkanTest, 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
|