Skip to content

Commit cec7e9e

Browse files
authored
Merge pull request #4 from 2A5F/dev
Mipmap
2 parents 603bbf1 + cd7aed8 commit cec7e9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4376
-1157
lines changed

.idea/.idea.Coplt.Graphics/.idea/vcs.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/editor.xml

Lines changed: 216 additions & 452 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/pattern.png

1.07 MB
Loading

Coplt.Graphics.Core/Coplt.Graphics.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="Coplt.Dropping" Version="0.6.0" PrivateAssets='All' />
17-
<PackageReference Include="Coplt.Union" Version="0.15.0" PrivateAssets='All' />
17+
<PackageReference Include="Coplt.Union" Version="0.17.0" PrivateAssets='All' />
1818
<PackageReference Include="Fody" Version="6.9.2">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Coplt.Graphics.Native;
2+
using Coplt.Graphics.States;
3+
4+
namespace Coplt.Graphics.Core;
5+
6+
public sealed unsafe class ComputeShaderPipeline : ShaderPipeline
7+
{
8+
#region Props
9+
10+
public new FComputeShaderPipeline* Ptr => (FComputeShaderPipeline*)m_ptr;
11+
12+
#endregion
13+
14+
#region Ctor
15+
16+
internal ComputeShaderPipeline(
17+
FComputeShaderPipeline* ptr, string? name,
18+
Shader shader, ShaderBindingLayout binding_layout
19+
) : base((FShaderPipeline*)ptr, name, shader, binding_layout) { }
20+
21+
#endregion
22+
}

Coplt.Graphics.Core/Core/GpuBuffer.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ m_name is null
6969

7070
#endregion
7171

72-
#region View
72+
#region Try View
7373

7474
public bool TryVbv() => Purpose.HasFlags(ResourcePurpose.VertexBuffer);
7575
public bool TryIbv() => Purpose.HasFlags(ResourcePurpose.IndexBuffer);
@@ -80,6 +80,13 @@ m_name is null
8080

8181
#endregion
8282

83+
#region Create View
84+
85+
public View View(ulong Offset = 0, int Size = -1, int Stride = -1, GraphicsFormat Format = 0) =>
86+
Core.View.MakeBuffer(this, Offset, Size, Stride, Format);
87+
88+
#endregion
89+
8390
#region Map UnMap
8491

8592
public void* Map() => Map(CpuAccess != CpuAccess.Read);

Coplt.Graphics.Core/Core/GpuDevice.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,34 @@ public GraphicsShaderPipeline CreateGraphicsShaderPipeline(
382382

383383
#endregion
384384

385+
#region CreateComputeShaderPipeline
386+
387+
public ComputeShaderPipeline CreateComputeShaderPipeline(
388+
Shader Shader, string? Name = null, ReadOnlySpan<byte> Name8 = default
389+
) => CreateComputeShaderPipeline(Shader, Shader.Layout.GetEmptyBindingLayout(), Name, Name8);
390+
391+
public ComputeShaderPipeline CreateComputeShaderPipeline(
392+
Shader Shader, ShaderBindingLayout BindingLayout,
393+
string? Name = null, ReadOnlySpan<byte> Name8 = default
394+
)
395+
{
396+
fixed (char* p_name = Name)
397+
fixed (byte* p_name8 = Name8)
398+
{
399+
FShaderPipelineCreateOptions f_options = new()
400+
{
401+
Name = new(Name, Name8, p_name, p_name8),
402+
Shader = Shader.Ptr,
403+
Layout = BindingLayout.Ptr,
404+
};
405+
FComputeShaderPipeline* ptr;
406+
Ptr->CreateComputePipeline(&f_options, &ptr).TryThrow();
407+
return new(ptr, Name, Shader, BindingLayout);
408+
}
409+
}
410+
411+
#endregion
412+
385413
#region CreateSampler
386414

387415
public Sampler CreateSampler(

Coplt.Graphics.Core/Core/GpuImage.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,42 @@ m_name is null
136136

137137
#endregion
138138

139-
#region View
139+
#region Try View
140140

141141
public bool TryRtv() => Purpose.HasFlags(ResourcePurpose.RenderTarget);
142142
public bool TryDsv() => Purpose.HasFlags(ResourcePurpose.DepthStencil);
143143
public bool TryUav() => Purpose.HasFlags(ResourcePurpose.UnorderedAccess);
144144
public bool TrySrv() => Purpose.HasFlags(ResourcePurpose.ShaderResource);
145145

146146
#endregion
147+
148+
#region Create View
149+
150+
/// <summary>Uav 忽略 NumMips</summary>
151+
public View View1D(byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
152+
=> View.MakeImage1D(this, Mip, NumMips, Format);
153+
/// <summary>Uav 忽略 NumMips</summary>
154+
public View View1DArray(uint Index = 0, int Size = -1, byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
155+
=> View.MakeImage1DArray(this, Index, Size, Mip, NumMips, Format);
156+
/// <summary>Uav 忽略 NumMips</summary>
157+
public View View2D(byte Mip = 0, sbyte NumMips = -1, byte Plane = 0, GraphicsFormat Format = 0)
158+
=> View.MakeImage2D(this, Mip, NumMips, Plane, Format);
159+
/// <summary>Uav 忽略 NumMips</summary>
160+
public View View2DArray(uint Index = 0, int Size = -1, byte Mip = 0, sbyte NumMips = -1, byte Plane = 0, GraphicsFormat Format = 0)
161+
=> View.MakeImage2DArray(this, Index, Size, Mip, NumMips, Plane, Format);
162+
public View View2DMs(GraphicsFormat Format = 0)
163+
=> View.MakeImage2DMs(this, Format);
164+
public View View2DMsArray(uint Index = 0, int Size = -1, GraphicsFormat Format = 0)
165+
=> View.MakeImage2DMsArray(this, Index, Size, Format);
166+
/// <summary>Uav 忽略 NumMips</summary>
167+
public View View3D(uint Z = 0, int Depth = -1, byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
168+
=> View.MakeImage3D(this, Z, Depth, Mip, NumMips, Format);
169+
/// <summary>Uav 忽略 NumMips</summary>
170+
public View ViewCube(byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
171+
=> View.MakeImageCube(this, Mip, NumMips, Format);
172+
/// <summary>Uav 忽略 NumMips</summary>
173+
public View ViewCubeArray(uint Index = 0, int Size = -1, byte Mip = 0, sbyte NumMips = -1, GraphicsFormat Format = 0)
174+
=> View.MakeImageCubeArray(this, Index, Size, Mip, NumMips, Format);
175+
176+
#endregion
147177
}

Coplt.Graphics.Core/Core/GpuIsolate.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ public ShaderBindGroup CreateBindGroup(
304304
f_items[i] = new()
305305
{
306306
View = item.View.ToFFI(),
307-
Slot = item.Slot,
308-
Index = item.Index,
307+
Slot = item.BindIndex,
308+
Index = item.ArrayIndex,
309309
};
310310
}
311311
fixed (char* p_name = Name)
@@ -421,6 +421,12 @@ public GpuImage CreateImage(
421421
fixed (char* p_name = Name)
422422
fixed (byte* p_name8 = Name8)
423423
{
424+
var DepthOrLength = Math.Max(options.DepthOrLength, 1);
425+
if (options.Dimension == ImageDimension.Cube)
426+
{
427+
if (options.DepthOrLength == 0) DepthOrLength = 6;
428+
if (options.DepthOrLength % 6 != 0) throw new ArgumentException("The number of cube texture arrays must be a multiple of 6");
429+
}
424430
FGpuImageCreateOptions f_options = new()
425431
{
426432
Base =
@@ -432,7 +438,7 @@ public GpuImage CreateImage(
432438
Format = options.Format.ToFFI(),
433439
Width = Math.Max(options.Width, 1),
434440
Height = Math.Max(options.Height, 1),
435-
DepthOrLength = Math.Max(options.DepthOrLength, 1),
441+
DepthOrLength = DepthOrLength,
436442
MipLevels = (ushort)Math.Max(options.MipLevels, 1),
437443
MultisampleCount = (byte)Math.Max(options.MultisampleCount, 1),
438444
Dimension = options.Dimension.ToFFI(),

Coplt.Graphics.Core/Core/GpuQueue.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)