Add Vulkan sphere integration support

This commit is contained in:
2026-03-27 15:07:21 +08:00
parent 18fd09b36f
commit 22ccdfb371
16 changed files with 429 additions and 63 deletions

View File

@@ -9,6 +9,7 @@ namespace XCEngine {
namespace RHI {
class VulkanDescriptorSet;
class VulkanDevice;
class VulkanDescriptorPool : public RHIDescriptorPool {
public:
@@ -29,8 +30,11 @@ public:
VkDevice GetDevice() const { return m_device; }
VkDescriptorPool GetDescriptorPool() const { return m_descriptorPool; }
VulkanDevice* GetDeviceOwner() const { return m_deviceOwner; }
void SetDeviceOwner(VulkanDevice* deviceOwner) { m_deviceOwner = deviceOwner; }
private:
VulkanDevice* m_deviceOwner = nullptr;
VkDevice m_device = VK_NULL_HANDLE;
VkDescriptorPool m_descriptorPool = VK_NULL_HANDLE;
DescriptorHeapType m_type = DescriptorHeapType::CBV_SRV_UAV;

View File

@@ -1,8 +1,10 @@
#pragma once
#include "XCEngine/RHI/RHIDescriptorSet.h"
#include "XCEngine/RHI/Vulkan/VulkanBuffer.h"
#include "XCEngine/RHI/Vulkan/VulkanCommon.h"
#include <memory>
#include <unordered_map>
#include <vector>
@@ -47,6 +49,12 @@ public:
VkDescriptorSetLayout GetDescriptorSetLayout() const { return m_descriptorSetLayout; }
private:
struct ConstantBindingRecord {
std::vector<uint8_t> data;
std::unique_ptr<VulkanBuffer> buffer;
size_t descriptorRange = 0;
};
const DescriptorSetLayoutBinding* FindBinding(uint32_t binding) const;
VkDevice m_device = VK_NULL_HANDLE;
@@ -55,6 +63,7 @@ private:
VkDescriptorSet m_descriptorSet = VK_NULL_HANDLE;
std::vector<DescriptorSetLayoutBinding> m_bindings;
std::unordered_map<uint32_t, uint32_t> m_bindingToIndex;
std::unordered_map<uint32_t, ConstantBindingRecord> m_constantBindings;
std::vector<uint8_t> m_constantBufferData;
bool m_constantDirty = false;
};

View File

@@ -44,6 +44,9 @@ public:
VkPipeline GetPipeline() const { return m_pipeline; }
VkPipelineLayout GetPipelineLayout() const { return m_pipelineLayout; }
VkRenderPass GetRenderPass() const { return m_renderPass; }
bool HasDepthStencilAttachment() const {
return m_depthStencilFormat != 0 && static_cast<Format>(m_depthStencilFormat) != Format::Unknown;
}
private:
VulkanDevice* m_deviceOwner = nullptr;

View File

@@ -15,6 +15,7 @@ public:
~VulkanResourceView() override;
bool InitializeAsRenderTarget(VkDevice device, VulkanTexture* texture, const ResourceViewDesc& desc);
bool InitializeAsDepthStencil(VkDevice device, VulkanTexture* texture, const ResourceViewDesc& desc);
bool InitializeAsShaderResource(VkDevice device, VulkanTexture* texture, const ResourceViewDesc& desc);
bool InitializeAsVertexBuffer(VulkanBuffer* buffer, const ResourceViewDesc& desc);
bool InitializeAsIndexBuffer(VulkanBuffer* buffer, const ResourceViewDesc& desc);