Skip to content

Commit cedd50e

Browse files
Few updates to match API240089
1 parent 5cb8c8e commit cedd50e

4 files changed

Lines changed: 38 additions & 108 deletions

File tree

SampleBase/src/SampleApp.cpp

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,11 @@ void SampleApp::InitializeDiligentEngine(const NativeWindow* pWindow)
104104
case RENDER_DEVICE_TYPE_D3D11:
105105
{
106106
EngineD3D11CreateInfo EngineCI;
107-
108-
# ifdef DILIGENT_DEVELOPMENT
109-
EngineCI.DebugFlags |=
110-
D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE |
111-
D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES;
112-
# endif
113107
# ifdef DILIGENT_DEBUG
114-
EngineCI.DebugFlags |= D3D11_DEBUG_FLAG_VERIFY_COMMITTED_RESOURCE_RELEVANCE;
108+
EngineCI.SetValidationLevel(VALIDATION_LEVEL_2);
115109
# endif
116-
117-
if (m_ValidationLevel >= 1)
118-
{
119-
EngineCI.DebugFlags =
120-
D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE |
121-
D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES |
122-
D3D11_DEBUG_FLAG_VERIFY_COMMITTED_RESOURCE_RELEVANCE;
123-
}
124-
else if (m_ValidationLevel == 0)
125-
{
126-
EngineCI.DebugFlags = D3D11_DEBUG_FLAG_NONE;
127-
}
110+
if (m_ValidationLevel >= 0)
111+
EngineCI.SetValidationLevel(static_cast<VALIDATION_LEVEL>(m_ValidationLevel));
128112

129113
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, EngineCI, m_SwapChainInitDesc);
130114

@@ -187,20 +171,8 @@ void SampleApp::InitializeDiligentEngine(const NativeWindow* pWindow)
187171
case RENDER_DEVICE_TYPE_D3D12:
188172
{
189173
EngineD3D12CreateInfo EngineCI;
190-
191-
# ifdef DILIGENT_DEVELOPMENT
192-
EngineCI.EnableDebugLayer = true;
193-
# endif
194-
if (m_ValidationLevel >= 1)
195-
{
196-
EngineCI.EnableDebugLayer = true;
197-
if (m_ValidationLevel >= 2)
198-
EngineCI.EnableGPUBasedValidation = true;
199-
}
200-
else if (m_ValidationLevel == 0)
201-
{
202-
EngineCI.EnableDebugLayer = false;
203-
}
174+
if (m_ValidationLevel >= 0)
175+
EngineCI.SetValidationLevel(static_cast<VALIDATION_LEVEL>(m_ValidationLevel));
204176

205177
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, EngineCI, m_SwapChainInitDesc);
206178

@@ -287,19 +259,10 @@ void SampleApp::InitializeDiligentEngine(const NativeWindow* pWindow)
287259
EngineGLCreateInfo EngineCI;
288260
EngineCI.Window = *pWindow;
289261

290-
# ifdef DILIGENT_DEVELOPMENT
291-
EngineCI.CreateDebugContext = true;
292-
# endif
293-
EngineCI.ForceNonSeparablePrograms = m_bForceNonSeprblProgs;
262+
if (m_ValidationLevel >= 0)
263+
EngineCI.SetValidationLevel(static_cast<VALIDATION_LEVEL>(m_ValidationLevel));
294264

295-
if (m_ValidationLevel >= 1)
296-
{
297-
EngineCI.CreateDebugContext = true;
298-
}
299-
else if (m_ValidationLevel == 0)
300-
{
301-
EngineCI.CreateDebugContext = false;
302-
}
265+
EngineCI.ForceNonSeparablePrograms = m_bForceNonSeprblProgs;
303266

304267
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, EngineCI, m_SwapChainInitDesc);
305268
if (EngineCI.NumDeferredContexts != 0)
@@ -326,24 +289,15 @@ void SampleApp::InitializeDiligentEngine(const NativeWindow* pWindow)
326289
// Load the dll and import GetEngineFactoryVk() function
327290
auto GetEngineFactoryVk = LoadGraphicsEngineVk();
328291
# endif
329-
EngineVkCreateInfo EngVkAttribs;
330-
# ifdef DILIGENT_DEVELOPMENT
331-
EngVkAttribs.EnableValidation = true;
332-
# endif
333-
if (m_ValidationLevel >= 1)
334-
{
335-
EngVkAttribs.EnableValidation = true;
336-
}
337-
else if (m_ValidationLevel == 0)
338-
{
339-
EngVkAttribs.EnableValidation = false;
340-
}
292+
EngineVkCreateInfo EngineCI;
293+
if (m_ValidationLevel >= 0)
294+
EngineCI.SetValidationLevel(static_cast<VALIDATION_LEVEL>(m_ValidationLevel));
341295

342-
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, EngVkAttribs, m_SwapChainInitDesc);
343-
ppContexts.resize(1 + EngVkAttribs.NumDeferredContexts);
296+
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, EngineCI, m_SwapChainInitDesc);
297+
ppContexts.resize(1 + EngineCI.NumDeferredContexts);
344298
auto* pFactoryVk = GetEngineFactoryVk();
345299
m_pEngineFactory = pFactoryVk;
346-
pFactoryVk->CreateDeviceAndContextsVk(EngVkAttribs, &m_pDevice, ppContexts.data());
300+
pFactoryVk->CreateDeviceAndContextsVk(EngineCI, &m_pDevice, ppContexts.data());
347301
if (!m_pDevice)
348302
{
349303
LOG_ERROR_AND_THROW("Unable to initialize Diligent Engine in Vulkan mode. The API may not be available, "
@@ -360,13 +314,15 @@ void SampleApp::InitializeDiligentEngine(const NativeWindow* pWindow)
360314
#if METAL_SUPPORTED
361315
case RENDER_DEVICE_TYPE_METAL:
362316
{
363-
EngineMtlCreateInfo MtlAttribs;
317+
EngineMtlCreateInfo EngineCI;
318+
if (m_ValidationLevel >= 0)
319+
EngineCI.SetValidationLevel(static_cast<VALIDATION_LEVEL>(m_ValidationLevel));
364320

365-
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, MtlAttribs, m_SwapChainInitDesc);
366-
ppContexts.resize(1 + MtlAttribs.NumDeferredContexts);
321+
m_TheSample->GetEngineInitializationAttribs(m_DeviceType, EngineCI, m_SwapChainInitDesc);
322+
ppContexts.resize(1 + EngineCI.NumDeferredContexts);
367323
auto* pFactoryMtl = GetEngineFactoryMtl();
368324
m_pEngineFactory = pFactoryMtl;
369-
pFactoryMtl->CreateDeviceAndContextsMtl(MtlAttribs, &m_pDevice, ppContexts.data());
325+
pFactoryMtl->CreateDeviceAndContextsMtl(EngineCI, &m_pDevice, ppContexts.data());
370326
if (!m_pDevice)
371327
{
372328
LOG_ERROR_AND_THROW("Unable to initialize Diligent Engine in Metal mode. The API may not be available, "

Tutorials/Tutorial00_HelloLinux/src/Tutorial00_HelloLinux.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,7 @@ class Tutorial00App
194194
EngineGLCreateInfo CreationAttribs;
195195
CreationAttribs.Window.WindowId = NativeWindowHandle;
196196
CreationAttribs.Window.pDisplay = display;
197-
# ifdef DILIGENT_DEBUG
198-
CreationAttribs.CreateDebugContext = true;
199-
# endif
197+
200198
pFactoryOpenGL->CreateDeviceAndSwapChainGL(
201199
CreationAttribs, &m_pDevice, &m_pImmediateContext, SCDesc, &m_pSwapChain);
202200

@@ -208,9 +206,7 @@ class Tutorial00App
208206
bool InitVulkan(XCBInfo& xcbInfo)
209207
{
210208
EngineVkCreateInfo EngVkAttribs;
211-
# ifdef _DEBUG
212-
EngVkAttribs.EnableValidation = true;
213-
# endif
209+
214210
auto* pFactoryVk = GetEngineFactoryVk();
215211
pFactoryVk->CreateDeviceAndContextsVk(EngVkAttribs, &m_pDevice, &m_pImmediateContext);
216212
SwapChainDesc SCDesc;

Tutorials/Tutorial00_HelloWin32/src/Tutorial00_HelloWin32.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,9 @@ class Tutorial00App
145145
case RENDER_DEVICE_TYPE_D3D11:
146146
{
147147
EngineD3D11CreateInfo EngineCI;
148-
# ifdef DILIGENT_DEBUG
149-
EngineCI.DebugFlags |=
150-
D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE |
151-
D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES;
152-
# endif
153148
# if ENGINE_DLL
154149
// Load the dll and import GetEngineFactoryD3D11() function
155-
auto GetEngineFactoryD3D11 = LoadGraphicsEngineD3D11();
150+
auto* GetEngineFactoryD3D11 = LoadGraphicsEngineD3D11();
156151
# endif
157152
auto* pFactoryD3D11 = GetEngineFactoryD3D11();
158153
pFactoryD3D11->CreateDeviceAndContextsD3D11(EngineCI, &m_pDevice, &m_pImmediateContext);
@@ -171,10 +166,7 @@ class Tutorial00App
171166
auto GetEngineFactoryD3D12 = LoadGraphicsEngineD3D12();
172167
# endif
173168
EngineD3D12CreateInfo EngineCI;
174-
# ifdef DILIGENT_DEBUG
175-
// There is a bug in D3D12 debug layer that causes memory leaks in this tutorial
176-
//EngineCI.EnableDebugLayer = true;
177-
# endif
169+
178170
auto* pFactoryD3D12 = GetEngineFactoryD3D12();
179171
pFactoryD3D12->CreateDeviceAndContextsD3D12(EngineCI, &m_pDevice, &m_pImmediateContext);
180172
Win32NativeWindow Window{hWnd};
@@ -196,9 +188,7 @@ class Tutorial00App
196188

197189
EngineGLCreateInfo EngineCI;
198190
EngineCI.Window.hWnd = hWnd;
199-
# ifdef DILIGENT_DEBUG
200-
EngineCI.CreateDebugContext = true;
201-
# endif
191+
202192
pFactoryOpenGL->CreateDeviceAndSwapChainGL(EngineCI, &m_pDevice, &m_pImmediateContext, SCDesc, &m_pSwapChain);
203193
}
204194
break;
@@ -213,9 +203,7 @@ class Tutorial00App
213203
auto GetEngineFactoryVk = LoadGraphicsEngineVk();
214204
# endif
215205
EngineVkCreateInfo EngineCI;
216-
# ifdef DILIGENT_DEBUG
217-
EngineCI.EnableValidation = true;
218-
# endif
206+
219207
auto* pFactoryVk = GetEngineFactoryVk();
220208
pFactoryVk->CreateDeviceAndContextsVk(EngineCI, &m_pDevice, &m_pImmediateContext);
221209

Tutorials/Tutorial15_MultipleWindows/src/Tutorial15_MultipleWindows.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,14 @@ class Tutorial00App
152152
#if D3D11_SUPPORTED
153153
case RENDER_DEVICE_TYPE_D3D11:
154154
{
155-
EngineD3D11CreateInfo DeviceAttribs;
156-
# ifdef DILIGENT_DEBUG
157-
DeviceAttribs.DebugFlags |=
158-
D3D11_DEBUG_FLAG_CREATE_DEBUG_DEVICE |
159-
D3D11_DEBUG_FLAG_VERIFY_COMMITTED_SHADER_RESOURCES;
160-
# endif
155+
EngineD3D11CreateInfo EngineCI;
156+
161157
# if ENGINE_DLL
162158
// Load the dll and import GetEngineFactoryD3D11() function
163159
auto GetEngineFactoryD3D11 = LoadGraphicsEngineD3D11();
164160
# endif
165161
auto* pFactoryD3D11 = GetEngineFactoryD3D11();
166-
pFactoryD3D11->CreateDeviceAndContextsD3D11(DeviceAttribs, &m_pDevice, &m_pImmediateContext);
162+
pFactoryD3D11->CreateDeviceAndContextsD3D11(EngineCI, &m_pDevice, &m_pImmediateContext);
167163
for (auto& WndInfo : m_Windows)
168164
{
169165
Win32NativeWindow Window{WndInfo.hWnd};
@@ -182,13 +178,10 @@ class Tutorial00App
182178
// Load the dll and import GetEngineFactoryD3D12() function
183179
auto GetEngineFactoryD3D12 = LoadGraphicsEngineD3D12();
184180
# endif
185-
EngineD3D12CreateInfo EngD3D12Attribs;
186-
# ifdef DILIGENT_DEBUG
187-
// There is currently a bug in D3D12 debug layer that causes memory leaks in this tutorial.
188-
// EngD3D12Attribs.EnableDebugLayer = true;
189-
# endif
181+
EngineD3D12CreateInfo EngineCI;
182+
190183
auto* pFactoryD3D12 = GetEngineFactoryD3D12();
191-
pFactoryD3D12->CreateDeviceAndContextsD3D12(EngD3D12Attribs, &m_pDevice, &m_pImmediateContext);
184+
pFactoryD3D12->CreateDeviceAndContextsD3D12(EngineCI, &m_pDevice, &m_pImmediateContext);
192185
for (auto& WndInfo : m_Windows)
193186
{
194187
Win32NativeWindow Window{WndInfo.hWnd};
@@ -211,13 +204,12 @@ class Tutorial00App
211204
MessageBox(NULL, L"OpenGL backend does not currently support multiple swap chains", L"Error", MB_OK | MB_ICONWARNING);
212205
auto* pFactoryOpenGL = GetEngineFactoryOpenGL();
213206

214-
EngineGLCreateInfo CreationAttribs;
207+
EngineGLCreateInfo EngineCI;
215208

216209
auto& WndInfo = m_Windows[0];
217210

218-
CreationAttribs.Window.hWnd = WndInfo.hWnd;
219-
pFactoryOpenGL->CreateDeviceAndSwapChainGL(
220-
CreationAttribs, &m_pDevice, &m_pImmediateContext, SCDesc, &WndInfo.pSwapChain);
211+
EngineCI.Window.hWnd = WndInfo.hWnd;
212+
pFactoryOpenGL->CreateDeviceAndSwapChainGL(EngineCI, &m_pDevice, &m_pImmediateContext, SCDesc, &WndInfo.pSwapChain);
221213
}
222214
break;
223215
#endif
@@ -230,12 +222,10 @@ class Tutorial00App
230222
// Load the dll and import GetEngineFactoryVk() function
231223
auto GetEngineFactoryVk = LoadGraphicsEngineVk();
232224
# endif
233-
EngineVkCreateInfo EngVkAttribs;
234-
# ifdef DILIGENT_DEBUG
235-
EngVkAttribs.EnableValidation = true;
236-
# endif
225+
EngineVkCreateInfo EngineCI;
226+
237227
auto* pFactoryVk = GetEngineFactoryVk();
238-
pFactoryVk->CreateDeviceAndContextsVk(EngVkAttribs, &m_pDevice, &m_pImmediateContext);
228+
pFactoryVk->CreateDeviceAndContextsVk(EngineCI, &m_pDevice, &m_pImmediateContext);
239229
for (auto& WndInfo : m_Windows)
240230
{
241231
Win32NativeWindow Window{WndInfo.hWnd};

0 commit comments

Comments
 (0)