Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 2024-08 spec. rename of image copy APIs #6618

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions deno_webgpu/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1900,22 +1900,22 @@ class GPUQueue {
}

/**
* @param {GPUImageCopyTexture} destination
* @param {GPUTexelCopyTextureInfo} destination
* @param {BufferSource} data
* @param {GPUImageDataLayout} dataLayout
* @param {GPUTexelCopyBufferLayout} dataLayout
* @param {GPUExtent3D} size
*/
writeTexture(destination, data, dataLayout, size) {
webidl.assertBranded(this, GPUQueuePrototype);
const prefix = "Failed to execute 'writeTexture' on 'GPUQueue'";
webidl.requiredArguments(arguments.length, 4, prefix);
destination = webidl.converters.GPUImageCopyTexture(
destination = webidl.converters.GPUTexelCopyTextureInfo(
destination,
prefix,
"Argument 1",
);
data = webidl.converters.BufferSource(data, prefix, "Argument 2");
dataLayout = webidl.converters.GPUImageDataLayout(
dataLayout = webidl.converters.GPUTexelCopyBufferLayout(
dataLayout,
prefix,
"Argument 3",
Expand Down Expand Up @@ -3279,17 +3279,17 @@ class GPUCommandEncoder {
}

/**
* @param {GPUImageCopyBuffer} source
* @param {GPUImageCopyTexture} destination
* @param {GPUTexelCopyBufferInfo} source
* @param {GPUTexelCopyTextureInfo} destination
* @param {GPUExtent3D} copySize
*/
copyBufferToTexture(source, destination, copySize) {
webidl.assertBranded(this, GPUCommandEncoderPrototype);
const prefix =
"Failed to execute 'copyBufferToTexture' on 'GPUCommandEncoder'";
webidl.requiredArguments(arguments.length, 3, prefix);
source = webidl.converters.GPUImageCopyBuffer(source, prefix, "Argument 1");
destination = webidl.converters.GPUImageCopyTexture(
source = webidl.converters.GPUTexelCopyBufferInfo(source, prefix, "Argument 1");
destination = webidl.converters.GPUTexelCopyTextureInfo(
destination,
prefix,
"Argument 2",
Expand Down Expand Up @@ -3329,21 +3329,21 @@ class GPUCommandEncoder {
}

/**
* @param {GPUImageCopyTexture} source
* @param {GPUImageCopyBuffer} destination
* @param {GPUTexelCopyTextureInfo} source
* @param {GPUTexelCopyBufferInfo} destination
* @param {GPUExtent3D} copySize
*/
copyTextureToBuffer(source, destination, copySize) {
webidl.assertBranded(this, GPUCommandEncoderPrototype);
const prefix =
"Failed to execute 'copyTextureToBuffer' on 'GPUCommandEncoder'";
webidl.requiredArguments(arguments.length, 3, prefix);
source = webidl.converters.GPUImageCopyTexture(
source = webidl.converters.GPUTexelCopyTextureInfo(
source,
prefix,
"Argument 1",
);
destination = webidl.converters.GPUImageCopyBuffer(
destination = webidl.converters.GPUTexelCopyBufferInfo(
destination,
prefix,
"Argument 2",
Expand Down Expand Up @@ -3380,21 +3380,21 @@ class GPUCommandEncoder {
}

/**
* @param {GPUImageCopyTexture} source
* @param {GPUImageCopyTexture} destination
* @param {GPUTexelCopyTextureInfo} source
* @param {GPUTexelCopyTextureInfo} destination
* @param {GPUExtent3D} copySize
*/
copyTextureToTexture(source, destination, copySize) {
webidl.assertBranded(this, GPUCommandEncoderPrototype);
const prefix =
"Failed to execute 'copyTextureToTexture' on 'GPUCommandEncoder'";
webidl.requiredArguments(arguments.length, 3, prefix);
source = webidl.converters.GPUImageCopyTexture(
source = webidl.converters.GPUTexelCopyTextureInfo(
source,
prefix,
"Argument 1",
);
destination = webidl.converters.GPUImageCopyTexture(
destination = webidl.converters.GPUTexelCopyTextureInfo(
destination,
prefix,
"Argument 2",
Expand Down Expand Up @@ -6549,8 +6549,8 @@ webidl.converters["GPUCommandEncoderDescriptor"] = webidl
dictMembersGPUCommandEncoderDescriptor,
);

// DICTIONARY: GPUImageDataLayout
const dictMembersGPUImageDataLayout = [
// DICTIONARY: GPUTexelCopyBufferLayout
const dictMembersGPUTexelCopyBufferLayout = [
{
key: "offset",
converter: webidl.converters["GPUSize64"],
Expand All @@ -6559,23 +6559,23 @@ const dictMembersGPUImageDataLayout = [
{ key: "bytesPerRow", converter: webidl.converters["GPUSize32"] },
{ key: "rowsPerImage", converter: webidl.converters["GPUSize32"] },
];
webidl.converters["GPUImageDataLayout"] = webidl.createDictionaryConverter(
"GPUImageDataLayout",
dictMembersGPUImageDataLayout,
webidl.converters["GPUTexelCopyBufferLayout"] = webidl.createDictionaryConverter(
"GPUTexelCopyBufferLayout",
dictMembersGPUTexelCopyBufferLayout,
);

// DICTIONARY: GPUImageCopyBuffer
const dictMembersGPUImageCopyBuffer = [
// DICTIONARY: GPUTexelCopyBufferInfo
const dictMembersGPUTexelCopyBufferInfo = [
{
key: "buffer",
converter: webidl.converters["GPUBuffer"],
required: true,
},
];
webidl.converters["GPUImageCopyBuffer"] = webidl.createDictionaryConverter(
"GPUImageCopyBuffer",
dictMembersGPUImageDataLayout,
dictMembersGPUImageCopyBuffer,
webidl.converters["GPUTexelCopyBufferInfo"] = webidl.createDictionaryConverter(
"GPUTexelCopyBufferInfo",
dictMembersGPUTexelCopyBufferLayout,
dictMembersGPUTexelCopyBufferInfo,
);

// DICTIONARY: GPUOrigin3DDict
Expand Down Expand Up @@ -6630,8 +6630,8 @@ webidl.converters["GPUOrigin3D"] = (V, opts) => {
);
};

// DICTIONARY: GPUImageCopyTexture
const dictMembersGPUImageCopyTexture = [
// DICTIONARY: GPUTexelCopyTextureInfo
const dictMembersGPUTexelCopyTextureInfo = [
{
key: "texture",
converter: webidl.converters["GPUTexture"],
Expand All @@ -6655,9 +6655,9 @@ const dictMembersGPUImageCopyTexture = [
defaultValue: "all",
},
];
webidl.converters["GPUImageCopyTexture"] = webidl.createDictionaryConverter(
"GPUImageCopyTexture",
dictMembersGPUImageCopyTexture,
webidl.converters["GPUTexelCopyTextureInfo"] = webidl.createDictionaryConverter(
"GPUTexelCopyTextureInfo",
dictMembersGPUTexelCopyTextureInfo,
);

// DICTIONARY: GPUOrigin2DDict
Expand Down
32 changes: 16 additions & 16 deletions deno_webgpu/command_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_buffer(

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GpuImageCopyBuffer {
pub struct GpuTexelCopyBufferInfo {
buffer: ResourceId,
offset: u64,
bytes_per_row: Option<u32>,
Expand All @@ -320,7 +320,7 @@ pub struct GpuImageCopyBuffer {

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GpuImageCopyTexture {
pub struct GpuTexelCopyTextureInfo {
pub texture: ResourceId,
pub mip_level: u32,
pub origin: wgpu_types::Origin3d,
Expand All @@ -332,8 +332,8 @@ pub struct GpuImageCopyTexture {
pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
state: &mut OpState,
#[smi] command_encoder_rid: ResourceId,
#[serde] source: GpuImageCopyBuffer,
#[serde] destination: GpuImageCopyTexture,
#[serde] source: GpuTexelCopyBufferInfo,
#[serde] destination: GpuTexelCopyTextureInfo,
#[serde] copy_size: wgpu_types::Extent3d,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
Expand All @@ -348,15 +348,15 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
.resource_table
.get::<super::texture::WebGpuTexture>(destination.texture)?;

let source = wgpu_core::command::ImageCopyBuffer {
let source = wgpu_core::command::TexelCopyBufferInfo {
buffer: source_buffer_resource.1,
layout: wgpu_types::ImageDataLayout {
layout: wgpu_types::TexelCopyBufferLayout {
offset: source.offset,
bytes_per_row: source.bytes_per_row,
rows_per_image: source.rows_per_image,
},
};
let destination = wgpu_core::command::ImageCopyTexture {
let destination = wgpu_core::command::TexelCopyTextureInfo {
texture: destination_texture_resource.id,
mip_level: destination.mip_level,
origin: destination.origin,
Expand All @@ -375,8 +375,8 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
state: &mut OpState,
#[smi] command_encoder_rid: ResourceId,
#[serde] source: GpuImageCopyTexture,
#[serde] destination: GpuImageCopyBuffer,
#[serde] source: GpuTexelCopyTextureInfo,
#[serde] destination: GpuTexelCopyBufferInfo,
#[serde] copy_size: wgpu_types::Extent3d,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
Expand All @@ -391,15 +391,15 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
.resource_table
.get::<super::buffer::WebGpuBuffer>(destination.buffer)?;

let source = wgpu_core::command::ImageCopyTexture {
let source = wgpu_core::command::TexelCopyTextureInfo {
texture: source_texture_resource.id,
mip_level: source.mip_level,
origin: source.origin,
aspect: source.aspect,
};
let destination = wgpu_core::command::ImageCopyBuffer {
let destination = wgpu_core::command::TexelCopyBufferInfo {
buffer: destination_buffer_resource.1,
layout: wgpu_types::ImageDataLayout {
layout: wgpu_types::TexelCopyBufferLayout {
offset: destination.offset,
bytes_per_row: destination.bytes_per_row,
rows_per_image: destination.rows_per_image,
Expand All @@ -418,8 +418,8 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
pub fn op_webgpu_command_encoder_copy_texture_to_texture(
state: &mut OpState,
#[smi] command_encoder_rid: ResourceId,
#[serde] source: GpuImageCopyTexture,
#[serde] destination: GpuImageCopyTexture,
#[serde] source: GpuTexelCopyTextureInfo,
#[serde] destination: GpuTexelCopyTextureInfo,
#[serde] copy_size: wgpu_types::Extent3d,
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
Expand All @@ -434,13 +434,13 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
.resource_table
.get::<super::texture::WebGpuTexture>(destination.texture)?;

let source = wgpu_core::command::ImageCopyTexture {
let source = wgpu_core::command::TexelCopyTextureInfo {
texture: source_texture_resource.id,
mip_level: source.mip_level,
origin: source.origin,
aspect: source.aspect,
};
let destination = wgpu_core::command::ImageCopyTexture {
let destination = wgpu_core::command::TexelCopyTextureInfo {
texture: destination_texture_resource.id,
mip_level: destination.mip_level,
origin: destination.origin,
Expand Down
14 changes: 7 additions & 7 deletions deno_webgpu/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ pub fn op_webgpu_queue_submit(

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GpuImageDataLayout {
pub struct GpuTexelCopyBufferLayout {
offset: u64,
bytes_per_row: Option<u32>,
rows_per_image: Option<u32>,
}

impl From<GpuImageDataLayout> for wgpu_types::ImageDataLayout {
fn from(layout: GpuImageDataLayout) -> Self {
wgpu_types::ImageDataLayout {
impl From<GpuTexelCopyBufferLayout> for wgpu_types::TexelCopyBufferLayout {
fn from(layout: GpuTexelCopyBufferLayout) -> Self {
wgpu_types::TexelCopyBufferLayout {
offset: layout.offset,
bytes_per_row: layout.bytes_per_row,
rows_per_image: layout.rows_per_image,
Expand Down Expand Up @@ -107,8 +107,8 @@ pub fn op_webgpu_write_buffer(
pub fn op_webgpu_write_texture(
state: &mut OpState,
#[smi] queue_rid: ResourceId,
#[serde] destination: super::command_encoder::GpuImageCopyTexture,
#[serde] data_layout: GpuImageDataLayout,
#[serde] destination: super::command_encoder::GpuTexelCopyTextureInfo,
#[serde] data_layout: GpuTexelCopyBufferLayout,
#[serde] size: wgpu_types::Extent3d,
#[buffer] buf: &[u8],
) -> Result<WebGpuResult, AnyError> {
Expand All @@ -119,7 +119,7 @@ pub fn op_webgpu_write_texture(
let queue_resource = state.resource_table.get::<WebGpuQueue>(queue_rid)?;
let queue = queue_resource.1;

let destination = wgpu_core::command::ImageCopyTexture {
let destination = wgpu_core::command::TexelCopyTextureInfo {
texture: texture_resource.id,
mip_level: destination.mip_level,
origin: destination.origin,
Expand Down
24 changes: 12 additions & 12 deletions deno_webgpu/webgpu.idl
Original file line number Diff line number Diff line change
Expand Up @@ -859,18 +859,18 @@ dictionary GPUVertexAttribute {
required GPUIndex32 shaderLocation;
};

dictionary GPUImageDataLayout {
dictionary GPUTexelCopyBufferLayout {
GPUSize64 offset = 0;
GPUSize32 bytesPerRow;
GPUSize32 rowsPerImage;
};

dictionary GPUImageCopyBuffer
: GPUImageDataLayout {
dictionary GPUTexelCopyBufferInfo
: GPUTexelCopyBufferLayout {
required GPUBuffer buffer;
};

dictionary GPUImageCopyTexture {
dictionary GPUTexelCopyTextureInfo {
required GPUTexture texture;
GPUIntegerCoordinate mipLevel = 0;
GPUOrigin3D origin = {};
Expand Down Expand Up @@ -902,18 +902,18 @@ interface GPUCommandEncoder {
GPUSize64 size);

undefined copyBufferToTexture(
GPUImageCopyBuffer source,
GPUImageCopyTexture destination,
GPUTexelCopyBufferInfo source,
GPUTexelCopyTextureInfo destination,
GPUExtent3D copySize);

undefined copyTextureToBuffer(
GPUImageCopyTexture source,
GPUImageCopyBuffer destination,
GPUTexelCopyTextureInfo source,
GPUTexelCopyBufferInfo destination,
GPUExtent3D copySize);

undefined copyTextureToTexture(
GPUImageCopyTexture source,
GPUImageCopyTexture destination,
GPUTexelCopyTextureInfo source,
GPUTexelCopyTextureInfo destination,
GPUExtent3D copySize);

undefined clearBuffer(
Expand Down Expand Up @@ -1114,9 +1114,9 @@ interface GPUQueue {
optional GPUSize64 size);

undefined writeTexture(
GPUImageCopyTexture destination,
GPUTexelCopyTextureInfo destination,
[AllowShared] BufferSource data,
GPUImageDataLayout dataLayout,
GPUTexelCopyBufferLayout dataLayout,
GPUExtent3D size);
};
GPUQueue includes GPUObjectBase;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bunnymark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl crate::framework::Example for Example {
queue.write_texture(
texture.as_image_copy(),
&buf,
wgpu::ImageDataLayout {
wgpu::TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(info.width * 4),
rows_per_image: None,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/cube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl crate::framework::Example for Example {
queue.write_texture(
texture.as_image_copy(),
&texels,
wgpu::ImageDataLayout {
wgpu::TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(size),
rows_per_image: None,
Expand Down
Loading