19 lines
1.5 KiB
GLSL
19 lines
1.5 KiB
GLSL
// Far blocks: 64 x 64 cell blocks of the world outside the simulated window, kept on the GPU (not simulated) for the projectiles that leave it - a black hole
|
|
// with accelerating shots eats on through them instead of meeting a wall at the window's edge. main.cpp makes them resident ahead of such projectiles (from the
|
|
// persistent store, the rest generated by terrain.comp shift_mode 3), edits.comp pass 1 applies the edits there, the dirty ones go back to the store.
|
|
// FarMap: (origin block x, y, map width, height), then a slot + 1 per block of the map (0 = not resident), then a dirty flag per slot, then the generation
|
|
// jobs: a count, then (slot, block x, block y, store-backed) each.
|
|
const int kFarMapW = 48, kFarMapH = 48, kFarSlots = 512, kFarJobs = 64;
|
|
const int kFarDirty = 4 + kFarMapW * kFarMapH, kFarJobCount = kFarDirty + kFarSlots, kFarJobList = kFarJobCount + 4;
|
|
layout(std430, set = 0, binding = 61) buffer FarCells { uint farcells[]; };
|
|
layout(std430, set = 0, binding = 62) buffer FarMap { int farmap[]; };
|
|
|
|
// the slot + 1 of the block of world cell w (0: none)
|
|
int far_slot(ivec2 w) {
|
|
const ivec2 b = (w >> 6) - ivec2(farmap[0], farmap[1]);
|
|
if (b.x < 0 || b.y < 0 || b.x >= farmap[2] || b.y >= farmap[3]) return 0;
|
|
return farmap[4 + b.y * farmap[2] + b.x];
|
|
}
|
|
bool far_in_map(ivec2 w) { const ivec2 b = (w >> 6) - ivec2(farmap[0], farmap[1]); return b.x >= 0 && b.y >= 0 && b.x < farmap[2] && b.y < farmap[3]; }
|
|
int far_index(int slot1, ivec2 w) { return (slot1 - 1) * 4096 + (w.y & 63) * 64 + (w.x & 63); }
|