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

Support for unsigned int in shaders code #2524

Open
Czaki opened this issue Aug 24, 2023 · 3 comments
Open

Support for unsigned int in shaders code #2524

Czaki opened this issue Aug 24, 2023 · 3 comments

Comments

@Czaki
Copy link
Contributor

Czaki commented Aug 24, 2023

As I check, it is not possible to use uint and uvecn in the shaders code. (lack of definition of proper constraints).

In napari, we implement a lookup table (see napari/napari#3308 and napari/napari#6182) for coloring labels. I want to use uint to ensure everything fits, but even if they are in OpenGL specification, they cannot be used with vispy.

Is this intentional, or no one request such a feature and you are open to such a contribution?

@djhoese
Copy link
Member

djhoese commented Aug 24, 2023

What error do you get when you use uint?

@Czaki
Copy link
Contributor Author

Czaki commented Aug 24, 2023

Traceback (most recent call last):
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 903, in paintGL
    self._vispy_canvas.events.draw(region=None)
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/util/event.py", line 453, in __call__
    self._invoke_callback(cb, event)
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    _handle_exception(self.ignore_callback_errors,
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/util/event.py", line 469, in _invoke_callback
    cb(event)
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/scene/canvas.py", line 218, in on_draw
    self._draw_scene()
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/scene/canvas.py", line 277, in _draw_scene
    self.draw_visual(self.scene)
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/scene/canvas.py", line 315, in draw_visual
    node.draw()
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/scene/visuals.py", line 103, in draw
    self._visual_superclass.draw(self)
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/visuals/visual.py", line 451, in draw
    self._program.draw(self._vshare.draw_mode,
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/visuals/shaders/program.py", line 101, in draw
    self.update_variables()
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/visuals/shaders/program.py", line 158, in update_variables
    self._process_pending_variables()
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/gloo/program.py", line 303, in _process_pending_variables
    self[name] = data
  File "/home/czaki/.pyenv/versions/napari/lib/python3.9/site-packages/vispy/gloo/program.py", line 372, in __setitem__
    dtype, numel = self._gtypes[type_]
KeyError: 'uint'

uvec2 is missed from different dict

@djhoese
Copy link
Member

djhoese commented Aug 24, 2023

I'm going to guess an oversight. A quick google doesn't suggest that these types are not in the OpenGL standards we support. Pull requests welcome!

vispy/vispy/gloo/program.py

Lines 114 to 134 in 6b68262

_gtypes = { # DTYPE, NUMEL
'float': (np.float32, 1),
'vec2': (np.float32, 2),
'vec3': (np.float32, 3),
'vec4': (np.float32, 4),
'int': (np.int32, 1),
'ivec2': (np.int32, 2),
'ivec3': (np.int32, 3),
'ivec4': (np.int32, 4),
'bool': (np.int32, 1),
'bvec2': (bool, 2),
'bvec3': (bool, 3),
'bvec4': (bool, 4),
'mat2': (np.float32, 4),
'mat3': (np.float32, 9),
'mat4': (np.float32, 16),
'sampler1D': (np.uint32, 1),
'sampler2D': (np.uint32, 1),
'sampler3D': (np.uint32, 1),
'samplerCube': (np.uint32, 1),
}

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