mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Update wgpu to fix segfault, fix sprite vertex lookup, normalize sprite
normals in vert shader
This commit is contained in:
parent
3a6a96b70b
commit
3312cb03b3
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -6583,7 +6583,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "wgpu"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu-rs.git?rev=f891e86e87f0733f04a8078f4be8ead2f24551cf#f891e86e87f0733f04a8078f4be8ead2f24551cf"
|
||||
source = "git+https://github.com/gfx-rs/wgpu-rs.git?rev=1f1a7e5dd47a1610733bbc3989414acb62395359#1f1a7e5dd47a1610733bbc3989414acb62395359"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"js-sys",
|
||||
@ -6602,7 +6602,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=7c7501cab72fd01b14def06b9d9bc63a8dd44b45#7c7501cab72fd01b14def06b9d9bc63a8dd44b45"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=3ebe198911b46cb77fcdc481f7d0daf9a962b82e#3ebe198911b46cb77fcdc481f7d0daf9a962b82e"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags",
|
||||
@ -6630,7 +6630,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=7c7501cab72fd01b14def06b9d9bc63a8dd44b45#7c7501cab72fd01b14def06b9d9bc63a8dd44b45"
|
||||
source = "git+https://github.com/gfx-rs/wgpu?rev=3ebe198911b46cb77fcdc481f7d0daf9a962b82e#3ebe198911b46cb77fcdc481f7d0daf9a962b82e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
@ -94,4 +94,5 @@ void main() {
|
||||
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light) * f_light;
|
||||
|
||||
tgt_color = vec4(surf_color, 1.0 - clamp((distance(focus_pos.xy, f_pos.xy) - (sprite_render_distance - FADE_DIST)) / FADE_DIST, 0, 1));
|
||||
//tgt_color = vec4(-f_norm, 1.0);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ const float SCALE_FACTOR = pow(SCALE, 1.3) * 0.2;
|
||||
|
||||
const int EXTRA_NEG_Z = 32768;
|
||||
const int VERT_EXTRA_NEG_Z = 128;
|
||||
const int VERT_PAGE_SIZE = 256;
|
||||
const int VERT_PAGE_SIZE = 300;
|
||||
|
||||
void main() {
|
||||
// Matrix to transform this sprite instance from model space to chunk space
|
||||
@ -68,8 +68,8 @@ void main() {
|
||||
f_inst_light = vec2(inst_light, inst_glow);
|
||||
|
||||
// Index of the vertex data in the 1D vertex texture
|
||||
int vertex_index = int(gl_VertexIndex % VERT_PAGE_SIZE + inst_vert_page);
|
||||
const int WIDTH = 16384; // TODO: temp
|
||||
int vertex_index = int(gl_VertexIndex % VERT_PAGE_SIZE + inst_vert_page * VERT_PAGE_SIZE);
|
||||
const int WIDTH = 8192; // TODO: temp
|
||||
ivec2 tex_coords = ivec2(vertex_index % WIDTH, vertex_index / WIDTH);
|
||||
uvec2 pos_atlas_pos_norm_ao = texelFetch(usampler2D(t_sprite_verts, s_sprite_verts), tex_coords, 0).xy;
|
||||
uint v_pos_norm = pos_atlas_pos_norm_ao.x;
|
||||
@ -97,7 +97,7 @@ void main() {
|
||||
|
||||
// Determine normal
|
||||
vec3 norm = (inst_mat[(v_pos_norm >> 30u) & 3u].xyz);
|
||||
f_norm = mix(-norm, norm, v_pos_norm >> 29u & 1u);
|
||||
f_norm = normalize(mix(-norm, norm, v_pos_norm >> 29u & 1u));
|
||||
|
||||
// Expand atlas tex coords to floats
|
||||
// NOTE: Could defer to fragment shader if we are vert heavy
|
||||
|
@ -27,7 +27,7 @@ anim = {package = "veloren-voxygen-anim", path = "anim", default-features = fals
|
||||
|
||||
# Graphics
|
||||
winit = {version = "0.24.0", features = ["serde"]}
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "f891e86e87f0733f04a8078f4be8ead2f24551cf" }
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "1f1a7e5dd47a1610733bbc3989414acb62395359" }
|
||||
bytemuck = { version="1.4", features=["derive"] }
|
||||
shaderc = "0.6.2"
|
||||
|
||||
|
@ -10,7 +10,7 @@ use core::fmt;
|
||||
use std::mem;
|
||||
use vek::*;
|
||||
|
||||
pub const VERT_PAGE_SIZE: u32 = 256;
|
||||
pub const VERT_PAGE_SIZE: u32 = 300;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Zeroable, Pod)]
|
||||
@ -92,7 +92,7 @@ pub fn create_verts_texture(renderer: &mut Renderer, mut mesh: Mesh<Vertex>) ->
|
||||
let format = wgpu::TextureFormat::Rg32Uint;
|
||||
|
||||
// TODO: temp
|
||||
const WIDTH: u32 = 16384;
|
||||
const WIDTH: u32 = 8192;
|
||||
let height = verts.len() as u32 / WIDTH;
|
||||
// Fill in verts to full texture size
|
||||
verts.resize_with(height as usize * WIDTH as usize, Vertex::default);
|
||||
|
@ -525,7 +525,7 @@ impl<'pass_ref, 'pass: 'pass_ref> SpriteDrawer<'pass_ref, 'pass> {
|
||||
self.render_pass
|
||||
.set_vertex_buffer(0, instances.buf().slice(..));
|
||||
self.render_pass
|
||||
.draw(0..sprite::VERT_PAGE_SIZE - 4, 0..instances.count() as u32);
|
||||
.draw(0..sprite::VERT_PAGE_SIZE, 0..instances.count() as u32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,6 +644,10 @@ impl<'pass_ref, 'pass: 'pass_ref> PreparedUiDrawer<'pass_ref, 'pass> {
|
||||
|
||||
pub fn set_scissor<'data: 'pass>(&mut self, scissor: Aabr<u16>) {
|
||||
let Aabr { min, max } = scissor;
|
||||
// TODO: Got an invalid scissor panic from wgpu,
|
||||
// use this if you can reproduce
|
||||
// Note: might have been from changing monitors
|
||||
// dbg!(&scissor)
|
||||
self.render_pass.set_scissor_rect(
|
||||
min.x as u32,
|
||||
min.y as u32,
|
||||
|
@ -10,6 +10,7 @@ use crate::{
|
||||
ColLightInfo, Consts, Drawer, FirstPassDrawer, FluidVertex, FluidWaves, GlobalModel,
|
||||
Instances, LodData, Mesh, Model, RenderError, Renderer, SpriteGlobalsBindGroup,
|
||||
SpriteInstance, SpriteVertex, TerrainLocals, TerrainShadowDrawer, TerrainVertex, Texture,
|
||||
SPRITE_VERT_PAGE_SIZE,
|
||||
},
|
||||
};
|
||||
|
||||
@ -41,7 +42,6 @@ use vek::*;
|
||||
|
||||
const SPRITE_SCALE: Vec3<f32> = Vec3::new(1.0 / 11.0, 1.0 / 11.0, 1.0 / 11.0);
|
||||
const SPRITE_LOD_LEVELS: usize = 5;
|
||||
const SPRITE_VERT_PAGE_SIZE: usize = 256;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Visibility {
|
||||
@ -390,7 +390,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
};
|
||||
// Get starting page count of opaque mesh
|
||||
let start_page_num =
|
||||
opaque_mesh.vertices().len() / SPRITE_VERT_PAGE_SIZE;
|
||||
opaque_mesh.vertices().len() / SPRITE_VERT_PAGE_SIZE as usize;
|
||||
// Mesh generation exclusively acts using side effects; it
|
||||
// has no interesting return value, but updates the mesh.
|
||||
generate_mesh_base_vol_sprite(
|
||||
@ -405,11 +405,11 @@ impl<V: RectRasterableVol> Terrain<V> {
|
||||
);
|
||||
// Get the number of pages after the model was meshed
|
||||
let end_page_num =
|
||||
(opaque_mesh.vertices().len() + SPRITE_VERT_PAGE_SIZE - 1)
|
||||
/ SPRITE_VERT_PAGE_SIZE;
|
||||
(opaque_mesh.vertices().len() + SPRITE_VERT_PAGE_SIZE as usize - 1)
|
||||
/ SPRITE_VERT_PAGE_SIZE as usize;
|
||||
// Fill the current last page up with degenerate verts
|
||||
opaque_mesh.vertices_mut_vec().resize_with(
|
||||
end_page_num * SPRITE_VERT_PAGE_SIZE,
|
||||
end_page_num * SPRITE_VERT_PAGE_SIZE as usize,
|
||||
SpriteVertex::default,
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user