Update rendering and resource management
Changed the `EditorState` class to use a timeout in the `WaitForGPUReady` method for improved responsiveness. Changed the `nativeDebugging` setting in `launchSettings.json` to `false` for the "Ghost.Editor (Package)" profile. Changed the `D3D12Renderer` class to set the swap chain only for the composition target type and replaced back buffer reset with dispose. Changed the mapping of resources in `D3D12Resource` to use a pointer for improved safety and clarity. Changed the `Mesh` class's upload buffer creation to not use the `true` flag for better memory management. Added a new `Vertex` struct with a `StructLayout` attribute for improved interoperability with unmanaged code. Refactored the `GraphicsPipeline` class to replace `IsGpuReady` with `WaitForGPUReady`, including a timeout parameter. Added a constant buffer to the HLSL source code in `MeshRenderPass` for passing transformation matrices to the vertex shader. Expanded the `UnitTestAppWindow` class to include event handlers for window activation and size changes for better resource management. Updated the XAML for `UnitTestAppWindow` to include a `SwapChainPanel` and corrected the XML declaration for formatting consistency.
This commit is contained in:
@@ -4,6 +4,7 @@ using Ghost.Graphics.D3D12.Utilities;
|
||||
using Ghost.Graphics.Data;
|
||||
using Ghost.Graphics.Utilities;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Win32;
|
||||
using Win32.Graphics.Direct3D;
|
||||
using Win32.Graphics.Direct3D12;
|
||||
@@ -14,6 +15,12 @@ namespace Ghost.Graphics.RenderPasses;
|
||||
internal unsafe class MeshRenderPass : IRenderPass
|
||||
{
|
||||
private const string _HLSL_SOURCE = @"
|
||||
|
||||
cbuffer ConstantBuffer : register(b0)
|
||||
{
|
||||
float4x4 WVP_Matrix;
|
||||
};
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float3 position : POSITION;
|
||||
@@ -56,7 +63,17 @@ float4 PSMain(PixelInput input) : SV_TARGET
|
||||
|
||||
private void CreateRootSignature()
|
||||
{
|
||||
var rootSignatureDesc = new RootSignatureDescription(0u, null)
|
||||
var rootParameters = new RootParameter[]
|
||||
{
|
||||
new ()
|
||||
{
|
||||
ParameterType = RootParameterType.Cbv,
|
||||
ShaderVisibility = ShaderVisibility.Vertex,
|
||||
Descriptor = new RootDescriptor(0, 0)
|
||||
}
|
||||
};
|
||||
|
||||
var rootSignatureDesc = new RootSignatureDescription(0u, (RootParameter*)Unsafe.AsPointer(ref rootParameters[0]))
|
||||
{
|
||||
Flags = RootSignatureFlags.AllowInputAssemblerInputLayout
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user