Add shader stage visibility and texture usage to TextureBuilder
This commit is contained in:
parent
9cf17a8066
commit
94ade95743
|
@ -14,6 +14,7 @@ pub struct TextureAttributes {
|
||||||
pub mag_filter: wgpu::FilterMode,
|
pub mag_filter: wgpu::FilterMode,
|
||||||
pub min_filter: wgpu::FilterMode,
|
pub min_filter: wgpu::FilterMode,
|
||||||
pub mipmap_filter: wgpu::FilterMode,
|
pub mipmap_filter: wgpu::FilterMode,
|
||||||
|
pub shader_visibility: wgpu::ShaderStages,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TextureAttributes {
|
impl Default for TextureAttributes {
|
||||||
|
@ -29,6 +30,7 @@ impl Default for TextureAttributes {
|
||||||
mag_filter: wgpu::FilterMode::default(),
|
mag_filter: wgpu::FilterMode::default(),
|
||||||
min_filter: wgpu::FilterMode::default(),
|
min_filter: wgpu::FilterMode::default(),
|
||||||
mipmap_filter: wgpu::FilterMode::default(),
|
mipmap_filter: wgpu::FilterMode::default(),
|
||||||
|
shader_visibility: wgpu::ShaderStages::FRAGMENT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +68,12 @@ impl TextureBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn with_usage(mut self, usage: wgpu::TextureUsages) -> Self {
|
||||||
|
self.attributes.usage = usage;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_address_mode(mut self, address_mode: wgpu::AddressMode) -> Self {
|
pub fn with_address_mode(mut self, address_mode: wgpu::AddressMode) -> Self {
|
||||||
self.attributes.address_mode_u = address_mode;
|
self.attributes.address_mode_u = address_mode;
|
||||||
|
@ -82,6 +90,12 @@ impl TextureBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn with_shader_visibility(mut self, visibility: wgpu::ShaderStages) -> Self {
|
||||||
|
self.attributes.shader_visibility = visibility;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn build(self, context: &RenderContext) -> Texture {
|
pub fn build(self, context: &RenderContext) -> Texture {
|
||||||
Texture::new(context, self.attributes)
|
Texture::new(context, self.attributes)
|
||||||
|
@ -89,10 +103,10 @@ impl TextureBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct Texture {
|
pub(crate) struct Texture {
|
||||||
attributes: TextureAttributes,
|
pub attributes: TextureAttributes,
|
||||||
texture: wgpu::Texture,
|
pub texture: wgpu::Texture,
|
||||||
view: wgpu::TextureView,
|
pub view: wgpu::TextureView,
|
||||||
sampler: wgpu::Sampler,
|
pub sampler: wgpu::Sampler,
|
||||||
pub bind_group_layout: wgpu::BindGroupLayout,
|
pub bind_group_layout: wgpu::BindGroupLayout,
|
||||||
pub bind_group: wgpu::BindGroup,
|
pub bind_group: wgpu::BindGroup,
|
||||||
}
|
}
|
||||||
|
@ -130,7 +144,7 @@ impl Texture {
|
||||||
entries: &[
|
entries: &[
|
||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 0,
|
binding: 0,
|
||||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
visibility: attributes.shader_visibility,
|
||||||
ty: wgpu::BindingType::Texture {
|
ty: wgpu::BindingType::Texture {
|
||||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||||
view_dimension: wgpu::TextureViewDimension::D2,
|
view_dimension: wgpu::TextureViewDimension::D2,
|
||||||
|
@ -140,7 +154,7 @@ impl Texture {
|
||||||
},
|
},
|
||||||
wgpu::BindGroupLayoutEntry {
|
wgpu::BindGroupLayoutEntry {
|
||||||
binding: 1,
|
binding: 1,
|
||||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
visibility: attributes.shader_visibility,
|
||||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
|
||||||
count: None,
|
count: None,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue