Commit graph

458 commits

Author SHA1 Message Date
Stephen Gutekanst
2b6aea7d91 module: add query() method to injectable *mach.Entities.Mod
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
65e2168b9f module: injected mach.Entity.Mod for global entity operations
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
69ff2e027f all: rename mod.entities -> mod.__entities (private)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
3bd46d078d module: add new query API
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
22feb42730 module: denote const vs. mut component queries
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
7d033ca2cf module: rename query2 -> query
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
2e8926d6fa module: rename query -> queryDeprecated
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-07 23:40:56 -07:00
Stephen Gutekanst
26b2351d4b module: fix zero-size component bug
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:03:57 -07:00
Stephen Gutekanst
1b65702ae8 module: add test for zero-size component bug
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:03:57 -07:00
Stephen Gutekanst
261f94d3bc module: begin improved query implementation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:03:57 -07:00
Stephen Gutekanst
2075959dad module: refactor: pass modules through Entities comptime logic
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:03:57 -07:00
Stephen Gutekanst
95c9ae5278 module: support merging module lists
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:03:57 -07:00
Stephen Gutekanst
b37ece1b9a module: rename all_components -> component_types_by_name
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:03:57 -07:00
Stephen Gutekanst
ca08255ec2 {gfx,examples}: fix refcounting bugs, improve sysgpu compatability
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:00:54 -07:00
Stephen Gutekanst
cbb728c37a gfx: SpritePipeline: fix ref counting
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:00:54 -07:00
Stephen Gutekanst
329fe251ef gfx: TextPipeline: fix ref counting
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:00:54 -07:00
Stephen Gutekanst
7ad38d6eff Audio: do not use event arguments
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-06 14:00:54 -07:00
Ali Chraghi
e711f69fad Audio: duplicate mono sounds to all channels 2024-05-06 14:00:36 -07:00
Stephen Gutekanst
9d95fcf0c2 Audio: always target 48000hz f32 audio
Resampling, which requires fairly involved (and certainly not free) filters,
is needed if the audio we are mixing does not match the sample rate of the
output device. Most OS audio APIs support resampling on their own, but have
preferred hardware formats. Most console hardware since Xbox/PS2/GC supposedly
prefers 48khz natively, but otherwise there seems to be no big preference
between 48khz or 44.1khz.

The important aspect is that we pick one, and encourage people to keep their
audio in one, so that runtime resampling is not required (both in mach itself,
and potentially without-our-knowledge in the OS audio system if we chose a
sample rate which the native hardware does not prefer.)

General guidance will be:

* `mach.Audio` module will always aim to select 48khz, f32 audio output from the
  OS APIs. Let the OS APIs do resampling, or if they do not then we can do so.
* We will prefer 48khz, f32 audio samples everywhere internally in our basic audio
  mixing etc. APIs.
* Tooling will aim to convert audio to Opus (or flac for lossless) format, with 48khz
  and number of channels depending on audio type (e.g. 1ch for most sfx, any number of
  channels for bgm, and maybe some exception for multi-channel sfx in the future.)

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-05-05 12:56:21 -07:00
Stephen Gutekanst
cbf066ade5 {gfx,examples}: improve sysgpu compatibility with higher-level examples
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
15fd2c3a64 Core: use an explicit .start event sent by app to begin .tick events
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
8089d3356e sysgpu: implement texture getWidth/getHeight
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
44f950a7f3 core: provide a default sysgpu interface implementation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
fc0ff2fffd all: rename local_events -> events
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
33bfdee520 {module,Audio}: ability to store event name and send it later
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
d690814b16 Core: fix potential printTitle leak
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
2c8ba82aa3 Core: use .app local init/deinit/tick events (avoid global events)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
e0640cc948 TextPipeline: make .init and .deinit explicit
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
ed9137fe98 SpritePipeline: make .init and .deinit explicit
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
3504dfcab6 Audio: make deinit explicit
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
4a000c7995 {Core,examples}: add TODO markers for core APIs that require module exposure
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
03a089610b Core: store framebuffer information as components
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
656b0202f2 Core: add .present_frame event replacing swapbuffers call
Note that on e.g. web platform, swapbuffers is not an explicit call.
We also need a signal that the frame has been submitted and finished,
and this is it.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
431e0dbbe1 {gfx,examples}: use core.state().queue
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
68677b3448 {Core,examples}: set window title via component
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
79dccb4d73 {gfx,examples}: use core.state().device
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-29 20:17:26 -07:00
Stephen Gutekanst
bffc668005 {gfx,examples}: add labels to gpu objects
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-21 20:29:14 -07:00
Liam Swayne
2b8bfcaa3e [math] simplify algorithm finding greatest vector 2024-04-21 17:34:15 -07:00
pfg
6a09787496 sysgpu: fix overflow trying to report an error 2024-04-21 17:33:57 -07:00
Ali Chraghi
7991053b37 spirv: sqrt instruction 2024-04-21 17:33:22 -07:00
Stephen Gutekanst
7a1efdaa69 core: cleanup sysgpu feature flag logic
* `@import("mach").core.gpu` has been renamed to `@import("mach").gpu`
* `pub const SYSGPUInterface` now has a default value (i.e. you do not need to write it in your main.zig, if you were.)
* You can now check `if (comptime mach.use_sysgpu)` for any conditional code you might have that should only run with sysgpu.

This (old):

```
pub const mach_core_options = core.ComptimeOptions{
    .use_wgpu = false,
    .use_sysgpu = true,
};
```

Has been replaced by this:

```
pub const use_sysgpu = true;
```

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-19 20:48:33 -07:00
Stephen Gutekanst
07d9855f73 core: examples: update import path style
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-19 19:05:18 -07:00
Stephen Gutekanst
2bc17a33fb module: correct alignment of dispatched arguments; move stack space to caller
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-19 18:05:17 -07:00
Stephen Gutekanst
d2179e8f2c gfx: correct some zls autofixes
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-18 21:04:43 -07:00
Stephen Gutekanst
87a7cd8ed8 engine: remove mach.Engine in favor of mach.Core for now
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-17 11:30:51 -07:00
Stephen Gutekanst
7011ad4848 audio: handle possible invalidated pointer after buffer growth
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-17 11:28:37 -07:00
Stephen Gutekanst
d045b34f70 {gfx,examples}: update all to new mach.Core module API
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-17 11:27:48 -07:00
Stephen Gutekanst
4ba8addb3c core: synchronize global .init before first .tick
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-16 20:48:04 -07:00
Stephen Gutekanst
282c83877e audio: redesign audio module
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-16 19:14:37 -07:00
Stephen Gutekanst
2b7b8f5571 math: add pow
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-16 19:14:37 -07:00