Pass the configured view_formats through to the present texture - #254
Open
hmaarrfk wants to merge 4 commits into
Open
Pass the configured view_formats through to the present texture#254hmaarrfk wants to merge 4 commits into
hmaarrfk wants to merge 4 commits into
Conversation
`configure()` accepts `view_formats`, validates each against the context capabilities, and stores them in the config -- and then the texture is created without them, so a view in any of those formats fails and the argument silently does nothing. The case this matters for is a canvas configured with an srgb format whose contents also need to be read as raw bytes: sampling an srgb view applies the transfer function, so anything reading the frame back sees values that differ from what was written. A view in the matching non-srgb format is the supported way to ask for the unconverted bytes, and it requires the format to be declared when the texture is created. The surface-backed path already forwards these to the surface configuration; this brings the bitmap path in line.
Covers the plumbing in both directions: with a format declared the view is created, and without it the same view is rejected, so the positive assertion is testing this change rather than something the backend would have allowed anyway. Skipped when the wgpu backend does not implement create_texture(view_formats=...), which it did not before pygfx/wgpu-py#832 -- otherwise the test would fail for a reason unrelated to rendercanvas.
hmaarrfk
commented
Aug 22, 2026
Contributor
Author
There was a problem hiding this comment.
this PR could be merged immediately without these tests, and we could hold these tests until the next wgpu-py release.
hmaarrfk
marked this pull request as ready for review
August 22, 2026 21:51
Ruff's B017 rejects a blind `pytest.raises(Exception)`, and rightly so here: the negative half of the test is only evidence that the format has to be declared if it fails on the validation of that format, and not on some unrelated error in the same call. Name the error wgpu raises and match its message.
<details><summary>Claude's draft</summary> The test feature-detected `create_texture(view_formats=...)` and skipped when the backend did not implement it, which is every released wgpu: the argument raises NotImplementedError until pygfx/wgpu-py#832 ships. So CI skipped it every run, the PR looked green, and nothing about the pass-through was verified. A skipped test is not evidence. Drop the feature detection and let the test run. On a wgpu without the argument, `get_current_texture()` raises NotImplementedError and the test turns that into an explicit failure naming the version in use and the wgpu-py PR it is waiting on, rather than an opaque traceback. On a wgpu with it, the test passes, and no marker has to be removed by hand for that to happen. The failure state is the point: this PR depends on something unreleased, and red is the honest report of that until the release lands. Verified in both worlds. Against wgpu 0.32 the test fails with the message above; against a wgpu that implements the argument it passes. Removing the `view_formats=` pass-through from `WgpuContextToBitmap._get_current_texture()` while keeping the implementing wgpu also fails it (GPUValidationError on the view), so the test cannot go green without the change it covers. Resume this Claude session: ``` cd /home/mark/git/ramona/python-owl claude --resume 66360ec9-8ab8-4ae1-8f3f-e873ce8fc563 ``` </details> Claude-Session: https://claude.ai/code/session_01FvMxuoA4rU1KvqM38ypUwe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow users to configure the view_formats for the textures.
From claude:
configure()acceptsview_formatsand validates each against the context capabilities, and then_get_current_texture()creates the texture without them — so a view in any declared format fails and the argument silently does nothing. The surface-backed path already forwards them to the surface configuration; this brings the bitmap path in line, one line. Needs pygfx/wgpu-py#832 and is inert until it lands, so the test skips when the backend does not implementcreate_texture(view_formats=...).