| 50 | namespace Falcor |
| 51 | { |
| 52 | SampleApp::SampleApp(const SampleAppConfig& config) |
| 53 | { |
| 54 | logInfo("Falcor {}", getLongVersionString()); |
| 55 | |
| 56 | OSServices::start(); |
| 57 | Threading::start(); |
| 58 | |
| 59 | mShowUI = config.showUI; |
| 60 | mVsyncOn = config.windowDesc.enableVSync; |
| 61 | mClock.setTimeScale(config.timeScale); |
| 62 | if (config.pauseTime) |
| 63 | mClock.pause(); |
| 64 | |
| 65 | // Create GPU device |
| 66 | mpDevice = make_ref<Device>(config.deviceDesc); |
| 67 | |
| 68 | if (!config.headless) |
| 69 | { |
| 70 | auto windowDesc = config.windowDesc; |
| 71 | // Vulkan does not allow creating a swapchain on a minimized window. |
| 72 | if (config.deviceDesc.type == Device::Type::Vulkan && windowDesc.mode == Window::WindowMode::Minimized) |
| 73 | windowDesc.mode = Window::WindowMode::Normal; |
| 74 | |
| 75 | // Create the window |
| 76 | mpWindow = Window::create(windowDesc, this); |
| 77 | mpWindow->setWindowIcon(getRuntimeDirectory() / "data/framework/nvidia.ico"); |
| 78 | |
| 79 | // Create swapchain |
| 80 | Swapchain::Desc desc; |
| 81 | desc.format = config.colorFormat; |
| 82 | desc.width = mpWindow->getClientAreaSize().x; |
| 83 | desc.height = mpWindow->getClientAreaSize().y; |
| 84 | desc.imageCount = 3; |
| 85 | desc.enableVSync = mVsyncOn; |
| 86 | mpSwapchain = make_ref<Swapchain>(mpDevice, desc, mpWindow->getApiHandle()); |
| 87 | |
| 88 | // Show the progress bar (unless window is minimized) |
| 89 | if (windowDesc.mode != Window::WindowMode::Minimized) |
| 90 | mProgressBar.show("Initializing Falcor"); |
| 91 | |
| 92 | // When not running headless, we want to show message boxes on error by default. |
| 93 | setErrorDiagnosticFlags(getErrorDiagnosticFlags() | ErrorDiagnosticFlags::ShowMessageBoxOnError); |
| 94 | } |
| 95 | |
| 96 | // Create target frame buffer |
| 97 | uint2 fboSize = mpWindow ? mpWindow->getClientAreaSize() : uint2(config.windowDesc.width, config.windowDesc.height); |
| 98 | mpTargetFBO = Fbo::create2D(mpDevice, fboSize.x, fboSize.y, config.colorFormat, config.depthFormat); |
| 99 | |
| 100 | // Setup asset search paths. |
| 101 | AssetResolver& resolver = AssetResolver::getDefaultResolver(); |
| 102 | resolver.addSearchPath(getProjectDirectory() / "media"); |
| 103 | for (auto& path : Settings::getGlobalSettings().getSearchDirectories("media")) |
| 104 | resolver.addSearchPath(path); |
| 105 | |
| 106 | mpDevice->getProgramManager()->setGenerateDebugInfoEnabled(config.generateShaderDebugInfo); |
| 107 | if (config.shaderPreciseFloat) |
| 108 | { |
| 109 | mpDevice->getProgramManager()->setForcedCompilerFlags( |
nothing calls this directly
no test coverage detected