Skip to content

Commit c72f643

Browse files
authored
Merge branch 'trunk' into naga-ray-tracing-pipelines
2 parents fc50128 + f114138 commit c72f643

File tree

19 files changed

+269
-88
lines changed

19 files changed

+269
-88
lines changed

.github/workflows/changelog.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
- ".github/workflows/changelog.yml"
77
- "CHANGELOG.md"
88
- "xtask/**/*"
9+
types:
10+
- opened
11+
- synchronize
12+
- reopened
13+
- labeled
14+
- unlabeled
915

1016
env:
1117
#
@@ -38,6 +44,7 @@ jobs:
3844
with:
3945
fetch-depth: 0
4046

47+
# NOTE: Keep label name(s) in sync. with `xtask`'s implementation.
4148
- name: Run `cargo xtask changelog …`
4249
run: |
43-
cargo xtask changelog "origin/${{ github.event.pull_request.base.ref }}"
50+
cargo xtask changelog "origin/${{ github.event.pull_request.base.ref }}" ${{ contains(github.event.pull_request.labels.*.name, 'changelog: released entry changed') && '--allow-released-changes' || '' }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206
110110

111111
- Added support for transient textures on Vulkan and Metal. By @opstic in [#8247](https://github.com/gfx-rs/wgpu/pull/8247)
112112
- Implement shader triangle barycentric coordinate builtins. By @atlv24 in [#8320](https://github.com/gfx-rs/wgpu/pull/8320).
113+
- Added support for binding arrays of storage textures on Metal. By @msvbg in [#8464](https://github.com/gfx-rs/wgpu/pull/8464)
113114

114115
### Changes
115116

@@ -171,6 +172,7 @@ By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206
171172
#### GLES
172173

173174
- Fix race when downloading texture from compute shader pass. By @SpeedCrash100 in [#8527](https://github.com/gfx-rs/wgpu/pull/8527)
175+
- Fix double window class registration when dynamic libraries are used. By @Azorlogh in [#8548](https://github.com/gfx-rs/wgpu/pull/8548)
174176

175177
#### hal
176178

naga/src/back/msl/writer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,9 +7152,11 @@ template <typename A>
71527152
}
71537153
}
71547154
crate::ImageClass::Storage { .. } => {
7155-
return Err(Error::UnsupportedArrayOf(
7156-
"read-write textures".to_string(),
7157-
));
7155+
if options.lang_version < (3, 0) {
7156+
return Err(Error::UnsupportedArrayOf(
7157+
"read-write textures".to_string(),
7158+
));
7159+
}
71587160
}
71597161
crate::ImageClass::External => {
71607162
return Err(Error::UnsupportedArrayOf(

naga/tests/naga/validation.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,3 +1100,55 @@ fn used() {
11001100
Some("_ = arr2[3];"),
11011101
);
11021102
}
1103+
1104+
/// Expects parsing `input` to succeed and its validation to fail with error equal to `snapshot`.
1105+
#[track_caller]
1106+
fn check_wgsl_validation_error_message(input: &str, snapshot: &str) {
1107+
let module = naga::front::wgsl::parse_str(input).unwrap();
1108+
let err = valid::Validator::new(Default::default(), valid::Capabilities::all())
1109+
.validate(&module)
1110+
.expect_err("module should be invalid")
1111+
.emit_to_string(input);
1112+
if err != snapshot {
1113+
for diff in diff::lines(snapshot, &err) {
1114+
match diff {
1115+
diff::Result::Left(l) => println!("-{l}"),
1116+
diff::Result::Both(l, _) => println!(" {l}"),
1117+
diff::Result::Right(r) => println!("+{r}"),
1118+
}
1119+
}
1120+
panic!("Error does not match the expected snapshot");
1121+
}
1122+
}
1123+
1124+
#[test]
1125+
fn image_store_type_mismatch() {
1126+
check_wgsl_validation_error_message(
1127+
r#"
1128+
@group(0) @binding(0)
1129+
var input_texture: texture_depth_2d;
1130+
@group(0) @binding(1)
1131+
var input_sampler: sampler;
1132+
@group(0) @binding(2)
1133+
var output_texture: texture_storage_2d<r32float,write>;
1134+
1135+
@compute @workgroup_size(1, 1)
1136+
fn main() {
1137+
let d: vec4<f32> = textureGather(input_texture, input_sampler, vec2f(0.0));
1138+
let min_d = min(min(d[0], d[1]), min(d[2], d[3]));
1139+
textureStore(output_texture, vec2u(1), min_d);
1140+
}
1141+
"#,
1142+
r#"error: Entry point main at Compute is invalid
1143+
┌─ wgsl:12:17
1144+
1145+
12 │ let min_d = min(min(d[0], d[1]), min(d[2], d[3]));
1146+
│ ^^^ this value is of type Scalar(Scalar { kind: Float, width: 4 })
1147+
13 │ textureStore(output_texture, vec2u(1), min_d);
1148+
│ ^^^^^^^^^^^^ expects a value argument of type Vector { size: Quad, scalar: Scalar { kind: Float, width: 4 } }
1149+
1150+
= Image store value parameter type mismatch
1151+
1152+
"#,
1153+
);
1154+
}

tests/tests/wgpu-gpu/binding_array/storage_textures.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::num::NonZeroU32;
22

33
use wgpu::*;
44
use wgpu_test::{
5-
gpu_test, image::ReadbackBuffers, FailureCase, GpuTestConfiguration, GpuTestInitializer,
6-
TestParameters, TestingContext,
5+
gpu_test, image::ReadbackBuffers, GpuTestConfiguration, GpuTestInitializer, TestParameters,
6+
TestingContext,
77
};
88

99
pub fn all_tests(tests: &mut Vec<GpuTestInitializer>) {
@@ -26,8 +26,7 @@ static BINDING_ARRAY_STORAGE_TEXTURES: GpuTestConfiguration = GpuTestConfigurati
2626
.limits(Limits {
2727
max_binding_array_elements_per_shader_stage: 17,
2828
..Limits::default()
29-
})
30-
.expect_fail(FailureCase::backend(Backends::METAL)),
29+
}),
3130
)
3231
.run_async(|ctx| async move { binding_array_storage_textures(ctx, false).await });
3332

@@ -45,8 +44,7 @@ static PARTIAL_BINDING_ARRAY_STORAGE_TEXTURES: GpuTestConfiguration = GpuTestCon
4544
.limits(Limits {
4645
max_binding_array_elements_per_shader_stage: 33,
4746
..Limits::default()
48-
})
49-
.expect_fail(FailureCase::backend(Backends::METAL)),
47+
}),
5048
)
5149
.run_async(|ctx| async move { binding_array_storage_textures(ctx, true).await });
5250

wgpu-core/src/command/clear.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ pub(super) fn clear_buffer(
189189
});
190190
}
191191

192+
// This must happen after parameter validation (so that errors are reported
193+
// as required by the spec), but before any side effects.
192194
if offset == end_offset {
193195
log::trace!("Ignoring fill_buffer of size 0");
194196
return Ok(());

wgpu-core/src/command/transfer.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,8 @@ pub(super) fn copy_buffer_to_buffer(
10371037
.into());
10381038
}
10391039

1040+
// This must happen after parameter validation (so that errors are reported
1041+
// as required by the spec), but before any side effects.
10401042
if size == 0 {
10411043
log::trace!("Ignoring copy_buffer_to_buffer of size 0");
10421044
return Ok(());
@@ -1255,6 +1257,8 @@ pub(super) fn copy_texture_to_buffer(
12551257
.check_usage(BufferUsages::COPY_DST)
12561258
.map_err(TransferError::MissingBufferUsage)?;
12571259

1260+
// This must happen after parameter validation (so that errors are reported
1261+
// as required by the spec), but before any side effects.
12581262
if copy_size.width == 0 || copy_size.height == 0 || copy_size.depth_or_array_layers == 0 {
12591263
log::trace!("Ignoring copy_texture_to_buffer of size 0");
12601264
return Ok(());
@@ -1376,12 +1380,6 @@ pub(super) fn copy_texture_to_texture(
13761380
.into());
13771381
}
13781382

1379-
// Handle texture init *before* dealing with barrier transitions so we
1380-
// have an easier time inserting "immediate-inits" that may be required
1381-
// by prior discards in rare cases.
1382-
handle_src_texture_init(state, source, copy_size, src_texture)?;
1383-
handle_dst_texture_init(state, destination, copy_size, dst_texture)?;
1384-
13851383
let src_raw = src_texture.try_raw(state.snatch_guard)?;
13861384
src_texture
13871385
.check_usage(TextureUsages::COPY_SRC)
@@ -1391,11 +1389,19 @@ pub(super) fn copy_texture_to_texture(
13911389
.check_usage(TextureUsages::COPY_DST)
13921390
.map_err(TransferError::MissingTextureUsage)?;
13931391

1392+
// This must happen after parameter validation (so that errors are reported
1393+
// as required by the spec), but before any side effects.
13941394
if copy_size.width == 0 || copy_size.height == 0 || copy_size.depth_or_array_layers == 0 {
13951395
log::trace!("Ignoring copy_texture_to_texture of size 0");
13961396
return Ok(());
13971397
}
13981398

1399+
// Handle texture init *before* dealing with barrier transitions so we
1400+
// have an easier time inserting "immediate-inits" that may be required
1401+
// by prior discards in rare cases.
1402+
handle_src_texture_init(state, source, copy_size, src_texture)?;
1403+
handle_dst_texture_init(state, destination, copy_size, dst_texture)?;
1404+
13991405
let src_pending =
14001406
state
14011407
.tracker

wgpu-core/src/conv.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ pub fn map_texture_usage_from_hal(uses: wgt::TextureUses) -> wgt::TextureUsages
199199
u
200200
}
201201

202+
/// Check the requested texture size against the supported limits.
203+
///
204+
/// This function implements the texture size and sample count checks in [vtd
205+
/// dimension step]. The format checks are elsewhere in [`create_texture`]`.
206+
///
207+
/// Note that while there is some basic checking of the sample count here, there
208+
/// is an additional set of checks when `sample_count > 1` elsewhere in
209+
/// [`create_texture`]`.
210+
///
211+
/// [vtd dimension step]: https://www.w3.org/TR/2025/CRD-webgpu-20251120/#:~:text=or%204.-,If%20descriptor.dimension%20is
212+
/// [`create_texture`]: crate::device::Device::create_texture
202213
pub fn check_texture_dimension_size(
203214
dimension: wgt::TextureDimension,
204215
wgt::Extent3d {

wgpu-core/src/device/queue.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ impl Queue {
537537
let data_size = if let Some(data_size) = wgt::BufferSize::new(data_size) {
538538
data_size
539539
} else {
540+
// This must happen after parameter validation (so that errors are reported
541+
// as required by the spec), but before any side effects.
540542
log::trace!("Ignoring write_buffer of size 0");
541543
return Ok(());
542544
};
@@ -791,6 +793,8 @@ impl Queue {
791793

792794
let dst_raw = dst.try_raw(&snatch_guard)?;
793795

796+
// This must happen after parameter validation (so that errors are reported
797+
// as required by the spec), but before any side effects.
794798
if size.width == 0 || size.height == 0 || size.depth_or_array_layers == 0 {
795799
log::trace!("Ignoring write_texture of size 0");
796800
return Ok(());
@@ -963,11 +967,6 @@ impl Queue {
963967

964968
self.device.check_is_valid()?;
965969

966-
if size.width == 0 || size.height == 0 || size.depth_or_array_layers == 0 {
967-
log::trace!("Ignoring write_texture of size 0");
968-
return Ok(());
969-
}
970-
971970
let mut needs_flag = false;
972971
needs_flag |= matches!(source.source, wgt::ExternalImageSource::OffscreenCanvas(_));
973972
needs_flag |= source.origin != wgt::Origin2d::ZERO;
@@ -1051,6 +1050,13 @@ impl Queue {
10511050

10521051
let (selector, dst_base) = extract_texture_selector(&destination, &size, &dst)?;
10531052

1053+
// This must happen after parameter validation (so that errors are reported
1054+
// as required by the spec), but before any side effects.
1055+
if size.width == 0 || size.height == 0 || size.depth_or_array_layers == 0 {
1056+
log::trace!("Ignoring copy_external_image_to_texture of size 0");
1057+
return Ok(());
1058+
}
1059+
10541060
let mut pending_writes = self.pending_writes.lock();
10551061
let encoder = pending_writes.activate();
10561062

wgpu-core/src/device/resource.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,11 @@ impl Device {
14241424
.map_err(|error| CreateTextureError::MissingFeatures(desc.format, error))?;
14251425

14261426
if desc.sample_count > 1 {
1427+
// <https://www.w3.org/TR/2025/CRD-webgpu-20251120/#:~:text=If%20descriptor%2EsampleCount%20%3E%201>
1428+
//
1429+
// Note that there are also some checks related to the sample count
1430+
// in [`conv::check_texture_dimension_size`].
1431+
14271432
if desc.mip_level_count != 1 {
14281433
return Err(CreateTextureError::InvalidMipLevelCount {
14291434
requested: desc.mip_level_count,

0 commit comments

Comments
 (0)