RHI: Remove无效的动态状态方法 - SetDepthStencilState/SetBlendState

重构原因:
- D3D12 PSO是不可变的,SetDepthStencilState/SetBlendState调用原本就是空实现(TODO)
- 这些方法在D3D12中完全无效,是死代码

移除的方法:
- SetDepthStencilState(const DepthStencilState&) - D3D12空实现,OpenGL直接调用GL函数
- SetBlendState(const BlendState&) - D3D12只设置BlendFactor其他忽略,OpenGL直接调用GL函数

保留的真正动态状态:
- SetViewport/SetViewports
- SetScissorRect/SetScissorRects
- SetStencilRef (D3D12动态状态)
- SetBlendFactor (D3D12动态状态)

注:PrimitiveTopology保留在CommandList,因为D3D12允许动态改变topology type

测试状态:150个RHI单元测试全部通过,8个集成测试全部通过
This commit is contained in:
2026-03-25 00:37:18 +08:00
parent f8a2507bdf
commit a2fc8eca02
8 changed files with 31 additions and 132 deletions

View File

@@ -813,58 +813,10 @@ void OpenGLCommandList::SetPrimitiveTopology(PrimitiveTopology topology) {
m_primitiveType = ToGLPrimitiveTopology(topology);
}
void OpenGLCommandList::SetDepthStencilState(const DepthStencilState& state) {
if (state.depthEnable) {
glEnable(GL_DEPTH_TEST);
glDepthFunc(ToGLComparisonFunc(state.depthFunc));
glDepthMask(state.depthWriteMask ? GL_TRUE : GL_FALSE);
} else {
glDisable(GL_DEPTH_TEST);
}
if (state.stencilEnable) {
glEnable(GL_STENCIL_TEST);
glStencilMask(state.stencilWriteMask);
glStencilFunc(ToGLComparisonFunc(state.frontFace.stencilFunc), 0, state.stencilReadMask);
glStencilOp(
ToGLStencilOp(state.frontFace.stencilFailOp),
ToGLStencilOp(state.frontFace.stencilDepthFailOp),
ToGLStencilOp(state.frontFace.stencilPassOp)
);
} else {
glDisable(GL_STENCIL_TEST);
}
}
void OpenGLCommandList::SetStencilRef(uint8_t ref) {
glStencilFunc(GL_FRONT_AND_BACK, ref, 0xFF);
}
void OpenGLCommandList::SetBlendState(const BlendState& state) {
if (state.alphaToCoverageEnable) {
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
} else {
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
const auto& rt = state.renderTargets[0];
if (rt.blendEnable) {
glEnable(GL_BLEND);
glBlendFuncSeparate(
ToGLBlendFactor(rt.srcBlend),
ToGLBlendFactor(rt.dstBlend),
ToGLBlendFactor(rt.srcBlendAlpha),
ToGLBlendFactor(rt.dstBlendAlpha)
);
glBlendEquationSeparate(
ToGLBlendOp(rt.blendOp),
ToGLBlendOp(rt.blendOpAlpha)
);
} else {
glDisable(GL_BLEND);
}
}
void OpenGLCommandList::SetBlendFactor(const float factor[4]) {
glBlendColor(factor[0], factor[1], factor[2], factor[3]);
}