mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix the buffer slicing in the submodel
Fixes the void figures
This commit is contained in:
parent
732e0fa483
commit
4b651d535f
@ -51,7 +51,9 @@ pub use self::{
|
||||
};
|
||||
pub use wgpu::{AddressMode, FilterMode};
|
||||
|
||||
pub trait Vertex = Clone + bytemuck::Pod;
|
||||
pub trait Vertex: Clone + bytemuck::Pod {
|
||||
const STRIDE: wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
/// Anti-aliasing modes
|
||||
|
@ -14,7 +14,9 @@ pub struct SubModel<'a, V: Vertex> {
|
||||
|
||||
impl<'a, V: Vertex> SubModel<'a, V> {
|
||||
pub(super) fn buf(&self) -> wgpu::BufferSlice<'a> {
|
||||
self.buf.slice(map_range(&self.vertex_range))
|
||||
let start = self.vertex_range.start as wgpu::BufferAddress * V::STRIDE;
|
||||
let end = self.vertex_range.end as wgpu::BufferAddress * V::STRIDE;
|
||||
self.buf.slice(start..end)
|
||||
}
|
||||
|
||||
pub fn len(&self) -> u32 { self.vertex_range.end - self.vertex_range.start }
|
||||
@ -83,5 +85,3 @@ impl<V: Vertex> DynamicModel<V> {
|
||||
|
||||
pub fn len(&self) -> usize { self.vbuf.len() }
|
||||
}
|
||||
|
||||
fn map_range(range: &Range<u32>) -> Range<u64> { (range.start as u64)..(range.end as u64) }
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::{
|
||||
super::{AaMode, Bound, Consts, Mesh, Tri},
|
||||
super::{AaMode, Consts},
|
||||
GlobalsLayouts,
|
||||
};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
@ -186,7 +186,7 @@ impl CloudsPipeline {
|
||||
depth_stencil_state: None,
|
||||
vertex_state: wgpu::VertexStateDescriptor {
|
||||
index_format: None,
|
||||
vertex_buffers: &[/*Vertex::desc()*/],
|
||||
vertex_buffers: &[],
|
||||
},
|
||||
sample_count: samples,
|
||||
sample_mask: !0,
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::super::{AaMode, GlobalsLayouts, TerrainLayout, Texture};
|
||||
use super::super::{AaMode, GlobalsLayouts, TerrainLayout, Texture, Vertex as VertexTrait};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
#[repr(C)]
|
||||
@ -32,17 +33,20 @@ impl Vertex {
|
||||
}
|
||||
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 1] =
|
||||
wgpu::vertex_attr_array![0 => Uint];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
pub struct BindGroup {
|
||||
pub(in super::super) bind_group: wgpu::BindGroup,
|
||||
waves: Texture,
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::super::{AaMode, GlobalsLayouts, Renderer, Texture};
|
||||
use super::super::{AaMode, GlobalsLayouts, Renderer, Texture, Vertex as VertexTrait};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
#[repr(C)]
|
||||
@ -16,17 +17,20 @@ impl Vertex {
|
||||
}
|
||||
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 1] =
|
||||
wgpu::vertex_attr_array![0 => Float2];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
pub struct LodData {
|
||||
pub map: Texture,
|
||||
pub alt: Texture,
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::super::{AaMode, GlobalsLayouts};
|
||||
use super::super::{AaMode, GlobalsLayouts, Vertex as VertexTrait};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
#[repr(C)]
|
||||
@ -32,17 +33,20 @@ impl Vertex {
|
||||
}
|
||||
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 2] =
|
||||
wgpu::vertex_attr_array![0 => Float3, 1 => Uint];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum ParticleMode {
|
||||
CampfireSmoke = 0,
|
||||
@ -148,7 +152,6 @@ impl Instance {
|
||||
}
|
||||
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 6] = wgpu::vertex_attr_array![2 => Float, 3 => Float, 4 => Float, 5 => Int, 6 => Float3, 7 => Float3];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::super::{AaMode, Bound, Consts, GlobalsLayouts, Mesh, Tri};
|
||||
use super::super::{AaMode, Consts, GlobalsLayouts};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use vek::*;
|
||||
|
||||
@ -154,7 +154,7 @@ impl PostProcessPipeline {
|
||||
depth_stencil_state: None,
|
||||
vertex_state: wgpu::VertexStateDescriptor {
|
||||
index_format: None,
|
||||
vertex_buffers: &[/*Vertex::desc()*/],
|
||||
vertex_buffers: &[],
|
||||
},
|
||||
sample_count: samples,
|
||||
sample_mask: !0,
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::super::{AaMode, GlobalsLayouts, Mesh, Quad};
|
||||
use super::super::{AaMode, GlobalsLayouts, Mesh, Quad, Vertex as VertexTrait};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Zeroable, Pod)]
|
||||
@ -9,9 +10,8 @@ pub struct Vertex {
|
||||
|
||||
impl Vertex {
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &[wgpu::VertexAttributeDescriptor {
|
||||
offset: 0,
|
||||
@ -22,6 +22,10 @@ impl Vertex {
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
pub struct SkyboxPipeline {
|
||||
pub pipeline: wgpu::RenderPipeline,
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::super::{AaMode, Bound, Consts, GlobalsLayouts, TerrainLayout};
|
||||
use super::super::{AaMode, Bound, Consts, GlobalsLayouts, TerrainLayout, Vertex as VertexTrait};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use core::fmt;
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
#[repr(C)]
|
||||
@ -60,17 +61,20 @@ impl Vertex {
|
||||
}
|
||||
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 3] =
|
||||
wgpu::vertex_attr_array![0 => Float3, 1 => Uint, 2 => Uint];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Zeroable, Pod)]
|
||||
pub struct Instance {
|
||||
@ -110,7 +114,6 @@ impl Instance {
|
||||
}
|
||||
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 7] = wgpu::vertex_attr_array![3 => Uint, 4 => Float4, 5 => Float4, 6 => Float4,7 => Float4, 8 => Float4, 9 => Float];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
|
@ -1,5 +1,6 @@
|
||||
use super::super::{AaMode, Bound, Consts, GlobalsLayouts};
|
||||
use super::super::{AaMode, Bound, Consts, GlobalsLayouts, Vertex as VertexTrait};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
#[repr(C)]
|
||||
@ -119,17 +120,20 @@ impl Vertex {
|
||||
}
|
||||
|
||||
pub fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 2] =
|
||||
wgpu::vertex_attr_array![0 => Uint,1 => Uint];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Zeroable, Pod)]
|
||||
// TODO: new function and private fields??
|
||||
|
@ -1,5 +1,8 @@
|
||||
use super::super::{AaMode, Bound, Consts, GlobalsLayouts, Quad, Texture, Tri};
|
||||
use super::super::{
|
||||
AaMode, Bound, Consts, GlobalsLayouts, Quad, Texture, Tri, Vertex as VertexTrait,
|
||||
};
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
#[repr(C)]
|
||||
@ -14,17 +17,20 @@ pub struct Vertex {
|
||||
|
||||
impl Vertex {
|
||||
fn desc<'a>() -> wgpu::VertexBufferDescriptor<'a> {
|
||||
use std::mem;
|
||||
const ATTRIBUTES: [wgpu::VertexAttributeDescriptor; 5] =
|
||||
wgpu::vertex_attr_array![0 => Float2, 1 => Float2, 2 => Float4, 3 => Float2, 4 => Uint];
|
||||
wgpu::VertexBufferDescriptor {
|
||||
stride: mem::size_of::<Self>() as wgpu::BufferAddress,
|
||||
stride: Self::STRIDE,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: &ATTRIBUTES,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VertexTrait for Vertex {
|
||||
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Zeroable, Pod)]
|
||||
pub struct Locals {
|
||||
|
@ -1,6 +1,5 @@
|
||||
use super::{
|
||||
super::{
|
||||
consts::Consts,
|
||||
pipelines::{
|
||||
figure, fluid, lod_terrain, sprite, terrain, ui, ColLights, GlobalModel,
|
||||
GlobalsBindGroup,
|
||||
|
Loading…
Reference in New Issue
Block a user