Skip to content

Commit

Permalink
refactor: handle 2024-08 spec. rename for image copy APIs in `deno_we…
Browse files Browse the repository at this point in the history
…bgpu/`
  • Loading branch information
ErichDonGubler committed Nov 27, 2024
1 parent 9436d56 commit 170f457
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 57 deletions.
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
16 changes: 8 additions & 8 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 Down Expand Up @@ -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 Down Expand Up @@ -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 Down
10 changes: 5 additions & 5 deletions deno_webgpu/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ 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::TexelCopyBufferLayout {
fn from(layout: GpuImageDataLayout) -> Self {
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,
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 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

0 comments on commit 170f457

Please sign in to comment.