Skip to content

Create a new buffer if necessary when setting an existing Graphic #869

Closed

Description

@kushalkolar

We can implement this pretty easily, would make things easier for users, tradeoff is that users are less aware that setting data this way is slower than setting data that fits in an existing buffer. We can just document it well.

image = fig[0, 0].add_image(np.random.rand(10, 10))

# allow this, internally delete the existing buffer 
# and world object and create a new one
image.data = np.random.rand(20, 20)

Might not have to create a new world object, might be possible to just replace the geometry I think.

Activity

  1. clewis7 commented on Jun 30, 2025

    @clewis7
    Member

    I think this would be more flexible, but I think it is only worth doing if we are able to handle the change without creating a new world object.

    We should also probably benchmark here how much time this would really take. Imagine you are trying to change the data to something much larger: np.random.rand(3_000, 3_000). Maybe it would be more cost-efficient to just remove the graphic and add a new one, but idk

  2. kushalkolar commented on Jul 1, 2025

    @kushalkolar
    MemberAuthor

    Yea this should be be benchmarked and good idea with keeping the world object because events are actually added to it.

    For this to work the buffer reference on the buffer manager needs to be changed as well as on the geometry, and garbage collection must occur if the buffer is isolated.

  3. kushalkolar commented on Oct 18, 2025

    @kushalkolar
    MemberAuthor

    I also wonder how this could be done such that if the buffer is shared between objects, the shared buffer updates too 🤔

  4. kushalkolar commented on Dec 1, 2025

    @kushalkolar
    MemberAuthor

    I got a better idea of how to do this after doing polygon vertex data stuff in #954

  5. changed the title [-]Create a new buffer and world object if necessary when setting an existing Graphic[/-] [+]Create a new buffer if necessary when setting an existing Graphic[/+] on Dec 2, 2025
  6. kushalkolar commented on Jan 13, 2026

    @kushalkolar
    MemberAuthor

    I've started implementing this, will make the NDWidget easier in some ways.

    I'm going to get rid of isolated_buffer, because that was only for special usecases if you wanted to use a huge buffers on the GPU and not create a new huge buffer on system RAM as well. However, OOC rendering and LOD levels is the better way to do this.

  7. kushalkolar commented on Aug 4, 2026

    @kushalkolar
    MemberAuthor

    done in #869

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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