Refactor render graph error handling and resource APIs

- RenderGraph.Compile/Execute now return Error for better failure detection; error handling is propagated throughout compiler and executor.
- Renamed ScheduleReleaseResource to ReleaseResource for clarity; updated all usages.
- ResourceManager now calls ReleaseResource directly on Mesh, Material, and Shader types.
- Camera exposes Actual/Virtual size properties and Render returns Error.
- RenderingContext now uses IResourceManager for mesh/resource ops.
- Replaced custom BinaryWriter with BufferWriter in RenderGraphHasher.
- Improved variable naming, interface signatures, and code formatting.
- Added Error extension for IsSuccess/IsFailure.
- Minor FMOD/native interop and test code cleanups.
- No breaking API changes except for new Error return values on some methods.
This commit is contained in:
2026-02-25 19:08:54 +09:00
parent 30090f84ab
commit 162b71f309
93 changed files with 537 additions and 593 deletions

View File

@@ -1,7 +1,6 @@
using Ghost.Core;
using Ghost.Core.Graphics;
using Ghost.DSL.ShaderParser;
using System.Runtime.CompilerServices;
using System.Text;
namespace Ghost.DSL.ShaderCompiler;
@@ -107,7 +106,7 @@ internal static class DSLShaderCompiler
if (semantics.passes != null)
{
descriptor.passes = new PassDescriptor[semantics.passes.Count];
for (int i = 0; i < semantics.passes.Count; i++)
for (var i = 0; i < semantics.passes.Count; i++)
{
var pass = semantics.passes[i];
var localPipeline = MeragePipeline(pass.localPipeline, PipelineState.Default);

View File

@@ -205,7 +205,7 @@ public class ShaderVisitor : GhostShaderParserBaseVisitor<object>
// Get the text between the braces
var start = context.LBRACE().Symbol.StopIndex + 1;
var stop = context.RBRACE().Symbol.StartIndex - 1;
if (stop >= start)
{
var input = context.Start.InputStream;

View File

@@ -1,13 +1,10 @@
using Ghost.Core;
using Ghost.Editor.Core.Contracts;
using Ghost.Graphics.Core;
using Ghost.Graphics.RHI;
using Misaki.HighPerformance.Image;
using System.Buffers;
using System.Configuration;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using TerraFX.Interop.Windows;
using static Ghost.Editor.Core.AssetHandler.TextureAssetSettings;
namespace Ghost.Editor.Core.AssetHandler;
@@ -150,7 +147,7 @@ public class TextureAssetSettings : IAssetSettings
{
get; set;
} = new Color128(0, 0, 0, 0);
public bool ZeroAlphaBorder
{
get; set;
@@ -228,7 +225,7 @@ internal class TextureAssetHandler : IImportableAssetHandler
try
{
ref byte address = ref MemoryMarshal.GetReference(tempArray);
ref var address = ref MemoryMarshal.GetReference(tempArray);
Unsafe.WriteUnaligned(ref address, settings.Basic);
Unsafe.WriteUnaligned(ref Unsafe.Add(ref address, Unsafe.SizeOf<BasicSettings>()), settings.Advanced);
Unsafe.WriteUnaligned(ref Unsafe.Add(ref address, Unsafe.SizeOf<BasicSettings>() + Unsafe.SizeOf<AdvancedSettings>()), settings.Sampler);
@@ -295,8 +292,8 @@ internal class TextureAssetHandler : IImportableAssetHandler
}
var isFloat = info.BitsPerChannel > 8;
var width = info.Width;
var height = info.Height;
var width = info.Width;
var height = info.Height;
var colorComponents = info.ColorComponents;
// ---- 2. Decode pixels into a managed byte[] ----------------------------
@@ -356,9 +353,9 @@ internal class TextureAssetHandler : IImportableAssetHandler
// byte[] pixelBytes
const int _CONTENT_HEADER_SIZE = 4 + 4 + 1 + 4; // 13 bytes
header.SettingsSize = sizeResult.Value;
header.SettingsSize = sizeResult.Value;
header.ContentOffset = header.SettingsOffset + sizeResult.Value;
header.ContentSize = _CONTENT_HEADER_SIZE + pixelBytes.Length;
header.ContentSize = _CONTENT_HEADER_SIZE + pixelBytes.Length;
// Write raw image content
targetStream.Seek(header.ContentOffset, SeekOrigin.Begin);

View File

@@ -5,9 +5,9 @@ namespace Ghost.Editor.Core.Contracts;
public interface IInspectable
{
public IconSource? CreateIcon();
IconSource? CreateIcon();
public UIElement? CreateHeader();
UIElement? CreateHeader();
public UIElement? CreateInspector();
UIElement? CreateInspector();
}

View File

@@ -2,6 +2,6 @@ namespace Ghost.Editor.Core.Contracts;
public interface INavigationAware
{
public void OnNavigatedTo(object? parameter);
public void OnNavigatedFrom();
void OnNavigatedTo(object? parameter);
void OnNavigatedFrom();
}

View File

@@ -5,6 +5,6 @@ namespace Ghost.Editor.Core.Contracts;
public interface INotificationService
{
public void ShowNotification(string? message, MessageType type, int duration = 5, string? title = null);
public void ShowNotification(Notification notification);
void ShowNotification(string? message, MessageType type, int duration = 5, string? title = null);
void ShowNotification(Notification notification);
}

View File

@@ -2,8 +2,8 @@ namespace Ghost.Editor.Core.Contracts;
public interface IProgressService
{
public void ShowProgress(string message, double progress = 0.0);
public void ShowIndeterminateProgress(string message);
public void SetProgress(double progress);
public void HideProgress();
void ShowProgress(string message, double progress = 0.0);
void ShowIndeterminateProgress(string message);
void SetProgress(double progress);
void HideProgress();
}

View File

@@ -1,7 +1,6 @@
using Ghost.Editor.Core.Utilities;
using Microsoft.UI.Xaml.Controls;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Ghost.Editor.Core.Controls;
@@ -93,7 +92,7 @@ public sealed partial class ContextFlyout : MenuFlyout
return;
}
int currentGroup = nodes[0].EffectiveGroup;
var currentGroup = nodes[0].EffectiveGroup;
foreach (var node in nodes)
{

View File

@@ -1,9 +1,6 @@
using Ghost.Editor.Core;
using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.Utilities;
using Ghost.Editor.Models;
using Ghost.Engine;
using Microsoft.UI.Xaml;
using System.Reflection;
namespace Ghost.Editor;

View File

@@ -1,6 +1,5 @@
using Ghost.Core;
using Ghost.Editor.Core;
using Ghost.Editor.Core.AssetHandle;
using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.Services;
using Ghost.Editor.View.Pages.EngineEditor;

View File

@@ -5,7 +5,7 @@ internal sealed class ArgumentNameAttribute : Attribute
{
public string Name
{
get;
get;
}
public ArgumentNameAttribute(string name)

View File

@@ -1,7 +1,5 @@
using Ghost.Engine.Utilities;
using Microsoft.UI.Xaml.Data;
using Misaki.HighPerformance.Mathematics;
using System.Numerics;
namespace Ghost.Editor.Utilities.Converters;

View File

@@ -1,17 +1,4 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

View File

@@ -31,7 +31,7 @@ internal partial class ProjectBrowser
{
return;
}
var currentDir = viewModel.CurrentDirectoryPath;
if (!Directory.Exists(currentDir))
{

View File

@@ -2,7 +2,6 @@ using Ghost.Editor.Core;
using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.Services;
using Ghost.Editor.ViewModels.Windows;
using System.Diagnostics;
using Windows.ApplicationModel;
using WinUIEx;

View File

@@ -1,6 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ghost.Editor.Core;
using Ghost.Editor.Core.AssetHandle;
using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.Utilities;
using Ghost.Editor.Models;

View File

@@ -1,7 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.SceneGraph;
using System.Collections.ObjectModel;
namespace Ghost.Editor.ViewModels.Pages.EngineEditor;

View File

@@ -1,7 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Ghost.Editor.Core;
using Ghost.Editor.Core.AssetHandle;
using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Models;
using System.Collections.ObjectModel;