18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 14:07:06 +01:00

Windscreen water (OpenGL): the mask of the wipers read for the kernels [skip ci]

The OpenGL renderer reads a texture when a draw binds it. The glasses never
draw the mask of their wipers, only the kernels read it, so under OpenGL the
mask stayed unread, the glass was never baked and had no map: no snow (the
log said "glass 1 not baked yet" for good). The kernels now have a texture
they read loaded from its file when nothing read it yet. Vulkan reads its
textures without a draw, so it had this right.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqfRrTiBDaAyQ2gT6ZrnZD
This commit is contained in:
Claude
2026-11-22 20:38:07 +01:00
parent 04e877ffa6
commit 48e4ef517f
+13 -3
View File
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "rendering/opengl46/opengl46water.h"
#include "model/Texture.h"
#include "rendering/renderer.h"
#include "utilities/Logs.h"
@@ -23,6 +24,16 @@ GLuint groups(std::size_t const Count)
return static_cast<GLuint>((Count + gl::WATER_GROUP_SIZE - 1) / gl::WATER_GROUP_SIZE);
}
// a texture a kernel reads, made ready: read from its file first when nothing read it yet. the opengl renderer reads a texture
// when a draw binds it, and the glasses never draw the mask of their wipers (only the kernels read it), so without this the mask
// stayed unread and the glass never got its map
bool kernel_texture(ITexture &Texture)
{
if (auto *source{dynamic_cast<texture_source *>(&Texture)}; (source != nullptr) && (source->data_state == resource_state::none) && (false == source->is_rendertarget))
source->load();
return Texture.create() && Texture.get_is_ready() && (Texture.get_id() != 0);
}
} // namespace
namespace
@@ -146,7 +157,7 @@ bool opengl46_windscreen_water::gpu_bake(std::size_t const Slot, texture_handle
if ((!m_storage) || (Mask == null_handle))
return false;
auto &texture{GfxRenderer->Texture(Mask)};
if ((false == texture.create()) || (false == texture.get_is_ready()) || (texture.get_id() == 0))
if (false == kernel_texture(texture))
return false;
m_storage->bind_base();
m_block->update(Block);
@@ -165,8 +176,7 @@ bool opengl46_windscreen_water::gpu_snow_layer(std::size_t const Slot, texture_h
return false;
auto &atlas{GfxRenderer->Texture(Atlas)};
auto &normal{GfxRenderer->Texture(Normal)};
if ((false == atlas.create()) || (false == atlas.get_is_ready()) || (atlas.get_id() == 0) || (false == normal.create()) || (false == normal.get_is_ready()) ||
(normal.get_id() == 0))
if ((false == kernel_texture(atlas)) || (false == kernel_texture(normal)))
return false;
m_storage->bind_base();
m_block->update(Block);