mirror of
				https://github.com/gnif/LookingGlass.git
				synced 2025-10-31 20:52:09 +00:00 
			
		
		
		
	[host] dxgi: allow the debug layer to be turned on via config
This commit is contained in:
		| @@ -22,9 +22,11 @@ | ||||
|  | ||||
| #include <assert.h> | ||||
| #include <d3d12.h> | ||||
| #include <d3d12sdklayers.h> | ||||
| #include "common/debug.h" | ||||
| #include "common/option.h" | ||||
| #include "common/windebug.h" | ||||
| #include "ods_capture.h" | ||||
|  | ||||
| #define ALIGN_TO(value, align) (((value) + (align) - 1) & -(align)) | ||||
|  | ||||
| @@ -43,6 +45,7 @@ struct D3D12Backend | ||||
| { | ||||
|   int                   copySleep; | ||||
|   ID3D12Device        * device; | ||||
|   ID3D12InfoQueue1    * debugInfoQueue; | ||||
|   ID3D12CommandQueue  * commandQueue; | ||||
|   ID3D12Resource      * src; | ||||
|   struct D3D12Texture * texture; | ||||
| @@ -61,6 +64,11 @@ typedef HRESULT (*D3D12CreateDevice_t)( | ||||
|   void              **ppDevice | ||||
| ); | ||||
|  | ||||
| typedef HRESULT (*D3D12GetDebugInterface_t)( | ||||
|   REFIID riid, | ||||
|   void   **ppvDebug | ||||
| ); | ||||
|  | ||||
| static void d3d12_free(); | ||||
|  | ||||
| static bool d3d12_create(struct DXGIInterface * intf) | ||||
| @@ -72,6 +80,22 @@ static bool d3d12_create(struct DXGIInterface * intf) | ||||
|   if (!d3d12) | ||||
|     return false; | ||||
|  | ||||
|   if (dxgi->debug) | ||||
|   { | ||||
|     D3D12GetDebugInterface_t D3D12GetDebugInterface = (D3D12GetDebugInterface_t) | ||||
|       GetProcAddress(d3d12, "D3D12GetDebugInterface"); | ||||
|     ID3D12Debug1 * debug; | ||||
|     if (FAILED(status = D3D12GetDebugInterface(&IID_ID3D12Debug1, (void **)&debug))) | ||||
|       DEBUG_WINERROR("D3D12GetDebugInterface", status); | ||||
|     else | ||||
|     { | ||||
|       captureOutputDebugString(); | ||||
|       ID3D12Debug1_EnableDebugLayer(debug); | ||||
|       ID3D12Debug1_SetEnableGPUBasedValidation(debug, TRUE); | ||||
|       ID3D12Debug1_SetEnableSynchronizedCommandQueueValidation(debug, TRUE); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   D3D12CreateDevice_t D3D12CreateDevice = (D3D12CreateDevice_t) | ||||
|     GetProcAddress(d3d12, "D3D12CreateDevice"); | ||||
|  | ||||
|   | ||||
| @@ -34,9 +34,9 @@ | ||||
| #include <unistd.h> | ||||
| #include <dxgi.h> | ||||
| #include <dxgi1_2.h> | ||||
| #include <dxgi1_3.h> | ||||
| #include <dxgi1_5.h> | ||||
| #include <d3d11.h> | ||||
| #include <d3d12.h> | ||||
| #include <d3dcommon.h> | ||||
| #include <versionhelpers.h> | ||||
| #include <dwmapi.h> | ||||
| @@ -127,6 +127,13 @@ static void dxgi_initOptions(void) | ||||
|       .type           = OPTION_TYPE_INT, | ||||
|       .value.x_int    = 5 | ||||
|     }, | ||||
|     { | ||||
|       .module         = "dxgi", | ||||
|       .name           = "debug", | ||||
|       .description    = "Enable Direct3D debugging (developers only, massive performance penalty)", | ||||
|       .type           = OPTION_TYPE_BOOL, | ||||
|       .value.x_bool   = false | ||||
|     }, | ||||
|     {0} | ||||
|   }; | ||||
|  | ||||
| @@ -155,6 +162,7 @@ static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostP | ||||
|   if (this->maxTextures <= 0) | ||||
|     this->maxTextures = 1; | ||||
|  | ||||
|   this->debug               = option_get_bool("dxgi", "debug"); | ||||
|   this->useAcquireLock      = option_get_bool("dxgi", "useAcquireLock"); | ||||
|   this->dwmFlush            = option_get_bool("dxgi", "dwmFlush"); | ||||
|   this->disableDamage       = option_get_bool("dxgi", "disableDamage"); | ||||
| @@ -199,7 +207,8 @@ static bool dxgi_init(void) | ||||
|  | ||||
|   lgResetEvent(this->frameEvent); | ||||
|  | ||||
|   status = CreateDXGIFactory1(&IID_IDXGIFactory1, (void **)&this->factory); | ||||
|   status = CreateDXGIFactory2(this->debug ? DXGI_CREATE_FACTORY_DEBUG : 0, | ||||
|     &IID_IDXGIFactory1, (void **)&this->factory); | ||||
|   if (FAILED(status)) | ||||
|   { | ||||
|     DEBUG_WINERROR("Failed to create DXGIFactory1", status); | ||||
| @@ -399,6 +408,7 @@ static bool dxgi_init(void) | ||||
|   DEBUG_INFO("Feature Level     : 0x%x"   , this->featureLevel); | ||||
|   DEBUG_INFO("Capture Size      : %u x %u", this->width, this->height); | ||||
|   DEBUG_INFO("AcquireLock       : %s"     , this->useAcquireLock ? "enabled" : "disabled"); | ||||
|   DEBUG_INFO("Debug mode        : %s"     , this->debug ? "enabled" : "disabled"); | ||||
|  | ||||
|   // try to reduce the latency | ||||
|   { | ||||
|   | ||||
| @@ -73,6 +73,7 @@ struct DXGIInterface | ||||
|   ID3D11Device             * device; | ||||
|   ID3D11DeviceContext      * deviceContext; | ||||
|   LG_Lock                    deviceContextLock; | ||||
|   bool                       debug; | ||||
|   bool                       useAcquireLock; | ||||
|   bool                       dwmFlush; | ||||
|   bool                       disableDamage; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Quantum
					Quantum