Commit graph

448 commits

Author SHA1 Message Date
Ali Chraghi
b500b04c41 all: build: install tests exe 2022-07-25 11:21:37 -07:00
alichraghi
348733867c gpu: use refAllDeclsRecursive to find and fix mistakes 2022-07-20 18:55:59 -07:00
alichraghi
e6adc3e350 build: add mode paramater to testStep functions 2022-07-20 18:55:59 -07:00
alichraghi
d194dafb79 build: add test-mach step to test src/ and test for testing all sub-projects 2022-07-19 09:25:55 -07:00
dweiller
134c2019b1 gpu: remove Queue.WorkDownCallback lifetime footgun
The previous implementation required the specific Queue struct that
submit() was called on to be valid when the callback is triggered. By
storing a pointer instead, the Queue does not need to be valid, only the
callback itself.
2022-06-24 10:14:19 -07:00
kamidev
68190e863a Change std.build.Pkg.path -> std.build.Pkg.source
Fixes breaking change in latest Zig master, see https://github.com/ziglang/zig/pull/11557
2022-05-29 08:25:52 -07:00
Michal Ziulek
f2ab1eb069 gpu: Queue.WorkDoneStatus fields should be snake_case. 2022-05-29 05:26:12 -07:00
Ali Chraghi
b5d10fb167 gpu: taked slice child type in writeTexture 2022-05-24 14:34:13 -07:00
iddev5
66cc8281e5 gpu: Dont link dawn and glfw in wasm32 2022-05-22 11:44:21 -07:00
iddev5
2b994d6b24 gpu: Fix build in 32-bit platforms
Because of the use of u64, this currently fails to build in 32-bit
platforms like wasm. usize is platform dependent but safe enough for
most use cases.
2022-05-21 23:00:38 -07:00
Michal Ziulek
5a2aebb14b
gpu: correct sending of pointer to a local var to a callback function (#271) 2022-05-08 15:04:25 -07:00
Michal Ziulek
0e64b9608c
gpu: 'dynamic_offsets' should be '?[] const u32' everywhere. (#260) 2022-04-30 08:57:10 -07:00
Silver
ea76aa0268 gpu: fix store_op 2022-04-29 13:10:04 -07:00
Stephen Gutekanst
f8e7f96a4a gpu: correct RenderPassDepthStencilAttachment default values
Helps hexops/mach#182

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-24 16:07:59 +00:00
Stephen Gutekanst
821117fb26 gpu: correct TextureView.Descriptor default values
Helps hexops/mach#182

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-24 16:07:59 +00:00
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
PiergiorgioZagaria
4e3a58897b
gpu: mirror more WebGPU spec default values (#249)
Helps hexops/mach#182
2022-04-21 18:38:26 -07:00
Stephen Gutekanst
58664afbd6 gpu/examples: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-20 23:01:52 -07:00
Michal Ziulek
bd28946397 gpu: Changes needed for latest Dawn (generated-2022-04-18). 2022-04-18 20:45:33 -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
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
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
9e945ce951 gpu: improve optional handling
Helps hexops/mach#182
2022-04-14 10:46:31 -07:00
Michal Ziulek
fe8e0e7c98
gpu: Add default values for some structs (taken from the spec). (#218)
Helps hexops/mach#182
2022-04-12 12:09:48 -07:00
Michal Ziulek
f2ce208aa1
gpu: Added helpers to BindGroup.Entry; make dynamic_offset a const slice (#215)
Helps hexops/mach#
2022-04-11 11:47:02 -07:00
Michal Ziulek
8c8534e609
gpu: Default values for BindGroup.Entry (#214)
simplifies creating BindGroup - all resources are null by default and the user sets only the one needed.

Helps hexops/mach#182
2022-04-10 15:17:20 -07:00
Michal Ziulek
9ed6f6ca8b
Added helper functions to BindGroupLayout.Entry (#213)
* gpu: Added helper functions to BindGroupLayout.Entry
* gpu: Changed default values for *.BindingLayout structures. Added comments for helpers.
2022-04-10 14:28:44 -07:00
Michal Ziulek
a943fbed3e
gpu: make RenderPipeline.fragment optional (#212)
pipeline with vertex stage only is perfectly valid

Helps hexops/mach#182
2022-04-10 10:30:34 -07:00
Michal Ziulek
d0782d24d1 gpu: VertexBufferLayout.attributes field needs to be a pointer to multiple structures. 2022-04-09 12:33:27 -07:00
Stephen Gutekanst
eac7efa5d1 gpu: fix regression in example causing it not to compile
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-08 16:58:27 -07:00
Silver
6fb3ec6fd8 gpu: make writeBuffer API nicer to use 2022-04-08 11:03:00 -07:00
Silver
5ecb980b5f gpu: fix signature of CommandEncoder.writeBuffer 2022-04-08 11:03:00 -07:00
Silver
614322edc7 gpu: convert Texture.Usage to packed struct 2022-04-08 11:03:00 -07:00
Silver
c62b5ba52f gpu: replace &slice[0] with slice.ptr
This avoids UB if the slice is empty
2022-04-08 11:03:00 -07:00
Silver
f4c8a1908d gpu: fix BindGroup.Entry so that optional things are optional 2022-04-08 11:03:00 -07:00
Silver
35b38dfa96 gpu: fix typo in writeBuffer and writeTexture 2022-04-08 11:03:00 -07:00
Silver
47cd84f8ff gpu: use packed structs to wrap WebGPU's bitfield enums 2022-04-08 11:03:00 -07:00
Silver
232d0dc5ad gpu: rename BlendFactor.oneMinusSrcAlpha to match Zig naming style 2022-04-08 11:03:00 -07:00
Silver
04da4565c1 gpu: add type to pkg def in build.zig 2022-04-07 18:42:15 -07:00
Stephen Gutekanst
38095942d9 gpu: make Options public
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-05 00:16:51 -07:00
Stephen Gutekanst
451b437322 gpu: add std.build.Pkg definition
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-05 00:16:51 -07:00
Stephen Gutekanst
cd88057edd gpu: add gpu.link to make using library elsewhere easier
Helps hexops/mach#189

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-05 00:16:51 -07:00
Stephen Gutekanst
fbbb0b0ae0 gpu: use Dawn adapter creation API for now so that GPU_BACKEND selection works
`webgpu.h` does not expose a method of choosing the GPU backend (vulkan, opengl, opengles, etc.)
at present. The only way to achieve this is to use Dawn's C++ API, which we expose as C shims
under the `machDawnNative*` prefix.

For now, we will use the Dawn adapter creation API so that we can choose between Vulkan/OpenGL/OpenGLES
etc via the `GPU_BACKEND` env var.

In the future, I believe we can do something nicer here. For example, perhaps we extend our `requestAdapter`
method (after all, we do not need to strictly match `webgpu.h`) to take such an option and be Dawn-aware so
that it handles this more seamlessly behind the scenes.

Fixes https://github.com/hexops/mach/issues/192#issuecomment-1080895255

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-31 16:57:30 +00:00
Stephen Gutekanst
1f076da7bf gpu: add gpu.NativeInstance.fromWGPUAdapter
For when you have a native adapter and need a wrapped one.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-31 16:51:18 +00:00
Stephen Gutekanst
13de9d6a8c gpu: make -Ddawn-from-source=true work in gpu/ example
Previously this was only working in the gpu-dawn/ example.

Fixes hexops/mach#196

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-31 16:45:46 +00:00
Andrew Gutekanst
8072839973 gpu: update GetModuleHandleW usage in examples 2022-03-19 18:01:41 -07:00
Stephen Gutekanst
bdc556f9d5 gpu: README: correct links to issue tracker / subproject
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-19 07:05:42 -07:00
Stephen Gutekanst
82f8113dcb gpu: README: further update TODO list
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-19 00:51:48 -07:00
Stephen Gutekanst
689f2b5122 gpu: example: change window title to "mach/gpu window"
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-19 00:51:48 -07:00