Skip to content

Commit 3346544

Browse files
committed
Examples: Fix batch files (amend b1a18d8, ocornut#3513), standardize them + DirectX12: Move ImGui::Render() call above the first barrier to clarify its lack of effect on the graphics pipe.
1 parent 17536f9 commit 3346544

File tree

15 files changed

+101
-52
lines changed

15 files changed

+101
-52
lines changed

backends/imgui_impl_dx12.cpp

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

88
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
99
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
10-
// This define is done in the example .vcxproj file and need to be replicated in your app (by e.g. editing imconfig.h)
10+
// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file.
1111

1212
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
1313
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.

backends/imgui_impl_dx12.h

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

88
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
99
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
10-
// This define is done in the example .vcxproj file and need to be replicated in your app (by e.g. editing imconfig.h)
10+
// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file.
1111

1212
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
1313
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Other Changes:
112112
- Examples: Apple+Metal: Consolidated/simplified to get closer to other examples. (#3543) [@warrenm]
113113
- Examples: Apple+Metal: Forward events down so OS key combination like Cmd+Q can work. (#3554) [@rokups]
114114
- Examples: Emscripten: Renamed example_emscripten/ to example_emscripten_opengl3/. (#3632)
115+
- Examples: DirectX12: Move ImGui::Render() call above the first barrier to clarify its lack of effect on the graphics pipe.
115116
- CI: Fix testing for Windows DLL builds. (#3603, #3601) [@iboB]
116117
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md improved them.
117118
- Docs: Consistently renamed all occurences of "binding" and "back-end" to "backend" in comments and docs.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
mkdir Debug
3-
cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include *.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_opengl2.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_glfw_opengl2
4+
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
7+
mkdir %OUT_DIR%
8+
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
mkdir Debug
3-
cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I ..\libs\gl3w *.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/example_glfw_opengl3.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_glfw_opengl3
4+
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I..\libs\gl3w
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c
6+
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib
7+
mkdir %OUT_DIR%
8+
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
22

3-
mkdir Debug
4-
cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
3+
@set OUT_EXE=example_glfw_vulkan
4+
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
57

6-
mkdir Release
7-
cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
8+
@set OUT_DIR=Debug
9+
mkdir %OUT_DIR%
10+
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
11+
12+
@set OUT_DIR=Release
13+
mkdir %OUT_DIR%
14+
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
@REM Build for Visual Studio compiler. Run your copy of amd64/vcvars32.bat to setup 64-bit command-line compiler.
22

3-
mkdir Debug
4-
cl /nologo /Zi /MD /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeDebug/example_glfw_vulkan.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
3+
@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include
4+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp
5+
@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
56

6-
mkdir Release
7-
cl /nologo /Zi /MD /Ox /Oi /I .. /I ..\.. /I ..\libs\glfw\include /I %VULKAN_SDK%\include *.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp /FeRelease/example_glfw_vulkan.exe /FoRelease/ /link /LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib
7+
@set OUT_DIR=Debug
8+
mkdir %OUT_DIR%
9+
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
10+
11+
@set OUT_DIR=Release
12+
mkdir %OUT_DIR%
13+
cl /nologo /Zi /MD /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
set OUT_DIR=Debug
3-
set OUT_EXE=example_sdl_directx11
4-
set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
5-
set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp
6-
set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_sdl_directx11
4+
@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
77
mkdir %OUT_DIR%
88
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
set OUT_DIR=Debug
3-
set OUT_EXE=example_sdl_opengl2
4-
set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include
5-
set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp
6-
set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_sdl_opengl2
4+
@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib
77
mkdir %OUT_DIR%
88
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
set OUT_DIR=Debug
3-
set OUT_EXE=example_sdl_opengl3
4-
set INCLUDES=/I.. /I..\.. /I%SDL2_DIR%\include /I..\libs\gl3w
5-
set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c
6-
set LIBS=/libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_sdl_opengl3
4+
@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include /I..\libs\gl3w
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c
6+
@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib
77
mkdir %OUT_DIR%
88
cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
mkdir Debug
3-
cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\backends\imgui_impl_dx10.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx10.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib
4-
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_win32_directx10
4+
@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\backends\imgui_impl_dx10.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib
7+
mkdir %OUT_DIR%
8+
cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
mkdir Debug
3-
cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx11.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_win32_directx11
4+
@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
7+
mkdir %OUT_DIR%
8+
cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
49

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
22
@REM Important: to build on 32-bit systems, the DX12 backends needs '#define ImTextureID ImU64', so we pass it here.
3+
@set OUT_DIR=Debug
4+
@set OUT_EXE=example_win32_directx12
5+
@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared"
6+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx12.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
7+
@set LIBS=d3d12.lib d3dcompiler.lib dxgi.lib
38
mkdir Debug
4-
cl /nologo /Zi /MD /I .. /I ..\.. /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /D ImTextureID=ImU64 /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_dx12.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx12.exe /FoDebug/ /link d3d12.lib d3dcompiler.lib dxgi.lib
5-
9+
cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%

examples/example_win32_directx12/main.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Dear ImGui: standalone example application for DirectX 12
22
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
33
// Read online: https://github.com/ocornut/imgui/tree/master/docs
4-
// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
4+
5+
// Important: to compile on 32-bit systems, the DirectX12 backend requires code to be compiled with '#define ImTextureID ImU64'.
6+
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
7+
// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file.
58

69
#include "imgui.h"
710
#include "imgui_impl_win32.h"
@@ -173,9 +176,11 @@ int main(int, char**)
173176
}
174177

175178
// Rendering
176-
FrameContext* frameCtxt = WaitForNextFrameResources();
179+
ImGui::Render();
180+
181+
FrameContext* frameCtx = WaitForNextFrameResources();
177182
UINT backBufferIdx = g_pSwapChain->GetCurrentBackBufferIndex();
178-
frameCtxt->CommandAllocator->Reset();
183+
frameCtx->CommandAllocator->Reset();
179184

180185
D3D12_RESOURCE_BARRIER barrier = {};
181186
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
@@ -184,13 +189,13 @@ int main(int, char**)
184189
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
185190
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
186191
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
187-
188-
g_pd3dCommandList->Reset(frameCtxt->CommandAllocator, NULL);
192+
g_pd3dCommandList->Reset(frameCtx->CommandAllocator, NULL);
189193
g_pd3dCommandList->ResourceBarrier(1, &barrier);
194+
195+
// Render Dear ImGui graphics
190196
g_pd3dCommandList->ClearRenderTargetView(g_mainRenderTargetDescriptor[backBufferIdx], (float*)&clear_color, 0, NULL);
191197
g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL);
192198
g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap);
193-
ImGui::Render();
194199
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), g_pd3dCommandList);
195200
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
196201
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
@@ -205,10 +210,12 @@ int main(int, char**)
205210
UINT64 fenceValue = g_fenceLastSignaledValue + 1;
206211
g_pd3dCommandQueue->Signal(g_fence, fenceValue);
207212
g_fenceLastSignaledValue = fenceValue;
208-
frameCtxt->FenceValue = fenceValue;
213+
frameCtx->FenceValue = fenceValue;
209214
}
210215

211216
WaitForLastSubmittedFrame();
217+
218+
// Cleanup
212219
ImGui_ImplDX12_Shutdown();
213220
ImGui_ImplWin32_Shutdown();
214221
ImGui::DestroyContext();
@@ -382,13 +389,13 @@ void CleanupRenderTarget()
382389

383390
void WaitForLastSubmittedFrame()
384391
{
385-
FrameContext* frameCtxt = &g_frameContext[g_frameIndex % NUM_FRAMES_IN_FLIGHT];
392+
FrameContext* frameCtx = &g_frameContext[g_frameIndex % NUM_FRAMES_IN_FLIGHT];
386393

387-
UINT64 fenceValue = frameCtxt->FenceValue;
394+
UINT64 fenceValue = frameCtx->FenceValue;
388395
if (fenceValue == 0)
389396
return; // No fence was signaled
390397

391-
frameCtxt->FenceValue = 0;
398+
frameCtx->FenceValue = 0;
392399
if (g_fence->GetCompletedValue() >= fenceValue)
393400
return;
394401

@@ -404,19 +411,19 @@ FrameContext* WaitForNextFrameResources()
404411
HANDLE waitableObjects[] = { g_hSwapChainWaitableObject, NULL };
405412
DWORD numWaitableObjects = 1;
406413

407-
FrameContext* frameCtxt = &g_frameContext[nextFrameIndex % NUM_FRAMES_IN_FLIGHT];
408-
UINT64 fenceValue = frameCtxt->FenceValue;
414+
FrameContext* frameCtx = &g_frameContext[nextFrameIndex % NUM_FRAMES_IN_FLIGHT];
415+
UINT64 fenceValue = frameCtx->FenceValue;
409416
if (fenceValue != 0) // means no fence was signaled
410417
{
411-
frameCtxt->FenceValue = 0;
418+
frameCtx->FenceValue = 0;
412419
g_fence->SetEventOnCompletion(fenceValue, g_fenceEvent);
413420
waitableObjects[1] = g_fenceEvent;
414421
numWaitableObjects = 2;
415422
}
416423

417424
WaitForMultipleObjects(numWaitableObjects, waitableObjects, TRUE, INFINITE);
418425

419-
return frameCtxt;
426+
return frameCtx;
420427
}
421428

422429
void ResizeSwapChain(HWND hWnd, int width, int height)
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
2-
mkdir Debug
3-
cl /nologo /Zi /MD /I .. /I ..\.. /I "%DXSDK_DIR%/Include" /D UNICODE /D _UNICODE *.cpp ..\..\backends\imgui_impl_dx9.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp /FeDebug/example_win32_directx9.exe /FoDebug/ /link /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib
2+
@set OUT_DIR=Debug
3+
@set OUT_EXE=example_win32_directx9
4+
@set INCLUDES=/I..\.. /I..\..\backends /I "%DXSDK_DIR%/Include"
5+
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx9.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
6+
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib
7+
mkdir %OUT_DIR%
8+
cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%

0 commit comments

Comments
 (0)