fixed 0,1 coord issue. Going to test multiple vertex buffers now

master
mitchellhansen 5 years ago
parent 9043c2cd3c
commit 5f2092ef21

@ -36,30 +36,30 @@ void main() {
uint idx = get_idx(0,0); uint idx = get_idx(0,0);
ivec4 p = separate(read_buffer.buf[get_idx(0 , 0)]); ivec4 p = separate(read_buffer.buf[get_idx(0 , 0)]);
// ivec4 p0 = separate(read_buffer.buf[get_idx(0 , 1)]); ivec4 p0 = separate(read_buffer.buf[get_idx(0 , 1)]);
// ivec4 p1 = separate(read_buffer.buf[get_idx(0 ,-1)]); ivec4 p1 = separate(read_buffer.buf[get_idx(0 ,-1)]);
// ivec4 p2 = separate(read_buffer.buf[get_idx(1 , 1)]); ivec4 p2 = separate(read_buffer.buf[get_idx(1 , 1)]);
// ivec4 p3 = separate(read_buffer.buf[get_idx(-1,-1)]); ivec4 p3 = separate(read_buffer.buf[get_idx(-1,-1)]);
// ivec4 p4 = separate(read_buffer.buf[get_idx(1 , 0)]); ivec4 p4 = separate(read_buffer.buf[get_idx(1 , 0)]);
// ivec4 p5 = separate(read_buffer.buf[get_idx(-1, 0)]); ivec4 p5 = separate(read_buffer.buf[get_idx(-1, 0)]);
// ivec4 p6 = separate(read_buffer.buf[get_idx(1 ,-1)]); ivec4 p6 = separate(read_buffer.buf[get_idx(1 ,-1)]);
// ivec4 p7 = separate(read_buffer.buf[get_idx(-1, 1)]); ivec4 p7 = separate(read_buffer.buf[get_idx(-1, 1)]);
//
// ivec3 d0 = abs(p0.xyz - p1.xyz); ivec3 d0 = abs(p0.xyz - p1.xyz);
// ivec3 d1 = abs(p2.xyz - p3.xyz); ivec3 d1 = abs(p2.xyz - p3.xyz);
// ivec3 d2 = abs(p4.xyz - p5.xyz); ivec3 d2 = abs(p4.xyz - p5.xyz);
// ivec3 d3 = abs(p6.xyz - p7.xyz); ivec3 d3 = abs(p6.xyz - p7.xyz);
//
// ivec3 m = max(max(max(d0, d1), d2), d3); ivec3 m = max(max(max(d0, d1), d2), d3);
//
// if ((m.x + m.y + m.z) > 200){ if ((m.x + m.y + m.z) > 200){
// p.x = 0; p.x = 0;
// p.y = 0; p.y = 0;
// p.z = 255; p.z = p.z * 2;
// } }
// else { else {
// //p.w = 125; //p.w = 125;
// } }
write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x000000FF) ) | (p.x); write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x000000FF) ) | (p.x);
write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x0000FF00) ) | (p.y << 8); write_buffer.buf[idx] = (write_buffer.buf[idx] & (~0x0000FF00) ) | (p.y << 8);

@ -396,7 +396,8 @@ impl CanvasState {
self.image_vertex_buffer.insert( self.image_vertex_buffer.insert(
k.clone(), k.clone(),
ImmutableBuffer::from_iter( ImmutableBuffer::from_iter(
v.first().unwrap().iter().cloned(), v.iter().fold(Vec::new(), |mut acc, x| [acc.as_slice(), x.as_slice()].concat()).iter(),
//v.first().unwrap().iter().cloned(),
BufferUsage::vertex_buffer(), BufferUsage::vertex_buffer(),
self.queue.clone(), self.queue.clone(),
).unwrap().0, ).unwrap().0,

@ -154,7 +154,7 @@ impl CompuState {
let size = input_buffer.get_size(); let size = input_buffer.get_size();
command_buffer = command_buffer command_buffer = command_buffer
.dispatch([size.0/8, size.1/8,1], pipeline, descriptor_set, ()).unwrap() // .dispatch([size.0/8, size.1/8,1], pipeline, descriptor_set, ()).unwrap()
.copy_buffer( .copy_buffer(
input_buffer.get_output_buffer(), input_buffer.get_output_buffer(),
output_buffer.get_input_buffer()).unwrap(); output_buffer.get_input_buffer()).unwrap();

@ -99,19 +99,24 @@ pub fn main() {
let sprite = Sprite::new_with_color((0., 0.), (0.1, 0.1), (1., 0., 0., 1.)); let sprite = Sprite::new_with_color((0., 0.), (0.1, 0.1), (1., 0., 0., 1.));
let sprite2 = Sprite::new_with_color((-0.3, -0.5), (0.1, 0.1), (0., 1., 0., 1.)); let sprite2 = Sprite::new_with_color((-0.3, -0.5), (0.1, 0.1), (0., 1., 0., 1.));
let compu_sprite1 = CompuSprite::new((-1., -0.5), (1.0, 1.0), (400.0, 400.0), let image_data = load_raw(String::from("funky-bird.jpg"));
let image_dimensions_f = ((image_data.1).0 as f32, (image_data.1).1 as f32);
let image_dimensions_u = image_data.1;
let compu_sprite1 = CompuSprite::new((-1., -0.5), (1.0, 1.0), image_dimensions_f,
// This swap image needs to match the size of the compute // This swap image needs to match the size of the compute
processor.new_swap_image((400, 400))); processor.new_swap_image(image_dimensions_u));
let image_data = load_raw(String::from("test2.png"));
let compute_buffer = processor.new_compute_buffer(image_data.0, image_data.1, 4); let compute_buffer = processor.new_compute_buffer(image_data.0, image_data.1, 4);
let compute_kernel = processor.get_kernel_handle(String::from("simple-edge.compute")) let compute_kernel = processor.get_kernel_handle(String::from("simple-edge.compute"))
.expect("Can't find that kernel"); .expect("Can't find that kernel");
let handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap(); let funky_handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
let sfml_handle = processor.get_texture_handle(String::from("funky-bird.jpg")).unwrap();
let sprite3 = Sprite::new_with_texture((0.0, -0.5), (0.5, 0.5), funky_handle.clone());
let sprite4 = Sprite::new_with_texture((0.3, 0.5), (0.9, 0.9), sfml_handle.clone());
let sprite3 = Sprite::new_with_texture((0.3, 0.5), (0.5, 0.5), handle.clone());
drop(q2); drop(q2);
drop(q1); drop(q1);
@ -120,6 +125,9 @@ pub fn main() {
let mut exit = false; let mut exit = false;
let mut count = 0;
while let Some(p) = window.get_position() { while let Some(p) = window.get_position() {
elapsed_time = timer.elap_time(); elapsed_time = timer.elap_time();
delta_time = elapsed_time - current_time; delta_time = elapsed_time - current_time;
@ -168,9 +176,16 @@ pub fn main() {
compu_frame.add(compute_buffer.clone(), compute_kernel.clone()); compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1); compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
if elapsed_time > (count) as f32 {
count += 1;
compu_frame.add_chained(compute_buffer.clone(), compute_buffer.clone(), compute_kernel.clone());
}
let mut canvas = CanvasFrame::new(); let mut canvas = CanvasFrame::new();
canvas.draw(&sprite); canvas.draw(&sprite);
canvas.draw(&sprite2); canvas.draw(&sprite2);
canvas.draw(&sprite4);
canvas.draw(&sprite3); canvas.draw(&sprite3);
canvas.draw(&compu_sprite1); canvas.draw(&compu_sprite1);

@ -40,12 +40,12 @@ impl Sprite {
position: position, position: position,
ti_position: [ ti_position: [
(-1.0, -1.0), // top left (-0.0, -0.0), // top left
(-1.0, 1.0), // bottom left (-0.0, 1.0), // bottom left
( 1.0, 1.0), // bottom right ( 1.0, 1.0), // bottom right
(-1.0, -1.0), // top left (-0.0, -0.0), // top left
( 1.0, 1.0), // bottom right ( 1.0, 1.0), // bottom right
( 1.0, -1.0), // top right ( 1.0, -0.0), // top right
], ],
size: size, size: size,
color: color, color: color,
@ -69,15 +69,15 @@ impl Sprite {
], ],
position: position, position: position,
ti_position: [ ti_position: [
(-1.0, -1.0), // top left (-0.0, -0.0), // top left
(-1.0, 1.0), // bottom left (-0.0, 1.0), // bottom left
( 1.0, 1.0), // bottom right ( 1.0, 1.0), // bottom right
(-1.0, -1.0), // top left (-0.0, -0.0), // top left
( 1.0, 1.0), // bottom right ( 1.0, 1.0), // bottom right
( 1.0, -1.0), // top right ( 1.0, -0.0), // top right
], ],
size: size, size: size,
color: (0.0, 0.0, 0.0, 0.0), color: (1.0, 0.0, 0.0, 1.0),
textured: true, textured: true,
texture_handle: Some(texture_handle.clone()) texture_handle: Some(texture_handle.clone())
} }

@ -145,6 +145,7 @@ impl<'a> VkProcessor<'a> {
self.canvas.load_texture(String::from("button.png")); self.canvas.load_texture(String::from("button.png"));
self.canvas.load_texture(String::from("background.jpg")); self.canvas.load_texture(String::from("background.jpg"));
self.canvas.load_texture(String::from("test2.png")); self.canvas.load_texture(String::from("test2.png"));
self.canvas.load_texture(String::from("sfml.png"));
} }
/// A hardcoded list of kernels which can be preloaded from this function /// A hardcoded list of kernels which can be preloaded from this function

Loading…
Cancel
Save