Resolve validation errors with trying to use unsupported filtering modes

This commit is contained in:
Imbris 2021-02-03 17:02:11 -05:00
parent 6228430002
commit 85c7f5c9c9
3 changed files with 45 additions and 18 deletions

View File

@ -101,6 +101,7 @@ impl CloudsLayout {
src_color: &wgpu::TextureView,
src_depth: &wgpu::TextureView,
sampler: &wgpu::Sampler,
depth_sampler: &wgpu::Sampler,
locals: &Consts<Locals>,
) -> BindGroup {
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
@ -121,7 +122,7 @@ impl CloudsLayout {
},
wgpu::BindGroupEntry {
binding: 3,
resource: wgpu::BindingResource::Sampler(sampler),
resource: wgpu::BindingResource::Sampler(depth_sampler),
},
wgpu::BindGroupEntry {
binding: 4,

View File

@ -66,7 +66,7 @@ impl LodData {
tgt_detail: u32,
//border_color: gfx::texture::PackedColor,
) -> Self {
let mut create_texture = |format, data| {
let mut create_texture = |format, data, filter| {
let texture_info = wgpu::TextureDescriptor {
label: None,
size: wgpu::Extent3d {
@ -86,8 +86,8 @@ impl LodData {
address_mode_u: wgpu::AddressMode::ClampToEdge,
address_mode_v: wgpu::AddressMode::ClampToEdge,
address_mode_w: wgpu::AddressMode::ClampToEdge,
mag_filter: wgpu::FilterMode::Linear,
min_filter: wgpu::FilterMode::Linear,
mag_filter: filter,
min_filter: filter,
mipmap_filter: wgpu::FilterMode::Nearest,
border_color: Some(wgpu::SamplerBorderColor::TransparentBlack),
..Default::default()
@ -111,13 +111,26 @@ impl LodData {
bytemuck::cast_slice(data),
)
};
let map = create_texture(wgpu::TextureFormat::Rgba8UnormSrgb, lod_base);
let map = create_texture(
wgpu::TextureFormat::Rgba8UnormSrgb,
lod_base,
wgpu::FilterMode::Linear,
);
// SamplerInfo {
// border: border_color,
let alt = create_texture(wgpu::TextureFormat::Rg16Uint, lod_alt);
let alt = create_texture(
// TODO: figure out format that can be linearly filtered or change the shaders
wgpu::TextureFormat::Rg16Uint,
lod_alt,
wgpu::FilterMode::Nearest,
);
// SamplerInfo {
// border: [0.0, 0.0, 0.0, 0.0].into(),
let horizon = create_texture(wgpu::TextureFormat::Rgba8Unorm, lod_horizon);
let horizon = create_texture(
wgpu::TextureFormat::Rgba8Unorm,
lod_horizon,
wgpu::FilterMode::Linear,
);
// SamplerInfo {
// border: [1.0, 0.0, 1.0, 0.0].into(),

View File

@ -184,12 +184,14 @@ impl Locals {
tgt_depth_view: &wgpu::TextureView,
tgt_color_pp_view: &wgpu::TextureView,
sampler: &wgpu::Sampler,
depth_sampler: &wgpu::Sampler,
) -> Self {
let clouds_bind = layouts.clouds.bind(
device,
tgt_color_view,
tgt_depth_view,
sampler,
depth_sampler,
&clouds_locals,
);
let postprocess_bind =
@ -215,12 +217,14 @@ impl Locals {
tgt_depth_view: &wgpu::TextureView,
tgt_color_pp_view: &wgpu::TextureView,
sampler: &wgpu::Sampler,
depth_sampler: &wgpu::Sampler,
) {
self.clouds_bind = layouts.clouds.bind(
device,
tgt_color_view,
tgt_depth_view,
sampler,
depth_sampler,
&self.clouds,
);
self.postprocess_bind =
@ -249,6 +253,7 @@ pub struct Renderer {
tgt_color_pp_view: wgpu::TextureView,
sampler: wgpu::Sampler,
depth_sampler: wgpu::Sampler,
shadow_map: ShadowMap,
shadow_bind: ShadowTexturesBindGroup,
@ -458,17 +463,22 @@ impl Renderer {
.bind_shadow_textures(&device, point, directed)
};
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
label: None,
address_mode_u: wgpu::AddressMode::ClampToEdge,
address_mode_v: wgpu::AddressMode::ClampToEdge,
address_mode_w: wgpu::AddressMode::ClampToEdge,
mag_filter: wgpu::FilterMode::Linear,
min_filter: wgpu::FilterMode::Linear,
mipmap_filter: wgpu::FilterMode::Nearest,
compare: None,
..Default::default()
});
let create_sampler = |filter| {
device.create_sampler(&wgpu::SamplerDescriptor {
label: None,
address_mode_u: wgpu::AddressMode::ClampToEdge,
address_mode_v: wgpu::AddressMode::ClampToEdge,
address_mode_w: wgpu::AddressMode::ClampToEdge,
mag_filter: filter,
min_filter: filter,
mipmap_filter: wgpu::FilterMode::Nearest,
compare: None,
..Default::default()
})
};
let sampler = create_sampler(wgpu::FilterMode::Linear);
let depth_sampler = create_sampler(wgpu::FilterMode::Nearest);
let noise_tex = Texture::new(
&device,
@ -492,6 +502,7 @@ impl Renderer {
&tgt_depth_view,
&tgt_color_pp_view,
&sampler,
&depth_sampler,
);
Ok(Self {
@ -508,6 +519,7 @@ impl Renderer {
tgt_color_pp_view,
sampler,
depth_sampler,
shadow_map,
shadow_bind,
@ -589,6 +601,7 @@ impl Renderer {
&self.tgt_depth_view,
&self.tgt_color_pp_view,
&self.sampler,
&self.depth_sampler,
);
if let (ShadowMap::Enabled(shadow_map), ShadowMode::Map(mode)) =