mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-31 10:17:21 +00:00
WebGPU: Switch from rgba8unorm
to bgra8unorm
to support MacOS (#1306)
* WebGPU: Switch from `rgba8unorm` to `bgra8unorm` to support MacOS This is a known issue in the Dawn bug database: https://bugs.chromium.org/p/chromium/issues/detail?id=1298618 Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com> * Undo the modification to `shader.wgsl` Apparently I didn't need to modify the order of the channels in the shader. Signed-off-by: Ică Alexandru-Gabriel <alexandru@seyhanlee.com>
This commit is contained in:
parent
f76b850b9c
commit
a5f890289b
1 changed files with 5 additions and 5 deletions
|
@ -158,7 +158,7 @@ impl gpu_executor::GpuExecutor for WgpuExecutor {
|
||||||
};
|
};
|
||||||
let format = match T::format() {
|
let format = match T::format() {
|
||||||
TextureBufferType::Rgba32Float => wgpu::TextureFormat::Rgba32Float,
|
TextureBufferType::Rgba32Float => wgpu::TextureFormat::Rgba32Float,
|
||||||
TextureBufferType::Rgba8Srgb => wgpu::TextureFormat::Rgba8UnormSrgb,
|
TextureBufferType::Rgba8Srgb => wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||||
};
|
};
|
||||||
|
|
||||||
let buffer = self.context.device.create_texture_with_data(
|
let buffer = self.context.device.create_texture_with_data(
|
||||||
|
@ -267,7 +267,7 @@ impl gpu_executor::GpuExecutor for WgpuExecutor {
|
||||||
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
let texture_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
let output = canvas.as_ref().surface.get_current_texture()?;
|
let output = canvas.as_ref().surface.get_current_texture()?;
|
||||||
let view = output.texture.create_view(&wgpu::TextureViewDescriptor {
|
let view = output.texture.create_view(&wgpu::TextureViewDescriptor {
|
||||||
format: Some(wgpu::TextureFormat::Rgba8Unorm),
|
format: Some(wgpu::TextureFormat::Bgra8Unorm),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let output_texture_bind_group = self.context.device.create_bind_group(&wgpu::BindGroupDescriptor {
|
let output_texture_bind_group = self.context.device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
|
@ -377,7 +377,7 @@ impl gpu_executor::GpuExecutor for WgpuExecutor {
|
||||||
let surface = self.context.instance.create_surface_from_canvas(canvas.surface)?;
|
let surface = self.context.instance.create_surface_from_canvas(canvas.surface)?;
|
||||||
|
|
||||||
let surface_caps = surface.get_capabilities(&self.context.adapter);
|
let surface_caps = surface.get_capabilities(&self.context.adapter);
|
||||||
let surface_format = wgpu::TextureFormat::Rgba8Unorm;
|
let surface_format = wgpu::TextureFormat::Bgra8Unorm;
|
||||||
let config = wgpu::SurfaceConfiguration {
|
let config = wgpu::SurfaceConfiguration {
|
||||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
format: surface_format,
|
format: surface_format,
|
||||||
|
@ -385,7 +385,7 @@ impl gpu_executor::GpuExecutor for WgpuExecutor {
|
||||||
height: 1080,
|
height: 1080,
|
||||||
present_mode: surface_caps.present_modes[0],
|
present_mode: surface_caps.present_modes[0],
|
||||||
alpha_mode: wgpu::CompositeAlphaMode::PreMultiplied,
|
alpha_mode: wgpu::CompositeAlphaMode::PreMultiplied,
|
||||||
view_formats: vec![wgpu::TextureFormat::Rgba8UnormSrgb],
|
view_formats: vec![wgpu::TextureFormat::Bgra8UnormSrgb],
|
||||||
};
|
};
|
||||||
surface.configure(&self.context.device, &config);
|
surface.configure(&self.context.device, &config);
|
||||||
Ok(SurfaceHandle {
|
Ok(SurfaceHandle {
|
||||||
|
@ -460,7 +460,7 @@ impl WgpuExecutor {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Bgra8Unorm,
|
||||||
blend: Some(wgpu::BlendState {
|
blend: Some(wgpu::BlendState {
|
||||||
color: wgpu::BlendComponent::REPLACE,
|
color: wgpu::BlendComponent::REPLACE,
|
||||||
alpha: wgpu::BlendComponent::REPLACE,
|
alpha: wgpu::BlendComponent::REPLACE,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue