Skip to content

Commit

Permalink
add buffer comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
nfginola committed May 29, 2022
1 parent c7db0a9 commit 51a407c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 12 deletions.
22 changes: 11 additions & 11 deletions DX12/DX12/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Collapsed=0
DockId=0x00000007,0

[Window][FPC Controller]
Pos=1363,0
Size=237,109
Pos=1324,0
Size=276,109
Collapsed=0
DockId=0x0000000B,0

Expand All @@ -33,14 +33,14 @@ Collapsed=0
DockId=0x00000009,0

[Window][Performance Statistics]
Pos=274,643
Size=1326,257
Pos=274,619
Size=1326,281
Collapsed=0
DockId=0x0000000A,0

[Window][Settings]
Pos=1363,111
Size=237,530
Pos=1324,111
Size=276,506
Collapsed=0
DockId=0x0000000C,0

Expand Down Expand Up @@ -70,16 +70,16 @@ DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=143,101 Size=1600,900
DockNode ID=0x0000000D Parent=0x00000012 SizeRef=337,455 Selected=0x2B345870
DockNode ID=0x0000000E Parent=0x00000012 SizeRef=337,257 Selected=0x4D230951
DockNode ID=0x00000010 Parent=0x8B93E3BD SizeRef=1326,900 Split=Y
DockNode ID=0x00000005 Parent=0x00000010 SizeRef=1600,641 Split=Y
DockNode ID=0x00000005 Parent=0x00000010 SizeRef=1600,617 Split=Y
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=1600,693 Split=X
DockNode ID=0x00000003 Parent=0x00000008 SizeRef=1087,881 Split=X
DockNode ID=0x00000003 Parent=0x00000008 SizeRef=1048,881 Split=X
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=54,881 Selected=0xE87781F4
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1230,881 CentralNode=1
DockNode ID=0x00000004 Parent=0x00000008 SizeRef=237,881 Split=Y Selected=0x5F68B3D7
DockNode ID=0x00000004 Parent=0x00000008 SizeRef=276,881 Split=Y Selected=0x5F68B3D7
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=238,353 Split=Y Selected=0x44D0BD26
DockNode ID=0x0000000B Parent=0x00000006 SizeRef=299,109 Selected=0x44D0BD26
DockNode ID=0x0000000C Parent=0x00000006 SizeRef=299,530 Selected=0x54723243
DockNode ID=0x0000000C Parent=0x00000006 SizeRef=299,506 Selected=0x54723243
DockNode ID=0x00000007 Parent=0x00000004 SizeRef=238,338 Selected=0x5F68B3D7
DockNode ID=0x00000009 Parent=0x00000005 SizeRef=1600,205 Selected=0xFB565D80
DockNode ID=0x0000000A Parent=0x00000010 SizeRef=1600,257 Selected=0xF4805BF9
DockNode ID=0x0000000A Parent=0x00000010 SizeRef=1600,281 Selected=0xF4805BF9

6 changes: 6 additions & 0 deletions DX12/DX12/src/Graphics/DX/DXBufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ void DXBufferManager::destroy_constant(InternalBufferResource* res)
m_constant_persistent_bufs[res->frame_idx_allocation]->deallocate(std::move(res->alloc));
m_handles.free_handle(res->handle);
}
else if (res->usage_cpu == UsageIntentCPU::eUpdateSometimes)
{
//m_constant_persistent_buf->deallocate(std::move(res->alloc));
m_constant_persistent_bufs[res->frame_idx_allocation]->deallocate(std::move(res->alloc));
m_handles.free_handle(res->handle);
}
else
assert(false);
}
Expand Down
55 changes: 54 additions & 1 deletion DX12/DX12/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ int main()
float scale = 0.07f;
int instance_count = 3;
bool nanosuit_on = false;
bool profile_buf_alloc = false;
bool is_sub_alloc = true;
int alloc_work = 25;
g_gui_ctx->add_persistent_ui("test", [&]()
{
ImGui::Begin("Settings");
Expand All @@ -311,6 +314,10 @@ int main()
ImGui::SliderInt("Work", &cpu_bogus_work_amount, 1, 3000);
ImGui::SliderFloat("Scale", &scale, 0.01f, 0.3f);
ImGui::Checkbox("Render Nanosuit", &nanosuit_on);
ImGui::Checkbox("Profile Buffer Allocation", &profile_buf_alloc);
ImGui::Checkbox("[X] Sub-alloc // [ ] Committed ", &is_sub_alloc);
ImGui::SliderInt("Alloc Work", &alloc_work, 1, 500);

ImGui::End();
});

Expand Down Expand Up @@ -601,7 +608,8 @@ int main()
MSG msg{};
while (g_app_running)
{





cpu_pf.frame_begin();
Expand All @@ -614,6 +622,51 @@ int main()
if (!g_app_running) // Early exit if WMs picked up by this frames pump messages
break;

// suballocation profiling
if (profile_buf_alloc)
{
cpu_pf.profile_begin("buf allocation");

if (is_sub_alloc)
{
for (int i = 0; i < alloc_work; ++i)
{
// allocate persistent suballocated memory
DXBufferDesc settings_cbd{};
settings_cbd.element_count = 1;
settings_cbd.element_size = 512;
settings_cbd.flag = BufferFlag::eConstant;
settings_cbd.usage_cpu = UsageIntentCPU::eUpdateSometimes;
settings_cbd.usage_gpu = UsageIntentGPU::eReadOncePerFrame;
auto bogus_buf = buf_mgr.create_buffer(settings_cbd);

buf_mgr.destroy_buffer(bogus_buf);
}
}
else
{

for (int i = 0; i < alloc_work; ++i)
{
DXBufferDesc scratch_d{};
scratch_d.element_count = 1;
scratch_d.element_size = 512;
scratch_d.flag = BufferFlag::eNonConstant;
scratch_d.usage_cpu = UsageIntentCPU::eUpdateNever;
scratch_d.usage_gpu = UsageIntentGPU::eWrite;
auto bogus_buf = buf_mgr.create_buffer(scratch_d); // normal UAV

buf_mgr.destroy_buffer(bogus_buf);
}
}

cpu_pf.profile_end("buf allocation");
}





g_input->frame_begin();

auto surface_idx = gfx_sc->get_curr_draw_surface();
Expand Down

0 comments on commit 51a407c

Please sign in to comment.