MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / InitializeGraphicsDevice

Function InitializeGraphicsDevice

tests/src/engine/test_float.cpp:519–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519std::unique_ptr<donut::app::DeviceManager> InitializeGraphicsDevice(nvrhi::GraphicsAPI graphicsApi)
520{
521 using namespace donut::app;
522
523 std::unique_ptr<DeviceManager> deviceManager = std::unique_ptr<DeviceManager>(
524 DeviceManager::Create(graphicsApi));
525
526 if (!deviceManager)
527 {
528 fprintf(stderr, "Failed to create a %s DeviceManager, skipping GPU tests.\n",
529 nvrhi::utils::GraphicsAPIToString(graphicsApi));
530 return nullptr;
531 }
532
533#if DONUT_WITH_DX12
534 if (graphicsApi == nvrhi::GraphicsAPI::D3D12)
535 {
536#if D3D12_PREVIEW_SDK_VERSION >= 720
537 UUID Features[] = { D3D12ExperimentalShaderModels };
538#else
539 UUID Features[] = { D3D12ExperimentalShaderModels, D3D12CooperativeVectorExperiment };
540#endif
541 HRESULT hr = D3D12EnableExperimentalFeatures(_countof(Features), Features, nullptr, nullptr);
542 if (FAILED(hr))
543 {
544 fprintf(stderr, "Failed to enable D3D12 experimental shader models, skipping GPU tests.\n");
545 return nullptr;
546 }
547 }
548#endif
549
550 DeviceCreationParameters deviceParams;
551 deviceParams.requiredVulkanDeviceExtensions.push_back(VK_NV_COOPERATIVE_VECTOR_EXTENSION_NAME);
552 if (!deviceManager->CreateHeadlessDevice(deviceParams))
553 {
554 fprintf(stderr, "Failed to create a %s device, skipping GPU tests.\n",
555 nvrhi::utils::GraphicsAPIToString(graphicsApi));
556 return nullptr;
557 }
558
559 if (!deviceManager->GetDevice()->queryFeatureSupport(nvrhi::Feature::CooperativeVectorInferencing))
560 {
561 fprintf(stderr, "%s device \"%s\" doesn't support Cooperative Vectors, skipping GPU tests.\n",
562 nvrhi::utils::GraphicsAPIToString(graphicsApi), deviceManager->GetRendererString());
563 return nullptr;
564 }
565
566 return std::move(deviceManager);
567}
568
569bool ReportTestResult(char const* name, bool pass)
570{

Callers 1

mainFunction · 0.85

Calls 4

push_backMethod · 0.80
CreateHeadlessDeviceMethod · 0.80
GetDeviceMethod · 0.45
GetRendererStringMethod · 0.45

Tested by

no test coverage detected