Added new RHI abstraction layer;
Added new console debug page to UnitTest;
This commit is contained in:
20
Ghost.UnitTest/Windows/DebugOutputWindow.xaml
Normal file
20
Ghost.UnitTest/Windows/DebugOutputWindow.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Window
|
||||
x:Class="Ghost.UnitTest.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:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Ghost.UnitTest.Windows"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="DebugOutputWindow"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
</Window.SystemBackdrop>
|
||||
|
||||
<Grid>
|
||||
<controls:DebugConsole HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
</Grid>
|
||||
</Window>
|
||||
11
Ghost.UnitTest/Windows/DebugOutputWindow.xaml.cs
Normal file
11
Ghost.UnitTest/Windows/DebugOutputWindow.xaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Ghost.UnitTest.Windows;
|
||||
|
||||
internal sealed partial class DebugOutputWindow : Window
|
||||
{
|
||||
public DebugOutputWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
47
Ghost.UnitTest/Windows/GraphicsTestWindow.xaml
Normal file
47
Ghost.UnitTest/Windows/GraphicsTestWindow.xaml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Window
|
||||
x:Class="Ghost.UnitTest.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:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Ghost.UnitTest.Windows"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="GraphicsTestWindow"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
</Window.SystemBackdrop>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="300" MinHeight="150" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Main test content area -->
|
||||
<SwapChainPanel
|
||||
x:Name="Panel"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch" />
|
||||
|
||||
<!-- Splitter -->
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Height="4"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{ThemeResource SystemControlBackgroundBaseLowBrush}" />
|
||||
|
||||
<!-- Debug Console -->
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||
BorderBrush="{ThemeResource SystemControlForegroundBaseLowBrush}"
|
||||
BorderThickness="0,1,0,0">
|
||||
<controls:DebugConsole x:Name="DebugConsole" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
72
Ghost.UnitTest/Windows/GraphicsTestWindow.xaml.cs
Normal file
72
Ghost.UnitTest/Windows/GraphicsTestWindow.xaml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using Ghost.Graphics;
|
||||
using Ghost.Graphics.Contracts;
|
||||
using Ghost.Graphics.D3D12;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
||||
using WinRT;
|
||||
|
||||
namespace Ghost.UnitTest.Windows;
|
||||
|
||||
public sealed partial class GraphicsTestWindow : Window
|
||||
{
|
||||
private Renderer? _renderer;
|
||||
private ISwapChainPanelNative _swapChainPanelNative;
|
||||
|
||||
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
|
||||
GraphicsPipeline.Initialize();
|
||||
GraphicsPipeline.Start();
|
||||
|
||||
var guid = typeof(ISwapChainPanelNative.Interface).GUID;
|
||||
((IWinRTObject)Panel).NativeObject.TryAs(guid, out var swapChainPanelNativeHandle);
|
||||
_swapChainPanelNative = new ISwapChainPanelNative(swapChainPanelNativeHandle);
|
||||
|
||||
//_renderer = GraphicsPipeline.GraphicsDevice.CreateRenderer(new(_swapChainPanelNative, (uint)AppWindow.Size.Width, (uint)AppWindow.Size.Height));
|
||||
|
||||
CompositionTarget.Rendering += OnRendering;
|
||||
}
|
||||
|
||||
private void SwapChainPanel_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CompositionTarget.Rendering -= OnRendering;
|
||||
|
||||
GraphicsPipeline.SignalCPUReady();
|
||||
GraphicsPipeline.Shutdown();
|
||||
|
||||
_swapChainPanelNative.Dispose();
|
||||
_renderer?.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();
|
||||
// });
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user