Refactor namespaces and improve resource handling

- Updated namespaces from `Ghost.UnitTest` to `Ghost.Graphics.Test` across multiple files.
- Refactored `GraphicsTestWindow` to use a new `RenderSystem` configuration.
- Removed deprecated `Logger` and `SerializationTest` classes.
- Improved memory management in D3D12 components, including resource allocation and cleanup.
- Added `[SupportedOSPlatform]` attributes to specify Windows version compatibility.
- Updated `.editorconfig` settings and project references for consistency.
- Enabled `nativeDebugging` in `launchSettings.json`.
This commit is contained in:
2025-11-11 21:30:47 +09:00
parent fb003da26a
commit 6f786a0698
35 changed files with 334 additions and 401 deletions

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<UserControl
x:Class="Ghost.UnitTest.Controls.DebugConsole"
x:Class="Ghost.Graphics.Test.Controls.DebugConsole"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Ghost.UnitTest.Controls"
xmlns:local="using:Ghost.Graphics.Test.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

View File

@@ -1,13 +1,15 @@
using Ghost.UnitTest.Models;
using Ghost.UnitTest.Services;
using System.Collections.ObjectModel;
using Ghost.Graphics.Test.Models;
using Ghost.Graphics.Test.Services;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
using System.Collections.ObjectModel;
namespace Ghost.UnitTest.Controls;
namespace Ghost.Graphics.Test.Controls;
public sealed partial class DebugConsole : UserControl
{
@@ -162,4 +164,4 @@ public class LogLevelToSymbolConverter : IValueConverter
{
throw new NotImplementedException();
}
}
}

View File

@@ -3,7 +3,7 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>Ghost.UnitTest</RootNamespace>
<RootNamespace>Ghost.Graphics.Test</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
@@ -59,12 +59,6 @@
<ProjectReference Include="..\Ghost.Test.Core\Ghost.Test.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Misaki.HighPerformance.Unsafe">
<HintPath>..\..\Class\Misaki.HighPerformance\Misaki.HighPerformance.LowLevel\bin\Release\net9.0\Misaki.HighPerformance.LowLevel.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Page Update="Windows\DebugOutputWindow.xaml">
<Generator>MSBuild:Compile</Generator>

View File

@@ -1,4 +1,4 @@
namespace Ghost.UnitTest.Models;
namespace Ghost.Graphics.Test.Models;
public enum LogLevel
{

View File

@@ -1,10 +1,10 @@
{
"profiles": {
"Ghost.UnitTest (Package)": {
"Ghost.Graphics.Test (Package)": {
"commandName": "MsixPackage",
"nativeDebugging": false
"nativeDebugging": true
},
"Ghost.UnitTest (Unpackaged)": {
"Ghost.Graphics.Test (Unpackaged)": {
"commandName": "Project"
}
}

View File

@@ -1,7 +1,8 @@
using Ghost.UnitTest.Models;
using Ghost.Graphics.Test.Models;
using System.Diagnostics;
namespace Ghost.UnitTest.Services;
namespace Ghost.Graphics.Test.Services;
internal class LoggingService
{

View File

@@ -1,50 +0,0 @@
using Ghost.Editor.Core.SceneGraph;
using Ghost.Entities;
using System.Text.Json;
namespace Ghost.UnitTest.Test;
internal class SerializationTest : ITest
{
private const string _TEST_FILE_PATH = "C:/Users/Misaki/Downloads/testScene.ghostscene";
public void Run()
{
var testWorld = World.Create();
var testScene = new WorldNode(testWorld, "Test Scene");
var entity1 = SceneGraphHelpers.CreateEntityNode(testScene, "entity 1");
var entity2 = SceneGraphHelpers.CreateEntityNode(testScene, "entity 2");
var entity3 = SceneGraphHelpers.CreateEntityNode(testScene, "entity 3");
var entity4 = SceneGraphHelpers.CreateEntityNode(testScene, "entity 4");
var entity5 = SceneGraphHelpers.CreateEntityNode(testScene, "entity 5");
testWorld.SystemStorage.AddSystem<TestSystem>();
SceneGraphHelpers.AttachChild(testScene, entity1, entity2);
SceneGraphHelpers.AttachChild(testScene, entity1, entity3);
SceneGraphHelpers.AttachChild(testScene, entity2, entity4);
testScene.AddChild(entity1);
testScene.AddChild(entity5);
var createStream = new FileStream(_TEST_FILE_PATH, FileMode.Create, FileAccess.Write, FileShare.None);
var options = new JsonSerializerOptions
{
WriteIndented = true,
IncludeFields = true,
IgnoreReadOnlyProperties = true,
};
JsonSerializer.Serialize(createStream, testScene, options);
createStream.Dispose();
testWorld.Dispose();
var readStream = new FileStream(_TEST_FILE_PATH, FileMode.Open, FileAccess.Read, FileShare.Read);
var deserializedScene = JsonSerializer.Deserialize<WorldNode>(readStream, options) ?? throw new Exception("Deserialization failed.");
deserializedScene.LoadAsync();
}
}

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<Application
x:Class="Ghost.UnitTest.UnitTestApp"
x:Class="Ghost.Graphics.Test.UnitTestApp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Ghost.UnitTest">
xmlns:local="using:Ghost.Graphics.Test">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

View File

@@ -1,11 +1,12 @@
using Ghost.UnitTest.Windows;
using Ghost.Graphics.Test.Windows;
using Microsoft.UI.Xaml;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace Ghost.UnitTest;
namespace Ghost.Graphics.Test;
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
@@ -30,12 +31,11 @@ public partial class UnitTestApp : Application
{
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
_window = new DebugOutputWindow();
_window = new GraphicsTestWindow();
_window.Activate();
UITestMethodAttribute.DispatcherQueue = _window.DispatcherQueue;
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine);
//TestRunner.Run<EntityTest>();
}
}

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<Window
x:Class="Ghost.UnitTest.Windows.DebugOutputWindow"
x:Class="Ghost.Graphics.Test.Windows.DebugOutputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Ghost.UnitTest.Controls"
xmlns:controls="using:Ghost.Graphics.Test.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Ghost.UnitTest.Windows"
xmlns:local="using:Ghost.Graphics.Test.Windows"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="DebugOutputWindow"
mc:Ignorable="d">

View File

@@ -1,6 +1,6 @@
using Microsoft.UI.Xaml;
namespace Ghost.UnitTest.Windows;
namespace Ghost.Graphics.Test.Windows;
internal sealed partial class DebugOutputWindow : Window
{

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<Window
x:Class="Ghost.UnitTest.Windows.GraphicsTestWindow"
x:Class="Ghost.Graphics.Test.Windows.GraphicsTestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Ghost.UnitTest.Controls"
xmlns:controls="using:Ghost.Graphics.Test.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Ghost.UnitTest.Windows"
xmlns:local="using:Ghost.Graphics.Test.Windows"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="GraphicsTestWindow"
mc:Ignorable="d">

View File

@@ -4,11 +4,11 @@ using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Misaki.HighPerformance.LowLevel.Buffer;
namespace Ghost.UnitTest.Windows;
namespace Ghost.Graphics.Test.Windows;
public sealed partial class GraphicsTestWindow : Window
{
private RenderSystem? _renderSystem;
private IRenderSystem? _renderSystem;
private IRenderer? _renderer;
private ISwapChain? _swapChain;
@@ -28,21 +28,27 @@ public sealed partial class GraphicsTestWindow : Window
AllocationManager.EnableDebugLayer();
#endif
_renderSystem = new(GraphicsAPI.Direct3D12);
_renderer = _renderSystem.CreateRenderer();
_renderSystem = new RenderSystem(new()
{
FrameBufferCount = 2,
GraphicsAPI = GraphicsAPI.Direct3D12
});
_renderer = _renderSystem.GraphicsEngine.CreateRenderer();
_swapChain = _renderSystem.GraphicsEngine.CreateSwapChain(new SwapChainDesc((uint)AppWindow.Size.Width, (uint)AppWindow.Size.Height, SwapChainTarget.FromCompositionSurface(Panel)));
_renderer.SetSwapChain(_swapChain);
_renderSystem.Start();
CompositionTarget.Rendering += OnRendering;
}
private void SwapChainPanel_Unloaded(object sender, RoutedEventArgs e)
{
CompositionTarget.Rendering -= OnRendering;
_renderSystem?.Stop();
_swapChain?.Dispose();
_renderer?.Dispose();
_swapChain?.Dispose();
_renderSystem?.Dispose();
}
@@ -50,18 +56,23 @@ public sealed partial class GraphicsTestWindow : Window
{
if (e.NewSize.Width > 8.0 && e.NewSize.Height > 8.0)
{
_renderer?.RequestResize((uint)e.NewSize.Width, (uint)e.NewSize.Height);
_renderer?.RequestResize(new((uint)e.NewSize.Width, (uint)e.NewSize.Height));
}
}
private void OnRendering(object? sender, object e)
{
//if (GraphicsPipeline.CPUFenceValue < GraphicsPipeline.GPUFenceValue + GraphicsPipeline._FRAME_COUNT)
//{
// DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.High, () =>
// {
// GraphicsPipeline.SignalCPUReady();
// });
//}
if (_renderSystem == null)
{
return;
}
if (_renderSystem.CPUFenceValue < _renderSystem.GPUFenceValue + _renderSystem.Config.FrameBufferCount)
{
DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.High, () =>
{
_renderSystem.SignalCPUReady();
});
}
}
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Ghost.UnitTest.app"/>
<assemblyIdentity version="1.0.0.0" name="Ghost.Graphics.Test.app"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>