diff --git a/.idea/.idea.Coplt.Graphics/.idea/vcs.xml b/.idea/.idea.Coplt.Graphics/.idea/vcs.xml
index 94a25f7..dd3e634 100644
--- a/.idea/.idea.Coplt.Graphics/.idea/vcs.xml
+++ b/.idea/.idea.Coplt.Graphics/.idea/vcs.xml
@@ -2,5 +2,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
index 25fcf2b..faedd0b 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -1,486 +1,250 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assets/pattern.png b/Assets/pattern.png
new file mode 100644
index 0000000..8de847e
Binary files /dev/null and b/Assets/pattern.png differ
diff --git a/Coplt.Graphics.Core/Coplt.Graphics.Core.csproj b/Coplt.Graphics.Core/Coplt.Graphics.Core.csproj
index 19ce236..39fc16d 100644
--- a/Coplt.Graphics.Core/Coplt.Graphics.Core.csproj
+++ b/Coplt.Graphics.Core/Coplt.Graphics.Core.csproj
@@ -14,7 +14,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Coplt.Graphics.Core/Core/ComputeShaderPipeline.cs b/Coplt.Graphics.Core/Core/ComputeShaderPipeline.cs
new file mode 100644
index 0000000..514772a
--- /dev/null
+++ b/Coplt.Graphics.Core/Core/ComputeShaderPipeline.cs
@@ -0,0 +1,22 @@
+using Coplt.Graphics.Native;
+using Coplt.Graphics.States;
+
+namespace Coplt.Graphics.Core;
+
+public sealed unsafe class ComputeShaderPipeline : ShaderPipeline
+{
+ #region Props
+
+ public new FComputeShaderPipeline* Ptr => (FComputeShaderPipeline*)m_ptr;
+
+ #endregion
+
+ #region Ctor
+
+ internal ComputeShaderPipeline(
+ FComputeShaderPipeline* ptr, string? name,
+ Shader shader, ShaderBindingLayout binding_layout
+ ) : base((FShaderPipeline*)ptr, name, shader, binding_layout) { }
+
+ #endregion
+}
diff --git a/Coplt.Graphics.Core/Core/GpuBuffer.cs b/Coplt.Graphics.Core/Core/GpuBuffer.cs
index c2d7ae2..61d5681 100644
--- a/Coplt.Graphics.Core/Core/GpuBuffer.cs
+++ b/Coplt.Graphics.Core/Core/GpuBuffer.cs
@@ -69,7 +69,7 @@ m_name is null
#endregion
- #region View
+ #region Try View
public bool TryVbv() => Purpose.HasFlags(ResourcePurpose.VertexBuffer);
public bool TryIbv() => Purpose.HasFlags(ResourcePurpose.IndexBuffer);
@@ -80,6 +80,13 @@ m_name is null
#endregion
+ #region Create View
+
+ public View View(ulong Offset = 0, int Size = -1, int Stride = -1, GraphicsFormat Format = 0) =>
+ Core.View.MakeBuffer(this, Offset, Size, Stride, Format);
+
+ #endregion
+
#region Map UnMap
public void* Map() => Map(CpuAccess != CpuAccess.Read);
diff --git a/Coplt.Graphics.Core/Core/GpuDevice.cs b/Coplt.Graphics.Core/Core/GpuDevice.cs
index 4802036..57efd96 100644
--- a/Coplt.Graphics.Core/Core/GpuDevice.cs
+++ b/Coplt.Graphics.Core/Core/GpuDevice.cs
@@ -382,6 +382,34 @@ public GraphicsShaderPipeline CreateGraphicsShaderPipeline(
#endregion
+ #region CreateComputeShaderPipeline
+
+ public ComputeShaderPipeline CreateComputeShaderPipeline(
+ Shader Shader, string? Name = null, ReadOnlySpan Name8 = default
+ ) => CreateComputeShaderPipeline(Shader, Shader.Layout.GetEmptyBindingLayout(), Name, Name8);
+
+ public ComputeShaderPipeline CreateComputeShaderPipeline(
+ Shader Shader, ShaderBindingLayout BindingLayout,
+ string? Name = null, ReadOnlySpan Name8 = default
+ )
+ {
+ fixed (char* p_name = Name)
+ fixed (byte* p_name8 = Name8)
+ {
+ FShaderPipelineCreateOptions f_options = new()
+ {
+ Name = new(Name, Name8, p_name, p_name8),
+ Shader = Shader.Ptr,
+ Layout = BindingLayout.Ptr,
+ };
+ FComputeShaderPipeline* ptr;
+ Ptr->CreateComputePipeline(&f_options, &ptr).TryThrow();
+ return new(ptr, Name, Shader, BindingLayout);
+ }
+ }
+
+ #endregion
+
#region CreateSampler
public Sampler CreateSampler(
diff --git a/Coplt.Graphics.Core/Core/GpuImage.cs b/Coplt.Graphics.Core/Core/GpuImage.cs
index fd2406e..f1ef2f5 100644
--- a/Coplt.Graphics.Core/Core/GpuImage.cs
+++ b/Coplt.Graphics.Core/Core/GpuImage.cs
@@ -136,7 +136,7 @@ m_name is null
#endregion
- #region View
+ #region Try View
public bool TryRtv() => Purpose.HasFlags(ResourcePurpose.RenderTarget);
public bool TryDsv() => Purpose.HasFlags(ResourcePurpose.DepthStencil);
@@ -144,4 +144,34 @@ m_name is null
public bool TrySrv() => Purpose.HasFlags(ResourcePurpose.ShaderResource);
#endregion
+
+ #region Create View
+
+ /// Uav 忽略 NumMips
+ public View View1D(byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
+ => View.MakeImage1D(this, Mip, NumMips, Format);
+ /// Uav 忽略 NumMips
+ public View View1DArray(uint Index = 0, int Size = -1, byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
+ => View.MakeImage1DArray(this, Index, Size, Mip, NumMips, Format);
+ /// Uav 忽略 NumMips
+ public View View2D(byte Mip = 0, sbyte NumMips = -1, byte Plane = 0, GraphicsFormat Format = 0)
+ => View.MakeImage2D(this, Mip, NumMips, Plane, Format);
+ /// Uav 忽略 NumMips
+ public View View2DArray(uint Index = 0, int Size = -1, byte Mip = 0, sbyte NumMips = -1, byte Plane = 0, GraphicsFormat Format = 0)
+ => View.MakeImage2DArray(this, Index, Size, Mip, NumMips, Plane, Format);
+ public View View2DMs(GraphicsFormat Format = 0)
+ => View.MakeImage2DMs(this, Format);
+ public View View2DMsArray(uint Index = 0, int Size = -1, GraphicsFormat Format = 0)
+ => View.MakeImage2DMsArray(this, Index, Size, Format);
+ /// Uav 忽略 NumMips
+ public View View3D(uint Z = 0, int Depth = -1, byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
+ => View.MakeImage3D(this, Z, Depth, Mip, NumMips, Format);
+ /// Uav 忽略 NumMips
+ public View ViewCube(byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
+ => View.MakeImageCube(this, Mip, NumMips, Format);
+ /// Uav 忽略 NumMips
+ public View ViewCubeArray(uint Index = 0, int Size = -1, byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
+ => View.MakeImageCubeArray(this, Index, Size, Mip, NumMips, Format);
+
+ #endregion
}
diff --git a/Coplt.Graphics.Core/Core/GpuIsolate.cs b/Coplt.Graphics.Core/Core/GpuIsolate.cs
index 626ab00..514de8e 100644
--- a/Coplt.Graphics.Core/Core/GpuIsolate.cs
+++ b/Coplt.Graphics.Core/Core/GpuIsolate.cs
@@ -304,8 +304,8 @@ public ShaderBindGroup CreateBindGroup(
f_items[i] = new()
{
View = item.View.ToFFI(),
- Slot = item.Slot,
- Index = item.Index,
+ Slot = item.BindIndex,
+ Index = item.ArrayIndex,
};
}
fixed (char* p_name = Name)
@@ -421,6 +421,12 @@ public GpuImage CreateImage(
fixed (char* p_name = Name)
fixed (byte* p_name8 = Name8)
{
+ var DepthOrLength = Math.Max(options.DepthOrLength, 1);
+ if (options.Dimension == ImageDimension.Cube)
+ {
+ if (options.DepthOrLength == 0) DepthOrLength = 6;
+ if (options.DepthOrLength % 6 != 0) throw new ArgumentException("The number of cube texture arrays must be a multiple of 6");
+ }
FGpuImageCreateOptions f_options = new()
{
Base =
@@ -432,7 +438,7 @@ public GpuImage CreateImage(
Format = options.Format.ToFFI(),
Width = Math.Max(options.Width, 1),
Height = Math.Max(options.Height, 1),
- DepthOrLength = Math.Max(options.DepthOrLength, 1),
+ DepthOrLength = DepthOrLength,
MipLevels = (ushort)Math.Max(options.MipLevels, 1),
MultisampleCount = (byte)Math.Max(options.MultisampleCount, 1),
Dimension = options.Dimension.ToFFI(),
diff --git a/Coplt.Graphics.Core/Core/GpuQueue.cs b/Coplt.Graphics.Core/Core/GpuQueue.cs
deleted file mode 100644
index be24a80..0000000
--- a/Coplt.Graphics.Core/Core/GpuQueue.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Collections.Concurrent;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using Coplt.Dropping;
-using Coplt.Graphics.Native;
-using Coplt.Graphics.Utilities;
-
-namespace Coplt.Graphics.Core;
-
-public enum GpuQueueType : byte
-{
- Direct,
- Compute,
- Copy,
- VideoEncode,
- VideoDecode,
- VideoProcess,
-}
-
-public static partial class GraphicsExtensions
-{
- public static FGpuQueueType ToFFI(this GpuQueueType value) => (FGpuQueueType)value;
-
- public static GpuQueueType FromFFI(this FGpuQueueType value) => (GpuQueueType)value;
-
- public static ReadOnlySpan ToUtf8String(this GpuQueueType value) => value switch
- {
- GpuQueueType.Direct => "Direct"u8,
- GpuQueueType.Compute => "Compute"u8,
- GpuQueueType.Copy => "Copy"u8,
- GpuQueueType.VideoEncode => "VideoEncode"u8,
- GpuQueueType.VideoDecode => "VideoDecode"u8,
- GpuQueueType.VideoProcess => "VideoProcess"u8,
- _ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
- };
-}
diff --git a/Coplt.Graphics.Core/Core/GpuRecord.cs b/Coplt.Graphics.Core/Core/GpuRecord.cs
index 8baaefa..b6ac529 100644
--- a/Coplt.Graphics.Core/Core/GpuRecord.cs
+++ b/Coplt.Graphics.Core/Core/GpuRecord.cs
@@ -14,7 +14,7 @@ public sealed unsafe class GpuRecord : IsolateChild
#region Fields
internal FGpuRecordData* m_data;
- internal readonly Dictionary