Adopt binding plan for builtin object-id pass

This commit is contained in:
2026-04-03 17:05:38 +08:00
parent 5d24fd0337
commit 27014e613e
7 changed files with 132 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
#include <XCEngine/Rendering/ObjectIdPass.h>
#include <XCEngine/Rendering/ObjectIdEncoding.h>
#include <XCEngine/Rendering/RenderMaterialUtility.h>
#include <XCEngine/Rendering/RenderResourceCache.h>
#include <XCEngine/Core/Asset/ResourceHandle.h>
#include <XCEngine/RHI/RHIPipelineState.h>
@@ -54,6 +55,8 @@ private:
RHI::RHIType m_backendType = RHI::RHIType::D3D12;
RHI::RHIPipelineLayout* m_pipelineLayout = nullptr;
RHI::RHIPipelineState* m_pipelineState = nullptr;
PassResourceBindingLocation m_perObjectBinding = {};
Core::uint32 m_firstDescriptorSet = 0;
Resources::ResourceHandle<Resources::Shader> m_builtinObjectIdShader;
RenderResourceCache m_resourceCache;
std::unordered_map<uint64_t, OwnedDescriptorSet> m_perObjectSets;

View File

@@ -229,6 +229,19 @@ inline Containers::Array<Resources::ShaderResourceBindingDesc> BuildLegacyBuilti
return bindings;
}
inline Containers::Array<Resources::ShaderResourceBindingDesc> BuildLegacyBuiltinObjectIdPassResourceBindings() {
Containers::Array<Resources::ShaderResourceBindingDesc> bindings;
bindings.Resize(1);
bindings[0].name = "PerObjectConstants";
bindings[0].type = Resources::ShaderResourceType::ConstantBuffer;
bindings[0].set = 0;
bindings[0].binding = 0;
bindings[0].semantic = "PerObject";
return bindings;
}
inline bool IsBuiltinPassResourceTypeCompatible(
BuiltinPassResourceSemantic semantic,
Resources::ShaderResourceType type) {