mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-11 21:37:46 -04:00
Fix a data race
This commit is contained in:
parent
e985c7c287
commit
d02512a3e5
@ -343,11 +343,7 @@ pub const ChannelChunk = struct {
|
|||||||
pub fn propagateUniformSun(self: *ChannelChunk, lightRefreshList: *main.List(chunk.ChunkPosition)) void {
|
pub fn propagateUniformSun(self: *ChannelChunk, lightRefreshList: *main.List(chunk.ChunkPosition)) void {
|
||||||
std.debug.assert(self.isSun);
|
std.debug.assert(self.isSun);
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
if(self.data.palette().len != 1) {
|
self.data.fillUniform(.fromArray(.{255, 255, 255}));
|
||||||
self.data.deferredDeinit();
|
|
||||||
self.data.init();
|
|
||||||
}
|
|
||||||
self.data.palette()[0].store(.fromArray(.{255, 255, 255}), .unordered);
|
|
||||||
self.mutex.unlock();
|
self.mutex.unlock();
|
||||||
const val = 255 -| 8*|@as(u8, @intCast(self.ch.pos.voxelSize));
|
const val = 255 -| 8*|@as(u8, @intCast(self.ch.pos.voxelSize));
|
||||||
var lightQueue = main.utils.CircularBufferQueue(Entry).init(main.stackAllocator, 1 << 12);
|
var lightQueue = main.utils.CircularBufferQueue(Entry).init(main.stackAllocator, 1 << 12);
|
||||||
|
@ -1167,6 +1167,19 @@ pub fn PaletteCompressedRegion(T: type, size: comptime_int) type { // MARK: Pale
|
|||||||
return impl.palette[0..impl.paletteLength];
|
return impl.palette[0..impl.paletteLength];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fillUniform(self: *Self, value: T) void {
|
||||||
|
const impl = self.impl.raw;
|
||||||
|
if(impl.paletteLength == 1) {
|
||||||
|
impl.palette[0].store(value, .unordered);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var newSelf: Self = undefined;
|
||||||
|
newSelf.init();
|
||||||
|
newSelf.impl.raw.palette[0] = .init(value);
|
||||||
|
newSelf.impl.raw = self.impl.swap(newSelf.impl.raw, .release);
|
||||||
|
newSelf.deferredDeinit();
|
||||||
|
}
|
||||||
|
|
||||||
fn getOrInsertPaletteIndex(noalias self: *Self, val: T) u32 {
|
fn getOrInsertPaletteIndex(noalias self: *Self, val: T) u32 {
|
||||||
var impl = self.impl.raw;
|
var impl = self.impl.raw;
|
||||||
std.debug.assert(impl.paletteLength <= impl.palette.len);
|
std.debug.assert(impl.paletteLength <= impl.palette.len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user