Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawing more than 50 images to a scene #60

Open
claydugo opened this issue Jul 20, 2023 · 2 comments
Open

Drawing more than 50 images to a scene #60

claydugo opened this issue Jul 20, 2023 · 2 comments

Comments

@claydugo
Copy link

I am attempting to draw more than 50 images to a panel but I seem to be hitting some sort of limit.

For testing I am using 1x1 pixel images so it seems to be a texture limit and not data related.

If I increase DVZ_MAX_FIFO_CAPACITY I can get 64 images to draw and then it begins to crash again.

Is there a better way to display many images to a scene?

Below is the script I am using to test.

import numpy as np
from datoviz import canvas, run


def tile_image(panel, image_shape, index, texture):
    visual = panel.visual('image', transform='init')
    visual.data('pos', np.array([[
        image_shape[1] * (index[1] + 1),
        image_shape[0] * (index[0] + 0),
        0,
    ]]), idx=0)  # noqa
    visual.data('pos', np.array([[
        image_shape[1] * (index[1] + 1),
        image_shape[0] * (index[0] + 1),
        0,
    ]]), idx=1)  # noqa
    visual.data('pos', np.array([[
        image_shape[1] * (index[1] + 0),
        image_shape[0] * (index[0] + 1),
        0,
    ]]), idx=2)  # noqa
    visual.data('pos', np.array([[
        image_shape[1] * (index[1] + 0),
        image_shape[0] * (index[0] + 0),
        0,
    ]]), idx=3)  # noqa

    visual.data('texcoords', np.atleast_2d([
        1,
        0,
    ]), idx=0)
    visual.data('texcoords', np.atleast_2d([
        1,
        1,
    ]), idx=1)
    visual.data('texcoords', np.atleast_2d([
        0,
        1,
    ]), idx=2)
    visual.data('texcoords', np.atleast_2d([
        0,
        0,
    ]), idx=3)

    visual.texture(texture)


def add_image(image):
    tex = ctx.texture(image.shape[0], image.shape[1])
    tex.set_filter('linear')
    tex.upload(image)
    return tex


c = canvas(show_fps=True)
panel = c.scene().panel(controller='panzoom')
ctx = c.gpu().context()

shape = (7, 7)

for i in np.ndindex(shape):
    img = np.dstack((
        np.random.randint(0, 256, (1, 1, 4), dtype=np.uint8),
        255 * np.ones((1, 1), dtype=np.uint8)
    ))
    texture = add_image(img)
    tile_image(panel, img.shape[:2], i, texture)

run()

Thank you for taking the time to look at this

@claydugo
Copy link
Author

@hmaarrfk

@hmaarrfk
Copy link
Contributor

Some insights, I tried printing minDepth and maxDepth and it seems that there is a buffer overflow error that is overwriting them:

with shape = (8, 9)

minDepth 0.000000
maxDepth 1.000000
minDepth 0.000000
maxDepth 1.000000
minDepth 0.000000
maxDepth 1.000000
minDepth 5707453190635520.000000
maxDepth 0.000000
python: /home/mark/git/datoviz/src/scene_utils.h:247: _update_visual_viewport: Assertion `(visual->viewport.viewport.minDepth < visual->viewport.viewport.maxDepth)' failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants