Removed references to `Misaki.HighPerformance.Unsafe` and replaced them with `Misaki.HighPerformance.LowLevel` in multiple files. Removed calls to `AllocationManager.Initialize()` and `AllocationManager.Dispose()` in `EngineCore.cs`. Added new methods to the `ICommandBuffer` interface for enhanced rendering capabilities. Updated the `D3D12CommandBuffer` class to implement new graphics command handling methods. Added the `Material` class to manage shader properties and caching for improved performance. Encapsulated shader compilation and reflection processes within the `Shader` class for better organization. Added the `CBufferCache` struct to optimize GPU resource management for constant buffer data. Updated the `MeshRenderPass` class to utilize the new `Material` class for dynamic mesh rendering. Updated various project files to reflect the restructuring of dependencies. Modified XAML files and code-behind for improved readability and maintainability.
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using Ghost.Graphics;
|
|
using Ghost.Graphics.Contracts;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Media;
|
|
using WinRT;
|
|
|
|
namespace Ghost.UnitTest;
|
|
|
|
public sealed partial class UnitTestAppWindow : Window
|
|
{
|
|
private IRenderer? _renderView;
|
|
private ISwapChainPanelNative _swapChainPanelNative;
|
|
|
|
public UnitTestAppWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Activated += UnitTestAppWindow_Activated;
|
|
Closed += UnitTestAppWindow_Closed;
|
|
|
|
Panel.SizeChanged += SwapChainPanel_SizeChanged;
|
|
}
|
|
|
|
private void SwapChainPanel_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
if (e.NewSize.Width > 8.0 && e.NewSize.Height > 8.0)
|
|
{
|
|
_renderView?.RequestResize((uint)e.NewSize.Width, (uint)e.NewSize.Height);
|
|
}
|
|
}
|
|
|
|
private void UnitTestAppWindow_Activated(object sender, WindowActivatedEventArgs args)
|
|
{
|
|
GraphicsPipeline.Initialize(Graphics.Data.GraphicsAPI.D3D12);
|
|
GraphicsPipeline.Start();
|
|
|
|
var guid = typeof(ISwapChainPanelNative.Interface).GUID;
|
|
((IWinRTObject)Panel).NativeObject.TryAs(guid, out var swapChainPanelNativeHandle);
|
|
_swapChainPanelNative = new ISwapChainPanelNative(swapChainPanelNativeHandle);
|
|
|
|
_renderView = GraphicsPipeline.GraphicsDevice.CreateRenderer(new(_swapChainPanelNative, (uint)AppWindow.Size.Width, (uint)AppWindow.Size.Height));
|
|
|
|
CompositionTarget.Rendering += OnRendering;
|
|
}
|
|
|
|
private void UnitTestAppWindow_Closed(object sender, WindowEventArgs args)
|
|
{
|
|
GraphicsPipeline.SignalCPUReady();
|
|
GraphicsPipeline.Shutdown();
|
|
CompositionTarget.Rendering -= OnRendering;
|
|
_swapChainPanelNative.Dispose();
|
|
_renderView?.Dispose();
|
|
}
|
|
|
|
private void OnRendering(object? sender, object e)
|
|
{
|
|
if (GraphicsPipeline.WaitForGPUReady(0))
|
|
{
|
|
DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.High, () =>
|
|
{
|
|
GraphicsPipeline.SignalCPUReady();
|
|
});
|
|
}
|
|
}
|
|
}
|