switch entity_transforms to storage buffers to remove hardcoded part cap

This commit is contained in:
Quaternions 2023-09-21 11:55:31 -07:00
parent e27ce3b507
commit 1cee3b52ac
2 changed files with 10 additions and 6 deletions

View File

@ -218,7 +218,7 @@ impl GraphicsData {
let model_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let model_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some(format!("ModelGraphics{}",i).as_str()), label: Some(format!("ModelGraphics{}",i).as_str()),
contents: bytemuck::cast_slice(&model_uniforms), contents: bytemuck::cast_slice(&model_uniforms),
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::COPY_DST,
}); });
let model_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { let model_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &self.bind_group_layouts.model, layout: &self.bind_group_layouts.model,
@ -321,7 +321,12 @@ impl strafe_client::framework::Example for GraphicsData {
| wgpu::Features::TEXTURE_COMPRESSION_ETC2 | wgpu::Features::TEXTURE_COMPRESSION_ETC2
| wgpu::Features::TEXTURE_COMPRESSION_BC | wgpu::Features::TEXTURE_COMPRESSION_BC
} }
fn required_features() -> wgpu::Features {
wgpu::Features::STORAGE_RESOURCE_BINDING_ARRAY
}
fn required_limits() -> wgpu::Limits {
wgpu::Limits::default() //framework.rs was using goofy limits that caused me a multi-day headache
}
fn init( fn init(
config: &wgpu::SurfaceConfiguration, config: &wgpu::SurfaceConfiguration,
_adapter: &wgpu::Adapter, _adapter: &wgpu::Adapter,
@ -462,7 +467,7 @@ impl strafe_client::framework::Example for GraphicsData {
binding: 0, binding: 0,
visibility: wgpu::ShaderStages::VERTEX, visibility: wgpu::ShaderStages::VERTEX,
ty: wgpu::BindingType::Buffer { ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform, ty: wgpu::BufferBindingType::Storage { read_only: true },
has_dynamic_offset: false, has_dynamic_offset: false,
min_binding_size: None, min_binding_size: None,
}, },

View File

@ -41,12 +41,11 @@ fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput {
return result; return result;
} }
const MAX_ENTITY_INSTANCES=1024;
//group 1 is the model //group 1 is the model
@group(1) @group(1)
@binding(0) @binding(0)
var<uniform> entity_transforms: array<mat4x4<f32>,MAX_ENTITY_INSTANCES>; var<storage> entity_transforms: array<mat4x4<f32>>;
//var<uniform> entity_texture_transforms: array<mat3x3<f32>,MAX_ENTITY_INSTANCES>; //entity_texture_transforms: mat3x3<f32>;
//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
//how to do no texture? //how to do no texture?