* Make crate features no-op on incompatible targets
* Remove `portable_features`
* Test `--all-features` in CI
* Make `renderdoc` no-op on WASM
* Address review
* remove redundant flag
* set the `MULTISAMPLED_SHADING` downlevel flag for gles and dx11
* set the right naga capabilities
add `Features::SHADER_EARLY_DEPTH_TEST`
* add changelog entry
* remove `@early_depth_test` from water example
* clippy --fix
* elide lifetimes
* fmt and more fixes
* disable clippy::needless_borrowed_reference as it clashes with clippy::pattern_type_mismatch
* missed flags for target=wasm32-unknown-unknown
wgpu currently checks if the `write_mask` is 0 to determine wether a
stencil is used as readonly or not. However Webgpu contains a more
complex ruleset that also checks the cull mode and face operations to
determine if the stencil is readonly or not.
This commit brings these new rules to wgpu.
* Add validation in accordance with WebGPU `GPUSamplerDescriptor` valid usage for `lodMinClamp` and `lodMaxClamp`.
`lodMinClamp` must not be negative, and `lodMaxClamp` must be >= `lodMinClamp`
* Add changelog entry.
* Run `cargo fmt`.
Somewhere after 1.64 but by 1.66, `rustdoc` started checking for
unmatched HTML tags in doc strings, meaning that text like
/// Convenience function turning Option<Selector> into this enum.
causes problems, since `rustdoc` will pass through `<Selector>` as
HTML tag, which browsers displaying the output will misunderstand.
* Low-level error handling in canvas context creation (for WebGPU and WebGL 2).
Part of fixing #3017. This commit changes the handling of `web_sys`
errors and nulls from `expect()` to returning `Err`, but it doesn't
actually affect the public API — that will be done in the next commit.
* Breaking: Change type of `create_surface()` functions to expose canvas errors.
Part of fixing #3017.
* enable doc_auto_cfg for docs.rs
This should expose more feature labels in the generated documentation and removes the needs for the manually labeling the features for a type, function or enum variants.
* enable docsrs cfg when building docs for master
* Split Blendability and Filterability into Two Different TextureFormatFeatureFlags
* Update CHANGELOG.md
* Split out individual booleans to improve readability
* Make sure blendablity is correctly set for guaranteed format features of WebGPU
* Cargo fmt
Co-authored-by: Xander Warnez <xander.warnez@materialise.be>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This change is to help with an attempt to allow the Context type in wgpu to be swappable at runtime. In order to do that, the functions provided by Context and it's associated types need to be object safe. Instead of passing a impl trait that combines both HasRawWindowHandle and HasRawDisplayHandle, we seperate the types into their RawDisplayHandle and RawWindowHandle parts internally to reduce some of the hal implementation code mess.
Change `Instance::as_hal<A>` to simply return an
`Option<&A::Instance>`, rather than passing it to a callback. We're
just borrowing a reference to some `wgpu_hal::Api::Instance` owned by
the `wgpu_core::instance::Instance`, so there's no special scoping or
locking magic required here.
* Use () instead of PhantomData as IdentityManager's Input type.
PhantomData suggests that there's some sort of persuasion required
for lifetime variance inference or other sorts of arcana, but it
doesn't seem to be necessary at all. `()` works just fine.
* Have `prepare_staging_buffer` take a raw hal Device.
This helps the borrow checker understand that we can borrow
`pending_writes`'s encoder and the raw Device at the same time.
* Always free staging buffers.
We must ensure that the staging buffer is not leaked when an error
occurs, so allocate it as late as possible, and free it explicitly when
those fallible operations we can't move it past go awry.
Fixes#2959.
* Some tests for texture and buffer copies.
* Add CHANGELOG.md entry.
Since `wgpu-core`'s public functions are supposed to validate their
parameters, the internal `track` module skips many of Rust's usual
run-time checks in release builds. However, some `wgpu-core` users are
happy to pay the performance cost in exchange for more safety. The
`"strict_asserts"` feature causes `wgpu_core` to perform the same
checks in release builds as it does in debug builds.
* Validate that map_async's range is not negative.
map_async already checks that the range's end is within the bounds of the buffer, so this also ensures the range start is within bounds.
* Add an entry in the changelog.
* Record that the buffer is mapped when its size is zero.
* Avoid internally trying to map a zero-sized buffer if mapped_at_creation is true.
* Add an entry in the changelog.
* Ensure the BufferMapAsyncCallback is always called.
This solves two issues on the Gecko side:
- The callback cleans up after itself (the user data is deleted at the end of the callback), so dropping the callback without calling it is a memory leak. I can't think of a better way to implement this on the C++ side since there can be any number of callback at any time living for an unspecified amount of time.
- This makes it easier to implement the error reporting of the WebGPU spec.
* Update the changelog.
* Make the color attachments `Option`-al in render pipelines, render passes, and render bundles
* vk: `Option`-al color attachments support
* dx12: sparse color_attachments support
* Only non-hole attachments is supported on wasm target and gl backend
* deno_webgpu: `Option`-al color attachments support
* Follow all suggestions
* Add Limit::max_buffer_size.
* Prevent very large buffer with some drivers.
Some drivers run into issues when buffer sizes and ranges are larger than what fits signed 32 bit integer. Adapt the maximum buffer size accordingly.
in the thiserror error format string, `{0:?}` ends up referring to the
first named argument, not the first struct field or a compile error, so
the error was incorrectly
Dimension 32768 value 32768 exceeds the limit of 16384
instead of
Dimension X value 32768 exceeds the limit of 16384
* Change all the functions
* Return the set of supported TextureFormat specified by WebGPU
* Remove redundant filtering and use list directly
* Replace pops with first
* Remove now unused function
* Fix doc and clarify preffered format
* Dereference enums
* Remove unused list
* Remove fancy coode
* Update wgpu-core/src/device/mod.rs
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
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.
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`.
* 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.
`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.
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.
* 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>
* 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>
* 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)
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.
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.
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.
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.
* 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