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

Introduce new ImageFormat component #7083

Merged
merged 25 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/build/re_types_builder/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,8 @@ impl Type {
if enum_index < enums.len() {
// It is an enum.
assert!(
typ == FbsBaseType::Byte,
"{virtpath}: For consistency, enums must be declared as the `byte` type"
typ == FbsBaseType::UByte,
"{virtpath}: For consistency, enums must be declared as the `ubyte` type"
);

let enum_ = &enums[field_type.index() as usize];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ table DepthImage (
/// The raw depth image data.
data: rerun.components.Blob ("attr.rerun.component_required", order: 1000);

/// The size of the image
resolution: rerun.components.Resolution2D ("attr.rerun.component_required", order: 1500);

/// The data type of the depth image data (U16, F32, …).
datatype: rerun.components.ChannelDatatype ("attr.rerun.component_required", order: 2000);
/// The format of the image.
format: rerun.components.ImageFormat ("attr.rerun.component_required", order: 1100);

// --- Optional ---

Expand Down
23 changes: 2 additions & 21 deletions crates/store/re_types/definitions/rerun/archetypes/image.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,8 @@ table Image (
/// The raw image data.
data: rerun.components.Blob ("attr.rerun.component_required", order: 1000);

/// The size of the image.
///
/// For chroma downsampled formats, this is the size of the full image (the luminance channel).
resolution: rerun.components.Resolution2D ("attr.rerun.component_required", order: 1200);

// --- Image format ---

/// Used mainly for chroma downsampled formats and differing number of bits per channel.
///
/// If specified, this takes precedence over both [components.ColorModel] and [components.ChannelDatatype] (which are ignored).
pixel_format: rerun.components.PixelFormat ("attr.rerun.component_optional", nullable, order: 2000);

/// L, RGB, RGBA, …
///
/// Also requires a [components.ChannelDatatype] to fully specify the pixel format.
color_model: rerun.components.ColorModel ("attr.rerun.component_optional", nullable, order: 2100);

/// The data type of each channel (e.g. the red channel) of the image data (U8, F16, …).
///
/// Also requires a [components.ColorModel] to fully specify the pixel format.
datatype: rerun.components.ChannelDatatype ("attr.rerun.component_optional", nullable, order: 2200);
/// The format of the image.
format: rerun.components.ImageFormat ("attr.rerun.component_required", order: 1100);

// --- Optional ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ table SegmentationImage (
/// The raw image data.
data: rerun.components.Blob ("attr.rerun.component_required", order: 1000);

/// The size of the image.
resolution: rerun.components.Resolution2D ("attr.rerun.component_required", order: 1500);

/// The data type of the segmentation image data (U16, U32, …).
datatype: rerun.components.ChannelDatatype ("attr.rerun.component_required", order: 2000);
/// The format of the image.
format: rerun.components.ImageFormat ("attr.rerun.component_required", order: 1100);

// --- Optional ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace rerun.blueprint.components;


/// The type of the background in a view.
enum BackgroundKind: byte (
enum BackgroundKind: ubyte (
"attr.rerun.scope": "blueprint"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace rerun.blueprint.components;


/// The kind of a blueprint container (tabs, grid, …).
enum ContainerKind: byte (
enum ContainerKind: ubyte (
"attr.rerun.scope": "blueprint",
"attr.rust.override_crate": "re_types_blueprint"
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace rerun.blueprint.components;

/// One of four 2D corners, typically used to align objects.
enum Corner2D: byte (
enum Corner2D: ubyte (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Copy, PartialEq, Eq"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace rerun.blueprint.components;


/// The kind of table displayed by the dataframe view
enum DataframeViewMode: byte (
enum DataframeViewMode: ubyte (
"attr.rerun.scope": "blueprint"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace rerun.blueprint.components;
// ---

/// Tri-state for panel controls.
enum PanelState: byte (
enum PanelState: ubyte (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Copy, PartialEq, Eq",
"attr.rust.repr": "transparent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace rerun.blueprint.components;


/// Primary element by which to group by in a temporal data table.
enum SortKey: byte (
enum SortKey: ubyte (
"attr.rerun.scope": "blueprint"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace rerun.blueprint.components;


/// Sort order for data table.
enum SortOrder: byte (
enum SortOrder: ubyte (
"attr.rerun.scope": "blueprint"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace rerun.blueprint.components;

/// Determines whether an image or texture should be scaled to fit the viewport.
enum ViewFit: byte (
enum ViewFit: ubyte (
"attr.rerun.scope": "blueprint"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
5 changes: 1 addition & 4 deletions crates/store/re_types/definitions/rerun/components.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace rerun.components;
/// This is used for lines in plots when the X axis distance of individual points goes below a single pixel,
/// i.e. a single pixel covers more than one tick worth of data. It can greatly improve performance
/// (and readability) in such situations as it prevents overdraw.
enum AggregationPolicy: byte {
enum AggregationPolicy: ubyte {
/// Invalid value. Won't show up in generated types.
Invalid = 0,

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace rerun.components;
/// This provides a number of popular pre-defined colormaps.
/// In the future, the Rerun Viewer will allow users to define their own colormaps,
/// but currently the Viewer is limited to the types defined here.
enum Colormap: byte {
enum Colormap: ubyte {
/// Invalid value. Won't show up in generated types.
Invalid = 0,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace rerun.components;

/// How a geometric shape is drawn and colored.
enum FillMode: byte(
enum FillMode: ubyte(
"attr.docs.unreleased"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace rerun.components;

/// The metadata describing the contents of a [rerun.components.ImageBuffer].
struct ImageFormat (
"attr.docs.unreleased",
"attr.rust.derive": "Default, Copy, PartialEq, Eq, Hash",
"attr.rust.repr": "transparent"
) {
image_format : rerun.datatypes.ImageFormat (order: 100);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace rerun.components;

/// Filter used when magnifying an image/texture such that a single pixel/texel is displayed as multiple pixels on screen.
enum MagnificationFilter: byte {
enum MagnificationFilter: ubyte {
/// Invalid value. Won't show up in generated types.
Invalid = 0,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace rerun.components;

/// The visual appearance of a point in e.g. a 2D plot.
enum MarkerShape: byte
enum MarkerShape: ubyte
{
/// Invalid value. Won't show up in generated types.
Invalid = 0,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace rerun.components;

/// Specifies relation a spatial transform describes.
enum TransformRelation: byte (
enum TransformRelation: ubyte (
"attr.docs.unreleased"
) {
/// Invalid value. Won't show up in generated types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace rerun.components;

// TODO(#6320)
/*
enum ViewDir: byte {
enum ViewDir: ubyte {
Up = 1,
Down = 2,
Right = 3,
Expand Down
4 changes: 4 additions & 0 deletions crates/store/re_types/definitions/rerun/datatypes.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace rerun.datatypes;

/// The innermost datatype of an image.
///
/// How individual color channel components are encoded.
enum ChannelDatatype: ubyte (
"attr.docs.unreleased"
) {
/// Invalid value. Won't show up in generated types.
Invalid = 0,

// In theory these values are totally arbitrary. There's no great accepted
// standard for these, but we'll try to keep them somewhat sanely organized.

// Reserve 1-31 for integer types. This is very likely overkill, but it's
// nice to have a bit of growing room, and rounding to the nearest power of
// 2 keeps things clean.
//
// Additionally, we always use the low bit to indicate signedness. Conceptually
// bool fits this pattern if you think of it as a pure sign. This lets us grow
// across Uint and Int types without knowing how far up we're going to go.

// Reserve 1 for bool.
// Reserve 2-5 in case we want to encode U2 or U4 in the future.

/// 8-bit unsigned integer.
U8 = 6 (default),

/// 8-bit signed integer.
I8 = 7,

/// 16-bit unsigned integer.
U16 = 8,

/// 16-bit signed integer.
I16 = 9,

/// 32-bit unsigned integer.
U32 = 10,

/// 32-bit signed integer.
I32 = 11,

/// 64-bit unsigned integer.
U64 = 12,

/// 64-bit signed integer.
I64 = 13,

// Reserve 14-31 for wider or non-power-of-2 integer types.

// Reserve 32 for the possibility of F8.

/// 16-bit IEEE-754 floating point, also known as `half`.
F16 = 33,

/// 32-bit IEEE-754 floating point, also known as `float` or `single`.
F32 = 34,

/// 64-bit IEEE-754 floating point, also known as `double`.
F64 = 35,

// Reservee at least 36-39 for future floating point types.
// For exampole, IEEE-754 binary256.

// This still leaves us plenty of room for encoding common fixed-point types,
// most likely starting at 64, or other exotic encodings beyond that.
}
Loading
Loading