diff --git a/rendering/opengl46/opengl46water.cpp b/rendering/opengl46/opengl46water.cpp index 457544257..51de7ddff 100644 --- a/rendering/opengl46/opengl46water.cpp +++ b/rendering/opengl46/opengl46water.cpp @@ -73,10 +73,21 @@ bool opengl46_windscreen_water::gpu_init() "water_snowlayer.comp"}; for (std::size_t i = 0; i < names.size(); ++i) { - if (m_programs[i]) - continue; - gl::shader shader(PROGRAM_NAMES[i]); - m_programs[i] = std::make_unique(std::vector>{shader}); + try + { + gl::shader shader(names[i]); + m_programs[i] = std::make_unique(std::vector>{shader}); + } + catch (gl::shader_exception const &e) + { + if (i < pass::snow) + throw; + // the passes of the snow are optional: without them the glasses of the snow stay clear, the rain works on + ErrorLog("windscreen water: can't use " + std::string(names[i]) + ", the glasses of the snow stay clear: " + std::string(e.what())); + m_programs[pass::snow].reset(); + m_programs[pass::snowlayer].reset(); + break; + } } } catch (gl::shader_exception const &e) @@ -172,7 +183,7 @@ bool opengl46_windscreen_water::gpu_bake(std::size_t const Slot, texture_handle bool opengl46_windscreen_water::gpu_snow_layer(std::size_t const Slot, texture_handle const Atlas, texture_handle const Normal, gl::water_ubs const &Block) { - if ((!m_storage) || (Slot >= gl::WATER_SLOTS) || (Atlas == null_handle) || (Normal == null_handle)) + if ((!m_storage) || (!m_programs[pass::snowlayer]) || (Slot >= gl::WATER_SLOTS) || (Atlas == null_handle) || (Normal == null_handle)) return false; auto &atlas{GfxRenderer->Texture(Atlas)}; auto &normal{GfxRenderer->Texture(Normal)}; @@ -224,7 +235,7 @@ void opengl46_windscreen_water::gpu_step(gl::water_ubs const &Block, std::uint32 run(pass::clear, cell_groups); run(pass::grid, drop_groups); // the snow of the glasses of the snow, a texel of their maps a thread - if (Block.snow_slots != glm::vec4{0.f}) + if ((Block.snow_slots != glm::vec4{0.f}) && m_programs[pass::snow]) run(pass::snow, groups(static_cast(gl::WATER_MAP) * gl::WATER_MAP)); gl::program::unbind(); } diff --git a/rendering/vulkan14/vulkan14water.cpp b/rendering/vulkan14/vulkan14water.cpp index 44ebc587e..c6b244bcc 100644 --- a/rendering/vulkan14/vulkan14water.cpp +++ b/rendering/vulkan14/vulkan14water.cpp @@ -89,6 +89,7 @@ void windscreen_water::destroy() m_storage.reset(); m_device = VK_NULL_HANDLE; m_cleared = false; + m_snowkernels = true; reset(); } @@ -105,9 +106,23 @@ bool windscreen_water::gpu_init() "water_snowlayer.comp"}; for (std::size_t i = 0; i < names.size(); ++i) { - if (false == m_kernels[i].create(m_device, *m_pipelines, m_shaders->get(names[i]), m_passlayout, {}, names[i])) + try { - throw gfx::shader_exception(std::string("no compute pipeline of ") + names[i]); + if (false == m_kernels[i].create(m_device, *m_pipelines, m_shaders->get(names[i]), m_passlayout, {}, names[i])) + { + throw gfx::shader_exception(std::string("no compute pipeline of ") + names[i]); + } + } + catch (gfx::shader_exception const &e) + { + if (i < pass::snow) + { + throw; + } + // the passes of the snow are optional: without them the glasses of the snow stay clear, the rain works on + ErrorLog("windscreen water: can't use " + std::string(names[i]) + ", the glasses of the snow stay clear: " + std::string(e.what())); + m_snowkernels = false; + break; } } } @@ -271,7 +286,7 @@ bool windscreen_water::gpu_bake(std::size_t const Slot, texture_handle const Mas bool windscreen_water::gpu_snow_layer(std::size_t const Slot, texture_handle const Atlas, texture_handle const Normal, gl::water_ubs const &Block) { auto const commands{m_host.commands()}; - if ((commands == nullptr) || (false == m_full) || (Slot >= gl::WATER_SLOTS)) + if ((commands == nullptr) || (false == m_full) || (false == m_snowkernels) || (Slot >= gl::WATER_SLOTS)) { return false; } @@ -341,7 +356,7 @@ void windscreen_water::gpu_step(gl::water_ubs const &Block, std::uint32_t const run(pass::clear, cell_groups); run(pass::grid, drop_groups); // the snow of the glasses of the snow, a texel of their maps a thread - if (Block.snow_slots != glm::vec4{0.f}) + if ((Block.snow_slots != glm::vec4{0.f}) && m_snowkernels) { run(pass::snow, groups(static_cast(gl::WATER_MAP) * gl::WATER_MAP)); } diff --git a/rendering/vulkan14/vulkan14water.h b/rendering/vulkan14/vulkan14water.h index 3c50ba915..a6ef05597 100644 --- a/rendering/vulkan14/vulkan14water.h +++ b/rendering/vulkan14/vulkan14water.h @@ -105,6 +105,7 @@ class windscreen_water : public gfx::windscreen_water bool m_raincelltried{false}; bool m_full{false}; // the storage is as large as the simulation needs (else a stand-in, the glasses make their water up) bool m_cleared{false}; + bool m_snowkernels{true}; // the passes of the snow made (they are optional: without them the glasses of the snow stay clear) }; } // namespace vk14