Skip to content

Commit

Permalink
A small stab at get_compilation_info
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Oct 23, 2023
1 parent 369f372 commit e4f2205
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
31 changes: 30 additions & 1 deletion wgpu/backends/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion wgpu/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,9 @@ class GPUShaderModule(GPUObjectBase):
# IDL: Promise<GPUCompilationInfo> 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:
Expand Down
4 changes: 2 additions & 2 deletions wgpu/resources/codegen_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e4f2205

Please sign in to comment.