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.
This commit is contained in:
Erich Gubler 2024-11-25 17:15:00 -05:00
parent 7fff667c5a
commit c05aa105f2
38 changed files with 248 additions and 247 deletions

View File

@ -348,15 +348,15 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
.resource_table .resource_table
.get::<super::texture::WebGpuTexture>(destination.texture)?; .get::<super::texture::WebGpuTexture>(destination.texture)?;
let source = wgpu_core::command::ImageCopyBuffer { let source = wgpu_core::command::TexelCopyBufferInfo {
buffer: source_buffer_resource.1, buffer: source_buffer_resource.1,
layout: wgpu_types::ImageDataLayout { layout: wgpu_types::TexelCopyBufferLayout {
offset: source.offset, offset: source.offset,
bytes_per_row: source.bytes_per_row, bytes_per_row: source.bytes_per_row,
rows_per_image: source.rows_per_image, rows_per_image: source.rows_per_image,
}, },
}; };
let destination = wgpu_core::command::ImageCopyTexture { let destination = wgpu_core::command::TexelCopyTextureInfo {
texture: destination_texture_resource.id, texture: destination_texture_resource.id,
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,
@ -391,15 +391,15 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
.resource_table .resource_table
.get::<super::buffer::WebGpuBuffer>(destination.buffer)?; .get::<super::buffer::WebGpuBuffer>(destination.buffer)?;
let source = wgpu_core::command::ImageCopyTexture { let source = wgpu_core::command::TexelCopyTextureInfo {
texture: source_texture_resource.id, texture: source_texture_resource.id,
mip_level: source.mip_level, mip_level: source.mip_level,
origin: source.origin, origin: source.origin,
aspect: source.aspect, aspect: source.aspect,
}; };
let destination = wgpu_core::command::ImageCopyBuffer { let destination = wgpu_core::command::TexelCopyBufferInfo {
buffer: destination_buffer_resource.1, buffer: destination_buffer_resource.1,
layout: wgpu_types::ImageDataLayout { layout: wgpu_types::TexelCopyBufferLayout {
offset: destination.offset, offset: destination.offset,
bytes_per_row: destination.bytes_per_row, bytes_per_row: destination.bytes_per_row,
rows_per_image: destination.rows_per_image, rows_per_image: destination.rows_per_image,
@ -434,13 +434,13 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
.resource_table .resource_table
.get::<super::texture::WebGpuTexture>(destination.texture)?; .get::<super::texture::WebGpuTexture>(destination.texture)?;
let source = wgpu_core::command::ImageCopyTexture { let source = wgpu_core::command::TexelCopyTextureInfo {
texture: source_texture_resource.id, texture: source_texture_resource.id,
mip_level: source.mip_level, mip_level: source.mip_level,
origin: source.origin, origin: source.origin,
aspect: source.aspect, aspect: source.aspect,
}; };
let destination = wgpu_core::command::ImageCopyTexture { let destination = wgpu_core::command::TexelCopyTextureInfo {
texture: destination_texture_resource.id, texture: destination_texture_resource.id,
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,

View File

@ -62,9 +62,9 @@ pub struct GpuImageDataLayout {
rows_per_image: Option<u32>, rows_per_image: Option<u32>,
} }
impl From<GpuImageDataLayout> for wgpu_types::ImageDataLayout { impl From<GpuImageDataLayout> for wgpu_types::TexelCopyBufferLayout {
fn from(layout: GpuImageDataLayout) -> Self { fn from(layout: GpuImageDataLayout) -> Self {
wgpu_types::ImageDataLayout { wgpu_types::TexelCopyBufferLayout {
offset: layout.offset, offset: layout.offset,
bytes_per_row: layout.bytes_per_row, bytes_per_row: layout.bytes_per_row,
rows_per_image: layout.rows_per_image, rows_per_image: layout.rows_per_image,
@ -119,7 +119,7 @@ pub fn op_webgpu_write_texture(
let queue_resource = state.resource_table.get::<WebGpuQueue>(queue_rid)?; let queue_resource = state.resource_table.get::<WebGpuQueue>(queue_rid)?;
let queue = queue_resource.1; let queue = queue_resource.1;
let destination = wgpu_core::command::ImageCopyTexture { let destination = wgpu_core::command::TexelCopyTextureInfo {
texture: texture_resource.id, texture: texture_resource.id,
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,

View File

@ -262,7 +262,7 @@ impl crate::framework::Example for Example {
queue.write_texture( queue.write_texture(
texture.as_image_copy(), texture.as_image_copy(),
&buf, &buf,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(info.width * 4), bytes_per_row: Some(info.width * 4),
rows_per_image: None, rows_per_image: None,

View File

@ -183,7 +183,7 @@ impl crate::framework::Example for Example {
queue.write_texture( queue.write_texture(
texture.as_image_copy(), texture.as_image_copy(),
&texels, &texels,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(size), bytes_per_row: Some(size),
rows_per_image: None, rows_per_image: None,

View File

@ -595,15 +595,15 @@ impl<E: Example + wgpu::WasmNotSendSync> From<ExampleTestParams<E>>
.create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); .create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
cmd_buf.copy_texture_to_buffer( cmd_buf.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &dst_texture, texture: &dst_texture,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &dst_buffer, buffer: &dst_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(params.width * 4), bytes_per_row: Some(params.width * 4),
rows_per_image: None, rows_per_image: None,

View File

@ -246,9 +246,9 @@ impl crate::framework::Example for Example {
usage: wgpu::BufferUsages::COPY_SRC, usage: wgpu::BufferUsages::COPY_SRC,
}); });
init_encoder.copy_buffer_to_texture( init_encoder.copy_buffer_to_texture(
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &temp_buf, buffer: &temp_buf,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4 * size), bytes_per_row: Some(4 * size),
rows_per_image: None, rows_per_image: None,

View File

@ -101,15 +101,15 @@ async fn run(_path: Option<String>) {
} }
// The texture now contains our rendered image // The texture now contains our rendered image
command_encoder.copy_texture_to_buffer( command_encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &render_target, texture: &render_target,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &output_staging_buffer, buffer: &output_staging_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
// This needs to be a multiple of 256. Normally we would need to pad // This needs to be a multiple of 256. Normally we would need to pad
// it but we here know it will work out anyways. // it but we here know it will work out anyways.

View File

@ -119,15 +119,15 @@ async fn run(_path: Option<String>) {
compute_pass.dispatch_workgroups(TEXTURE_DIMS.0 as u32, TEXTURE_DIMS.1 as u32, 1); compute_pass.dispatch_workgroups(TEXTURE_DIMS.0 as u32, TEXTURE_DIMS.1 as u32, 1);
} }
command_encoder.copy_texture_to_buffer( command_encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &storage_texture, texture: &storage_texture,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &output_staging_buffer, buffer: &output_staging_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
// This needs to be padded to 256. // This needs to be padded to 256.
bytes_per_row: Some((TEXTURE_DIMS.0 * 4) as u32), bytes_per_row: Some((TEXTURE_DIMS.0 * 4) as u32),

View File

@ -195,7 +195,7 @@ impl crate::framework::Example for Example {
queue.write_texture( queue.write_texture(
red_texture.as_image_copy(), red_texture.as_image_copy(),
&red_texture_data, &red_texture_data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,
@ -205,7 +205,7 @@ impl crate::framework::Example for Example {
queue.write_texture( queue.write_texture(
green_texture.as_image_copy(), green_texture.as_image_copy(),
&green_texture_data, &green_texture_data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,
@ -215,7 +215,7 @@ impl crate::framework::Example for Example {
queue.write_texture( queue.write_texture(
blue_texture.as_image_copy(), blue_texture.as_image_copy(),
&blue_texture_data, &blue_texture_data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,
@ -225,7 +225,7 @@ impl crate::framework::Example for Example {
queue.write_texture( queue.write_texture(
white_texture.as_image_copy(), white_texture.as_image_copy(),
&white_texture_data, &white_texture_data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,

View File

@ -398,18 +398,18 @@ fn copy_texture_to_buffer_with_aspect(
); );
let mip_level = 0; let mip_level = 0;
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
ImageCopyTexture { TexelCopyTextureInfo {
texture, texture,
mip_level, mip_level,
origin: Origin3d::ZERO, origin: Origin3d::ZERO,
aspect, aspect,
}, },
ImageCopyBuffer { TexelCopyBufferInfo {
buffer: match aspect { buffer: match aspect {
TextureAspect::StencilOnly => buffer_stencil.as_ref().unwrap(), TextureAspect::StencilOnly => buffer_stencil.as_ref().unwrap(),
_ => buffer, _ => buffer,
}, },
layout: ImageDataLayout { layout: TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(bytes_per_row), bytes_per_row: Some(bytes_per_row),
rows_per_image: Some(texture.height() / block_height), rows_per_image: Some(texture.height() / block_height),

View File

@ -116,15 +116,15 @@ static BGRA8_UNORM_STORAGE: GpuTestConfiguration = GpuTestConfiguration::new()
} }
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture, texture: &texture,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d { x: 0, y: 0, z: 0 }, origin: wgpu::Origin3d { x: 0, y: 0, z: 0 },
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &readback_buffer, buffer: &readback_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(256 * 4), bytes_per_row: Some(256 * 4),
rows_per_image: Some(256), rows_per_image: Some(256),

View File

@ -385,9 +385,9 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
&ctx.device, &ctx.device,
|| { || {
encoder_for_buffer_texture_copy.copy_buffer_to_texture( encoder_for_buffer_texture_copy.copy_buffer_to_texture(
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &buffer_source, buffer: &buffer_source,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,
@ -406,9 +406,9 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|| { || {
encoder_for_texture_buffer_copy.copy_texture_to_buffer( encoder_for_texture_buffer_copy.copy_texture_to_buffer(
texture_for_read.as_image_copy(), texture_for_read.as_image_copy(),
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &buffer_source, buffer: &buffer_source,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,

View File

@ -168,9 +168,9 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) {
"copy_buffer_to_texture", "copy_buffer_to_texture",
Box::new(|encoder: &mut wgpu::CommandEncoder| { Box::new(|encoder: &mut wgpu::CommandEncoder| {
encoder.copy_buffer_to_texture( encoder.copy_buffer_to_texture(
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &buffer_source, buffer: &buffer_source,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,
@ -185,15 +185,15 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) {
"copy_texture_to_buffer", "copy_texture_to_buffer",
Box::new(|encoder: &mut wgpu::CommandEncoder| { Box::new(|encoder: &mut wgpu::CommandEncoder| {
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture_src, texture: &texture_src,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &buffer_dest, buffer: &buffer_dest,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,
@ -207,13 +207,13 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) {
"copy_texture_to_texture", "copy_texture_to_texture",
Box::new(|encoder: &mut wgpu::CommandEncoder| { Box::new(|encoder: &mut wgpu::CommandEncoder| {
encoder.copy_texture_to_texture( encoder.copy_texture_to_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture_src, texture: &texture_src,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture_dst, texture: &texture_dst,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,

View File

@ -269,12 +269,12 @@ static IMAGE_BITMAP_IMPORT: GpuTestConfiguration =
!valid, !valid,
|| { || {
ctx.queue.copy_external_image_to_texture( ctx.queue.copy_external_image_to_texture(
&wgpu::ImageCopyExternalImage { &wgpu::CopyExternalImageSourceInfo {
source: source.clone(), source: source.clone(),
origin: src_origin, origin: src_origin,
flip_y: src_flip_y, flip_y: src_flip_y,
}, },
wgpu::ImageCopyTextureTagged { wgpu::CopyExternalImageDestInfo {
texture: &texture, texture: &texture,
mip_level: 0, mip_level: 0,
origin: dest_origin, origin: dest_origin,
@ -299,7 +299,7 @@ static IMAGE_BITMAP_IMPORT: GpuTestConfiguration =
.device .device
.create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); .create_command_encoder(&wgpu::CommandEncoderDescriptor::default());
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture, texture: &texture,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d { origin: wgpu::Origin3d {
@ -309,9 +309,9 @@ static IMAGE_BITMAP_IMPORT: GpuTestConfiguration =
}, },
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &readback_buffer, buffer: &readback_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(256), bytes_per_row: Some(256),
rows_per_image: None, rows_per_image: None,

View File

@ -26,14 +26,14 @@ static QUEUE_WRITE_TEXTURE_OVERFLOW: GpuTestConfiguration =
&ctx.device, &ctx.device,
|| { || {
ctx.queue.write_texture( ctx.queue.write_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture, texture: &texture,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d { x: 0, y: 0, z: 1 }, origin: wgpu::Origin3d { x: 0, y: 0, z: 1 },
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
&data, &data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(879161360), bytes_per_row: Some(879161360),
//bytes_per_image: 4294967295, //bytes_per_image: 4294967295,

View File

@ -164,15 +164,15 @@ async fn reinterpret(
.device .device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &target_tex, texture: &target_tex,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &read_buffer, buffer: &read_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(wgpu::COPY_BYTES_PER_ROW_ALIGNMENT), bytes_per_row: Some(wgpu::COPY_BYTES_PER_ROW_ALIGNMENT),
rows_per_image: None, rows_per_image: None,

View File

@ -13,7 +13,7 @@ static BAD_COPY_ORIGIN_TEST: GpuTestConfiguration = GpuTestConfiguration::new().
should_panic, should_panic,
|| { || {
ctx.queue.write_texture( ctx.queue.write_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &texture, texture: &texture,
mip_level: 0, mip_level: 0,
origin, origin,
@ -108,7 +108,7 @@ const BYTES_PER_PIXEL: u32 = 4;
const BUFFER_SIZE: u32 = TEXTURE_SIZE.width * TEXTURE_SIZE.height * BYTES_PER_PIXEL; const BUFFER_SIZE: u32 = TEXTURE_SIZE.width * TEXTURE_SIZE.height * BYTES_PER_PIXEL;
const BUFFER_COPY_LAYOUT: wgpu::ImageDataLayout = wgpu::ImageDataLayout { const BUFFER_COPY_LAYOUT: wgpu::TexelCopyBufferLayout = wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(TEXTURE_SIZE.width * BYTES_PER_PIXEL), bytes_per_row: Some(TEXTURE_SIZE.width * BYTES_PER_PIXEL),
rows_per_image: None, rows_per_image: None,

View File

@ -40,13 +40,13 @@ static COPY_OVERFLOW_Z: GpuTestConfiguration = GpuTestConfiguration::new().run_s
|| { || {
// Validation should catch the silly selected z layer range without panicking. // Validation should catch the silly selected z layer range without panicking.
encoder.copy_texture_to_texture( encoder.copy_texture_to_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &t1, texture: &t1,
mip_level: 1, mip_level: 1,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &t2, texture: &t2,
mip_level: 1, mip_level: 1,
origin: wgpu::Origin3d { origin: wgpu::Origin3d {

View File

@ -26,14 +26,14 @@ static WRITE_TEXTURE_SUBSET_2D: GpuTestConfiguration =
let data = vec![1u8; size as usize * 2]; let data = vec![1u8; size as usize * 2];
// Write the first two rows // Write the first two rows
ctx.queue.write_texture( ctx.queue.write_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &tex, texture: &tex,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
&data, &data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(size), bytes_per_row: Some(size),
rows_per_image: Some(size), rows_per_image: Some(size),
@ -59,15 +59,15 @@ static WRITE_TEXTURE_SUBSET_2D: GpuTestConfiguration =
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &tex, texture: &tex,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &read_buffer, buffer: &read_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(size), bytes_per_row: Some(size),
rows_per_image: Some(size), rows_per_image: Some(size),
@ -121,14 +121,14 @@ static WRITE_TEXTURE_SUBSET_3D: GpuTestConfiguration =
let data = vec![1u8; (size * size) as usize * 2]; let data = vec![1u8; (size * size) as usize * 2];
// Write the first two slices // Write the first two slices
ctx.queue.write_texture( ctx.queue.write_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &tex, texture: &tex,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
&data, &data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(size), bytes_per_row: Some(size),
rows_per_image: Some(size), rows_per_image: Some(size),
@ -154,15 +154,15 @@ static WRITE_TEXTURE_SUBSET_3D: GpuTestConfiguration =
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
encoder.copy_texture_to_buffer( encoder.copy_texture_to_buffer(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &tex, texture: &tex,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
wgpu::ImageCopyBuffer { wgpu::TexelCopyBufferInfo {
buffer: &read_buffer, buffer: &read_buffer,
layout: wgpu::ImageDataLayout { layout: wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(size), bytes_per_row: Some(size),
rows_per_image: Some(size), rows_per_image: Some(size),
@ -213,14 +213,14 @@ static WRITE_TEXTURE_NO_OOB: GpuTestConfiguration =
}); });
let data = vec![1u8; size as usize * 2 + 100]; // check that we don't attempt to copy OOB internally by adding 100 bytes here let data = vec![1u8; size as usize * 2 + 100]; // check that we don't attempt to copy OOB internally by adding 100 bytes here
ctx.queue.write_texture( ctx.queue.write_texture(
wgpu::ImageCopyTexture { wgpu::TexelCopyTextureInfo {
texture: &tex, texture: &tex,
mip_level: 0, mip_level: 0,
origin: wgpu::Origin3d::ZERO, origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All, aspect: wgpu::TextureAspect::All,
}, },
&data, &data,
wgpu::ImageDataLayout { wgpu::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(size), bytes_per_row: Some(size),
rows_per_image: Some(size), rows_per_image: Some(size),

View File

@ -177,14 +177,14 @@ impl<'ctx> TestCase<'ctx> {
let buffer_size = texture.height() * bytes_per_row; let buffer_size = texture.height() * bytes_per_row;
let data = vec![255; buffer_size as usize]; let data = vec![255; buffer_size as usize];
ctx.queue.write_texture( ctx.queue.write_texture(
ImageCopyTexture { TexelCopyTextureInfo {
texture: &texture, texture: &texture,
mip_level: 0, mip_level: 0,
origin: Origin3d { x: 0, y: 0, z: 0 }, origin: Origin3d { x: 0, y: 0, z: 0 },
aspect: TextureAspect::All, aspect: TextureAspect::All,
}, },
&data, &data,
ImageDataLayout { TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(bytes_per_row), bytes_per_row: Some(bytes_per_row),
rows_per_image: None, rows_per_image: None,

View File

@ -386,7 +386,7 @@ fn clear_texture_via_buffer_copies(
let num_rows = num_rows_left.min(max_rows_per_copy); let num_rows = num_rows_left.min(max_rows_per_copy);
zero_buffer_copy_regions.push(hal::BufferTextureCopy { zero_buffer_copy_regions.push(hal::BufferTextureCopy {
buffer_layout: wgt::ImageDataLayout { buffer_layout: wgt::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(bytes_per_row), bytes_per_row: Some(bytes_per_row),
rows_per_image: None, rows_per_image: None,

View File

@ -27,9 +27,9 @@ use std::sync::Arc;
use super::{ClearError, CommandBufferMutable}; use super::{ClearError, CommandBufferMutable};
pub type ImageCopyBuffer = wgt::ImageCopyBuffer<BufferId>; pub type TexelCopyBufferInfo = wgt::TexelCopyBufferInfo<BufferId>;
pub type ImageCopyTexture = wgt::ImageCopyTexture<TextureId>; pub type TexelCopyTextureInfo = wgt::TexelCopyTextureInfo<TextureId>;
pub type ImageCopyTextureTagged = wgt::ImageCopyTextureTagged<TextureId>; pub type CopyExternalImageDestInfo = wgt::CopyExternalImageDestInfo<TextureId>;
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub enum CopySide { pub enum CopySide {
@ -153,7 +153,7 @@ impl From<DeviceError> for CopyError {
} }
pub(crate) fn extract_texture_selector<T>( pub(crate) fn extract_texture_selector<T>(
copy_texture: &wgt::ImageCopyTexture<T>, copy_texture: &wgt::TexelCopyTextureInfo<T>,
copy_size: &Extent3d, copy_size: &Extent3d,
texture: &Texture, texture: &Texture,
) -> Result<(TextureSelector, hal::TextureCopyBase), TransferError> { ) -> Result<(TextureSelector, hal::TextureCopyBase), TransferError> {
@ -203,7 +203,7 @@ pub(crate) fn extract_texture_selector<T>(
/// ///
/// [vltd]: https://gpuweb.github.io/gpuweb/#abstract-opdef-validating-linear-texture-data /// [vltd]: https://gpuweb.github.io/gpuweb/#abstract-opdef-validating-linear-texture-data
pub(crate) fn validate_linear_texture_data( pub(crate) fn validate_linear_texture_data(
layout: &wgt::ImageDataLayout, layout: &wgt::TexelCopyBufferLayout,
format: wgt::TextureFormat, format: wgt::TextureFormat,
aspect: wgt::TextureAspect, aspect: wgt::TextureAspect,
buffer_size: BufferAddress, buffer_size: BufferAddress,
@ -311,7 +311,7 @@ pub(crate) fn validate_linear_texture_data(
/// ///
/// [vtcr]: https://gpuweb.github.io/gpuweb/#validating-texture-copy-range /// [vtcr]: https://gpuweb.github.io/gpuweb/#validating-texture-copy-range
pub(crate) fn validate_texture_copy_range<T>( pub(crate) fn validate_texture_copy_range<T>(
texture_copy_view: &wgt::ImageCopyTexture<T>, texture_copy_view: &wgt::TexelCopyTextureInfo<T>,
desc: &wgt::TextureDescriptor<(), Vec<wgt::TextureFormat>>, desc: &wgt::TextureDescriptor<(), Vec<wgt::TextureFormat>>,
texture_side: CopySide, texture_side: CopySide,
copy_size: &Extent3d, copy_size: &Extent3d,
@ -404,7 +404,7 @@ fn handle_texture_init(
init_kind: MemoryInitKind, init_kind: MemoryInitKind,
cmd_buf_data: &mut CommandBufferMutable, cmd_buf_data: &mut CommandBufferMutable,
device: &Device, device: &Device,
copy_texture: &ImageCopyTexture, copy_texture: &TexelCopyTextureInfo,
copy_size: &Extent3d, copy_size: &Extent3d,
texture: &Arc<Texture>, texture: &Arc<Texture>,
snatch_guard: &SnatchGuard<'_>, snatch_guard: &SnatchGuard<'_>,
@ -453,7 +453,7 @@ fn handle_texture_init(
fn handle_src_texture_init( fn handle_src_texture_init(
cmd_buf_data: &mut CommandBufferMutable, cmd_buf_data: &mut CommandBufferMutable,
device: &Device, device: &Device,
source: &ImageCopyTexture, source: &TexelCopyTextureInfo,
copy_size: &Extent3d, copy_size: &Extent3d,
texture: &Arc<Texture>, texture: &Arc<Texture>,
snatch_guard: &SnatchGuard<'_>, snatch_guard: &SnatchGuard<'_>,
@ -477,7 +477,7 @@ fn handle_src_texture_init(
fn handle_dst_texture_init( fn handle_dst_texture_init(
cmd_buf_data: &mut CommandBufferMutable, cmd_buf_data: &mut CommandBufferMutable,
device: &Device, device: &Device,
destination: &ImageCopyTexture, destination: &TexelCopyTextureInfo,
copy_size: &Extent3d, copy_size: &Extent3d,
texture: &Arc<Texture>, texture: &Arc<Texture>,
snatch_guard: &SnatchGuard<'_>, snatch_guard: &SnatchGuard<'_>,
@ -673,8 +673,8 @@ impl Global {
pub fn command_encoder_copy_buffer_to_texture( pub fn command_encoder_copy_buffer_to_texture(
&self, &self,
command_encoder_id: CommandEncoderId, command_encoder_id: CommandEncoderId,
source: &ImageCopyBuffer, source: &TexelCopyBufferInfo,
destination: &ImageCopyTexture, destination: &TexelCopyTextureInfo,
copy_size: &Extent3d, copy_size: &Extent3d,
) -> Result<(), CopyError> { ) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_buffer_to_texture"); profiling::scope!("CommandEncoder::copy_buffer_to_texture");
@ -826,8 +826,8 @@ impl Global {
pub fn command_encoder_copy_texture_to_buffer( pub fn command_encoder_copy_texture_to_buffer(
&self, &self,
command_encoder_id: CommandEncoderId, command_encoder_id: CommandEncoderId,
source: &ImageCopyTexture, source: &TexelCopyTextureInfo,
destination: &ImageCopyBuffer, destination: &TexelCopyBufferInfo,
copy_size: &Extent3d, copy_size: &Extent3d,
) -> Result<(), CopyError> { ) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_texture_to_buffer"); profiling::scope!("CommandEncoder::copy_texture_to_buffer");
@ -993,8 +993,8 @@ impl Global {
pub fn command_encoder_copy_texture_to_texture( pub fn command_encoder_copy_texture_to_texture(
&self, &self,
command_encoder_id: CommandEncoderId, command_encoder_id: CommandEncoderId,
source: &ImageCopyTexture, source: &TexelCopyTextureInfo,
destination: &ImageCopyTexture, destination: &TexelCopyTextureInfo,
copy_size: &Extent3d, copy_size: &Extent3d,
) -> Result<(), CopyError> { ) -> Result<(), CopyError> {
profiling::scope!("CommandEncoder::copy_texture_to_texture"); profiling::scope!("CommandEncoder::copy_texture_to_texture");

View File

@ -5,7 +5,7 @@ use crate::{
command::{ command::{
extract_texture_selector, validate_linear_texture_data, validate_texture_copy_range, extract_texture_selector, validate_linear_texture_data, validate_texture_copy_range,
ClearError, CommandAllocator, CommandBuffer, CommandEncoderError, CopySide, ClearError, CommandAllocator, CommandBuffer, CommandEncoderError, CopySide,
ImageCopyTexture, TransferError, TexelCopyTextureInfo, TransferError,
}, },
conv, conv,
device::{DeviceError, WaitIdleError}, device::{DeviceError, WaitIdleError},
@ -680,9 +680,9 @@ impl Queue {
pub fn write_texture( pub fn write_texture(
&self, &self,
destination: wgt::ImageCopyTexture<Fallible<Texture>>, destination: wgt::TexelCopyTextureInfo<Fallible<Texture>>,
data: &[u8], data: &[u8],
data_layout: &wgt::ImageDataLayout, data_layout: &wgt::TexelCopyBufferLayout,
size: &wgt::Extent3d, size: &wgt::Extent3d,
) -> Result<(), QueueWriteError> { ) -> Result<(), QueueWriteError> {
profiling::scope!("Queue::write_texture"); profiling::scope!("Queue::write_texture");
@ -694,7 +694,7 @@ impl Queue {
} }
let dst = destination.texture.get()?; let dst = destination.texture.get()?;
let destination = wgt::ImageCopyTexture { let destination = wgt::TexelCopyTextureInfo {
texture: (), texture: (),
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,
@ -857,7 +857,7 @@ impl Queue {
let mut texture_base = dst_base.clone(); let mut texture_base = dst_base.clone();
texture_base.array_layer += array_layer_offset; texture_base.array_layer += array_layer_offset;
hal::BufferTextureCopy { hal::BufferTextureCopy {
buffer_layout: wgt::ImageDataLayout { buffer_layout: wgt::TexelCopyBufferLayout {
offset: array_layer_offset as u64 offset: array_layer_offset as u64
* rows_per_image as u64 * rows_per_image as u64
* stage_bytes_per_row as u64, * stage_bytes_per_row as u64,
@ -901,8 +901,8 @@ impl Queue {
#[cfg(webgl)] #[cfg(webgl)]
pub fn copy_external_image_to_texture( pub fn copy_external_image_to_texture(
&self, &self,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
destination: wgt::ImageCopyTextureTagged<Fallible<Texture>>, destination: wgt::CopyExternalImageDestInfo<Fallible<Texture>>,
size: wgt::Extent3d, size: wgt::Extent3d,
) -> Result<(), QueueWriteError> { ) -> Result<(), QueueWriteError> {
profiling::scope!("Queue::copy_external_image_to_texture"); profiling::scope!("Queue::copy_external_image_to_texture");
@ -933,7 +933,7 @@ impl Queue {
let dst = destination.texture.get()?; let dst = destination.texture.get()?;
let premultiplied_alpha = destination.premultiplied_alpha; let premultiplied_alpha = destination.premultiplied_alpha;
let destination = wgt::ImageCopyTexture { let destination = wgt::TexelCopyTextureInfo {
texture: (), texture: (),
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,
@ -1475,9 +1475,9 @@ impl Global {
pub fn queue_write_texture( pub fn queue_write_texture(
&self, &self,
queue_id: QueueId, queue_id: QueueId,
destination: &ImageCopyTexture, destination: &TexelCopyTextureInfo,
data: &[u8], data: &[u8],
data_layout: &wgt::ImageDataLayout, data_layout: &wgt::TexelCopyBufferLayout,
size: &wgt::Extent3d, size: &wgt::Extent3d,
) -> Result<(), QueueWriteError> { ) -> Result<(), QueueWriteError> {
let queue = self.hub.queues.get(queue_id); let queue = self.hub.queues.get(queue_id);
@ -1493,7 +1493,7 @@ impl Global {
}); });
} }
let destination = wgt::ImageCopyTexture { let destination = wgt::TexelCopyTextureInfo {
texture: self.hub.textures.get(destination.texture), texture: self.hub.textures.get(destination.texture),
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,
@ -1506,12 +1506,12 @@ impl Global {
pub fn queue_copy_external_image_to_texture( pub fn queue_copy_external_image_to_texture(
&self, &self,
queue_id: QueueId, queue_id: QueueId,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
destination: crate::command::ImageCopyTextureTagged, destination: crate::command::CopyExternalImageDestInfo,
size: wgt::Extent3d, size: wgt::Extent3d,
) -> Result<(), QueueWriteError> { ) -> Result<(), QueueWriteError> {
let queue = self.hub.queues.get(queue_id); let queue = self.hub.queues.get(queue_id);
let destination = wgt::ImageCopyTextureTagged { let destination = wgt::CopyExternalImageDestInfo {
texture: self.hub.textures.get(destination.texture), texture: self.hub.textures.get(destination.texture),
mip_level: destination.mip_level, mip_level: destination.mip_level,
origin: destination.origin, origin: destination.origin,

View File

@ -121,9 +121,9 @@ pub enum Action<'a> {
queued: bool, queued: bool,
}, },
WriteTexture { WriteTexture {
to: crate::command::ImageCopyTexture, to: crate::command::TexelCopyTextureInfo,
data: FileName, data: FileName,
layout: wgt::ImageDataLayout, layout: wgt::TexelCopyBufferLayout,
size: wgt::Extent3d, size: wgt::Extent3d,
}, },
Submit(crate::SubmissionIndex, Vec<Command>), Submit(crate::SubmissionIndex, Vec<Command>),
@ -153,18 +153,18 @@ pub enum Command {
size: wgt::BufferAddress, size: wgt::BufferAddress,
}, },
CopyBufferToTexture { CopyBufferToTexture {
src: crate::command::ImageCopyBuffer, src: crate::command::TexelCopyBufferInfo,
dst: crate::command::ImageCopyTexture, dst: crate::command::TexelCopyTextureInfo,
size: wgt::Extent3d, size: wgt::Extent3d,
}, },
CopyTextureToBuffer { CopyTextureToBuffer {
src: crate::command::ImageCopyTexture, src: crate::command::TexelCopyTextureInfo,
dst: crate::command::ImageCopyBuffer, dst: crate::command::TexelCopyBufferInfo,
size: wgt::Extent3d, size: wgt::Extent3d,
}, },
CopyTextureToTexture { CopyTextureToTexture {
src: crate::command::ImageCopyTexture, src: crate::command::TexelCopyTextureInfo,
dst: crate::command::ImageCopyTexture, dst: crate::command::TexelCopyTextureInfo,
size: wgt::Extent3d, size: wgt::Extent3d,
}, },
ClearBuffer { ClearBuffer {

View File

@ -344,7 +344,7 @@ impl<A: hal::Api> Example<A> {
usage: hal::TextureUses::COPY_DST..hal::TextureUses::RESOURCE, usage: hal::TextureUses::COPY_DST..hal::TextureUses::RESOURCE,
}; };
let copy = hal::BufferTextureCopy { let copy = hal::BufferTextureCopy {
buffer_layout: wgt::ImageDataLayout { buffer_layout: wgt::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(4), bytes_per_row: Some(4),
rows_per_image: None, rows_per_image: None,

View File

@ -347,7 +347,7 @@ impl crate::CommandEncoder for Encoder {
#[cfg(webgl)] #[cfg(webgl)]
unsafe fn copy_external_image_to_texture<T>( unsafe fn copy_external_image_to_texture<T>(
&mut self, &mut self,
src: &wgt::ImageCopyExternalImage, src: &wgt::CopyExternalImageSourceInfo,
dst: &Resource, dst: &Resource,
dst_premultiplication: bool, dst_premultiplication: bool,
regions: T, regions: T,

View File

@ -367,7 +367,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
#[cfg(webgl)] #[cfg(webgl)]
unsafe fn copy_external_image_to_texture<T>( unsafe fn copy_external_image_to_texture<T>(
&mut self, &mut self,
src: &wgt::ImageCopyExternalImage, src: &wgt::CopyExternalImageSourceInfo,
dst: &super::Texture, dst: &super::Texture,
dst_premultiplication: bool, dst_premultiplication: bool,
regions: T, regions: T,

View File

@ -909,7 +909,7 @@ enum Command {
}, },
#[cfg(webgl)] #[cfg(webgl)]
CopyExternalImageToTexture { CopyExternalImageToTexture {
src: wgt::ImageCopyExternalImage, src: wgt::CopyExternalImageSourceInfo,
dst: glow::Texture, dst: glow::Texture,
dst_target: BindTarget, dst_target: BindTarget,
dst_format: wgt::TextureFormat, dst_format: wgt::TextureFormat,

View File

@ -1206,7 +1206,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
#[cfg(webgl)] #[cfg(webgl)]
unsafe fn copy_external_image_to_texture<T>( unsafe fn copy_external_image_to_texture<T>(
&mut self, &mut self,
src: &wgt::ImageCopyExternalImage, src: &wgt::CopyExternalImageSourceInfo,
dst: &<Self::A as Api>::Texture, dst: &<Self::A as Api>::Texture,
dst_premultiplication: bool, dst_premultiplication: bool,
regions: T, regions: T,
@ -2296,7 +2296,7 @@ pub struct TextureCopy {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct BufferTextureCopy { pub struct BufferTextureCopy {
pub buffer_layout: wgt::ImageDataLayout, pub buffer_layout: wgt::TexelCopyBufferLayout,
pub texture_base: TextureCopyBase, pub texture_base: TextureCopyBase,
pub size: CopyExtent, pub size: CopyExtent,
} }

View File

@ -77,7 +77,7 @@ pub type DynamicOffset = u32;
/// ///
/// This doesn't apply to [`Queue::write_texture`][Qwt]. /// This doesn't apply to [`Queue::write_texture`][Qwt].
/// ///
/// [`bytes_per_row`]: ImageDataLayout::bytes_per_row /// [`bytes_per_row`]: TexelCopyBufferLayout::bytes_per_row
/// [Qwt]: ../wgpu/struct.Queue.html#method.write_texture /// [Qwt]: ../wgpu/struct.Queue.html#method.write_texture
pub const COPY_BYTES_PER_ROW_ALIGNMENT: u32 = 256; pub const COPY_BYTES_PER_ROW_ALIGNMENT: u32 = 256;
/// An offset into the query resolve buffer has to be aligned to this. /// An offset into the query resolve buffer has to be aligned to this.
@ -1692,11 +1692,11 @@ bitflags::bitflags! {
/// With this feature not present, there are the following restrictions on `Queue::copy_external_image_to_texture`: /// With this feature not present, there are the following restrictions on `Queue::copy_external_image_to_texture`:
/// - The source must not be [`web_sys::OffscreenCanvas`] /// - The source must not be [`web_sys::OffscreenCanvas`]
/// - [`ImageCopyExternalImage::origin`] must be zero. /// - [`CopyExternalImageSourceInfo::origin`] must be zero.
/// - [`ImageCopyTextureTagged::color_space`] must be srgb. /// - [`CopyExternalImageDestInfo::color_space`] must be srgb.
/// - If the source is an [`web_sys::ImageBitmap`]: /// - If the source is an [`web_sys::ImageBitmap`]:
/// - [`ImageCopyExternalImage::flip_y`] must be false. /// - [`CopyExternalImageSourceInfo::flip_y`] must be false.
/// - [`ImageCopyTextureTagged::premultiplied_alpha`] must be false. /// - [`CopyExternalImageDestInfo::premultiplied_alpha`] must be false.
/// ///
/// WebGL doesn't support this. WebGPU does. /// WebGL doesn't support this. WebGPU does.
const UNRESTRICTED_EXTERNAL_TEXTURE_COPIES = 1 << 20; const UNRESTRICTED_EXTERNAL_TEXTURE_COPIES = 1 << 20;
@ -6365,12 +6365,12 @@ impl<T> Default for RenderBundleDescriptor<Option<T>> {
/// | 256x256 | BC3 | 16 | 4 * 4 * 1 | 16 * (256 / 4) = 1024 = Some(1024) | None | /// | 256x256 | BC3 | 16 | 4 * 4 * 1 | 16 * (256 / 4) = 1024 = Some(1024) | None |
/// | 64x64x8 | BC3 | 16 | 4 * 4 * 1 | 16 * (64 / 4) = 256 = Some(256) | 64 / 4 = 16 = Some(16) | /// | 64x64x8 | BC3 | 16 | 4 * 4 * 1 | 16 * (64 / 4) = 256 = Some(256) | 64 / 4 = 16 = Some(16) |
/// ///
/// Corresponds to [WebGPU `GPUImageDataLayout`]( /// Corresponds to [WebGPU `GPUTexelCopyBufferLayout`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagedatalayout). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagedatalayout).
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ImageDataLayout { pub struct TexelCopyBufferLayout {
/// Offset into the buffer that is the start of the texture. Must be a multiple of texture block size. /// Offset into the buffer that is the start of the texture. Must be a multiple of texture block size.
/// For non-compressed textures, this is 1. /// For non-compressed textures, this is 1.
pub offset: BufferAddress, pub offset: BufferAddress,
@ -6809,26 +6809,26 @@ pub struct BindGroupLayoutEntry {
/// View of a buffer which can be used to copy to/from a texture. /// View of a buffer which can be used to copy to/from a texture.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyBuffer`]( /// Corresponds to [WebGPU `GPUTexelCopyBufferInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopybuffer). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopybuffer).
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ImageCopyBuffer<B> { pub struct TexelCopyBufferInfo<B> {
/// The buffer to be copied to/from. /// The buffer to be copied to/from.
pub buffer: B, pub buffer: B,
/// The layout of the texture data in this buffer. /// The layout of the texture data in this buffer.
pub layout: ImageDataLayout, pub layout: TexelCopyBufferLayout,
} }
/// View of a texture which can be used to copy to/from a buffer/texture. /// View of a texture which can be used to copy to/from a buffer/texture.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyTexture`]( /// Corresponds to [WebGPU `GPUTexelCopyTextureInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexture). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexture).
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ImageCopyTexture<T> { pub struct TexelCopyTextureInfo<T> {
/// The texture to be copied to/from. /// The texture to be copied to/from.
pub texture: T, pub texture: T,
/// The target mip level of the texture. /// The target mip level of the texture.
@ -6843,15 +6843,15 @@ pub struct ImageCopyTexture<T> {
pub aspect: TextureAspect, pub aspect: TextureAspect,
} }
impl<T> ImageCopyTexture<T> { impl<T> TexelCopyTextureInfo<T> {
/// Adds color space and premultiplied alpha information to make this /// Adds color space and premultiplied alpha information to make this
/// descriptor tagged. /// descriptor tagged.
pub fn to_tagged( pub fn to_tagged(
self, self,
color_space: PredefinedColorSpace, color_space: PredefinedColorSpace,
premultiplied_alpha: bool, premultiplied_alpha: bool,
) -> ImageCopyTextureTagged<T> { ) -> CopyExternalImageDestInfo<T> {
ImageCopyTextureTagged { CopyExternalImageDestInfo {
texture: self.texture, texture: self.texture,
mip_level: self.mip_level, mip_level: self.mip_level,
origin: self.origin, origin: self.origin,
@ -6864,11 +6864,11 @@ impl<T> ImageCopyTexture<T> {
/// View of an external texture that can be used to copy to a texture. /// View of an external texture that can be used to copy to a texture.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyExternalImage`]( /// Corresponds to [WebGPU `GPUCopyExternalImageSourceInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopyexternalimage). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopyexternalimage).
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ImageCopyExternalImage { pub struct CopyExternalImageSourceInfo {
/// The texture to be copied from. The copy source data is captured at the moment /// The texture to be copied from. The copy source data is captured at the moment
/// the copy is issued. /// the copy is issued.
pub source: ExternalImageSource, pub source: ExternalImageSource,
@ -6887,7 +6887,7 @@ pub struct ImageCopyExternalImage {
/// Source of an external texture copy. /// Source of an external texture copy.
/// ///
/// Corresponds to the [implicit union type on WebGPU `GPUImageCopyExternalImage.source`]( /// Corresponds to the [implicit union type on WebGPU `GPUCopyExternalImageSourceInfo.source`](
/// https://gpuweb.github.io/gpuweb/#dom-gpuimagecopyexternalimage-source). /// https://gpuweb.github.io/gpuweb/#dom-gpuimagecopyexternalimage-source).
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -6990,11 +6990,11 @@ pub enum PredefinedColorSpace {
/// View of a texture which can be used to copy to a texture, including /// View of a texture which can be used to copy to a texture, including
/// color space and alpha premultiplication information. /// color space and alpha premultiplication information.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyTextureTagged`]( /// Corresponds to [WebGPU `GPUCopyExternalImageDestInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexturetagged). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexturetagged).
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ImageCopyTextureTagged<T> { pub struct CopyExternalImageDestInfo<T> {
/// The texture to be copied to/from. /// The texture to be copied to/from.
pub texture: T, pub texture: T,
/// The target mip level of the texture. /// The target mip level of the texture.
@ -7009,10 +7009,10 @@ pub struct ImageCopyTextureTagged<T> {
pub premultiplied_alpha: bool, pub premultiplied_alpha: bool,
} }
impl<T> ImageCopyTextureTagged<T> { impl<T> CopyExternalImageDestInfo<T> {
/// Removes the colorspace information from the type. /// Removes the colorspace information from the type.
pub fn to_untagged(self) -> ImageCopyTexture<T> { pub fn to_untagged(self) -> TexelCopyTextureInfo<T> {
ImageCopyTexture { TexelCopyTextureInfo {
texture: self.texture, texture: self.texture,
mip_level: self.mip_level, mip_level: self.mip_level,
origin: self.origin, origin: self.origin,

View File

@ -37,23 +37,23 @@ impl Drop for CommandEncoder {
pub type CommandEncoderDescriptor<'a> = wgt::CommandEncoderDescriptor<Label<'a>>; pub type CommandEncoderDescriptor<'a> = wgt::CommandEncoderDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(CommandEncoderDescriptor<'_>: Send, Sync); static_assertions::assert_impl_all!(CommandEncoderDescriptor<'_>: Send, Sync);
pub use wgt::ImageCopyBuffer as ImageCopyBufferBase; pub use wgt::TexelCopyBufferInfo as TexelCopyBufferInfoBase;
/// View of a buffer which can be used to copy to/from a texture. /// View of a buffer which can be used to copy to/from a texture.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyBuffer`]( /// Corresponds to [WebGPU `GPUTexelCopyBufferInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopybuffer). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopybuffer).
pub type ImageCopyBuffer<'a> = ImageCopyBufferBase<&'a Buffer>; pub type TexelCopyBufferInfo<'a> = TexelCopyBufferInfoBase<&'a Buffer>;
#[cfg(send_sync)] #[cfg(send_sync)]
static_assertions::assert_impl_all!(ImageCopyBuffer<'_>: Send, Sync); static_assertions::assert_impl_all!(TexelCopyBufferInfo<'_>: Send, Sync);
pub use wgt::ImageCopyTexture as ImageCopyTextureBase; pub use wgt::TexelCopyTextureInfo as TexelCopyTextureInfoBase;
/// View of a texture which can be used to copy to/from a buffer/texture. /// View of a texture which can be used to copy to/from a buffer/texture.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyTexture`]( /// Corresponds to [WebGPU `GPUTexelCopyTextureInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexture). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexture).
pub type ImageCopyTexture<'a> = ImageCopyTextureBase<&'a Texture>; pub type TexelCopyTextureInfo<'a> = TexelCopyTextureInfoBase<&'a Texture>;
#[cfg(send_sync)] #[cfg(send_sync)]
static_assertions::assert_impl_all!(ImageCopyTexture<'_>: Send, Sync); static_assertions::assert_impl_all!(TexelCopyTextureInfo<'_>: Send, Sync);
use crate::api::blas::{ use crate::api::blas::{
BlasBuildEntry, BlasGeometries, BlasTriangleGeometry, DynContextBlasBuildEntry, BlasBuildEntry, BlasGeometries, BlasTriangleGeometry, DynContextBlasBuildEntry,
@ -62,16 +62,16 @@ use crate::api::blas::{
use crate::api::tlas::{ use crate::api::tlas::{
DynContextTlasBuildEntry, DynContextTlasPackage, TlasBuildEntry, TlasPackage, DynContextTlasBuildEntry, DynContextTlasPackage, TlasBuildEntry, TlasPackage,
}; };
pub use wgt::ImageCopyTextureTagged as ImageCopyTextureTaggedBase; pub use wgt::CopyExternalImageDestInfo as CopyExternalImageDestInfoBase;
/// View of a texture which can be used to copy to a texture, including /// View of a texture which can be used to copy to a texture, including
/// color space and alpha premultiplication information. /// color space and alpha premultiplication information.
/// ///
/// Corresponds to [WebGPU `GPUImageCopyTextureTagged`]( /// Corresponds to [WebGPU `GPUCopyExternalImageDestInfo`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexturetagged). /// https://gpuweb.github.io/gpuweb/#dictdef-gpuimagecopytexturetagged).
pub type ImageCopyTextureTagged<'a> = ImageCopyTextureTaggedBase<&'a Texture>; pub type CopyExternalImageDestInfo<'a> = CopyExternalImageDestInfoBase<&'a Texture>;
#[cfg(send_sync)] #[cfg(send_sync)]
static_assertions::assert_impl_all!(ImageCopyTexture<'_>: Send, Sync); static_assertions::assert_impl_all!(TexelCopyTextureInfo<'_>: Send, Sync);
impl CommandEncoder { impl CommandEncoder {
/// Finishes recording and returns a [`CommandBuffer`] that can be submitted for execution. /// Finishes recording and returns a [`CommandBuffer`] that can be submitted for execution.
@ -165,8 +165,8 @@ impl CommandEncoder {
/// Copy data from a buffer to a texture. /// Copy data from a buffer to a texture.
pub fn copy_buffer_to_texture( pub fn copy_buffer_to_texture(
&mut self, &mut self,
source: ImageCopyBuffer<'_>, source: TexelCopyBufferInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
) { ) {
DynContext::command_encoder_copy_buffer_to_texture( DynContext::command_encoder_copy_buffer_to_texture(
@ -181,8 +181,8 @@ impl CommandEncoder {
/// Copy data from a texture to a buffer. /// Copy data from a texture to a buffer.
pub fn copy_texture_to_buffer( pub fn copy_texture_to_buffer(
&mut self, &mut self,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyBuffer<'_>, destination: TexelCopyBufferInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
) { ) {
DynContext::command_encoder_copy_texture_to_buffer( DynContext::command_encoder_copy_texture_to_buffer(
@ -203,8 +203,8 @@ impl CommandEncoder {
/// - Copy would overrun either texture /// - Copy would overrun either texture
pub fn copy_texture_to_texture( pub fn copy_texture_to_texture(
&mut self, &mut self,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
) { ) {
DynContext::command_encoder_copy_texture_to_texture( DynContext::command_encoder_copy_texture_to_texture(

View File

@ -207,9 +207,9 @@ impl Queue {
/// caller may discard it any time after this call completes. /// caller may discard it any time after this call completes.
pub fn write_texture( pub fn write_texture(
&self, &self,
texture: ImageCopyTexture<'_>, texture: TexelCopyTextureInfo<'_>,
data: &[u8], data: &[u8],
data_layout: ImageDataLayout, data_layout: TexelCopyBufferLayout,
size: Extent3d, size: Extent3d,
) { ) {
DynContext::queue_write_texture( DynContext::queue_write_texture(
@ -226,8 +226,8 @@ impl Queue {
#[cfg(any(webgpu, webgl))] #[cfg(any(webgpu, webgl))]
pub fn copy_external_image_to_texture( pub fn copy_external_image_to_texture(
&self, &self,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
dest: crate::ImageCopyTextureTagged<'_>, dest: crate::CopyExternalImageDestInfo<'_>,
size: Extent3d, size: Extent3d,
) { ) {
DynContext::queue_copy_external_image_to_texture( DynContext::queue_copy_external_image_to_texture(

View File

@ -61,9 +61,9 @@ impl Texture {
DynContext::texture_destroy(&*self.context, self.data.as_ref()); DynContext::texture_destroy(&*self.context, self.data.as_ref());
} }
/// Make an `ImageCopyTexture` representing the whole texture. /// Make an `TexelCopyTextureInfo` representing the whole texture.
pub fn as_image_copy(&self) -> ImageCopyTexture<'_> { pub fn as_image_copy(&self) -> TexelCopyTextureInfo<'_> {
ImageCopyTexture { TexelCopyTextureInfo {
texture: self, texture: self,
mip_level: 0, mip_level: 0,
origin: Origin3d::ZERO, origin: Origin3d::ZERO,

View File

@ -629,7 +629,7 @@ fn map_texture_view_dimension(
} }
} }
fn map_buffer_copy_view(view: crate::ImageCopyBuffer<'_>) -> webgpu_sys::GpuImageCopyBuffer { fn map_buffer_copy_view(view: crate::TexelCopyBufferInfo<'_>) -> webgpu_sys::GpuImageCopyBuffer {
let buffer: &<ContextWebGpu as crate::Context>::BufferData = let buffer: &<ContextWebGpu as crate::Context>::BufferData =
downcast_ref(view.buffer.data.as_ref()); downcast_ref(view.buffer.data.as_ref());
let mut mapped = webgpu_sys::GpuImageCopyBuffer::new(&buffer.0.buffer); let mut mapped = webgpu_sys::GpuImageCopyBuffer::new(&buffer.0.buffer);
@ -643,7 +643,7 @@ fn map_buffer_copy_view(view: crate::ImageCopyBuffer<'_>) -> webgpu_sys::GpuImag
mapped mapped
} }
fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> webgpu_sys::GpuImageCopyTexture { fn map_texture_copy_view(view: crate::TexelCopyTextureInfo<'_>) -> webgpu_sys::GpuImageCopyTexture {
let texture: &<ContextWebGpu as crate::Context>::TextureData = let texture: &<ContextWebGpu as crate::Context>::TextureData =
downcast_ref(view.texture.data.as_ref()); downcast_ref(view.texture.data.as_ref());
let mut mapped = webgpu_sys::GpuImageCopyTexture::new(&texture.0); let mut mapped = webgpu_sys::GpuImageCopyTexture::new(&texture.0);
@ -653,7 +653,7 @@ fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> webgpu_sys::GpuIm
} }
fn map_tagged_texture_copy_view( fn map_tagged_texture_copy_view(
view: crate::ImageCopyTextureTagged<'_>, view: crate::CopyExternalImageDestInfo<'_>,
) -> webgpu_sys::GpuImageCopyTextureTagged { ) -> webgpu_sys::GpuImageCopyTextureTagged {
let texture: &<ContextWebGpu as crate::Context>::TextureData = let texture: &<ContextWebGpu as crate::Context>::TextureData =
downcast_ref(view.texture.data.as_ref()); downcast_ref(view.texture.data.as_ref());
@ -667,7 +667,7 @@ fn map_tagged_texture_copy_view(
} }
fn map_external_texture_copy_view( fn map_external_texture_copy_view(
view: &crate::ImageCopyExternalImage, view: &crate::CopyExternalImageSourceInfo,
) -> webgpu_sys::GpuImageCopyExternalImage { ) -> webgpu_sys::GpuImageCopyExternalImage {
let mut mapped = webgpu_sys::GpuImageCopyExternalImage::new(&view.source); let mut mapped = webgpu_sys::GpuImageCopyExternalImage::new(&view.source);
mapped.origin(&map_origin_2d(view.origin)); mapped.origin(&map_origin_2d(view.origin));
@ -2338,8 +2338,8 @@ impl crate::context::Context for ContextWebGpu {
fn command_encoder_copy_buffer_to_texture( fn command_encoder_copy_buffer_to_texture(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: crate::ImageCopyBuffer<'_>, source: crate::TexelCopyBufferInfo<'_>,
destination: crate::ImageCopyTexture<'_>, destination: crate::TexelCopyTextureInfo<'_>,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
) { ) {
encoder_data encoder_data
@ -2354,8 +2354,8 @@ impl crate::context::Context for ContextWebGpu {
fn command_encoder_copy_texture_to_buffer( fn command_encoder_copy_texture_to_buffer(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: crate::ImageCopyTexture<'_>, source: crate::TexelCopyTextureInfo<'_>,
destination: crate::ImageCopyBuffer<'_>, destination: crate::TexelCopyBufferInfo<'_>,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
) { ) {
encoder_data encoder_data
@ -2370,8 +2370,8 @@ impl crate::context::Context for ContextWebGpu {
fn command_encoder_copy_texture_to_texture( fn command_encoder_copy_texture_to_texture(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: crate::ImageCopyTexture<'_>, source: crate::TexelCopyTextureInfo<'_>,
destination: crate::ImageCopyTexture<'_>, destination: crate::TexelCopyTextureInfo<'_>,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
) { ) {
encoder_data encoder_data
@ -2709,9 +2709,9 @@ impl crate::context::Context for ContextWebGpu {
fn queue_write_texture( fn queue_write_texture(
&self, &self,
queue_data: &Self::QueueData, queue_data: &Self::QueueData,
texture: crate::ImageCopyTexture<'_>, texture: crate::TexelCopyTextureInfo<'_>,
data: &[u8], data: &[u8],
data_layout: wgt::ImageDataLayout, data_layout: wgt::TexelCopyBufferLayout,
size: wgt::Extent3d, size: wgt::Extent3d,
) { ) {
let mut mapped_data_layout = webgpu_sys::GpuImageDataLayout::new(); let mut mapped_data_layout = webgpu_sys::GpuImageDataLayout::new();
@ -2744,8 +2744,8 @@ impl crate::context::Context for ContextWebGpu {
fn queue_copy_external_image_to_texture( fn queue_copy_external_image_to_texture(
&self, &self,
queue_data: &Self::QueueData, queue_data: &Self::QueueData,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
dest: crate::ImageCopyTextureTagged<'_>, dest: crate::CopyExternalImageDestInfo<'_>,
size: wgt::Extent3d, size: wgt::Extent3d,
) { ) {
queue_data queue_data

View File

@ -363,15 +363,17 @@ impl ContextWgpuCore {
} }
} }
fn map_buffer_copy_view(view: crate::ImageCopyBuffer<'_>) -> wgc::command::ImageCopyBuffer { fn map_buffer_copy_view(view: crate::TexelCopyBufferInfo<'_>) -> wgc::command::TexelCopyBufferInfo {
wgc::command::ImageCopyBuffer { wgc::command::TexelCopyBufferInfo {
buffer: downcast_buffer(view.buffer).id, buffer: downcast_buffer(view.buffer).id,
layout: view.layout, layout: view.layout,
} }
} }
fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> wgc::command::ImageCopyTexture { fn map_texture_copy_view(
wgc::command::ImageCopyTexture { view: crate::TexelCopyTextureInfo<'_>,
) -> wgc::command::TexelCopyTextureInfo {
wgc::command::TexelCopyTextureInfo {
texture: downcast_texture(view.texture).id, texture: downcast_texture(view.texture).id,
mip_level: view.mip_level, mip_level: view.mip_level,
origin: view.origin, origin: view.origin,
@ -384,9 +386,9 @@ fn map_texture_copy_view(view: crate::ImageCopyTexture<'_>) -> wgc::command::Ima
allow(unused) allow(unused)
)] )]
fn map_texture_tagged_copy_view( fn map_texture_tagged_copy_view(
view: crate::ImageCopyTextureTagged<'_>, view: crate::CopyExternalImageDestInfo<'_>,
) -> wgc::command::ImageCopyTextureTagged { ) -> wgc::command::CopyExternalImageDestInfo {
wgc::command::ImageCopyTextureTagged { wgc::command::CopyExternalImageDestInfo {
texture: downcast_texture(view.texture).id, texture: downcast_texture(view.texture).id,
mip_level: view.mip_level, mip_level: view.mip_level,
origin: view.origin, origin: view.origin,
@ -1630,8 +1632,8 @@ impl crate::Context for ContextWgpuCore {
fn command_encoder_copy_buffer_to_texture( fn command_encoder_copy_buffer_to_texture(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: crate::ImageCopyBuffer<'_>, source: crate::TexelCopyBufferInfo<'_>,
destination: crate::ImageCopyTexture<'_>, destination: crate::TexelCopyTextureInfo<'_>,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
) { ) {
if let Err(cause) = self.0.command_encoder_copy_buffer_to_texture( if let Err(cause) = self.0.command_encoder_copy_buffer_to_texture(
@ -1651,8 +1653,8 @@ impl crate::Context for ContextWgpuCore {
fn command_encoder_copy_texture_to_buffer( fn command_encoder_copy_texture_to_buffer(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: crate::ImageCopyTexture<'_>, source: crate::TexelCopyTextureInfo<'_>,
destination: crate::ImageCopyBuffer<'_>, destination: crate::TexelCopyBufferInfo<'_>,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
) { ) {
if let Err(cause) = self.0.command_encoder_copy_texture_to_buffer( if let Err(cause) = self.0.command_encoder_copy_texture_to_buffer(
@ -1672,8 +1674,8 @@ impl crate::Context for ContextWgpuCore {
fn command_encoder_copy_texture_to_texture( fn command_encoder_copy_texture_to_texture(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: crate::ImageCopyTexture<'_>, source: crate::TexelCopyTextureInfo<'_>,
destination: crate::ImageCopyTexture<'_>, destination: crate::TexelCopyTextureInfo<'_>,
copy_size: wgt::Extent3d, copy_size: wgt::Extent3d,
) { ) {
if let Err(cause) = self.0.command_encoder_copy_texture_to_texture( if let Err(cause) = self.0.command_encoder_copy_texture_to_texture(
@ -2029,9 +2031,9 @@ impl crate::Context for ContextWgpuCore {
fn queue_write_texture( fn queue_write_texture(
&self, &self,
queue_data: &Self::QueueData, queue_data: &Self::QueueData,
texture: crate::ImageCopyTexture<'_>, texture: crate::TexelCopyTextureInfo<'_>,
data: &[u8], data: &[u8],
data_layout: wgt::ImageDataLayout, data_layout: wgt::TexelCopyBufferLayout,
size: wgt::Extent3d, size: wgt::Extent3d,
) { ) {
match self.0.queue_write_texture( match self.0.queue_write_texture(
@ -2052,8 +2054,8 @@ impl crate::Context for ContextWgpuCore {
fn queue_copy_external_image_to_texture( fn queue_copy_external_image_to_texture(
&self, &self,
queue_data: &Self::QueueData, queue_data: &Self::QueueData,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
dest: crate::ImageCopyTextureTagged<'_>, dest: crate::CopyExternalImageDestInfo<'_>,
size: wgt::Extent3d, size: wgt::Extent3d,
) { ) {
match self.0.queue_copy_external_image_to_texture( match self.0.queue_copy_external_image_to_texture(

View File

@ -2,21 +2,20 @@ use std::{any::Any, fmt::Debug, future::Future, ops::Range, pin::Pin, sync::Arc}
use wgt::{ use wgt::{
strict_assert, AdapterInfo, BufferAddress, BufferSize, Color, DeviceLostReason, strict_assert, AdapterInfo, BufferAddress, BufferSize, Color, DeviceLostReason,
DownlevelCapabilities, DynamicOffset, Extent3d, Features, ImageDataLayout, DownlevelCapabilities, DynamicOffset, Extent3d, Features, ImageSubresourceRange, IndexFormat,
ImageSubresourceRange, IndexFormat, Limits, ShaderStages, SurfaceStatus, TextureFormat, Limits, ShaderStages, SurfaceStatus, TexelCopyBufferLayout, TextureFormat,
TextureFormatFeatures, WasmNotSend, WasmNotSendSync, TextureFormatFeatures, WasmNotSend, WasmNotSendSync,
}; };
use crate::{ use crate::{
AnyWasmNotSendSync, BindGroupDescriptor, BindGroupLayoutDescriptor, BufferAsyncError, AnyWasmNotSendSync, BindGroupDescriptor, BindGroupLayoutDescriptor, BufferAsyncError,
BufferDescriptor, CommandEncoderDescriptor, CompilationInfo, ComputePassDescriptor, BufferDescriptor, CommandEncoderDescriptor, CompilationInfo, ComputePassDescriptor,
ComputePipelineDescriptor, DeviceDescriptor, Error, ErrorFilter, ImageCopyBuffer, ComputePipelineDescriptor, DeviceDescriptor, Error, ErrorFilter, Maintain, MaintainResult,
ImageCopyTexture, Maintain, MaintainResult, MapMode, PipelineCacheDescriptor, MapMode, PipelineCacheDescriptor, PipelineLayoutDescriptor, QuerySetDescriptor,
PipelineLayoutDescriptor, QuerySetDescriptor, RenderBundleDescriptor, RenderBundleDescriptor, RenderBundleEncoderDescriptor, RenderPassDescriptor,
RenderBundleEncoderDescriptor, RenderPassDescriptor, RenderPipelineDescriptor, RenderPipelineDescriptor, RequestAdapterOptions, RequestDeviceError, SamplerDescriptor,
RequestAdapterOptions, RequestDeviceError, SamplerDescriptor, ShaderModuleDescriptor, ShaderModuleDescriptor, ShaderModuleDescriptorSpirV, SurfaceTargetUnsafe, TexelCopyBufferInfo,
ShaderModuleDescriptorSpirV, SurfaceTargetUnsafe, TextureDescriptor, TextureViewDescriptor, TexelCopyTextureInfo, TextureDescriptor, TextureViewDescriptor, UncapturedErrorHandler,
UncapturedErrorHandler,
}; };
/// Meta trait for an data associated with an id tracked by a context. /// Meta trait for an data associated with an id tracked by a context.
/// ///
@ -282,22 +281,22 @@ pub trait Context: Debug + WasmNotSendSync + Sized {
fn command_encoder_copy_buffer_to_texture( fn command_encoder_copy_buffer_to_texture(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: ImageCopyBuffer<'_>, source: TexelCopyBufferInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
); );
fn command_encoder_copy_texture_to_buffer( fn command_encoder_copy_texture_to_buffer(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyBuffer<'_>, destination: TexelCopyBufferInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
); );
fn command_encoder_copy_texture_to_texture( fn command_encoder_copy_texture_to_texture(
&self, &self,
encoder_data: &Self::CommandEncoderData, encoder_data: &Self::CommandEncoderData,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
); );
@ -393,17 +392,17 @@ pub trait Context: Debug + WasmNotSendSync + Sized {
fn queue_write_texture( fn queue_write_texture(
&self, &self,
queue_data: &Self::QueueData, queue_data: &Self::QueueData,
texture: ImageCopyTexture<'_>, texture: TexelCopyTextureInfo<'_>,
data: &[u8], data: &[u8],
data_layout: ImageDataLayout, data_layout: TexelCopyBufferLayout,
size: Extent3d, size: Extent3d,
); );
#[cfg(any(webgl, webgpu))] #[cfg(any(webgl, webgpu))]
fn queue_copy_external_image_to_texture( fn queue_copy_external_image_to_texture(
&self, &self,
queue_data: &Self::QueueData, queue_data: &Self::QueueData,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
dest: crate::ImageCopyTextureTagged<'_>, dest: crate::CopyExternalImageDestInfo<'_>,
size: wgt::Extent3d, size: wgt::Extent3d,
); );
fn queue_submit<I: Iterator<Item = Self::CommandBufferData>>( fn queue_submit<I: Iterator<Item = Self::CommandBufferData>>(
@ -1000,22 +999,22 @@ pub(crate) trait DynContext: Debug + WasmNotSendSync {
fn command_encoder_copy_buffer_to_texture( fn command_encoder_copy_buffer_to_texture(
&self, &self,
encoder_data: &crate::Data, encoder_data: &crate::Data,
source: ImageCopyBuffer<'_>, source: TexelCopyBufferInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
); );
fn command_encoder_copy_texture_to_buffer( fn command_encoder_copy_texture_to_buffer(
&self, &self,
encoder_data: &crate::Data, encoder_data: &crate::Data,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyBuffer<'_>, destination: TexelCopyBufferInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
); );
fn command_encoder_copy_texture_to_texture( fn command_encoder_copy_texture_to_texture(
&self, &self,
encoder_data: &crate::Data, encoder_data: &crate::Data,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
); );
@ -1100,17 +1099,17 @@ pub(crate) trait DynContext: Debug + WasmNotSendSync {
fn queue_write_texture( fn queue_write_texture(
&self, &self,
queue_data: &crate::Data, queue_data: &crate::Data,
texture: ImageCopyTexture<'_>, texture: TexelCopyTextureInfo<'_>,
data: &[u8], data: &[u8],
data_layout: ImageDataLayout, data_layout: TexelCopyBufferLayout,
size: Extent3d, size: Extent3d,
); );
#[cfg(any(webgpu, webgl))] #[cfg(any(webgpu, webgl))]
fn queue_copy_external_image_to_texture( fn queue_copy_external_image_to_texture(
&self, &self,
queue_data: &crate::Data, queue_data: &crate::Data,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
dest: crate::ImageCopyTextureTagged<'_>, dest: crate::CopyExternalImageDestInfo<'_>,
size: wgt::Extent3d, size: wgt::Extent3d,
); );
fn queue_submit( fn queue_submit(
@ -1925,8 +1924,8 @@ where
fn command_encoder_copy_buffer_to_texture( fn command_encoder_copy_buffer_to_texture(
&self, &self,
encoder_data: &crate::Data, encoder_data: &crate::Data,
source: ImageCopyBuffer<'_>, source: TexelCopyBufferInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
) { ) {
let encoder_data = downcast_ref(encoder_data); let encoder_data = downcast_ref(encoder_data);
@ -1942,8 +1941,8 @@ where
fn command_encoder_copy_texture_to_buffer( fn command_encoder_copy_texture_to_buffer(
&self, &self,
encoder_data: &crate::Data, encoder_data: &crate::Data,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyBuffer<'_>, destination: TexelCopyBufferInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
) { ) {
let encoder_data = downcast_ref(encoder_data); let encoder_data = downcast_ref(encoder_data);
@ -1959,8 +1958,8 @@ where
fn command_encoder_copy_texture_to_texture( fn command_encoder_copy_texture_to_texture(
&self, &self,
encoder_data: &crate::Data, encoder_data: &crate::Data,
source: ImageCopyTexture<'_>, source: TexelCopyTextureInfo<'_>,
destination: ImageCopyTexture<'_>, destination: TexelCopyTextureInfo<'_>,
copy_size: Extent3d, copy_size: Extent3d,
) { ) {
let encoder_data = downcast_ref(encoder_data); let encoder_data = downcast_ref(encoder_data);
@ -2128,9 +2127,9 @@ where
fn queue_write_texture( fn queue_write_texture(
&self, &self,
queue_data: &crate::Data, queue_data: &crate::Data,
texture: ImageCopyTexture<'_>, texture: TexelCopyTextureInfo<'_>,
data: &[u8], data: &[u8],
data_layout: ImageDataLayout, data_layout: TexelCopyBufferLayout,
size: Extent3d, size: Extent3d,
) { ) {
let queue_data = downcast_ref(queue_data); let queue_data = downcast_ref(queue_data);
@ -2141,8 +2140,8 @@ where
fn queue_copy_external_image_to_texture( fn queue_copy_external_image_to_texture(
&self, &self,
queue_data: &crate::Data, queue_data: &crate::Data,
source: &wgt::ImageCopyExternalImage, source: &wgt::CopyExternalImageSourceInfo,
dest: crate::ImageCopyTextureTagged<'_>, dest: crate::CopyExternalImageDestInfo<'_>,
size: wgt::Extent3d, size: wgt::Extent3d,
) { ) {
let queue_data = downcast_ref(queue_data); let queue_data = downcast_ref(queue_data);

View File

@ -61,23 +61,23 @@ pub use wgt::{
CommandBufferDescriptor, CompareFunction, CompositeAlphaMode, CoreCounters, DepthBiasState, CommandBufferDescriptor, CompareFunction, CompositeAlphaMode, CoreCounters, DepthBiasState,
DepthStencilState, DeviceLostReason, DeviceType, DownlevelCapabilities, DownlevelFlags, DepthStencilState, DeviceLostReason, DeviceType, DownlevelCapabilities, DownlevelFlags,
Dx12Compiler, DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace, Dx12Compiler, DynamicOffset, Extent3d, Face, Features, FilterMode, FrontFace,
Gles3MinorVersion, HalCounters, ImageDataLayout, ImageSubresourceRange, IndexFormat, Gles3MinorVersion, HalCounters, ImageSubresourceRange, IndexFormat, InstanceDescriptor,
InstanceDescriptor, InstanceFlags, InternalCounters, Limits, MaintainResult, MemoryHints, InstanceFlags, InternalCounters, Limits, MaintainResult, MemoryHints, MultisampleState,
MultisampleState, Origin2d, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference, Origin2d, Origin3d, PipelineStatisticsTypes, PolygonMode, PowerPreference,
PredefinedColorSpace, PresentMode, PresentationTimestamp, PrimitiveState, PrimitiveTopology, PredefinedColorSpace, PresentMode, PresentationTimestamp, PrimitiveState, PrimitiveTopology,
PushConstantRange, QueryType, RenderBundleDepthStencil, SamplerBindingType, SamplerBorderColor, PushConstantRange, QueryType, RenderBundleDepthStencil, SamplerBindingType, SamplerBorderColor,
ShaderLocation, ShaderModel, ShaderStages, StencilFaceState, StencilOperation, StencilState, ShaderLocation, ShaderModel, ShaderStages, StencilFaceState, StencilOperation, StencilState,
StorageTextureAccess, SurfaceCapabilities, SurfaceStatus, TextureAspect, TextureDimension, StorageTextureAccess, SurfaceCapabilities, SurfaceStatus, TexelCopyBufferLayout, TextureAspect,
TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType, TextureDimension, TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures,
TextureUsages, TextureViewDimension, VertexAttribute, VertexFormat, VertexStepMode, TextureSampleType, TextureUsages, TextureViewDimension, VertexAttribute, VertexFormat,
WasmNotSend, WasmNotSendSync, WasmNotSync, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, VertexStepMode, WasmNotSend, WasmNotSendSync, WasmNotSync, COPY_BUFFER_ALIGNMENT,
MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT,
QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT, QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_STRIDE_ALIGNMENT,
}; };
// wasm-only types, we try to keep as many types non-platform // wasm-only types, we try to keep as many types non-platform
// specific, but these need to depend on web-sys. // specific, but these need to depend on web-sys.
#[cfg(any(webgpu, webgl))] #[cfg(any(webgpu, webgl))]
pub use wgt::{ExternalImageSource, ImageCopyExternalImage}; pub use wgt::{CopyExternalImageSourceInfo, ExternalImageSource};
// //
// //

View File

@ -161,7 +161,7 @@ impl DeviceExt for crate::Device {
let end_offset = binary_offset + data_size as usize; let end_offset = binary_offset + data_size as usize;
queue.write_texture( queue.write_texture(
crate::ImageCopyTexture { crate::TexelCopyTextureInfo {
texture: &texture, texture: &texture,
mip_level: mip, mip_level: mip,
origin: crate::Origin3d { origin: crate::Origin3d {
@ -172,7 +172,7 @@ impl DeviceExt for crate::Device {
aspect: wgt::TextureAspect::All, aspect: wgt::TextureAspect::All,
}, },
&data[binary_offset..end_offset], &data[binary_offset..end_offset],
crate::ImageDataLayout { crate::TexelCopyBufferLayout {
offset: 0, offset: 0,
bytes_per_row: Some(bytes_per_row), bytes_per_row: Some(bytes_per_row),
rows_per_image: Some(height_blocks), rows_per_image: Some(height_blocks),