From 98f7be3c6f1b003765bde3995aa7baa85e870e1b Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Sun, 19 Dec 2021 21:51:33 +0100 Subject: [PATCH 1/3] new idl --- wgpu/resources/webgpu.idl | 201 ++++++++++++++++++++++++-------------- 1 file changed, 130 insertions(+), 71 deletions(-) diff --git a/wgpu/resources/webgpu.idl b/wgpu/resources/webgpu.idl index fb2e57a1..e286ec44 100644 --- a/wgpu/resources/webgpu.idl +++ b/wgpu/resources/webgpu.idl @@ -21,7 +21,7 @@ dictionary GPUObjectDescriptorBase { }; -[Exposed=(Window, DedicatedWorker)] +[Exposed=(Window, DedicatedWorker), SecureContext] interface GPUSupportedLimits { readonly attribute unsigned long maxTextureDimension1D; readonly attribute unsigned long maxTextureDimension2D; @@ -52,7 +52,7 @@ interface GPUSupportedLimits { }; -[Exposed=(Window, DedicatedWorker)] +[Exposed=(Window, DedicatedWorker), SecureContext] interface GPUSupportedFeatures { readonly setlike; }; @@ -84,7 +84,7 @@ dictionary GPURequestAdapterOptions { enum GPUPowerPreference { "low-power", - "high-performance" + "high-performance", }; @@ -106,12 +106,14 @@ dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase { enum GPUFeatureName { - "depth-clamping", + "depth-clip-control", "depth24unorm-stencil8", "depth32float-stencil8", - "pipeline-statistics-query", "texture-compression-bc", + "texture-compression-etc2", + "texture-compression-astc", "timestamp-query", + "indirect-first-instance", }; @@ -249,14 +251,14 @@ enum GPUTextureViewDimension { "2d-array", "cube", "cube-array", - "3d" + "3d", }; enum GPUTextureAspect { "all", "stencil-only", - "depth-only" + "depth-only", }; @@ -308,13 +310,19 @@ enum GPUTextureFormat { "rgba32sint", "rgba32float", - // Depth and stencil formats + // Depth/stencil formats "stencil8", "depth16unorm", "depth24plus", "depth24plus-stencil8", "depth32float", + // "depth24unorm-stencil8" feature + "depth24unorm-stencil8", + + // "depth32float-stencil8" feature + "depth32float-stencil8", + // BC compressed formats usable if "texture-compression-bc" is both // supported by the device/user agent and enabled in requestDevice. "bc1-rgba-unorm", @@ -332,11 +340,49 @@ enum GPUTextureFormat { "bc7-rgba-unorm", "bc7-rgba-unorm-srgb", - // "depth24unorm-stencil8" feature - "depth24unorm-stencil8", - - // "depth32float-stencil8" feature - "depth32float-stencil8", + // ETC2 compressed formats usable if "texture-compression-etc2" is both + // supported by the device/user agent and enabled in requestDevice. + "etc2-rgb8unorm", + "etc2-rgb8unorm-srgb", + "etc2-rgb8a1unorm", + "etc2-rgb8a1unorm-srgb", + "etc2-rgba8unorm", + "etc2-rgba8unorm-srgb", + "eac-r11unorm", + "eac-r11snorm", + "eac-rg11unorm", + "eac-rg11snorm", + + // ASTC compressed formats usable if "texture-compression-astc" is both + // supported by the device/user agent and enabled in requestDevice. + "astc-4x4-unorm", + "astc-4x4-unorm-srgb", + "astc-5x4-unorm", + "astc-5x4-unorm-srgb", + "astc-5x5-unorm", + "astc-5x5-unorm-srgb", + "astc-6x5-unorm", + "astc-6x5-unorm-srgb", + "astc-6x6-unorm", + "astc-6x6-unorm-srgb", + "astc-8x5-unorm", + "astc-8x5-unorm-srgb", + "astc-8x6-unorm", + "astc-8x6-unorm-srgb", + "astc-8x8-unorm", + "astc-8x8-unorm-srgb", + "astc-10x5-unorm", + "astc-10x5-unorm-srgb", + "astc-10x6-unorm", + "astc-10x6-unorm-srgb", + "astc-10x8-unorm", + "astc-10x8-unorm-srgb", + "astc-10x10-unorm", + "astc-10x10-unorm-srgb", + "astc-12x10-unorm", + "astc-12x10-unorm-srgb", + "astc-12x12-unorm", + "astc-12x12-unorm-srgb", }; @@ -375,13 +421,13 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase { enum GPUAddressMode { "clamp-to-edge", "repeat", - "mirror-repeat" + "mirror-repeat", }; enum GPUFilterMode { "nearest", - "linear" + "linear", }; @@ -393,7 +439,7 @@ enum GPUCompareFunction { "greater", "not-equal", "greater-equal", - "always" + "always", }; @@ -453,11 +499,11 @@ dictionary GPUSamplerBindingLayout { enum GPUTextureSampleType { - "float", - "unfilterable-float", - "depth", - "sint", - "uint", + "float", + "unfilterable-float", + "depth", + "sint", + "uint", }; dictionary GPUTextureBindingLayout { @@ -527,16 +573,21 @@ interface GPUShaderModule { GPUShaderModule includes GPUObjectBase; +dictionary GPUShaderModuleCompilationHint { + required GPUPipelineLayout layout; +}; + dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase { required USVString code; object sourceMap; + record hints; }; enum GPUCompilationMessageType { "error", "warning", - "info" + "info", }; [Exposed=(Window, DedicatedWorker), Serializable, SecureContext] @@ -606,7 +657,7 @@ enum GPUPrimitiveTopology { "line-list", "line-strip", "triangle-list", - "triangle-strip" + "triangle-strip", }; @@ -616,21 +667,21 @@ dictionary GPUPrimitiveState { GPUFrontFace frontFace = "ccw"; GPUCullMode cullMode = "none"; - // Enable depth clamping (requires "depth-clamping" feature) - boolean clampDepth = false; + // Requires "depth-clip-control" feature. + boolean unclippedDepth = false; }; enum GPUFrontFace { "ccw", - "cw" + "cw", }; enum GPUCullMode { "none", "front", - "back" + "back", }; @@ -641,7 +692,7 @@ dictionary GPUMultisampleState { }; -dictionary GPUFragmentState: GPUProgrammableStage { +dictionary GPUFragmentState : GPUProgrammableStage { required sequence targets; }; @@ -691,7 +742,7 @@ enum GPUBlendFactor { "one-minus-dst-alpha", "src-alpha-saturated", "constant", - "one-minus-constant" + "one-minus-constant", }; @@ -700,7 +751,7 @@ enum GPUBlendOperation { "subtract", "reverse-subtract", "min", - "max" + "max", }; @@ -738,13 +789,13 @@ enum GPUStencilOperation { "increment-clamp", "decrement-clamp", "increment-wrap", - "decrement-wrap" + "decrement-wrap", }; enum GPUIndexFormat { "uint16", - "uint32" + "uint32", }; @@ -784,11 +835,11 @@ enum GPUVertexFormat { enum GPUVertexStepMode { "vertex", - "instance" + "instance", }; -dictionary GPUVertexState: GPUProgrammableStage { +dictionary GPUVertexState : GPUProgrammableStage { sequence buffers = []; }; @@ -810,7 +861,6 @@ dictionary GPUVertexAttribute { [Exposed=(Window, DedicatedWorker), SecureContext] interface GPUCommandBuffer { - readonly attribute Promise executionTime; }; GPUCommandBuffer includes GPUObjectBase; @@ -846,6 +896,11 @@ interface GPUCommandEncoder { GPUImageCopyTexture destination, GPUExtent3D copySize); + undefined clearBuffer( + GPUBuffer buffer, + optional GPUSize64 offset = 0, + optional GPUSize64 size); + undefined pushDebugGroup(USVString groupLabel); undefined popDebugGroup(); undefined insertDebugMarker(USVString markerLabel); @@ -865,7 +920,6 @@ GPUCommandEncoder includes GPUObjectBase; dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase { - boolean measureExecutionTime = false; }; @@ -923,18 +977,27 @@ interface GPUComputePassEncoder { undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1); undefined dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); - undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex); - undefined endPipelineStatisticsQuery(); - - undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex); - undefined endPass(); }; GPUComputePassEncoder includes GPUObjectBase; GPUComputePassEncoder includes GPUProgrammablePassEncoder; +enum GPUComputePassTimestampLocation { + "beginning", + "end", +}; + +dictionary GPUComputePassTimestampWrite { + required GPUQuerySet querySet; + required GPUSize32 queryIndex; + required GPUComputePassTimestampLocation location; +}; + +typedef sequence GPUComputePassTimestampWrites; + dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase { + GPUComputePassTimestampWrites timestampWrites = []; }; @@ -970,11 +1033,6 @@ interface GPURenderPassEncoder { undefined beginOcclusionQuery(GPUSize32 queryIndex); undefined endOcclusionQuery(); - undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex); - undefined endPipelineStatisticsQuery(); - - undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex); - undefined executeBundles(sequence bundles); undefined endPass(); }; @@ -983,10 +1041,24 @@ GPURenderPassEncoder includes GPUProgrammablePassEncoder; GPURenderPassEncoder includes GPURenderEncoderBase; +enum GPURenderPassTimestampLocation { + "beginning", + "end", +}; + +dictionary GPURenderPassTimestampWrite { + required GPUQuerySet querySet; + required GPUSize32 queryIndex; + required GPURenderPassTimestampLocation location; +}; + +typedef sequence GPURenderPassTimestampWrites; + dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase { required sequence colorAttachments; GPURenderPassDepthStencilAttachment depthStencilAttachment; GPUQuerySet occlusionQuerySet; + GPURenderPassTimestampWrites timestampWrites = []; }; @@ -1013,13 +1085,13 @@ dictionary GPURenderPassDepthStencilAttachment { enum GPULoadOp { - "load" + "load", }; enum GPUStoreOp { "store", - "discard" + "discard", }; @@ -1069,10 +1141,10 @@ interface GPUQueue { optional GPUSize64 size); undefined writeTexture( - GPUImageCopyTexture destination, - [AllowShared] BufferSource data, - GPUImageDataLayout dataLayout, - GPUExtent3D size); + GPUImageCopyTexture destination, + [AllowShared] BufferSource data, + GPUImageDataLayout dataLayout, + GPUExtent3D size); undefined copyExternalImageToTexture( GPUImageCopyExternalImage source, @@ -1092,23 +1164,12 @@ GPUQuerySet includes GPUObjectBase; dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase { required GPUQueryType type; required GPUSize32 count; - sequence pipelineStatistics = []; }; enum GPUQueryType { "occlusion", - "pipeline-statistics", - "timestamp" -}; - - -enum GPUPipelineStatisticName { - "vertex-shader-invocations", - "clipper-invocations", - "clipper-primitives-out", - "fragment-shader-invocations", - "compute-shader-invocations" + "timestamp", }; @@ -1144,7 +1205,7 @@ enum GPUDeviceLostReason { "destroyed", }; -[Exposed=(Window, DedicatedWorker)] +[Exposed=(Window, DedicatedWorker), SecureContext] interface GPUDeviceLostInfo { readonly attribute (GPUDeviceLostReason or undefined) reason; readonly attribute DOMString message; @@ -1157,16 +1218,16 @@ partial interface GPUDevice { enum GPUErrorFilter { "out-of-memory", - "validation" + "validation", }; -[Exposed=(Window, DedicatedWorker)] +[Exposed=(Window, DedicatedWorker), SecureContext] interface GPUOutOfMemoryError { constructor(); }; -[Exposed=(Window, DedicatedWorker)] +[Exposed=(Window, DedicatedWorker), SecureContext] interface GPUValidationError { constructor(DOMString message); readonly attribute DOMString message; @@ -1181,9 +1242,7 @@ partial interface GPUDevice { }; -[ - Exposed=(Window, DedicatedWorker) -] +[Exposed=(Window, DedicatedWorker), SecureContext] interface GPUUncapturedErrorEvent : Event { constructor( DOMString type, From d7e253fdbad3684f3408c64aa147dee7ea8ae118 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Sun, 19 Dec 2021 22:27:00 +0100 Subject: [PATCH 2/3] make adjustments --- CHANGELOG.md | 2 +- wgpu/backends/rs.py | 48 +++++++++++--------- wgpu/backends/rs_mappings.py | 59 +++++++++++++++++++++---- wgpu/base.py | 76 +++++++++++--------------------- wgpu/enums.py | 72 +++++++++++++++++++++++------- wgpu/resources/codegen_report.md | 17 +++---- wgpu/structs.py | 28 ++++++++++-- 7 files changed, 193 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 843d127d..893082f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Changed: * Now targeting wgpu-native v0.11.0.1, containing many upstream fixes and improvements. * The `[[block]]` syntax in shaders has been dropped. - +* Renamed `depth_clamping` -> `depth_clip_control`. ### [v0.6.0] - 16-12-2021 diff --git a/wgpu/backends/rs.py b/wgpu/backends/rs.py index 98cee223..bf6f0054 100644 --- a/wgpu/backends/rs.py +++ b/wgpu/backends/rs.py @@ -845,8 +845,17 @@ def create_pipeline_layout( id = lib.wgpuDeviceCreatePipelineLayout(self._internal, struct) return GPUPipelineLayout(label, id, self, bind_group_layouts) - def create_shader_module(self, *, label="", code: str, source_map: dict = None): - + def create_shader_module( + self, + *, + label="", + code: str, + source_map: dict = None, + hints: "Dict[str, structs.ShaderModuleCompilationHint]" = None, + ): + if hints: + for val in hints.values(): + check_struct("ShaderModuleCompilationHint", val) if isinstance(code, str): # WGSL # H: chain: WGPUChainedStruct, code: char * @@ -1152,7 +1161,7 @@ async def create_render_pipeline_async( fragment=fragment, ) - def create_command_encoder(self, *, label="", measure_execution_time: bool = False): + def create_command_encoder(self, *, label=""): # H: nextInChain: WGPUChainedStruct *, label: char * struct = new_struct_p( "WGPUCommandEncoderDescriptor *", @@ -1178,14 +1187,7 @@ def create_render_bundle_encoder( raise NotImplementedError() # FIXME: new method to implement - def create_query_set( - self, - *, - label="", - type: "enums.QueryType", - count: int, - pipeline_statistics: "List[enums.PipelineStatisticName]" = [], - ): + def create_query_set(self, *, label="", type: "enums.QueryType", count: int): raise NotImplementedError() def _destroy(self): @@ -1422,7 +1424,14 @@ def _destroy(self): class GPUCommandEncoder(base.GPUCommandEncoder, GPUObjectBase): - def begin_compute_pass(self, *, label=""): + def begin_compute_pass( + self, + *, + label="", + timestamp_writes: "List[structs.ComputePassTimestampWrite]" = [], + ): + for val in timestamp_writes: + check_struct("ComputePassTimestampWrite", val) # H: nextInChain: WGPUChainedStruct *, label: char *, timestampWriteCount: int, timestampWrites: WGPUComputePassTimestampWrite * struct = new_struct_p( "WGPUComputePassDescriptor *", @@ -1442,8 +1451,11 @@ def begin_render_pass( color_attachments: "List[structs.RenderPassColorAttachment]", depth_stencil_attachment: "structs.RenderPassDepthStencilAttachment" = None, occlusion_query_set: "GPUQuerySet" = None, + timestamp_writes: "List[structs.RenderPassTimestampWrite]" = [], ): # Note that occlusion_query_set is ignored because wgpu-native does not have it. + for val in timestamp_writes: + check_struct("RenderPassTimestampWrite", val) c_color_attachments_list = [] for color_attachment in color_attachments: @@ -1768,6 +1780,10 @@ def _destroy(self): # H: void f(WGPUCommandEncoder commandEncoder) internal # lib.wgpuCommandEncoderDrop(internal) # Causes 'Cannot remove a vacant resource' + # FIXME: new method to implement + def clear_buffer(self, buffer, offset=0, size=None): + raise NotImplementedError() + class GPUProgrammablePassEncoder(base.GPUProgrammablePassEncoder): def set_bind_group( @@ -1864,10 +1880,6 @@ def end_pass(self): # H: void f(WGPUComputePassEncoder computePassEncoder) lib.wgpuComputePassEncoderEndPass(self._internal) - # FIXME: new method to implement - def write_timestamp(self, query_set, query_index): - raise NotImplementedError() - def _destroy(self): if self._internal is not None and lib is not None: self._internal, internal = None, self._internal @@ -2000,10 +2012,6 @@ def begin_occlusion_query(self, query_index): def end_occlusion_query(self): raise NotImplementedError() - # FIXME: new method to implement - def write_timestamp(self, query_set, query_index): - raise NotImplementedError() - class GPURenderBundleEncoder( base.GPURenderBundleEncoder, diff --git a/wgpu/backends/rs_mappings.py b/wgpu/backends/rs_mappings.py index 0ee52532..bd056130 100644 --- a/wgpu/backends/rs_mappings.py +++ b/wgpu/backends/rs_mappings.py @@ -4,7 +4,7 @@ # flake8: noqa -# There are 188 enum mappings +# There are 227 enum mappings enummap = { "AddressMode.clamp-to-edge": 2, @@ -42,16 +42,21 @@ "CompilationMessageType.error": 0, "CompilationMessageType.info": 2, "CompilationMessageType.warning": 1, + "ComputePassTimestampLocation.beginning": 0, + "ComputePassTimestampLocation.end": 1, "CullMode.back": 2, "CullMode.front": 1, "CullMode.none": 0, "DeviceLostReason.destroyed": 1, "ErrorFilter.out-of-memory": 2, "ErrorFilter.validation": 1, + "FeatureName.depth-clip-control": 1, "FeatureName.depth24unorm-stencil8": 2, "FeatureName.depth32float-stencil8": 3, - "FeatureName.pipeline-statistics-query": 5, + "FeatureName.indirect-first-instance": 9, + "FeatureName.texture-compression-astc": 8, "FeatureName.texture-compression-bc": 6, + "FeatureName.texture-compression-etc2": 7, "FeatureName.timestamp-query": 4, "FilterMode.linear": 1, "FilterMode.nearest": 0, @@ -60,11 +65,6 @@ "IndexFormat.uint16": 1, "IndexFormat.uint32": 2, "LoadOp.load": 1, - "PipelineStatisticName.clipper-invocations": 1, - "PipelineStatisticName.clipper-primitives-out": 2, - "PipelineStatisticName.compute-shader-invocations": 4, - "PipelineStatisticName.fragment-shader-invocations": 3, - "PipelineStatisticName.vertex-shader-invocations": 0, "PowerPreference.high-performance": 2, "PowerPreference.low-power": 1, "PrimitiveTopology.line-list": 1, @@ -73,8 +73,9 @@ "PrimitiveTopology.triangle-list": 3, "PrimitiveTopology.triangle-strip": 4, "QueryType.occlusion": 0, - "QueryType.pipeline-statistics": 1, "QueryType.timestamp": 2, + "RenderPassTimestampLocation.beginning": 0, + "RenderPassTimestampLocation.end": 1, "SamplerBindingType.comparison": 3, "SamplerBindingType.filtering": 1, "SamplerBindingType.non-filtering": 2, @@ -95,6 +96,34 @@ "TextureDimension.1d": 0, "TextureDimension.2d": 1, "TextureDimension.3d": 2, + "TextureFormat.astc-10x10-unorm": 90, + "TextureFormat.astc-10x10-unorm-srgb": 91, + "TextureFormat.astc-10x5-unorm": 84, + "TextureFormat.astc-10x5-unorm-srgb": 85, + "TextureFormat.astc-10x6-unorm": 86, + "TextureFormat.astc-10x6-unorm-srgb": 87, + "TextureFormat.astc-10x8-unorm": 88, + "TextureFormat.astc-10x8-unorm-srgb": 89, + "TextureFormat.astc-12x10-unorm": 92, + "TextureFormat.astc-12x10-unorm-srgb": 93, + "TextureFormat.astc-12x12-unorm": 94, + "TextureFormat.astc-12x12-unorm-srgb": 95, + "TextureFormat.astc-4x4-unorm": 68, + "TextureFormat.astc-4x4-unorm-srgb": 69, + "TextureFormat.astc-5x4-unorm": 70, + "TextureFormat.astc-5x4-unorm-srgb": 71, + "TextureFormat.astc-5x5-unorm": 72, + "TextureFormat.astc-5x5-unorm-srgb": 73, + "TextureFormat.astc-6x5-unorm": 74, + "TextureFormat.astc-6x5-unorm-srgb": 75, + "TextureFormat.astc-6x6-unorm": 76, + "TextureFormat.astc-6x6-unorm-srgb": 77, + "TextureFormat.astc-8x5-unorm": 78, + "TextureFormat.astc-8x5-unorm-srgb": 79, + "TextureFormat.astc-8x6-unorm": 80, + "TextureFormat.astc-8x6-unorm-srgb": 81, + "TextureFormat.astc-8x8-unorm": 82, + "TextureFormat.astc-8x8-unorm-srgb": 83, "TextureFormat.bc1-rgba-unorm": 44, "TextureFormat.bc1-rgba-unorm-srgb": 45, "TextureFormat.bc2-rgba-unorm": 46, @@ -117,6 +146,16 @@ "TextureFormat.depth24unorm-stencil8": 41, "TextureFormat.depth32float": 42, "TextureFormat.depth32float-stencil8": 43, + "TextureFormat.eac-r11snorm": 65, + "TextureFormat.eac-r11unorm": 64, + "TextureFormat.eac-rg11snorm": 67, + "TextureFormat.eac-rg11unorm": 66, + "TextureFormat.etc2-rgb8a1unorm": 60, + "TextureFormat.etc2-rgb8a1unorm-srgb": 61, + "TextureFormat.etc2-rgb8unorm": 58, + "TextureFormat.etc2-rgb8unorm-srgb": 59, + "TextureFormat.etc2-rgba8unorm": 62, + "TextureFormat.etc2-rgba8unorm-srgb": 63, "TextureFormat.r16float": 7, "TextureFormat.r16sint": 6, "TextureFormat.r16uint": 5, @@ -197,7 +236,7 @@ "VertexStepMode.vertex": 0, } -# There are 47 struct-field enum mappings +# There are 49 struct-field enum mappings cstructfield2enum = { "BlendComponent.dstFactor": "BlendFactor", @@ -206,6 +245,7 @@ "BufferBindingLayout.type": "BufferBindingType", "ColorTargetState.format": "TextureFormat", "CompilationMessage.type": "CompilationMessageType", + "ComputePassTimestampWrite.location": "ComputePassTimestampLocation", "DepthStencilState.depthCompare": "CompareFunction", "DepthStencilState.format": "TextureFormat", "ImageCopyTexture.aspect": "TextureAspect", @@ -221,6 +261,7 @@ "RenderPassDepthStencilAttachment.depthStoreOp": "StoreOp", "RenderPassDepthStencilAttachment.stencilLoadOp": "LoadOp", "RenderPassDepthStencilAttachment.stencilStoreOp": "StoreOp", + "RenderPassTimestampWrite.location": "RenderPassTimestampLocation", "RequestAdapterOptions.powerPreference": "PowerPreference", "SamplerBindingLayout.type": "SamplerBindingType", "SamplerDescriptor.addressModeU": "AddressMode", diff --git a/wgpu/base.py b/wgpu/base.py index c18d6197..4b11e2d4 100644 --- a/wgpu/base.py +++ b/wgpu/base.py @@ -596,13 +596,21 @@ def create_pipeline_layout( raise NotImplementedError() # IDL: GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor); - def create_shader_module(self, *, label="", code: str, source_map: dict = None): + def create_shader_module( + self, + *, + label="", + code: str, + source_map: dict = None, + hints: "Dict[str, structs.ShaderModuleCompilationHint]" = None, + ): """Create a :class:`GPUShaderModule` object from shader source. Arguments: label (str): A human readable label. Optional. code (str | bytes): The shader code, as WGSL text or binary SpirV (or an object implementing ``to_spirv()`` or ``to_bytes()``). + hints: unused. """ raise NotImplementedError() @@ -792,14 +800,13 @@ async def create_render_pipeline_async( raise NotImplementedError() # IDL: GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); - def create_command_encoder(self, *, label="", measure_execution_time: bool = False): + def create_command_encoder(self, *, label=""): """Create a :class:`GPUCommandEncoder` object. A command encoder is used to record commands, which can then be submitted at once to the GPU. Arguments: label (str): A human readable label. Optional. - measure_execution_time (bool): Whether to measure the execution time. Default False. """ raise NotImplementedError() @@ -822,14 +829,7 @@ def create_render_bundle_encoder( # FIXME: new method to implement # IDL: GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor); - def create_query_set( - self, - *, - label="", - type: "enums.QueryType", - count: int, - pipeline_statistics: "List[enums.PipelineStatisticName]" = [], - ): + def create_query_set(self, *, label="", type: "enums.QueryType", count: int): """Create a :class:`GPUQuerySet` object.""" raise NotImplementedError() @@ -1172,12 +1172,6 @@ class GPUCommandBuffer(GPUObjectBase): Create a command buffer using :func:`GPUCommandEncoder.finish`. """ - # IDL: readonly attribute Promise executionTime; - @property - def execution_time(self): - """Returns a future that, if measureExecutionTime is true, resolves after the command buffer executes.""" - raise NotImplementedError() - class GPUCommandEncoder(GPUObjectBase): """ @@ -1188,12 +1182,18 @@ class GPUCommandEncoder(GPUObjectBase): """ # IDL: GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); - def begin_compute_pass(self, *, label=""): + def begin_compute_pass( + self, + *, + label="", + timestamp_writes: "List[structs.ComputePassTimestampWrite]" = [], + ): """Record the beginning of a compute pass. Returns a :class:`GPUComputePassEncoder` object. Arguments: label (str): A human readable label. Optional. + timestamp_writes: unused """ raise NotImplementedError() @@ -1205,6 +1205,7 @@ def begin_render_pass( color_attachments: "List[structs.RenderPassColorAttachment]", depth_stencil_attachment: "structs.RenderPassDepthStencilAttachment" = None, occlusion_query_set: "GPUQuerySet" = None, + timestamp_writes: "List[structs.RenderPassTimestampWrite]" = [], ): """Record the beginning of a render pass. Returns a :class:`GPURenderPassEncoder` object. @@ -1214,6 +1215,7 @@ def begin_render_pass( color_attachments (list of dict): List of color attachment dicts. See below. depth_stencil_attachment (dict): A depth stencil attachment dict. See below. Default None. occlusion_query_set: Default None. TODO NOT IMPLEMENTED in wgpu-native. + timestamp_writes: unused Example color attachment: @@ -1331,6 +1333,12 @@ def resolve_query_set( """TODO""" raise NotImplementedError() + # FIXME: new method to implement + # IDL: undefined clearBuffer( GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); + def clear_buffer(self, buffer, offset=0, size=None): + """Set (part of) the given buffer to zeros.""" + raise NotImplementedError() + class GPUProgrammablePassEncoder: """ @@ -1416,22 +1424,6 @@ def end_pass(self): """Record the end of the compute pass.""" raise NotImplementedError() - # IDL: undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex); - @apidiff.hide - def begin_pipeline_statistics_query(self, query_set, query_index): - raise NotImplementedError() - - # IDL: undefined endPipelineStatisticsQuery(); - @apidiff.hide - def end_pipeline_statistics_query(self): - raise NotImplementedError() - - # FIXME: new method to implement - # IDL: undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex); - def write_timestamp(self, query_set, query_index): - """TODO""" - raise NotImplementedError() - class GPURenderEncoderBase: """ @@ -1609,22 +1601,6 @@ def end_occlusion_query(self): """TODO""" raise NotImplementedError() - # IDL: undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex); - @apidiff.hide - def begin_pipeline_statistics_query(self, query_set, query_index): - raise NotImplementedError() - - # IDL: undefined endPipelineStatisticsQuery(); - @apidiff.hide - def end_pipeline_statistics_query(self): - raise NotImplementedError() - - # FIXME: new method to implement - # IDL: undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex); - def write_timestamp(self, query_set, query_index): - """TODO""" - raise NotImplementedError() - class GPURenderBundle(GPUObjectBase): """ diff --git a/wgpu/enums.py b/wgpu/enums.py index fafe16c9..4eeec1a1 100644 --- a/wgpu/enums.py +++ b/wgpu/enums.py @@ -25,7 +25,7 @@ def __repr__(self): return f"<{self.__class__.__name__} {self._name}: {options}>" -# There are 31 enums +# There are 32 enums PredefinedColorSpace = Enum( "PredefinedColorSpace", @@ -40,12 +40,14 @@ def __repr__(self): FeatureName = Enum( "FeatureName", - depth_clamping="depth-clamping", + depth_clip_control="depth-clip-control", depth24unorm_stencil8="depth24unorm-stencil8", depth32float_stencil8="depth32float-stencil8", - pipeline_statistics_query="pipeline-statistics-query", texture_compression_bc="texture-compression-bc", + texture_compression_etc2="texture-compression-etc2", + texture_compression_astc="texture-compression-astc", timestamp_query="timestamp-query", + indirect_first_instance="indirect-first-instance", ) #: TextureDimension = Enum( @@ -115,6 +117,8 @@ def __repr__(self): depth24plus="depth24plus", depth24plus_stencil8="depth24plus-stencil8", depth32float="depth32float", + depth24unorm_stencil8="depth24unorm-stencil8", + depth32float_stencil8="depth32float-stencil8", bc1_rgba_unorm="bc1-rgba-unorm", bc1_rgba_unorm_srgb="bc1-rgba-unorm-srgb", bc2_rgba_unorm="bc2-rgba-unorm", @@ -129,8 +133,44 @@ def __repr__(self): bc6h_rgb_float="bc6h-rgb-float", bc7_rgba_unorm="bc7-rgba-unorm", bc7_rgba_unorm_srgb="bc7-rgba-unorm-srgb", - depth24unorm_stencil8="depth24unorm-stencil8", - depth32float_stencil8="depth32float-stencil8", + etc2_rgb8unorm="etc2-rgb8unorm", + etc2_rgb8unorm_srgb="etc2-rgb8unorm-srgb", + etc2_rgb8a1unorm="etc2-rgb8a1unorm", + etc2_rgb8a1unorm_srgb="etc2-rgb8a1unorm-srgb", + etc2_rgba8unorm="etc2-rgba8unorm", + etc2_rgba8unorm_srgb="etc2-rgba8unorm-srgb", + eac_r11unorm="eac-r11unorm", + eac_r11snorm="eac-r11snorm", + eac_rg11unorm="eac-rg11unorm", + eac_rg11snorm="eac-rg11snorm", + astc_4x4_unorm="astc-4x4-unorm", + astc_4x4_unorm_srgb="astc-4x4-unorm-srgb", + astc_5x4_unorm="astc-5x4-unorm", + astc_5x4_unorm_srgb="astc-5x4-unorm-srgb", + astc_5x5_unorm="astc-5x5-unorm", + astc_5x5_unorm_srgb="astc-5x5-unorm-srgb", + astc_6x5_unorm="astc-6x5-unorm", + astc_6x5_unorm_srgb="astc-6x5-unorm-srgb", + astc_6x6_unorm="astc-6x6-unorm", + astc_6x6_unorm_srgb="astc-6x6-unorm-srgb", + astc_8x5_unorm="astc-8x5-unorm", + astc_8x5_unorm_srgb="astc-8x5-unorm-srgb", + astc_8x6_unorm="astc-8x6-unorm", + astc_8x6_unorm_srgb="astc-8x6-unorm-srgb", + astc_8x8_unorm="astc-8x8-unorm", + astc_8x8_unorm_srgb="astc-8x8-unorm-srgb", + astc_10x5_unorm="astc-10x5-unorm", + astc_10x5_unorm_srgb="astc-10x5-unorm-srgb", + astc_10x6_unorm="astc-10x6-unorm", + astc_10x6_unorm_srgb="astc-10x6-unorm-srgb", + astc_10x8_unorm="astc-10x8-unorm", + astc_10x8_unorm_srgb="astc-10x8-unorm-srgb", + astc_10x10_unorm="astc-10x10-unorm", + astc_10x10_unorm_srgb="astc-10x10-unorm-srgb", + astc_12x10_unorm="astc-12x10-unorm", + astc_12x10_unorm_srgb="astc-12x10-unorm-srgb", + astc_12x12_unorm="astc-12x12-unorm", + astc_12x12_unorm_srgb="astc-12x12-unorm-srgb", ) #: AddressMode = Enum( @@ -299,6 +339,18 @@ def __repr__(self): instance="instance", ) #: +ComputePassTimestampLocation = Enum( + "ComputePassTimestampLocation", + beginning="beginning", + end="end", +) #: + +RenderPassTimestampLocation = Enum( + "RenderPassTimestampLocation", + beginning="beginning", + end="end", +) #: + LoadOp = Enum( "LoadOp", load="load", @@ -313,19 +365,9 @@ def __repr__(self): QueryType = Enum( "QueryType", occlusion="occlusion", - pipeline_statistics="pipeline-statistics", timestamp="timestamp", ) #: -PipelineStatisticName = Enum( - "PipelineStatisticName", - vertex_shader_invocations="vertex-shader-invocations", - clipper_invocations="clipper-invocations", - clipper_primitives_out="clipper-primitives-out", - fragment_shader_invocations="fragment-shader-invocations", - compute_shader_invocations="compute-shader-invocations", -) #: - CanvasCompositingAlphaMode = Enum( "CanvasCompositingAlphaMode", opaque="opaque", diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index 1aff6f32..0cd3e0d2 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -1,13 +1,13 @@ # Code generatation report ## Preparing -* The webgpu.idl defines 33 classes with 83 functions -* The webgpu.idl defines 5 flags, 31 enums, 54 structs +* The webgpu.idl defines 33 classes with 78 functions +* The webgpu.idl defines 5 flags, 32 enums, 57 structs * The wgpu.h defines 131 functions * The wgpu.h defines 5 flags, 46 enums, 69 structs ## Updating API * Wrote 5 flags to flags.py -* Wrote 31 enums to enums.py -* Wrote 54 structs to structs.py +* Wrote 32 enums to enums.py +* Wrote 57 structs to structs.py ### Patching API for base.py * Diffs for GPU: change request_adapter, change request_adapter_async * Diffs for GPUCanvasContext: add present @@ -16,18 +16,15 @@ * Diffs for GPUBuffer: add map_read, add map_write, add size, add usage, hide get_mapped_range, hide map_async, hide unmap * Diffs for GPUTexture: add dimension, add format, add mip_level_count, add sample_count, add size, add usage * Diffs for GPUTextureView: add size, add texture -* Diffs for GPUComputePassEncoder: hide begin_pipeline_statistics_query, hide end_pipeline_statistics_query -* Diffs for GPURenderPassEncoder: hide begin_pipeline_statistics_query, hide end_pipeline_statistics_query * Diffs for GPUQueue: add read_buffer, add read_texture, hide copy_external_image_to_texture -* Validated 33 classes, 110 methods, 35 properties +* Validated 33 classes, 105 methods, 34 properties ### Patching API for backends/rs.py * Diffs for GPUAdapter: add request_device_tracing -* Validated 33 classes, 95 methods, 0 properties +* Validated 33 classes, 94 methods, 0 properties ## Validating rs.py * Enum PredefinedColorSpace missing in wgpu.h -* Enum field FeatureName.depth-clamping missing in wgpu.h * Enum CanvasCompositingAlphaMode missing in wgpu.h -* Wrote 188 enum mappings and 47 struct-field mappings to rs_mappings.py +* Wrote 227 enum mappings and 49 struct-field mappings to rs_mappings.py * Validated 79 C function calls * Not using 57 C functions * Validated 69 C structs diff --git a/wgpu/structs.py b/wgpu/structs.py index 49541e80..a55be7b4 100644 --- a/wgpu/structs.py +++ b/wgpu/structs.py @@ -23,7 +23,7 @@ def __repr__(self): return f"<{self.__class__.__name__} {self._name}: {options}>" -# There are 54 structs +# There are 57 structs RequestAdapterOptions = Struct( "RequestAdapterOptions", @@ -164,11 +164,17 @@ def __repr__(self): bind_group_layouts="List[GPUBindGroupLayout]", ) #: +ShaderModuleCompilationHint = Struct( + "ShaderModuleCompilationHint", + layout="GPUPipelineLayout", +) #: + ShaderModuleDescriptor = Struct( "ShaderModuleDescriptor", label="str", code="str", source_map="dict", + hints="Dict[str, structs.ShaderModuleCompilationHint]", ) #: ProgrammableStage = Struct( @@ -202,7 +208,7 @@ def __repr__(self): strip_index_format="enums.IndexFormat", front_face="enums.FrontFace", cull_mode="enums.CullMode", - clamp_depth="bool", + unclipped_depth="bool", ) #: MultisampleState = Struct( @@ -292,7 +298,6 @@ def __repr__(self): CommandEncoderDescriptor = Struct( "CommandEncoderDescriptor", label="str", - measure_execution_time="bool", ) #: ImageDataLayout = Struct( @@ -324,9 +329,24 @@ def __repr__(self): origin="Union[List[int], structs.Origin2D]", ) #: +ComputePassTimestampWrite = Struct( + "ComputePassTimestampWrite", + query_set="GPUQuerySet", + query_index="int", + location="enums.ComputePassTimestampLocation", +) #: + ComputePassDescriptor = Struct( "ComputePassDescriptor", label="str", + timestamp_writes="List[structs.ComputePassTimestampWrite]", +) #: + +RenderPassTimestampWrite = Struct( + "RenderPassTimestampWrite", + query_set="GPUQuerySet", + query_index="int", + location="enums.RenderPassTimestampLocation", ) #: RenderPassDescriptor = Struct( @@ -335,6 +355,7 @@ def __repr__(self): color_attachments="List[structs.RenderPassColorAttachment]", depth_stencil_attachment="structs.RenderPassDepthStencilAttachment", occlusion_query_set="GPUQuerySet", + timestamp_writes="List[structs.RenderPassTimestampWrite]", ) #: RenderPassColorAttachment = Struct( @@ -384,7 +405,6 @@ def __repr__(self): label="str", type="enums.QueryType", count="int", - pipeline_statistics="List[enums.PipelineStatisticName]", ) #: CanvasConfiguration = Struct( From 354045a8aa401fc8f252f8d442e9624679f7ae5e Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Sun, 19 Dec 2021 22:34:47 +0100 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 893082f7..62560cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Changed: * Now targeting wgpu-native v0.11.0.1, containing many upstream fixes and improvements. * The `[[block]]` syntax in shaders has been dropped. -* Renamed `depth_clamping` -> `depth_clip_control`. +* Renamed `ProgrammableStage.clamp_depth` -> `unclipped_depth`. ### [v0.6.0] - 16-12-2021