Add Vulkan coverage to generic RHI unit tests

This commit is contained in:
2026-03-27 20:21:36 +08:00
parent 5a49812ea9
commit 6aa0e73a05
10 changed files with 96 additions and 15 deletions

View File

@@ -427,8 +427,10 @@ bool VulkanDevice::CreateLogicalDevice() {
void VulkanDevice::QueryDeviceInfo() {
VkPhysicalDeviceProperties properties = {};
VkPhysicalDeviceFeatures features = {};
VkPhysicalDeviceMemoryProperties memoryProperties = {};
vkGetPhysicalDeviceProperties(m_physicalDevice, &properties);
vkGetPhysicalDeviceFeatures(m_physicalDevice, &features);
vkGetPhysicalDeviceMemoryProperties(m_physicalDevice, &memoryProperties);
m_deviceInfo.description = WidenAscii(properties.deviceName);
m_deviceInfo.vendor = ResolveVendorName(properties.vendorID);
@@ -439,6 +441,14 @@ void VulkanDevice::QueryDeviceInfo() {
m_deviceInfo.vendorId = properties.vendorID;
m_deviceInfo.deviceId = properties.deviceID;
m_deviceInfo.isSoftware = properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU;
for (uint32_t heapIndex = 0; heapIndex < memoryProperties.memoryHeapCount; ++heapIndex) {
const VkMemoryHeap& heap = memoryProperties.memoryHeaps[heapIndex];
if ((heap.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0) {
m_deviceInfo.dedicatedVideoMemory += heap.size;
} else {
m_deviceInfo.sharedSystemMemory += heap.size;
}
}
m_capabilities.bSupportsGeometryShaders = features.geometryShader == VK_TRUE;
m_capabilities.bSupportsTessellation = features.tessellationShader == VK_TRUE;
@@ -580,6 +590,7 @@ RHITexture* VulkanDevice::CreateTexture(const TextureDesc& desc) {
memory,
desc.width,
desc.height,
desc.depth > 0 ? desc.depth : 1u,
imageInfo.mipLevels,
format,
static_cast<TextureType>(desc.textureType),

View File

@@ -66,6 +66,7 @@ bool VulkanPipelineState::Initialize(VulkanDevice* device, const GraphicsPipelin
const bool hasVertexShader = HasShaderPayload(desc.vertexShader);
const bool hasFragmentShader = HasShaderPayload(desc.fragmentShader);
if (!hasVertexShader && !hasFragmentShader) {
m_isConfigured = true;
return true;
}
@@ -79,6 +80,7 @@ bool VulkanPipelineState::Initialize(VulkanDevice* device, const GraphicsPipelin
return false;
}
m_isConfigured = true;
return true;
}
@@ -362,6 +364,9 @@ void VulkanPipelineState::SetComputeShader(RHIShader* shader) {
m_pipeline = VK_NULL_HANDLE;
}
m_computeShader = shader;
if (m_computeShader != nullptr && m_pipelineLayout != VK_NULL_HANDLE) {
m_isConfigured = true;
}
}
PipelineStateHash VulkanPipelineState::GetHash() const {
@@ -425,6 +430,7 @@ void VulkanPipelineState::Shutdown() {
m_device = VK_NULL_HANDLE;
m_ownsPipelineLayout = false;
m_computeShader = nullptr;
m_isConfigured = false;
}
} // namespace RHI

View File

@@ -18,6 +18,7 @@ bool VulkanTexture::InitializeSwapChainImage(
m_image = image;
m_width = width;
m_height = height;
m_depth = 1;
m_mipLevels = 1;
m_format = format;
m_vkFormat = vkFormat;
@@ -33,6 +34,7 @@ bool VulkanTexture::InitializeOwnedImage(
VkDeviceMemory memory,
uint32_t width,
uint32_t height,
uint32_t depth,
uint32_t mipLevels,
Format format,
TextureType textureType,
@@ -46,6 +48,7 @@ bool VulkanTexture::InitializeOwnedImage(
m_memory = memory;
m_width = width;
m_height = height;
m_depth = depth > 0 ? depth : 1u;
m_mipLevels = mipLevels;
m_format = format;
m_vkFormat = vkFormat;
@@ -69,6 +72,7 @@ void VulkanTexture::Shutdown() {
m_device = VK_NULL_HANDLE;
m_width = 0;
m_height = 0;
m_depth = 1;
m_mipLevels = 1;
m_format = Format::Unknown;
m_vkFormat = VK_FORMAT_UNDEFINED;