@@ -913,29 +913,32 @@ void Renderer::initScreenSizedResources(uint32_t width, uint32_t height, core::s
913913 }
914914 }
915915
916- // we have to recompile some shaders and runtime_defines.glsl changes
917- {
918- (std::ofstream (" runtime_defines.glsl" )
919- << " #define _NBL_EXT_MITSUBA_LOADER_VT_STORAGE_VIEW_COUNT " << m_globalMeta->m_global .getVTStorageViewCount () << " \n "
920- << m_globalMeta->m_global .m_materialCompilerGLSL_declarations
921- << " #define MAX_PATH_DEPTH " << m_maxDepth << " \n "
922- << " #ifndef MAX_RAYS_GENERATED\n "
923- << " # define MAX_RAYS_GENERATED " << m_staticViewData.samplesPerPixelPerDispatch << " \n "
924- << " #endif\n "
925- ).close ();
916+ (std::ofstream (" runtime_defines.glsl" )
917+ << " #define _NBL_EXT_MITSUBA_LOADER_VT_STORAGE_VIEW_COUNT " << m_globalMeta->m_global .getVTStorageViewCount () << " \n "
918+ << m_globalMeta->m_global .m_materialCompilerGLSL_declarations
919+ << " #define MAX_PATH_DEPTH " << m_maxDepth << " \n "
920+ << " #ifndef MAX_RAYS_GENERATED\n "
921+ << " # define MAX_RAYS_GENERATED " << m_staticViewData.samplesPerPixelPerDispatch << " \n "
922+ << " #endif\n "
923+ ).close ();
926924
925+ compileShadersFuture = std::async (std::launch::async, [&]()
926+ {
927927 // cull
928- m_cullPipeline = m_driver-> createGPUComputePipeline ( nullptr , core::smart_refctd_ptr (m_cullPipelineLayout), gpuSpecializedShaderFromFile (m_assetManager,m_driver," ../cull.comp" ) );
928+ m_cullGPUShader = gpuSpecializedShaderFromFile (m_assetManager,m_driver," ../cull.comp" );
929929
930930 // raygen
931- m_raygenPipeline = m_driver-> createGPUComputePipeline ( nullptr , core::smart_refctd_ptr (m_raygenPipelineLayout), gpuSpecializedShaderFromFile (m_assetManager,m_driver," ../raygen.comp" ) );
931+ m_raygenGPUShader = gpuSpecializedShaderFromFile (m_assetManager,m_driver," ../raygen.comp" );
932932
933933 // closest hit
934- m_closestHitPipeline = m_driver-> createGPUComputePipeline ( nullptr , core::smart_refctd_ptr (m_closestHitPipelineLayout), gpuSpecializedShaderFromFile (m_assetManager,m_driver," ../closestHit.comp" ) );
934+ m_closestHitGPUShader = gpuSpecializedShaderFromFile (m_assetManager,m_driver," ../closestHit.comp" );
935935
936936 // resolve
937- m_resolvePipeline = m_driver->createGPUComputePipeline (nullptr ,core::smart_refctd_ptr (m_resolvePipelineLayout),gpuSpecializedShaderFromFile (m_assetManager,m_driver,m_useDenoiser ? " ../resolveForDenoiser.comp" :" ../resolve.comp" ));
938- }
937+ m_resolveGPUShader = gpuSpecializedShaderFromFile (m_assetManager,m_driver,m_useDenoiser ? " ../resolveForDenoiser.comp" :" ../resolve.comp" );
938+
939+ bool success = m_cullGPUShader && m_raygenGPUShader && m_closestHitGPUShader && m_resolveGPUShader;
940+ return success;
941+ });
939942
940943 auto setBufferInfo = [&](IGPUDescriptorSet::SDescriptorInfo* info, const core::smart_refctd_ptr<IGPUBuffer>& buffer) -> void
941944 {
@@ -1226,23 +1229,18 @@ void Renderer::resetSampleAndFrameCounters()
12261229 m_prevCamTform = nbl::core::matrix4x3 ();
12271230}
12281231
1229- void Renderer::takeAndSaveScreenShot (const std::string& screenShotName, const std:: filesystem::path& screenshotFolderPath )
1232+ void Renderer::takeAndSaveScreenShot (const std::filesystem::path& screenshotFilePath )
12301233{
12311234 auto commandQueue = m_rrManager->getCLCommandQueue ();
12321235 ocl::COpenCLHandler::ocl.pclFinish (commandQueue);
12331236
12341237 glFinish ();
12351238
1236- auto finalFile = (screenshotFolderPath / (screenShotName + " .exr" ).c_str ());
1237-
1238- if (!screenshotFolderPath.empty () && !std::filesystem::is_directory (screenshotFolderPath))
1239- {
1240- std::cout << " ScreenShot Directorty (" << screenshotFolderPath.string ().c_str () << " ) does not exist, Defaulting to executable folder" << std::endl;
1241- finalFile = std::filesystem::path (screenShotName + " .exr" );
1242- }
1239+ // TODO: Deduce Format from CElementFilm (How?) -> Get format from input
1240+ asset::E_FORMAT format = asset::EF_R32G32B32A32_SFLOAT;
12431241
12441242 if (m_tonemapOutput)
1245- ext::ScreenShot::createScreenShot (m_driver,m_assetManager,m_tonemapOutput.get (),finalFile .string (),asset::EF_R32G32B32A32_SFLOAT );
1243+ ext::ScreenShot::createScreenShot (m_driver,m_assetManager,m_tonemapOutput.get (),screenshotFilePath .string (), format );
12461244}
12471245
12481246// one day it will just work like that
@@ -1289,6 +1287,23 @@ void Renderer::render(nbl::ITimer* timer)
12891287
12901288 // TODO: update positions and rr->Commit() if stuff starts to move
12911289
1290+ if (compileShadersFuture.valid ())
1291+ {
1292+ bool compiledShaders = compileShadersFuture.get ();
1293+ if (compiledShaders)
1294+ {
1295+ m_cullPipeline = m_driver->createGPUComputePipeline (nullptr ,core::smart_refctd_ptr (m_cullPipelineLayout), core::smart_refctd_ptr (m_cullGPUShader));
1296+ m_raygenPipeline = m_driver->createGPUComputePipeline (nullptr ,core::smart_refctd_ptr (m_raygenPipelineLayout), core::smart_refctd_ptr (m_raygenGPUShader));
1297+ m_closestHitPipeline = m_driver->createGPUComputePipeline (nullptr ,core::smart_refctd_ptr (m_closestHitPipelineLayout), core::smart_refctd_ptr (m_closestHitGPUShader));
1298+ m_resolvePipeline = m_driver->createGPUComputePipeline (nullptr ,core::smart_refctd_ptr (m_resolvePipelineLayout), core::smart_refctd_ptr (m_resolveGPUShader));
1299+ bool createPipelinesSuceess = m_cullPipeline && m_raygenPipeline && m_closestHitPipeline && m_resolvePipeline;
1300+ if (!createPipelinesSuceess)
1301+ std::cout << " Pipeline Compilation Failed." << std::endl;
1302+ }
1303+ else
1304+ std::cout << " Shader Compilation Failed." << std::endl;
1305+ }
1306+
12921307 // raster jittered frame
12931308 {
12941309 // jitter with AA AntiAliasingSequence
0 commit comments