forked from Misaki/GhostEngine
Updated target frameworks to .NET 10.0 across multiple projects for compatibility with the latest features. Refactored namespaces and introduced new classes for shader descriptors, FMOD integration, and DirectX 12 utilities using TerraFX. Replaced `Win32` bindings with TerraFX equivalents for DirectX 12. Added a C# wrapper for FMOD Studio API, including DSP and error handling. Enhanced entity queries, component storage, and query filters for better performance and type safety. Introduced new test projects and updated the solution structure. Added `meshoptimizer` bindings and integrated `meshoptimizer_native.dll`. Improved code readability, maintainability, and performance.
68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using Ghost.Graphics;
|
|
using Ghost.Graphics.RHI;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Media;
|
|
using Misaki.HighPerformance.LowLevel.Buffer;
|
|
|
|
namespace Ghost.UnitTest.Windows;
|
|
|
|
public sealed partial class GraphicsTestWindow : Window
|
|
{
|
|
private RenderSystem? _renderSystem;
|
|
private IRenderer? _renderer;
|
|
private ISwapChain? _swapChain;
|
|
|
|
public GraphicsTestWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Panel.Loaded += SwapChainPanel_Loaded;
|
|
Panel.Unloaded += SwapChainPanel_Unloaded;
|
|
|
|
Panel.SizeChanged += SwapChainPanel_SizeChanged;
|
|
}
|
|
|
|
private void SwapChainPanel_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
#if DEBUG
|
|
AllocationManager.EnableDebugLayer();
|
|
#endif
|
|
|
|
_renderSystem = new(GraphicsAPI.Direct3D12);
|
|
_renderer = _renderSystem.CreateRenderer();
|
|
|
|
_swapChain = _renderSystem.GraphicsEngine.CreateSwapChain(new SwapChainDesc((uint)AppWindow.Size.Width, (uint)AppWindow.Size.Height, SwapChainTarget.FromCompositionSurface(Panel)));
|
|
_renderer.SetSwapChain(_swapChain);
|
|
|
|
CompositionTarget.Rendering += OnRendering;
|
|
}
|
|
|
|
private void SwapChainPanel_Unloaded(object sender, RoutedEventArgs e)
|
|
{
|
|
CompositionTarget.Rendering -= OnRendering;
|
|
|
|
_swapChain?.Dispose();
|
|
_renderer?.Dispose();
|
|
_renderSystem?.Dispose();
|
|
}
|
|
|
|
private void SwapChainPanel_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
if (e.NewSize.Width > 8.0 && e.NewSize.Height > 8.0)
|
|
{
|
|
_renderer?.RequestResize((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();
|
|
// });
|
|
//}
|
|
}
|
|
}
|