Skip to content

Commit 6935fdb

Browse files
authored
Update to latest IDL (#192)
1 parent d856799 commit 6935fdb

File tree

4 files changed

+40
-39
lines changed

4 files changed

+40
-39
lines changed

codegen/idlparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _parse(self):
265265
val, _, key = value.rpartition(" ")
266266
key = key.strip().strip(";").strip()
267267
self.typedefs[key] = val.strip()
268-
elif line.startswith(("interface ", "partial interface ")):
268+
elif line.startswith(("namespace ", "interface ", "partial interface ")):
269269
# A class or a set of flags
270270
# Collect lines that define this interface
271271
lines = [line]

wgpu/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def request_adapter(self, *, canvas, power_preference=None):
101101
confident that the returned adapter will work just fine).
102102
powerPreference(PowerPreference): "high-performance" or "low-power"
103103
"""
104+
# todo: include forceFallbackAdapter arg when this is also correctly applied in wgpu-native (currently its not)
104105
raise RuntimeError(
105106
"Select a backend (by importing wgpu.rs) before requesting an adapter!"
106107
)
@@ -269,9 +270,9 @@ def _destroy(self):
269270
def __del__(self):
270271
self._destroy()
271272

272-
# IDL: readonly attribute boolean isSoftware;
273+
# IDL: readonly attribute boolean isFallbackAdapter;
273274
@property
274-
def is_software(self):
275+
def is_fallback_adapter(self):
275276
"""Whether this adapter runs on software (rather than dedicated hardware)."""
276277
return self._properties.get("adapterType", "").lower() in ("software", "cpu")
277278

wgpu/resources/webgpu.idl

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ enum GPUPredefinedColorSpace {
6464

6565

6666
interface mixin NavigatorGPU {
67-
[SameObject] readonly attribute GPU gpu;
67+
[SameObject, SecureContext] readonly attribute GPU gpu;
6868
};
6969
Navigator includes NavigatorGPU;
7070
WorkerNavigator includes NavigatorGPU;
7171

7272

73-
[Exposed=(Window, DedicatedWorker)]
73+
[Exposed=(Window, DedicatedWorker), SecureContext]
7474
interface GPU {
7575
Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
7676
};
7777

7878

7979
dictionary GPURequestAdapterOptions {
8080
GPUPowerPreference powerPreference;
81-
boolean forceSoftware = false;
81+
boolean forceFallbackAdapter = false;
8282
};
8383

8484

@@ -88,12 +88,12 @@ enum GPUPowerPreference {
8888
};
8989

9090

91-
[Exposed=(Window, DedicatedWorker)]
91+
[Exposed=(Window, DedicatedWorker), SecureContext]
9292
interface GPUAdapter {
9393
readonly attribute DOMString name;
9494
[SameObject] readonly attribute GPUSupportedFeatures features;
9595
[SameObject] readonly attribute GPUSupportedLimits limits;
96-
readonly attribute boolean isSoftware;
96+
readonly attribute boolean isFallbackAdapter;
9797

9898
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
9999
};
@@ -115,7 +115,7 @@ enum GPUFeatureName {
115115
};
116116

117117

118-
[Exposed=(Window, DedicatedWorker)]
118+
[Exposed=(Window, DedicatedWorker), SecureContext]
119119
interface GPUDevice : EventTarget {
120120
[SameObject] readonly attribute GPUSupportedFeatures features;
121121
[SameObject] readonly attribute GPUSupportedLimits limits;
@@ -147,7 +147,7 @@ interface GPUDevice : EventTarget {
147147
GPUDevice includes GPUObjectBase;
148148

149149

150-
[Exposed=(Window, DedicatedWorker)]
150+
[Exposed=(Window, DedicatedWorker), SecureContext]
151151
interface GPUBuffer {
152152
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
153153
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
@@ -167,7 +167,7 @@ dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
167167

168168
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
169169
[Exposed=(Window, DedicatedWorker)]
170-
interface GPUBufferUsage {
170+
namespace GPUBufferUsage {
171171
const GPUFlagsConstant MAP_READ = 0x0001;
172172
const GPUFlagsConstant MAP_WRITE = 0x0002;
173173
const GPUFlagsConstant COPY_SRC = 0x0004;
@@ -183,13 +183,13 @@ interface GPUBufferUsage {
183183

184184
typedef [EnforceRange] unsigned long GPUMapModeFlags;
185185
[Exposed=(Window, DedicatedWorker)]
186-
interface GPUMapMode {
186+
namespace GPUMapMode {
187187
const GPUFlagsConstant READ = 0x0001;
188188
const GPUFlagsConstant WRITE = 0x0002;
189189
};
190190

191191

192-
[Exposed=(Window, DedicatedWorker)]
192+
[Exposed=(Window, DedicatedWorker), SecureContext]
193193
interface GPUTexture {
194194
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
195195

@@ -217,7 +217,7 @@ enum GPUTextureDimension {
217217

218218
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
219219
[Exposed=(Window, DedicatedWorker)]
220-
interface GPUTextureUsage {
220+
namespace GPUTextureUsage {
221221
const GPUFlagsConstant COPY_SRC = 0x01;
222222
const GPUFlagsConstant COPY_DST = 0x02;
223223
const GPUFlagsConstant TEXTURE_BINDING = 0x04;
@@ -226,7 +226,7 @@ interface GPUTextureUsage {
226226
};
227227

228228

229-
[Exposed=(Window, DedicatedWorker)]
229+
[Exposed=(Window, DedicatedWorker), SecureContext]
230230
interface GPUTextureView {
231231
};
232232
GPUTextureView includes GPUObjectBase;
@@ -340,7 +340,7 @@ enum GPUTextureFormat {
340340
};
341341

342342

343-
[Exposed=(Window, DedicatedWorker)]
343+
[Exposed=(Window, DedicatedWorker), SecureContext]
344344
interface GPUExternalTexture {
345345
};
346346
GPUExternalTexture includes GPUObjectBase;
@@ -352,7 +352,7 @@ dictionary GPUExternalTextureDescriptor : GPUObjectDescriptorBase {
352352
};
353353

354354

355-
[Exposed=(Window, DedicatedWorker)]
355+
[Exposed=(Window, DedicatedWorker), SecureContext]
356356
interface GPUSampler {
357357
};
358358
GPUSampler includes GPUObjectBase;
@@ -397,7 +397,7 @@ enum GPUCompareFunction {
397397
};
398398

399399

400-
[Exposed=(Window, DedicatedWorker)]
400+
[Exposed=(Window, DedicatedWorker), SecureContext]
401401
interface GPUBindGroupLayout {
402402
};
403403
GPUBindGroupLayout includes GPUObjectBase;
@@ -410,7 +410,7 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
410410

411411
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
412412
[Exposed=(Window, DedicatedWorker)]
413-
interface GPUShaderStage {
413+
namespace GPUShaderStage {
414414
const GPUFlagsConstant VERTEX = 0x1;
415415
const GPUFlagsConstant FRAGMENT = 0x2;
416416
const GPUFlagsConstant COMPUTE = 0x4;
@@ -482,7 +482,7 @@ dictionary GPUExternalTextureBindingLayout {
482482
};
483483

484484

485-
[Exposed=(Window, DedicatedWorker)]
485+
[Exposed=(Window, DedicatedWorker), SecureContext]
486486
interface GPUBindGroup {
487487
};
488488
GPUBindGroup includes GPUObjectBase;
@@ -509,7 +509,7 @@ dictionary GPUBufferBinding {
509509
};
510510

511511

512-
[Exposed=(Window, DedicatedWorker)]
512+
[Exposed=(Window, DedicatedWorker), SecureContext]
513513
interface GPUPipelineLayout {
514514
};
515515
GPUPipelineLayout includes GPUObjectBase;
@@ -520,7 +520,7 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
520520
};
521521

522522

523-
[Exposed=(Window, DedicatedWorker)]
523+
[Exposed=(Window, DedicatedWorker), SecureContext]
524524
interface GPUShaderModule {
525525
Promise<GPUCompilationInfo> compilationInfo();
526526
};
@@ -539,7 +539,7 @@ enum GPUCompilationMessageType {
539539
"info"
540540
};
541541

542-
[Exposed=(Window, DedicatedWorker), Serializable]
542+
[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
543543
interface GPUCompilationMessage {
544544
readonly attribute DOMString message;
545545
readonly attribute GPUCompilationMessageType type;
@@ -549,7 +549,7 @@ interface GPUCompilationMessage {
549549
readonly attribute unsigned long long length;
550550
};
551551

552-
[Exposed=(Window, DedicatedWorker), Serializable]
552+
[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
553553
interface GPUCompilationInfo {
554554
readonly attribute FrozenArray<GPUCompilationMessage> messages;
555555
};
@@ -573,7 +573,7 @@ dictionary GPUProgrammableStage {
573573
typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32.
574574

575575

576-
[Exposed=(Window, DedicatedWorker)]
576+
[Exposed=(Window, DedicatedWorker), SecureContext]
577577
interface GPUComputePipeline {
578578
};
579579
GPUComputePipeline includes GPUObjectBase;
@@ -585,7 +585,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
585585
};
586586

587587

588-
[Exposed=(Window, DedicatedWorker)]
588+
[Exposed=(Window, DedicatedWorker), SecureContext]
589589
interface GPURenderPipeline {
590590
};
591591
GPURenderPipeline includes GPUObjectBase;
@@ -662,7 +662,7 @@ dictionary GPUBlendState {
662662

663663
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
664664
[Exposed=(Window, DedicatedWorker)]
665-
interface GPUColorWrite {
665+
namespace GPUColorWrite {
666666
const GPUFlagsConstant RED = 0x1;
667667
const GPUFlagsConstant GREEN = 0x2;
668668
const GPUFlagsConstant BLUE = 0x4;
@@ -672,9 +672,9 @@ interface GPUColorWrite {
672672

673673

674674
dictionary GPUBlendComponent {
675+
GPUBlendOperation operation = "add";
675676
GPUBlendFactor srcFactor = "one";
676677
GPUBlendFactor dstFactor = "zero";
677-
GPUBlendOperation operation = "add";
678678
};
679679

680680

@@ -808,7 +808,7 @@ dictionary GPUVertexAttribute {
808808
};
809809

810810

811-
[Exposed=(Window, DedicatedWorker)]
811+
[Exposed=(Window, DedicatedWorker), SecureContext]
812812
interface GPUCommandBuffer {
813813
readonly attribute Promise<double> executionTime;
814814
};
@@ -819,7 +819,7 @@ dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
819819
};
820820

821821

822-
[Exposed=(Window, DedicatedWorker)]
822+
[Exposed=(Window, DedicatedWorker), SecureContext]
823823
interface GPUCommandEncoder {
824824
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
825825
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
@@ -917,7 +917,7 @@ interface mixin GPUProgrammablePassEncoder {
917917
};
918918

919919

920-
[Exposed=(Window, DedicatedWorker)]
920+
[Exposed=(Window, DedicatedWorker), SecureContext]
921921
interface GPUComputePassEncoder {
922922
undefined setPipeline(GPUComputePipeline pipeline);
923923
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
@@ -955,7 +955,7 @@ interface mixin GPURenderEncoderBase {
955955
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
956956
};
957957

958-
[Exposed=(Window, DedicatedWorker)]
958+
[Exposed=(Window, DedicatedWorker), SecureContext]
959959
interface GPURenderPassEncoder {
960960
undefined setViewport(float x, float y,
961961
float width, float height,
@@ -1030,7 +1030,7 @@ dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
10301030
};
10311031

10321032

1033-
[Exposed=(Window, DedicatedWorker)]
1033+
[Exposed=(Window, DedicatedWorker), SecureContext]
10341034
interface GPURenderBundle {
10351035
};
10361036
GPURenderBundle includes GPUObjectBase;
@@ -1040,7 +1040,7 @@ dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
10401040
};
10411041

10421042

1043-
[Exposed=(Window, DedicatedWorker)]
1043+
[Exposed=(Window, DedicatedWorker), SecureContext]
10441044
interface GPURenderBundleEncoder {
10451045
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
10461046
};
@@ -1055,7 +1055,7 @@ dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
10551055
};
10561056

10571057

1058-
[Exposed=(Window, DedicatedWorker)]
1058+
[Exposed=(Window, DedicatedWorker), SecureContext]
10591059
interface GPUQueue {
10601060
undefined submit(sequence<GPUCommandBuffer> commandBuffers);
10611061

@@ -1082,7 +1082,7 @@ interface GPUQueue {
10821082
GPUQueue includes GPUObjectBase;
10831083

10841084

1085-
[Exposed=(Window, DedicatedWorker)]
1085+
[Exposed=(Window, DedicatedWorker), SecureContext]
10861086
interface GPUQuerySet {
10871087
undefined destroy();
10881088
};
@@ -1112,7 +1112,7 @@ enum GPUPipelineStatisticName {
11121112
};
11131113

11141114

1115-
[Exposed=(Window, DedicatedWorker)]
1115+
[Exposed=(Window, DedicatedWorker), SecureContext]
11161116
interface GPUCanvasContext {
11171117
readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;
11181118

wgpu/structs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __repr__(self):
2828
RequestAdapterOptions = Struct(
2929
"RequestAdapterOptions",
3030
power_preference="enums.PowerPreference",
31-
force_software="bool",
31+
force_fallback_adapter="bool",
3232
) #:
3333

3434
DeviceDescriptor = Struct(
@@ -235,9 +235,9 @@ def __repr__(self):
235235

236236
BlendComponent = Struct(
237237
"BlendComponent",
238+
operation="enums.BlendOperation",
238239
src_factor="enums.BlendFactor",
239240
dst_factor="enums.BlendFactor",
240-
operation="enums.BlendOperation",
241241
) #:
242242

243243
DepthStencilState = Struct(

0 commit comments

Comments
 (0)