MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/Cauldron / DeviceInit

Method DeviceInit

src/DX12/base/FrameworkWindows.cpp:362–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360 }
361
362 void FrameworkWindows::DeviceInit(HWND WindowsHandle)
363 {
364 const char* STR_CAULDRON = "Cauldron v1.4";
365
366 // Store the windows handle (other things need it later)
367 m_windowHwnd = WindowsHandle;
368
369 // Create Device
370 m_device.OnCreate(m_Name, STR_CAULDRON, m_isCpuValidationLayerEnabled, m_isGpuValidationLayerEnabled, m_windowHwnd, m_initializeAGS);
371
372 // set stable power state (only works when Developer Mode is enabled)
373 if (m_stablePowerState)
374 {
375 HRESULT hr = m_device.GetDevice()->SetStablePowerState(TRUE);
376
377 // handle failure / device removed
378 if (FAILED(hr))
379 {
380 HRESULT reason = m_device.GetDevice()->GetDeviceRemovedReason();
381
382 Trace("Warning: ID3D12Device::SetStablePowerState(TRUE) failed: Reason 0x%x (DXGI_ERROR). Recreating device, setting m_stablePowerState = false.", reason);
383
384 // device removed, so recreate
385 m_device.OnDestroy();
386 m_device.OnCreate(m_Name, STR_CAULDRON, m_isCpuValidationLayerEnabled, m_isGpuValidationLayerEnabled, m_windowHwnd, m_initializeAGS);
387 m_stablePowerState = false;
388 }
389 }
390
391 // Get the monitor
392 m_monitor = MonitorFromWindow(m_windowHwnd, MONITOR_DEFAULTTONEAREST);
393
394 // Create Swapchain
395 uint32_t dwNumberOfBackBuffers = 2;
396 m_swapChain.OnCreate(&m_device, dwNumberOfBackBuffers, m_windowHwnd);
397
398 m_swapChain.EnumerateDisplayModes(&m_displayModesAvailable, &m_displayModesNamesAvailable);
399
400 if (m_previousFullscreenMode != m_fullscreenMode)
401 {
402 HandleFullScreen();
403 m_previousFullscreenMode = m_fullscreenMode;
404 }
405
406 // Get system info
407 std::string dummyStr;
408 m_device.GetDeviceInfo(&m_systemInfo.mGPUName, &dummyStr); // 2nd parameter is unused
409 m_systemInfo.mCPUName = GetCPUNameString();
410 m_systemInfo.mGfxAPI = "DirectX 12";
411 }
412
413 void FrameworkWindows::DeviceShutdown()
414 {

Callers 1

RunFrameworkFunction · 0.45

Calls 7

TraceFunction · 0.85
GetCPUNameStringFunction · 0.70
OnCreateMethod · 0.45
GetDeviceMethod · 0.45
OnDestroyMethod · 0.45
EnumerateDisplayModesMethod · 0.45
GetDeviceInfoMethod · 0.45

Tested by

no test coverage detected