Commit graph

1266 commits

Author SHA1 Message Date
Stephen Gutekanst
c535e041bd gpu: correct default TextureView.Descriptor.format value
According to kangz `WGPUTextureFormat_Undefined` is the correct default value for
`TextureView.Descriptor.format`. According to the spec, the default should be the
associated _Texture_'s descriptor.format, but it seems Dawn internally handles
this when set to `Undefined` - we will take the same approach.

https://matrix.to/#/!MFogdGJfnZLrDmgkBN:matrix.org/$eVPXZMzewxJMZ_25K5jVV2N6SVriMUovkfXZI62Kq-k?via=matrix.org&via=mozilla.org&via=zinz.dev

Helps hexops/mach#182

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-22 16:19:02 -07:00
Release automation
118a3468ae gpu-dawn: update to latest binary release 2022-04-22 07:47:44 +00:00
Stephen Gutekanst
53e57e8e78
gpu-dawn: update Dawn to latest revision as of 2022-04-21 (#250)
upstream @ c2f9fea56bee11cf573fe90b08a296a38202500b

Includes fix for UB on Linux/Vulkan: https://github.com/hexops/dawn/pull/11

Closes hexops/mach#239

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 23:58:21 -07:00
PiergiorgioZagaria
4e3a58897b
gpu: mirror more WebGPU spec default values (#249)
Helps hexops/mach#182
2022-04-21 18:38:26 -07:00
PiergiorgioZagaria
8df8b043ad
shaderexp: add initial shader explorer tool (#245)
* shaderexp: first commit
* shaderexp: further improve error handling
* shaderexp: attribute ray_marching example

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 04:44:02 -07:00
Stephen Gutekanst
8d574e772c examples: rename texture-light -> advanced-gen-texture-light
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 04:39:24 -07:00
Stephen Gutekanst
417ec654df examples: texture-light: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 04:39:24 -07:00
Stephen Gutekanst
9ec8553cf8 examples: texture-light: more instances, rotate camera by default, make movement independent of frame-rate
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 04:39:24 -07:00
Stephen Gutekanst
e7609c76a2 examples: texture-light: don't crash on window resize (recreate depth buffer)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 04:39:24 -07:00
Stephen Gutekanst
7daff572f3 examples: correct texture size for running on macOS
```
mach: found Metal backend on Discrete GPU adapter: Apple M1, Metal driver on macOS Version 12.1 (Build 21C52)
gpu: validation error: Attachment [TextureView] size (width: 640, height: 480) does not match the size of the other attachments (width: 1280, height: 960).
 - While validating depthStencilAttachment.
 - While encoding [CommandEncoder].BeginRenderPass([RenderPassDescriptor]).
```

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 04:39:24 -07:00
d3m1gd
45df76bdd8 example: texture and light 2022-04-21 04:39:24 -07:00
Release automation
538af3e6df gpu-dawn: update to latest binary release 2022-04-21 11:28:09 +00:00
Stephen Gutekanst
c600431244 gpu-dawn: clarify how to build as separate repository
Fixes hexops/mach#203

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 03:48:36 -07:00
Stephen Gutekanst
a863bde72f Revert "gpu-dawn: update to latest binary release"
This reverts commit c930f4b913.

Helps hexops/mach#248
2022-04-21 03:41:49 -07:00
Stephen Gutekanst
89c9c6c8e1 CI: correct YAML syntax / regression
Helps hexops/mach#248

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-21 03:41:38 -07:00
Release automation
c930f4b913 gpu-dawn: update to latest binary release 2022-04-21 07:03:52 +00:00
Stephen Gutekanst
58664afbd6 gpu/examples: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-20 23:01:52 -07:00
Stephen Gutekanst
7ebe8cde5e glfw: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-20 23:01:39 -07:00
Stephen Gutekanst
8137f1a914 examples: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-20 23:01:30 -07:00
Johan Forsberg
3b86aa08cc
examples: add instanced-cube example (#246)
add example based on webgpu-samples' instancedCube sample.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-20 23:00:02 -07:00
PiergiorgioZagaria
8f7a20d2e6
examples: fix BlendState for rotating-cube and two-cubes (#244) 2022-04-20 10:59:40 -07:00
iddev5
bb65083561 CI: dont run aarch64-mac workflow on forks
The workflow uses a self hosted runner which is only available for
hexops/mach* repositories. Without this commit, whenever a fork of mach
or mach-* were pushed, it would queue an aarch64-mac job and then crash
after one day due to no machines being found.
2022-04-19 20:12:22 -07:00
iddev5
fde336736d README: Add web (wasm) status 2022-04-19 01:30:13 -07:00
d3m1gd
6300c85e79
examples: fix blend mode in triangle example (#240)
Co-authored-by: d3m1gd <mach+d3m1gd@users.noreply.github.com>
2022-04-18 23:50:23 -07:00
Stephen Gutekanst
0db0481f01
README: fix formatting, add sponsor section, etc. 2022-04-18 23:48:39 -07:00
Stephen Gutekanst
6901711734
README: polish it up! 2022-04-18 23:29:49 -07:00
Release automation
c9ac61c1c4 gpu-dawn: update to latest binary release 2022-04-19 04:26:30 +00:00
Stephen Gutekanst
954a5d3cc0 gpu-dawn: fix compilation on Linux
Helps hexops/mach#236

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-18 20:47:23 -07:00
Michal Ziulek
bd28946397 gpu: Changes needed for latest Dawn (generated-2022-04-18). 2022-04-18 20:45:33 -07:00
Stephen Gutekanst
b2ac779180 glfw: update vulkan headers to latest (adds v1.3 support)
Produced via `./update-upstream.sh`

Helps hexops/mach#236

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-18 20:44:34 -07:00
Stephen Gutekanst
a127378b19 gpu-dawn: update Dawn to latest revision as of 2022-04-18
Effectively a redo of hexops/mach#231 where I messed up the submodule update by accident.

Updates Dawn to latest revision as of 2022-04-18 c7b7b6def6

* Followed https://github.com/hexops/dawn/tree/main/mach#updating
* The UB issue should now actually get fixed (once CI builds the binary releases.)
* Verified example runs on macOS.

Helps hexops/mach#221

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-18 11:38:32 -07:00
PiergiorgioZagaria
169b1e2a42
gpu: correct alignment in pointer casts; handle void Context in all callbacks (#233)
* Fixed ErrorCallback.init() alignment
* Fixed callbacks alignments
* Fixed more of the callback alignment problems
* Added checks for void Context in callback
2022-04-18 11:38:09 -07:00
Stephen Gutekanst
d664c8e55d
do not produce needless libraries (#220)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-18 10:32:21 -07:00
Stephen Gutekanst
7285fa0f03 gpu-dawn: correct update to latest Dawn revision
In e673e6c5d4 I failed to update the submodule correctly, this
commit fixes that and actually updates us to the latest Dawn revision.

Helps hexops/mach#221

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-18 06:47:00 -07:00
Release automation
3b92e9f2cf gpu-dawn: update to latest binary release 2022-04-18 07:30:07 +00:00
Stephen Gutekanst
e673e6c5d4
gpu-dawn: update Dawn to latest revision as of 2022-04-17 (#231)
Updates Dawn to latest revision as of 2022-04-17 69daaab759

* Followed https://github.com/hexops/dawn/tree/main/mach#updating
* Includes a fix for UB issue https://github.com/hexops/dawn/pull/9 (I will send a CL for this upstream soon.)
* Verified examples run on macOS (other OSes will get built by CI and verified later)

Closes hexops/mach#221

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-17 23:39:34 -07:00
Stephen Gutekanst
e9671f388c examples: ensure zmath submodule is cloned during zig build
Fixes the issue people are running into at e.g.:

* https://old.reddit.com/r/Zig/comments/u622dq/mach_engine_webgpu_examples_showcase/i564w4s/
* https://twitter.com/slimsag/status/1515925666230784000?s=20&t=M2KXFUcLZT0-mJAcMy6sPw

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-17 23:00:39 -07:00
PiergiorgioZagaria
3fb59a1e34
examples: add ported two-cubes example (#228) 2022-04-17 14:31:52 -07:00
PiergiorgioZagaria
f96bbb453e
examples: add ported rotating-cube example (#227) 2022-04-17 13:50:25 -07:00
Stephen Gutekanst
93629022c5 examples: add libs/zmath dependency
Helps hexops/mach#222

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-17 12:57:59 -07:00
iddev5
a922b4b29b mach: set error message to be shown on glfw error
This uses glfw.setErrorCallback to set a global callback in mach's App
which would work across all mach applications
2022-04-17 11:50:33 -07:00
iddev5
27146af8ce glfw: add getErrorString() to access the current error description 2022-04-17 10:49:05 -07:00
Stephen Gutekanst
6f3864c1f9 examples: boids: make boids calculation framerate independent
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-17 10:07:27 -07:00
Stephen Gutekanst
305c446aa2 add delta time calculation for frame-rate independent movement
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-17 10:06:56 -07:00
d3m1gd
7e8cbc78ff
gpu: fix samler typo (#224)
Co-authored-by: d3m1gd <mach+d3m1gd@users.noreply.github.com>
2022-04-17 09:15:52 -07:00
Stephen Gutekanst
5883a50d92 add high-level vsync modes
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-16 11:52:47 -07:00
d3m1gd
05853da233
gpu: fix alignment issues with getMappedRange, getConstMappedRange (#223)
fixes alignment issues with getMappedRange, getConstMappedRange

Prior to this change `getMappedRange` and `getConstMappedRange` would not handle alignment to `COPY_BUFFER_ALIGNMENT` for users, and so invocation could result in an unhelpful error message:

```
    thread 254201 panic: attempt to use null value
    .../mach/gpu/src/NativeInstance.zig:1721:42: 0x480747
    in .gpu.NativeInstance.buffer_vtable.getMappedRange (game)
            return @ptrCast([*c]u8, range.?)[0..size];
					 ^
```

To address this:

1. Ensure we always request a 4-byte aligned buffer when `createBuffer` is called.
2. Ensure we always map 4-byte aligned buffers.

Co-authored-by: d3m1gd <mach+d3m1gd@users.noreply.github.com>
2022-04-16 10:16:20 -07:00
Andrew Gutekanst
c11d818c89 examples: add license information 2022-04-14 10:46:31 -07:00
Andrew Gutekanst
a7727c6b54 examples: add ported boids example
Ported from https://github.com/austinEng/webgpu-samples/
2022-04-14 10:46:31 -07:00
Andrew Gutekanst
9e945ce951 gpu: improve optional handling
Helps hexops/mach#182
2022-04-14 10:46:31 -07:00