Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `ProgrammableStage.clamp_depth` -> `unclipped_depth`.

### [v0.6.0] - 16-12-2021

Expand Down
48 changes: 28 additions & 20 deletions wgpu/backends/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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 *",
Expand All @@ -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):
Expand Down Expand Up @@ -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 *",
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
59 changes: 50 additions & 9 deletions wgpu/backends/rs_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# flake8: noqa

# There are 188 enum mappings
# There are 227 enum mappings

enummap = {
"AddressMode.clamp-to-edge": 2,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Loading