Commit Graph

3762 Commits

Author SHA1 Message Date
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
Jim Blandy
b53a8bcb17
New function: Global::create_buffer_error. (#2673) 2022-05-19 13:10:47 -04:00
Jinlei Li
8b2e6fe3a2
Roll naga to 571302e (50 revisions) (#2672) 2022-05-18 21:09:22 -07:00
Jinlei Li
0c1233b834
Move TEXTURE_COMPRESSION_ETC2 | ASTC_LDR to web section to match spec (#2671) 2022-05-18 12:38:53 -04:00
Jinlei Li
36f8d83e5c
Roll wasm32 target dependencies to latest (#2669) 2022-05-17 12:17:06 -04:00
i509VCB
f5c2ff11d0
Adapter and Instance as_hal functions (#2663)
These functions are added to allow lower level access to adapter and instance from backends.
2022-05-17 06:13:58 +00:00
Jinlei Li
26f96c7dfe
Add DEPTH32FLOAT_STENCIL8 featue (#2664) 2022-05-17 02:11:05 -04:00
Jim Blandy
b51fd851be Report invalid pipelines in render bundles as errors, not panics.
Fixes #2665.
2022-05-16 14:26:36 -07:00
Jim Blandy
c608ee0bbe
Accept both parking-lot 0.11 and 0.12.*, to avoid windows-rs. (#2660)
In parking_lot 0.12 and parking_lot_core 0.9.0, those crates switched
from the winapi crate to the official Microsoft windows-sys crate.
This is fine, except that windows-sys and its dependencies are even
larger than winapi. Some users may wish to stick with winapi for the
time being; this change allows wgpu to accommodate them.
2022-05-16 01:16:53 -04:00
Jim Blandy
202d81a64a
Move set_index_buffer FFI functions back into wgpu. (#2661)
It's very odd to have almost all the render pass and compute pass ffi
functions in `wgpu` except for the `set_index_buffer` functions, which
live in Firefox. I'd like to remove these from Firefox and put them
back next to their companions.

These functions were originally removed from wgpu in #1077, because
wgpu-native has its own incompatible version of IndexFormat (see that
PR for details). However, with wgpu-native#85, that code was removed,
so having these functions in `wgpu` should be no longer be a problem
for wgpu-native.
2022-05-15 15:18:05 -04:00
Shaye Garg
75b881e636
fix: panic in Storage::get (#2657)
* fix: don't panic on invalid id in Storage::get

* formatting

* removed double matches

* more match removal

* fix formatting

* add fix to Storage::label_for_invalid_id
2022-05-14 14:59:47 +05:30
Jim Blandy
284ed4654e Spell out the type of the result from map_pass_err.
Without these changes, rust-analyzer cannot determine the type of
`cmd_buf`.
2022-05-13 22:18:12 -07:00
Jinlei Li
8e5ac75d45
metal: fix Rgb9e5Ufloat capabilities and sampler_lod_average support (#2656) 2022-05-14 01:06:06 +00:00
Kevin Reid
c1934dc07f
RenderPassDescriptor: make label lifetime match doc, and make names descriptive. (#2654)
Lifetime names like `<'a, 'b>` mean that the reader must look at how
they are used to understand them. By changing them to `'tex` (lifetime
of borrows of the texture views the documentation describes) and `'desc`
(everything else), and mentioning them in the documentation, it's more
obvious which role each one plays.

For consistency, I also changed `begin_render_pass()`,
`RenderPassColorAttachment`, and `RenderPassDepthStencilAttachment` to
use matching lifetime names.

Also, this made it clear that the `Label` had the wrong lifetime --
the docs say that the texture views have a different lifetime from
“everything else”, but the `Label` in fact had the same lifetime as
the texture views, so I changed it to the `'desc` (formerly `'b`)
lifetime. (On review of change history, this mismatch was previously
introduced in commit 632f828eda9af1f6f18c74398b5f40644cf02f03.)
This change is definitely safe because I followed the data flow down
to `BasePass::new` which promptly calls `to_string()` on the label,
thus converting it to owned data.
2022-05-12 22:16:53 -07:00
Jinlei Li
ddf1903b03
Add SHADER_FLOAT16 feature (#2646)
* Add SHADER_FLOAT16 feature

* vk: check SHADER_FLOAT16 feature
2022-05-12 22:14:19 -07:00
Jim Blandy
144e943737 Two more fixes to WebGPU spec links. 2022-05-12 20:27:54 -07:00
Kevin Reid
07f94d829a Add cross-references to each wgpu type's documentation.
Added:
* WebGPU specification links.
* How to create an instance, if it is not all-public-fields.
* What function or enclosing type this type is used for.

(The latter two are not present for `wgpu-types` items due to the
dependency running the wrong direction for that — I saw existing
`../wgpu/` links, but those do not work on https://docs.rs/wgpu/.)

This commit specifically does not:
* substantially revise existing language, except where necessary to fit
  the new information, or when there was an obvious trivial improvement
  like adding a link to support "how to use this".
* add similar information to the documentation of types not directly
  corresponding to the WebGPU specification
2022-05-12 20:27:54 -07:00
Poly
8e62ca0538 Add new integrated GPU to the list: AMD Renoir
Renoir is codename for AMD series of mainstream mobile and desktop APUs based on the Zen 2 CPU and Vega GPU microarchitectures succeeding Picasso.
2022-05-11 20:32:43 -07:00