17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 04:39:07 +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

@@ -0,0 +1,46 @@
// the modelviews of the instances of the timbers and sleepers of the tracks drawn in a pass (opengl46_timbers): their transforms
// are kept relative to the origins of the tracks, each run of them is turned by the modelview of the origin of its cell and written
// to the instance buffer of the frame, where the instanced draws read it. a work group a run
#include <common>
layout(local_size_x = TIMBER_GROUP_SIZE) in;
struct timber_range
{
uint source;
uint count;
uint target;
uint origin;
};
layout(std430, binding = TIMBER_LOCAL_SSBO_BINDING) readonly buffer timber_local_ssbo
{
mat4 timber_local[];
};
layout(std430, binding = TIMBER_RANGE_SSBO_BINDING) readonly buffer timber_range_ssbo
{
timber_range timber_ranges[];
};
layout(std430, binding = TIMBER_OUTPUT_SSBO_BINDING) writeonly buffer timber_output_ssbo
{
mat4 timber_output[];
};
layout(std430, binding = TIMBER_ORIGIN_SSBO_BINDING) readonly buffer timber_origin_ssbo
{
mat4 timber_origins[];
};
// x: the first run of the dispatch, y: the first modelview of the origins
layout(location = 0) uniform uvec4 params;
void main()
{
timber_range range = timber_ranges[params.x + gl_WorkGroupID.x];
mat4 origin = timber_origins[params.y + range.origin];
for (uint index = gl_LocalInvocationID.x; index < range.count; index += TIMBER_GROUP_SIZE)
timber_output[range.target + index] = origin * timber_local[range.source + index];
}