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

@@ -4,8 +4,10 @@
#include "Debug/Logger.h"
#include "Rendering/Picking/ObjectIdCodec.h"
#include "Rendering/Detail/ShaderVariantUtils.h"
#include "Rendering/Materials/RenderMaterialStateUtils.h"
#include "RHI/RHICommandList.h"
#include "RHI/RHIDevice.h"
#include <XCEngine/Resources/BuiltinResources.h>
#include <algorithm>
#include <utility>
@@ -52,32 +54,46 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(
pipelineDesc.depthStencilFormat = static_cast<uint32_t>(RHI::Format::Unknown);
pipelineDesc.sampleCount = 1;
pipelineDesc.rasterizerState.fillMode = static_cast<uint32_t>(RHI::FillMode::Solid);
pipelineDesc.rasterizerState.cullMode = static_cast<uint32_t>(RHI::CullMode::None);
pipelineDesc.rasterizerState.frontFace = static_cast<uint32_t>(RHI::FrontFace::CounterClockwise);
pipelineDesc.rasterizerState.depthClipEnable = true;
pipelineDesc.blendState.blendEnable = true;
pipelineDesc.blendState.srcBlend = static_cast<uint32_t>(RHI::BlendFactor::SrcAlpha);
pipelineDesc.blendState.dstBlend = static_cast<uint32_t>(RHI::BlendFactor::InvSrcAlpha);
pipelineDesc.blendState.srcBlendAlpha = static_cast<uint32_t>(RHI::BlendFactor::One);
pipelineDesc.blendState.dstBlendAlpha = static_cast<uint32_t>(RHI::BlendFactor::InvSrcAlpha);
pipelineDesc.blendState.blendOp = static_cast<uint32_t>(RHI::BlendOp::Add);
pipelineDesc.blendState.blendOpAlpha = static_cast<uint32_t>(RHI::BlendOp::Add);
pipelineDesc.blendState.colorWriteMask = static_cast<uint8_t>(RHI::ColorWriteMask::All);
pipelineDesc.depthStencilState.depthTestEnable = false;
pipelineDesc.depthStencilState.depthWriteEnable = false;
pipelineDesc.depthStencilState.depthFunc = static_cast<uint32_t>(RHI::ComparisonFunc::Always);
const Resources::ShaderPass* shaderPass = shader.FindPass(passName);
if (shaderPass != nullptr && shaderPass->hasFixedFunctionState) {
::XCEngine::Rendering::ApplyRenderState(shaderPass->fixedFunctionState, pipelineDesc);
} else {
Resources::MaterialRenderState fallbackState = {};
fallbackState.cullMode = Resources::MaterialCullMode::None;
fallbackState.depthWriteEnable = false;
fallbackState.depthTestEnable = false;
fallbackState.depthFunc = Resources::MaterialComparisonFunc::Always;
fallbackState.blendEnable = true;
fallbackState.srcBlend = Resources::MaterialBlendFactor::SrcAlpha;
fallbackState.dstBlend = Resources::MaterialBlendFactor::InvSrcAlpha;
fallbackState.srcBlendAlpha = Resources::MaterialBlendFactor::One;
fallbackState.dstBlendAlpha = Resources::MaterialBlendFactor::InvSrcAlpha;
fallbackState.blendOp = Resources::MaterialBlendOp::Add;
fallbackState.blendOpAlpha = Resources::MaterialBlendOp::Add;
fallbackState.colorWriteMask = static_cast<uint8_t>(RHI::ColorWriteMask::All);
::XCEngine::Rendering::ApplyRenderState(fallbackState, pipelineDesc);
}
const Resources::ShaderBackend backend = ::XCEngine::Rendering::Detail::ToShaderBackend(backendType);
if (const Resources::ShaderStageVariant* vertexVariant =
shader.FindVariant(passName, Resources::ShaderType::Vertex, backend)) {
::XCEngine::Rendering::Detail::ApplyShaderStageVariant(*vertexVariant, pipelineDesc.vertexShader);
if (shaderPass != nullptr) {
::XCEngine::Rendering::Detail::ApplyShaderStageVariant(
*shaderPass,
backend,
*vertexVariant,
pipelineDesc.vertexShader);
}
}
if (const Resources::ShaderStageVariant* fragmentVariant =
shader.FindVariant(passName, Resources::ShaderType::Fragment, backend)) {
::XCEngine::Rendering::Detail::ApplyShaderStageVariant(*fragmentVariant, pipelineDesc.fragmentShader);
if (shaderPass != nullptr) {
::XCEngine::Rendering::Detail::ApplyShaderStageVariant(
*shaderPass,
backend,
*fragmentVariant,
pipelineDesc.fragmentShader);
}
}
return pipelineDesc;
@@ -86,7 +102,7 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(
} // namespace
BuiltinObjectIdOutlinePass::BuiltinObjectIdOutlinePass(Containers::String shaderPath)
: m_shaderPath(std::move(shaderPath)) {
: m_shaderPath(shaderPath.Empty() ? Resources::GetBuiltinObjectIdOutlineShaderPath() : std::move(shaderPath)) {
ResetState();
}