Skip to content

Improve HDR support #75

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

Merged
merged 2 commits into from
Apr 9, 2025
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 rendercanvas/offscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _rc_gui_poll(self):
def _rc_get_present_methods(self):
return {
"bitmap": {
"formats": ["rgba-u8"],
"formats": ["rgba-u8", "rgba-f16", "rgba-f32", "rgba-u16"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

}
}

Expand Down
19 changes: 13 additions & 6 deletions rendercanvas/utils/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# %% Entrypoints (sync and async)


def setup_drawing_sync(canvas, power_preference="high-performance", limits=None):
def setup_drawing_sync(
canvas, power_preference="high-performance", limits=None, format=None
):
"""Setup to draw a rotating cube on the given canvas.

The given canvas must implement WgpuCanvasInterface, but nothing more.
Expand All @@ -23,7 +25,9 @@ def setup_drawing_sync(canvas, power_preference="high-performance", limits=None)
device = adapter.request_device_sync(required_limits=limits)

pipeline_layout, uniform_buffer, bind_groups = create_pipeline_layout(device)
pipeline_kwargs = get_render_pipeline_kwargs(canvas, device, pipeline_layout)
pipeline_kwargs = get_render_pipeline_kwargs(
canvas, device, pipeline_layout, format
)

render_pipeline = device.create_render_pipeline(**pipeline_kwargs)

Expand All @@ -32,7 +36,7 @@ def setup_drawing_sync(canvas, power_preference="high-performance", limits=None)
)


async def setup_drawing_async(canvas, limits=None):
async def setup_drawing_async(canvas, limits=None, format=None):
"""Setup to async-draw a rotating cube on the given canvas.

The given canvas must implement WgpuCanvasInterface, but nothing more.
Expand All @@ -43,7 +47,9 @@ async def setup_drawing_async(canvas, limits=None):
device = await adapter.request_device_async(required_limits=limits)

pipeline_layout, uniform_buffer, bind_groups = create_pipeline_layout(device)
pipeline_kwargs = get_render_pipeline_kwargs(canvas, device, pipeline_layout)
pipeline_kwargs = get_render_pipeline_kwargs(
canvas, device, pipeline_layout, format
)

render_pipeline = await device.create_render_pipeline_async(**pipeline_kwargs)

Expand All @@ -55,9 +61,10 @@ async def setup_drawing_async(canvas, limits=None):
# %% Functions to create wgpu objects


def get_render_pipeline_kwargs(canvas, device, pipeline_layout):
def get_render_pipeline_kwargs(canvas, device, pipeline_layout, render_texture_format):
context = canvas.get_context("wgpu")
render_texture_format = context.get_preferred_format(device.adapter)
if render_texture_format is None:
render_texture_format = context.get_preferred_format(device.adapter)
context.configure(device=device, format=render_texture_format)

shader = device.create_shader_module(code=shader_source)
Expand Down