graphics: need depth texture
This commit is contained in:
@@ -127,6 +127,7 @@ pub struct GraphicsState{
|
||||
camera_buf:wgpu::Buffer,
|
||||
temp_squid_texture_view:wgpu::TextureView,
|
||||
models:Vec<GraphicsModel>,
|
||||
depth:wgpu::Texture,
|
||||
depth_view:wgpu::TextureView,
|
||||
staging_belt:wgpu::util::StagingBelt,
|
||||
model_instances_uniform_len:usize,
|
||||
@@ -137,8 +138,8 @@ impl GraphicsState{
|
||||
fn create_depth_texture(
|
||||
size:glam::UVec2,
|
||||
device:&wgpu::Device,
|
||||
)->wgpu::TextureView{
|
||||
let depth_texture=device.create_texture(&wgpu::TextureDescriptor{
|
||||
)->wgpu::Texture{
|
||||
device.create_texture(&wgpu::TextureDescriptor{
|
||||
size:wgpu::Extent3d{
|
||||
width:size.x,
|
||||
height:size.y,
|
||||
@@ -151,9 +152,10 @@ impl GraphicsState{
|
||||
usage:wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
label:None,
|
||||
view_formats:&[],
|
||||
});
|
||||
|
||||
depth_texture.create_view(&wgpu::TextureViewDescriptor::default())
|
||||
})
|
||||
}
|
||||
pub const fn depth_texture(&self)->&wgpu::Texture{
|
||||
&self.depth
|
||||
}
|
||||
pub const fn depth_texture_view(&self)->&wgpu::TextureView{
|
||||
&self.depth_view
|
||||
@@ -881,7 +883,8 @@ impl GraphicsState{
|
||||
label:Some("Sky Texture"),
|
||||
});
|
||||
|
||||
let depth_view=Self::create_depth_texture(size,device);
|
||||
let depth=Self::create_depth_texture(size,device);
|
||||
let depth_view=depth.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
|
||||
Self{
|
||||
pipelines:GraphicsPipelines{
|
||||
@@ -895,6 +898,7 @@ impl GraphicsState{
|
||||
camera,
|
||||
camera_buf,
|
||||
models:Vec::new(),
|
||||
depth,
|
||||
depth_view,
|
||||
staging_belt:wgpu::util::StagingBelt::new(device.clone(),0x100),
|
||||
bind_group_layouts:GraphicsBindGroupLayouts{model:model_bind_group_layout},
|
||||
@@ -909,7 +913,8 @@ impl GraphicsState{
|
||||
size:glam::UVec2,
|
||||
fov:glam::Vec2,
|
||||
){
|
||||
self.depth_view=Self::create_depth_texture(size,device);
|
||||
self.depth=Self::create_depth_texture(size,device);
|
||||
self.depth_view=self.depth.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
self.camera.screen_size=size;
|
||||
self.camera.fov=fov;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user