Move scene viewport shaders into editor resources

This commit is contained in:
2026-04-03 15:43:21 +08:00
parent f1981dd523
commit 24a200e126
22 changed files with 248 additions and 137 deletions

View File

@@ -6,12 +6,12 @@
#include <XCEngine/Debug/Logger.h>
#include <XCEngine/RHI/RHICommandList.h>
#include <XCEngine/RHI/RHIDevice.h>
#include <XCEngine/Resources/BuiltinResources.h>
#include "Rendering/Detail/ShaderVariantUtils.h"
#include <algorithm>
#include <cmath>
#include <utility>
namespace XCEngine {
namespace Rendering {
@@ -140,6 +140,23 @@ InfiniteGridParameters BuildInfiniteGridParameters(const InfiniteGridPassData& d
return parameters;
}
BuiltinInfiniteGridPass::BuiltinInfiniteGridPass(Containers::String shaderPath)
: m_shaderPath(std::move(shaderPath)) {
}
void BuiltinInfiniteGridPass::SetShaderPath(const Containers::String& shaderPath) {
if (m_shaderPath == shaderPath) {
return;
}
DestroyResources();
m_shaderPath = shaderPath;
}
const Containers::String& BuiltinInfiniteGridPass::GetShaderPath() const {
return m_shaderPath;
}
void BuiltinInfiniteGridPass::Shutdown() {
DestroyResources();
}
@@ -243,14 +260,21 @@ bool BuiltinInfiniteGridPass::CreateResources(const RenderContext& renderContext
return false;
}
if (m_shaderPath.Empty()) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinInfiniteGridPass requires an injected shader path before resource creation");
return false;
}
m_device = renderContext.device;
m_backendType = renderContext.backendType;
m_builtinInfiniteGridShader = Resources::ResourceManager::Get().Load<Resources::Shader>(
Resources::GetBuiltinInfiniteGridShaderPath());
m_shaderPath);
if (!m_builtinInfiniteGridShader.IsValid()) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinInfiniteGridPass failed to load builtin infinite-grid shader resource");
"BuiltinInfiniteGridPass failed to load configured infinite-grid shader resource");
DestroyResources();
return false;
}

View File

@@ -6,7 +6,6 @@
#include "Rendering/Detail/ShaderVariantUtils.h"
#include "RHI/RHICommandList.h"
#include "RHI/RHIDevice.h"
#include "Resources/BuiltinResources.h"
#include <algorithm>
#include <utility>
@@ -86,10 +85,24 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(
} // namespace
BuiltinObjectIdOutlinePass::BuiltinObjectIdOutlinePass() {
BuiltinObjectIdOutlinePass::BuiltinObjectIdOutlinePass(Containers::String shaderPath)
: m_shaderPath(std::move(shaderPath)) {
ResetState();
}
void BuiltinObjectIdOutlinePass::SetShaderPath(const Containers::String& shaderPath) {
if (m_shaderPath == shaderPath) {
return;
}
DestroyResources();
m_shaderPath = shaderPath;
}
const Containers::String& BuiltinObjectIdOutlinePass::GetShaderPath() const {
return m_shaderPath;
}
void BuiltinObjectIdOutlinePass::Shutdown() {
DestroyResources();
}
@@ -197,12 +210,19 @@ bool BuiltinObjectIdOutlinePass::CreateResources(const RenderContext& renderCont
return false;
}
if (m_shaderPath.Empty()) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinObjectIdOutlinePass requires an injected shader path before resource creation");
return false;
}
Resources::ResourceHandle<Resources::Shader> shader = Resources::ResourceManager::Get().Load<Resources::Shader>(
Resources::GetBuiltinObjectIdOutlineShaderPath());
m_shaderPath);
if (!shader.IsValid()) {
Debug::Logger::Get().Error(
Debug::LogCategory::Rendering,
"BuiltinObjectIdOutlinePass failed to load builtin object-id-outline shader resource");
"BuiltinObjectIdOutlinePass failed to load configured object-id-outline shader resource");
ResetState();
return false;
}