all: update ECS Mod(.module_tag) -> Mod(ModuleType)

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-12-16 22:56:46 -07:00
parent 8ff30c931f
commit 260802f777
4 changed files with 28 additions and 25 deletions

View file

@ -12,8 +12,8 @@
}, },
.dependencies = .{ .dependencies = .{
.mach_ecs = .{ .mach_ecs = .{
.url = "https://pkg.machengine.org/mach-ecs/ef06fb647353356eff080ad3ec337e028b492d41.tar.gz", .url = "https://pkg.machengine.org/mach-ecs/7267d8eb26ced985f65d4526770e96af488d007c.tar.gz",
.hash = "1220014851adb37d191430ac371cc467e0e0eb633b84b856c7a37e41a3149dea7ce8", .hash = "1220d252360b3ddb0e9a3d813f179142a455c089eccdfdb5e4615b6d39fab5e23e96",
}, },
.mach_core = .{ .mach_core = .{
.url = "https://pkg.machengine.org/mach-core/cce02fb96ca787378289c5855b381f0ca9f3e090.tar.gz", .url = "https://pkg.machengine.org/mach-core/cce02fb96ca787378289c5855b381f0ca9f3e090.tar.gz",

View file

@ -15,6 +15,7 @@ pub const Engine = struct {
encoder: *gpu.CommandEncoder, encoder: *gpu.CommandEncoder,
pub const name = .engine; pub const name = .engine;
pub const Mod = World.Mod(@This());
pub const local = struct { pub const local = struct {
pub fn init(world: *World) !void { pub fn init(world: *World) !void {
@ -33,7 +34,7 @@ pub const Engine = struct {
pub fn deinit( pub fn deinit(
world: *World, world: *World,
engine: *World.Mod(.engine), engine: *Mod,
) !void { ) !void {
// TODO: this triggers a device loss error, which we should handle correctly // TODO: this triggers a device loss error, which we should handle correctly
// engine.state.device.release(); // engine.state.device.release();
@ -51,7 +52,7 @@ pub const Engine = struct {
} }
pub fn beginPass( pub fn beginPass(
engine: *World.Mod(.engine), engine: *Mod,
clear_color: gpu.Color, clear_color: gpu.Color,
) !void { ) !void {
const back_buffer_view = core.swap_chain.getCurrentTextureView().?; const back_buffer_view = core.swap_chain.getCurrentTextureView().?;
@ -72,7 +73,7 @@ pub const Engine = struct {
} }
pub fn endPass( pub fn endPass(
engine: *World.Mod(.engine), engine: *Mod,
) !void { ) !void {
// End this pass // End this pass
engine.state.pass.end(); engine.state.pass.end();

View file

@ -16,6 +16,7 @@ const Mat4x4 = math.Mat4x4;
pipelines: std.AutoArrayHashMapUnmanaged(u32, Pipeline), pipelines: std.AutoArrayHashMapUnmanaged(u32, Pipeline),
pub const name = .mach_gfx_sprite; pub const name = .mach_gfx_sprite;
pub const Mod = mach.Mod(@This());
pub const components = struct { pub const components = struct {
/// The ID of the pipeline this sprite belongs to. By default, zero. /// The ID of the pipeline this sprite belongs to. By default, zero.
@ -120,14 +121,14 @@ pub const PipelineOptions = struct {
pipeline_layout: ?*gpu.PipelineLayout = null, pipeline_layout: ?*gpu.PipelineLayout = null,
}; };
pub fn deinit(sprite_mod: *mach.Mod(.mach_gfx_sprite)) !void { pub fn deinit(sprite_mod: *Mod) !void {
for (sprite_mod.state.pipelines.entries.items(.value)) |*pipeline| pipeline.deinit(); for (sprite_mod.state.pipelines.entries.items(.value)) |*pipeline| pipeline.deinit();
sprite_mod.state.pipelines.deinit(sprite_mod.allocator); sprite_mod.state.pipelines.deinit(sprite_mod.allocator);
} }
pub const local = struct { pub const local = struct {
pub fn init( pub fn init(
sprite_mod: *mach.Mod(.mach_gfx_sprite), sprite_mod: *Mod,
) !void { ) !void {
sprite_mod.state = .{ sprite_mod.state = .{
// TODO: struct default value initializers don't work // TODO: struct default value initializers don't work
@ -136,8 +137,8 @@ pub const local = struct {
} }
pub fn initPipeline( pub fn initPipeline(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
sprite_mod: *mach.Mod(.mach_gfx_sprite), sprite_mod: *Mod,
opt: PipelineOptions, opt: PipelineOptions,
) !void { ) !void {
const device = engine.state.device; const device = engine.state.device;
@ -276,8 +277,8 @@ pub const local = struct {
} }
pub fn updated( pub fn updated(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
sprite_mod: *mach.Mod(.mach_gfx_sprite), sprite_mod: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = sprite_mod.state.pipelines.getPtr(pipeline_id).?; const pipeline = sprite_mod.state.pipelines.getPtr(pipeline_id).?;
@ -325,8 +326,8 @@ pub const local = struct {
} }
pub fn preRender( pub fn preRender(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
sprite_mod: *mach.Mod(.mach_gfx_sprite), sprite_mod: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = sprite_mod.state.pipelines.get(pipeline_id).?; const pipeline = sprite_mod.state.pipelines.get(pipeline_id).?;
@ -353,8 +354,8 @@ pub const local = struct {
} }
pub fn render( pub fn render(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
sprite_mod: *mach.Mod(.mach_gfx_sprite), sprite_mod: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = sprite_mod.state.pipelines.get(pipeline_id).?; const pipeline = sprite_mod.state.pipelines.get(pipeline_id).?;

View file

@ -19,6 +19,7 @@ const Mat4x4 = math.Mat4x4;
pipelines: std.AutoArrayHashMapUnmanaged(u32, Pipeline), pipelines: std.AutoArrayHashMapUnmanaged(u32, Pipeline),
pub const name = .mach_gfx_text; pub const name = .mach_gfx_text;
pub const Mod = mach.Mod(@This());
// TODO: better/proper text layout, shaping // TODO: better/proper text layout, shaping
// //
@ -170,14 +171,14 @@ pub const PipelineOptions = struct {
pipeline_layout: ?*gpu.PipelineLayout = null, pipeline_layout: ?*gpu.PipelineLayout = null,
}; };
pub fn deinit(text_mod: *mach.Mod(.mach_gfx_text)) !void { pub fn deinit(text_mod: *Mod) !void {
for (text_mod.state.pipelines.entries.items(.value)) |*pipeline| pipeline.deinit(text_mod.allocator); for (text_mod.state.pipelines.entries.items(.value)) |*pipeline| pipeline.deinit(text_mod.allocator);
text_mod.state.pipelines.deinit(text_mod.allocator); text_mod.state.pipelines.deinit(text_mod.allocator);
} }
pub const local = struct { pub const local = struct {
pub fn init( pub fn init(
text_mod: *mach.Mod(.mach_gfx_text), text_mod: *Mod,
) !void { ) !void {
text_mod.state = .{ text_mod.state = .{
// TODO: struct default value initializers don't work // TODO: struct default value initializers don't work
@ -186,8 +187,8 @@ pub const local = struct {
} }
pub fn initPipeline( pub fn initPipeline(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
text_mod: *mach.Mod(.mach_gfx_text), text_mod: *Mod,
opt: PipelineOptions, opt: PipelineOptions,
) !void { ) !void {
const device = engine.state.device; const device = engine.state.device;
@ -346,8 +347,8 @@ pub const local = struct {
} }
pub fn updated( pub fn updated(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
text_mod: *mach.Mod(.mach_gfx_text), text_mod: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = text_mod.state.pipelines.getPtr(pipeline_id).?; const pipeline = text_mod.state.pipelines.getPtr(pipeline_id).?;
@ -500,8 +501,8 @@ pub const local = struct {
} }
pub fn preRender( pub fn preRender(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
text_mod: *mach.Mod(.mach_gfx_text), text_mod: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = text_mod.state.pipelines.get(pipeline_id).?; const pipeline = text_mod.state.pipelines.get(pipeline_id).?;
@ -528,8 +529,8 @@ pub const local = struct {
} }
pub fn render( pub fn render(
engine: *mach.Mod(.engine), engine: *Engine.Mod,
text_mod: *mach.Mod(.mach_gfx_text), text_mod: *Mod,
pipeline_id: u32, pipeline_id: u32,
) !void { ) !void {
const pipeline = text_mod.state.pipelines.get(pipeline_id).?; const pipeline = text_mod.state.pipelines.get(pipeline_id).?;