wgpu 22.0.0

This commit is contained in:
Quaternions 2024-05-04 16:18:56 -07:00
parent 5f1b162775
commit 1b71bda9c7
5 changed files with 576 additions and 369 deletions

916
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,8 @@ strafesnet_bsp_loader = { version = "0.1.1", registry = "strafesnet" }
strafesnet_common = { version = "0.1.2", registry = "strafesnet" } strafesnet_common = { version = "0.1.2", registry = "strafesnet" }
strafesnet_deferred_loader = { version = "0.3.0", features = ["legacy"], registry = "strafesnet" } strafesnet_deferred_loader = { version = "0.3.0", features = ["legacy"], registry = "strafesnet" }
strafesnet_rbx_loader = { version = "0.3.0", registry = "strafesnet" } strafesnet_rbx_loader = { version = "0.3.0", registry = "strafesnet" }
wgpu = "0.19.0" wgpu = "22.0.0"
winit = "0.29.2" winit = "0.30.4"
#[profile.release] #[profile.release]
#lto = true #lto = true

View File

@ -463,7 +463,9 @@ impl GraphicsState{
instance_count+=model.instances.len(); instance_count+=model.instances.len();
for instances_chunk in model.instances.rchunks(chunk_size){ for instances_chunk in model.instances.rchunks(chunk_size){
model_count+=1; model_count+=1;
let model_uniforms=get_instances_buffer_data(instances_chunk); let mut model_uniforms=get_instances_buffer_data(instances_chunk);
//TEMP: fill with zeroes to pass validation
model_uniforms.resize(MODEL_BUFFER_SIZE*512,0.0f32);
let model_buf=device.create_buffer_init(&wgpu::util::BufferInitDescriptor{ let model_buf=device.create_buffer_init(&wgpu::util::BufferInitDescriptor{
label:Some(format!("Model{} Buf",model_count).as_str()), label:Some(format!("Model{} Buf",model_count).as_str()),
contents:bytemuck::cast_slice(&model_uniforms), contents:bytemuck::cast_slice(&model_uniforms),
@ -754,11 +756,13 @@ impl GraphicsState{
module:&shader, module:&shader,
entry_point:"vs_sky", entry_point:"vs_sky",
buffers:&[], buffers:&[],
compilation_options:wgpu::PipelineCompilationOptions::default(),
}, },
fragment:Some(wgpu::FragmentState{ fragment:Some(wgpu::FragmentState{
module:&shader, module:&shader,
entry_point:"fs_sky", entry_point:"fs_sky",
targets:&[Some(config.view_formats[0].into())], targets:&[Some(config.view_formats[0].into())],
compilation_options:wgpu::PipelineCompilationOptions::default(),
}), }),
primitive:wgpu::PrimitiveState{ primitive:wgpu::PrimitiveState{
front_face:wgpu::FrontFace::Cw, front_face:wgpu::FrontFace::Cw,
@ -773,6 +777,7 @@ impl GraphicsState{
}), }),
multisample:wgpu::MultisampleState::default(), multisample:wgpu::MultisampleState::default(),
multiview:None, multiview:None,
cache:None,
}); });
let model_pipeline=device.create_render_pipeline(&wgpu::RenderPipelineDescriptor{ let model_pipeline=device.create_render_pipeline(&wgpu::RenderPipelineDescriptor{
label:Some("Model Pipeline"), label:Some("Model Pipeline"),
@ -785,11 +790,13 @@ impl GraphicsState{
step_mode:wgpu::VertexStepMode::Vertex, step_mode:wgpu::VertexStepMode::Vertex,
attributes:&wgpu::vertex_attr_array![0=>Float32x3,1=>Float32x2,2=>Float32x3,3=>Float32x4], attributes:&wgpu::vertex_attr_array![0=>Float32x3,1=>Float32x2,2=>Float32x3,3=>Float32x4],
}], }],
compilation_options:wgpu::PipelineCompilationOptions::default(),
}, },
fragment:Some(wgpu::FragmentState{ fragment:Some(wgpu::FragmentState{
module:&shader, module:&shader,
entry_point:"fs_entity_texture", entry_point:"fs_entity_texture",
targets:&[Some(config.view_formats[0].into())], targets:&[Some(config.view_formats[0].into())],
compilation_options:wgpu::PipelineCompilationOptions::default(),
}), }),
primitive:wgpu::PrimitiveState{ primitive:wgpu::PrimitiveState{
front_face:wgpu::FrontFace::Cw, front_face:wgpu::FrontFace::Cw,
@ -805,6 +812,7 @@ impl GraphicsState{
}), }),
multisample:wgpu::MultisampleState::default(), multisample:wgpu::MultisampleState::default(),
multiview:None, multiview:None,
cache:None,
}); });
let camera=GraphicsCamera::default(); let camera=GraphicsCamera::default();

View File

@ -25,14 +25,14 @@ struct SetupContextPartial1{
instance:wgpu::Instance, instance:wgpu::Instance,
} }
fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Result<winit::window::Window,winit::error::OsError>{ fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Result<winit::window::Window,winit::error::OsError>{
let mut builder = winit::window::WindowBuilder::new(); let mut attr=winit::window::WindowAttributes::default();
builder = builder.with_title(title); attr=attr.with_title(title);
#[cfg(windows_OFF)] // TODO #[cfg(windows_OFF)] // TODO
{ {
use winit::platform::windows::WindowBuilderExtWindows; use winit::platform::windows::WindowBuilderExtWindows;
builder=builder.with_no_redirection_bitmap(true); builder=builder.with_no_redirection_bitmap(true);
} }
builder.build(event_loop) event_loop.create_window(attr)
} }
fn create_instance()->SetupContextPartial1{ fn create_instance()->SetupContextPartial1{
let backends=wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all); let backends=wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all);
@ -143,6 +143,7 @@ impl<'a> SetupContextPartial3<'a>{
label: None, label: None,
required_features: (optional_features & self.adapter.features()) | required_features, required_features: (optional_features & self.adapter.features()) | required_features,
required_limits: needed_limits, required_limits: needed_limits,
memory_hints:wgpu::MemoryHints::Performance,
}, },
trace_dir.ok().as_ref().map(std::path::Path::new), trace_dir.ok().as_ref().map(std::path::Path::new),
)) ))

View File

@ -48,7 +48,7 @@ struct ModelInstance{
//my fancy idea is to create a megatexture for each model that includes all the textures each intance will need //my fancy idea is to create a megatexture for each model that includes all the textures each intance will need
//the texture transform then maps the texture coordinates to the location of the specific texture //the texture transform then maps the texture coordinates to the location of the specific texture
//group 1 is the model //group 1 is the model
const MAX_MODEL_INSTANCES=4096; const MAX_MODEL_INSTANCES=512;
@group(2) @group(2)
@binding(0) @binding(0)
var<uniform> model_instances: array<ModelInstance, MAX_MODEL_INSTANCES>; var<uniform> model_instances: array<ModelInstance, MAX_MODEL_INSTANCES>;