This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/gpu/tests/gpu_testing.hh
Jeroen Bakker fda65ad5ca GPU: Renderdoc Frame Capturing
This PR uses renderdoc for frame capturing when enabled.
It enabled an easier workflow for frame capturing.

- Capture GPU API calls from test cases
- Capture GPU API calls from background threads
- Capture GPU API calls from background rendering.

Renderdoc is an important GPU debugger used by the Eevee/
Viewport module. Previously we needed to change code in
order to record background rendering, that could on its own
lead to other side-effects.

The integration with renderdoc can be enabled using
`WITH_RENDERDOC=On` compiler option. `GPU_debug_capture_begin`
and `GPU_debug_capture_end` can be added to the section
of the code you want to debug. When running Blender inside
renderdoc this part will automatically be captured.

All GPU test cases are now guarded by these calls. In order
to capture the test cases you need to start the test cases
from renderdoc and the captured GPU API calls will appear
where each capture is a single test case.

Pull Request: blender/blender#105921
2023-03-23 16:37:52 +01:00

90 lines
1.9 KiB
C++

/* 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