Enable depth-only shadow pass execution

This commit is contained in:
2026-04-04 20:35:47 +08:00
parent a548e0d0a9
commit 353d129613
8 changed files with 494 additions and 59 deletions

View File

@@ -45,6 +45,7 @@ public:
VkPipeline GetPipeline() const { return m_pipeline; }
VkPipelineLayout GetPipelineLayout() const { return m_pipelineLayout; }
VkRenderPass GetRenderPass() const { return m_renderPass; }
uint32_t GetRenderTargetCount() const { return m_renderTargetCount; }
bool HasDepthStencilAttachment() const {
return m_depthStencilFormat != 0 && static_cast<Format>(m_depthStencilFormat) != Format::Unknown;
}

View File

@@ -22,14 +22,14 @@ struct ScenePassRenderRequest {
RenderCameraData cameraDataOverride = {};
bool IsRequested() const {
return !surface.GetColorAttachments().empty();
return surface.GetDepthAttachment() != nullptr ||
!surface.GetColorAttachments().empty();
}
bool IsValid() const {
const std::vector<RHI::RHIResourceView*>& colorAttachments = surface.GetColorAttachments();
return !colorAttachments.empty() &&
colorAttachments[0] != nullptr &&
surface.GetDepthAttachment() != nullptr &&
return surface.GetDepthAttachment() != nullptr &&
(colorAttachments.empty() || colorAttachments[0] != nullptr) &&
surface.GetRenderAreaWidth() > 0 &&
surface.GetRenderAreaHeight() > 0;
}

View File

@@ -102,11 +102,17 @@ private:
Resources::MaterialRenderState renderState;
const Resources::Shader* shader = nullptr;
Containers::String passName;
uint32_t renderTargetCount = 0;
uint32_t renderTargetFormat = 0;
uint32_t depthStencilFormat = 0;
bool operator==(const PipelineStateKey& other) const {
return renderState == other.renderState &&
shader == other.shader &&
passName == other.passName;
passName == other.passName &&
renderTargetCount == other.renderTargetCount &&
renderTargetFormat == other.renderTargetFormat &&
depthStencilFormat == other.depthStencilFormat;
}
};
@@ -115,6 +121,9 @@ private:
size_t hash = MaterialRenderStateHash()(key.renderState);
hash ^= reinterpret_cast<size_t>(key.shader) + 0x9e3779b9u + (hash << 6) + (hash >> 2);
hash ^= std::hash<Containers::String>{}(key.passName) + 0x9e3779b9u + (hash << 6) + (hash >> 2);
hash ^= std::hash<uint32_t>{}(key.renderTargetCount) + 0x9e3779b9u + (hash << 6) + (hash >> 2);
hash ^= std::hash<uint32_t>{}(key.renderTargetFormat) + 0x9e3779b9u + (hash << 6) + (hash >> 2);
hash ^= std::hash<uint32_t>{}(key.depthStencilFormat) + 0x9e3779b9u + (hash << 6) + (hash >> 2);
return hash;
}
};
@@ -133,6 +142,7 @@ private:
const ResolvedShaderPass& resolvedShaderPass);
RHI::RHIPipelineState* GetOrCreatePipelineState(
const RenderContext& context,
const RenderSurface& surface,
const Resources::Material* material);
bool CreateOwnedDescriptorSet(
const BuiltinPassSetLayoutMetadata& setLayout,
@@ -145,6 +155,7 @@ private:
void DestroyPassResourceLayout(PassResourceLayout& passLayout);
bool DrawVisibleItem(
const RenderContext& context,
const RenderSurface& surface,
const RenderSceneData& sceneData,
const VisibleRenderItem& visibleItem);