- Implemented ComputeSchedulerTest to validate device management, task scheduling, and resource cleanup for the compute scheduler. - Created mock_window class for testing Vulkan surface creation, supporting both headless and windowed modes. - Added shader_loader utility for loading SPIR-V shaders from files and providing minimal embedded shaders for testing. - Introduced test_helpers for creating and destroying shader modules, validating device features, and finding memory types. - Established VulkanTestBase and VulkanGPUTest classes to streamline Vulkan test setup and teardown processes.
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <gtest/gtest.h>
|
|
#include "vulkan/vulkan_common.h"
|
|
#include "vulkan/context.h"
|
|
#include "vulkan/device_manager.h"
|
|
#include "vulkan/logical_device.h"
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace mirage::render::vulkan::test {
|
|
|
|
/**
|
|
* @brief Base test fixture for Vulkan tests that don't require GPU.
|
|
* Provides basic environment detection utilities.
|
|
*/
|
|
class VulkanTestBase : public ::testing::Test {
|
|
protected:
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
|
|
/**
|
|
* @brief Checks if a GPU is available on the system.
|
|
* Used to skip tests in CI environments without GPU.
|
|
*/
|
|
static bool HasGPU();
|
|
|
|
/**
|
|
* @brief Checks if running in a CI environment.
|
|
*/
|
|
static bool IsCI();
|
|
|
|
/**
|
|
* @brief Gets a human-readable name for the current test.
|
|
*/
|
|
std::string GetTestName() const;
|
|
};
|
|
|
|
/**
|
|
* @brief Test fixture for tests that require GPU access.
|
|
* Automatically creates Vulkan context and device.
|
|
*/
|
|
class VulkanGPUTest : public VulkanTestBase {
|
|
protected:
|
|
void SetUp() override;
|
|
void TearDown() override;
|
|
|
|
// Vulkan components (created in SetUp)
|
|
std::unique_ptr<render_context> context_;
|
|
std::unique_ptr<device_manager> device_mgr_;
|
|
std::unique_ptr<logical_device> device_;
|
|
vk::PhysicalDevice physical_device_;
|
|
};
|
|
|
|
} // namespace mirage::render::vulkan::test
|