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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Possible sections in each release:
* Security: in case of vulnerabilities.


### [v0.7.0] - TBD

Changed:

* Now targeting wgpu-native v0.11.0.1, containing many upstream fixes and improvements.
* The `[[block]]` syntax in shaders has been dropped.


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

Added:
Expand Down
1 change: 0 additions & 1 deletion examples/compute_noop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

shader_source = """

[[block]]
struct DataContainer {
data: [[stride(4)]] array<i32>;
};
Expand Down
1 change: 0 additions & 1 deletion examples/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@


shader_source = """
[[block]]
struct Locals {
transform: mat4x4<f32>;
};
Expand Down
4 changes: 0 additions & 4 deletions tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


simple_compute_shader = """
[[block]]
struct DataContainer { data: [[stride(4)]] array<i32>; };

[[group(0), binding(0)]]
Expand Down Expand Up @@ -120,7 +119,6 @@ def test_compute_0_1_spirv():
def test_compute_1_3():

compute_shader = """
[[block]]
struct DataContainer { data: [[stride(4)]] array<i32>; };

[[group(0), binding(0)]]
Expand Down Expand Up @@ -156,7 +154,6 @@ def test_compute_1_3():
def test_compute_indirect():

compute_shader = """
[[block]]
struct DataContainer { data: [[stride(4)]] array<i32>; };

[[group(0), binding(0)]]
Expand Down Expand Up @@ -263,7 +260,6 @@ def test_compute_indirect():

def test_compute_fails():
compute_shader = """
[[block]]
struct DataContainer { data: [[stride(4)]] array<i32>; };

[[group(0), binding(0)]]
Expand Down
28 changes: 16 additions & 12 deletions tests/test_gui_glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import sys
import time
import asyncio

import wgpu.backends.rs # noqa
from pytest import skip
Expand Down Expand Up @@ -38,7 +39,9 @@ def test_glfw_canvas_basics():
canvas = WgpuCanvas()

canvas.set_logical_size(300, 200)
glfw.poll_events()
etime = time.time() + 0.1
while time.time() < etime:
glfw.poll_events()
lsize = canvas.get_logical_size()
assert isinstance(lsize, tuple) and len(lsize) == 2
assert isinstance(lsize[0], float) and isinstance(lsize[1], float)
Expand Down Expand Up @@ -76,7 +79,9 @@ def test_glfw_canvas_render():
import glfw
from wgpu.gui.glfw import update_glfw_canvasses, WgpuCanvas

canvas = WgpuCanvas()
loop = asyncio.get_event_loop()

canvas = WgpuCanvas(max_fps=9999)

# wgpu.utils.get_default_device()
adapter = wgpu.request_adapter(canvas=canvas, power_preference="high-performance")
Expand All @@ -93,30 +98,29 @@ def draw_frame2():
canvas.request_draw(draw_frame2)

# Give it a few rounds to start up
for i in range(5):
glfw.poll_events()
update_glfw_canvasses()
async def miniloop():
for i in range(10):
glfw.poll_events()
update_glfw_canvasses()
await asyncio.sleep(0.01)

loop.run_until_complete(miniloop())
# There should have been exactly one draw now
assert frame_counter == 1

# Ask for a lot of draws
for i in range(5):
canvas.request_draw()
# Process evens for a while
for i in range(5):
glfw.poll_events()
update_glfw_canvasses()
loop.run_until_complete(miniloop())
# We should have had just one draw
assert frame_counter == 2

# Change the canvase size
canvas.set_logical_size(300, 200)
canvas.set_logical_size(400, 300)
for i in range(5):
time.sleep(0.01)
glfw.poll_events()
update_glfw_canvasses()
# We should have had just one draw
loop.run_until_complete(miniloop())
assert frame_counter == 3

# canvas.close()
Expand Down
1 change: 0 additions & 1 deletion tests/test_rs_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def test_tuple_from_tuple_or_dict():


compute_shader_wgsl = """
[[block]]
struct ArrayContainer { data: [[stride(4)]] array<i32>; };

[[group(0), binding(0)]]
Expand Down
21 changes: 13 additions & 8 deletions wgpu/backends/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
apidiff = ApiDiff()

# The wgpu-native version that we target/expect
__version__ = "0.10.4.1"
__commit_sha__ = "b4dd62d1781c923ae0b52195fb9e710a7fc6b177"
__version__ = "0.11.0.1"
__commit_sha__ = "9d962ef667ef6006cca7bac7489d5bf303a2a244"
version_info = tuple(map(int, __version__.split(".")))
check_expected_version(version_info) # produces a warning on mismatch

Expand Down Expand Up @@ -445,10 +445,10 @@ def _request_device(self, label, features, required_limits, trace_path):
# H: chain: WGPUChainedStruct, nativeFeatures: WGPUNativeFeature, label: char*, tracePath: char*
extras = new_struct_p(
"WGPUDeviceExtras *",
label=to_c_label(label),
tracePath=c_trace_path,
nativeFeatures=lib.WGPUNativeFeature_TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
# not used: chain
# not used: label
)
extras.chain.sType = lib.WGPUSType_DeviceExtras

Expand All @@ -464,9 +464,10 @@ def _request_device(self, label, features, required_limits, trace_path):
for key, val in required_limits.items():
setattr(c_limits, to_camel_case(key), val)

# H: nextInChain: WGPUChainedStruct *, requiredFeaturesCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *
# H: nextInChain: WGPUChainedStruct *, label: char *, requiredFeaturesCount: int, requiredFeatures: WGPUFeatureName *, requiredLimits: WGPURequiredLimits *
struct = new_struct_p(
"WGPUDeviceDescriptor *",
label=to_c_label(label),
nextInChain=ffi.cast("WGPUChainedStruct * ", extras),
requiredFeaturesCount=0,
requiredFeatures=ffi.new("WGPUFeatureName []", []),
Expand Down Expand Up @@ -848,10 +849,10 @@ def create_shader_module(self, *, label="", code: str, source_map: dict = None):

if isinstance(code, str):
# WGSL
# H: chain: WGPUChainedStruct, source: char *
# H: chain: WGPUChainedStruct, code: char *
source_struct = new_struct_p(
"WGPUShaderModuleWGSLDescriptor *",
source=ffi.new("char []", code.encode()),
code=ffi.new("char []", code.encode()),
# not used: chain
)
source_struct[0].chain.next = ffi.NULL
Expand Down Expand Up @@ -1422,11 +1423,13 @@ def _destroy(self):

class GPUCommandEncoder(base.GPUCommandEncoder, GPUObjectBase):
def begin_compute_pass(self, *, label=""):
# H: nextInChain: WGPUChainedStruct *, label: char *
# H: nextInChain: WGPUChainedStruct *, label: char *, timestampWriteCount: int, timestampWrites: WGPUComputePassTimestampWrite *
struct = new_struct_p(
"WGPUComputePassDescriptor *",
label=to_c_label(label),
# not used: nextInChain
# not used: timestampWriteCount
# not used: timestampWrites
)
# H: WGPUComputePassEncoder f(WGPUCommandEncoder commandEncoder, WGPUComputePassDescriptor const * descriptor)
raw_pass = lib.wgpuCommandEncoderBeginComputePass(self._internal, struct)
Expand Down Expand Up @@ -1508,7 +1511,7 @@ def begin_render_pass(
),
)

# H: nextInChain: WGPUChainedStruct *, label: char *, colorAttachmentCount: int, colorAttachments: WGPURenderPassColorAttachment *, depthStencilAttachment: WGPURenderPassDepthStencilAttachment *, occlusionQuerySet: WGPUQuerySet
# H: nextInChain: WGPUChainedStruct *, label: char *, colorAttachmentCount: int, colorAttachments: WGPURenderPassColorAttachment *, depthStencilAttachment: WGPURenderPassDepthStencilAttachment *, occlusionQuerySet: WGPUQuerySet, timestampWriteCount: int, timestampWrites: WGPURenderPassTimestampWrite *
struct = new_struct_p(
"WGPURenderPassDescriptor *",
label=to_c_label(label),
Expand All @@ -1517,6 +1520,8 @@ def begin_render_pass(
depthStencilAttachment=c_depth_stencil_attachment,
# not used: occlusionQuerySet
# not used: nextInChain
# not used: timestampWriteCount
# not used: timestampWrites
)

# H: WGPURenderPassEncoder f(WGPUCommandEncoder commandEncoder, WGPURenderPassDescriptor const * descriptor)
Expand Down
39 changes: 20 additions & 19 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 187 enum mappings
# There are 188 enum mappings

enummap = {
"AddressMode.clamp-to-edge": 2,
Expand Down Expand Up @@ -48,7 +48,6 @@
"DeviceLostReason.destroyed": 1,
"ErrorFilter.out-of-memory": 2,
"ErrorFilter.validation": 1,
"FeatureName.depth-clamping": 1,
"FeatureName.depth24unorm-stencil8": 2,
"FeatureName.depth32float-stencil8": 3,
"FeatureName.pipeline-statistics-query": 5,
Expand All @@ -66,8 +65,8 @@
"PipelineStatisticName.compute-shader-invocations": 4,
"PipelineStatisticName.fragment-shader-invocations": 3,
"PipelineStatisticName.vertex-shader-invocations": 0,
"PowerPreference.high-performance": 1,
"PowerPreference.low-power": 0,
"PowerPreference.high-performance": 2,
"PowerPreference.low-power": 1,
"PrimitiveTopology.line-list": 1,
"PrimitiveTopology.line-strip": 2,
"PrimitiveTopology.point-list": 0,
Expand Down Expand Up @@ -96,26 +95,28 @@
"TextureDimension.1d": 0,
"TextureDimension.2d": 1,
"TextureDimension.3d": 2,
"TextureFormat.bc1-rgba-unorm": 42,
"TextureFormat.bc1-rgba-unorm-srgb": 43,
"TextureFormat.bc2-rgba-unorm": 44,
"TextureFormat.bc2-rgba-unorm-srgb": 45,
"TextureFormat.bc3-rgba-unorm": 46,
"TextureFormat.bc3-rgba-unorm-srgb": 47,
"TextureFormat.bc4-r-snorm": 49,
"TextureFormat.bc4-r-unorm": 48,
"TextureFormat.bc5-rg-snorm": 51,
"TextureFormat.bc5-rg-unorm": 50,
"TextureFormat.bc6h-rgb-float": 53,
"TextureFormat.bc6h-rgb-ufloat": 52,
"TextureFormat.bc7-rgba-unorm": 54,
"TextureFormat.bc7-rgba-unorm-srgb": 55,
"TextureFormat.bc1-rgba-unorm": 44,
"TextureFormat.bc1-rgba-unorm-srgb": 45,
"TextureFormat.bc2-rgba-unorm": 46,
"TextureFormat.bc2-rgba-unorm-srgb": 47,
"TextureFormat.bc3-rgba-unorm": 48,
"TextureFormat.bc3-rgba-unorm-srgb": 49,
"TextureFormat.bc4-r-snorm": 51,
"TextureFormat.bc4-r-unorm": 50,
"TextureFormat.bc5-rg-snorm": 53,
"TextureFormat.bc5-rg-unorm": 52,
"TextureFormat.bc6h-rgb-float": 55,
"TextureFormat.bc6h-rgb-ufloat": 54,
"TextureFormat.bc7-rgba-unorm": 56,
"TextureFormat.bc7-rgba-unorm-srgb": 57,
"TextureFormat.bgra8unorm": 23,
"TextureFormat.bgra8unorm-srgb": 24,
"TextureFormat.depth16unorm": 38,
"TextureFormat.depth24plus": 39,
"TextureFormat.depth24plus-stencil8": 40,
"TextureFormat.depth32float": 41,
"TextureFormat.depth24unorm-stencil8": 41,
"TextureFormat.depth32float": 42,
"TextureFormat.depth32float-stencil8": 43,
"TextureFormat.r16float": 7,
"TextureFormat.r16sint": 6,
"TextureFormat.r16uint": 5,
Expand Down
11 changes: 5 additions & 6 deletions wgpu/resources/codegen_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
## Preparing
* The webgpu.idl defines 33 classes with 83 functions
* The webgpu.idl defines 5 flags, 31 enums, 54 structs
* The wgpu.h defines 128 functions
* The wgpu.h defines 5 flags, 43 enums, 67 structs
* The wgpu.h defines 131 functions
* The wgpu.h defines 5 flags, 46 enums, 69 structs
## Updating API
* Wrote 5 flags to flags.py
* Wrote 31 enums to enums.py
Expand All @@ -25,10 +25,9 @@
* Validated 33 classes, 95 methods, 0 properties
## Validating rs.py
* Enum PredefinedColorSpace missing in wgpu.h
* Enum field TextureFormat.depth24unorm-stencil8 missing in wgpu.h
* Enum field TextureFormat.depth32float-stencil8 missing in wgpu.h
* Enum field FeatureName.depth-clamping missing in wgpu.h
* Enum CanvasCompositingAlphaMode missing in wgpu.h
* Wrote 187 enum mappings and 47 struct-field mappings to rs_mappings.py
* Wrote 188 enum mappings and 47 struct-field mappings to rs_mappings.py
* Validated 79 C function calls
* Not using 54 C functions
* Not using 57 C functions
* Validated 69 C structs
Loading