summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-05-27 17:51:00 -0300
committerGravatar ameerj2021-07-22 21:51:34 -0400
commitb7764c3a796e53ac74009bc7d7cd153c64b6d743 (patch)
tree592a8be7cd43349cbabfc3d84693b443ddc0b5d8 /src/video_core/renderer_vulkan
parentglasm: Use integer lod for TXQ (diff)
downloadyuzu-b7764c3a796e53ac74009bc7d7cd153c64b6d743.tar.gz
yuzu-b7764c3a796e53ac74009bc7d7cd153c64b6d743.tar.xz
yuzu-b7764c3a796e53ac74009bc7d7cd153c64b6d743.zip
shader: Handle host exceptions
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index f86bf9c30..b6998e37c 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -303,6 +303,9 @@ GraphicsPipeline* PipelineCache::CurrentGraphicsPipeline() {
303 if (is_new) { 303 if (is_new) {
304 pipeline = CreateGraphicsPipeline(); 304 pipeline = CreateGraphicsPipeline();
305 } 305 }
306 if (!pipeline) {
307 return nullptr;
308 }
306 if (current_pipeline) { 309 if (current_pipeline) {
307 current_pipeline->AddTransition(pipeline.get()); 310 current_pipeline->AddTransition(pipeline.get());
308 } 311 }
@@ -362,9 +365,10 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
362 workers.QueueWork([this, key, env = std::move(env), &state, &callback]() mutable { 365 workers.QueueWork([this, key, env = std::move(env), &state, &callback]() mutable {
363 ShaderPools pools; 366 ShaderPools pools;
364 auto pipeline{CreateComputePipeline(pools, key, env, false)}; 367 auto pipeline{CreateComputePipeline(pools, key, env, false)};
365
366 std::lock_guard lock{state.mutex}; 368 std::lock_guard lock{state.mutex};
367 compute_cache.emplace(key, std::move(pipeline)); 369 if (pipeline) {
370 compute_cache.emplace(key, std::move(pipeline));
371 }
368 ++state.built; 372 ++state.built;
369 if (state.has_loaded) { 373 if (state.has_loaded) {
370 callback(VideoCore::LoadCallbackStage::Build, state.built, state.total); 374 callback(VideoCore::LoadCallbackStage::Build, state.built, state.total);
@@ -405,7 +409,7 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
405 409
406std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline( 410std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
407 ShaderPools& pools, const GraphicsPipelineCacheKey& key, 411 ShaderPools& pools, const GraphicsPipelineCacheKey& key,
408 std::span<Shader::Environment* const> envs, bool build_in_parallel) { 412 std::span<Shader::Environment* const> envs, bool build_in_parallel) try {
409 LOG_INFO(Render_Vulkan, "0x{:016x}", key.Hash()); 413 LOG_INFO(Render_Vulkan, "0x{:016x}", key.Hash());
410 size_t env_index{0}; 414 size_t env_index{0};
411 std::array<Shader::IR::Program, Maxwell::MaxShaderProgram> programs; 415 std::array<Shader::IR::Program, Maxwell::MaxShaderProgram> programs;
@@ -458,6 +462,10 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
458 return std::make_unique<GraphicsPipeline>( 462 return std::make_unique<GraphicsPipeline>(
459 maxwell3d, gpu_memory, scheduler, buffer_cache, texture_cache, device, descriptor_pool, 463 maxwell3d, gpu_memory, scheduler, buffer_cache, texture_cache, device, descriptor_pool,
460 update_descriptor_queue, thread_worker, render_pass_cache, key, std::move(modules), infos); 464 update_descriptor_queue, thread_worker, render_pass_cache, key, std::move(modules), infos);
465
466} catch (const Shader::Exception& exception) {
467 LOG_ERROR(Render_Vulkan, "{}", exception.what());
468 return nullptr;
461} 469}
462 470
463std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline() { 471std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline() {
@@ -466,7 +474,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline() {
466 474
467 main_pools.ReleaseContents(); 475 main_pools.ReleaseContents();
468 auto pipeline{CreateGraphicsPipeline(main_pools, graphics_key, environments.Span(), true)}; 476 auto pipeline{CreateGraphicsPipeline(main_pools, graphics_key, environments.Span(), true)};
469 if (pipeline_cache_filename.empty()) { 477 if (!pipeline || pipeline_cache_filename.empty()) {
470 return pipeline; 478 return pipeline;
471 } 479 }
472 serialization_thread.QueueWork([this, key = graphics_key, envs = std::move(environments.envs)] { 480 serialization_thread.QueueWork([this, key = graphics_key, envs = std::move(environments.envs)] {
@@ -477,7 +485,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline() {
477 env_ptrs.push_back(&envs[index]); 485 env_ptrs.push_back(&envs[index]);
478 } 486 }
479 } 487 }
480 VideoCommon::SerializePipeline(key, env_ptrs, pipeline_cache_filename); 488 SerializePipeline(key, env_ptrs, pipeline_cache_filename);
481 }); 489 });
482 return pipeline; 490 return pipeline;
483} 491}
@@ -491,18 +499,19 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
491 499
492 main_pools.ReleaseContents(); 500 main_pools.ReleaseContents();
493 auto pipeline{CreateComputePipeline(main_pools, key, env, true)}; 501 auto pipeline{CreateComputePipeline(main_pools, key, env, true)};
494 if (!pipeline_cache_filename.empty()) { 502 if (!pipeline || pipeline_cache_filename.empty()) {
495 serialization_thread.QueueWork([this, key, env = std::move(env)] { 503 return pipeline;
496 VideoCommon::SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env},
497 pipeline_cache_filename);
498 });
499 } 504 }
505 serialization_thread.QueueWork([this, key, env = std::move(env)] {
506 SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env},
507 pipeline_cache_filename);
508 });
500 return pipeline; 509 return pipeline;
501} 510}
502 511
503std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( 512std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
504 ShaderPools& pools, const ComputePipelineCacheKey& key, Shader::Environment& env, 513 ShaderPools& pools, const ComputePipelineCacheKey& key, Shader::Environment& env,
505 bool build_in_parallel) { 514 bool build_in_parallel) try {
506 LOG_INFO(Render_Vulkan, "0x{:016x}", key.Hash()); 515 LOG_INFO(Render_Vulkan, "0x{:016x}", key.Hash());
507 516
508 Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; 517 Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()};
@@ -517,6 +526,10 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
517 Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr}; 526 Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
518 return std::make_unique<ComputePipeline>(device, descriptor_pool, update_descriptor_queue, 527 return std::make_unique<ComputePipeline>(device, descriptor_pool, update_descriptor_queue,
519 thread_worker, program.info, std::move(spv_module)); 528 thread_worker, program.info, std::move(spv_module));
529
530} catch (const Shader::Exception& exception) {
531 LOG_ERROR(Render_Vulkan, "{}", exception.what());
532 return nullptr;
520} 533}
521 534
522} // namespace Vulkan 535} // namespace Vulkan