* Add `BGRA8UNORM_STORAGE` extension
* Leave a comment in the backends that don't support bgra8unorm-storage
* Pass the appropriate storage format to naga
* Check for bgra8unorm storage support in the vulkan backend
* Add a test
Co-authored-by: Jinlei Li <jinleili0@outlook.com>
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
* Add the base of the example. May need refining and definitely fact-checking.
* Start change to changelog.
* Complete changelog change for repeated-compute.
* Apply suggestion to fix typos.
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
* Add storage-texture example which currently works native but needs to be changed to work for wasm. [no ci]
* repeated-compute now works on the web. [no ci]
* `storage-texture` now works on the web as well as native.
* Format because I forgot to do that (ugh).
* Add `storage-texture` to changelog.
* Add `render-to-texture` example.
* Not all the files got git added. Fixed it.
* Add `render-to-texture` to changelog.
* Make better readme's and add examples to said readme's.
* Oops. Put the example updates in the wrong place.
* Add `uniform-values` example.
* Apply clippy suggestions.
* Improved readme's and documentation.
* Fmt. Turning into the Joker rn.
* Make instructions for examples on the web more clear. \(Fmt and clippy happy\)
* hello-workgroups It doesn't work.
* Add basic comments and readme to hello-workgroups.
* Add hello-synchronization example. Currently doesn't have any tests but those should be added later.
* Forgot to check wasm compatibility for hello-synchronization. Fixed it.
* Add test for hello-synchronization.
* Make my examples downlevel defaults.
* Make uniform-values downlevel defaults. (Forgot to do that last commit.)
* Fix clippy doc complaints.
* Didn't fully fix the docs last commit. Got it here I think.
* Fix redundant bullet point in examples/hello-workgroups/README.md.
* Trim down the introduction section of examples/hello-workgroups/README.md.
* Add technical links section to examples/hello-workgroups/README.md.
* Use idiomatic Rust comments, break up big text wall into paragraphs, and fix some spelling errors.
* Move output image functions into examples/common and give output_image_wasm some upgrades.
* Modify changelog for moving output_image_native and output_image_wasm into wgpu-example.
* Fix output_image_wasm. (Formerly did not handle pre-existing output image targets.)
* Make a multiline comment be made of single lines to be more ideomatic.
* "Fix" more multiline comments. I think this is actually the last of them.
* Make the window a consistant, square size that's convenient for viewing.
* Make the window on uniform-values not endlessly poll, taking up 100% of the main thread in background at idle. Also, change layout a little and make native use nanos by default for logging.
* Make execute in hello-synchronization return a struct of vecs instead of using out parameters.
* Didn't realize the naming of wgpu_example::framework so I moved my common example utility functions into wgpu_example::utils.
* Add add_web_nothing_to_see_msg function to replace all the instances of adding "open the console" messages across the examples.
* Add small documentation to add_web_nothing_to_see_msg and change it to use h1 instead of p.
* Add documentation to output_image_native and output_image_wasm in examples/common.
* Do better logging for output image functions in wgpu-example::utils.
* Remove redundant append_child'ing of the output image element in wgpu-example::utils::output_image_wasm.
* Fix error regarding log message for having written the image in wgpu-example::utils::output_image_native.
* Fmt.
* In examples/README.md, re-arrange the examples in the graph to be in alphabetical order.
* Fix changlog item regarding wgpu-example::utils and the output image functions.
* Move all the added examples into one changelog item that lists all of them.
* Updated table in examples/README.md with new examples. Added new features to the table to accurately represent the examples.\n\nFor the new features, not all old examples may be fully represented.
* Fix inaccurate comment in hello-workgroups/src/shader.wgsl.
* Update examples/README.md to include basic descriptions of the basic examples as well as hints on how examples build off of each other.
* Remove `capture` example. See changelog entry for reasoning.
* Fix typo in hello-workgroups/shader.wgsl
* Change the method of vertex generation in the shader code of render-to-texture to make it more clear.
* Modify/correct message in repeated-compute/main.rs regarding the output staging buffer.
* Update message in uniform-values/main.rs about writing the app state struct to the input WGSL buffer.
* Add notice in repeated-compute/main.rs about why async channels are necessary (portability to WASM).
* Revise comment in uniform-values/main.rs about why we don't cast the struct using POD to be more clear.
* Change uniform-values to use encase for translating AppState to WGSL bytes.
* Cargo & Clippy: My two best friends.
* Add MIT-0 to the list of allowed liscences.
* Fix docs for wasm.
---------
Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
* Make buffer_unmap check for device validity, add tests.
This patch makes buffer_unmap check for a valid device, and corrects
buffer_map to return the appropriate error for an invalid device.
Tests are added for both operations.
It also adds device validity checks to device_maintain_ids and to the
functions that get and set buffer sub data.
* Update changelog and test comment.
* Run rustfmt.
* Update test device_lose_then_more to specify more buffer usages to keep Vulkan happy.
* wgpu-core: Only produce StageError::InputNotConsumed on DX11/DX12
This error only exists due to an issue with naga's HLSL support:
https://github.com/gfx-rs/naga/issues/1945
The WGPU spec itself allows vertex shader outputs that are
not consumed by the fragment shader.
Until the issue is fixed, we can allow unconsumed outputs on
all platforms other than DX11/DX12.
* Add Features::SHADER_UNUSED_VERTEX_OUTPUT to allow disabling check
* Pick an unused feature id
Implements timer queries via write_timestamp on Metal for encoders (whenever timer queries are available) and passes (for Intel/AMD GPUs, where we should advertise TIMESTAMP_QUERY_INSIDE_PASSES now).
Due to some bugs in Metal this was a lot harder than expected. I believe the solution is close to optimal with the current restrictions in place. For details see code comments.
Due to an issue with Mesa versions less than 21.2 presentation on Vulkan
was forced to Nvidia only. This in itself brought new issues around the
Nvidia driver specfic format modifers.
As of Mesa 21.2 the Intel vulkan issue is fixed. This commit enables
presentation on versions 21.2 and above for Intel.
References:
- https://github.com/NVIDIA/egl-wayland/issues/72
Closes [#4101](https://github.com/gfx-rs/wgpu/issues/4101)
Calling `vkDestroyCommandPool` automatically frees all command buffers allocated
from that pool, so there is no need for `Device::destroy_command_encoder` to
explicitly call `vkFreeCommandBuffers` on the `CommandEncoder`'s `free` and
`discarded` lists.
* Add validation in accordance with WebGPU `setViewport` valid usage for `x`, `y` and `this.[[attachment_size]]`.
`x` and `y` must not be negative, and the rect must be contained in the render target.
* Add changelog entry.
* Explain the general relationship of `set` and `draw` methods.
* Explain render state changes and that you can have lots of them.
* Specify default values of render state.
* Add the docs. (And change max_buffer_size for default and downlevel_default to be more readable.)
* Put limits listed in documentation on seperate lines via bullet points.
* Update changelog.
* Fix fmt.
* Turn doc lists into testable code blocks with markers for changed values.
* Update glow to a new minor version, improve gles adapter astc feature selection
* Update Cargo.lock
* Add changelog entry
* Improve cfg flags to filter out emscripten
Introduces a DisplayOwner struct to own both the library
and associated display pointer; their lifetimes are combined
in that struct.
The display pointer is encapsulated in a DisplayRef.
When DisplayOwner is dropped, it ensures that the DisplayRef
is correctly closed prior to unloading the library.
refs: https://github.com/gfx-rs/wgpu/issues/3813
* Make initialize_adapter_from_env take a compatible surface
Add a compatible surface parameter to initialize_adapter_from_env, and
use that to make initialize_adapter_from_env_or_default always respect
its compatible_surface parameter.
---------
Co-authored-by: Andreas Reich <r_andreas2@web.de>
* web: use `get_preferred_canvas_format()` to fill `formats` of `SurfaceCapabilities`
* Only keep preferred format as the first element
* Update CHANGELOG
* Find preferred format and move it to the first position in the formats.
* Add a note to preferred_format.
* Remove the unnecessary allocation.
* EGL: respect the user requesting a non-sRGB surface format
What used to happen was that sRGB was used whether you requested it or not.
This commit fixes that and now passing in a non-sRGB texture format in SurfaceConfiguration will result in a non-sRGB surface being created.
* add changelog entry about the EGL non-sRGB support change
As described in [Vulkan-ValidationLayers#5671], the validation layers don't understand debug ranges paired across different command buffers on the same queue, even though the Vulkan spec says:
> An application may open a debug label region in one command buffer and close it in another, or otherwise split debug label regions across multiple command buffers or multiple queue submissions. When viewed from the linear series of submissions to a single queue, the calls to vkCmdBeginDebugUtilsLabelEXT and vkCmdEndDebugUtilsLabelEXT must be matched and balanced.
Until this is fixed, wgpu should ignore this validation error to reduce noise in test runs.
Fixes#3733.
[Vulkan-ValidationLayers#5671]: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671
* enable debug extension on emscripten
* update changelog
* extract emscripten stuff into a separate module
* use unmasked queries on w-u-u, and only enable extension on emscripten
* fix docs
* 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
* Fix dx12 shader validation errors when dxil.dll isn't available in the local scope.
* changelog
* clippy
* always explicitly validate shaders to simplify code
* destructor ordering
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.
* Cache programs in GLES backend by their stage info, to avoid recreating the same program untold many times
* Don't duplicate an arcs ref count in gles programs
* Extract ProgramCacheKey from gles ProgramCache
* gles: Panic if we can't acquire program_cache lock
* Clarify why the program cache is safe
* 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`.
* update to ash 0.37.1 to fix CI
* changelog
* Use equals for ash version
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
* 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.
`RenderBundleEncoder::set_index_buffer` and `set_vertex_buffer`
interpret a `size` of `None` to mean "from the given offset to the end
of the buffer", but `std::num::NonZeroU64::new` produces `None` when
its argument is zero, which is quite different. Fix this similarly to
the way it's handled in `op_webgpu_render_pass_set_index_buffer`.
The WebGPU spec says this should work; filed as #3170.
* 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>
* set GL vendor for id Mesa and Apple
* match on "apple m" to mark M2 cpu as integrated in gles
* document AdapterInfo::vendor if the vendor has no PCI id
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.
* Document that `write_buffer_with` is sound to read from.
To a reader informed about Rust's memory model, the existing claim that
> dereferencing it to a `&[u8]` panics
without further context sounds awfully like someone thinks they've
invented a write-only reference, and that the API might actually be
exposing undefined behavior via an uninitialized `&mut [u8]`. Therefore,
let's specify what happens if you *do* read through the mutable
reference. The text added in this commit is based on what was said in
the review when `write_buffer_with` was added:
https://github.com/gfx-rs/wgpu/pull/2777/files#r901392551
This is also relevant information to someone considering using
`write_buffer_with()` for performance gains: for example, it suggests
that it might be a bad idea to write data into the view and then sort
it in-place. (Or is that not a bad idea? Is it not slow if the CPU
already wrote over all the memory contiguously? I don't know.)
* Changelog addition (+ fixing duplicate documentation section)
The function's does not depend on the `canvas` argument meeting the
given requirements to avoid undefined behavior, so it should just be a
normal contract, not a safety contract.
* 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.
Vulkan prohibits including `VkPhysicalDeviceVulkan12Features` structures in the chain passed to `VkCreateDevice` along with other more specific features structs. Similiar restrictions apply to the `...Properties` structures.
Fixes#2925.
* 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.
* Fix opening renderdoc lib
Renderdoc needs to not be opened by us, but instead open the existing copy.
Unfortunately this requires OS specific flags for opening, plus `libloading`
doesn't have full API coverage currently.
* Added changelog entry for #2930
* Hide RTLD_NOLOAD behind a cfg for unix
Co-authored-by: ABuffSeagull <reecevanatta@hey.com>
* StagingBelt: check for free chunks in the `receiver` as well as `free_chunks`.
Previously, chunks would only be taken from the GPU callback receiver
and put on `free_chunks` during `finish()`. So, there might be chunks
that are actually available for use but wouldn't be used.
Now, we consult the receiver whenever we're about to consult the
`free_chunks`, so the reuse of chunks will be as good as possible (given
the application's uses of operations that trigger `map_async` callbacks).
* Changelog entry.
* 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.