Skip to content

Commit 986342d

Browse files
committed
Clean up the borders
1 parent 1bc46af commit 986342d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

rust-gpu-toy/shaders/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ pub fn main(
3434
1.0,
3535
);
3636

37-
unsafe { output_buffer.write(global_ix.truncate(), frag_color) }
37+
// Without the int8 capability, can't use bools
38+
// A better choice might be to just enable the int8 capability
39+
if global_ix.x < config.width {
40+
if global_ix.y < config.height {
41+
unsafe { output_buffer.write(global_ix.truncate(), frag_color) }
42+
}
43+
}
3844
}
3945

4046
// A simple vert/frag shader to copy an image to the swapchain.

rust-gpu-toy/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ impl State {
334334
cpass.set_pipeline(&self.pipelines.compute_pipeline);
335335
cpass.set_push_constants(0, bytemuck::bytes_of(&config));
336336
cpass.set_bind_group(0, &self.compute_bind_group, &[]);
337-
cpass.dispatch(size.width / 16, size.height / 16, 1);
337+
// Round up to next multiple
338+
cpass.dispatch((size.width + 16 - 1) / 16, (size.height + 16 - 1) / 16, 1);
338339
}
339340
{
340341
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {

0 commit comments

Comments
 (0)