GNOME Bugzilla – Bug 671524
Add support for stereoscopic rendering
Last modified: 2021-06-10 11:33:09 UTC
Created attachment 209134 [details] [review] Adds initial support for stereoscopic rendering I've attached a patch that adds basic support for stereoscopic rendering to Clutter using a toe-in approach to setting up the eye projections and supporting anaglyph or split screen rendering modes. The patch introduces the internal concept of a ClutterCamera which encapsulates a viewport, projection and view transform. In the future the camera would also encapsulate a reference to the destination framebuffer, but for now it's assumed that the backend framebuffer behind stage->priv->impl is associated with all cameras. If clutter_stage_set_stereo_enabled (stage, TRUE) is called then Clutter will enable stereographic rendering, using a simple toe-in approach of modifying the view transform for each eye to model that there is a gap between the eyes and both eyes look towards the center of the z=0 plane (This is the plane where most 2d content for a clutter application goes) A notable disadvantage to the simple toe-in approach is that 2D content on the z=0 plane will look different for each eye so straight lines for example wont appear straight to the user. A better approach we will implement later is to setup asymmetric projections for each eye that can model the eye gap but the frustums cross at the z=0 plane such that both eyes would have the same view of 2D content. Currently there are three modes of output for stereoscopic content. » There is anaglyph rendering (for use with filter glasses with a red filter for the left eye and cyan filter for the right) » There is a vertical split mode which splits the stage and shows the left eye content on the left and the right eye on the right. » There is a horizontal split mode which splits the stage and shows the left eye content on the top and right eye on the bottom. The mode can be selected using clutter_stage_set_stereo_mode(). The mode can also be explicitly overridden using the CLUTTER_STEREO_MODE environment variable by setting it to "default", "anaglyph", "vertical-split" or "horizontal-split". Setting this environment variable also implicitly forces stereo rendering to be enabled. Feedback welcome
Review of attachment 209134 [details] [review]: ::: clutter/clutter-actor.c @@ +1122,3 @@ +static ClutterStage * +_clutter_actor_get_stage_real (ClutterActor *actor) if the function is static then there's no need to use the leading underscore @@ +1137,3 @@ + /* Note: we never want to have a type check when we cast here + * since this is function can be used very heavily. */ + this is ridiculous premature optimization. you can do tens of millions of type checks per second, and once an actor is mapped (which is mostly the case for when we call get_stage()) then the cached stage is always going to be valid. @@ +1146,3 @@ + /* Note: we never want to have a type check when we cast here + * since this is function can be used very heavily. */ + actor = actor->priv->parent; same as above. in this case, we may even consider changing the return value to ClutterStage. @@ +1411,3 @@ + * if (_clutter_actor_get_stage_real (self)) + * clutter_actor_queue_redraw (self); + * this should go to a separate bug @@ +1514,3 @@ + * if (_clutter_actor_get_stage_real (self)) + * clutter_actor_queue_redraw (self); + * same as above @@ +2437,3 @@ CoglMatrix *matrix) { + g_return_if_fail (ancestor != NULL); I'd rather use g_assert() here. @@ +2732,3 @@ ClutterActor *parent; + g_return_if_fail (ancestor != NULL); again, this should really be g_assert() and not g_return_if_fail() @@ +3020,3 @@ + priv->cameras_age = cameras_age; + } + priv->camera_state); I'd actually feel safer if you checked that camera_index is always less than priv->n_cameras using an assertion — just in case. ::: clutter/clutter-enums.h @@ +1110,3 @@ + * has native support for stereoscopic hardware, but for platforms without native + * stereoscopic support there are several fallback methods including anaglpyh for + * right. missing a Since: 1.10 annotation ::: clutter/clutter-stage.c @@ +2699,3 @@ } + stereo_mode = getenv ("CLUTTER_STEREO_MODE"); use g_getenv(), as it is portable. @@ +4765,3 @@ + * disables stereoscopic rendering if enabled = %FALSE; + * + * @enabled: Whether stereoscopic rendering should be enabled or not Since: 1.10 @@ +4768,3 @@ + */ +void + * there is no clutter_stage_get_stereo_enabled() and there is no ClutterStage:stereo-enabled property. @@ +4816,3 @@ + * can be used with a lot of 3D TVs. + * + * the swap-buffers feature to enable stereo rendering... */ Since: 1.10 @@ +4819,3 @@ + */ +void + !_clutter_stage_window_has_feature (stage->priv->impl, there is no clutter_stage_get_stereo_mode(), and there is no ClutterStage:stereo-mode property.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version of clutter, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a ticket at https://gitlab.gnome.org/GNOME/clutter/-/issues/ Thank you for your understanding and your help.