all: use new mach.Entity.Mod query API
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
541ce9e7c0
commit
bd655828e3
13 changed files with 213 additions and 265 deletions
|
|
@ -97,7 +97,7 @@ fn deinit(audio: *Mod) void {
|
|||
/// instead. At the same time, we don't want to play too far ahead as that would cause latency
|
||||
/// between e.g. user interactions and audio actually playing - so in practice the amount we play
|
||||
/// ahead is rather small and imperceivable to most humans.
|
||||
fn audioTick(audio: *Mod) !void {
|
||||
fn audioTick(entities: *mach.Entities.Mod, audio: *Mod) !void {
|
||||
const allocator = audio.state().allocator;
|
||||
const player = &audio.state().player;
|
||||
const player_channels: u8 = @intCast(player.channels().len);
|
||||
|
|
@ -134,17 +134,15 @@ fn audioTick(audio: *Mod) !void {
|
|||
@memset(mixing_buffer.items, 0);
|
||||
|
||||
var did_state_change = false;
|
||||
var archetypes_iter = audio.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_audio = &.{ .samples, .channels, .playing, .index } },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (
|
||||
archetype.slice(.entities, .id),
|
||||
archetype.slice(.mach_audio, .samples),
|
||||
archetype.slice(.mach_audio, .channels),
|
||||
archetype.slice(.mach_audio, .playing),
|
||||
archetype.slice(.mach_audio, .index),
|
||||
) |id, samples, channels, playing, index| {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.samples_slices = Mod.read(.samples),
|
||||
.channels = Mod.read(.channels),
|
||||
.playings = Mod.read(.playing),
|
||||
.indexes = Mod.read(.index),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.samples_slices, v.channels, v.playings, v.indexes) |id, samples, channels, playing, index| {
|
||||
if (!playing) continue;
|
||||
|
||||
const channels_diff = player_channels - channels + 1;
|
||||
|
|
|
|||
37
src/Core.zig
37
src/Core.zig
|
|
@ -131,21 +131,16 @@ fn init(entities: *mach.Entities.Mod, core: *Mod) !void {
|
|||
mach.core.mods.send(.app, .init, .{});
|
||||
}
|
||||
|
||||
fn update(core: *Mod) !void {
|
||||
var archetypes_iter = core.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_core = &.{
|
||||
.title,
|
||||
} },
|
||||
} });
|
||||
|
||||
fn update(entities: *mach.Entities.Mod) !void {
|
||||
var num_windows: usize = 0;
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (
|
||||
archetype.slice(.entities, .id),
|
||||
archetype.slice(.mach_core, .title),
|
||||
) |window_id, title| {
|
||||
num_windows += 1;
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.titles = Mod.read(.title),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.titles) |window_id, title| {
|
||||
_ = window_id;
|
||||
num_windows += 1;
|
||||
try mach.core.printTitle("{s}", .{title});
|
||||
}
|
||||
}
|
||||
|
|
@ -169,17 +164,17 @@ fn presentFrame(core: *Mod) !void {
|
|||
}
|
||||
}
|
||||
|
||||
fn deinit(core: *Mod) void {
|
||||
fn deinit(entities: *mach.Entities.Mod, core: *Mod) !void {
|
||||
core.state().queue.release();
|
||||
mach.core.deinit();
|
||||
|
||||
var archetypes_iter = core.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_core = &.{
|
||||
.title,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (archetype.slice(.mach_core, .title)) |title| core.state().allocator.free(title);
|
||||
var q = try entities.query(.{
|
||||
.titles = Mod.read(.title),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.titles) |title| {
|
||||
core.state().allocator.free(title);
|
||||
}
|
||||
}
|
||||
|
||||
_ = gpa.deinit();
|
||||
|
|
|
|||
|
|
@ -42,56 +42,50 @@ pub const events = .{
|
|||
.update = .{ .handler = update },
|
||||
};
|
||||
|
||||
fn update(core: *mach.Core.Mod, sprite: *Mod, sprite_pipeline: *gfx.SpritePipeline.Mod) !void {
|
||||
var archetypes_iter = sprite_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, *built| {
|
||||
try updatePipeline(core, sprite, sprite_pipeline, pipeline_id, built);
|
||||
fn update(
|
||||
entities: *mach.Entities.Mod,
|
||||
core: *mach.Core.Mod,
|
||||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
) !void {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.built_pipelines = gfx.SpritePipeline.Mod.read(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.built_pipelines) |pipeline_id, built| {
|
||||
try updatePipeline(entities, core, sprite_pipeline, pipeline_id, &built);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn updatePipeline(
|
||||
entities: *mach.Entities.Mod,
|
||||
core: *mach.Core.Mod,
|
||||
sprite: *Mod,
|
||||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
pipeline_id: mach.EntityID,
|
||||
built: *gfx.SpritePipeline.BuiltPipeline,
|
||||
built: *const gfx.SpritePipeline.BuiltPipeline,
|
||||
) !void {
|
||||
const device = core.state().device;
|
||||
const label = @tagName(name) ++ ".updatePipeline";
|
||||
const encoder = device.createCommandEncoder(&.{ .label = label });
|
||||
defer encoder.release();
|
||||
|
||||
var archetypes_iter = sprite.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite = &.{
|
||||
.uv_transform,
|
||||
.transform,
|
||||
.size,
|
||||
.pipeline,
|
||||
} },
|
||||
} });
|
||||
var num_sprites: u32 = 0;
|
||||
var i: usize = 0;
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const transforms = archetype.slice(.mach_gfx_sprite, .transform);
|
||||
const uv_transforms = archetype.slice(.mach_gfx_sprite, .uv_transform);
|
||||
const sizes = archetype.slice(.mach_gfx_sprite, .size);
|
||||
const pipelines = archetype.slice(.mach_gfx_sprite, .pipeline);
|
||||
|
||||
// TODO: currently we cannot query all sprites which have a _single_ pipeline component
|
||||
// value and get back contiguous memory for all of them. This is because all sprites with
|
||||
// possibly different pipeline component values are stored as the same archetype. If we
|
||||
// introduce a new concept of tagging-by-value to our entity storage then we can enforce
|
||||
// that all entities with the same pipeline value are stored in contiguous memory, and
|
||||
// skip this copy.
|
||||
for (transforms, uv_transforms, sizes, pipelines) |transform, uv_transform, size, sprite_pipeline_id| {
|
||||
var q = try entities.query(.{
|
||||
.transforms = Mod.read(.transform),
|
||||
.uv_transforms = Mod.read(.uv_transform),
|
||||
.sizes = Mod.read(.size),
|
||||
.pipelines = Mod.read(.pipeline),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.transforms, v.uv_transforms, v.sizes, v.pipelines) |transform, uv_transform, size, sprite_pipeline_id| {
|
||||
// TODO: currently we cannot query all sprites which have a _single_ pipeline component
|
||||
// value and get back contiguous memory for all of them. This is because all sprites with
|
||||
// possibly different pipeline component values are stored as the same archetype. If we
|
||||
// introduce a new concept of tagging-by-value to our entity storage then we can enforce
|
||||
// that all entities with the same pipeline value are stored in contiguous memory, and
|
||||
// skip this copy.
|
||||
if (sprite_pipeline_id == pipeline_id) {
|
||||
gfx.SpritePipeline.cp_transforms[i] = transform;
|
||||
gfx.SpritePipeline.cp_uv_transforms[i] = uv_transform;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ pub const BuiltPipeline = struct {
|
|||
uv_transforms: *gpu.Buffer,
|
||||
sizes: *gpu.Buffer,
|
||||
|
||||
pub fn deinit(p: *BuiltPipeline) void {
|
||||
pub fn deinit(p: *const BuiltPipeline) void {
|
||||
p.render.release();
|
||||
p.texture_sampler.release();
|
||||
p.texture.release();
|
||||
|
|
@ -123,31 +123,27 @@ fn init(sprite_pipeline: *Mod) void {
|
|||
sprite_pipeline.init(.{});
|
||||
}
|
||||
|
||||
fn deinit(sprite_pipeline: *Mod) void {
|
||||
var archetypes_iter = sprite_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (archetype.slice(.mach_gfx_sprite_pipeline, .built)) |*p| p.deinit();
|
||||
fn deinit(entities: *mach.Entities.Mod) !void {
|
||||
var q = try entities.query(.{
|
||||
.built_pipelines = Mod.read(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.built_pipelines) |built| {
|
||||
built.deinit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update(core: *mach.Core.Mod, sprite_pipeline: *Mod) !void {
|
||||
fn update(entities: *mach.Entities.Mod, core: *mach.Core.Mod, sprite_pipeline: *Mod) !void {
|
||||
// Destroy all sprite render pipelines. We will rebuild them all.
|
||||
deinit(sprite_pipeline);
|
||||
try deinit(entities);
|
||||
|
||||
var archetypes_iter = sprite_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite_pipeline = &.{
|
||||
.texture,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const textures = archetype.slice(.mach_gfx_sprite_pipeline, .texture);
|
||||
|
||||
for (ids, textures) |pipeline_id, texture| {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.textures = Mod.read(.texture),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.textures) |pipeline_id, texture| {
|
||||
try buildPipeline(core, sprite_pipeline, pipeline_id, texture);
|
||||
}
|
||||
}
|
||||
|
|
@ -319,19 +315,16 @@ fn buildPipeline(
|
|||
try sprite_pipeline.set(pipeline_id, .num_sprites, 0);
|
||||
}
|
||||
|
||||
fn preRender(sprite_pipeline: *Mod, core: *mach.Core.Mod) void {
|
||||
fn preRender(entities: *mach.Entities.Mod, core: *mach.Core.Mod) !void {
|
||||
const label = @tagName(name) ++ ".preRender";
|
||||
const encoder = core.state().device.createCommandEncoder(&.{ .label = label });
|
||||
defer encoder.release();
|
||||
|
||||
var archetypes_iter = sprite_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built);
|
||||
for (built_pipelines) |built| {
|
||||
var q = try entities.query(.{
|
||||
.built_pipelines = Mod.read(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.built_pipelines) |built| {
|
||||
// Create the projection matrix
|
||||
// TODO(sprite): move this out of the hot codepath
|
||||
const proj = math.Mat4x4.projection2D(.{
|
||||
|
|
@ -362,20 +355,17 @@ fn preRender(sprite_pipeline: *Mod, core: *mach.Core.Mod) void {
|
|||
core.state().queue.submit(&[_]*gpu.CommandBuffer{command});
|
||||
}
|
||||
|
||||
fn render(sprite_pipeline: *Mod) !void {
|
||||
fn render(entities: *mach.Entities.Mod, sprite_pipeline: *Mod) !void {
|
||||
const render_pass = if (sprite_pipeline.state().render_pass) |rp| rp else std.debug.panic("sprite_pipeline.state().render_pass must be specified", .{});
|
||||
sprite_pipeline.state().render_pass = null;
|
||||
|
||||
// TODO(sprite): need a way to specify order of rendering with multiple pipelines
|
||||
var archetypes_iter = sprite_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_sprite_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_sprite_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, built| {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.built_pipelines = Mod.read(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.built_pipelines) |pipeline_id, built| {
|
||||
// Draw the sprite batch
|
||||
const total_vertices = sprite_pipeline.get(pipeline_id, .num_sprites).? * 6;
|
||||
render_pass.setPipeline(built.render);
|
||||
|
|
|
|||
|
|
@ -58,24 +58,27 @@ const BuiltText = struct {
|
|||
glyphs: std.ArrayListUnmanaged(gfx.TextPipeline.Glyph),
|
||||
};
|
||||
|
||||
fn update(core: *mach.Core.Mod, text: *Mod, text_pipeline: *gfx.TextPipeline.Mod) !void {
|
||||
var archetypes_iter = text_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_text_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_text_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, *built| {
|
||||
try updatePipeline(core, text, text_pipeline, pipeline_id, built);
|
||||
fn update(
|
||||
entities: *mach.Entities.Mod,
|
||||
text: *Mod,
|
||||
core: *mach.Core.Mod,
|
||||
text_pipeline: *gfx.TextPipeline.Mod,
|
||||
) !void {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.built_pipelines = gfx.TextPipeline.Mod.write(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.built_pipelines) |pipeline_id, *built| {
|
||||
try updatePipeline(entities, text, core, text_pipeline, pipeline_id, built);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn updatePipeline(
|
||||
core: *mach.Core.Mod,
|
||||
entities: *mach.Entities.Mod,
|
||||
text: *Mod,
|
||||
core: *mach.Core.Mod,
|
||||
text_pipeline: *gfx.TextPipeline.Mod,
|
||||
pipeline_id: mach.EntityID,
|
||||
built: *gfx.TextPipeline.BuiltPipeline,
|
||||
|
|
@ -97,28 +100,22 @@ fn updatePipeline(
|
|||
var texture_update = false;
|
||||
var num_texts: u32 = 0;
|
||||
var removes = try std.ArrayListUnmanaged(mach.EntityID).initCapacity(allocator, 8);
|
||||
var archetypes_iter = text.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_text = &.{
|
||||
.transform,
|
||||
.text,
|
||||
.style,
|
||||
.pipeline,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const transforms = archetype.slice(.mach_gfx_text, .transform);
|
||||
const segment_slices = archetype.slice(.mach_gfx_text, .text);
|
||||
const style_slices = archetype.slice(.mach_gfx_text, .style);
|
||||
const pipelines = archetype.slice(.mach_gfx_text, .pipeline);
|
||||
|
||||
// TODO: currently we cannot query all texts which have a _single_ pipeline component
|
||||
// value and get back contiguous memory for all of them. This is because all texts with
|
||||
// possibly different pipeline component values are stored as the same archetype. If we
|
||||
// introduce a new concept of tagging-by-value to our entity storage then we can enforce
|
||||
// that all entities with the same pipeline value are stored in contiguous memory, and
|
||||
// skip this copy.
|
||||
for (ids, transforms, segment_slices, style_slices, pipelines) |id, transform, segments, styles, text_pipeline_id| {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.transforms = Mod.read(.transform),
|
||||
.segment_slices = Mod.read(.text),
|
||||
.style_slices = Mod.read(.style),
|
||||
.pipelines = Mod.read(.pipeline),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.transforms, v.segment_slices, v.style_slices, v.pipelines) |id, transform, segments, styles, text_pipeline_id| {
|
||||
// TODO: currently we cannot query all texts which have a _single_ pipeline component
|
||||
// value and get back contiguous memory for all of them. This is because all texts with
|
||||
// possibly different pipeline component values are stored as the same archetype. If we
|
||||
// introduce a new concept of tagging-by-value to our entity storage then we can enforce
|
||||
// that all entities with the same pipeline value are stored in contiguous memory, and
|
||||
// skip this copy.
|
||||
if (text_pipeline_id != pipeline_id) continue;
|
||||
|
||||
gfx.TextPipeline.cp_transforms[num_texts] = transform;
|
||||
|
|
|
|||
|
|
@ -144,33 +144,31 @@ pub const BuiltPipeline = struct {
|
|||
}
|
||||
};
|
||||
|
||||
fn deinit(text_pipeline: *Mod) void {
|
||||
var archetypes_iter = text_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_text_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
for (archetype.slice(.mach_gfx_text_pipeline, .built)) |*p| p.deinit(text_pipeline.state().allocator);
|
||||
fn deinit(entities: *mach.Entities.Mod, text_pipeline: *Mod) !void {
|
||||
var q = try entities.query(.{
|
||||
.built_pipelines = Mod.write(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.built_pipelines) |*built| {
|
||||
built.deinit(text_pipeline.state().allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update(core: *mach.Core.Mod, text_pipeline: *Mod) !void {
|
||||
fn update(entities: *mach.Entities.Mod, core: *mach.Core.Mod, text_pipeline: *Mod) !void {
|
||||
text_pipeline.init(.{
|
||||
.allocator = gpa.allocator(),
|
||||
});
|
||||
|
||||
// Destroy all text render pipelines. We will rebuild them all.
|
||||
deinit(text_pipeline);
|
||||
try deinit(entities, text_pipeline);
|
||||
|
||||
var archetypes_iter = text_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_text_pipeline = &.{
|
||||
.is_pipeline,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
for (ids) |pipeline_id| {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.is_pipelines = Mod.read(.is_pipeline),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids) |pipeline_id| {
|
||||
try buildPipeline(core, text_pipeline, pipeline_id);
|
||||
}
|
||||
}
|
||||
|
|
@ -348,19 +346,16 @@ fn buildPipeline(
|
|||
try text_pipeline.set(pipeline_id, .num_glyphs, 0);
|
||||
}
|
||||
|
||||
fn preRender(text_pipeline: *Mod, core: *mach.Core.Mod) void {
|
||||
fn preRender(entities: *mach.Entities.Mod, core: *mach.Core.Mod) !void {
|
||||
const label = @tagName(name) ++ ".preRender";
|
||||
const encoder = core.state().device.createCommandEncoder(&.{ .label = label });
|
||||
defer encoder.release();
|
||||
|
||||
var archetypes_iter = text_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_text_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const built_pipelines = archetype.slice(.mach_gfx_text_pipeline, .built);
|
||||
for (built_pipelines) |built| {
|
||||
var q = try entities.query(.{
|
||||
.built_pipelines = Mod.read(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.built_pipelines) |built| {
|
||||
// Create the projection matrix
|
||||
// TODO(text): move this out of the hot codepath
|
||||
const proj = math.Mat4x4.projection2D(.{
|
||||
|
|
@ -391,20 +386,17 @@ fn preRender(text_pipeline: *Mod, core: *mach.Core.Mod) void {
|
|||
core.state().queue.submit(&[_]*gpu.CommandBuffer{command});
|
||||
}
|
||||
|
||||
fn render(text_pipeline: *Mod) !void {
|
||||
fn render(entities: *mach.Entities.Mod, text_pipeline: *Mod) !void {
|
||||
const render_pass = if (text_pipeline.state().render_pass) |rp| rp else std.debug.panic("text_pipeline.state().render_pass must be specified", .{});
|
||||
text_pipeline.state().render_pass = null;
|
||||
|
||||
// TODO(text): need a way to specify order of rendering with multiple pipelines
|
||||
var archetypes_iter = text_pipeline.__entities.queryDeprecated(.{ .all = &.{
|
||||
.{ .mach_gfx_text_pipeline = &.{
|
||||
.built,
|
||||
} },
|
||||
} });
|
||||
while (archetypes_iter.next()) |archetype| {
|
||||
const ids = archetype.slice(.entities, .id);
|
||||
const built_pipelines = archetype.slice(.mach_gfx_text_pipeline, .built);
|
||||
for (ids, built_pipelines) |pipeline_id, built| {
|
||||
var q = try entities.query(.{
|
||||
.ids = mach.Entities.Mod.read(.id),
|
||||
.built_pipelines = Mod.read(.built),
|
||||
});
|
||||
while (q.next()) |v| {
|
||||
for (v.ids, v.built_pipelines) |pipeline_id, built| {
|
||||
// Draw the text batch
|
||||
const total_vertices = text_pipeline.get(pipeline_id, .num_glyphs).? * 6;
|
||||
render_pass.setPipeline(built.render);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue