diff --git a/codegen/wgpu_native_patcher.py b/codegen/wgpu_native_patcher.py index e85e9efb..a864d90e 100644 --- a/codegen/wgpu_native_patcher.py +++ b/codegen/wgpu_native_patcher.py @@ -41,7 +41,7 @@ def compare_flags(): """ idl = get_idl_parser() - hp = get_h_parser() + hp = get_h_parser() # gets both headerfiles! name_map = { "ColorWrite": "ColorWriteMask", @@ -50,7 +50,9 @@ def compare_flags(): for name, flag in idl.flags.items(): name = name_map.get(name, name) if name not in hp.flags: - print(f"Flag {name} missing in wgpu.h") + print( + f"Flag {name} missing in wgpu.h" + ) # should actually be webgpu.h/wgpu.h as this hparser here has both else: for key, val in flag.items(): key = key.title().replace("_", "") # MAP_READ -> MapRead @@ -70,6 +72,7 @@ def write_mappings(): idl = get_idl_parser() hp = get_h_parser() + # these are empty and have no use? name_map = {} name_map_i = {v: k for k, v in name_map.items()} @@ -126,6 +129,7 @@ def write_mappings(): ("BackendType", False), ("NativeFeature", True), ("PipelineStatisticName", True), + ("Dx12Compiler", False), ): pylines.append(f' "{name}":' + " {") for key, val in hp.enums[name].items(): diff --git a/examples/cube.py b/examples/cube.py index 506f1c0e..7625d5ee 100644 --- a/examples/cube.py +++ b/examples/cube.py @@ -15,13 +15,14 @@ import wgpu import numpy as np + from rendercanvas.auto import RenderCanvas, loop # %% Entrypoints (sync and async) -def setup_drawing_sync(canvas, power_preference="high-performance", limits=None): +def setup_drawing_sync(canvas, power_preference="high-performance", limits={}): """Setup to draw a rotating cube on the given canvas. The given canvas must implement WgpuCanvasInterface, but nothing more. @@ -41,7 +42,7 @@ def setup_drawing_sync(canvas, power_preference="high-performance", limits=None) ) -async def setup_drawing_async(canvas, limits=None): +async def setup_drawing_async(canvas, limits={}): """Setup to async-draw a rotating cube on the given canvas. The given canvas must implement WgpuCanvasInterface, but nothing more. @@ -454,7 +455,6 @@ async def draw_frame_async(): uniform_dtype = [("transform", "float32", (4, 4))] uniform_data = np.zeros((), dtype=uniform_dtype) - print("Available adapters on this system:") for a in wgpu.gpu.enumerate_adapters_sync(): print(a.summary) diff --git a/tests/test_wgpu_native_errors.py b/tests/test_wgpu_native_errors.py index 90447787..d3a20587 100644 --- a/tests/test_wgpu_native_errors.py +++ b/tests/test_wgpu_native_errors.py @@ -185,7 +185,7 @@ def test_validate_shader_error1(caplog): ┌─ :10:20 │ 10 │ out.position = matrics * out.position; - │ ^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [7] + │ ^^^^^^^^^^^^^^^^^^^^^^ naga::ir::Expression [7] │ = Expression [7] is invalid = Operation Multiply can't work with [4] (of type Matrix { columns: Quad, rows: Quad, scalar: Scalar { kind: Float, width: 4 } }) and [6] (of type Vector { size: Tri, scalar: Scalar { kind: Float, width: 4 } }) @@ -238,7 +238,7 @@ def test_validate_shader_error2(caplog): ┌─ :9:16 │ 9 │ return vec3(1.0, 0.0, 1.0); - │ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::Expression [8] + │ ^^^^^^^^^^^^^^^^^^^^^^^^ naga::ir::Expression [8] │ = The `return` value Some([8]) does not match the function return value diff --git a/tools/download_wgpu_native.py b/tools/download_wgpu_native.py index abb32b57..76432579 100644 --- a/tools/download_wgpu_native.py +++ b/tools/download_wgpu_native.py @@ -149,7 +149,9 @@ def main(version=None, os_string=None, arch=None, upstream=None): current_version = get_current_version() if version != current_version: - print(f"Version changed, updating {VERSION_FILE}") + print( + f"Version changed, updating {VERSION_FILE}, diff: https://github.com/{upstream}/compare/v{current_version}...v{version}" + ) filename = "commit-sha" url = f"https://github.com/{upstream}/releases/download/v{version}/{filename}" commit_sha_filename = os.path.join(tmp, filename) diff --git a/wgpu/_classes.py b/wgpu/_classes.py index 83ac8214..7ef724d6 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -92,7 +92,7 @@ class GPU: def request_adapter_sync( self, *, - feaure_level: str = "core", + feature_level: str = "core", power_preference: enums.PowerPreference = None, force_fallback_adapter: bool = False, canvas=None, @@ -105,6 +105,7 @@ def request_adapter_sync( from .backends.auto import gpu return gpu.request_adapter_sync( + feature_level=feature_level, power_preference=power_preference, force_fallback_adapter=force_fallback_adapter, canvas=canvas, @@ -115,7 +116,7 @@ def request_adapter_sync( async def request_adapter_async( self, *, - feaure_level: str = "core", + feature_level: str = "core", power_preference: enums.PowerPreference = None, force_fallback_adapter: bool = False, canvas=None, @@ -124,7 +125,7 @@ async def request_adapter_async( implementation, from which one can request a `GPUDevice`. Arguments: - feaure_level (str): The feature level "core" (default) or "compatibility". + feature_level (str): The feature level "core" (default) or "compatibility". This provides a way to opt into additional validation restrictions. power_preference (PowerPreference): "high-performance" or "low-power". force_fallback_adapter (bool): whether to use a (probably CPU-based) @@ -135,7 +136,10 @@ async def request_adapter_async( # If this method gets called, no backend has been loaded yet, let's do that now! from .backends.auto import gpu + # note, feature_level current' does nothing: # not used currently: https://gpuweb.github.io/gpuweb/#dom-gpurequestadapteroptions-featurelevel + return await gpu.request_adapter_async( + feature_level=feature_level, power_preference=power_preference, force_fallback_adapter=force_fallback_adapter, canvas=canvas, diff --git a/wgpu/backends/wgpu_native/__init__.py b/wgpu/backends/wgpu_native/__init__.py index 44b06449..499fe75f 100644 --- a/wgpu/backends/wgpu_native/__init__.py +++ b/wgpu/backends/wgpu_native/__init__.py @@ -11,8 +11,8 @@ # The wgpu-native version that we target/expect -__version__ = "24.0.3.1" -__commit_sha__ = "e305465e8f1abd2b13878274bf74bbde920096a3" +__version__ = "25.0.2.1" +__commit_sha__ = "af9074edf144efe4f1432b2e42c477429c4964c1" version_info = tuple(map(int, __version__.split("."))) # noqa: RUF048 _check_expected_version(version_info) # produces a warning on mismatch diff --git a/wgpu/backends/wgpu_native/_api.py b/wgpu/backends/wgpu_native/_api.py index b9077ca3..34338f96 100644 --- a/wgpu/backends/wgpu_native/_api.py +++ b/wgpu/backends/wgpu_native/_api.py @@ -427,7 +427,7 @@ class GPU(classes.GPU): def request_adapter_sync( self, *, - feaure_level: str = "core", + feature_level: str = "core", power_preference: enums.PowerPreference = None, force_fallback_adapter: bool = False, canvas=None, @@ -437,7 +437,7 @@ def request_adapter_sync( """ check_can_use_sync_variants() awaitable = self._request_adapter( - feaure_level=feaure_level, + feature_level=feature_level, power_preference=power_preference, force_fallback_adapter=force_fallback_adapter, canvas=canvas, @@ -448,7 +448,7 @@ def request_adapter_sync( async def request_adapter_async( self, *, - feaure_level: str = "core", + feature_level: str = "core", power_preference: enums.PowerPreference = None, force_fallback_adapter: bool = False, canvas=None, @@ -466,7 +466,7 @@ async def request_adapter_async( be left to None. If given, the object must implement ``WgpuCanvasInterface``. """ awaitable = self._request_adapter( - feaure_level=feaure_level, + feature_level=feature_level, power_preference=power_preference, force_fallback_adapter=force_fallback_adapter, canvas=canvas, @@ -474,7 +474,7 @@ async def request_adapter_async( return await awaitable def _request_adapter( - self, *, feaure_level, power_preference, force_fallback_adapter, canvas + self, *, feature_level, power_preference, force_fallback_adapter, canvas ): # Similar to https://github.com/gfx-rs/wgpu?tab=readme-ov-file#environment-variables # It seems that the environment variables are only respected in their @@ -527,7 +527,7 @@ def _request_adapter( c_feature_level = { "core": lib.WGPUFeatureLevel_Core, "compatibility": lib.WGPUFeatureLevel_Compatibility, - }[feaure_level] + }[feature_level] # H: nextInChain: WGPUChainedStruct *, featureLevel: WGPUFeatureLevel, powerPreference: WGPUPowerPreference, forceFallbackAdapter: WGPUBool/int, backendType: WGPUBackendType, compatibleSurface: WGPUSurface struct = new_struct_p( @@ -1123,10 +1123,37 @@ def _request_device( # ----- Set limits + + # the native only limits are passed in via the next-in-chain struct + if "max-push-constant-size" in required_limits or "max-non-sampler-bindings" in required_limits: + # H: chain: WGPUChainedStructOut, maxPushConstantSize: int, maxNonSamplerBindings: int + c_limits_native_chain = new_struct( + "WGPUChainedStructOut", + next=ffi.NULL, + sType=lib.WGPUSType_NativeLimits, + ) + + c_required_limits_native = new_struct_p( + "WGPUNativeLimits *", + maxPushConstantSize=required_limits.get("max-push-constant-size", self._limits["max-push-constant-size"]), + maxNonSamplerBindings=required_limits.get("max-non-sampler-bindings", self._limits["max-non-sampler-bindings"]), + chain=c_limits_native_chain, + ) + # c_required_limits_native.chain.next = ffi.NULL + # c_required_limits_native.chain.sType = lib.WGPUSType_NativeLimits + + # c_required_limits.nextInChain = ffi.addressof(c_required_limits_native, "chain") + # c_required_limits.nextInChain = ffi.cast("WGPUChainedStructOut", c_required_limits_native.chain) + # c_required_limits.nextInChain = c_required_limits_native + + chain_ptr = ffi.addressof(c_required_limits_native, "chain") + else: + chain_ptr = ffi.NULL + # H: nextInChain: WGPUChainedStructOut *, maxTextureDimension1D: int, maxTextureDimension2D: int, maxTextureDimension3D: int, maxTextureArrayLayers: int, maxBindGroups: int, maxBindGroupsPlusVertexBuffers: int, maxBindingsPerBindGroup: int, maxDynamicUniformBuffersPerPipelineLayout: int, maxDynamicStorageBuffersPerPipelineLayout: int, maxSampledTexturesPerShaderStage: int, maxSamplersPerShaderStage: int, maxStorageBuffersPerShaderStage: int, maxStorageTexturesPerShaderStage: int, maxUniformBuffersPerShaderStage: int, maxUniformBufferBindingSize: int, maxStorageBufferBindingSize: int, minUniformBufferOffsetAlignment: int, minStorageBufferOffsetAlignment: int, maxVertexBuffers: int, maxBufferSize: int, maxVertexAttributes: int, maxVertexBufferArrayStride: int, maxInterStageShaderVariables: int, maxColorAttachments: int, maxColorAttachmentBytesPerSample: int, maxComputeWorkgroupStorageSize: int, maxComputeInvocationsPerWorkgroup: int, maxComputeWorkgroupSizeX: int, maxComputeWorkgroupSizeY: int, maxComputeWorkgroupSizeZ: int, maxComputeWorkgroupsPerDimension: int c_required_limits = new_struct_p( "WGPULimits *", - # not used: nextInChain + nextInChain = chain_ptr, # not used: maxTextureDimension1D # not used: maxTextureDimension2D # not used: maxTextureDimension3D @@ -1160,6 +1187,8 @@ def _request_device( # not used: maxComputeWorkgroupsPerDimension ) + # _refs_per_struct[c_required_limits] = (c_required_limits_native, c_limits_native_chain, chain_ptr) + def canonicalize_limit_name(name): if name in self._limits: return name @@ -1183,10 +1212,12 @@ def canonicalize_limit_name(name): # setting it to {}, but the loop below goes just a little bit faster. required_limits = self._limits + for key in dir(c_required_limits): snake_key = to_snake_case(key, "-") # Skip the pointers - if "chain" in snake_key: + if snake_key in ("next-in-chain", "max-push-constant-size", "max-non-sampler-bindings"): + # Skip the chain and the native limits as they are handled in their own continue # Use the value in required_limits if it exists. Otherwise, the old value try: @@ -1195,18 +1226,7 @@ def canonicalize_limit_name(name): value = self._limits[snake_key] setattr(c_required_limits, key, value) - # the native only limits are passed in via the next-in-chain struct - # H: chain: WGPUChainedStructOut, maxPushConstantSize: int, maxNonSamplerBindings: int - c_required_limits_native = new_struct( - "WGPUNativeLimits", - maxPushConstantSize=required_limits.get("max-push-constant-size", 0), - maxNonSamplerBindings=required_limits.get("max-non-sampler-bindings", 0), - # not used: chain - ) - c_required_limits_native.chain.next = ffi.NULL - c_required_limits_native.chain.sType = lib.WGPUSType_NativeLimits - c_required_limits.nextInChain = ffi.addressof(c_required_limits_native, "chain") # ---- Set queue descriptor @@ -1238,6 +1258,7 @@ def canonicalize_limit_name(name): "void(WGPUDevice const *, WGPUDeviceLostReason, WGPUStringView, void *, void *)" ) def device_lost_callback(c_device, c_reason, c_message, userdata1, userdata2): + print("DEVICE LOST!") reason = enum_int2str["DeviceLostReason"].get(c_reason, "Unknown") msg = from_c_string_view(c_message) # This is afaik an error that cannot usually be attributed to a specific call, @@ -1266,6 +1287,8 @@ def device_lost_callback(c_device, c_reason, c_message, userdata1, userdata2): def uncaptured_error_callback( c_device, c_type, c_message, userdata1, userdata2 ): + # TODO: does this always raise an exception? retest the loop cases! + print("UNCAPTURED ERROR!") error_type = enum_int2str["ErrorType"].get(c_type, "Unknown") msg = from_c_string_view(c_message) msg = "\n".join(line.rstrip() for line in msg.splitlines()) @@ -1309,7 +1332,7 @@ def request_device_callback(status, result, c_message, userdata1, userdata2): callback_info = new_struct( "WGPURequestDeviceCallbackInfo", # not used: nextInChain - mode=lib.WGPUCallbackMode_AllowProcessEvents, + mode=lib.WGPUCallbackMode_AllowSpontaneous, callback=request_device_callback, # not used: userdata1 # not used: userdata2 @@ -1356,12 +1379,12 @@ class GPUDevice(classes.GPUDevice, GPUObjectBase): def _poll(self): # Internal function if self._internal: - # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUSubmissionIndex const * wrappedSubmissionIndex) + # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUSubmissionIndex const * submissionIndex) libf.wgpuDevicePoll(self._internal, False, ffi.NULL) def _poll_wait(self): if self._internal: - # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUSubmissionIndex const * wrappedSubmissionIndex) + # H: WGPUBool f(WGPUDevice device, WGPUBool wait, WGPUSubmissionIndex const * submissionIndex) libf.wgpuDevicePoll(self._internal, True, ffi.NULL) def create_buffer( @@ -1771,18 +1794,17 @@ def create_shader_module( value=to_c_string_view("gl_VertexIndex"), ) ) - # note, GLSL is a wgpu-native feature and still uses the older structure! # H: chain: WGPUChainedStruct, stage: WGPUShaderStage/int, code: WGPUStringView, defineCount: int, defines: WGPUShaderDefine * source_struct = new_struct_p( - "WGPUShaderModuleGLSLDescriptor *", + "WGPUShaderSourceGLSL *", + # not used: chain code=to_c_string_view(code), stage=c_stage, defineCount=len(defines), defines=new_array("WGPUShaderDefine[]", defines), - # not used: chain ) source_struct[0].chain.next = ffi.NULL - source_struct[0].chain.sType = lib.WGPUSType_ShaderModuleGLSLDescriptor + source_struct[0].chain.sType = lib.WGPUSType_ShaderSourceGLSL else: # === WGSL # H: chain: WGPUChainedStruct, code: WGPUStringView diff --git a/wgpu/backends/wgpu_native/_helpers.py b/wgpu/backends/wgpu_native/_helpers.py index 7a6d0f94..27d6c764 100644 --- a/wgpu/backends/wgpu_native/_helpers.py +++ b/wgpu/backends/wgpu_native/_helpers.py @@ -29,7 +29,6 @@ "Internal": GPUInternalError, } - if sys.platform.startswith("darwin"): from rubicon.objc.api import ObjCInstance, ObjCClass @@ -87,14 +86,21 @@ def get_memoryview_from_address(address, nbytes, format="B"): _the_instance = None -def get_wgpu_instance(): +def get_wgpu_instance(extras=None): """Get the global wgpu instance.""" # Note, we could also use wgpuInstanceRelease, # but we keep a global instance, so we don't have to. global _the_instance + if _the_instance is not None and extras is not None: + # reset the instance if extras are given to avoid not getting requested extras. + lib.wgpuInstanceRelease(_the_instance) + _the_instance = None + if _the_instance is None: # H: nextInChain: WGPUChainedStruct * struct = ffi.new("WGPUInstanceDescriptor *") + if extras is not None: + struct.nextInChain = ffi.cast("WGPUChainedStruct *", extras) _the_instance = lib.wgpuCreateInstance(struct) return _the_instance diff --git a/wgpu/backends/wgpu_native/_mappings.py b/wgpu/backends/wgpu_native/_mappings.py index 42057149..c4273beb 100644 --- a/wgpu/backends/wgpu_native/_mappings.py +++ b/wgpu/backends/wgpu_native/_mappings.py @@ -365,6 +365,11 @@ "fragment-shader-invocations": 3, "compute-shader-invocations": 4, }, + "Dx12Compiler": { + "Undefined": 0, + "Fxc": 1, + "Dxc": 2, + }, } enum_int2str = { diff --git a/wgpu/backends/wgpu_native/extras.py b/wgpu/backends/wgpu_native/extras.py index 4662460c..52fd2ad9 100644 --- a/wgpu/backends/wgpu_native/extras.py +++ b/wgpu/backends/wgpu_native/extras.py @@ -1,9 +1,20 @@ import os -from typing import List +from typing import List, Union from . import GPUCommandEncoder, GPUComputePassEncoder, GPURenderPassEncoder -from ._api import Dict, GPUBindGroupLayout, enums, logger, structs +from ._api import ( + Dict, + GPUBindGroupLayout, + enums, + logger, + structs, + new_struct_p, + to_c_string_view, + enum_str2int, +) from ...enums import Enum +from ._helpers import get_wgpu_instance +from ..._coreutils import get_library_filename # NOTE: these functions represent backend-specific extra API. @@ -172,3 +183,88 @@ def write_timestamp(encoder, query_set, query_index): encoder, (GPURenderPassEncoder, GPUComputePassEncoder, GPUCommandEncoder) ) encoder._write_timestamp(query_set, query_index) + + +def set_instance_extras( + backends=0, # default all + flags=0, + dx12_compiler="fxc", + gles3_minor_version="Atomic", + fence_behavior="Normal", + dxil_path: Union[os.PathLike, None] = None, + dxc_path: Union[os.PathLike, None] = None, + dxc_max_shader_model: float = 6.5, +): + """ + Sets the global instance with extras. Replaces any existing instance. + Args: + backends: bitflag/int, which backends to enable on the instance level. Defaults to (0b0: all). + flags: bitflag/int for debugging the instance and compiler. Defaults to (0b0: default). + dx12_compiler: enum/str, either "Fxc", "Dxc" or "Undefined". Defaults to "Fxc" same as "Undefined". Dxc requires additional library files. + gles3_minor_version: enum/int, 0, 1 or 2. Defaults to "Atomic" (handled by driver). + fence_behavior: enum/int, "Normal" or "AutoFinish". Defaults to "Normal". + dxil_path: Path to the dxil.dll file, if not provided or `None`, will try to load from wgpu/resources. + dxc_path: Path to the dxcompiler.dll file, if not provided or `None`, will try to load from wgpu/resources. + dxc_max_shader_model: float between 6.0 and 6.7, the maximum shader model to use with DXC. Defaults to 6.5. + """ + # TODO document and explain, find reference for defaults + + c_dx12_compiler = enum_str2int["Dx12Compiler"].get( + dx12_compiler.capitalize(), enum_str2int["Dx12Compiler"]["Undefined"] + ) + # https://docs.rs/wgpu/latest/wgpu/enum.Dx12Compiler.html#variant.DynamicDxc #explains the idea, will improve in the future. + # https://github.com/gfx-rs/wgpu-native/blob/v25.0.2.1/src/conv.rs#L308-L349 handles the fxc fallback, most of the time... + if ( + c_dx12_compiler == enum_str2int["Dx12Compiler"]["Dxc"] + and not (dxil_path or dxc_path) + ): # os.path.exists(dxil_path) or os.path.exists(dxc_path)): # this check errors with None as default. but we can't have empty strings. + # if dxc is specified but no paths are provided, there will be a panic about static-dxc, so maybe we check against that. + try: + dxil_path = get_library_filename("dxil.dll") + dxc_path = get_library_filename("dxcompiler.dll") + except RuntimeError as e: + # here we couldn't load the libs from wgpu/resources... so we assume the user doesn't have them. + # TODO: explain user to add DXC manually or provide a script/package it? (in the future) + logger.warning( + f"could not load .dll files for DXC from /resource: {e}.\n Please provide a path manually which can panic. Falling back to FXC" + ) + c_dx12_compiler = enum_str2int["Dx12Compiler"]["Fxc"] + + # https://docs.rs/wgpu/latest/wgpu/enum.Gles3MinorVersion.html + if gles3_minor_version[-1].isdigit(): + gles3_minor_version = ( + int(gles3_minor_version[-1]) + 1 + ) # hack as the last char easily maps to the enum. + elif isinstance(gles3_minor_version, str): + gles3_minor_version = 0 # likely means atomic + + # https://docs.rs/wgpu/latest/wgpu/enum.GlFenceBehavior.html + fence_behavior_map = { + "Normal": 0, # WGPUGLFenceBehavior_Normal + "AutoFinish": 1, # WGPUGLFenceBehavior_AutoFinish + } + fence_behavior = fence_behavior_map.get(fence_behavior, 0) + + # hack as only version 6.0..6.7 are supported and enum mapping fits. + c_max_shader_model = int((dxc_max_shader_model - 6.0) * 1.0) + + # TODO: can we codegen the native only flags? do we put them here or in a flags.py? + + # H: chain: WGPUChainedStruct, backends: WGPUInstanceBackend/int, flags: WGPUInstanceFlag/int, dx12ShaderCompiler: WGPUDx12Compiler, gles3MinorVersion: WGPUGles3MinorVersion, glFenceBehaviour: WGPUGLFenceBehaviour, dxilPath: WGPUStringView, dxcPath: WGPUStringView, dxcMaxShaderModel: WGPUDxcMaxShaderModel + c_extras = new_struct_p( + "WGPUInstanceExtras *", + # not used: chain + backends=backends, + flags=flags, + dx12ShaderCompiler=c_dx12_compiler, + gles3MinorVersion=gles3_minor_version, + glFenceBehaviour=fence_behavior, + dxilPath=to_c_string_view(dxil_path), + dxcPath=to_c_string_view(dxc_path), + dxcMaxShaderModel=c_max_shader_model, + ) + + c_extras.chain.sType = ( + 0x00030006 # lib.WGPUSType_InstanceExtras (but we don't import lib here?) + ) + get_wgpu_instance(extras=c_extras) # this sets a global diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index 6424e09a..d76ca5ba 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -3,7 +3,7 @@ * The webgpu.idl defines 37 classes with 76 functions * The webgpu.idl defines 5 flags, 34 enums, 60 structs * The wgpu.h defines 211 functions -* The wgpu.h defines 7 flags, 58 enums, 101 structs +* The wgpu.h defines 7 flags, 60 enums, 101 structs ## Updating API * Wrote 5 flags to flags.py * Wrote 34 enums to enums.py diff --git a/wgpu/resources/wgpu.h b/wgpu/resources/wgpu.h index 6cee9d15..ec12da35 100644 --- a/wgpu/resources/wgpu.h +++ b/wgpu/resources/wgpu.h @@ -8,7 +8,7 @@ typedef enum WGPUNativeSType { WGPUSType_DeviceExtras = 0x00030001, WGPUSType_NativeLimits = 0x00030002, WGPUSType_PipelineLayoutExtras = 0x00030003, - WGPUSType_ShaderModuleGLSLDescriptor = 0x00030004, + WGPUSType_ShaderSourceGLSL = 0x00030004, WGPUSType_InstanceExtras = 0x00030006, WGPUSType_BindGroupEntryExtras = 0x00030007, WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, @@ -118,14 +118,34 @@ typedef enum WGPUNativeQueryType { WGPUNativeQueryType_Force32 = 0x7FFFFFFF } WGPUNativeQueryType WGPU_ENUM_ATTRIBUTE; +typedef enum WGPUDxcMaxShaderModel { + WGPUDxcMaxShaderModel_V6_0 = 0x00000000, + WGPUDxcMaxShaderModel_V6_1 = 0x00000001, + WGPUDxcMaxShaderModel_V6_2 = 0x00000002, + WGPUDxcMaxShaderModel_V6_3 = 0x00000003, + WGPUDxcMaxShaderModel_V6_4 = 0x00000004, + WGPUDxcMaxShaderModel_V6_5 = 0x00000005, + WGPUDxcMaxShaderModel_V6_6 = 0x00000006, + WGPUDxcMaxShaderModel_V6_7 = 0x00000007, + WGPUDxcMaxShaderModel_Force32 = 0x7FFFFFFF +} WGPUDxcMaxShaderModel; + +typedef enum WGPUGLFenceBehaviour { + WGPUGLFenceBehaviour_Normal = 0x00000000, + WGPUGLFenceBehaviour_AutoFinish = 0x00000001, + WGPUGLFenceBehaviour_Force32 = 0x7FFFFFFF +} WGPUGLFenceBehaviour; + typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; WGPUInstanceBackend backends; WGPUInstanceFlag flags; WGPUDx12Compiler dx12ShaderCompiler; WGPUGles3MinorVersion gles3MinorVersion; + WGPUGLFenceBehaviour glFenceBehaviour; WGPUStringView dxilPath; WGPUStringView dxcPath; + WGPUDxcMaxShaderModel dxcMaxShaderModel; } WGPUInstanceExtras; typedef struct WGPUDeviceExtras { @@ -159,13 +179,13 @@ typedef struct WGPUShaderDefine { WGPUStringView value; } WGPUShaderDefine; -typedef struct WGPUShaderModuleGLSLDescriptor { +typedef struct WGPUShaderSourceGLSL { WGPUChainedStruct chain; WGPUShaderStage stage; WGPUStringView code; uint32_t defineCount; WGPUShaderDefine * defines; -} WGPUShaderModuleGLSLDescriptor; +} WGPUShaderSourceGLSL; typedef struct WGPUShaderModuleDescriptorSpirV { WGPUStringView label; @@ -260,7 +280,7 @@ size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUIn WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * wrappedSubmissionIndex); +WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUSubmissionIndex const * submissionIndex); WGPUShaderModule wgpuDeviceCreateShaderModuleSpirV(WGPUDevice device, WGPUShaderModuleDescriptorSpirV const * descriptor); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata);