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 4375684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion graphics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ build:
mkdir -p ../view/public/resources
cp -r resources ../view/public
echo "*" > ../view/public/resources/.gitignore
wasm-pack build --target web --out-dir ../view/pkg --debug
wasm-pack build --target web --out-dir ../view/pkg
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 4375684

Please sign in to comment.