docs(editor): sync script assembly builder api docs
This commit is contained in:
@@ -689,7 +689,6 @@ std::vector<fs::path> CollectBuiltinShaderAssetPaths() {
|
||||
GetBuiltinSelectionOutlineShaderPath(),
|
||||
GetBuiltinSkyboxShaderPath(),
|
||||
GetBuiltinGaussianSplatShaderPath(),
|
||||
GetBuiltinGaussianSplatCompositeShaderPath(),
|
||||
GetBuiltinGaussianSplatUtilitiesShaderPath(),
|
||||
GetBuiltinVolumetricShaderPath(),
|
||||
GetBuiltinColorScalePostProcessShaderPath(),
|
||||
@@ -1735,11 +1734,7 @@ bool AssetDatabase::ReimportAsset(const Containers::String& requestPath,
|
||||
}
|
||||
|
||||
SourceAssetRecord sourceRecord;
|
||||
if (!EnsureMetaForPath(
|
||||
absoluteFsPath,
|
||||
false,
|
||||
SourceHashPolicy::EnsureCurrent,
|
||||
sourceRecord)) {
|
||||
if (!EnsureMetaForPath(absoluteFsPath, false, sourceRecord)) {
|
||||
SetLastErrorMessage(Containers::String("Failed to prepare asset metadata: ") + absolutePath);
|
||||
return false;
|
||||
}
|
||||
@@ -1811,35 +1806,18 @@ bool AssetDatabase::ReimportAllAssets(MaintenanceStats* outStats) {
|
||||
bool allSucceeded = true;
|
||||
MaintenanceStats localStats;
|
||||
for (const SourceAssetRecord& record : importableRecords) {
|
||||
const fs::path sourcePath = fs::path(m_projectRoot.CStr()) / record.relativePath.CStr();
|
||||
|
||||
SourceAssetRecord currentRecord;
|
||||
if (!EnsureMetaForPath(
|
||||
sourcePath,
|
||||
false,
|
||||
SourceHashPolicy::EnsureCurrent,
|
||||
currentRecord)) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::FileSystem,
|
||||
Containers::String("[AssetDatabase] ReimportAllAssets failed to refresh metadata path=") +
|
||||
record.relativePath);
|
||||
allSucceeded = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
ArtifactRecord rebuiltRecord;
|
||||
if (!ImportAsset(currentRecord, rebuiltRecord)) {
|
||||
if (!ImportAsset(record, rebuiltRecord)) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::FileSystem,
|
||||
Containers::String("[AssetDatabase] ReimportAllAssets failed path=") + currentRecord.relativePath);
|
||||
Containers::String("[AssetDatabase] ReimportAllAssets failed path=") + record.relativePath);
|
||||
allSucceeded = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
m_artifactsByGuid[currentRecord.guid] = rebuiltRecord;
|
||||
m_sourcesByGuid[currentRecord.guid].lastKnownArtifactKey = rebuiltRecord.artifactKey;
|
||||
m_sourcesByPathKey[ToStdString(MakeKey(currentRecord.relativePath))].lastKnownArtifactKey =
|
||||
rebuiltRecord.artifactKey;
|
||||
m_artifactsByGuid[record.guid] = rebuiltRecord;
|
||||
m_sourcesByGuid[record.guid].lastKnownArtifactKey = rebuiltRecord.artifactKey;
|
||||
m_sourcesByPathKey[ToStdString(MakeKey(record.relativePath))].lastKnownArtifactKey = rebuiltRecord.artifactKey;
|
||||
++localStats.importedAssetCount;
|
||||
}
|
||||
|
||||
@@ -2108,11 +2086,7 @@ void AssetDatabase::ScanAssetPath(const fs::path& path,
|
||||
|
||||
const bool isFolder = fs::is_directory(path);
|
||||
SourceAssetRecord record;
|
||||
if (EnsureMetaForPath(
|
||||
path,
|
||||
isFolder,
|
||||
SourceHashPolicy::PreserveOrClear,
|
||||
record)) {
|
||||
if (EnsureMetaForPath(path, isFolder, record)) {
|
||||
seenPaths[ToStdString(MakeKey(record.relativePath))] = true;
|
||||
}
|
||||
|
||||
@@ -2220,7 +2194,6 @@ Core::uint32 AssetDatabase::CleanupOrphanedArtifacts() const {
|
||||
|
||||
bool AssetDatabase::EnsureMetaForPath(const fs::path& sourcePath,
|
||||
bool isFolder,
|
||||
SourceHashPolicy sourceHashPolicy,
|
||||
SourceAssetRecord& outRecord) {
|
||||
const Containers::String relativePath = NormalizeRelativePath(sourcePath);
|
||||
if (relativePath.Empty()) {
|
||||
@@ -2243,35 +2216,6 @@ bool AssetDatabase::EnsureMetaForPath(const fs::path& sourcePath,
|
||||
outRecord.importerName = GetImporterNameForPath(relativePath, isFolder);
|
||||
outRecord.importerVersion = GetCurrentImporterVersion(outRecord.importerName);
|
||||
|
||||
const auto refreshSourceSnapshot = [&]() {
|
||||
if (isFolder) {
|
||||
outRecord.sourceHash.Clear();
|
||||
outRecord.sourceFileSize = 0;
|
||||
outRecord.sourceWriteTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const Core::uint64 fileSize = GetFileSizeValue(sourcePath);
|
||||
const Core::uint64 writeTime = GetFileWriteTimeValue(sourcePath);
|
||||
const bool canReuseExistingHash =
|
||||
existingIt != m_sourcesByPathKey.end() &&
|
||||
existingIt->second.sourceFileSize == fileSize &&
|
||||
existingIt->second.sourceWriteTime == writeTime &&
|
||||
!existingIt->second.sourceHash.Empty();
|
||||
|
||||
if (sourceHashPolicy == SourceHashPolicy::EnsureCurrent) {
|
||||
outRecord.sourceHash =
|
||||
canReuseExistingHash ? existingIt->second.sourceHash : ComputeFileHash(sourcePath);
|
||||
} else if (canReuseExistingHash) {
|
||||
outRecord.sourceHash = existingIt->second.sourceHash;
|
||||
} else {
|
||||
outRecord.sourceHash.Clear();
|
||||
}
|
||||
|
||||
outRecord.sourceFileSize = fileSize;
|
||||
outRecord.sourceWriteTime = writeTime;
|
||||
};
|
||||
|
||||
if (UsesExternalSyntheticSourceRecord(relativePath)) {
|
||||
if (!outRecord.guid.IsValid()) {
|
||||
outRecord.guid = HashStringToAssetGUID(NormalizePathString(sourcePath));
|
||||
@@ -2289,7 +2233,24 @@ bool AssetDatabase::EnsureMetaForPath(const fs::path& sourcePath,
|
||||
outRecord.guid = HashStringToAssetGUID(duplicateSignature);
|
||||
}
|
||||
|
||||
refreshSourceSnapshot();
|
||||
if (isFolder) {
|
||||
outRecord.sourceHash.Clear();
|
||||
outRecord.sourceFileSize = 0;
|
||||
outRecord.sourceWriteTime = 0;
|
||||
} else {
|
||||
const Core::uint64 fileSize = GetFileSizeValue(sourcePath);
|
||||
const Core::uint64 writeTime = GetFileWriteTimeValue(sourcePath);
|
||||
if (existingIt != m_sourcesByPathKey.end() &&
|
||||
existingIt->second.sourceFileSize == fileSize &&
|
||||
existingIt->second.sourceWriteTime == writeTime &&
|
||||
!existingIt->second.sourceHash.Empty()) {
|
||||
outRecord.sourceHash = existingIt->second.sourceHash;
|
||||
} else {
|
||||
outRecord.sourceHash = ComputeFileHash(sourcePath);
|
||||
}
|
||||
outRecord.sourceFileSize = fileSize;
|
||||
outRecord.sourceWriteTime = writeTime;
|
||||
}
|
||||
|
||||
m_sourcesByPathKey[pathKey] = outRecord;
|
||||
m_sourcesByGuid[outRecord.guid] = outRecord;
|
||||
@@ -2329,7 +2290,24 @@ bool AssetDatabase::EnsureMetaForPath(const fs::path& sourcePath,
|
||||
}
|
||||
|
||||
outRecord.metaHash = HashStringToAssetGUID(ReadWholeFileText(metaPath)).ToString();
|
||||
refreshSourceSnapshot();
|
||||
if (isFolder) {
|
||||
outRecord.sourceHash.Clear();
|
||||
outRecord.sourceFileSize = 0;
|
||||
outRecord.sourceWriteTime = 0;
|
||||
} else {
|
||||
const Core::uint64 fileSize = GetFileSizeValue(sourcePath);
|
||||
const Core::uint64 writeTime = GetFileWriteTimeValue(sourcePath);
|
||||
if (existingIt != m_sourcesByPathKey.end() &&
|
||||
existingIt->second.sourceFileSize == fileSize &&
|
||||
existingIt->second.sourceWriteTime == writeTime &&
|
||||
!existingIt->second.sourceHash.Empty()) {
|
||||
outRecord.sourceHash = existingIt->second.sourceHash;
|
||||
} else {
|
||||
outRecord.sourceHash = ComputeFileHash(sourcePath);
|
||||
}
|
||||
outRecord.sourceFileSize = fileSize;
|
||||
outRecord.sourceWriteTime = writeTime;
|
||||
}
|
||||
|
||||
m_sourcesByPathKey[pathKey] = outRecord;
|
||||
m_sourcesByGuid[outRecord.guid] = outRecord;
|
||||
@@ -2534,11 +2512,6 @@ bool AssetDatabase::ShouldReimport(const SourceAssetRecord& sourceRecord,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sourceRecord.isFolder &&
|
||||
(sourceRecord.sourceHash.Empty() || artifactRecord->sourceHash.Empty())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return artifactRecord->importerVersion != sourceRecord.importerVersion ||
|
||||
artifactRecord->sourceHash != sourceRecord.sourceHash ||
|
||||
artifactRecord->metaHash != sourceRecord.metaHash ||
|
||||
@@ -2607,14 +2580,8 @@ bool AssetDatabase::EnsureArtifact(const Containers::String& requestPath,
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool isFolder = fs::is_directory(absoluteFsPath);
|
||||
|
||||
SourceAssetRecord sourceRecord;
|
||||
if (!EnsureMetaForPath(
|
||||
absoluteFsPath,
|
||||
isFolder,
|
||||
SourceHashPolicy::PreserveOrClear,
|
||||
sourceRecord)) {
|
||||
if (!EnsureMetaForPath(absoluteFsPath, fs::is_directory(absoluteFsPath), sourceRecord)) {
|
||||
SetLastErrorMessage(Containers::String("Failed to prepare asset metadata: ") + absolutePath);
|
||||
return false;
|
||||
}
|
||||
@@ -2661,25 +2628,6 @@ bool AssetDatabase::EnsureArtifact(const Containers::String& requestPath,
|
||||
}
|
||||
|
||||
if (ShouldReimport(sourceRecord, artifactRecord)) {
|
||||
if (!EnsureMetaForPath(
|
||||
absoluteFsPath,
|
||||
isFolder,
|
||||
SourceHashPolicy::EnsureCurrent,
|
||||
sourceRecord)) {
|
||||
SetLastErrorMessage(Containers::String("Failed to validate asset metadata: ") + absolutePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
artifactIt = m_artifactsByGuid.find(sourceRecord.guid);
|
||||
artifactRecord = artifactIt != m_artifactsByGuid.end() ? &artifactIt->second : nullptr;
|
||||
|
||||
if (!ShouldReimport(sourceRecord, artifactRecord)) {
|
||||
SaveSourceAssetDB();
|
||||
PopulateResolvedAssetResult(m_projectRoot, sourceRecord, *artifactRecord, false, outAsset);
|
||||
ClearLastErrorMessage();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ShouldTraceAssetPath(requestPath)) {
|
||||
Debug::Logger::Get().Info(
|
||||
Debug::LogCategory::FileSystem,
|
||||
|
||||
@@ -348,7 +348,7 @@ void D3D12CommandList::SetGraphicsDescriptorSets(
|
||||
}
|
||||
|
||||
D3D12DescriptorHeap* heap = d3d12Set->GetHeap();
|
||||
if (heap == nullptr) {
|
||||
if (heap == nullptr || !heap->IsShaderVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ void D3D12CommandList::SetComputeDescriptorSets(
|
||||
}
|
||||
|
||||
D3D12DescriptorHeap* heap = d3d12Set->GetHeap();
|
||||
if (heap == nullptr) {
|
||||
if (heap == nullptr || !heap->IsShaderVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,9 +77,6 @@ D3D12_CPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::GetCPUDescriptorHandleForHeapSt
|
||||
}
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::GetGPUDescriptorHandleForHeapStart() const {
|
||||
if (!m_shaderVisible || m_descriptorHeap == nullptr) {
|
||||
return D3D12_GPU_DESCRIPTOR_HANDLE{0};
|
||||
}
|
||||
return m_descriptorHeap->GetGPUDescriptorHandleForHeapStart();
|
||||
}
|
||||
|
||||
@@ -92,10 +89,6 @@ CPUDescriptorHandle D3D12DescriptorHeap::GetCPUDescriptorHandle(uint32_t index)
|
||||
}
|
||||
|
||||
GPUDescriptorHandle D3D12DescriptorHeap::GetGPUDescriptorHandle(uint32_t index) {
|
||||
if (!m_shaderVisible || m_descriptorHeap == nullptr) {
|
||||
return GPUDescriptorHandle{0};
|
||||
}
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE handle = m_descriptorHeap->GetGPUDescriptorHandleForHeapStart();
|
||||
handle.ptr += index * m_descriptorSize;
|
||||
GPUDescriptorHandle result;
|
||||
|
||||
@@ -51,10 +51,6 @@ bool HasShaderPayload(const ShaderCompileDesc& desc) {
|
||||
return !desc.source.empty() || !desc.fileName.empty() || !desc.compiledBinary.empty();
|
||||
}
|
||||
|
||||
bool UsesTransientShaderVisibleDescriptorHeap(DescriptorHeapType type) {
|
||||
return type == DescriptorHeapType::CBV_SRV_UAV || type == DescriptorHeapType::Sampler;
|
||||
}
|
||||
|
||||
bool ShouldTraceVolumetricShaderCompile(const ShaderCompileDesc& desc) {
|
||||
const std::string fileName = NarrowAscii(desc.fileName);
|
||||
if (fileName.find("volumetric") != std::string::npos) {
|
||||
@@ -1283,9 +1279,6 @@ RHIDescriptorPool* D3D12Device::CreateDescriptorPool(const DescriptorPoolDesc& d
|
||||
auto* pool = new D3D12DescriptorHeap();
|
||||
DescriptorPoolDesc poolDesc = desc;
|
||||
poolDesc.device = m_device.Get();
|
||||
if (UsesTransientShaderVisibleDescriptorHeap(poolDesc.type)) {
|
||||
poolDesc.shaderVisible = false;
|
||||
}
|
||||
if (pool->Initialize(poolDesc)) {
|
||||
return pool;
|
||||
}
|
||||
|
||||
@@ -65,22 +65,6 @@ const Resources::ShaderPass* FindCompatibleComputePass(
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
const Resources::ShaderPass* FindCompatibleGraphicsPass(
|
||||
const Resources::Shader& shader,
|
||||
const Containers::String& passName,
|
||||
const Resources::ShaderKeywordSet& keywordSet,
|
||||
Resources::ShaderBackend backend) {
|
||||
const Resources::ShaderPass* shaderPass = shader.FindPass(passName);
|
||||
if (shaderPass == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return shader.FindVariant(passName, Resources::ShaderType::Vertex, backend, keywordSet) != nullptr &&
|
||||
shader.FindVariant(passName, Resources::ShaderType::Fragment, backend, keywordSet) != nullptr
|
||||
? shaderPass
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
RHI::GraphicsPipelineDesc CreatePipelineDesc(
|
||||
RHI::RHIType backendType,
|
||||
RHI::RHIPipelineLayout* pipelineLayout,
|
||||
@@ -121,44 +105,6 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(
|
||||
return pipelineDesc;
|
||||
}
|
||||
|
||||
RHI::GraphicsPipelineDesc CreateCompositePipelineDesc(
|
||||
RHI::RHIType backendType,
|
||||
RHI::RHIPipelineLayout* pipelineLayout,
|
||||
const Resources::Shader& shader,
|
||||
const Resources::ShaderPass& shaderPass,
|
||||
const Containers::String& passName,
|
||||
const RenderSurface& surface) {
|
||||
RHI::GraphicsPipelineDesc pipelineDesc = {};
|
||||
pipelineDesc.pipelineLayout = pipelineLayout;
|
||||
pipelineDesc.topologyType = static_cast<uint32_t>(RHI::PrimitiveTopologyType::Triangle);
|
||||
::XCEngine::Rendering::Internal::ApplySingleColorAttachmentPropertiesToGraphicsPipelineDesc(surface, pipelineDesc);
|
||||
pipelineDesc.depthStencilFormat =
|
||||
static_cast<uint32_t>(::XCEngine::Rendering::Internal::ResolveSurfaceDepthFormat(surface));
|
||||
ApplyResolvedRenderState(&shaderPass, nullptr, pipelineDesc);
|
||||
|
||||
const Resources::ShaderBackend backend = ::XCEngine::Rendering::Internal::ToShaderBackend(backendType);
|
||||
if (const Resources::ShaderStageVariant* vertexVariant =
|
||||
shader.FindVariant(passName, Resources::ShaderType::Vertex, backend)) {
|
||||
::XCEngine::Rendering::Internal::ApplyShaderStageVariant(
|
||||
shader.GetPath(),
|
||||
shaderPass,
|
||||
backend,
|
||||
*vertexVariant,
|
||||
pipelineDesc.vertexShader);
|
||||
}
|
||||
if (const Resources::ShaderStageVariant* fragmentVariant =
|
||||
shader.FindVariant(passName, Resources::ShaderType::Fragment, backend)) {
|
||||
::XCEngine::Rendering::Internal::ApplyShaderStageVariant(
|
||||
shader.GetPath(),
|
||||
shaderPass,
|
||||
backend,
|
||||
*fragmentVariant,
|
||||
pipelineDesc.fragmentShader);
|
||||
}
|
||||
|
||||
return pipelineDesc;
|
||||
}
|
||||
|
||||
RHI::ComputePipelineDesc CreateComputePipelineDesc(
|
||||
RHI::RHIType backendType,
|
||||
RHI::RHIPipelineLayout* pipelineLayout,
|
||||
@@ -262,10 +208,6 @@ void BindDescriptorSetRanges(
|
||||
}
|
||||
}
|
||||
|
||||
RHI::Format ResolveGaussianAccumulationFormat() {
|
||||
return RHI::Format::R16G16B16A16_Float;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BuiltinGaussianSplatPass::~BuiltinGaussianSplatPass() {
|
||||
@@ -362,31 +304,10 @@ bool BuiltinGaussianSplatPass::Execute(const RenderPassContext& context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureCompositeResources(context.renderContext, context.surface)) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to initialize composite resources");
|
||||
return false;
|
||||
}
|
||||
|
||||
Internal::BuiltinGaussianSplatPassResources::AccumulationSurface* accumulationSurface = nullptr;
|
||||
if (m_passResources == nullptr ||
|
||||
!m_passResources->EnsureAccumulationSurface(
|
||||
m_device,
|
||||
context.surface.GetWidth(),
|
||||
context.surface.GetHeight(),
|
||||
ResolveGaussianAccumulationFormat(),
|
||||
accumulationSurface) ||
|
||||
accumulationSurface == nullptr ||
|
||||
accumulationSurface->renderTargetView == nullptr ||
|
||||
accumulationSurface->shaderResourceView == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to allocate gaussian accumulation surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::RHICommandList* commandList = context.renderContext.commandList;
|
||||
RHI::RHIResourceView* renderTarget = colorAttachments[0];
|
||||
commandList->SetRenderTargets(1, &renderTarget, context.surface.GetDepthAttachment());
|
||||
|
||||
const RHI::Viewport viewport = {
|
||||
static_cast<float>(renderArea.x),
|
||||
static_cast<float>(renderArea.y),
|
||||
@@ -401,31 +322,9 @@ bool BuiltinGaussianSplatPass::Execute(const RenderPassContext& context) {
|
||||
renderArea.x + renderArea.width,
|
||||
renderArea.y + renderArea.height
|
||||
};
|
||||
const RHI::Rect clearRects[] = { scissorRect };
|
||||
const float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
RenderSurface accumulationRenderSurface(context.surface.GetWidth(), context.surface.GetHeight());
|
||||
accumulationRenderSurface.SetColorAttachment(accumulationSurface->renderTargetView);
|
||||
accumulationRenderSurface.SetDepthAttachment(context.surface.GetDepthAttachment());
|
||||
accumulationRenderSurface.SetRenderArea(renderArea);
|
||||
accumulationRenderSurface.SetAutoTransitionEnabled(false);
|
||||
accumulationRenderSurface.SetSampleDesc(1u, 0u);
|
||||
|
||||
commandList->EndRenderPass();
|
||||
if (accumulationSurface->currentColorState != RHI::ResourceStates::RenderTarget) {
|
||||
commandList->TransitionBarrier(
|
||||
accumulationSurface->renderTargetView,
|
||||
accumulationSurface->currentColorState,
|
||||
RHI::ResourceStates::RenderTarget);
|
||||
accumulationSurface->currentColorState = RHI::ResourceStates::RenderTarget;
|
||||
}
|
||||
|
||||
RHI::RHIResourceView* accumulationRenderTarget = accumulationSurface->renderTargetView;
|
||||
commandList->SetRenderTargets(1, &accumulationRenderTarget, context.surface.GetDepthAttachment());
|
||||
commandList->SetViewport(viewport);
|
||||
commandList->SetScissorRect(scissorRect);
|
||||
commandList->SetPrimitiveTopology(RHI::PrimitiveTopology::TriangleList);
|
||||
commandList->ClearRenderTarget(accumulationRenderTarget, clearColor, 1u, clearRects);
|
||||
|
||||
for (const VisibleGaussianSplatItem& visibleGaussianSplat : context.sceneData.visibleGaussianSplats) {
|
||||
if (!MarkVisibleGaussianSplatChunks(
|
||||
@@ -451,23 +350,14 @@ bool BuiltinGaussianSplatPass::Execute(const RenderPassContext& context) {
|
||||
|
||||
if (!DrawVisibleGaussianSplat(
|
||||
context.renderContext,
|
||||
accumulationRenderSurface,
|
||||
context.surface,
|
||||
context.sceneData,
|
||||
visibleGaussianSplat)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
commandList->EndRenderPass();
|
||||
if (accumulationSurface->currentColorState != RHI::ResourceStates::PixelShaderResource) {
|
||||
commandList->TransitionBarrier(
|
||||
accumulationSurface->shaderResourceView,
|
||||
accumulationSurface->currentColorState,
|
||||
RHI::ResourceStates::PixelShaderResource);
|
||||
accumulationSurface->currentColorState = RHI::ResourceStates::PixelShaderResource;
|
||||
}
|
||||
|
||||
return CompositeAccumulationSurface(context, accumulationSurface->shaderResourceView);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuiltinGaussianSplatPass::Shutdown() {
|
||||
@@ -482,8 +372,6 @@ bool BuiltinGaussianSplatPass::EnsureInitialized(const RenderContext& context) {
|
||||
if (m_device == context.device &&
|
||||
m_backendType == context.backendType &&
|
||||
m_builtinGaussianSplatShader.IsValid() &&
|
||||
m_builtinGaussianSplatCompositeShader.IsValid() &&
|
||||
m_builtinGaussianSplatUtilitiesShader.IsValid() &&
|
||||
m_builtinGaussianSplatMaterial != nullptr) {
|
||||
return true;
|
||||
}
|
||||
@@ -505,16 +393,6 @@ bool BuiltinGaussianSplatPass::CreateResources(const RenderContext& context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_builtinGaussianSplatCompositeShader = Resources::ResourceManager::Get().Load<Resources::Shader>(
|
||||
Resources::GetBuiltinGaussianSplatCompositeShaderPath());
|
||||
if (!m_builtinGaussianSplatCompositeShader.IsValid()) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to load builtin gaussian composite shader resource");
|
||||
DestroyResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_builtinGaussianSplatUtilitiesShader = Resources::ResourceManager::Get().Load<Resources::Shader>(
|
||||
Resources::GetBuiltinGaussianSplatUtilitiesShaderPath());
|
||||
if (!m_builtinGaussianSplatUtilitiesShader.IsValid()) {
|
||||
@@ -537,207 +415,6 @@ bool BuiltinGaussianSplatPass::CreateResources(const RenderContext& context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuiltinGaussianSplatPass::EnsureCompositeResources(
|
||||
const RenderContext& context,
|
||||
const RenderSurface& surface) {
|
||||
const RHI::Format renderTargetFormat =
|
||||
::XCEngine::Rendering::Internal::ResolveSurfaceColorFormat(surface, 0u);
|
||||
const Core::uint32 sampleCount =
|
||||
::XCEngine::Rendering::Internal::ResolveSurfaceSampleCount(surface);
|
||||
const Core::uint32 sampleQuality =
|
||||
::XCEngine::Rendering::Internal::ResolveSurfaceSampleQuality(surface);
|
||||
|
||||
if (m_compositeResources.pipelineLayout != nullptr &&
|
||||
m_compositeResources.pipelineState != nullptr &&
|
||||
m_compositeResources.textureSet.set != nullptr &&
|
||||
m_compositeResources.renderTargetFormat == renderTargetFormat &&
|
||||
m_compositeResources.sampleCount == sampleCount &&
|
||||
m_compositeResources.sampleQuality == sampleQuality) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DestroyCompositeResources();
|
||||
return CreateCompositeResources(context, surface);
|
||||
}
|
||||
|
||||
bool BuiltinGaussianSplatPass::CreateCompositeResources(
|
||||
const RenderContext& context,
|
||||
const RenderSurface& surface) {
|
||||
if (!context.IsValid() || !m_builtinGaussianSplatCompositeShader.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::Format renderTargetFormat = RHI::Format::Unknown;
|
||||
if (!::XCEngine::Rendering::Internal::TryResolveSingleColorAttachmentFormat(surface, renderTargetFormat)) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass composite requires a valid single-color destination surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
const Containers::String compositePassName("GaussianComposite");
|
||||
const Resources::Shader& shader = *m_builtinGaussianSplatCompositeShader.Get();
|
||||
const Resources::ShaderBackend backend = ::XCEngine::Rendering::Internal::ToShaderBackend(context.backendType);
|
||||
const Resources::ShaderPass* compositePass = FindCompatibleGraphicsPass(
|
||||
shader,
|
||||
compositePassName,
|
||||
Resources::ShaderKeywordSet(),
|
||||
backend);
|
||||
if (compositePass == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to resolve gaussian composite shader pass");
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::DescriptorSetLayoutBinding textureBinding = {};
|
||||
textureBinding.binding = 0u;
|
||||
textureBinding.type = static_cast<uint32_t>(RHI::DescriptorType::SRV);
|
||||
textureBinding.count = 1u;
|
||||
textureBinding.visibility = static_cast<uint32_t>(RHI::ShaderVisibility::All);
|
||||
|
||||
RHI::DescriptorSetLayoutDesc textureLayout = {};
|
||||
textureLayout.bindings = &textureBinding;
|
||||
textureLayout.bindingCount = 1u;
|
||||
|
||||
RHI::RHIPipelineLayoutDesc pipelineLayoutDesc = {};
|
||||
pipelineLayoutDesc.setLayouts = &textureLayout;
|
||||
pipelineLayoutDesc.setLayoutCount = 1u;
|
||||
m_compositeResources.pipelineLayout = m_device->CreatePipelineLayout(pipelineLayoutDesc);
|
||||
if (m_compositeResources.pipelineLayout == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to create gaussian composite pipeline layout");
|
||||
DestroyCompositeResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
RHI::DescriptorPoolDesc poolDesc = {};
|
||||
poolDesc.type = RHI::DescriptorHeapType::CBV_SRV_UAV;
|
||||
poolDesc.descriptorCount = 1u;
|
||||
poolDesc.shaderVisible = true;
|
||||
m_compositeResources.textureSet.pool = m_device->CreateDescriptorPool(poolDesc);
|
||||
if (m_compositeResources.textureSet.pool == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to create gaussian composite descriptor pool");
|
||||
DestroyCompositeResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_compositeResources.textureSet.set =
|
||||
m_compositeResources.textureSet.pool->AllocateSet(textureLayout);
|
||||
if (m_compositeResources.textureSet.set == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to allocate gaussian composite descriptor set");
|
||||
DestroyCompositeResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_compositeResources.pipelineState = m_device->CreatePipelineState(
|
||||
CreateCompositePipelineDesc(
|
||||
m_backendType,
|
||||
m_compositeResources.pipelineLayout,
|
||||
shader,
|
||||
*compositePass,
|
||||
compositePassName,
|
||||
surface));
|
||||
if (m_compositeResources.pipelineState == nullptr || !m_compositeResources.pipelineState->IsValid()) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass failed to create gaussian composite pipeline state");
|
||||
DestroyCompositeResources();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_compositeResources.renderTargetFormat = renderTargetFormat;
|
||||
m_compositeResources.sampleCount =
|
||||
::XCEngine::Rendering::Internal::ResolveSurfaceSampleCount(surface);
|
||||
m_compositeResources.sampleQuality =
|
||||
::XCEngine::Rendering::Internal::ResolveSurfaceSampleQuality(surface);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuiltinGaussianSplatPass::DestroyCompositeResources() {
|
||||
m_compositeResources.boundAccumulationView = nullptr;
|
||||
|
||||
if (m_compositeResources.pipelineState != nullptr) {
|
||||
m_compositeResources.pipelineState->Shutdown();
|
||||
delete m_compositeResources.pipelineState;
|
||||
m_compositeResources.pipelineState = nullptr;
|
||||
}
|
||||
|
||||
DestroyOwnedDescriptorSet(m_compositeResources.textureSet);
|
||||
|
||||
if (m_compositeResources.pipelineLayout != nullptr) {
|
||||
m_compositeResources.pipelineLayout->Shutdown();
|
||||
delete m_compositeResources.pipelineLayout;
|
||||
m_compositeResources.pipelineLayout = nullptr;
|
||||
}
|
||||
|
||||
m_compositeResources.renderTargetFormat = RHI::Format::Unknown;
|
||||
m_compositeResources.sampleCount = 1u;
|
||||
m_compositeResources.sampleQuality = 0u;
|
||||
}
|
||||
|
||||
bool BuiltinGaussianSplatPass::CompositeAccumulationSurface(
|
||||
const RenderPassContext& context,
|
||||
RHI::RHIResourceView* accumulationTextureView) {
|
||||
if (m_compositeResources.pipelineLayout == nullptr ||
|
||||
m_compositeResources.pipelineState == nullptr ||
|
||||
m_compositeResources.textureSet.set == nullptr ||
|
||||
accumulationTextureView == nullptr) {
|
||||
Debug::Logger::Get().Error(
|
||||
Debug::LogCategory::Rendering,
|
||||
"BuiltinGaussianSplatPass composite failed: composite resources are incomplete");
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<RHI::RHIResourceView*>& colorAttachments = context.surface.GetColorAttachments();
|
||||
if (colorAttachments.empty() || colorAttachments[0] == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_compositeResources.boundAccumulationView != accumulationTextureView) {
|
||||
m_compositeResources.textureSet.set->Update(0u, accumulationTextureView);
|
||||
m_compositeResources.boundAccumulationView = accumulationTextureView;
|
||||
}
|
||||
|
||||
const Math::RectInt renderArea = context.surface.GetRenderArea();
|
||||
const RHI::Viewport viewport = {
|
||||
static_cast<float>(renderArea.x),
|
||||
static_cast<float>(renderArea.y),
|
||||
static_cast<float>(renderArea.width),
|
||||
static_cast<float>(renderArea.height),
|
||||
0.0f,
|
||||
1.0f
|
||||
};
|
||||
const RHI::Rect scissorRect = {
|
||||
renderArea.x,
|
||||
renderArea.y,
|
||||
renderArea.x + renderArea.width,
|
||||
renderArea.y + renderArea.height
|
||||
};
|
||||
|
||||
RHI::RHICommandList* commandList = context.renderContext.commandList;
|
||||
RHI::RHIResourceView* renderTarget = colorAttachments[0];
|
||||
commandList->SetRenderTargets(1u, &renderTarget, context.surface.GetDepthAttachment());
|
||||
commandList->SetViewport(viewport);
|
||||
commandList->SetScissorRect(scissorRect);
|
||||
commandList->SetPrimitiveTopology(RHI::PrimitiveTopology::TriangleList);
|
||||
commandList->SetPipelineState(m_compositeResources.pipelineState);
|
||||
|
||||
RHI::RHIDescriptorSet* descriptorSet = m_compositeResources.textureSet.set;
|
||||
commandList->SetGraphicsDescriptorSets(
|
||||
0u,
|
||||
1u,
|
||||
&descriptorSet,
|
||||
m_compositeResources.pipelineLayout);
|
||||
commandList->Draw(3u, 1u, 0u, 0u);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuiltinGaussianSplatPass::DestroyResources() {
|
||||
if (m_passResources != nullptr) {
|
||||
m_passResources->Shutdown();
|
||||
@@ -773,11 +450,8 @@ void BuiltinGaussianSplatPass::DestroyResources() {
|
||||
}
|
||||
m_passResourceLayouts.clear();
|
||||
|
||||
DestroyCompositeResources();
|
||||
|
||||
m_builtinGaussianSplatMaterial.reset();
|
||||
m_builtinGaussianSplatUtilitiesShader.Reset();
|
||||
m_builtinGaussianSplatCompositeShader.Reset();
|
||||
m_builtinGaussianSplatShader.Reset();
|
||||
m_device = nullptr;
|
||||
m_backendType = RHI::RHIType::D3D12;
|
||||
@@ -1474,10 +1148,10 @@ bool BuiltinGaussianSplatPass::MarkVisibleGaussianSplatChunks(
|
||||
sceneData.cameraData.projection,
|
||||
sceneData.cameraData.view,
|
||||
visibleGaussianSplat.localToWorld.Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse().Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse(),
|
||||
Math::Vector4(sceneData.cameraData.worldRight, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldUp, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, sceneData.cameraData.nearClipPlane),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, 0.0f),
|
||||
Math::Vector4(
|
||||
static_cast<float>(sceneData.cameraData.viewportWidth),
|
||||
static_cast<float>(sceneData.cameraData.viewportHeight),
|
||||
@@ -1651,10 +1325,10 @@ bool BuiltinGaussianSplatPass::PrepareVisibleGaussianSplat(
|
||||
sceneData.cameraData.projection,
|
||||
sceneData.cameraData.view,
|
||||
visibleGaussianSplat.localToWorld.Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse().Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse(),
|
||||
Math::Vector4(sceneData.cameraData.worldRight, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldUp, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, sceneData.cameraData.nearClipPlane),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, 0.0f),
|
||||
Math::Vector4(
|
||||
static_cast<float>(sceneData.cameraData.viewportWidth),
|
||||
static_cast<float>(sceneData.cameraData.viewportHeight),
|
||||
@@ -1835,10 +1509,10 @@ bool BuiltinGaussianSplatPass::SortVisibleGaussianSplat(
|
||||
sceneData.cameraData.projection,
|
||||
sceneData.cameraData.view,
|
||||
visibleGaussianSplat.localToWorld.Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse().Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse(),
|
||||
Math::Vector4(sceneData.cameraData.worldRight, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldUp, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, sceneData.cameraData.nearClipPlane),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, 0.0f),
|
||||
Math::Vector4(
|
||||
static_cast<float>(sceneData.cameraData.viewportWidth),
|
||||
static_cast<float>(sceneData.cameraData.viewportHeight),
|
||||
@@ -2008,10 +1682,10 @@ bool BuiltinGaussianSplatPass::DrawVisibleGaussianSplat(
|
||||
sceneData.cameraData.projection,
|
||||
sceneData.cameraData.view,
|
||||
visibleGaussianSplat.localToWorld.Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse().Transpose(),
|
||||
visibleGaussianSplat.localToWorld.Inverse(),
|
||||
Math::Vector4(sceneData.cameraData.worldRight, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldUp, 0.0f),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, sceneData.cameraData.nearClipPlane),
|
||||
Math::Vector4(sceneData.cameraData.worldPosition, 0.0f),
|
||||
Math::Vector4(
|
||||
static_cast<float>(sceneData.cameraData.viewportWidth),
|
||||
static_cast<float>(sceneData.cameraData.viewportHeight),
|
||||
|
||||
@@ -37,8 +37,6 @@ constexpr const char* kBuiltinSelectionMaskShaderPath = "builtin://shaders/selec
|
||||
constexpr const char* kBuiltinSelectionOutlineShaderPath = "builtin://shaders/selection-outline";
|
||||
constexpr const char* kBuiltinSkyboxShaderPath = "builtin://shaders/skybox";
|
||||
constexpr const char* kBuiltinGaussianSplatShaderPath = "builtin://shaders/gaussian-splat";
|
||||
constexpr const char* kBuiltinGaussianSplatCompositeShaderPath =
|
||||
"builtin://shaders/gaussian-splat-composite";
|
||||
constexpr const char* kBuiltinGaussianSplatUtilitiesShaderPath =
|
||||
"builtin://shaders/gaussian-splat-utilities";
|
||||
constexpr const char* kBuiltinVolumetricShaderPath = "builtin://shaders/volumetric";
|
||||
@@ -75,8 +73,6 @@ constexpr const char* kBuiltinSkyboxShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/skybox.shader";
|
||||
constexpr const char* kBuiltinGaussianSplatShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/gaussian-splat.shader";
|
||||
constexpr const char* kBuiltinGaussianSplatCompositeShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/gaussian-splat-composite.shader";
|
||||
constexpr const char* kBuiltinGaussianSplatUtilitiesShaderAssetRelativePath =
|
||||
"engine/assets/builtin/shaders/gaussian-splat-utilities.shader";
|
||||
constexpr const char* kBuiltinVolumetricShaderAssetRelativePath =
|
||||
@@ -178,9 +174,6 @@ const char* GetBuiltinShaderAssetRelativePath(const Containers::String& builtinS
|
||||
if (builtinShaderPath == Containers::String(kBuiltinGaussianSplatShaderPath)) {
|
||||
return kBuiltinGaussianSplatShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinGaussianSplatCompositeShaderPath)) {
|
||||
return kBuiltinGaussianSplatCompositeShaderAssetRelativePath;
|
||||
}
|
||||
if (builtinShaderPath == Containers::String(kBuiltinGaussianSplatUtilitiesShaderPath)) {
|
||||
return kBuiltinGaussianSplatUtilitiesShaderAssetRelativePath;
|
||||
}
|
||||
@@ -761,10 +754,6 @@ Shader* BuildBuiltinGaussianSplatShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
|
||||
Shader* BuildBuiltinGaussianSplatCompositeShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
|
||||
Shader* BuildBuiltinVolumetricShader(const Containers::String& path) {
|
||||
return TryLoadBuiltinShaderFromAsset(path);
|
||||
}
|
||||
@@ -887,10 +876,6 @@ bool TryGetBuiltinShaderPathByShaderName(
|
||||
outPath = GetBuiltinGaussianSplatShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Gaussian Splat Composite") {
|
||||
outPath = GetBuiltinGaussianSplatCompositeShaderPath();
|
||||
return true;
|
||||
}
|
||||
if (shaderName == "Builtin Gaussian Splat Utilities") {
|
||||
outPath = GetBuiltinGaussianSplatUtilitiesShaderPath();
|
||||
return true;
|
||||
@@ -986,10 +971,6 @@ Containers::String GetBuiltinGaussianSplatShaderPath() {
|
||||
return Containers::String(kBuiltinGaussianSplatShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinGaussianSplatCompositeShaderPath() {
|
||||
return Containers::String(kBuiltinGaussianSplatCompositeShaderPath);
|
||||
}
|
||||
|
||||
Containers::String GetBuiltinGaussianSplatUtilitiesShaderPath() {
|
||||
return Containers::String(kBuiltinGaussianSplatUtilitiesShaderPath);
|
||||
}
|
||||
@@ -1114,8 +1095,6 @@ LoadResult CreateBuiltinShaderResource(const Containers::String& path) {
|
||||
shader = BuildBuiltinSkyboxShader(path);
|
||||
} else if (path == GetBuiltinGaussianSplatShaderPath()) {
|
||||
shader = BuildBuiltinGaussianSplatShader(path);
|
||||
} else if (path == GetBuiltinGaussianSplatCompositeShaderPath()) {
|
||||
shader = BuildBuiltinGaussianSplatCompositeShader(path);
|
||||
} else if (path == GetBuiltinGaussianSplatUtilitiesShaderPath()) {
|
||||
shader = TryLoadBuiltinShaderFromAsset(path);
|
||||
} else if (path == GetBuiltinVolumetricShaderPath()) {
|
||||
|
||||
Reference in New Issue
Block a user