Skip to content

Commit 22e624f

Browse files
committed
save
1 parent ea1d56a commit 22e624f

File tree

8 files changed

+200
-47
lines changed

8 files changed

+200
-47
lines changed

Coplt.Graphics.Core/Core/CommandList.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ public RenderScope Render(
10101010
for (var i = 0; i < Info.Rtvs.Length; i++)
10111011
{
10121012
ref readonly var rtv = ref Info.Rtvs[i];
1013-
if (!rtv.View.Size.Equals(rt_size))
1013+
if (!rtv.View.Size2d.Equals(rt_size))
10141014
throw new ArgumentException("RenderTargets And DepthStencil must be the same size");
10151015
info.Rtv[i] = AddResource(rtv.View.Resource);
10161016
info.ResolveInfoIndex[i] = uint.MaxValue; // todo
@@ -1118,8 +1118,7 @@ public ComputeScope Compute(string? Name = null, ReadOnlySpan<byte> Name8 = defa
11181118
InfoIndex = (uint)info_index,
11191119
CommandStartIndex = (uint)m_compute_commands.Count,
11201120
};
1121-
m_commands.Add(new() { Compute = cmd });
1122-
return new(this, info_index, m_compute_commands.Count, m_compute_commands, debug_scope);
1121+
return new(this, info_index, cmd, m_compute_commands, debug_scope);
11231122

11241123
#endregion
11251124
}
@@ -1300,13 +1299,15 @@ bool debug_scope
13001299
{
13011300
#region Fields
13021301

1302+
private FCommandRender render_cmd = render_cmd;
13031303
private ShaderPipeline? m_current_pipeline;
13041304
private ShaderBinding? m_current_binding;
13051305
private bool m_disposed;
13061306
private bool m_has_pixel_shader;
13071307
private bool m_has_vertex_shader;
13081308
private bool m_has_mesh_shader;
13091309
private bool m_has_task_shader;
1310+
private bool m_has_uav_writes;
13101311

13111312
#endregion
13121313

@@ -1327,6 +1328,7 @@ public void Dispose()
13271328
"There is still Debug scope not ended, please check whether Dispose is missed."
13281329
);
13291330
ref var info = ref Info;
1331+
info.HasUavWrites = m_has_uav_writes;
13301332
if (self.AutoBarrierEnabled)
13311333
{
13321334
var stages = m_has_pixel_shader ? FShaderStageFlags.Pixel : FShaderStageFlags.None;
@@ -1353,9 +1355,8 @@ public void Dispose()
13531355
);
13541356
}
13551357
}
1358+
render_cmd.CommandCount = (uint)m_commands.Count - render_cmd.CommandStartIndex;
13561359
self.m_commands.Add(new() { Render = render_cmd });
1357-
Info.CommandCount = (uint)m_commands.Count - render_cmd.CommandStartIndex;
1358-
self.m_render_commands.Add(new() { Type = FCommandType.End });
13591360
self.m_in_render_or_compute_scope = false;
13601361
if (debug_scope) new DebugScope(self).Dispose();
13611362
}
@@ -1686,13 +1687,14 @@ public void DispatchMesh(
16861687
public unsafe struct ComputeScope(
16871688
CommandList self,
16881689
int info_index,
1689-
int cmd_index,
1690+
FCommandCompute compute_cmd,
16901691
List<FComputeCommandItem> m_commands,
16911692
bool debug_scope
16921693
) : IDisposable
16931694
{
16941695
#region Fields
16951696

1697+
private FCommandCompute compute_cmd = compute_cmd;
16961698
private ShaderPipeline? m_current_pipeline;
16971699
private ShaderBinding? m_current_binding;
16981700
private bool m_disposed;
@@ -1715,8 +1717,8 @@ public void Dispose()
17151717
throw new InvalidOperationException(
17161718
"There is still Debug scope not ended, please check whether Dispose is missed."
17171719
);
1718-
Info.CommandCount = (uint)m_commands.Count - (uint)cmd_index;
1719-
self.m_compute_commands.Add(new() { Type = FCommandType.End });
1720+
compute_cmd.CommandCount = (uint)m_commands.Count - compute_cmd.CommandStartIndex;
1721+
self.m_commands.Add(new() { Compute = compute_cmd });
17201722
self.m_in_render_or_compute_scope = false;
17211723
if (debug_scope) new DebugScope(self).Dispose();
17221724
}

Coplt.Graphics.Core/Native/Native.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,7 +2661,6 @@ public partial struct FResState
26612661
public enum FCommandType : uint
26622662
{
26632663
None,
2664-
End,
26652664
Label,
26662665
BeginScope,
26672666
EndScope,
@@ -2691,7 +2690,7 @@ public enum FResourceRefType : byte
26912690

26922691
public unsafe partial struct FResourceMeta
26932692
{
2694-
[NativeTypeName("__AnonymousRecord_Command_L62_C9")]
2693+
[NativeTypeName("__AnonymousRecord_Command_L60_C9")]
26952694
public _Anonymous_e__Union Anonymous;
26962695

26972696
[NativeTypeName("Coplt::FResourceRefType")]
@@ -2860,7 +2859,7 @@ public partial struct FBarrier
28602859
[NativeTypeName("Coplt::FBarrierType")]
28612860
public FBarrierType Type;
28622861

2863-
[NativeTypeName("__AnonymousRecord_Command_L168_C9")]
2862+
[NativeTypeName("__AnonymousRecord_Command_L166_C9")]
28642863
public _Anonymous_e__Union Anonymous;
28652864

28662865
[UnscopedRef]
@@ -3047,9 +3046,6 @@ public enum FStoreOp : byte
30473046

30483047
public partial struct FRenderInfo
30493048
{
3050-
[NativeTypeName("Coplt::u32")]
3051-
public uint CommandCount;
3052-
30533049
[NativeTypeName("Coplt::FResourceRef")]
30543050
public FResourceRef Dsv;
30553051

@@ -3083,6 +3079,9 @@ public partial struct FRenderInfo
30833079
[NativeTypeName("FStoreOp[8]")]
30843080
public _RtvStoreOp_e__FixedBuffer RtvStoreOp;
30853081

3082+
[NativeTypeName("Coplt::b8")]
3083+
public B8 HasUavWrites;
3084+
30863085
[InlineArray(8)]
30873086
public partial struct _Rtv_e__FixedBuffer
30883087
{
@@ -3128,8 +3127,6 @@ public partial struct _RtvStoreOp_e__FixedBuffer
31283127

31293128
public partial struct FComputeInfo
31303129
{
3131-
[NativeTypeName("Coplt::u32")]
3132-
public uint CommandCount;
31333130
}
31343131

31353132
public partial struct FBufferRange
@@ -3356,6 +3353,9 @@ public partial struct FCommandRender
33563353

33573354
[NativeTypeName("Coplt::u32")]
33583355
public uint CommandStartIndex;
3356+
3357+
[NativeTypeName("Coplt::u32")]
3358+
public uint CommandCount;
33593359
}
33603360

33613361
[NativeTypeName("struct FCommandCompute : Coplt::FCommandBase")]
@@ -3368,6 +3368,9 @@ public partial struct FCommandCompute
33683368

33693369
[NativeTypeName("Coplt::u32")]
33703370
public uint CommandStartIndex;
3371+
3372+
[NativeTypeName("Coplt::u32")]
3373+
public uint CommandCount;
33713374
}
33723375

33733376
[NativeTypeName("struct FCommandSetPipeline : Coplt::FCommandBase")]
@@ -3465,7 +3468,7 @@ public partial struct FCommandDispatch
34653468

34663469
public partial struct FCommandItem
34673470
{
3468-
[NativeTypeName("__AnonymousRecord_Command_L490_C9")]
3471+
[NativeTypeName("__AnonymousRecord_Command_L489_C9")]
34693472
public _Anonymous_e__Union Anonymous;
34703473

34713474
[UnscopedRef]
@@ -3663,7 +3666,7 @@ public partial struct __pad_e__FixedBuffer
36633666

36643667
public partial struct FRenderCommandItem
36653668
{
3666-
[NativeTypeName("__AnonymousRecord_Command_L518_C9")]
3669+
[NativeTypeName("__AnonymousRecord_Command_L517_C9")]
36673670
public _Anonymous_e__Union Anonymous;
36683671

36693672
[UnscopedRef]
@@ -3833,7 +3836,7 @@ public partial struct __pad_e__FixedBuffer
38333836

38343837
public partial struct FComputeCommandItem
38353838
{
3836-
[NativeTypeName("__AnonymousRecord_Command_L541_C9")]
3839+
[NativeTypeName("__AnonymousRecord_Command_L540_C9")]
38373840
public _Anonymous_e__Union Anonymous;
38383841

38393842
[UnscopedRef]

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace Coplt
1111
enum class FCommandType : u32
1212
{
1313
None,
14-
// Render / Compute
15-
End,
1614

1715
Label,
1816
BeginScope,
@@ -266,7 +264,6 @@ namespace Coplt
266264

267265
struct FRenderInfo
268266
{
269-
u32 CommandCount{};
270267
// 可选
271268
FResourceRef Dsv{};
272269
u32 NumRtv{};
@@ -280,11 +277,11 @@ namespace Coplt
280277
FStoreOp DsvStoreOp[2]{};
281278
FLoadOp RtvLoadOp[8]{};
282279
FStoreOp RtvStoreOp[8]{};
280+
b8 HasUavWrites{};
283281
};
284282

285283
struct FComputeInfo
286284
{
287-
u32 CommandCount{};
288285
};
289286

290287
struct FBufferRange
@@ -418,13 +415,15 @@ namespace Coplt
418415
// 类型为 FRenderInfo
419416
u32 InfoIndex{};
420417
u32 CommandStartIndex{};
418+
u32 CommandCount{};
421419
};
422420

423421
struct FCommandCompute : FCommandBase
424422
{
425423
// 类型为 FComputeInfo
426424
u32 InfoIndex{};
427425
u32 CommandStartIndex{};
426+
u32 CommandCount{};
428427
};
429428

430429
////////////////////////////////////////////////////////////////////////////////////////////////////

Coplt.Graphics.Native/D3d12/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ add_library(${target_name} SHARED
5151
set_target_properties(${target_name} PROPERTIES LINKER_LANGUAGE CXX)
5252
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME "Coplt.Graphics.Native.D3d12")
5353
add_library(Coplt::Graphics::D3d12 ALIAS ${target_name})
54-
target_compile_definitions(${target_name} PRIVATE -DFFI_SRC -DNOMINMAX)
54+
target_compile_definitions(${target_name} PRIVATE -DFFI_SRC -DNOMINMAX -DUSE_PIX)
5555
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/WinPixEventRuntime/Include/WinPixEventRuntime)
5656

5757
set(BUILD_XAUDIO_WIN10 OFF)

Coplt.Graphics.Native/D3d12/Include/PipelineState.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,24 @@ namespace Coplt
236236
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
237237
}
238238
}
239+
240+
inline D3D12_RESOLVE_MODE ToDx(const FResolveMode value)
241+
{
242+
switch (value)
243+
{
244+
case FResolveMode::Decompress:
245+
return D3D12_RESOLVE_MODE_DECOMPRESS;
246+
break;
247+
case FResolveMode::Min:
248+
return D3D12_RESOLVE_MODE_MIN;
249+
break;
250+
case FResolveMode::Max:
251+
return D3D12_RESOLVE_MODE_MAX;
252+
break;
253+
case FResolveMode::Average:
254+
return D3D12_RESOLVE_MODE_AVERAGE;
255+
break;
256+
}
257+
return D3D12_RESOLVE_MODE_DECOMPRESS;
258+
}
239259
}

0 commit comments

Comments
 (0)