mirror of
				https://github.com/bspeice/speice.io
				synced 2025-11-04 02:20:36 -05:00 
			
		
		
		
	Actually run the compute pass, show offset issues
This commit is contained in:
		@ -6,12 +6,12 @@ use spirv_std::spirv;
 | 
			
		||||
#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
 | 
			
		||||
#[repr(C)]
 | 
			
		||||
pub struct Viewport {
 | 
			
		||||
    pub image_size: glam::UVec2,
 | 
			
		||||
    pub viewport_offset: glam::UVec2,
 | 
			
		||||
    pub viewport_size: glam::UVec2,
 | 
			
		||||
    pub offset: glam::UVec2,
 | 
			
		||||
    pub size: glam::UVec2,
 | 
			
		||||
    pub image: glam::UVec2,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const BLOCK_SIZE: u32 = 16;
 | 
			
		||||
const BLOCK_SIZE: usize = 16;
 | 
			
		||||
const BLACK: glam::Vec4 = glam::vec4(0.0, 0.0, 0.0, 1.0);
 | 
			
		||||
const WHITE: glam::Vec4 = glam::vec4(1.0, 1.0, 1.0, 1.0);
 | 
			
		||||
 | 
			
		||||
@ -24,18 +24,16 @@ pub fn main_cs(
 | 
			
		||||
    #[spirv(uniform, descriptor_set = 0, binding = 0)] viewport: &Viewport,
 | 
			
		||||
    #[spirv(storage_buffer, descriptor_set = 0, binding = 1)] image: &mut [glam::Vec4],
 | 
			
		||||
) {
 | 
			
		||||
    let width = viewport.image_size.x as usize;
 | 
			
		||||
    let height = viewport.image_size.y as usize;
 | 
			
		||||
    let width = viewport.image.x as usize;
 | 
			
		||||
    let height = viewport.image.y as usize;
 | 
			
		||||
    for x in 0..width {
 | 
			
		||||
        let x_even = x / BLOCK_SIZE % 2 == 0;
 | 
			
		||||
        for y in 0..height {
 | 
			
		||||
            let y_even = y / BLOCK_SIZE % 2 == 0;
 | 
			
		||||
 | 
			
		||||
            let color = if x_even == y_even { BLACK } else { WHITE };
 | 
			
		||||
            let index = image_index(x, y, width);
 | 
			
		||||
            if x == 0
 | 
			
		||||
                || x == width - 1
 | 
			
		||||
                || y == 0
 | 
			
		||||
                || y == height - 1
 | 
			
		||||
            {
 | 
			
		||||
                image[index] = WHITE;
 | 
			
		||||
            }
 | 
			
		||||
            image[index] = color;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -58,10 +56,9 @@ pub fn main_fs(
 | 
			
		||||
) {
 | 
			
		||||
    let pixel_coordinate = frag_coord.xy().as_usizevec2();
 | 
			
		||||
    let (pixel_x, pixel_y) = (pixel_coordinate.x, pixel_coordinate.y);
 | 
			
		||||
    let index = image_index(pixel_x, pixel_y, viewport.viewport_size.x as usize);
 | 
			
		||||
 | 
			
		||||
    *output = if index < image.len() {
 | 
			
		||||
        image[index]
 | 
			
		||||
    *output = if pixel_x < viewport.image.x as usize && pixel_y < viewport.image.y as usize {
 | 
			
		||||
        image[image_index(pixel_x, pixel_y, viewport.image.x as usize)]
 | 
			
		||||
    } else {
 | 
			
		||||
        BLACK
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user