17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-02 16:19:13 +01:00

perf(sleepers): the instances of the sleepers and timbers of a track sent to the gpu once, as it's laid, and kept there in a buffer of their own; in each pass the runs of them in sight turned by the modelviews of their cells into the instance buffer of the frame by a compute pass, one dispatch and one barrier a pass, and drawn in one instanced draw for each model, part and level of detail, in place of the cpu turning every instance every frame

This commit is contained in:
maj00r
2026-10-24 01:40:34 +02:00
parent f155956669
commit 85b76acca5
12 changed files with 444 additions and 92 deletions

View File

@@ -125,11 +125,15 @@ std::pair<double, double> shared_zone( TTrack const &Track, int const Path ) {
namespace {
// the instances made so far, of all the tracks
std::uint64_t makings { 0 };
// the beams as instances of the parts of the model of the track: those of the fastenings with them, or left for later and the beams
// kept for them meanwhile
void instance( TTrack &Track, std::vector<beam> &&Beams, bool const Fastened ) {
auto &laid { Track.m_sleepers3d };
laid.made = ++makings;
for( auto &instances : laid.instances ) {
instances.clear();
}

View File

@@ -103,6 +103,7 @@ struct laid {
std::vector<glm::mat4> whole; // transforms of the timbers of a model without parts, drawn whole
std::vector<glm::mat4> plain; // transforms of the plain sleepers, whole models, relative to the origin of the track
std::vector<chunk> chunks;
std::uint64_t made { 0 }; // which making of the instances they are, none other of any track the same: a copy of them tells by it
bool fastened { false }; // the fastenings are laid, else they're laid as the track comes near where they're drawn
std::vector<beam> beams; // kept for the fastenings till they're laid
};