diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-22 00:27:38 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-22 00:27:38 +0100 |
commit | c682a1315adfa4e90d661d25e55df6e99a884d40 (patch) | |
tree | 96c2b1bb075ae7cea43f0588373af1af00936706 | |
parent | 0612ce58890741428f10c73a63bcb417dcd43a9f (diff) | |
download | weareserver-c682a1315adfa4e90d661d25e55df6e99a884d40.tar weareserver-c682a1315adfa4e90d661d25e55df6e99a884d40.tar.bz2 weareserver-c682a1315adfa4e90d661d25e55df6e99a884d40.tar.zst |
move scene bgl to scene_prepare
-rw-r--r-- | client/src/scene_prepare.rs | 72 | ||||
-rw-r--r-- | client/src/scene_render.rs | 66 |
2 files changed, 68 insertions, 70 deletions
diff --git a/client/src/scene_prepare.rs b/client/src/scene_prepare.rs index 4b298a1..e7d3403 100644 --- a/client/src/scene_prepare.rs +++ b/client/src/scene_prepare.rs @@ -18,7 +18,6 @@ use crate::{ armature::RArmature, download::Downloader, meshops::{generate_normals, generate_tangents, generate_texcoords}, - scene_render::SceneBgLayouts, shaders::SceneShaders, }; use anyhow::Result; @@ -42,14 +41,16 @@ use weareshared::{ resources::{Image, MeshPart, Prefab}, }; use wgpu::{ - AddressMode, BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindingResource, - BlendState, Buffer, BufferUsages, ColorTargetState, ColorWrites, CompareFunction, + AddressMode, BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, + BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendState, + Buffer, BufferBindingType, BufferUsages, ColorTargetState, ColorWrites, CompareFunction, DepthBiasState, DepthStencilState, Device, Extent3d, Face, FilterMode, FragmentState, FrontFace, MultisampleState, PipelineCompilationOptions, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, Queue, RenderPipeline, - RenderPipelineDescriptor, SamplerDescriptor, ShaderStages, StencilState, Texture, - TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, TextureViewDescriptor, - VertexAttribute, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, + RenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor, ShaderStages, StencilState, + Texture, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, + TextureViewDescriptor, TextureViewDimension, VertexAttribute, VertexBufferLayout, VertexFormat, + VertexState, VertexStepMode, util::{BufferInitDescriptor, DeviceExt, TextureDataOrder}, }; @@ -618,6 +619,65 @@ fn create_texture( (Arc::new(texture), Arc::new(bindgroup)) } +pub struct SceneBgLayouts { + pub texture: BindGroupLayout, + pub material: BindGroupLayout, + pub joints: BindGroupLayout, +} +impl SceneBgLayouts { + pub fn load(device: &Device) -> Self { + Self { + texture: device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[ + BindGroupLayoutEntry { + binding: 0, + count: None, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Texture { + sample_type: TextureSampleType::Float { filterable: true }, + view_dimension: TextureViewDimension::D2, + multisampled: false, + }, + }, + BindGroupLayoutEntry { + binding: 1, + count: None, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Sampler(SamplerBindingType::Filtering), + }, + ], + label: None, + }), + material: device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[BindGroupLayoutEntry { + binding: 0, + count: None, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Buffer { + ty: BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: None, + }, + }], + label: None, + }), + joints: device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[BindGroupLayoutEntry { + binding: 0, + count: None, + visibility: ShaderStages::VERTEX, + ty: BindingType::Buffer { + ty: BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: None, + }, + }], + label: None, + }), + } + } +} + impl PipelineConfig { pub fn create( &self, diff --git a/client/src/scene_render.rs b/client/src/scene_render.rs index d621ba6..2720e33 100644 --- a/client/src/scene_render.rs +++ b/client/src/scene_render.rs @@ -19,74 +19,12 @@ use glam::{EulerRot, Mat3, Mat4}; use std::sync::Arc; use weareshared::{packets::Resource, resources::Prefab, tree::SceneTree}; use wgpu::{ - BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, - BufferBindingType, Color, CommandEncoder, Device, IndexFormat, LoadOp, Operations, - RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor, - SamplerBindingType, ShaderStages, StoreOp, TextureSampleType, TextureView, - TextureViewDimension, + Color, CommandEncoder, IndexFormat, LoadOp, Operations, RenderPassColorAttachment, + RenderPassDepthStencilAttachment, RenderPassDescriptor, ShaderStages, StoreOp, TextureView, }; pub struct ScenePipeline; -pub struct SceneBgLayouts { - pub texture: BindGroupLayout, - pub material: BindGroupLayout, - pub joints: BindGroupLayout, -} -impl SceneBgLayouts { - pub fn load(device: &Device) -> Self { - Self { - texture: device.create_bind_group_layout(&BindGroupLayoutDescriptor { - entries: &[ - BindGroupLayoutEntry { - binding: 0, - count: None, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Texture { - sample_type: TextureSampleType::Float { filterable: true }, - view_dimension: TextureViewDimension::D2, - multisampled: false, - }, - }, - BindGroupLayoutEntry { - binding: 1, - count: None, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Sampler(SamplerBindingType::Filtering), - }, - ], - label: None, - }), - material: device.create_bind_group_layout(&BindGroupLayoutDescriptor { - entries: &[BindGroupLayoutEntry { - binding: 0, - count: None, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Buffer { - ty: BufferBindingType::Uniform, - has_dynamic_offset: false, - min_binding_size: None, - }, - }], - label: None, - }), - joints: device.create_bind_group_layout(&BindGroupLayoutDescriptor { - entries: &[BindGroupLayoutEntry { - binding: 0, - count: None, - visibility: ShaderStages::VERTEX, - ty: BindingType::Buffer { - ty: BufferBindingType::Uniform, - has_dynamic_offset: false, - min_binding_size: None, - }, - }], - label: None, - }), - } - } -} - impl ScenePipeline { pub fn draw( &mut self, |