Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.idea.Coplt.Graphics/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

668 changes: 216 additions & 452 deletions .idea/editor.xml

Large diffs are not rendered by default.

Binary file added Assets/pattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Coplt.Graphics.Core/Coplt.Graphics.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Coplt.Dropping" Version="0.6.0" PrivateAssets='All' />
<PackageReference Include="Coplt.Union" Version="0.15.0" PrivateAssets='All' />
<PackageReference Include="Coplt.Union" Version="0.17.0" PrivateAssets='All' />
<PackageReference Include="Fody" Version="6.9.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
22 changes: 22 additions & 0 deletions Coplt.Graphics.Core/Core/ComputeShaderPipeline.cs
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 8 additions & 1 deletion Coplt.Graphics.Core/Core/GpuBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions Coplt.Graphics.Core/Core/GpuDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,34 @@ public GraphicsShaderPipeline CreateGraphicsShaderPipeline(

#endregion

#region CreateComputeShaderPipeline

public ComputeShaderPipeline CreateComputeShaderPipeline(
Shader Shader, string? Name = null, ReadOnlySpan<byte> Name8 = default
) => CreateComputeShaderPipeline(Shader, Shader.Layout.GetEmptyBindingLayout(), Name, Name8);

public ComputeShaderPipeline CreateComputeShaderPipeline(
Shader Shader, ShaderBindingLayout BindingLayout,
string? Name = null, ReadOnlySpan<byte> 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(
Expand Down
32 changes: 31 additions & 1 deletion Coplt.Graphics.Core/Core/GpuImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,42 @@ m_name is null

#endregion

#region View
#region Try View

public bool TryRtv() => Purpose.HasFlags(ResourcePurpose.RenderTarget);
public bool TryDsv() => Purpose.HasFlags(ResourcePurpose.DepthStencil);
public bool TryUav() => Purpose.HasFlags(ResourcePurpose.UnorderedAccess);
public bool TrySrv() => Purpose.HasFlags(ResourcePurpose.ShaderResource);

#endregion

#region Create View

/// <summary>Uav 忽略 NumMips</summary>
public View View1D(byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
=> View.MakeImage1D(this, Mip, NumMips, Format);
/// <summary>Uav 忽略 NumMips</summary>
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);
/// <summary>Uav 忽略 NumMips</summary>
public View View2D(byte Mip = 0, sbyte NumMips = -1, byte Plane = 0, GraphicsFormat Format = 0)
=> View.MakeImage2D(this, Mip, NumMips, Plane, Format);
/// <summary>Uav 忽略 NumMips</summary>
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);
/// <summary>Uav 忽略 NumMips</summary>
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);
/// <summary>Uav 忽略 NumMips</summary>
public View ViewCube(byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
=> View.MakeImageCube(this, Mip, NumMips, Format);
/// <summary>Uav 忽略 NumMips</summary>
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
}
12 changes: 9 additions & 3 deletions Coplt.Graphics.Core/Core/GpuIsolate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand All @@ -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(),
Expand Down
36 changes: 0 additions & 36 deletions Coplt.Graphics.Core/Core/GpuQueue.cs

This file was deleted.

Loading
Loading