Added constants
parent
a4ca62e1dc
commit
83857d4d0d
|
@ -55,3 +55,9 @@ pub const PARTICLE_SPRITE_INSTANCE_LIMIT: u64 = 1000;
|
||||||
|
|
||||||
/// Must be small enough to fit in an i32
|
/// Must be small enough to fit in an i32
|
||||||
pub const STARFIELD_SPRITE_INSTANCE_LIMIT: u64 = STARFIELD_COUNT * 24;
|
pub const STARFIELD_SPRITE_INSTANCE_LIMIT: u64 = STARFIELD_COUNT * 24;
|
||||||
|
|
||||||
|
/// The maximum number of sprites we can define
|
||||||
|
pub const SPRITE_LIMIT: u32 = 1024;
|
||||||
|
|
||||||
|
/// The maximum number of images we can load
|
||||||
|
pub const IMAGE_LIMIT: u32 = 1024;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
|
use galactica_constants::IMAGE_LIMIT;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use wgpu;
|
use wgpu;
|
||||||
|
|
||||||
|
@ -14,14 +15,14 @@ pub struct ImageLocation {
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct ImageLocationArray {
|
pub struct ImageLocationArray {
|
||||||
pub data: [ImageLocation; 108],
|
pub data: [ImageLocation; IMAGE_LIMIT as usize],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Pod for ImageLocationArray {}
|
unsafe impl Pod for ImageLocationArray {}
|
||||||
unsafe impl Zeroable for ImageLocationArray {
|
unsafe impl Zeroable for ImageLocationArray {
|
||||||
fn zeroed() -> Self {
|
fn zeroed() -> Self {
|
||||||
Self {
|
Self {
|
||||||
data: [ImageLocation::zeroed(); 108],
|
data: [ImageLocation::zeroed(); IMAGE_LIMIT as usize],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use galactica_constants::{IMAGE_LIMIT, SPRITE_LIMIT};
|
||||||
use wgpu;
|
use wgpu;
|
||||||
|
|
||||||
use super::{AtlasContent, DataContent, SpriteContent};
|
use super::{AtlasContent, DataContent, SpriteContent};
|
||||||
|
@ -30,7 +31,7 @@ impl GlobalUniform {
|
||||||
starfield_size_limits: vec2<f32>,
|
starfield_size_limits: vec2<f32>,
|
||||||
current_time: vec2<f32>,
|
current_time: vec2<f32>,
|
||||||
};
|
};
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
out.push_str("\n");
|
out.push_str("\n");
|
||||||
|
|
||||||
|
@ -44,11 +45,16 @@ impl GlobalUniform {
|
||||||
width: f32,
|
width: f32,
|
||||||
height: f32,
|
height: f32,
|
||||||
};
|
};
|
||||||
struct AtlasUniform {
|
"#,
|
||||||
data: array<ImageLocation, 108>,
|
|
||||||
};
|
|
||||||
"#,
|
|
||||||
);
|
);
|
||||||
|
out.push_str(&format!(
|
||||||
|
r#"
|
||||||
|
struct AtlasUniform {{
|
||||||
|
data: array<ImageLocation, {}>,
|
||||||
|
}};
|
||||||
|
"#,
|
||||||
|
IMAGE_LIMIT,
|
||||||
|
));
|
||||||
out.push_str("\n");
|
out.push_str("\n");
|
||||||
|
|
||||||
// TODO: document
|
// TODO: document
|
||||||
|
@ -72,11 +78,16 @@ impl GlobalUniform {
|
||||||
padding_b: f32,
|
padding_b: f32,
|
||||||
padding_c: f32,
|
padding_c: f32,
|
||||||
};
|
};
|
||||||
struct SpriteUniform {
|
"#,
|
||||||
data: array<SpriteData, 108>,
|
|
||||||
};
|
|
||||||
"#,
|
|
||||||
);
|
);
|
||||||
|
out.push_str(&format!(
|
||||||
|
r#"
|
||||||
|
struct SpriteUniform {{
|
||||||
|
data: array<SpriteData, {}>,
|
||||||
|
}};
|
||||||
|
"#,
|
||||||
|
SPRITE_LIMIT,
|
||||||
|
));
|
||||||
out.push_str("\n");
|
out.push_str("\n");
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
|
use galactica_constants::SPRITE_LIMIT;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use wgpu;
|
use wgpu;
|
||||||
|
|
||||||
|
@ -19,14 +20,14 @@ pub struct SpriteData {
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct SpriteDataArray {
|
pub struct SpriteDataArray {
|
||||||
pub data: [SpriteData; 108],
|
pub data: [SpriteData; SPRITE_LIMIT as usize],
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Pod for SpriteDataArray {}
|
unsafe impl Pod for SpriteDataArray {}
|
||||||
unsafe impl Zeroable for SpriteDataArray {
|
unsafe impl Zeroable for SpriteDataArray {
|
||||||
fn zeroed() -> Self {
|
fn zeroed() -> Self {
|
||||||
Self {
|
Self {
|
||||||
data: [SpriteData::zeroed(); 108],
|
data: [SpriteData::zeroed(); SPRITE_LIMIT as usize],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue