azul_webrender

Struct Device

Source
pub struct Device { /* private fields */ }

Implementations§

Source§

impl Device

Source

pub fn new( gl: Rc<GenericGlContext>, crash_annotator: Option<Box<dyn CrashAnnotator>>, resource_override_path: Option<PathBuf>, use_optimized_shaders: bool, upload_method: UploadMethod, cached_programs: Option<Rc<ProgramCache>>, allow_texture_storage_support: bool, allow_texture_swizzling: bool, dump_shader_source: Option<String>, surface_origin_is_top_left: bool, _panic_on_gl_error: bool, ) -> Device

Source

pub fn gl(&self) -> &GenericGlContext

Source

pub fn rc_gl(&self) -> &Rc<GenericGlContext>

Source

pub fn clamp_max_texture_size(&mut self, size: i32)

Ensures that the maximum texture size is less than or equal to the provided value. If the provided value is less than the value supported by the driver, the latter is used.

Source

pub fn max_texture_size(&self) -> i32

Returns the limit on texture dimensions (width or height).

Source

pub fn surface_origin_is_top_left(&self) -> bool

Source

pub fn get_capabilities(&self) -> &Capabilities

Source

pub fn preferred_color_formats(&self) -> TextureFormatPair<ImageFormat>

Source

pub fn swizzle_settings(&self) -> Option<SwizzleSettings>

Source

pub fn depth_bits(&self) -> i32

Source

pub fn max_depth_ids(&self) -> i32

Source

pub fn ortho_near_plane(&self) -> f32

Source

pub fn ortho_far_plane(&self) -> f32

Source

pub fn required_pbo_stride(&self) -> StrideAlignment

Source

pub fn upload_method(&self) -> &UploadMethod

Source

pub fn use_batched_texture_uploads(&self) -> bool

Source

pub fn use_draw_calls_for_texture_copy(&self) -> bool

Source

pub fn set_use_batched_texture_uploads(&mut self, enabled: bool)

Source

pub fn set_use_draw_calls_for_texture_copy(&mut self, enabled: bool)

Source

pub fn reset_state(&mut self)

Source

pub fn compile_shader( &self, name: &str, shader_type: GLenum, source: &String, ) -> Result<GLuint, ShaderError>

Source

pub fn begin_frame(&mut self) -> GpuFrameId

Source

pub fn bind_texture<S>(&mut self, slot: S, texture: &Texture, swizzle: Swizzle)
where S: Into<TextureSlot>,

Source

pub fn bind_external_texture<S>( &mut self, slot: S, external_texture: &ExternalTexture, )
where S: Into<TextureSlot>,

Source

pub fn bind_read_target_impl(&mut self, fbo_id: FBOId, offset: DeviceIntPoint)

Source

pub fn bind_read_target(&mut self, target: ReadTarget)

Source

pub fn reset_read_target(&mut self)

Source

pub fn reset_draw_target(&mut self)

Source

pub fn bind_draw_target(&mut self, target: DrawTarget)

Source

pub fn create_fbo(&mut self) -> FBOId

Creates an unbound FBO object. Additional attachment API calls are required to make it complete.

Source

pub fn create_fbo_for_external_texture(&mut self, texture_id: u32) -> FBOId

Creates an FBO with the given texture bound as the color attachment.

Source

pub fn delete_fbo(&mut self, fbo: FBOId)

Source

pub fn bind_external_draw_target(&mut self, fbo_id: FBOId)

Link a program, attaching the supplied vertex format.

If create_program() finds a binary shader on disk, it will kick off linking immediately, which some drivers (notably ANGLE) run in parallel on background threads. As such, this function should ideally be run sometime later, to give the driver time to do that before blocking due to an API call accessing the shader.

This generally means that the first run of the application will have to do a bunch of blocking work to compile the shader from source, but subsequent runs should load quickly.

Source

pub fn bind_program(&mut self, program: &Program) -> bool

Source

pub fn create_texture( &mut self, target: ImageBufferKind, format: ImageFormat, width: i32, height: i32, filter: TextureFilter, render_target: Option<RenderTargetInfo>, ) -> Texture

Source

pub fn copy_entire_texture(&mut self, dst: &mut Texture, src: &Texture)

Copies the entire contents of one texture to another. The dest texture must be at least as large as the source texture in each dimension. No scaling is performed, so if the dest texture is larger than the source texture then some of its pixels will not be written to.

Source

pub fn copy_texture_sub_region( &mut self, src_texture: &Texture, src_x: usize, src_y: usize, dest_texture: &Texture, dest_x: usize, dest_y: usize, width: usize, height: usize, )

Copies the specified subregion from src_texture to dest_texture.

Source

pub fn invalidate_render_target(&mut self, texture: &Texture)

Notifies the device that the contents of a render target are no longer needed.

Source

pub fn invalidate_depth_target(&mut self)

Notifies the device that the contents of the current framebuffer’s depth attachment is no longer needed. Unlike invalidate_render_target, this can be called even when the contents of the colour attachment is still required. This should be called before unbinding the framebuffer at the end of a pass, to allow tiled GPUs to avoid writing the contents back to memory.

Source

pub fn reuse_render_target<T: Texel>( &mut self, texture: &mut Texture, rt_info: RenderTargetInfo, )

Notifies the device that a render target is about to be reused.

This method adds or removes a depth target as necessary.

Source

pub fn blit_render_target( &mut self, src_target: ReadTarget, src_rect: FramebufferIntRect, dest_target: DrawTarget, dest_rect: FramebufferIntRect, filter: TextureFilter, )

Perform a blit between src_target and dest_target. This will overwrite self.bound_read_fbo and self.bound_draw_fbo.

Source

pub fn blit_render_target_invert_y( &mut self, src_target: ReadTarget, src_rect: FramebufferIntRect, dest_target: DrawTarget, dest_rect: FramebufferIntRect, )

Performs a blit while flipping vertically. Useful for blitting textures (which use origin-bottom-left) to the main framebuffer (which uses origin-top-left).

Source

pub fn delete_texture(&mut self, texture: Texture)

Source

pub fn delete_program(&mut self, program: Program)

Source

pub fn create_program_linked( &mut self, base_filename: &'static str, features: &[&'static str], descriptor: &VertexDescriptor, ) -> Result<Program, ShaderError>

Create a shader program and link it immediately.

Source

pub fn create_program( &mut self, base_filename: &'static str, features: &[&'static str], ) -> Result<Program, ShaderError>

Create a shader program. This does minimal amount of work to start loading a binary shader. If a binary shader is found, we invoke glProgramBinary, which, at least on ANGLE, will load and link the binary on a background thread. This can speed things up later when we invoke link_program().

Source

pub fn bind_shader_samplers<S>( &mut self, program: &Program, bindings: &[(&'static str, S)], )
where S: Into<TextureSlot> + Copy,

Source

pub fn get_uniform_location( &self, program: &Program, name: &str, ) -> UniformLocation

Source

pub fn set_uniforms(&self, program: &Program, transform: &Transform3D<f32>)

Source

pub fn switch_mode(&self, mode: i32)

Source

pub fn set_shader_texture_size( &self, program: &Program, texture_size: DeviceSize, )

Sets the uTextureSize uniform. Most shaders do not require this to be called as they use the textureSize GLSL function instead.

Source

pub fn create_pbo(&mut self) -> PBO

Source

pub fn create_pbo_with_size(&mut self, size: usize) -> PBO

Source

pub fn read_pixels_into_pbo( &mut self, read_target: ReadTarget, rect: DeviceIntRect, format: ImageFormat, pbo: &PBO, )

Source

pub fn map_pbo_for_readback<'a>( &'a mut self, pbo: &'a PBO, ) -> Option<BoundPBO<'a>>

Source

pub fn delete_pbo(&mut self, pbo: PBO)

Source

pub fn required_upload_size_and_stride( &self, size: DeviceIntSize, format: ImageFormat, ) -> (usize, usize)

Returns the size and stride in bytes required to upload an area of pixels of the specified size, to a texture of the specified format.

Source

pub fn upload_texture<'a>( &mut self, pbo_pool: &'a mut UploadPBOPool, ) -> TextureUploader<'a>

Returns a TextureUploader which can be used to upload texture data to texture. Once uploads have been performed the uploader must be flushed with TextureUploader::flush().

Source

pub fn upload_texture_immediate<T: Texel>( &mut self, texture: &Texture, pixels: &[T], )

Performs an immediate (non-PBO) texture upload.

Source

pub fn read_pixels(&mut self, img_desc: &ImageDescriptor) -> Vec<u8>

Source

pub fn read_pixels_into( &mut self, rect: FramebufferIntRect, format: ImageFormat, output: &mut [u8], )

Read rectangle of pixels into the specified output slice.

Source

pub fn get_tex_image_into( &mut self, texture: &Texture, format: ImageFormat, output: &mut [u8], )

Get texels of a texture into the specified output slice.

Source

pub fn attach_read_texture_external( &mut self, texture_id: GLuint, target: ImageBufferKind, )

Source

pub fn attach_read_texture(&mut self, texture: &Texture)

Source

pub fn bind_vao(&mut self, vao: &VAO)

Source

pub fn bind_custom_vao(&mut self, vao: &CustomVAO)

Source

pub fn create_custom_vao(&mut self, streams: &[Stream<'_>]) -> CustomVAO

Source

pub fn delete_custom_vao(&mut self, vao: CustomVAO)

Source

pub fn create_vbo<T>(&mut self) -> VBO<T>

Source

pub fn delete_vbo<T>(&mut self, vbo: VBO<T>)

Source

pub fn create_vao( &mut self, descriptor: &VertexDescriptor, instance_divisor: u32, ) -> VAO

Source

pub fn delete_vao(&mut self, vao: VAO)

Source

pub fn allocate_vbo<V>( &mut self, vbo: &mut VBO<V>, count: usize, usage_hint: VertexUsageHint, )

Source

pub fn fill_vbo<V>(&mut self, vbo: &VBO<V>, data: &[V], offset: usize)

Source

pub fn create_vao_with_new_instances( &mut self, descriptor: &VertexDescriptor, base_vao: &VAO, ) -> VAO

Source

pub fn update_vao_main_vertices<V>( &mut self, vao: &VAO, vertices: &[V], usage_hint: VertexUsageHint, )

Source

pub fn update_vao_instances<V: Clone>( &mut self, vao: &VAO, instances: &[V], usage_hint: VertexUsageHint, repeat: Option<NonZeroUsize>, )

Source

pub fn update_vao_indices<I>( &mut self, vao: &VAO, indices: &[I], usage_hint: VertexUsageHint, )

Source

pub fn draw_triangles_u16(&mut self, first_vertex: i32, index_count: i32)

Source

pub fn draw_triangles_u32(&mut self, first_vertex: i32, index_count: i32)

Source

pub fn draw_nonindexed_points(&mut self, first_vertex: i32, vertex_count: i32)

Source

pub fn draw_nonindexed_lines(&mut self, first_vertex: i32, vertex_count: i32)

Source

pub fn draw_indexed_triangles(&mut self, index_count: i32)

Source

pub fn draw_indexed_triangles_instanced_u16( &mut self, index_count: i32, instance_count: i32, )

Source

pub fn end_frame(&mut self)

Source

pub fn clear_target( &self, color: Option<[f32; 4]>, depth: Option<f32>, rect: Option<FramebufferIntRect>, )

Source

pub fn enable_depth(&self, depth_func: DepthFunction)

Source

pub fn disable_depth(&self)

Source

pub fn enable_depth_write(&self)

Source

pub fn disable_depth_write(&self)

Source

pub fn disable_stencil(&self)

Source

pub fn set_scissor_rect(&self, rect: FramebufferIntRect)

Source

pub fn enable_scissor(&self)

Source

pub fn disable_scissor(&self)

Source

pub fn enable_color_write(&self)

Source

pub fn disable_color_write(&self)

Source

pub fn set_blend(&mut self, enable: bool)

Source

pub fn set_blend_mode_alpha(&mut self)

Source

pub fn set_blend_mode_premultiplied_alpha(&mut self)

Source

pub fn set_blend_mode_premultiplied_dest_out(&mut self)

Source

pub fn set_blend_mode_multiply(&mut self)

Source

pub fn set_blend_mode_subpixel_pass0(&mut self)

Source

pub fn set_blend_mode_subpixel_pass1(&mut self)

Source

pub fn set_blend_mode_subpixel_with_bg_color_pass0(&mut self)

Source

pub fn set_blend_mode_subpixel_with_bg_color_pass1(&mut self)

Source

pub fn set_blend_mode_subpixel_with_bg_color_pass2(&mut self)

Source

pub fn set_blend_mode_subpixel_constant_text_color(&mut self, color: ColorF)

Source

pub fn set_blend_mode_subpixel_dual_source(&mut self)

Source

pub fn set_blend_mode_multiply_dual_source(&mut self)

Source

pub fn set_blend_mode_screen(&mut self)

Source

pub fn set_blend_mode_exclusion(&mut self)

Source

pub fn set_blend_mode_show_overdraw(&mut self)

Source

pub fn set_blend_mode_max(&mut self)

Source

pub fn set_blend_mode_min(&mut self)

Source

pub fn set_blend_mode_advanced(&mut self, mode: MixBlendMode)

Source

pub fn supports_extension(&self, extension: &str) -> bool

Source

pub fn echo_driver_messages(&self)

Source

pub fn gl_describe_format(&self, format: ImageFormat) -> FormatDesc

Source

pub fn report_memory( &self, size_op_funs: &MallocSizeOfOps, swgl: *mut c_void, ) -> MemoryReport

Generates a memory report for the resources managed by the device layer.

Source

pub fn depth_targets_memory(&self) -> usize

Auto Trait Implementations§

§

impl Freeze for Device

§

impl !RefUnwindSafe for Device

§

impl !Send for Device

§

impl !Sync for Device

§

impl Unpin for Device

§

impl !UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.