chore: checkpoint current workspace changes

This commit is contained in:
2026-04-11 22:14:02 +08:00
parent 3e55f8c204
commit 8848cfd958
227 changed files with 34027 additions and 6711 deletions

View File

@@ -2,6 +2,7 @@
#include "Core/Asset/ResourceManager.h"
#include "RHI/RHICommandList.h"
#include "Rendering/Internal/RenderSurfacePipelineUtils.h"
#include "Rendering/Extraction/RenderSceneExtractor.h"
#include "Rendering/RenderSurface.h"
#include "Resources/Mesh/Mesh.h"
@@ -52,7 +53,7 @@ RHI::InputLayoutDesc BuiltinObjectIdPass::BuildInputLayout() {
}
bool BuiltinObjectIdPass::Initialize(const RenderContext& context) {
return EnsureInitialized(context);
return context.IsValid();
}
bool BuiltinObjectIdPass::Execute(const RenderPassContext& context) {
@@ -61,7 +62,8 @@ bool BuiltinObjectIdPass::Execute(const RenderPassContext& context) {
}
const std::vector<RHI::RHIResourceView*>& colorAttachments = context.surface.GetColorAttachments();
if (colorAttachments.empty() ||
if (!::XCEngine::Rendering::Internal::HasSingleColorAttachment(context.surface) ||
colorAttachments.empty() ||
colorAttachments[0] == nullptr ||
context.surface.GetDepthAttachment() == nullptr) {
return false;
@@ -72,21 +74,26 @@ bool BuiltinObjectIdPass::Execute(const RenderPassContext& context) {
return false;
}
if (!EnsureInitialized(context.renderContext)) {
if (!EnsureInitialized(context.renderContext, context.surface)) {
return false;
}
RHI::RHICommandList* commandList = context.renderContext.commandList;
RHI::RHIResourceView* renderTarget = colorAttachments[0];
RHI::RHIResourceView* depthAttachment = context.surface.GetDepthAttachment();
if (context.surface.IsAutoTransitionEnabled()) {
commandList->TransitionBarrier(
renderTarget,
context.surface.GetColorStateBefore(),
RHI::ResourceStates::RenderTarget);
commandList->TransitionBarrier(
depthAttachment,
context.surface.GetDepthStateBefore(),
RHI::ResourceStates::DepthWrite);
}
commandList->SetRenderTargets(1, &renderTarget, context.surface.GetDepthAttachment());
commandList->SetRenderTargets(1, &renderTarget, depthAttachment);
const RHI::Viewport viewport = {
static_cast<float>(renderArea.x),
@@ -108,7 +115,7 @@ bool BuiltinObjectIdPass::Execute(const RenderPassContext& context) {
commandList->SetViewport(viewport);
commandList->SetScissorRect(scissorRect);
commandList->ClearRenderTarget(renderTarget, clearColor, 1, clearRects);
commandList->ClearDepthStencil(context.surface.GetDepthAttachment(), 1.0f, 0, 1, clearRects);
commandList->ClearDepthStencil(depthAttachment, 1.0f, 0, 1, clearRects);
commandList->SetPrimitiveTopology(RHI::PrimitiveTopology::TriangleList);
commandList->SetPipelineState(m_pipelineState);
@@ -123,6 +130,10 @@ bool BuiltinObjectIdPass::Execute(const RenderPassContext& context) {
renderTarget,
RHI::ResourceStates::RenderTarget,
context.surface.GetColorStateAfter());
commandList->TransitionBarrier(
depthAttachment,
RHI::ResourceStates::DepthWrite,
context.surface.GetDepthStateAfter());
}
return true;