mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 16:25:31 +00:00
use repr(C) (#1757)
This commit is contained in:
parent
fc45a3516b
commit
aa5a97481e
@ -40,6 +40,7 @@ use winit::event::{Event, WindowEvent};
|
||||
use winit::event_loop::{ControlFlow, EventLoop};
|
||||
use winit::window::{Window, WindowBuilder};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -151,6 +151,7 @@ impl AmbientLightingSystem {
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -166,6 +166,7 @@ impl DirectionalLightingSystem {
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -179,6 +179,7 @@ impl PointLightingSystem {
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -99,6 +99,7 @@ impl TriangleDrawSystem {
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -101,6 +101,7 @@ fn main() {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -107,6 +107,7 @@ fn main() {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -56,6 +56,7 @@ use winit::window::{Window, WindowBuilder};
|
||||
|
||||
// # Vertex Types
|
||||
// `Vertex` is the vertex type that will be output from the compute shader and be input to the vertex shader.
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -45,6 +45,7 @@ use winit::window::{Window, WindowBuilder};
|
||||
// graphics pipeline, we need to define two vertex types:
|
||||
//
|
||||
// 1. `Vertex` is the vertex type that we will use to describe the triangle's geometry.
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
@ -52,6 +53,7 @@ struct Vertex {
|
||||
impl_vertex!(Vertex, position);
|
||||
|
||||
// 2. `InstanceData` is the vertex type that describes the unique data per instance.
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct InstanceData {
|
||||
position_offset: [f32; 2],
|
||||
|
@ -22,6 +22,7 @@ use vulkano::render_pass::Subpass;
|
||||
use vulkano::sampler::{Filter, MipmapMode, Sampler, SamplerAddressMode};
|
||||
|
||||
/// Vertex for textured quads
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone, Copy)]
|
||||
pub struct TexturedVertex {
|
||||
pub position: [f32; 2],
|
||||
|
@ -241,6 +241,7 @@ fn main() {
|
||||
let vs = vs::load(device.clone()).unwrap();
|
||||
let fs = fs::load(device.clone()).unwrap();
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Copy, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -130,6 +130,7 @@ fn main() {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -130,6 +130,7 @@ fn main() {
|
||||
|
||||
let image_view = ImageView::new(image.clone()).unwrap();
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -96,6 +96,7 @@ fn main() {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 3],
|
||||
|
@ -99,6 +99,7 @@ fn main() {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -44,6 +44,7 @@ use winit::event::{Event, WindowEvent};
|
||||
use winit::event_loop::{ControlFlow, EventLoop};
|
||||
use winit::window::{Window, WindowBuilder};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Copy, Clone)]
|
||||
pub struct Vertex {
|
||||
pub position: [f32; 2],
|
||||
|
@ -110,6 +110,7 @@ fn main() {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -205,6 +205,7 @@ fn main() {
|
||||
};
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
#[repr(C)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
}
|
||||
|
@ -208,6 +208,9 @@ fn main() {
|
||||
};
|
||||
|
||||
// We now create a buffer that will store the shape of our triangle.
|
||||
// We use #[repr(C)] here to force rustc to not do anything funky with our data, although for this
|
||||
// particular example, it doesn't actually change the in-memory representation.
|
||||
#[repr(C)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
struct Vertex {
|
||||
position: [f32; 2],
|
||||
|
@ -14,6 +14,12 @@
|
||||
//! between a Vulkan buffer and a regular buffer is that the content of a Vulkan buffer is
|
||||
//! accessible from the GPU.
|
||||
//!
|
||||
//! Vulkano does not perform any specific marshalling of buffer data. The representation of the buffer in
|
||||
//! memory is identical between the CPU and GPU. Because the Rust compiler is allowed to reorder struct
|
||||
//! fields at will by default when using `#[repr(Rust)]`, it is advised to mark each struct requiring
|
||||
//! imput assembly as `#[repr(C)]`. This forces Rust to follow the standard C procedure. Each element is
|
||||
//! laid out in memory in the order of declaration and aligned to a multiple of their alignment.
|
||||
//!
|
||||
//! # Various kinds of buffers
|
||||
//!
|
||||
//! The low level implementation of a buffer is [`UnsafeBuffer`](crate::buffer::sys::UnsafeBuffer).
|
||||
|
Loading…
Reference in New Issue
Block a user