From e4f22054329af1b0845cee55f21d687e377f1a18 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 23 Oct 2023 16:44:36 +0200 Subject: [PATCH] A small stab at get_compilation_info --- wgpu/backends/rs.py | 31 ++++++++++++++++++++++++++++++- wgpu/base.py | 4 +++- wgpu/resources/codegen_report.md | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/wgpu/backends/rs.py b/wgpu/backends/rs.py index a2a3e23f..7d9c5d3e 100644 --- a/wgpu/backends/rs.py +++ b/wgpu/backends/rs.py @@ -1817,7 +1817,36 @@ def _destroy(self): class GPUShaderModule(base.GPUShaderModule, GPUObjectBase): def get_compilation_info(self): - return super().get_compilation_info() + # Here's a little setup to implement this method. Unfortunately, + # this is not yet implemented in wgpu-native. Another problem + # is that if there is an error in the shader source, we raise + # an exception, so the user never gets a GPUShaderModule object + # that can be used to call this method :/ So perhaps we should + # do this stuff in device.create_shader_module() and attach it + # to the exception that we raise? + + # info = None + # + # @ffi.callback("void(WGPUCompilationInfoRequestStatus, WGPUCompilationInfo*, void*)") + # def callback(status_, info_, userdata): + # if status_ == 0: + # nonlocal info + # info = info_ + # else: + # pass + # + # H: void f(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata) + # libf.wgpuShaderModuleGetCompilationInfo(self._internal, callback, ffi.NULL) + # + # H: bool f(WGPUDevice device, bool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex) + # libf.wgpuDevicePoll(self._device._internal, True, ffi.NULL) + # + # if info is None: + # raise RuntimeError("Could not obtain shader compilation info.") + # + # ... and then turn these WGPUCompilationInfoRequestStatus objects into Python objects ... + + return [] def _destroy(self): if self._internal is not None and lib is not None: diff --git a/wgpu/base.py b/wgpu/base.py index aaa2650e..028d2c28 100644 --- a/wgpu/base.py +++ b/wgpu/base.py @@ -1277,7 +1277,9 @@ class GPUShaderModule(GPUObjectBase): # IDL: Promise getCompilationInfo(); def get_compilation_info(self): """Get shader compilation info. Always returns empty list at the moment.""" - return [] + # How can this return shader errors if one cannot create a + # shader module when the shader source has errors? + raise NotImplementedError() class GPUPipelineBase: diff --git a/wgpu/resources/codegen_report.md b/wgpu/resources/codegen_report.md index 4c7666fb..71f72a30 100644 --- a/wgpu/resources/codegen_report.md +++ b/wgpu/resources/codegen_report.md @@ -28,6 +28,6 @@ * Enum CanvasAlphaMode missing in wgpu.h * Enum field DeviceLostReason.unknown missing in wgpu.h * Wrote 232 enum mappings and 47 struct-field mappings to rs_mappings.py -* Validated 86 C function calls -* Not using 116 C functions +* Validated 88 C function calls +* Not using 115 C functions * Validated 72 C structs