pub struct Texture {
    id: GLuint,
    target: GLuint,
    format: ImageFormat,
    size: DeviceIntSize,
    filter: TextureFilter,
    flags: TextureFlags,
    active_swizzle: Cell<Swizzle>,
    fbo: Option<FBOId>,
    fbo_with_depth: Option<FBOId>,
    last_frame_used: GpuFrameId,
}Expand description
WebRender interface to an OpenGL texture.
Because freeing a texture requires various device handles that are not
reachable from this struct, manual destruction via Device is required.
Our Drop implementation asserts that this has happened.
Fields§
§id: GLuint§target: GLuint§format: ImageFormat§size: DeviceIntSize§filter: TextureFilter§flags: TextureFlags§active_swizzle: Cell<Swizzle>An internally mutable swizzling state that may change between batches.
fbo: Option<FBOId>Framebuffer Object allowing this texture to be rendered to.
Empty if this texture is not used as a render target or if a depth buffer is needed.
fbo_with_depth: Option<FBOId>Same as the above, but with a depth buffer attached.
FBOs are cheap to create but expensive to reconfigure (since doing so invalidates framebuffer completeness caching). Moreover, rendering with a depth buffer attached but the depth write+test disabled relies on the driver to optimize it out of the rendering pass, which most drivers probably do but, according to jgilbert, is best not to rely on.
So we lazily generate a second list of FBOs with depth. This list is empty if this texture is not used as a render target or if it is, but the depth buffer has never been requested.
Note that we always fill fbo, and then lazily create fbo_with_depth when needed. We could make both lazy (i.e. render targets would have one or the other, but not both, unless they were actually used in both configurations). But that would complicate a lot of logic in this module, and FBOs are cheap enough to create.
last_frame_used: GpuFrameIdImplementations§
Source§impl Texture
 
impl Texture
pub fn get_dimensions(&self) -> DeviceIntSize
pub fn get_format(&self) -> ImageFormat
pub fn get_filter(&self) -> TextureFilter
pub fn get_target(&self) -> ImageBufferKind
pub fn supports_depth(&self) -> bool
pub fn last_frame_used(&self) -> GpuFrameId
pub fn used_in_frame(&self, frame_id: GpuFrameId) -> bool
pub fn is_render_target(&self) -> bool
Sourcepub fn used_recently(
    &self,
    current_frame_id: GpuFrameId,
    threshold: usize,
) -> bool
 
pub fn used_recently( &self, current_frame_id: GpuFrameId, threshold: usize, ) -> bool
Returns true if this texture was used within threshold frames of
the current frame.
Sourcepub fn flags(&self) -> &TextureFlags
 
pub fn flags(&self) -> &TextureFlags
Returns the flags for this texture.
Sourcepub fn flags_mut(&mut self) -> &mut TextureFlags
 
pub fn flags_mut(&mut self) -> &mut TextureFlags
Returns a mutable borrow of the flags for this texture.
Sourcepub fn size_in_bytes(&self) -> usize
 
pub fn size_in_bytes(&self) -> usize
Returns the number of bytes (generally in GPU memory) that this texture consumes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Texture
impl !RefUnwindSafe for Texture
impl Send for Texture
impl !Sync for Texture
impl Unpin for Texture
impl UnwindSafe for Texture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more