This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn inspector(context: anytype) void { | |
if (imgui.Begin("Inspector", .{})) { | |
const World = @typeInfo(@TypeOf(context.world)).pointer.child; | |
inline for (World.entities, 0..) |E, k| { | |
if (k == context.target.kind) { | |
const slice = context.world.tables[k].columns.slice(); | |
if (context.target.id >= slice.len) break; // invalid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const builtin = @import("builtin"); | |
pub const Reflection = struct { | |
internal: []const type, | |
types: []const Type, | |
lookup: std.StaticStringMap(LocalId), // todo: use HashMap for this ? | |
pub const LocalId = u32; | |
pub const invalid_id = std.math.maxInt(LocalId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// update 1 - fix sorting, skip std.mem.Allocator, added a leak counter | |
const std = @import("std"); | |
const Allocator = std.mem.Allocator; | |
const StackTrace = std.builtin.StackTrace; | |
const log = std.log.scoped(.mem); | |
const tracy = @import("tracy"); | |
// todo: support for double free | |
pub const DebugAllocator = struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const builtin = @import("builtin"); | |
pub const StringContext = struct { | |
pub inline fn hash(_: @This(), s: []const u8) u64 { | |
return std.hash_map.hashString(s); | |
} | |
pub inline fn eql(_: @This(), a: []const u8, b: []const u8) bool { | |
return std.mem.eql(u8, a, b); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const Atomic = std.atomic.Value; | |
// core is a upper namespace, with way more stuff with it | |
const core = struct { | |
pub var allocator: std.mem.Allocator = undefined; | |
}; | |
/// lock-free stack | |
pub const Stack = extern struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn SlabAllocation(comptime types: []const type) type { | |
var alignment: usize = 1; | |
var slices: [types.len]type = undefined; | |
for (types, 0..) |T, i| { | |
slices[i] = []T; | |
alignment = @max(alignment, @alignOf(T)); | |
} | |
const out_alignment = alignment; | |
const Slices = std.meta.Tuple(&slices); | |
return struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile with: -mcpu=x86_64+sse2 to ensure sse2 support | |
pub fn decodeHex(input: []const u8, output: []u8) !void { | |
const block_size = 16; // change block size to use avx2 | |
const ByteBlock = @Vector(block_size, u8); | |
const IntBlock = @Vector(block_size / 4, u32); | |
if (input.len & 1 != 0) { | |
return error.OddLenghtInput; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPR isn't a silver bullet for the driver hell, for my experience DX11 works best in all platforms | |
// but Vulkan often has a better performance: | |
// | |
// Intel - DX11 works and runs faster than Vulkan that crashes a lot | |
// AMD - DX11 video enconding doesn't work in some cards, Vulkan has no issues | |
// NVIDEA - I had no problems with DX11 or Vulkan | |
// on a compute shader | |
Buffer<uint2> _SourcePositions; // WORNG! I can swear it was working somehow but it stopped working at some point | |
StructuredBuffer<uint2> _SourcePositions; // RIGHT! |