Skip to content

Commit

Permalink
use perferred format
Browse files Browse the repository at this point in the history
  • Loading branch information
Vipitis committed Sep 28, 2024
1 parent b2ee401 commit 634b7e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion wgpu_shadertoy/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __init__(
self._input_headers = ""
# self.channels = self._attach_inputs(inputs)
self._format: wgpu.TextureFormat = (
wgpu.TextureFormat.bgra8unorm
wgpu.TextureFormat.bgra8unorm_srgb,
) # assume default?

@property
Expand Down
6 changes: 5 additions & 1 deletion wgpu_shadertoy/shadertoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def __init__(
self.title += " (incomplete)"

self._prepare_canvas()
self.image._format = self._format
self._bind_events()
# TODO: could this be part of the __init__ of each renderpass? (but we need the device)
for rpass in (self.image, *self.buffers.values()):
Expand Down Expand Up @@ -240,9 +241,12 @@ def _prepare_canvas(self):
self._present_context: wgpu.GPUCanvasContext = self._canvas.get_context()

# We use "bgra8unorm" not "bgra8unorm-srgb" here because we want to let the shader fully control the color-space.
# broken in newer versions of wgpu-py it seems... due to the minimal Vulkan capabilities...
# TODO: instead use canvas preference? ref: GPUCanvasContext.get_preferred_format()
self._format = self._present_context.get_preferred_format(adapter=self._device.adapter)

self._present_context.configure(
device=self._device, format=wgpu.TextureFormat.bgra8unorm
device=self._device, format=self._format
)

def _bind_events(self):
Expand Down

0 comments on commit 634b7e2

Please sign in to comment.