Skip to content
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
2 changes: 1 addition & 1 deletion codegen/idlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _parse(self):
val, _, key = value.rpartition(" ")
key = key.strip().strip(";").strip()
self.typedefs[key] = val.strip()
elif line.startswith(("interface ", "partial interface ")):
elif line.startswith(("namespace ", "interface ", "partial interface ")):
# A class or a set of flags
# Collect lines that define this interface
lines = [line]
Expand Down
5 changes: 3 additions & 2 deletions wgpu/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def request_adapter(self, *, canvas, power_preference=None):
confident that the returned adapter will work just fine).
powerPreference(PowerPreference): "high-performance" or "low-power"
"""
# todo: include forceFallbackAdapter arg when this is also correctly applied in wgpu-native (currently its not)
raise RuntimeError(
"Select a backend (by importing wgpu.rs) before requesting an adapter!"
)
Expand Down Expand Up @@ -269,9 +270,9 @@ def _destroy(self):
def __del__(self):
self._destroy()

# IDL: readonly attribute boolean isSoftware;
# IDL: readonly attribute boolean isFallbackAdapter;
@property
def is_software(self):
def is_fallback_adapter(self):
"""Whether this adapter runs on software (rather than dedicated hardware)."""
return self._properties.get("adapterType", "").lower() in ("software", "cpu")

Expand Down
68 changes: 34 additions & 34 deletions wgpu/resources/webgpu.idl
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ enum GPUPredefinedColorSpace {


interface mixin NavigatorGPU {
[SameObject] readonly attribute GPU gpu;
[SameObject, SecureContext] readonly attribute GPU gpu;
};
Navigator includes NavigatorGPU;
WorkerNavigator includes NavigatorGPU;


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPU {
Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
};


dictionary GPURequestAdapterOptions {
GPUPowerPreference powerPreference;
boolean forceSoftware = false;
boolean forceFallbackAdapter = false;
};


Expand All @@ -88,12 +88,12 @@ enum GPUPowerPreference {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUAdapter {
readonly attribute DOMString name;
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
readonly attribute boolean isSoftware;
readonly attribute boolean isFallbackAdapter;

Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
};
Expand All @@ -115,7 +115,7 @@ enum GPUFeatureName {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
Expand Down Expand Up @@ -147,7 +147,7 @@ interface GPUDevice : EventTarget {
GPUDevice includes GPUObjectBase;


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

typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
[Exposed=(Window, DedicatedWorker)]
interface GPUBufferUsage {
namespace GPUBufferUsage {
const GPUFlagsConstant MAP_READ = 0x0001;
const GPUFlagsConstant MAP_WRITE = 0x0002;
const GPUFlagsConstant COPY_SRC = 0x0004;
Expand All @@ -183,13 +183,13 @@ interface GPUBufferUsage {

typedef [EnforceRange] unsigned long GPUMapModeFlags;
[Exposed=(Window, DedicatedWorker)]
interface GPUMapMode {
namespace GPUMapMode {
const GPUFlagsConstant READ = 0x0001;
const GPUFlagsConstant WRITE = 0x0002;
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});

Expand Down Expand Up @@ -217,7 +217,7 @@ enum GPUTextureDimension {

typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
[Exposed=(Window, DedicatedWorker)]
interface GPUTextureUsage {
namespace GPUTextureUsage {
const GPUFlagsConstant COPY_SRC = 0x01;
const GPUFlagsConstant COPY_DST = 0x02;
const GPUFlagsConstant TEXTURE_BINDING = 0x04;
Expand All @@ -226,7 +226,7 @@ interface GPUTextureUsage {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUTextureView {
};
GPUTextureView includes GPUObjectBase;
Expand Down Expand Up @@ -340,7 +340,7 @@ enum GPUTextureFormat {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUExternalTexture {
};
GPUExternalTexture includes GPUObjectBase;
Expand All @@ -352,7 +352,7 @@ dictionary GPUExternalTextureDescriptor : GPUObjectDescriptorBase {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUSampler {
};
GPUSampler includes GPUObjectBase;
Expand Down Expand Up @@ -397,7 +397,7 @@ enum GPUCompareFunction {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUBindGroupLayout {
};
GPUBindGroupLayout includes GPUObjectBase;
Expand All @@ -410,7 +410,7 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {

typedef [EnforceRange] unsigned long GPUShaderStageFlags;
[Exposed=(Window, DedicatedWorker)]
interface GPUShaderStage {
namespace GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
const GPUFlagsConstant COMPUTE = 0x4;
Expand Down Expand Up @@ -482,7 +482,7 @@ dictionary GPUExternalTextureBindingLayout {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUBindGroup {
};
GPUBindGroup includes GPUObjectBase;
Expand All @@ -509,7 +509,7 @@ dictionary GPUBufferBinding {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUPipelineLayout {
};
GPUPipelineLayout includes GPUObjectBase;
Expand All @@ -520,7 +520,7 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUShaderModule {
Promise<GPUCompilationInfo> compilationInfo();
};
Expand All @@ -539,7 +539,7 @@ enum GPUCompilationMessageType {
"info"
};

[Exposed=(Window, DedicatedWorker), Serializable]
[Exposed=(Window, DedicatedWorker), Serializable, SecureContext]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
Expand All @@ -549,7 +549,7 @@ interface GPUCompilationMessage {
readonly attribute unsigned long long length;
};

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


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUComputePipeline {
};
GPUComputePipeline includes GPUObjectBase;
Expand All @@ -585,7 +585,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPURenderPipeline {
};
GPURenderPipeline includes GPUObjectBase;
Expand Down Expand Up @@ -662,7 +662,7 @@ dictionary GPUBlendState {

typedef [EnforceRange] unsigned long GPUColorWriteFlags;
[Exposed=(Window, DedicatedWorker)]
interface GPUColorWrite {
namespace GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
const GPUFlagsConstant BLUE = 0x4;
Expand All @@ -672,9 +672,9 @@ interface GPUColorWrite {


dictionary GPUBlendComponent {
GPUBlendOperation operation = "add";
GPUBlendFactor srcFactor = "one";
GPUBlendFactor dstFactor = "zero";
GPUBlendOperation operation = "add";
};


Expand Down Expand Up @@ -808,7 +808,7 @@ dictionary GPUVertexAttribute {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUCommandBuffer {
readonly attribute Promise<double> executionTime;
};
Expand All @@ -819,7 +819,7 @@ dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
Expand Down Expand Up @@ -917,7 +917,7 @@ interface mixin GPUProgrammablePassEncoder {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
Expand Down Expand Up @@ -955,7 +955,7 @@ interface mixin GPURenderEncoderBase {
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
};

[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
Expand Down Expand Up @@ -1030,7 +1030,7 @@ dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPURenderBundle {
};
GPURenderBundle includes GPUObjectBase;
Expand All @@ -1040,7 +1040,7 @@ dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPURenderBundleEncoder {
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
Expand All @@ -1055,7 +1055,7 @@ dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);

Expand All @@ -1082,7 +1082,7 @@ interface GPUQueue {
GPUQueue includes GPUObjectBase;


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUQuerySet {
undefined destroy();
};
Expand Down Expand Up @@ -1112,7 +1112,7 @@ enum GPUPipelineStatisticName {
};


[Exposed=(Window, DedicatedWorker)]
[Exposed=(Window, DedicatedWorker), SecureContext]
interface GPUCanvasContext {
readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;

Expand Down
4 changes: 2 additions & 2 deletions wgpu/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __repr__(self):
RequestAdapterOptions = Struct(
"RequestAdapterOptions",
power_preference="enums.PowerPreference",
force_software="bool",
force_fallback_adapter="bool",
) #:

DeviceDescriptor = Struct(
Expand Down Expand Up @@ -235,9 +235,9 @@ def __repr__(self):

BlendComponent = Struct(
"BlendComponent",
operation="enums.BlendOperation",
src_factor="enums.BlendFactor",
dst_factor="enums.BlendFactor",
operation="enums.BlendOperation",
) #:

DepthStencilState = Struct(
Expand Down