Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A small stab at get_compilation_info #389

Merged
merged 2 commits into from
Oct 24, 2023
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
31 changes: 30 additions & 1 deletion wgpu/backends/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,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 @@ -1278,7 +1278,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