fix(core): validate sample_count is 1 in Queue::write_texture#7984
Closed
ErichDonGubler wants to merge 1 commit intogfx-rs:trunkfrom
Closed
fix(core): validate sample_count is 1 in Queue::write_texture#7984ErichDonGubler wants to merge 1 commit intogfx-rs:trunkfrom
sample_count is 1 in Queue::write_texture#7984ErichDonGubler wants to merge 1 commit intogfx-rs:trunkfrom
Conversation
This is a missing piece of the ["validating texture buffer copy" routine](https://www.w3.org/TR/webgpu/#abstract-opdef-validating-texture-buffer-copy), which is currently not outlined in the same way as the WebGPU spec. It's almost certainly better to refactor `writeTexture` and other copy commands so that we can capture the routine and properly share it between different standard operations. This commit leaves this as future work, only fixing the missing validation in `writeTexture.`
d19f441 to
d893b71
Compare
Member
Author
|
A Rust MRE, if anyone is interested: //! A Rust-y version of
//! [`webgpu:api,validation,queue,writeTexture:sample_count:*`](https://github.com/gpuweb/cts/blob/26530c7da1c48ea5d0bf4c5da83b15b996eb522f/src/webgpu/api/validation/queue/writeTexture.spec.ts#L60-L85).
use pollster::FutureExt as _;
fn main() {
env_logger::init();
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::from_env_or_default());
let adapter = instance
.request_adapter(&Default::default())
.block_on()
.unwrap();
let (device, queue) = adapter
.request_device(&Default::default())
.block_on()
.unwrap();
for sample_count in [1, 4] {
let texture = device.create_texture(&wgpu::TextureDescriptor {
label: None,
size: wgpu::Extent3d {
width: 16,
height: 16,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Bgra8Unorm,
usage: wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::RENDER_ATTACHMENT,
view_formats: &[],
});
let data = [0u8; 16];
let size = wgpu::Extent3d {
width: 1,
height: 1,
depth_or_array_layers: 1,
};
let is_valid = sample_count == 1;
device.push_error_scope(wgpu::ErrorFilter::Validation);
queue.write_texture(
wgpu::TexelCopyTextureInfoBase {
texture: &texture,
mip_level: 0,
origin: Default::default(),
aspect: Default::default(),
},
&data,
Default::default(),
size,
);
match (is_valid, device.pop_error_scope().block_on()) {
(true, None) | (false, Some(..)) => (),
(expected_valid, err_opt) => panic!(
concat!(
"expected valid = {} for `sample_count` = {}, ",
"but error scope yielded {:?}"
),
expected_valid, sample_count, err_opt
),
}
}
} |
Member
|
Couldyoumaybeaddthatasavalidationtestmaybe? |
Contributor
|
This fix is also included in #7948. |
Member
Author
Does…the relevant CTS test being added to CI not count? 🤔 |
Contributor
|
I didn't add the same CTS test ( |
Member
Author
|
I see that all parts of this PR have been subsumed into #7948 (nice number, BTW!), which has been merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a missing piece of the "validating texture buffer copy" routine, which is currently not outlined in the same way as the WebGPU spec.
It's almost certainly better to refactor
writeTextureand other copy commands so that we can capture the routine and properly share it between different standard operations. This commit leaves this as future work, only fixing the missing validation inwriteTexture.Connections
webgpu:api,validation,image_copy,buffer_texture_copies:sample_count:*CTS test.Squash or Rebase?
Squash.
Checklist
CHANGELOG.mdentry.