bevy_render/render_resource/
texture.rs1use crate::renderer::{wgpu_wrapper, RenderDevice, RenderQueue};
2use bevy_derive::{Deref, DerefMut};
3use bevy_ecs::{
4 resource::Resource,
5 world::{FromWorld, World},
6};
7use bevy_image::ImageSamplerDescriptor;
8use bevy_utils::define_atomic_id;
9use core::ops::Deref;
10
11pub struct TextureId(::core::num::NonZero<u32>);
#[automatically_derived]impl ::core::marker::Copy for TextureId { }
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for TextureId {
}
#[automatically_derived]impl ::core::clone::Clone for TextureId {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<::core::num::NonZero<u32>>;
*self
}
}
#[automatically_derived]impl ::core::hash::Hash for TextureId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
#[automatically_derived]impl ::core::cmp::Eq for TextureId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<::core::num::NonZero<u32>>;
}
}
#[automatically_derived]impl ::core::marker::StructuralPartialEq for TextureId
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for TextureId {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]impl ::core::cmp::PartialOrd for TextureId {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}
#[automatically_derived]impl ::core::cmp::Ord for TextureId {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]impl ::core::fmt::Debug for TextureId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "TextureId",
&&self.0)
}
}
impl TextureId {
#[expect(clippy :: new_without_default, reason =
"Implementing the `Default` trait on atomic IDs would imply that two `<AtomicIdType>::default()` equal each other. By only implementing `new()`, we indicate that each atomic ID created will be unique.")]
pub fn new() -> Self {
use ::core::sync::atomic::{AtomicU32, Ordering};
static COUNTER: AtomicU32 = AtomicU32::new(1);
let counter = COUNTER.fetch_add(1, Ordering::Relaxed);
Self(::core::num::NonZero::<u32>::new(counter).unwrap_or_else(||
{
{
::core::panicking::panic_fmt(format_args!("The system ran out of unique `{0}`s.",
"TextureId"));
};
}))
}
}
impl ::core::convert::From<TextureId> for ::core::num::NonZero<u32> {
fn from(value: TextureId) -> Self { value.0 }
}
impl ::core::convert::From<::core::num::NonZero<u32>> for TextureId {
fn from(value: ::core::num::NonZero<u32>) -> Self { Self(value) }
}define_atomic_id!(TextureId);
12
13struct WgpuTexture(wgpu::Texture);
#[automatically_derived]impl ::core::clone::Clone for WgpuTexture {
#[inline]
fn clone(&self) -> Self {
WgpuTexture(::core::clone::Clone::clone(&self.0))
}
}
#[automatically_derived]impl ::core::fmt::Debug for WgpuTexture {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "WgpuTexture",
&&self.0)
}
}
impl WgpuTexture {
pub fn new(t: wgpu::Texture) -> Self { Self(t) }
#[allow(clippy :: allow_attributes, unused, reason =
"This is not used on all wrappers.")]
pub fn into_inner(self) -> wgpu::Texture { self.0 }
}
impl ::core::ops::Deref for WgpuTexture {
type Target = wgpu::Texture;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl ::core::ops::DerefMut for WgpuTexture {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}
const _: () =
{
const fn assert_sync_send<T: Sync + Send>() {}
assert_sync_send::<wgpu::Texture>()
};
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Send for WgpuTexture { }
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Sync for WgpuTexture { }wgpu_wrapper! {
14 #[derive(Clone, Debug)]
15 struct WgpuTexture(wgpu::Texture);
16}
17
18#[derive(#[automatically_derived]impl ::core::clone::Clone for Texture {
#[inline]
fn clone(&self) -> Self {
Texture {
id: ::core::clone::Clone::clone(&self.id),
value: ::core::clone::Clone::clone(&self.value),
}
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Texture {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Texture", "id",
&self.id, "value", &&self.value)
}
}Debug)]
32pub struct Texture {
33 id: TextureId,
34 value: WgpuTexture,
35}
36
37impl Texture {
38 #[inline]
40 pub fn id(&self) -> TextureId {
41 self.id
42 }
43
44 pub fn create_view(&self, desc: &wgpu::TextureViewDescriptor) -> TextureView {
46 TextureView::from(self.value.create_view(desc))
47 }
48}
49
50impl From<wgpu::Texture> for Texture {
51 fn from(value: wgpu::Texture) -> Self {
52 Texture {
53 id: TextureId::new(),
54 value: WgpuTexture::new(value),
55 }
56 }
57}
58
59impl Deref for Texture {
60 type Target = wgpu::Texture;
61
62 #[inline]
63 fn deref(&self) -> &Self::Target {
64 &self.value
65 }
66}
67
68pub struct TextureViewId(::core::num::NonZero<u32>);
#[automatically_derived]impl ::core::marker::Copy for TextureViewId { }
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for TextureViewId {
}
#[automatically_derived]impl ::core::clone::Clone for TextureViewId {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<::core::num::NonZero<u32>>;
*self
}
}
#[automatically_derived]impl ::core::hash::Hash for TextureViewId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
#[automatically_derived]impl ::core::cmp::Eq for TextureViewId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<::core::num::NonZero<u32>>;
}
}
#[automatically_derived]impl ::core::marker::StructuralPartialEq for
TextureViewId {
}
#[automatically_derived]impl ::core::cmp::PartialEq for TextureViewId {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]impl ::core::cmp::PartialOrd for TextureViewId {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}
#[automatically_derived]impl ::core::cmp::Ord for TextureViewId {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]impl ::core::fmt::Debug for TextureViewId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "TextureViewId",
&&self.0)
}
}
impl TextureViewId {
#[expect(clippy :: new_without_default, reason =
"Implementing the `Default` trait on atomic IDs would imply that two `<AtomicIdType>::default()` equal each other. By only implementing `new()`, we indicate that each atomic ID created will be unique.")]
pub fn new() -> Self {
use ::core::sync::atomic::{AtomicU32, Ordering};
static COUNTER: AtomicU32 = AtomicU32::new(1);
let counter = COUNTER.fetch_add(1, Ordering::Relaxed);
Self(::core::num::NonZero::<u32>::new(counter).unwrap_or_else(||
{
{
::core::panicking::panic_fmt(format_args!("The system ran out of unique `{0}`s.",
"TextureViewId"));
};
}))
}
}
impl ::core::convert::From<TextureViewId> for ::core::num::NonZero<u32> {
fn from(value: TextureViewId) -> Self { value.0 }
}
impl ::core::convert::From<::core::num::NonZero<u32>> for TextureViewId {
fn from(value: ::core::num::NonZero<u32>) -> Self { Self(value) }
}define_atomic_id!(TextureViewId);
69
70struct WgpuTextureView(wgpu::TextureView);
#[automatically_derived]impl ::core::clone::Clone for WgpuTextureView {
#[inline]
fn clone(&self) -> Self {
WgpuTextureView(::core::clone::Clone::clone(&self.0))
}
}
#[automatically_derived]impl ::core::fmt::Debug for WgpuTextureView {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"WgpuTextureView", &&self.0)
}
}
impl WgpuTextureView {
pub fn new(t: wgpu::TextureView) -> Self { Self(t) }
#[allow(clippy :: allow_attributes, unused, reason =
"This is not used on all wrappers.")]
pub fn into_inner(self) -> wgpu::TextureView { self.0 }
}
impl ::core::ops::Deref for WgpuTextureView {
type Target = wgpu::TextureView;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl ::core::ops::DerefMut for WgpuTextureView {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}
const _: () =
{
const fn assert_sync_send<T: Sync + Send>() {}
assert_sync_send::<wgpu::TextureView>()
};
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Send for WgpuTextureView { }
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Sync for WgpuTextureView { }
struct WgpuSurfaceTexture(wgpu::SurfaceTexture);
impl WgpuSurfaceTexture {
pub fn new(t: wgpu::SurfaceTexture) -> Self { Self(t) }
#[allow(clippy :: allow_attributes, unused, reason =
"This is not used on all wrappers.")]
pub fn into_inner(self) -> wgpu::SurfaceTexture { self.0 }
}
impl ::core::ops::Deref for WgpuSurfaceTexture {
type Target = wgpu::SurfaceTexture;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl ::core::ops::DerefMut for WgpuSurfaceTexture {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}
const _: () =
{
const fn assert_sync_send<T: Sync + Send>() {}
assert_sync_send::<wgpu::SurfaceTexture>()
};
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Send for WgpuSurfaceTexture { }
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Sync for WgpuSurfaceTexture { }wgpu_wrapper! {
71 #[derive(Clone, Debug)]
72 struct WgpuTextureView(wgpu::TextureView);
73
74 struct WgpuSurfaceTexture(wgpu::SurfaceTexture);
75}
76
77#[derive(#[automatically_derived]impl ::core::clone::Clone for TextureView {
#[inline]
fn clone(&self) -> Self {
TextureView {
id: ::core::clone::Clone::clone(&self.id),
value: ::core::clone::Clone::clone(&self.value),
}
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for TextureView {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "TextureView",
"id", &self.id, "value", &&self.value)
}
}Debug)]
79pub struct TextureView {
80 id: TextureViewId,
81 value: WgpuTextureView,
82}
83
84pub struct SurfaceTexture {
85 value: WgpuSurfaceTexture,
86}
87
88impl SurfaceTexture {
89 pub fn present(self, render_queue: &RenderQueue) {
90 render_queue.present(self.value.into_inner());
91 }
92}
93
94impl TextureView {
95 #[inline]
97 pub fn id(&self) -> TextureViewId {
98 self.id
99 }
100}
101
102impl From<wgpu::TextureView> for TextureView {
103 fn from(value: wgpu::TextureView) -> Self {
104 TextureView {
105 id: TextureViewId::new(),
106 value: WgpuTextureView::new(value),
107 }
108 }
109}
110
111impl From<wgpu::SurfaceTexture> for SurfaceTexture {
112 fn from(value: wgpu::SurfaceTexture) -> Self {
113 SurfaceTexture {
114 value: WgpuSurfaceTexture::new(value),
115 }
116 }
117}
118
119impl Deref for TextureView {
120 type Target = wgpu::TextureView;
121
122 #[inline]
123 fn deref(&self) -> &Self::Target {
124 &self.value
125 }
126}
127
128impl Deref for SurfaceTexture {
129 type Target = wgpu::SurfaceTexture;
130
131 #[inline]
132 fn deref(&self) -> &Self::Target {
133 &self.value
134 }
135}
136
137pub struct SamplerId(::core::num::NonZero<u32>);
#[automatically_derived]impl ::core::marker::Copy for SamplerId { }
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for SamplerId {
}
#[automatically_derived]impl ::core::clone::Clone for SamplerId {
#[inline]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<::core::num::NonZero<u32>>;
*self
}
}
#[automatically_derived]impl ::core::hash::Hash for SamplerId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
#[automatically_derived]impl ::core::cmp::Eq for SamplerId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<::core::num::NonZero<u32>>;
}
}
#[automatically_derived]impl ::core::marker::StructuralPartialEq for SamplerId
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for SamplerId {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]impl ::core::cmp::PartialOrd for SamplerId {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}
#[automatically_derived]impl ::core::cmp::Ord for SamplerId {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]impl ::core::fmt::Debug for SamplerId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "SamplerId",
&&self.0)
}
}
impl SamplerId {
#[expect(clippy :: new_without_default, reason =
"Implementing the `Default` trait on atomic IDs would imply that two `<AtomicIdType>::default()` equal each other. By only implementing `new()`, we indicate that each atomic ID created will be unique.")]
pub fn new() -> Self {
use ::core::sync::atomic::{AtomicU32, Ordering};
static COUNTER: AtomicU32 = AtomicU32::new(1);
let counter = COUNTER.fetch_add(1, Ordering::Relaxed);
Self(::core::num::NonZero::<u32>::new(counter).unwrap_or_else(||
{
{
::core::panicking::panic_fmt(format_args!("The system ran out of unique `{0}`s.",
"SamplerId"));
};
}))
}
}
impl ::core::convert::From<SamplerId> for ::core::num::NonZero<u32> {
fn from(value: SamplerId) -> Self { value.0 }
}
impl ::core::convert::From<::core::num::NonZero<u32>> for SamplerId {
fn from(value: ::core::num::NonZero<u32>) -> Self { Self(value) }
}define_atomic_id!(SamplerId);
138
139struct WgpuSampler(wgpu::Sampler);
#[automatically_derived]impl ::core::clone::Clone for WgpuSampler {
#[inline]
fn clone(&self) -> Self {
WgpuSampler(::core::clone::Clone::clone(&self.0))
}
}
#[automatically_derived]impl ::core::fmt::Debug for WgpuSampler {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "WgpuSampler",
&&self.0)
}
}
impl WgpuSampler {
pub fn new(t: wgpu::Sampler) -> Self { Self(t) }
#[allow(clippy :: allow_attributes, unused, reason =
"This is not used on all wrappers.")]
pub fn into_inner(self) -> wgpu::Sampler { self.0 }
}
impl ::core::ops::Deref for WgpuSampler {
type Target = wgpu::Sampler;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl ::core::ops::DerefMut for WgpuSampler {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}
const _: () =
{
const fn assert_sync_send<T: Sync + Send>() {}
assert_sync_send::<wgpu::Sampler>()
};
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Send for WgpuSampler { }
#[expect(unsafe_code, reason = "Blanket-impl Send requires unsafe.")]
unsafe impl Sync for WgpuSampler { }wgpu_wrapper! {
140 #[derive(Clone, Debug)]
141 struct WgpuSampler(wgpu::Sampler);
142}
143
144#[derive(#[automatically_derived]impl ::core::clone::Clone for Sampler {
#[inline]
fn clone(&self) -> Self {
Sampler {
id: ::core::clone::Clone::clone(&self.id),
value: ::core::clone::Clone::clone(&self.value),
}
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Sampler {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Sampler", "id",
&self.id, "value", &&self.value)
}
}Debug)]
150pub struct Sampler {
151 id: SamplerId,
152 value: WgpuSampler,
153}
154
155impl Sampler {
156 #[inline]
158 pub fn id(&self) -> SamplerId {
159 self.id
160 }
161}
162
163impl From<wgpu::Sampler> for Sampler {
164 fn from(value: wgpu::Sampler) -> Self {
165 Sampler {
166 id: SamplerId::new(),
167 value: WgpuSampler::new(value),
168 }
169 }
170}
171
172impl Deref for Sampler {
173 type Target = wgpu::Sampler;
174
175 #[inline]
176 fn deref(&self) -> &Self::Target {
177 &self.value
178 }
179}
180
181#[derive(impl bevy_ecs::component::Component for DefaultImageSamplerDescriptor where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {
const STORAGE_TYPE: bevy_ecs::component::StorageType =
bevy_ecs::component::StorageType::SparseSet;
type Mutability = bevy_ecs::component::Mutable;
fn register_required_components(_requiree:
bevy_ecs::component::ComponentId,
required_components:
&mut bevy_ecs::component::RequiredComponentsRegistrator) {
let resource_component_id =
if let ::core::option::Option::Some(id) =
required_components.components_registrator().component_id::<DefaultImageSamplerDescriptor>()
{
id
} else {
required_components.components_registrator().register_component::<DefaultImageSamplerDescriptor>()
};
required_components.register_required::<bevy_ecs::resource::IsResource>(move
||
bevy_ecs::resource::IsResource::new(resource_component_id));
}
fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
use bevy_ecs::component::{
DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
};
(&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
}
fn relationship_accessor()
->
::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
::core::option::Option::None
}
}
impl bevy_ecs::resource::Resource for DefaultImageSamplerDescriptor where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Resource, #[automatically_derived]impl ::core::fmt::Debug for
DefaultImageSamplerDescriptor {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DefaultImageSamplerDescriptor", &&self.0)
}
}Debug, #[automatically_derived]impl ::core::clone::Clone for
DefaultImageSamplerDescriptor {
#[inline]
fn clone(&self) -> Self {
DefaultImageSamplerDescriptor(::core::clone::Clone::clone(&self.0))
}
}Clone, impl ::core::ops::Deref for DefaultImageSamplerDescriptor {
type Target = ImageSamplerDescriptor;
fn deref(&self) -> &Self::Target { &self.0 }
}Deref)]
185pub struct DefaultImageSamplerDescriptor(pub ImageSamplerDescriptor);
186
187#[derive(impl bevy_ecs::component::Component for DefaultImageSampler where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {
const STORAGE_TYPE: bevy_ecs::component::StorageType =
bevy_ecs::component::StorageType::SparseSet;
type Mutability = bevy_ecs::component::Mutable;
fn register_required_components(_requiree:
bevy_ecs::component::ComponentId,
required_components:
&mut bevy_ecs::component::RequiredComponentsRegistrator) {
let resource_component_id =
if let ::core::option::Option::Some(id) =
required_components.components_registrator().component_id::<DefaultImageSampler>()
{
id
} else {
required_components.components_registrator().register_component::<DefaultImageSampler>()
};
required_components.register_required::<bevy_ecs::resource::IsResource>(move
||
bevy_ecs::resource::IsResource::new(resource_component_id));
}
fn clone_behavior() -> bevy_ecs::component::ComponentCloneBehavior {
use bevy_ecs::component::{
DefaultCloneBehaviorBase, DefaultCloneBehaviorViaClone,
};
(&&&bevy_ecs::component::DefaultCloneBehaviorSpecialization::<Self>::default()).default_clone_behavior()
}
fn relationship_accessor()
->
::core::option::Option<bevy_ecs::relationship::ComponentRelationshipAccessor<Self>> {
::core::option::Option::None
}
}
impl bevy_ecs::resource::Resource for DefaultImageSampler where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Resource, #[automatically_derived]impl ::core::fmt::Debug for DefaultImageSampler {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DefaultImageSampler", &&self.0)
}
}Debug, #[automatically_derived]impl ::core::clone::Clone for DefaultImageSampler {
#[inline]
fn clone(&self) -> Self {
DefaultImageSampler(::core::clone::Clone::clone(&self.0))
}
}Clone, impl ::core::ops::Deref for DefaultImageSampler {
type Target = Sampler;
fn deref(&self) -> &Self::Target { &self.0 }
}Deref, impl ::core::ops::DerefMut for DefaultImageSampler {
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}DerefMut)]
193pub struct DefaultImageSampler(pub(crate) Sampler);
194
195impl FromWorld for DefaultImageSampler {
196 fn from_world(world: &mut World) -> Self {
197 let descriptor = world.resource::<DefaultImageSamplerDescriptor>();
198 let wgpu_descriptor = descriptor.as_wgpu();
199 let device = world.resource::<RenderDevice>();
200 let sampler = device.create_sampler(&wgpu_descriptor);
201 Self(sampler)
202 }
203}