308 Commits

Author SHA1 Message Date
Vecvec
6558deb204 Split up features. (#6905)
Splits up features into wgpu & webgpu features.
2025-02-08 17:38:06 +01:00
Vecvec
d34707ec3f Rename instance_id & instance_custom_index to instance_index & instance_custom_data (#6780) 2025-02-05 18:23:22 +01:00
Vecvec
7cde4707ec Fix hlsl storage format generation (#6993) 2025-01-31 16:31:03 +01:00
Connor Fitzgerald
8caefceb8e Add rust-version to more crates (#7036) 2025-01-31 10:33:10 +01:00
@brody4hire - C. Jonathan Brody
ea4d18c108 cleanup: resolve spelling errors in test comments (#7028) 2025-01-29 23:49:26 +00:00
@brody4hire - C. Jonathan Brody
df54acc05d use hashbrown in more crates (etc.) (#6938)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-01-27 11:50:33 -05:00
JMS55
0fc0b35899 Transition resources (#6678)
* WIP

* Fix typo

* WIP: Implement structure of  command_encoder_transition_resources

* WIP

* More work

* Clippy

* Fix web build

* Use new types for API, more docs

* Add very basic test

* Try to fix test cfg

* Fix merge

* Missed commit

* Use wgt types instead of hal types

* Implement `Clone` for `ShaderModule` (#6939)

* Move to dispatch trait, move more things to wgt

* Move existing code to use new wgt types

* Fixes

* Format import

* Format another file

* Fixes

* Make module private

* Fix imports

* Fix test imports

* Rexport types

* Fix imports

* Fix import

---------

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-01-24 00:54:19 -05:00
Connor Fitzgerald
d8e7ab1ad1 Refactor Cargo.toml Significantly (#6980) 2025-01-23 22:49:48 +00:00
Teodor Tanasoaia
a8bd1fe1ac [d3d12] bound check dynamic buffers (#6931)
To achieve this for dynamic storage buffers we changed the way we bind them. They now go in root tables and we pass the offset via a root constant.
2025-01-23 17:18:36 +00:00
Connor Fitzgerald
a1fc4a0316 Allow Short Circuting GL Fences (#6942) 2025-01-21 19:28:14 +00:00
Connor Fitzgerald
436f716715 Unconditionally Generate Bindless Samplers in DX12 (#6766) 2025-01-21 14:24:03 -05:00
Connor Fitzgerald
4ed5021996 Ban Dynamic Offsets and Binding Arrays in the Same Bind Group (#6811)
* Ban Dynamic Offsets and Binding Arrays in the Same Bind Group

* Add Tests and Uniform Buffer Restriction
2025-01-20 13:28:32 -05:00
Andreas Reich
426c1d364f Fix missing wgt re-export on wgpu for CopyExternalImageDestInfo (#6962) 2025-01-20 18:00:34 +00:00
Vecvec
bdef8c0407 [spirv] Stop naga causing undefined behavior in rayQueryGet*Intersection (#6752)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-01-17 00:04:33 +00:00
Connor Fitzgerald
0f37714fb8 Separate Out Backend Options into Individual Structs (#6895) 2025-01-15 17:32:15 +00:00
atlv
be95178709 64 bit image atomics (#5537) 2025-01-15 08:05:13 -05:00
Vecvec
0b2c9e4f4b [Ray-tracing] Change index offset to first index (#6873)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-01-14 16:56:24 -05:00
Connor Fitzgerald
c71d67010f Fix Features when Depending on wgpu (#6915) 2025-01-14 18:19:43 +00:00
atlv
18471d8e78 Image atomics support (#6706)
* Image atomics support

* Address feedback

* fix merge

* Fixes

* Add a couple tests

* Update wgpu-types/src/lib.rs

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>

* feedback

* feedback

* glsl

* glsl fix

* fix glsl

* fix fix

* fix fix fic

* fix?

* fix

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2025-01-13 15:37:12 +00:00
AbdullahElsheshtawy
55391f716d Added Texture Blitting Utility (#6852)
* Added TextureBlitter Utility

* Fixed Clippy and made TextureBlitter Public

* Written Documentation

* change cull_mode

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

* syntax error

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

* 1 formatting space in shader

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

* Applied suggestions

* fix test

* Fixed typos

* Fixed the tests

* Fixed the shader after trying it manually and looking at the output.

* Added `BlendState` customization parameter.

* Apply suggestions from code review

Documentation!

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

* Made it Load instead of Clear(Black)

* Added `TextureBlitterBuilder`

* Added feature wgsl feature flag for `pub use texture_blitter...;`

* Re-add file

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-01-10 22:16:01 +00:00
Erich Gubler
d9cc72785b Use more Rust features allowed under REPO_MSRV (#6887)
* chore: remove `std::mem::*` imports now unnecessary with `REPO_MSRV`

`std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust
1.80; see
[`rust`#123168](https://github.com/rust-lang/rust/pull/123168/).

* refactor(benches): s/once_cell::Lazy/std::sync::LazyLock

Weaken our dependence on the `once_cell` crate by using functionality
from `std` instead that was upstreamed from `once_cell`, this time with
what's available in Rust 1.80+.

It's not yet possible to eliminate this dependency entirely, but do what
we can with `REPO_MSRV` for now.

* chore: remove unnecessarily `allow`'d lint rules under `REPO_MSRV`

* chore: migrate easy `allow`s to `expect` under `REPO_MSRV`

Remove or `expect` clear-cut `allow` statements that were easy for me to
figure out.

* chore: `warn` on `clippy::allow_attributes` under `REPO_MSRV`
2025-01-10 22:06:26 +00:00
Connor Fitzgerald
98f1c728ed Turn #6827 Into Failing Regression Test (#6883)
* Turn 6827 Into Failing Regression Test

* Update tests/tests/regression/issue_6827.rs

Co-authored-by: Kevin Reid <kpreid@switchb.org>

* Format

* Fix Paravirtual Device

* DX12 Failure

* Validation Err

* Panick

---------

Co-authored-by: Kevin Reid <kpreid@switchb.org>
2025-01-09 16:53:29 +00:00
Asher Jingkong Chen
198762e5cc feat: Add 32-bit floating-point atomics (SHADER_FLOAT32_ATOMIC) (#6234)
* feat: Add 32-bit floating-point atomics

* Current supported platforms: Metal
* Platforms to support in the future: Vulkan

Related issues or PRs:

* gfx-rs/wgpu#1020

* Add changelog

* Edit changelog

* feat: Add 32-bit float atomics support for Vulkan (SPIR-V shaders)

* atomicSub for f32 in the previous commits is removed.

* Update test

* chore: doc type link

* refactor: Revise float atomics on msl and spv

* Make branches tidy
* Also revise old codes
* Ensure the implementations are supported by Metal and Vulkan backends

* refactor: Renaming flt32 atomics to float32 atomics

* chore: Add link to Vulkan feature

* fix: cargo fmt

* chore: hack comment

* Revert changelog

* Fix: Cargo advisory

* Update wgpu-hal/src/metal/adapter.rs

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>

* Update naga/src/lib.rs

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>

* Adjust feature flag position

---------

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2025-01-09 16:03:47 +00:00
Vecvec
658052885a Use transform_buffer_offset when initialising transform_buffer. (#6864)
* use `transform_buffer_offset` instead of `index_buffer_offset` in part of the initialisation of transform_buffer.

* Format.

* Changelog.

* Only unwrap transform alignment once.
2025-01-07 03:01:50 -05:00
Andreas Reich
fb210ab363 Pass InstanceDescriptor by reference and make it clonable (#6849) 2025-01-06 15:40:30 -05:00
Connor Fitzgerald
03ff99e2c3 Implement Clone on Api Types and Arc Dispatcher (#6665) 2025-01-02 19:30:47 -05:00
Connor Fitzgerald
b38aad994a Fix Skipping Amd RT Tests (#6781) 2024-12-18 15:25:22 -05:00
Samson
d63ca09c34 Add usage to TextureViewDescriptor (#6755)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2024-12-18 18:38:28 +01:00
Erich Gubler
964a8d99d2 chore: satisfy clippy::unnecessary_map_or (#6710)
Started firing in Rust 1.84.
2024-12-16 17:26:12 -05:00
Christofer Nolander
21ff9686a7 Add 1-component ({s,u}{int,norm}{8,16}, float16) and unorm8x4-bgra vertex formats (#6632)
* feat: add missing 8/16-bit vertex formats (and 8-bit bgra) #6614

* add tests for 1-component vertex formats (and bgra)

* metal: unpacking function for 1-component vertex formats

* test: use proper alignment for float16 vertex format

* changelog: new vertex formats
2024-12-16 10:18:50 -05:00
Connor Fitzgerald
bcc962687d Use Static-DXC for tests (#6730) 2024-12-16 10:14:35 -05:00
Connor Fitzgerald
7f1e45ff88 Fix Test Failure on AMD GL (#6726) 2024-12-16 04:13:12 -05:00
Connor Fitzgerald
f384a72bf6 Skip AMD GPUs from RT Tests (#6728) 2024-12-16 04:09:50 -05:00
Connor Fitzgerald
286082acef Bindless Tests (#6732)
* Move Partial Binding into Own File

* Texture Bindless Test

* Make It Work

* Tests

* Uniform Buffers

* BadCode

* Bugs!

* Exclude llvmpipe

* Combine Partial Binding Test

* MVK Issue

* Sampler Array Tests

* Make All Tests Partially Bound As Well
2024-12-16 04:08:05 -05:00
Kent Slaney
5bec461fb5 Override-expressions for Fixed Size Arrays (#6654) 2024-12-10 15:43:22 +01:00
Kent Slaney
b56960b8e8 Add Pipeline Overrides for workgroup_size (#6635) 2024-12-06 11:44:05 +01:00
Connor Fitzgerald
4e139ed199 Rework wgpu-rs Context (#6619) 2024-12-04 12:00:14 -05:00
Vecvec
ed2940d869 Add minor ray tracing tests (#6651) 2024-12-03 11:25:35 +01:00
Erich Gubler
c05aa105f2 refactor!: handle 2024-08 spec. rename of image copy APIs
This commit was authored by running the following Nushell script, using
the `nu` binary and the lovely `fastmod` tool:

```nushell
# Copy-pasted from the OP in [`gpuweb`#4838](https://github.com/gpuweb/gpuweb/pull/4838).
let renames_table = '
Type 	Old 	New 	Used in
dict 	GPUImageDataLayout 	GPUTexelCopyBufferLayout 	"writeTexture,
parent type of ↙"
dict 	GPUImageCopyBuffer 	"GPUTexelCopyBufferInfo
extends ↑" 	T2B, B2T
dict 	GPUImageCopyTexture 	GPUTexelCopyTextureInfo 	T2B, B2T, T2T, writeTexture
dict 	GPUImageCopyTextureTagged 	"GPUCopyExternalImageDestInfo
extends ↑" 	copyExternalImageToTexture
dict 	GPUImageCopyExternalImage 	GPUCopyExternalImageSourceInfo 	copyExternalImageToTexture
union 	GPUImageCopyExternalImageSource 	GPUCopyExternalImageSource 	member of ↖
'

let renames_table = $renames_table
  | from tsv
  | select 'Old ' 'New '
  | rename old new
  | update new { $in | lines | get 0 } # only the first line has the renamed symbol identifier
  | update old { strip_gpu_prefix | str trim }
  | update new { strip_gpu_prefix | str trim }
  | sort-by old | reverse # Replace most specific symbol names first (some have the same "word segments" but with fewer segments)

def strip_gpu_prefix []: string -> string {
  $in | str replace --regex '^GPU' ''
}

# Rename image APIs.
for entry in $renames_table {
  fastmod --accept-all --fixed-strings $entry.old $entry.new --iglob '!CHANGELOG.md' --iglob "!xtask/src/vendor_web_sys.rs" --iglob '!wgpu/src/backend/webgpu/webgpu_sys/' --iglob '!deno_webgpu/' --iglob '!wgpu/src/backend/webgpu.rs'
}
cargo fmt
```

…and cleaning up `deno_webgpu/`'s Rust compilation errors.
2024-11-26 23:16:35 -05:00
teoxoy
f4bdd1cb65 remove Dropped & ReplacedCallback variants of DeviceLostReason 2024-11-26 20:31:18 +01:00
fyellin
2389106a75 Fix set_push_constants for render bundles (#6540) 2024-11-19 11:12:21 +01:00
teoxoy
97acfd26ce rely on our ownership model to keep the device alive while there are still active submissions
`Global::device_drop` was wrongly assuming `device_poll` with `Maintain::Wait` was called but this is not a documented invariant and only `wgpu` was upholding this.
2024-11-14 06:27:37 -08:00
Erich Gubler
b5986a9df1 diag: re-word CreateBindGroupError::InvalidTextureSampleType 2024-11-13 07:02:53 -05:00
Erich Gubler
5fb5719cdc diag: add CreateBindGroupError::InvalidTextureSampleType::view_sample_type 2024-11-13 07:02:53 -05:00
Vecvec
79a6f2cd31 Ray Queries (#6291)
* fix more compile errors

* fix err

* fix all compile errors

* fix clippy errors

* fix issues in ray-traced-triangle example

* fix clippy warnings

* fix wasm not compiling

* fix test

* fix clippy (again)

* fix some rustfmt issues

* fix more rustfmt issues

* fix even more rustfmt issues

* fix yet more rustfmt issues

* add #[allow(dead_code)] to some structs to fix clippy on web assembly

* more format fixes

* even more format fixes

* close to final format fixes

* final format fixes (hopefully)

* actual final format fixes (hopefully)

* move ray_cube_cube example and fix bugs

* move other examples

* fix crash when dropping

* fix test

* apply clippy and rustfmt changes

* fix some memory leaks

* fix incompatibility with new wgpu trunk changes

* fix clippy & fmt

* fix clippy errors on github

* update to trunk

* remove a line that printed log "Created blas ..." in device create tlas

* fix merge issues

* fix merge

* fix fmt

* restored example ray scene functionality

* WIP fix rebase

* Fix compile issues

* More fixes

* Fix rebase

* Add wgls backend write_value_type AccelerationStructure

* Add back xtask Cargo.lock

* Revert serde path

* Doc typos

* Add -diff

* Revert more serde

* Revert serde again?

* Fix doc typo

* add test

* clippy & fmt

* fix error "blas does not exist"

* fix various things

* fix unused acceleration structures causing invalid SPIR-V

* fix merge

* fix use after free in a different way (now moved tlas instances to wgpu_core)

* refactor & fmt

* remove accidentally created file

* remove accidentally created file (actually)

* merge & fix

* Fix problems

* fix validation error

* fix validation

* fix merge

* fmt

* fix merge

* use staging buffer trackers in creating the ray-tracing staging buffers (not the tlas_s)

* change one missed staging buffer's tracker

* wip: example

* finished shadow!

* fix merge

* clippy

* remove some uses of blas ids

* fmt

* fix merge

* deduplicate code shared between command_encoder_build_acceleration_structures and command_encoder_build_acceleration_structures_unsafe_tlas

* clippy

* fix merge

* fix warnings

* clippy & fmt

* re-add matching to get_raw_tlas_instance_size and tlas_instance_into_bytes

* fmt

* fix command

* wip: fix merge

* fix merge

* fmt & docs

* fix wasm clippy

* fix issues with tests

* fix issues with tests

* fmt & clippy (wasm)

* wip ray-traced-triangle (non hal)

* unify camera location in ray_shadows

* fix tests

* add readme to ray_traced_triangle

* note that vertex format must be f32x3 (not yet validated)

* changelog

* require VertexFormat::Float32x3

* fix compile error

* when creating and building acceleration structures require Features::RAY_TRACING_ACCELERATION_STRUCTURE is enabled

* remove duplicate workaround

* fix most feedback

* remove all changes from .gitattributes

* fix compile error in test

* more changes along same lines

* format

* apply feedback to more places

* fix `cargo clippy` not just `cargo clippy --all-features`

* cache max instances from tlas creation

* fix clippy

* fix examples

* fix tests

* remove now useless docs

* add more docs

* yet more docs

* still more docs

* Documentation.

* Running out of unique commit messages to say writing docs.

* Add more references to docs.

* Get BindGroup in scope

* Remove unintentional changes

* Remove #[allow(dead_code)]

* Remove old comments

* Add device.poll

* make ray_scene start right way up

* fmt

* move scratch buffer to its own module

* actually remove intentional changes (turns out wgt is inconsistent)

* use better names in ray_scene/shader.wgsl

* fmt

* remove more unintentional changes.

* work on ray_tracing use after free

* spelling

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

* grammar

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

* move things into struct (should be all vectors with 3 item types or more)

* remove long-standing locks.

* fmt

* move not using index buffer to test

* impl index & index mut for tlas package

* impl index & index mut for tlas package

* fix errors

* fix test errors

* move everything out of ray_tracing.rs

* more index_mut

* fmt

* fix docs links

* move to separate impl block

* fix older request review

* fmt

* remove missed deref

* fix wasm clippy

* change to suggestions

* fmt

* add a note as to why `command_encoder_build_acceleration_structures_unsafe_tlas` and `command_encoder_build_acceleration_structures` are currently separate

* add a todo to reconsider soon `command_encoder_build_acceleration_structures_unsafe_tlas`

* switch to mat4 in ray-tracing examples

* Combine RT Tests Under Single Submodule

* Add More Raytracing Tests and Re-Organize

* Documentation and Formatting Fixes

* Remove Forced Alignment in wgpu-hal

* work on out_of_order_as_build and add out_of_order_as_build_use

* fmt

* update test label naming

* fix one validation error

* fix clippy & fmt

* add acceleration structure creation tests

* make mis-matched index test use the correct function

* move validation into validate_command_buffer

* fix tests

* add blas and tlas to pending writes to remove (now unneeded) `device.poll()`s

* remove commented out code from examples and properly use the constants in ray_shadow

* add examples to examples\README.md

* rename ray tracing to ray queries in readme

* remove unneeded usage from scratch buffer creation

* use snatchables for raw acceleration structures

* format

* add EXPERIMENTAL_ to features

* fix missed comment

---------

Co-authored-by: Daniel Keitel <daniel.mg.keitel@fau.de>
Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
Co-authored-by: atlas dostal <rodol@rivalrebels.com>
Co-authored-by: vero <email@atlasdostal.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2024-11-09 17:59:48 +00:00
David Ellis
080d99b5bf Fix Issue 6467: Prevent MacOS crash on invalid workgroup size definition (#6494) 2024-11-05 14:21:33 +01:00
Andreas Reich
e23146aa3e Avoid breaking change: set_bind_group now takes Into<Option<...>> rather than Option<...> (#6452) 2024-10-23 15:29:42 -04:00
teoxoy
207747cab5 [hlsl-out] add support for restricting indexing to avoid OOB accesses 2024-10-23 16:51:44 +02:00
teoxoy
b32574b368 add OOB indexing test 2024-10-23 16:51:44 +02:00
teoxoy
94e040bc8a avoid creating the bind group for indirect validation if buffer size is 0 2024-10-17 18:41:24 +02:00