Commit Graph

3879 Commits

Author SHA1 Message Date
Jim Blandy
915be10443
wgpu_core::command::bundle: Consolidate pipeline and vertex state. (#2769)
Refactor `wgpu_core::command::bundle::State` to more closely resemble
the internal slots of a WebGPU `GPURenderBundleEncoder`, and add
validation required by the WebGPU specification.

Use `Option` to represent state that may be left unset on the encoder:
specifically, the pipeline and vertex buffers. (Previous commits have
already addressed index buffers and bind groups.) Use `.ok_or`, etc.
for unwrapping, to ensure that encoding state errors are reported.

Consolidate state derived from the pipeline in a new `PipelineState`
struct.

Remove `wgpu_core::command::bundle::PushConstantState::is_dirty`; just
represent push constant state as a vector of `PushConstantRange`
values. It's sufficient to simply zero the push constants whenever the
vector is non-empty.

Rename `bundle::State::flush_push_constants` to `zero_push_constants`a.
This is not a "flush pending state changes" function like all the
others; it just ensures that each pipeline's push constant state is
initialized.
2022-06-14 23:06:05 -04:00
Ashley Ruglys
5c8d4a8c80 Change WEBGPU_TEXTURE_FORMAT_SUPPORT to 1 << 14 instead of 1 << 13 2022-06-14 19:01:49 -07:00
Jinlei Li
006bbbc94d
Update the Supported Platforms table in README (#2770) 2022-06-14 05:04:14 +00:00
Jim Blandy
b30b445423
Clarify docs for wgpu_core's Id and gfx_select!. (#2766)
Clarify that `gfx_select!` is not specific to `hub::Global`.

Clarify that the `T` in `id<T>` is not a real resource type.
2022-06-14 00:46:58 -04:00
Jim Blandy
fd22c7f269
Increase max_outliers on wgpu water example reftest. (#2767)
The example says:

    Using AMD RADV POLARIS12 (Vulkan)

The test says:

    thread 'water' panicked at 'Image data mismatch! Outlier count 464 over limit 460. Max difference 213', wgpu/examples/water/../../tests/common/image.rs:134:13

I checked the `water-difference.png` file, and it's just a few dots
here and there. The example seems to run fine.
2022-06-14 00:45:23 -04:00
Ashley
a880eb9642
[WebGL] Add a downlevel capability for rendering to floating point textures (#2729)
* Add a downlevel capability for rendering to floating point textures

* Rename capabilities to _capabilities

* Run cargo fmt

* Pass downlevel_flags to the adapter

* Add wgt::DownlevelFlags::COLOR_ATTACHMENT_FLOAT to dx11

* Remove downlevel_flags from the adapter and use is_ext_color_buffer_float_supported instead

* Add DownlevelFlags::WEBGPU_TEXTURE_FORMAT_SUPPORT

* Apply suggestions
2022-06-14 00:43:56 -04:00
Jim Blandy
3a193ec3d3
Introduce VertexStep: a stride and a step mode. (#2768)
This is used in various places around render pipelines, passes, and
bundles.

The public `wgpu_core::pipeline::VertexBufferLayout` could use
`VertexStep` as well, but I think it's best to let that continue to
resemble `GPUVertexBufferLayout`.
2022-06-14 00:42:03 -04:00
Jim Blandy
a4352a1dac
Improve push constant documentation, including internal docs. (#2764) 2022-06-11 15:11:06 -04:00
Steven
df1472d4a3
Fix bunnymark test screenshot and replace rand with nanorand (#2746)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-06-10 21:44:27 +00:00
Nicolas Silva
629ccaf4e0
Align the validation of Device::create_texture with the WebGPU spec (#2759) 2022-06-10 16:02:49 -04:00
Jinlei Li
048a420d82
Remove the default features from wgpu-info (#2753)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-06-10 19:57:06 +00:00
Jim Blandy
498842f993
Expect shader_primitive_index tests to fail on AMD RADV. (#2754)
On Fedora, mesa-vulkan-drivers 22.0.3 AMD RADV POLARIS12 just colors
both the NE and SW corners red. There's no blue. (NW and SE are white,
as expected.) I suspect
this means that the primitive ID is always being passed as zero.

This is probably not just due to a difference in rasterization: I
tried enlarging the texture to 4x4 and shifting the triangles to
ensure that there was a pixel in each quadrant that was fully covered.

With Vulkan "llvmpipe (LLVM 14.0.0, 256 bits)", the unmodified test passes.

This is probably limited to Linux, but
`wgpu_tests::common::TestParameters` doesn't have a slot for that.

Fixes #2751.
2022-06-10 15:44:25 -04:00
Jim Blandy
b2cc6ff185
Move RenderBundleEncoder::finish's pipeline layout id into the state. (#2755) 2022-06-10 15:41:32 -04:00
i509VCB
e0327b1db7
expose vulkan physical device capabilities, enabled device extensions (#2688) 2022-06-10 15:32:52 -04:00
Jim Blandy
f94f25f355 Fix documentation links. 2022-06-09 17:42:03 -07:00
Jinlei Li
5e070783bc
vk: fix PIPELINE_STATISTICS_QUERY feature support (#2750) 2022-06-08 01:08:16 -04:00
kwillemsen
ed9cdb7946
Fixed builtin(primitive_index) for vulkan backend (#2716)
Co-authored-by: Koen Willemsen <koen.willemsen@materialise.be>
2022-06-07 20:24:46 +00:00
Jinlei Li
f0c7fe3a8e
Improve read-write and read-only texture storage error message (#2745)
* Improve read-write and read-only texture storage error message

* Update wgpu-core/src/binding_model.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-06-07 06:21:17 +00:00
Jim Blandy
091e9b1788
Clean up render bundle index buffer tracking. (#2743)
* Remove unused field `bundle::IndexState::pipeline_format`.

* Clean up render bundle index buffer tracking.

Put all state associated with an established index buffer within an
`Option`, so that the Rust types accurately represent value liveness.

Generate `MissingIndexBuffer` errors as needed for `DrawIndexed` and
indexed `MultiDrawIndirect` commands.
2022-06-07 02:17:27 -04:00
Jim Blandy
d26c04c715
Don't dirty the vertex buffer for stride/rate changes on bundles. (#2744)
`wgpu_core::command::bundle::State::set_pipeline` marks a vertex
buffer slot dirty if the pipeline's stride or step mode for that
vertex buffer slot differs from what had been previously established.
The effect of marking the slot dirty is to ensure that a new
`SetVertexBuffer` command is inserted before the next draw command
that uses that vertex buffer. However, this is unnecessary:
`wgpu_hal::CommandEncoder::set_vertex_buffer` does not need to be
called simply because the stride or rate has changed.
2022-06-07 02:10:08 -04:00
Josh Groves
be625f9a01
gles: allow clearing index buffers on WebGL (#2740) 2022-06-07 02:08:51 -04:00
Jinlei Li
31c6b39c20
metal: check if in the main thread when calling create_surface (#2736) 2022-06-07 02:07:38 -04:00
Jim Blandy
5bee63e605
Track depth and stencil writability separately. (#2693)
Put some plumbing in place to accomodate the latest definition of
`GPURenderBundleEncoderDescriptor` in the WebGPU spec, which now has
separate `depthReadOnly` and `stencilReadOnly` members.

Rename `RenderPassDepthStencilAttachment::is_read_only` to
`depth_stencil_read_only`, and don't skip validation steps due to
early returns.
2022-06-07 02:02:23 -04:00
Harald Reingruber
25b16d5cc8
OffscreenCanvas Support for WebGL Backend (#2603)
* First attempt of exposing create_surface_from_canvas for webgl

* Test Fix Compile For WebGL Offscreen Canvas

* Only specify web-sys feature version in wgpu-core, so that patch version is taken from workspace

* Reuse already existing fn create_surface_from_canvas

* Remove unnecessary unsafe

* Remove unsafe prefix also from top-level create_surface_from_canvas

* Add create_surface_from_offscreen_canvas() for webgl

* Cargo fmt

* Store webgl2_context instead of canvas, which works also for OffscreenCanvas

* Copy skybox example for OffscreenCanvas example

* Use offscreen_canvas instead in newly created example

* Update skypbox_offscreen readme.md

* Allow enabling OffscreenCanvas in examples via http://localhost:8000/?offscreen_canvas=true

* Fix cargo fmt

* [fix warning] Only import FromStr for wasm32

* [fix warning] Exclude offscreen_canvas_setup from non-wasm32

* [fix warning] Add ImageBitmap feature as well so that all related methods can be used

* Fix cargo fmt

* Fix emscripten build

* Remove `webgl` feature from wgpu-core as webgl is the only wasm32 backend

Co-authored-by: Zicklag <zicklag@katharostech.com>
2022-06-07 01:57:16 -04:00
Ashley
717bc40106
Add Features::MULTI_DRAW_INDIRECT to Metal (#2737) 2022-06-06 08:00:34 -04:00
Ashley
a3b241857d
[gles] Handle cubemap copies (#2725) 2022-06-05 17:23:31 -04:00
Connor Fitzgerald
5bd0a6c4ac
Implement submission indexes (#2700)
* Implement submission indexes

* Write some unit tests for poll

* Update wgpu/src/lib.rs

Co-authored-by: Jim Blandy <jimb@red-bean.com>

* Unify Maintain in both wgc and wgpu

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2022-06-05 17:22:25 -04:00
Robert Bragg
444836f747
Acquire texture: Option<std::time::Duration> timeouts (#2724)
* surface.acquire_texture: pass Option<Duration> for timeout

A std::time::Duration allows for timeouts to be specified more clearly in
Rust using whatever units are convenient for the caller, and an Option also
makes it clearer in case no timeout is wanted, as opposed to passing a
bitwise !0 as special timeout value.

Notably there was an impedance mismatch with the Vulkan backend that
takes a 64bit timeout in nanoseconds and uses u64::MAX to indicate no
timeout and the backend was not mapping a given u32::MAX into a u64::MAX

* surface.acquire_texture: ignore timeout for Android < 11

Prior to Android 11 then Android's vkAcquireNextImageKHR implementation was
non-conformant and didn't support timeouts and additionally would log a
verbose warning if a timeout was requested.

For reference this version of AcquireNextImageKHR doesn't support timeouts:
https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-mainline-10.0.0_r13/vulkan/libvulkan/swapchain.cpp#1426
and this version does:
https://android.googlesource.com/platform/frameworks/native/+/refs/tags/android-mainline-11.0.0_r45/vulkan/libvulkan/swapchain.cpp#1438
(i.e. timeout support was added in Android 11)

This patch adds a dependency on the `android-properties` crate that provides
a simple wrapper for the `__system_property_set` syscall so that the
platform version can be read via the `ro.build.version.sdk` property
and then for versions < 30 (corresponds to Android 11) any timeout
given to `acquire_texture` will be ignored (and `u64::MAX` will be
passed to Vulkan)
2022-06-04 16:05:40 +00:00
Xiaopeng Li
46420212d7
Add raw_adapter method for dx12 hal adapter (#2714) 2022-06-04 01:20:13 -04:00
Jinlei Li
9e3cd08e59
Improve InvalidViewport error message (#2723) 2022-06-03 01:54:09 -04:00
Jinlei Li
75db572bf7
Improve InvalidScissorRect error message (#2713) 2022-06-02 07:35:13 +00:00
Connor Fitzgerald
32af4f5607
Convert map_async from being async to being callback based (#2698) 2022-05-31 11:22:21 -04:00
Jinlei Li
8063edc648
Add DEPTH24UNORM_STENCIL8 feature (#2689) 2022-05-30 15:29:12 -04:00
Connor Fitzgerald
fd954a2bd6
Stop using storage usage for sampling (#2703) 2022-05-29 19:52:41 -04:00
Connor Fitzgerald
c12ae0880f
Check that all vertex outputs are consumed by the fragment shader (#2704) 2022-05-29 23:38:11 +00:00
Daisuke Kato
16c796578c
Add symlink LICENSE files into crates. (#2604) 2022-05-29 03:07:42 -04:00
i509VCB
2c9c5bbbe5
expose egl display in gles (#2670) 2022-05-29 03:05:57 -04:00
Jim Blandy
0c0bbdb3ad
Perform "valid to use with" checks when recording render bundles. (#2690)
* Update module docs for `wgpu_core::commands::bundle`.

* Perform "valid to use with" checks when recording render bundles.
2022-05-28 04:57:06 -04:00
DHuan
a2e27afd82
Add links for SpirV documents. (#2697) 2022-05-28 06:27:37 +00:00
Connor Fitzgerald
9114283707
Tracking Optimization and Rewrite (#2662)
* Texture state full is dead code

* temp

* temp2 - next is lifetime only

* temp3 - all trackers in place

* temp4 - continue muddling along

* temp5 - doodle doodle

* temp6 - continuous progress is continuous

* temp7 - pro-gress

* temp8 - Add refcounts to trackers

* temp9 - Soundness, generics, refcounts, and epochs

* temp10 - Compiling?!1?!1?!1

* temp11 - Add bind group state optimization

* temp12 - Safety and adding size setting

* temp13 - unsafe

* temp14 - Abstract all the state transitions

* temp15 - It verks! kinda...

* temp16 - it more verks!

* temp17 - debugging and unit tests

* temp18 - fixing unfixed things

* temp19 - hmmm

* temp20 - curious about line deltas

* temp21 - working texture trackers

* temp22 - write merge/update/barrier for buffers

* temp23 - cleanup and buffers

* temp24 - clippy cleanup

* temp25 - Add inline markers on buffer functions

* temp26 - Fix buffer trackers

* temp27 - fixed texture insert to handle both sides

* temp28 - document tracker and usages

* temp29 - document track/mod.rs

* temp30 - convert STORAGE_WRITE to STORAGE_READ_WRITE

* temp31 - Add some debug asserts to make sure we can't insert invalid states

* temp32 - clippy is opinionated sometimes

* temp33 - renaming and documentation

* temp34 - logging
2022-05-24 11:36:13 -04:00
Leo Kettmeir
dd6febe309
Update deno (#2691)
* update deno crates & align to IDL

* revert GPUAutoLayoutMode

* revert GPUAutoLayoutMode
2022-05-24 00:01:19 -07:00
i509VCB
435188cb89 expose some underlying types in Vulkan hal 2022-05-22 08:49:04 -07:00
Jim Blandy
c7872ab8b5 Eliminate wgpu_core::commands::bundle::State::raw_dynamic_offsets.
This vector's contents always ended up identical to the
`RenderBundleEncoder`'s `BasePass`'s `dynamic_offsets` vector, so
we can just take values from there instead of copying them.
2022-05-22 08:38:47 -07:00
Jim Blandy
87d75d9c7b Document command::BasePass. 2022-05-22 08:38:47 -07:00
Jim Blandy
afed25fa5c Clean up render bundle bind group tracking.
The `dynamic_offsets` and `is_dirty` flags only make sense when the
slot is occupied, so they should be inside the `Option`. This makes
`State::bind` into an `ArrayVec<Option<BindState>>`, and cleans up
various other bits.
2022-05-22 08:38:47 -07:00
Jim Blandy
d3235484f9 Document some parts of wgpu_core's render bundle code. 2022-05-22 08:38:47 -07:00
Jim Blandy
26a7c8c2a5
Document VertexStepMode. (#2685) 2022-05-22 08:34:33 -07:00
Jinlei Li
eb260ba7a6
metal: fix Depth24Plus | Depth24PlusStencil8 capabilities (#2686) 2022-05-22 08:31:15 -07:00
Jim Blandy
84efe2b18b Actually use RenderBundleEncoder::set_bind_group in tests. 2022-05-21 01:51:34 -07:00
Ashley
1ec26784c4
[Gles] Fix clearing depth and stencil at the same time (#2675) 2022-05-19 17:10:27 -04:00