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.
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using System.Numerics;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using Win32.Graphics.Dxgi.Common;
|
|
|
|
namespace Ghost.Graphics.Data;
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct Vertex(Vector4 position, Vector4 normal, Vector4 tangent, Color128 color, Vector4 uv)
|
|
{
|
|
public unsafe struct Semantic
|
|
{
|
|
public const Format ALIGNED_FORMAT = Format.R32G32B32A32Float;
|
|
|
|
private static readonly byte[] s_positionBytes = Encoding.UTF8.GetBytes("POSITION");
|
|
private static readonly byte[] s_normalBytes = Encoding.UTF8.GetBytes("NORMAL");
|
|
private static readonly byte[] s_tangentBytes = Encoding.UTF8.GetBytes("TANGENT");
|
|
private static readonly byte[] s_colorBytes = Encoding.UTF8.GetBytes("COLOR");
|
|
private static readonly byte[] s_uvBytes = Encoding.UTF8.GetBytes("UV");
|
|
|
|
public static byte* PositionName => (byte*)Unsafe.AsPointer(ref s_positionBytes[0]);
|
|
public static byte* NormalName => (byte*)Unsafe.AsPointer(ref s_normalBytes[0]);
|
|
public static byte* TangentName => (byte*)Unsafe.AsPointer(ref s_tangentBytes[0]);
|
|
public static byte* ColorName => (byte*)Unsafe.AsPointer(ref s_colorBytes[0]);
|
|
public static byte* UVName => (byte*)Unsafe.AsPointer(ref s_uvBytes[0]);
|
|
}
|
|
|
|
public Vector4 Position
|
|
{
|
|
get;
|
|
set;
|
|
} = position;
|
|
|
|
public Vector4 Normal
|
|
{
|
|
get;
|
|
set;
|
|
} = normal;
|
|
|
|
public Vector4 Tangent
|
|
{
|
|
get;
|
|
set;
|
|
} = tangent;
|
|
|
|
public Color128 Color
|
|
{
|
|
get;
|
|
set;
|
|
} = color;
|
|
|
|
public Vector4 UV
|
|
{
|
|
get;
|
|
set;
|
|
} = uv;
|
|
} |