This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository direct3d.
View the commit online.
commit d03561675ae6cc9ad024cef7b8f6ee5ce69a2728
Author: Vincent Torri <[email protected]>
AuthorDate: Thu Jul 28 16:53:49 2022 +0200
improve d3d debugging
---
src/.gitignore | 2 ++
src/d3d_0.c | 6 +++---
src/d3d_1.c | 31 ++++++++++++++++++++-----------
src/d3d_2.c | 31 ++++++++++++++++++++-----------
src/d3d_3.c | 31 ++++++++++++++++++++-----------
src/d3d_4.c | 31 ++++++++++++++++++++-----------
src/d3d_5.c | 31 ++++++++++++++++++++-----------
7 files changed, 105 insertions(+), 58 deletions(-)
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..8023132
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,2 @@
+*.exe
+*~
diff --git a/src/d3d_0.c b/src/d3d_0.c
index 074fe12..d5e7910 100644
--- a/src/d3d_0.c
+++ b/src/d3d_0.c
@@ -9,9 +9,9 @@
/* C API for d3d11 */
#define COBJMACROS
-#include <dxgi1_3.h>
-#include <d3d11.h>
-#include <d3dcompiler.h>
+#include <dxgi1_3.h> /* DXGI interface */
+#include <d3d11.h> /* D3D11 interface */
+#include <d3dcompiler.h> /* compilation of shader */
#include "win.h"
diff --git a/src/d3d_1.c b/src/d3d_1.c
index fd24755..e8e6eb3 100644
--- a/src/d3d_1.c
+++ b/src/d3d_1.c
@@ -9,9 +9,9 @@
/* C API for d3d11 */
#define COBJMACROS
-#include <dxgi1_3.h>
-#include <d3d11.h>
-#include <d3dcompiler.h>
+#include <dxgi1_3.h> /* DXGI interface */
+#include <d3d11.h> /* D3D11 interface */
+#include <d3dcompiler.h> /* compilation of shader */
#include "win.h"
@@ -30,6 +30,9 @@ struct D3d
IDXGISwapChain1 *dxgi_swapchain;
/* D3D11 */
ID3D11Device *d3d_device;
+#ifdef _DEBUG
+ ID3D11Debug *d3d_debug;
+#endif
ID3D11DeviceContext *d3d_device_ctx;
ID3D11RenderTargetView *d3d_render_target_view;
ID3D11InputLayout *d3d_input_layout;
@@ -177,6 +180,13 @@ D3d *d3d_init(Window *win, int vsync)
if (FAILED(res))
goto release_dxgi_factory2;
+#ifdef _DEBUG
+ res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
+ (void **)&d3d->d3d_debug);
+ if (FAILED(res))
+ goto release_d3d_device;
+#endif
+
if (!GetClientRect(win->win, &r))
goto release_d3d_device;
@@ -243,6 +253,10 @@ D3d *d3d_init(Window *win, int vsync)
IDXGISwapChain1_SetFullscreenState(d3d->dxgi_swapchain, FALSE, NULL);
IDXGISwapChain1_Release(d3d->dxgi_swapchain);
release_d3d_device:
+#ifdef _DEBUG
+ if (d3d->d3d_debug)
+ ID3D11Debug_Release(d3d->d3d_debug);
+#endif
ID3D11DeviceContext_Release(d3d->d3d_device_ctx);
ID3D11Device_Release(d3d->d3d_device);
release_dxgi_factory2:
@@ -257,15 +271,13 @@ void d3d_shutdown(D3d *d3d)
{
#ifdef _DEBUG
ID3D11Debug *d3d_debug;
- HRESULT res;
#endif
if (!d3d)
return;
#ifdef _DEBUG
- res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
- (void **)&d3d_debug);
+ d3d_debug = d3d->d3d_debug;
#endif
ID3D11RasterizerState_Release(d3d->d3d_rasterizer_state);
@@ -278,11 +290,8 @@ void d3d_shutdown(D3d *d3d)
free(d3d);
#ifdef _DEBUG
- if (SUCCEEDED(res))
- {
- ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
- ID3D11Debug_Release(d3d_debug);
- }
+ ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
+ ID3D11Debug_Release(d3d_debug);
#endif
}
diff --git a/src/d3d_2.c b/src/d3d_2.c
index b24d5be..aa743be 100644
--- a/src/d3d_2.c
+++ b/src/d3d_2.c
@@ -9,9 +9,9 @@
/* C API for d3d11 */
#define COBJMACROS
-#include <dxgi1_3.h>
-#include <d3d11.h>
-#include <d3dcompiler.h>
+#include <dxgi1_3.h> /* DXGI interface */
+#include <d3d11.h> /* D3D11 interface */
+#include <d3dcompiler.h> /* compilation of shader */
#include "win.h"
@@ -30,6 +30,9 @@ struct D3d
IDXGISwapChain1 *dxgi_swapchain;
/* D3D11 */
ID3D11Device *d3d_device;
+#ifdef _DEBUG
+ ID3D11Debug *d3d_debug;
+#endif
ID3D11DeviceContext *d3d_device_ctx;
ID3D11RenderTargetView *d3d_render_target_view;
ID3D11InputLayout *d3d_input_layout;
@@ -209,6 +212,13 @@ D3d *d3d_init(Window *win, int vsync)
if (FAILED(res))
goto release_dxgi_factory2;
+#ifdef _DEBUG
+ res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
+ (void **)&d3d->d3d_debug);
+ if (FAILED(res))
+ goto release_d3d_device;
+#endif
+
if (!GetClientRect(win->win, &r))
goto release_d3d_device;
@@ -379,6 +389,10 @@ D3d *d3d_init(Window *win, int vsync)
IDXGISwapChain1_SetFullscreenState(d3d->dxgi_swapchain, FALSE, NULL);
IDXGISwapChain1_Release(d3d->dxgi_swapchain);
release_d3d_device:
+#ifdef _DEBUG
+ if (d3d->d3d_debug)
+ ID3D11Debug_Release(d3d->d3d_debug);
+#endif
ID3D11DeviceContext_Release(d3d->d3d_device_ctx);
ID3D11Device_Release(d3d->d3d_device);
release_dxgi_factory2:
@@ -393,15 +407,13 @@ void d3d_shutdown(D3d *d3d)
{
#ifdef _DEBUG
ID3D11Debug *d3d_debug;
- HRESULT res;
#endif
if (!d3d)
return;
#ifdef _DEBUG
- res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
- (void **)&d3d_debug);
+ d3d_debug = d3d->d3d_debug;
#endif
ID3D11Buffer_Release(d3d->d3d_const_buffer);
@@ -418,11 +430,8 @@ void d3d_shutdown(D3d *d3d)
free(d3d);
#ifdef _DEBUG
- if (SUCCEEDED(res))
- {
- ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
- ID3D11Debug_Release(d3d_debug);
- }
+ ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
+ ID3D11Debug_Release(d3d_debug);
#endif
}
diff --git a/src/d3d_3.c b/src/d3d_3.c
index bb9dae8..e6902d4 100644
--- a/src/d3d_3.c
+++ b/src/d3d_3.c
@@ -9,9 +9,9 @@
/* C API for d3d11 */
#define COBJMACROS
-#include <dxgi1_3.h>
-#include <d3d11.h>
-#include <d3dcompiler.h>
+#include <dxgi1_3.h> /* DXGI interface */
+#include <d3d11.h> /* D3D11 interface */
+#include <d3dcompiler.h> /* compilation of shader */
#include "win.h"
@@ -30,6 +30,9 @@ struct D3d
IDXGISwapChain1 *dxgi_swapchain;
/* D3D11 */
ID3D11Device *d3d_device;
+#ifdef _DEBUG
+ ID3D11Debug *d3d_debug;
+#endif
ID3D11DeviceContext *d3d_device_ctx;
ID3D11RenderTargetView *d3d_render_target_view;
ID3D11InputLayout *d3d_input_layout;
@@ -214,6 +217,13 @@ D3d *d3d_init(Window *win, int vsync)
if (FAILED(res))
goto release_dxgi_factory2;
+#ifdef _DEBUG
+ res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
+ (void **)&d3d->d3d_debug);
+ if (FAILED(res))
+ goto release_d3d_device;
+#endif
+
if (!GetClientRect(win->win, &r))
goto release_d3d_device;
@@ -384,6 +394,10 @@ D3d *d3d_init(Window *win, int vsync)
IDXGISwapChain1_SetFullscreenState(d3d->dxgi_swapchain, FALSE, NULL);
IDXGISwapChain1_Release(d3d->dxgi_swapchain);
release_d3d_device:
+#ifdef _DEBUG
+ if (d3d->d3d_debug)
+ ID3D11Debug_Release(d3d->d3d_debug);
+#endif
ID3D11DeviceContext_Release(d3d->d3d_device_ctx);
ID3D11Device_Release(d3d->d3d_device);
release_dxgi_factory2:
@@ -398,15 +412,13 @@ void d3d_shutdown(D3d *d3d)
{
#ifdef _DEBUG
ID3D11Debug *d3d_debug;
- HRESULT res;
#endif
if (!d3d)
return;
#ifdef _DEBUG
- res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
- (void **)&d3d_debug);
+ d3d_debug = d3d->d3d_debug;
#endif
ID3D11Buffer_Release(d3d->d3d_const_buffer);
@@ -423,11 +435,8 @@ void d3d_shutdown(D3d *d3d)
free(d3d);
#ifdef _DEBUG
- if (SUCCEEDED(res))
- {
- ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
- ID3D11Debug_Release(d3d_debug);
- }
+ ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
+ ID3D11Debug_Release(d3d_debug);
#endif
}
diff --git a/src/d3d_4.c b/src/d3d_4.c
index ef52282..a28325b 100644
--- a/src/d3d_4.c
+++ b/src/d3d_4.c
@@ -9,9 +9,9 @@
/* C API for d3d11 */
#define COBJMACROS
-#include <dxgi1_3.h>
-#include <d3d11.h>
-#include <d3dcompiler.h>
+#include <dxgi1_3.h> /* DXGI interface */
+#include <d3d11.h> /* D3D11 interface */
+#include <d3dcompiler.h> /* compilation of shader */
#include "win.h"
@@ -30,6 +30,9 @@ struct D3d
IDXGISwapChain1 *dxgi_swapchain;
/* D3D11 */
ID3D11Device *d3d_device;
+#ifdef _DEBUG
+ ID3D11Debug *d3d_debug;
+#endif
ID3D11DeviceContext *d3d_device_ctx;
ID3D11RenderTargetView *d3d_render_target_view;
ID3D11InputLayout *d3d_input_layout;
@@ -214,6 +217,13 @@ D3d *d3d_init(Window *win, int vsync)
if (FAILED(res))
goto release_dxgi_factory2;
+#ifdef _DEBUG
+ res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
+ (void **)&d3d->d3d_debug);
+ if (FAILED(res))
+ goto release_d3d_device;
+#endif
+
if (!GetClientRect(win->win, &r))
goto release_d3d_device;
@@ -384,6 +394,10 @@ D3d *d3d_init(Window *win, int vsync)
IDXGISwapChain1_SetFullscreenState(d3d->dxgi_swapchain, FALSE, NULL);
IDXGISwapChain1_Release(d3d->dxgi_swapchain);
release_d3d_device:
+#ifdef _DEBUG
+ if (d3d->d3d_debug)
+ ID3D11Debug_Release(d3d->d3d_debug);
+#endif
ID3D11DeviceContext_Release(d3d->d3d_device_ctx);
ID3D11Device_Release(d3d->d3d_device);
release_dxgi_factory2:
@@ -398,15 +412,13 @@ void d3d_shutdown(D3d *d3d)
{
#ifdef _DEBUG
ID3D11Debug *d3d_debug;
- HRESULT res;
#endif
if (!d3d)
return;
#ifdef _DEBUG
- res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
- (void **)&d3d_debug);
+ d3d_debug = d3d->d3d_debug;
#endif
ID3D11Buffer_Release(d3d->d3d_const_buffer);
@@ -423,11 +435,8 @@ void d3d_shutdown(D3d *d3d)
free(d3d);
#ifdef _DEBUG
- if (SUCCEEDED(res))
- {
- ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
- ID3D11Debug_Release(d3d_debug);
- }
+ ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
+ ID3D11Debug_Release(d3d_debug);
#endif
}
diff --git a/src/d3d_5.c b/src/d3d_5.c
index e567500..9f031fc 100644
--- a/src/d3d_5.c
+++ b/src/d3d_5.c
@@ -9,9 +9,9 @@
/* C API for d3d11 */
#define COBJMACROS
-#include <dxgi1_3.h>
-#include <d3d11.h>
-#include <d3dcompiler.h>
+#include <dxgi1_3.h> /* DXGI interface */
+#include <d3d11.h> /* D3D11 interface */
+#include <d3dcompiler.h> /* compilation of shader */
#include "win.h"
@@ -30,6 +30,9 @@ struct D3d
IDXGISwapChain1 *dxgi_swapchain;
/* D3D11 */
ID3D11Device *d3d_device;
+#ifdef _DEBUG
+ ID3D11Debug *d3d_debug;
+#endif
ID3D11DeviceContext *d3d_device_ctx;
ID3D11RenderTargetView *d3d_render_target_view;
ID3D11InputLayout *d3d_input_layout;
@@ -215,6 +218,13 @@ D3d *d3d_init(Window *win, int vsync)
if (FAILED(res))
goto release_dxgi_factory2;
+#ifdef _DEBUG
+ res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
+ (void **)&d3d->d3d_debug);
+ if (FAILED(res))
+ goto release_d3d_device;
+#endif
+
if (!GetClientRect(win->win, &r))
goto release_d3d_device;
@@ -385,6 +395,10 @@ D3d *d3d_init(Window *win, int vsync)
IDXGISwapChain1_SetFullscreenState(d3d->dxgi_swapchain, FALSE, NULL);
IDXGISwapChain1_Release(d3d->dxgi_swapchain);
release_d3d_device:
+#ifdef _DEBUG
+ if (d3d->d3d_debug)
+ ID3D11Debug_Release(d3d->d3d_debug);
+#endif
ID3D11DeviceContext_Release(d3d->d3d_device_ctx);
ID3D11Device_Release(d3d->d3d_device);
release_dxgi_factory2:
@@ -399,15 +413,13 @@ void d3d_shutdown(D3d *d3d)
{
#ifdef _DEBUG
ID3D11Debug *d3d_debug;
- HRESULT res;
#endif
if (!d3d)
return;
#ifdef _DEBUG
- res = ID3D11Debug_QueryInterface(d3d->d3d_device, &IID_ID3D11Debug,
- (void **)&d3d_debug);
+ d3d_debug = d3d->d3d_debug;
#endif
ID3D11Buffer_Release(d3d->d3d_const_buffer);
@@ -424,11 +436,8 @@ void d3d_shutdown(D3d *d3d)
free(d3d);
#ifdef _DEBUG
- if (SUCCEEDED(res))
- {
- ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
- ID3D11Debug_Release(d3d_debug);
- }
+ ID3D11Debug_ReportLiveDeviceObjects(d3d_debug, D3D11_RLDO_DETAIL);
+ ID3D11Debug_Release(d3d_debug);
#endif
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.