Skip to content

Commit 30238bf

Browse files
committed
readme
1 parent eee6de5 commit 30238bf

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

Coplt.Graphics.Core/Core/ShaderLayout.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
namespace Coplt.Graphics.Core;
66

7+
public enum ResourceAccess : byte
8+
{
9+
Unknown,
10+
ReadOnly,
11+
WriteOnly,
12+
ReadWrite,
13+
}
14+
715
public enum ShaderLayoutItemView : byte
816
{
917
Cbv,
@@ -71,6 +79,7 @@ public unsafe record struct ShaderLayoutItemDefine
7179
public ShaderLayoutItemView View;
7280
public ShaderLayoutItemType Type;
7381
public ShaderLayoutItemUsage Usage;
82+
public ResourceAccess UavAccess;
7483

7584
static ShaderLayoutItemDefine()
7685
{

Coplt.Graphics.Core/Native/Native.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,6 +4122,15 @@ public partial struct __pad_e__FixedBuffer
41224122
}
41234123
}
41244124

4125+
[NativeTypeName("Coplt::u8")]
4126+
public enum FResourceAccess : byte
4127+
{
4128+
Unknown,
4129+
ReadOnly,
4130+
WriteOnly,
4131+
ReadWrite,
4132+
}
4133+
41254134
[NativeTypeName("Coplt::u8")]
41264135
public enum FShaderLayoutItemView : byte
41274136
{
@@ -4202,6 +4211,9 @@ public partial struct FShaderLayoutItemDefine
42024211

42034212
[NativeTypeName("Coplt::FShaderLayoutItemUsage")]
42044213
public FShaderLayoutItemUsage Usage;
4214+
4215+
[NativeTypeName("Coplt::FResourceAccess")]
4216+
public FResourceAccess UavAccess;
42054217
}
42064218

42074219
[NativeTypeName("Coplt::u8")]

Coplt.Graphics.Native/Api/FFI/Layout.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
namespace Coplt
1111
{
12+
enum class FResourceAccess : u8
13+
{
14+
Unknown,
15+
ReadOnly,
16+
WriteOnly,
17+
ReadWrite,
18+
};
19+
1220
enum class FShaderLayoutItemView : u8
1321
{
1422
Cbv,
@@ -94,6 +102,7 @@ namespace Coplt
94102
FShaderLayoutItemView View{};
95103
FShaderLayoutItemType Type{};
96104
FShaderLayoutItemUsage Usage{};
105+
FResourceAccess UavAccess{};
97106

98107
#ifdef FFI_SRC
99108
bool IsAllowBuffer() const

Examples/Colorful/Colorful.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ Layout = Device.CreateShaderLayout(
2929
[
3030
new()
3131
{
32-
Slot = 0,
33-
Stage = ShaderStage.Pixel,
34-
View = ShaderLayoutItemView.Cbv,
35-
Type = ShaderLayoutItemType.ConstantBuffer,
36-
Usage = ShaderLayoutItemUsage.Persist,
32+
Slot = 0, // Dx: hlsl register; Vk: binding or push const offset when View is Constants
33+
Stage = ShaderStage.Pixel, // Can only be bound to a single shader stage
34+
View = ShaderLayoutItemView.Cbv, // View type, Cbv Srv Uav Sampler Constants
35+
Type = ShaderLayoutItemType.ConstantBuffer, // Resource type, use hlsl style, ConstantBuffer StructureBuffer Texture2D etc
36+
Usage = ShaderLayoutItemUsage.Persist, // Resource binding change frequency
37+
// Dynamic: may change every frame
38+
// Persist:rarely changes, such as material parameters
39+
// Instant:only buffer and sampler, when buffer mean may change every draw, when sampler it is static sampler
40+
// View type is Constants will ignore Usage
41+
UavAccess: ResourceAccess.Unknown, // Unknown ReadOnly WriteOnly ReadWrite
42+
// Not necessary, can optimize automatic barriers
3743
}
3844
],
3945
Name: Name

0 commit comments

Comments
 (0)