Fix RHI constant binding and add sphere test

This commit is contained in:
2026-03-26 01:23:29 +08:00
parent c5605c2a32
commit 39edb0b497
17 changed files with 959 additions and 35 deletions

View File

@@ -33,6 +33,7 @@ public:
GPUDescriptorHandle GetGPUDescriptorHandle(uint32_t index);
uint32_t GetDescriptorCount() const override;
DescriptorHeapType GetType() const override;
bool IsShaderVisible() const { return m_shaderVisible; }
uint32_t GetDescriptorSize() const { return m_descriptorSize; }
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart() const;

View File

@@ -1,6 +1,7 @@
#pragma once
#include <d3d12.h>
#include <memory>
#include <wrl/client.h>
#include <vector>
@@ -13,6 +14,7 @@ namespace XCEngine {
namespace RHI {
class D3D12DescriptorHeap;
class D3D12Buffer;
class D3D12DescriptorSet : public RHIDescriptorSet {
public:
@@ -41,6 +43,10 @@ public:
uint32_t GetOffset() const { return m_offset; }
uint32_t GetCount() const { return m_count; }
D3D12DescriptorHeap* GetHeap() const { return m_heap; }
bool HasBindingType(DescriptorType type) const;
uint32_t GetFirstBindingOfType(DescriptorType type) const;
bool UploadConstantBuffer();
D3D12_GPU_VIRTUAL_ADDRESS GetConstantBufferGPUAddress() const;
private:
D3D12DescriptorHeap* m_heap;
@@ -50,7 +56,9 @@ private:
DescriptorSetLayoutBinding* m_bindings;
std::vector<uint8_t> m_constantBufferData;
bool m_constantBufferDirty = false;
std::unique_ptr<D3D12Buffer> m_constantBuffer;
uint64_t m_constantBufferCapacity = 0;
};
} // namespace RHI
} // namespace XCEngine
} // namespace XCEngine

View File

@@ -29,12 +29,14 @@ public:
uint32_t GetRootParameterIndex(uint32_t shaderRegister) const;
bool HasRootParameter(uint32_t shaderRegister) const;
const RHIPipelineLayoutDesc& GetDesc() const { return m_desc; }
private:
bool InitializeInternal(D3D12Device* device, const RHIPipelineLayoutDesc& desc);
ComPtr<ID3D12RootSignature> m_rootSignature;
D3D12Device* m_device;
RHIPipelineLayoutDesc m_desc = {};
std::unordered_map<uint32_t, uint32_t> m_registerToRootIndex;
std::vector<D3D12_ROOT_PARAMETER> m_rootParameters;
std::vector<D3D12_DESCRIPTOR_RANGE> m_descriptorRanges;