[oden] Correct circle layout to fix colors
This commit is contained in:
parent
106db89e9b
commit
2322493efd
2 changed files with 24 additions and 19 deletions
|
|
@ -8,11 +8,11 @@ struct VertexInput {
|
|||
};
|
||||
|
||||
struct InstanceInput {
|
||||
@location(4) center: vec2<f32>,
|
||||
@location(5) radius: f32,
|
||||
@location(6) stroke_width: f32,
|
||||
@location(7) stroke_color: vec4<f32>,
|
||||
@location(8) fill_color: vec4<f32>,
|
||||
@location(5) center: vec2<f32>,
|
||||
@location(6) radius: f32,
|
||||
@location(7) stroke_width: f32,
|
||||
@location(8) stroke_color: vec4<f32>,
|
||||
@location(9) fill_color: vec4<f32>,
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
|
|
|
|||
33
src/lib.rs
33
src/lib.rs
|
|
@ -26,7 +26,7 @@ struct Vertex {
|
|||
impl Vertex {
|
||||
fn desc() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
array_stride: std::mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &[
|
||||
wgpu::VertexAttribute {
|
||||
|
|
@ -57,7 +57,7 @@ pub struct SpriteInstance {
|
|||
impl SpriteInstance {
|
||||
fn desc() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<SpriteInstance>() as wgpu::BufferAddress,
|
||||
array_stride: std::mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Instance,
|
||||
attributes: &[
|
||||
wgpu::VertexAttribute {
|
||||
|
|
@ -98,40 +98,45 @@ pub struct CircleInstance {
|
|||
impl CircleInstance {
|
||||
fn desc() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
array_stride: std::mem::size_of::<SpriteInstance>() as wgpu::BufferAddress,
|
||||
array_stride: std::mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::VertexStepMode::Instance,
|
||||
attributes: &[
|
||||
wgpu::VertexAttribute {
|
||||
// center
|
||||
offset: 0,
|
||||
shader_location: 4,
|
||||
shader_location: 5,
|
||||
format: wgpu::VertexFormat::Float32x2,
|
||||
},
|
||||
wgpu::VertexAttribute {
|
||||
// radius
|
||||
offset: std::mem::size_of::<[f32; 2]>() as wgpu::BufferAddress,
|
||||
shader_location: 5,
|
||||
format: wgpu::VertexFormat::Float32,
|
||||
},
|
||||
wgpu::VertexAttribute {
|
||||
offset: (std::mem::size_of::<[f32; 2]>() + std::mem::size_of::<f32>())
|
||||
as wgpu::BufferAddress,
|
||||
shader_location: 6,
|
||||
format: wgpu::VertexFormat::Float32,
|
||||
},
|
||||
wgpu::VertexAttribute {
|
||||
// stroke_width
|
||||
offset: (std::mem::size_of::<[f32; 2]>() + std::mem::size_of::<f32>())
|
||||
as wgpu::BufferAddress,
|
||||
shader_location: 7,
|
||||
format: wgpu::VertexFormat::Float32,
|
||||
},
|
||||
wgpu::VertexAttribute {
|
||||
// stroke_color
|
||||
offset: (std::mem::size_of::<[f32; 2]>()
|
||||
+ std::mem::size_of::<f32>()
|
||||
+ std::mem::size_of::<f32>())
|
||||
as wgpu::BufferAddress,
|
||||
shader_location: 7,
|
||||
shader_location: 8,
|
||||
format: wgpu::VertexFormat::Float32x4,
|
||||
},
|
||||
wgpu::VertexAttribute {
|
||||
// fill_color
|
||||
offset: (std::mem::size_of::<[f32; 2]>()
|
||||
+ std::mem::size_of::<f32>()
|
||||
+ std::mem::size_of::<f32>()
|
||||
+ std::mem::size_of::<[f32; 4]>())
|
||||
as wgpu::BufferAddress,
|
||||
shader_location: 8,
|
||||
shader_location: 9,
|
||||
format: wgpu::VertexFormat::Float32x4,
|
||||
},
|
||||
],
|
||||
|
|
@ -180,7 +185,7 @@ impl WindowAndDevice {
|
|||
// The instance is a handle to our GPU
|
||||
// Backends::all => Vulkan + Metal + DX12 + Browser WebGPU
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::all(),
|
||||
backends: wgpu::Backends::all() & !wgpu::Backends::VULKAN,
|
||||
dx12_shader_compiler: Default::default(),
|
||||
});
|
||||
|
||||
|
|
@ -489,7 +494,7 @@ impl State {
|
|||
|
||||
let circle_pipeline_layout =
|
||||
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||
label: Some("Sprite Pipeline Layout"),
|
||||
label: Some("Circle Pipeline Layout"),
|
||||
bind_group_layouts: &[&screen_uniform_bind_group_layout],
|
||||
push_constant_ranges: &[],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue