Commit Graph

215 Commits

Author SHA1 Message Date
Jim Blandy
a50836e0cb
Make wgpu-core users responsible for choosing back ends. (#3254) 2022-12-07 20:58:45 -05:00
Jim Blandy
537f077132
Evaluate gfx_select's #[cfg] conditions at the right time. (#3253)
See the comments in the code for details.
2022-12-05 12:47:42 -08:00
Ashley
6147c91818
Support OES_texture_float_linear in webgl (#3261)
closes https://github.com/gfx-rs/wgpu/issues/3215
2022-12-05 12:58:06 -05:00
Jinlei Li
5f3acf50b4
Decrease max_buffer_size limit value to be compatible with Apple2 GPU (#3255)
* Decrease `max_buffer_size` limit value to be compatible with Apple2 GPU

* Update CHANGELOG

* Update CHANGELOG.md

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-12-03 08:12:43 +00:00
Kevin Reid
2209463a54
Return an error instead of panicking when canvas context is unavailable (#3052)
* 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.
2022-11-30 23:41:29 -05:00
Nicolas Silva
e90aacea96
Validate texture copy ranges earlier to prevent integer overflow (#3090)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-12-01 01:20:48 +00:00
Jim Blandy
9c6a60d97c
Fix surface creation cfgs in example framework. (#3246) 2022-11-30 16:46:24 -05:00
Nicolas Silva
a9d33193b3
Fix incorrect offset in get_mapped_range (#3233)
* Add a test.

* Fix incorrect offset in get_mapped_range.

* Add an entry in the changelog.
2022-11-30 16:45:49 -05:00
Connor Fitzgerald
183ba3f231 Make Surface::get_default_config return an Option. 2022-11-27 01:50:47 -05:00
Connor Fitzgerald
84cb3e65a9 Unify Surface Capabilities APIs under one function call 2022-11-27 01:50:47 -05:00
Nicolas Silva
82e9dcf8f7
Allow unspecified bits when deserializing the API's bitflags (#3229) 2022-11-25 23:13:22 -05:00
Jim Blandy
d4b1d57f3c
Move ResourceMetadata into its own module, and give it a proper interface (#3213) 2022-11-23 17:29:20 -05:00
Jim Blandy
73b23f1c8d
Move minimum supported rust version (MSRV) from 1.65 back to 1.64. (#3231) 2022-11-23 21:22:03 +00:00
Andreas Reich
2ccfb42440
allow gles float textures to be multisampled if available (#3183) 2022-11-23 16:10:11 -05:00
Jim Blandy
596d8851aa
Update ndk-sys to v0.4.1+23.1.7779620, to fix checksum failures. (#3232) 2022-11-23 15:29:22 -05:00
Erich Gubler
18f3f5f6f0
Enable unsafe_ops_in_unsafe_fn lint in all workspaces (#3044) 2022-11-14 10:49:39 -08:00
Ali
3c82a4cd5c
Added support for MSAA(x2,x8) beyond WEBGPU restrictions for native a… (#3140)
Closes https://github.com/gfx-rs/wgpu/issues/2910
2022-11-09 15:19:05 -05:00
Erich Gubler
46af01c302 build: migrate Rust 1.64 -> 1.65 2022-11-07 17:36:04 -08:00
Andreas Reich
a377ae2b7f
Alpha to coverage support for GLES (#3187) 2022-11-07 16:56:59 -05:00
Andreas Reich
b838b0871c
Added new UNRESTRICTED_INDEX_BUFFER downlevel flag. (#3157)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-11-07 15:45:50 -05:00
Nicolas Silva
db30e3909a
Avoid integer overflow on multiplication in write_texture. (#3146) 2022-11-07 15:31:19 -05:00
Jim Blandy
9fb9dbf653 deno_webgpu: Don't confuse zero with "to the end of the buffer".
`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.
2022-11-03 09:14:18 -07:00
Connor Fitzgerald
4d199a38df
Forward port v0.14.1 changelog (#3166) 2022-11-02 22:15:03 +00:00
Lilith
a31cd2ef5c
Remove DEPTH24PLUS_STENCIL8 feature (#3151) 2022-11-02 16:44:15 -04:00
Harald Reingruber
51b34c5b51
Improve compute shader validation error message (#3139)
* Improve compute shader validation error message

* Add entry to changelog.

* Improve error message wording (by cwfitzgerald)

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Add credit and PR link to changelog

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-29 17:49:03 -04:00
Jinlei Li
cc448817e7
Use cargo 1.64 workspace inheritance feature (#3107) 2022-10-20 01:41:17 -04:00
Ashley
d3ab5a197e
WebGL2 multiview support via OVR_multiview2 (#3121)
* Add OVR_multiview2 support

* Add changelog entry

* Only use multiview on wasm32 + unknown

* Add note to Features::MULTIVIEW
2022-10-18 12:14:18 -04:00
Nicolas Silva
d1ff3838b8
Expose the full Result type to the rust map_async callback (#2939) 2022-10-13 15:41:52 -04:00
i509VCB
7aca31fe9c
allow creation of wgpu_hal textures for gles backend (#3046)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-13 06:41:12 +00:00
Jinlei Li
caee97e402
Add get_default_configure to simplify user creation of SurfaceConfiguration (#3034) 2022-10-13 06:15:46 +00:00
Jinlei Li
b72bcc54dc
web: implement queue_validate_write_buffer (#3098) 2022-10-13 02:11:31 -04:00
Jim Blandy
f3d455b617
vulkan: Don't use pointer to dropped PhysicalDeviceDriverProperties. (#3076)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-12 20:52:32 +00:00
killian
0951b033a7
Implement Hash for DepthStencilState and DepthBiasState (#3092)
* Implement Hash for DepthStencilState and DepthBiasState

* Fix clippy error

* cargo fmt

* Fix Hash implementation

Co-authored-by: char0313 <killia.charrier@etudiant.univ-reims.dr>
2022-10-11 19:14:10 +00:00
Andreas Reich
351ca3ea3d
Fix webgl srgb blit not setting the viewport correctly (#3093)
* Fix webgl srgb blit not setting the viewport correctly

* Add changelog notes
2022-10-11 14:04:06 -04:00
Nicolas Silva
eca04f59db
Make some errors not fatal (#3094) 2022-10-11 13:40:30 -04:00
daxpedda
318cb7aa9b
Implement Clone for ShaderModuleDescriptor (#3086) 2022-10-09 14:14:33 -04:00
Andreas Reich
acadd8dad5
webgl backend supports now non-srgb framebuffer (#3070) 2022-10-08 23:48:44 -04:00
Lukas Herzberger
3cd93983b2
Create instance from worker (#2858)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-08 05:49:20 +00:00
Olaroll
f57db150f2
Fixed missing device feature in mipmap example (#3081) 2022-10-08 05:42:57 +00:00
daxpedda
02cc2ae234
[BREAKING] Make Shader(Module)Source::Wgsl optional (#2890) 2022-10-08 01:12:50 -04:00
char0313
6451d31b7a Add a CHANGELOG entry 2022-10-07 18:16:23 -04:00
char0313
ac5390528e Convert All Default Implementations on Enums to derive(Default) 2022-10-07 18:16:23 -04:00
Connor Fitzgerald
29643139e1
Update cargo-public-api report in release notes (#3078) 2022-10-07 00:01:40 +00:00
terrarier2111
1e63e8ca9b
Implement Default for CompositeAlphaMode (#3074) 2022-10-06 20:07:12 +00:00
Jim Blandy
58f92cc6b4
Provoke VUID-vkDestroyDevice-device-00378 without #3069. (#3075) 2022-10-06 18:06:32 +00:00
Nicolas Silva
f68a095ecb Add an entry in the changelog. 2022-10-06 10:12:16 -07:00
Connor Fitzgerald
261069d04f Bump changelog 2022-10-05 18:45:25 -04:00
Mikko Lehtonen
60fd2a32e9
Implement missing PrettyError impls (#3066) 2022-10-05 18:43:52 -04:00
Yaroslav Biletskyi
50e2a5becf
Implement copyExternalImageToTexture (#2781)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-05 21:56:26 +00:00
Nicolas Silva
37de3a3574
Set the image stride to zero when updating a single layer on metal. (#3063)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-05 21:45:12 +00:00
Jinlei Li
b13bb468cb
gl: add Rgba16Float format support for color attachments (#3045)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-10-05 21:31:22 +00:00
Jinlei Li
4992de5938
gl: ASTC_HDR feature detection (#3042) 2022-10-05 17:08:45 -04:00
Dragoș Tiselice
5c33e23b66
Fixed buffer sizes encoding on Metal. (#3047) 2022-10-05 16:44:51 -04:00
i509VCB
2372895944
Handle unsupported surfaces more gracefully (#3054) 2022-10-05 16:42:06 -04:00
Xander Warnez
2c1d7a8a5c
Split Blendability and Filterability into Two Different TextureFormatFeatureFlags (#3012)
* 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>
2022-09-21 19:39:01 +00:00
i509VCB
061e04bff1
expose driver info in AdapterInfo (#3037)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-09-21 02:45:28 +00:00
Jinlei Li
ffd733726a
Update wasm32 dependencies, set alpha_mode on web target (#3040) 2022-09-20 06:53:55 +00:00
i509VCB
65e405193e
vulkan: use effective api version for determining device features (#3011) 2022-09-20 01:11:15 -04:00
i509VCB
f877a8a3c9
Vendor id clarification (#3036)
* 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
2022-09-19 23:52:00 -04:00
daxpedda
95408cd48b
[BREAKING] Wrap ShaderSource::Naga in Cow<'static> (#2903) 2022-09-19 00:50:46 -04:00
Imbris
41006d7a88
Buffer usages mismatch check and documentation for mapped_at_creation size requirement. (#3023)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-09-19 04:41:29 +00:00
Jinlei Li
44399bb4a3
Expose alpha_mode, support non-opaque mode on metal and vk backends (#2836) 2022-09-19 00:10:21 -04:00
i509VCB
b752c7d248
statically assert public wgpu types appropriately implement Send and Sync (#3025) 2022-09-16 12:36:23 -04:00
i509VCB
9e3efd7019
pass around RawDisplayHandle and RawWindowHandle in implementation (#3022)
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.
2022-09-15 16:29:20 -07:00
Jim Blandy
90eb399d43
Fill in Adapter::as_hal and Device::as_hal documentation. (#2992)
In particular, explain why a callback is needed, rather than just
having these functions return an `Option<&A::Mumble>`.
2022-09-02 20:56:27 -07:00
Jinlei Li
e350f50b2f
metal: remove PrivateCapabilities's format_rgb10a2_unorm_surface field (#2981)
* metal: remove PrivateCapabilities's format_rgb10a2_unorm_surface field

* Update CHANGELOG
2022-09-02 20:28:26 -07:00
Jim Blandy
bec26b79ec
Don't use a callback to return backend instance handles. (#2991)
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.
2022-09-02 17:32:58 -07:00
Kevin Reid
4a7fc68df0
Document that write_buffer_with is sound to read from. (#3006)
* 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)
2022-09-02 23:50:15 +00:00
Jim Blandy
7e84bb2eae
Correct create_surface_from_(offscreen)_canvas docs. (#2990)
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.
2022-09-02 16:29:06 -07:00
Andreas Monitzer
6348a07d28
Expose the vk::Queue and the queue index in the Vulkan hal. (#2950) 2022-09-02 22:58:01 +00:00
Jim Blandy
701564da8c
Use () instead of PhantomData as IdentityManager's Input type. (#2972)
* 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.
2022-09-02 15:37:21 -07:00
Jinlei Li
ee7fd47ecb
metal: fix max_storage_xx max_texture max_sampler and max_vertex_xx limits (#2978) 2022-09-02 15:36:07 -07:00
i509VCB
c519901d57
vulkan: remove use of Vulkan12Features/Properties types (#2936)
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.
2022-09-02 21:05:13 +00:00
François
27f6302d5b changelog 2022-09-02 11:41:20 -07:00
Jim Blandy
58bc205f2a Update to Naga b209d911 (2022-9-1).
This removes an expected failure on AMD RADV. I guess #2751 was our
bug all along.
2022-09-02 11:33:55 -07:00
Jim Blandy
7d138e2e76
Avoid overflow in check texture copy bounds. (#2963) 2022-08-28 20:07:04 -04:00
Jim Blandy
a0dfb28b8d
Document wgpu_core id handling, factories, etc. (#2973) 2022-08-28 19:49:09 -04:00
Jim Blandy
2cd08a1c9c
Placate Clippy 0.1.63. (#2977) 2022-08-24 17:25:59 -04:00
Jinlei Li
f918ac1ed1
vk: fix astc_hdr formats support (#2971)
* vk: fix `astc_hdr` formats support

* Update CHANGELOG
2022-08-20 19:18:39 +00:00
Jinlei Li
a08ea2a255
metal: add the missing msg_send![view, retain] call within from_view (#2976)
* metal: add the missing `msg_send![view, retain]` call within `from_view`

* Update CHANGELOG
2022-08-20 07:14:57 -07:00
Jim Blandy
c6ca2a7d0d
Always free staging buffers (#2961)
* 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.
2022-08-13 18:25:49 -07:00
Nicolas Silva
6e99cd3a3e
Fix calculation/validation of layer/mip ranges in create_texture_view (#2955)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-08-14 00:01:19 +00:00
Nicolas Silva
96a85b3ac5
Add missing validation in copy_texture_to-Buffer. (#2958) 2022-08-13 19:48:17 -04:00
Jim Blandy
d655017439
Implement "strict_asserts" feature in wgpu-core. (#2872)
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.
2022-08-08 00:45:39 -04:00
Wyatt Herkamp
f7526ae960
winit 0.27 Update and raw-window-handle 0.5 (#2918) 2022-08-04 06:09:37 +00:00
Nicolas Silva
ef3b31cd9a
Map bounds check (#2938)
* 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.
2022-08-03 20:28:36 -07:00
Kevin Reid
780209dfb4
Add Buffer::size() and Buffer::usage(). (#2923) 2022-08-02 17:10:49 -04:00
ani
29f5f8f60e
Add WGSL examples to documentation (#2888)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-08-02 19:24:10 +00:00
i509VCB
8444fbe460
vulkan: fix issues querying multiview support (#2934) 2022-08-01 20:55:53 -04:00
Nicolas Silva
e59c33046b
Validate against the maximum binding index (#2892)
* Validate binding indices in create_bind_group_layout.

* Add an entry in the changelog
2022-08-01 16:25:32 -04:00
Seamooo
0dce58dfbd
changed websys features in core and hal to align with used features (#2922)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-08-01 19:06:26 +00:00
Reece
4cbf8cfcf1
Fix opening of renderdoc lib (#2930)
* 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>
2022-08-01 01:39:55 +00:00
Nicolas Silva
a05c8dc2dc
Fix buffer zeroing with offset in map_buffer (#2916)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-07-31 22:05:18 +00:00
Kevin Reid
a420e453c3
StagingBelt: check for free chunks in the receiver as well as free_chunks. (#2906)
* 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.
2022-07-26 14:59:27 +00:00
i509VCB
75519839be
export AdapterContext in Gles hal (#2870) 2022-07-25 23:37:50 -04:00
Kevin Reid
7b487682d9
Expand StagingBelt documentation. (#2905) 2022-07-26 03:36:56 +00:00
Nicolas Silva
d0aa3f471a
Validate the number of color attachments in create_render_pipeline (#2913) 2022-07-25 23:28:52 -04:00
Connor Fitzgerald
537c6bed4e
Add warning when using CompareFunction::*Equal without an invariant Attribute (#2887) 2022-07-21 02:24:49 -04:00
Seamus Mulholland-Patterson
e49ef97311 added changelog entry for #2886 2022-07-15 14:11:04 -04:00
Connor Fitzgerald
48325f1aaa
v0.13.2 changelog (#2882) 2022-07-14 01:29:09 +00:00