Skip to content

Commit fde16e0

Browse files
authored
WebGPU: Rename structures for ABI changes (emscripten-core#13690)
wgpu::Buffer/TextureCopyView was change to ImageCopyBuffer/Texture this commit updates them in a backwards compatible manner by using type aliases for the old names.
1 parent bdf9e07 commit fde16e0

6 files changed

Lines changed: 93 additions & 78 deletions

File tree

src/library_webgpu.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,14 @@ var LibraryWebGPU = {
190190
};
191191
},
192192

193-
makeTextureCopyView: function(ptr) {
193+
makeImageCopyTexture: function(ptr) {
194194
{{{ gpu.makeCheckDescriptor('ptr') }}}
195195
return {
196196
"texture": this.mgrTexture.get(
197-
{{{ makeGetValue('ptr', C_STRUCTS.WGPUTextureCopyView.texture, '*') }}}),
198-
"mipLevel": {{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUTextureCopyView.mipLevel, '*') }}},
199-
"origin": WebGPU.makeOrigin3D(ptr + {{{ C_STRUCTS.WGPUTextureCopyView.origin }}}),
200-
"aspect": WebGPU.TextureAspect[{{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUTextureCopyView.aspect) }}}],
197+
{{{ makeGetValue('ptr', C_STRUCTS.WGPUImageCopyTexture.texture, '*') }}}),
198+
"mipLevel": {{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUImageCopyTexture.mipLevel, '*') }}},
199+
"origin": WebGPU.makeOrigin3D(ptr + {{{ C_STRUCTS.WGPUImageCopyTexture.origin }}}),
200+
"aspect": WebGPU.TextureAspect[{{{ gpu.makeGetU32('ptr', C_STRUCTS.WGPUImageCopyTexture.aspect) }}}],
201201
};
202202
},
203203

@@ -210,12 +210,12 @@ var LibraryWebGPU = {
210210
};
211211
},
212212

213-
makeBufferCopyView: function(ptr) {
213+
makeImageCopyBuffer: function(ptr) {
214214
{{{ gpu.makeCheckDescriptor('ptr') }}}
215-
var layoutPtr = ptr + {{{ C_STRUCTS.WGPUBufferCopyView.layout }}};
215+
var layoutPtr = ptr + {{{ C_STRUCTS.WGPUImageCopyBuffer.layout }}};
216216
var bufferCopyView = this.makeTextureDataLayout(layoutPtr);
217217
bufferCopyView["buffer"] = this.mgrBuffer.get(
218-
{{{ makeGetValue('ptr', C_STRUCTS.WGPUBufferCopyView.buffer, '*') }}});
218+
{{{ makeGetValue('ptr', C_STRUCTS.WGPUImageCopyBuffer.buffer, '*') }}});
219219
return bufferCopyView;
220220
},
221221

@@ -1202,7 +1202,7 @@ var LibraryWebGPU = {
12021202
destinationPtr, data, _dataSize, dataLayoutPtr, writeSizePtr) {
12031203
var queue = WebGPU.mgrQueue.get(queueId);
12041204

1205-
var destination = WebGPU.makeTextureCopyView(destinationPtr);
1205+
var destination = WebGPU.makeImageCopyTexture(destinationPtr);
12061206
var dataLayout = WebGPU.makeTextureDataLayout(dataLayoutPtr);
12071207
dataLayout["offset"] += data;
12081208
var writeSize = WebGPU.makeExtent3D(writeSizePtr);
@@ -1353,21 +1353,21 @@ var LibraryWebGPU = {
13531353
var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId);
13541354
var copySize = WebGPU.makeExtent3D(copySizePtr);
13551355
commandEncoder["copyBufferToTexture"](
1356-
WebGPU.makeBufferCopyView(srcPtr), WebGPU.makeTextureCopyView(dstPtr), copySize);
1356+
WebGPU.makeImageCopyBuffer(srcPtr), WebGPU.makeImageCopyTexture(dstPtr), copySize);
13571357
},
13581358

13591359
wgpuCommandEncoderCopyTextureToBuffer: function(encoderId, srcPtr, dstPtr, copySizePtr) {
13601360
var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId);
13611361
var copySize = WebGPU.makeExtent3D(copySizePtr);
13621362
commandEncoder["copyTextureToBuffer"](
1363-
WebGPU.makeTextureCopyView(srcPtr), WebGPU.makeBufferCopyView(dstPtr), copySize);
1363+
WebGPU.makeImageCopyTexture(srcPtr), WebGPU.makeImageCopyBuffer(dstPtr), copySize);
13641364
},
13651365

13661366
wgpuCommandEncoderCopyTextureToTexture: function(encoderId, srcPtr, dstPtr, copySizePtr) {
13671367
var commandEncoder = WebGPU.mgrCommandEncoder.get(encoderId);
13681368
var copySize = WebGPU.makeExtent3D(copySizePtr);
13691369
commandEncoder["copyTextureToTexture"](
1370-
WebGPU.makeTextureCopyView(srcPtr), WebGPU.makeTextureCopyView(dstPtr), copySize);
1370+
WebGPU.makeImageCopyTexture(srcPtr), WebGPU.makeImageCopyTexture(dstPtr), copySize);
13711371
},
13721372

13731373
wgpuCommandEncoderResolveQuerySet: function(encoderId, querySetId, firstQuery, queryCount,

src/struct_info.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@
17851785
"entryCount",
17861786
"entries"
17871787
],
1788-
"WGPUBufferCopyView": [
1788+
"WGPUImageCopyBuffer": [
17891789
"nextInChain",
17901790
"layout",
17911791
"buffer"
@@ -1820,7 +1820,7 @@
18201820
"storeOp",
18211821
"clearColor"
18221822
],
1823-
"WGPUTextureCopyView": [
1823+
"WGPUImageCopyTexture": [
18241824
"nextInChain",
18251825
"texture",
18261826
"mipLevel",

system/include/webgpu/webgpu.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,11 @@ typedef struct WGPUBindGroupLayoutEntry {
817817
WGPUStorageTextureBindingLayout storageTexture;
818818
} WGPUBindGroupLayoutEntry;
819819

820-
typedef struct WGPUBufferCopyView {
820+
typedef struct WGPUImageCopyBuffer {
821821
WGPUChainedStruct const * nextInChain;
822822
WGPUTextureDataLayout layout;
823823
WGPUBuffer buffer;
824-
} WGPUBufferCopyView;
824+
} WGPUImageCopyBuffer;
825825

826826
typedef struct WGPUColorStateDescriptor {
827827
WGPUChainedStruct const * nextInChain;
@@ -857,13 +857,13 @@ typedef struct WGPURenderPassColorAttachmentDescriptor {
857857
WGPUColor clearColor;
858858
} WGPURenderPassColorAttachmentDescriptor;
859859

860-
typedef struct WGPUTextureCopyView {
860+
typedef struct WGPUImageCopyTexture {
861861
WGPUChainedStruct const * nextInChain;
862862
WGPUTexture texture;
863863
uint32_t mipLevel;
864864
WGPUOrigin3D origin;
865865
WGPUTextureAspect aspect;
866-
} WGPUTextureCopyView;
866+
} WGPUImageCopyTexture;
867867

868868
typedef struct WGPUTextureDescriptor {
869869
WGPUChainedStruct const * nextInChain;
@@ -923,6 +923,13 @@ typedef struct WGPURenderPipelineDescriptor {
923923
bool alphaToCoverageEnabled;
924924
} WGPURenderPipelineDescriptor;
925925

926+
// WGPUBufferCopyView is deprecated.
927+
// Use WGPUImageCopyBuffer instead.
928+
typedef WGPUImageCopyBuffer WGPUBufferCopyView;
929+
930+
// WGPUTextureCopyView is deprecated.
931+
// Use WGPUImageCopyTexture instead.
932+
typedef WGPUImageCopyTexture WGPUTextureCopyView;
926933

927934
#ifdef __cplusplus
928935
extern "C" {
@@ -974,9 +981,9 @@ typedef void (*WGPUProcCommandBufferRelease)(WGPUCommandBuffer commandBuffer);
974981
typedef WGPUComputePassEncoder (*WGPUProcCommandEncoderBeginComputePass)(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor);
975982
typedef WGPURenderPassEncoder (*WGPUProcCommandEncoderBeginRenderPass)(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor);
976983
typedef void (*WGPUProcCommandEncoderCopyBufferToBuffer)(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size);
977-
typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUBufferCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize);
978-
typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUBufferCopyView const * destination, WGPUExtent3D const * copySize);
979-
typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize);
984+
typedef void (*WGPUProcCommandEncoderCopyBufferToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
985+
typedef void (*WGPUProcCommandEncoderCopyTextureToBuffer)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize);
986+
typedef void (*WGPUProcCommandEncoderCopyTextureToTexture)(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
980987
typedef WGPUCommandBuffer (*WGPUProcCommandEncoderFinish)(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor);
981988
typedef void (*WGPUProcCommandEncoderInsertDebugMarker)(WGPUCommandEncoder commandEncoder, char const * markerLabel);
982989
typedef void (*WGPUProcCommandEncoderPopDebugGroup)(WGPUCommandEncoder commandEncoder);
@@ -1055,7 +1062,7 @@ typedef WGPUFence (*WGPUProcQueueCreateFence)(WGPUQueue queue, WGPUFenceDescript
10551062
typedef void (*WGPUProcQueueSignal)(WGPUQueue queue, WGPUFence fence, uint64_t signalValue);
10561063
typedef void (*WGPUProcQueueSubmit)(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands);
10571064
typedef void (*WGPUProcQueueWriteBuffer)(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size);
1058-
typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUTextureCopyView const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize);
1065+
typedef void (*WGPUProcQueueWriteTexture)(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize);
10591066
typedef void (*WGPUProcQueueReference)(WGPUQueue queue);
10601067
typedef void (*WGPUProcQueueRelease)(WGPUQueue queue);
10611068

@@ -1175,9 +1182,9 @@ WGPU_EXPORT void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer);
11751182
WGPU_EXPORT WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor);
11761183
WGPU_EXPORT WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor);
11771184
WGPU_EXPORT void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size);
1178-
WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUBufferCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize);
1179-
WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUBufferCopyView const * destination, WGPUExtent3D const * copySize);
1180-
WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUTextureCopyView const * source, WGPUTextureCopyView const * destination, WGPUExtent3D const * copySize);
1185+
WGPU_EXPORT void wgpuCommandEncoderCopyBufferToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyBuffer const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
1186+
WGPU_EXPORT void wgpuCommandEncoderCopyTextureToBuffer(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyBuffer const * destination, WGPUExtent3D const * copySize);
1187+
WGPU_EXPORT void wgpuCommandEncoderCopyTextureToTexture(WGPUCommandEncoder commandEncoder, WGPUImageCopyTexture const * source, WGPUImageCopyTexture const * destination, WGPUExtent3D const * copySize);
11811188
WGPU_EXPORT WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, WGPUCommandBufferDescriptor const * descriptor);
11821189
WGPU_EXPORT void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, char const * markerLabel);
11831190
WGPU_EXPORT void wgpuCommandEncoderPopDebugGroup(WGPUCommandEncoder commandEncoder);
@@ -1256,7 +1263,7 @@ WGPU_EXPORT WGPUFence wgpuQueueCreateFence(WGPUQueue queue, WGPUFenceDescriptor
12561263
WGPU_EXPORT void wgpuQueueSignal(WGPUQueue queue, WGPUFence fence, uint64_t signalValue);
12571264
WGPU_EXPORT void wgpuQueueSubmit(WGPUQueue queue, uint32_t commandCount, WGPUCommandBuffer const * commands);
12581265
WGPU_EXPORT void wgpuQueueWriteBuffer(WGPUQueue queue, WGPUBuffer buffer, uint64_t bufferOffset, void const * data, size_t size);
1259-
WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUTextureCopyView const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize);
1266+
WGPU_EXPORT void wgpuQueueWriteTexture(WGPUQueue queue, WGPUImageCopyTexture const * destination, void const * data, size_t dataSize, WGPUTextureDataLayout const * dataLayout, WGPUExtent3D const * writeSize);
12601267
WGPU_EXPORT void wgpuQueueReference(WGPUQueue queue);
12611268
WGPU_EXPORT void wgpuQueueRelease(WGPUQueue queue);
12621269

system/include/webgpu/webgpu_cpp.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -621,19 +621,27 @@ namespace wgpu {
621621
struct VertexAttributeDescriptor;
622622
struct BindGroupDescriptor;
623623
struct BindGroupLayoutEntry;
624-
struct BufferCopyView;
624+
struct ImageCopyBuffer;
625625
struct ColorStateDescriptor;
626626
struct ComputePipelineDescriptor;
627627
struct DepthStencilStateDescriptor;
628628
struct RenderPassColorAttachmentDescriptor;
629-
struct TextureCopyView;
629+
struct ImageCopyTexture;
630630
struct TextureDescriptor;
631631
struct VertexBufferLayoutDescriptor;
632632
struct BindGroupLayoutDescriptor;
633633
struct RenderPassDescriptor;
634634
struct VertexStateDescriptor;
635635
struct RenderPipelineDescriptor;
636636

637+
// BufferCopyView is deprecated.
638+
// Use ImageCopyBuffer instead.
639+
using BufferCopyView = ImageCopyBuffer;
640+
641+
// TextureCopyView is deprecated.
642+
// Use ImageCopyTexture instead.
643+
using TextureCopyView = ImageCopyTexture;
644+
637645
template<typename Derived, typename CType>
638646
class ObjectBase {
639647
public:
@@ -772,9 +780,9 @@ namespace wgpu {
772780
ComputePassEncoder BeginComputePass(ComputePassDescriptor const * descriptor = nullptr) const;
773781
RenderPassEncoder BeginRenderPass(RenderPassDescriptor const * descriptor) const;
774782
void CopyBufferToBuffer(Buffer const& source, uint64_t sourceOffset, Buffer const& destination, uint64_t destinationOffset, uint64_t size) const;
775-
void CopyBufferToTexture(BufferCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const;
776-
void CopyTextureToBuffer(TextureCopyView const * source, BufferCopyView const * destination, Extent3D const * copySize) const;
777-
void CopyTextureToTexture(TextureCopyView const * source, TextureCopyView const * destination, Extent3D const * copySize) const;
783+
void CopyBufferToTexture(ImageCopyBuffer const * source, ImageCopyTexture const * destination, Extent3D const * copySize) const;
784+
void CopyTextureToBuffer(ImageCopyTexture const * source, ImageCopyBuffer const * destination, Extent3D const * copySize) const;
785+
void CopyTextureToTexture(ImageCopyTexture const * source, ImageCopyTexture const * destination, Extent3D const * copySize) const;
778786
CommandBuffer Finish(CommandBufferDescriptor const * descriptor = nullptr) const;
779787
void InsertDebugMarker(char const * markerLabel) const;
780788
void PopDebugGroup() const;
@@ -915,7 +923,7 @@ namespace wgpu {
915923
void Signal(Fence const& fence, uint64_t signalValue) const;
916924
void Submit(uint32_t commandCount, CommandBuffer const * commands) const;
917925
void WriteBuffer(Buffer const& buffer, uint64_t bufferOffset, void const * data, size_t size) const;
918-
void WriteTexture(TextureCopyView const * destination, void const * data, size_t dataSize, TextureDataLayout const * dataLayout, Extent3D const * writeSize) const;
926+
void WriteTexture(ImageCopyTexture const * destination, void const * data, size_t dataSize, TextureDataLayout const * dataLayout, Extent3D const * writeSize) const;
919927

920928
private:
921929
friend ObjectBase<Queue, WGPUQueue>;
@@ -1391,7 +1399,7 @@ namespace wgpu {
13911399
StorageTextureBindingLayout storageTexture;
13921400
};
13931401

1394-
struct BufferCopyView {
1402+
struct ImageCopyBuffer {
13951403
ChainedStruct const * nextInChain = nullptr;
13961404
TextureDataLayout layout;
13971405
Buffer buffer;
@@ -1431,7 +1439,7 @@ namespace wgpu {
14311439
Color clearColor;
14321440
};
14331441

1434-
struct TextureCopyView {
1442+
struct ImageCopyTexture {
14351443
ChainedStruct const * nextInChain = nullptr;
14361444
Texture texture;
14371445
uint32_t mipLevel = 0;

0 commit comments

Comments
 (0)