Skip to main content

D3d12FrameRenderer

Trait D3d12FrameRenderer 

Source
pub trait D3d12FrameRenderer: Send {
    // Required methods
    fn device(&self) -> ID3D12Device;
    unsafe fn submit_yuv420p(
        &self,
        y: RawPlane,
        u: RawPlane,
        v: RawPlane,
        width: u32,
        height: u32,
    ) -> Result<(), SubmitError>;
    unsafe fn submit_nv12_texture(
        &self,
        texture: ID3D12Resource,
        fence: ID3D12Fence,
        fence_value: u64,
        width: u32,
        height: u32,
        keep_alive: Box<dyn Any + Send>,
    ) -> Result<(), SubmitError>;
    fn resize(&self, width: u32, height: u32) -> Result<(), SubmitError>;
}
Available on Windows and crate feature d3d12 and (crate features d3d11 or d3d12 or wasapi-renderer) only.
Expand description

What D3d12Renderer needs from an actual DX12 window/rendering implementation — deliberately the only thing this crate knows about D3D12 rendering. Not GPU-vendor-agnostic despite submit_yuv420p’s plain RawPlane args: submit_nv12_texture’s zero-copy path takes ID3D12Resource/ID3D12Fence directly, so this trait (and any element built on it) is inherently D3D12-only — a Vulkan/CUDA renderer would need its own trait, not an impl of this one. D3d12Renderer itself only depends on this trait (plus the windows COM types the zero-copy path needs to pass through) — not on renderer_engine or any other concrete rendering crate. A caller wanting to actually render implements this for its own window/rendering stack; this repository’s examples use examples/render/render_common for that implementation, outside the media-pp crate itself.

Required Methods§

Source

fn device(&self) -> ID3D12Device

The ID3D12Device this implementation actually renders/submits with. D3d12Renderer reads this once at construction to guard D3d12FrameRenderer::submit_nv12_texture’s zero-copy path: a texture from a different device is invalid to draw from at all (not just wrong-looking), so it’s checked against this rather than trusted.

Source

unsafe fn submit_yuv420p( &self, y: RawPlane, u: RawPlane, v: RawPlane, width: u32, height: u32, ) -> Result<(), SubmitError>

§Safety

All plane pointers must be readable for the given length and remain valid until this call returns.

Source

unsafe fn submit_nv12_texture( &self, texture: ID3D12Resource, fence: ID3D12Fence, fence_value: u64, width: u32, height: u32, keep_alive: Box<dyn Any + Send>, ) -> Result<(), SubmitError>

§Safety

texture must be a valid ID3D12Resource on the same ID3D12Device this renderer was created with, laid out as NV12. fence must only reach fence_value once the GPU work that produced texture’s contents has completed.

Source

fn resize(&self, width: u32, height: u32) -> Result<(), SubmitError>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§