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

64 bit label support #1955

Open
1 task done
aschampion opened this issue Dec 9, 2019 · 2 comments
Open
1 task done

64 bit label support #1955

aschampion opened this issue Dec 9, 2019 · 2 comments

Comments

@aschampion
Copy link
Contributor

aschampion commented Dec 9, 2019

Taken from #1801.

Tested support

bits ndarray texture render vis (shader hash) shader ids selection issues
8 ✅ (as gl float) shader generality
16 shader generality
24/32 ✅ (as gl float rgba)
32 ✅ (as gl float rgba) premultiplied alpha
48/64 16bpp, bigint, shader p
53/64 premultiplied alpha, 16bpp, bigint, shader p
64 premultiplied alpha, 16bpp, bigint, shader p, js numerics

Summary

Taken from lab wiki.

  • To avoid maintaining a Scijs fork to handle ImageBlocks in CATMAID, we will evaluate the TensorFlow.js base library. It is not clear if it fully supports 64 bit — tf.tensor takes any TypedArray as input (which includes BigInt64Array/BigUint64Array ), but the dtype specifier is tf.DataType which is 'float32'|'int32'|'bool'|'complex64'. If suitable, having tensors processing and eventually TensorFlow support in CATMAID may be useful for general image processing and in-browser inference.
  • @clbarnes checked that 64 values do not work. Further, while the next release of tf.js will support importing int64 tensors from other TensorFlow backends, they are silently cast to int32.
  • Instead, four options remain:
    1. Fork and patch SciJS
    2. Write minimal N-D slicing and padding in JS
    3. Write minimal N-D slicing and padding in TS
    4. Write a thin wasm-bindgen wrapper around necessary ops in rust ndarray
  • 1 is lowest initial effort but perhaps a higher ongoing burden. 2 is the simplest solution in not introducing any new libraries, but has the least extensibility. 4 is most consistent with our strategic goal of relying as much as possible on a common backend between Rust, Python and JS. However, not introducing another large binary blob into the CATMAID repo would require merging webpack support (Infrastructure tracking: compilation, source mapping, and TypeScript #1338) first.

Roadmap

  • To remove this as a blocker for the rest of label support, do 1 (fork SciJS for BigInt support) first, then consider more permanent options.
@aschampion
Copy link
Contributor Author

Upstream PRs finally got merged last night, so I forked numjs with the remaining fixes for bigint support: https://github.com/aschampion/numjs/tree/features/bigint64-support

Since the maintainer is inactive I won't bother PRing until we're using the fork and have confirmed it's working for us.

@aschampion
Copy link
Contributor Author

I have a branch fixing numjs' BigInt64 support, which fills out the first column of the matrix (ndarray). For the second column, actually getting the data into WebGL2 and rendered, while I have a branch getting textures uploaded in the correct GL internalformat/type/format triples, the next step is creating subclasses of Pixi.Sprite that are different object types with their own renders (extending Pixi.SpriteRenderer that have custom shaders with the appropriate glsl types. ImageBlockLayers will then re-init their tiles to the correct type once their tile source loads.

Note that this is a different problem from the rest of the shader columns, which refer to stack viewer filter shaders. Those issues and type-generality still need to be addressed, but we also need to factor the concepts of viewer filters (which apply to the entire render buffer) and layer filters (like object labeling, which apply to specific layers). This is because we likely want layers to be required to render down to normal GL floats for a sane pipeline, meaning the mapping from label IDs to colors should happen as part of the layer.

aschampion added a commit to aschampion/CATMAID that referenced this issue Jan 16, 2020
This adds support for rendering non-uint8 blocks by adding custom
`SpriteRenderers` for each data type. These renderers create shaders
based on Pixi's but with appropriate datatypes and scaling to output the
data type into a normal floating point render buffer.

Note that 64-bit integer types render to 16-bit RGBA, and that float64
is not supported.

All other types were tested, though not all are necessary useful as is.

This builds toward support for label rendering and 3D texture rendering.

See catmaid#1955.
aschampion added a commit to aschampion/CATMAID that referenced this issue Jan 16, 2020
This adds support for rendering non-uint8 blocks by adding custom
`SpriteRenderers` for each data type. These renderers create shaders
based on Pixi's but with appropriate datatypes and scaling to output the
data type into a normal floating point render buffer.

Note that 64-bit integer types render to 16-bit RGBA, and that float64
is not supported.

All other types were tested, though not all are necessary useful as is.

This builds toward support for label rendering and 3D texture rendering.

See catmaid#1955.
aschampion added a commit to aschampion/CATMAID that referenced this issue Jan 16, 2020
This adds support for rendering non-uint8 blocks by adding custom
`SpriteRenderers` for each data type. These renderers create shaders
based on Pixi's but with appropriate datatypes and scaling to output the
data type into a normal floating point render buffer.

Note that 64-bit integer types render to 16-bit RGBA, and that float64
is not supported.

All other types were tested, though not all are necessary useful as is.

This builds toward support for label rendering and 3D texture rendering.

See catmaid#1955.
aschampion added a commit to aschampion/CATMAID that referenced this issue Jan 16, 2020
This adds support for rendering non-uint8 blocks by adding custom
`SpriteRenderers` for each data type. These renderers create shaders
based on Pixi's but with appropriate datatypes and scaling to output the
data type into a normal floating point render buffer.

Note that 64-bit integer types render to 16-bit RGBA, and that float64
is not supported.

All other types were tested, though not all are necessary useful as is.

This builds toward support for label rendering and 3D texture rendering.

See catmaid#1955.
aschampion added a commit that referenced this issue Jan 16, 2020
This adds support for rendering non-uint8 blocks by adding custom
`SpriteRenderers` for each data type. These renderers create shaders
based on Pixi's but with appropriate datatypes and scaling to output the
data type into a normal floating point render buffer.

Note that 64-bit integer types render to 16-bit RGBA, and that float64
is not supported.

All other types were tested, though not all are necessary useful as is.

This builds toward support for label rendering and 3D texture rendering.

See #1955.
aschampion added a commit that referenced this issue Jun 4, 2020
This allows for manual control of min/max scaling via the console, and
builds towards future ability to perform shader computation before tiles
are rendered to a render buffer. Note that presently TypedSpriteRenderer
is still shaded between all TypedSprites of the same type, so this
pipeline is not granular enough for most intended uses. Consequently no
configuration is exposed for now.

Related to #1955.
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

1 participant