Skip to content

Commit

Permalink
srgb suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
TadaTeruki committed Aug 25, 2024
1 parent 9f7c6bb commit 9ac93af
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions graphics/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ impl State {
.first()
.copied()
.expect("No surface formats"),
)
.add_srgb_suffix();
);

let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
Expand All @@ -112,7 +111,11 @@ impl State {
.first()
.copied()
.expect("No alpha modes"),
view_formats: vec![],
view_formats: if !surface_format.is_srgb() {
vec![surface_format.add_srgb_suffix()]
} else {
vec![]
},
desired_maximum_frame_latency: 2,
};

Expand Down Expand Up @@ -209,7 +212,7 @@ impl State {
module: &shader,
entry_point: "fs_main",
targets: &[Some(wgpu::ColorTargetState {
format: config.format,
format: config.format.add_srgb_suffix(),
blend: Some(blend_state),
write_mask: wgpu::ColorWrites::ALL,
})],
Expand Down Expand Up @@ -253,7 +256,7 @@ impl State {
module: &shader,
entry_point: "fs_main",
targets: &[Some(wgpu::ColorTargetState {
format: config.format,
format: config.format.add_srgb_suffix(),
blend: Some(wgpu::BlendState::REPLACE),
write_mask: wgpu::ColorWrites::ALL,
})],
Expand Down Expand Up @@ -294,7 +297,7 @@ impl State {
module: &shader,
entry_point: "fs_main",
targets: &[Some(wgpu::ColorTargetState {
format: config.format,
format: config.format.add_srgb_suffix(),
blend: Some(blend_state),
write_mask: wgpu::ColorWrites::ALL,
})],
Expand Down Expand Up @@ -330,7 +333,7 @@ impl State {
module: &shader,
entry_point: "fs_main",
targets: &[Some(wgpu::ColorTargetState {
format: config.format,
format: config.format.add_srgb_suffix(),
blend: Some(blend_state),
write_mask: wgpu::ColorWrites::ALL,
})],
Expand Down Expand Up @@ -412,10 +415,14 @@ impl State {

#[wasm_bindgen]
pub fn render(&mut self) {

let output = self.surface.get_current_texture().unwrap();
let view = output
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
.create_view(&wgpu::TextureViewDescriptor {
format: Some(self.config.format.add_srgb_suffix()),
..Default::default()
});
let mut encoder = self
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
Expand Down

0 comments on commit 9ac93af

Please sign in to comment.