engine: sync editor rendering and ui changes

This commit is contained in:
2026-04-08 16:09:15 +08:00
parent 31756847ab
commit 162f1cc12e
153 changed files with 4454 additions and 2990 deletions

View File

@@ -28,7 +28,7 @@ void OpenGLPipelineState::SetRasterizerState(const RasterizerDesc& state) {
m_glRasterizerState.scissorTestEnable = state.scissorTestEnable;
m_glRasterizerState.multisampleEnable = state.multisampleEnable;
m_glRasterizerState.polygonOffsetFactor = state.slopeScaledDepthBias;
m_glRasterizerState.polygonOffsetUnits = state.depthBiasClamp;
m_glRasterizerState.polygonOffsetUnits = static_cast<float>(state.depthBias);
}
void OpenGLPipelineState::SetBlendState(const BlendDesc& state) {
@@ -52,10 +52,14 @@ void OpenGLPipelineState::SetDepthStencilState(const DepthStencilStateDesc& stat
m_glDepthStencilState.stencilEnable = state.stencilEnable;
m_glDepthStencilState.stencilReadMask = state.stencilReadMask;
m_glDepthStencilState.stencilWriteMask = state.stencilWriteMask;
m_glDepthStencilState.stencilFunc = static_cast<ComparisonFunc>(state.front.func);
m_glDepthStencilState.stencilFailOp = static_cast<StencilOp>(state.front.failOp);
m_glDepthStencilState.stencilDepthFailOp = static_cast<StencilOp>(state.front.depthFailOp);
m_glDepthStencilState.stencilDepthPassOp = static_cast<StencilOp>(state.front.passOp);
m_glDepthStencilState.frontStencilFunc = static_cast<ComparisonFunc>(state.front.func);
m_glDepthStencilState.frontStencilFailOp = static_cast<StencilOp>(state.front.failOp);
m_glDepthStencilState.frontStencilDepthFailOp = static_cast<StencilOp>(state.front.depthFailOp);
m_glDepthStencilState.frontStencilDepthPassOp = static_cast<StencilOp>(state.front.passOp);
m_glDepthStencilState.backStencilFunc = static_cast<ComparisonFunc>(state.back.func);
m_glDepthStencilState.backStencilFailOp = static_cast<StencilOp>(state.back.failOp);
m_glDepthStencilState.backStencilDepthFailOp = static_cast<StencilOp>(state.back.depthFailOp);
m_glDepthStencilState.backStencilDepthPassOp = static_cast<StencilOp>(state.back.passOp);
}
void OpenGLPipelineState::SetTopology(uint32_t topologyType) {
@@ -121,16 +125,31 @@ void OpenGLPipelineState::ApplyDepthStencil() {
if (m_glDepthStencilState.stencilEnable) {
glEnable(GL_STENCIL_TEST);
glStencilMask(m_glDepthStencilState.stencilWriteMask);
glStencilFunc(
ToOpenGL(m_glDepthStencilState.stencilFunc),
glStencilMaskSeparate(GL_FRONT, m_glDepthStencilState.stencilWriteMask);
glStencilMaskSeparate(GL_BACK, m_glDepthStencilState.stencilWriteMask);
glStencilFuncSeparate(
GL_FRONT,
ToOpenGL(m_glDepthStencilState.frontStencilFunc),
m_glDepthStencilState.stencilRef,
m_glDepthStencilState.stencilReadMask
);
glStencilOp(
ToOpenGL(m_glDepthStencilState.stencilFailOp),
ToOpenGL(m_glDepthStencilState.stencilDepthFailOp),
ToOpenGL(m_glDepthStencilState.stencilDepthPassOp)
glStencilOpSeparate(
GL_FRONT,
ToOpenGL(m_glDepthStencilState.frontStencilFailOp),
ToOpenGL(m_glDepthStencilState.frontStencilDepthFailOp),
ToOpenGL(m_glDepthStencilState.frontStencilDepthPassOp)
);
glStencilFuncSeparate(
GL_BACK,
ToOpenGL(m_glDepthStencilState.backStencilFunc),
m_glDepthStencilState.stencilRef,
m_glDepthStencilState.stencilReadMask
);
glStencilOpSeparate(
GL_BACK,
ToOpenGL(m_glDepthStencilState.backStencilFailOp),
ToOpenGL(m_glDepthStencilState.backStencilDepthFailOp),
ToOpenGL(m_glDepthStencilState.backStencilDepthPassOp)
);
} else {
glDisable(GL_STENCIL_TEST);
@@ -177,6 +196,18 @@ void OpenGLPipelineState::ApplyRasterizer() {
} else {
glDisable(GL_MULTISAMPLE);
}
const bool polygonOffsetEnable =
m_glRasterizerState.polygonOffsetFactor != 0.0f ||
m_glRasterizerState.polygonOffsetUnits != 0.0f;
if (polygonOffsetEnable) {
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(
m_glRasterizerState.polygonOffsetFactor,
m_glRasterizerState.polygonOffsetUnits);
} else {
glDisable(GL_POLYGON_OFFSET_FILL);
}
}
void OpenGLPipelineState::ApplyViewport() {