Skip to content

Support external image buffer for add_image() #524

Closed
@JerryShih

Description

@JerryShih

Right now, there are some copy in the path from add_image() interface to the final gpu texture uploading in texture_cache module.
The buffer is serialized(so, here is a copy) through the ipc-channel at [1].
If we are playing a video, it's a big performance impact for every frame's copy-op.

In quantum project, I'm trying to pass raw_buffer_ptr through FFI and serialize the raw_ptr using my custom serializer.

The data enum will like:

pub enum ExternalImage {
    // shmem or memory buffer
    MemoryBuff {
        buff: *const u8,  // the raw_buffer ptr from c++
        size: usize,
    }
}

The serialization/deserialization code is at [2].
With this enum, we could have the new interface "AddExternalImage()" in WR and pass the "buff: *const u8" to gl texture with the minimizing copy.
There will have life-time and sync problem for this raw-buffer. If we can handle the the persistence and thread problem in gecko for this buffer, how about this idea if we try to use WR in gecko or other project?

pub enum ApiMsg {
   ....
  AddExternalImage(ImageKey, u32, u32, ImageFormat, ExternalImage),
}

[1]

self.api_sender.send(msg).unwrap();

[2]
https://gist.github.com/JerryShih/2d4b4738fe0d9d399f90300cdbe6c95d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions