1
0
Fork 0

cogl: Remove various Framebuffer functions

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3806>
This commit is contained in:
Bilal Elmoussaoui 2024-06-12 13:46:35 +02:00
parent 2c996a1b16
commit 9097deb69d
4 changed files with 3 additions and 427 deletions

View file

@ -1159,25 +1159,6 @@ cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer)
return bits.alpha; return bits.alpha;
} }
int
cogl_framebuffer_get_depth_bits (CoglFramebuffer *framebuffer)
{
CoglFramebufferBits bits;
cogl_framebuffer_query_bits (framebuffer, &bits);
return bits.depth;
}
gboolean
cogl_framebuffer_get_is_stereo (CoglFramebuffer *framebuffer)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
return priv->config.stereo_enabled;
}
CoglStereoMode CoglStereoMode
cogl_framebuffer_get_stereo_mode (CoglFramebuffer *framebuffer) cogl_framebuffer_get_stereo_mode (CoglFramebuffer *framebuffer)
{ {
@ -1187,26 +1168,6 @@ cogl_framebuffer_get_stereo_mode (CoglFramebuffer *framebuffer)
return priv->stereo_mode; return priv->stereo_mode;
} }
void
cogl_framebuffer_set_stereo_mode (CoglFramebuffer *framebuffer,
CoglStereoMode stereo_mode)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
if (priv->stereo_mode == stereo_mode)
return;
/* Stereo mode changes don't go through the journal */
_cogl_framebuffer_flush_journal (framebuffer);
priv->stereo_mode = stereo_mode;
if (priv->context->current_draw_buffer == framebuffer)
priv->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_STEREO_MODE;
}
gboolean gboolean
cogl_framebuffer_get_depth_write_enabled (CoglFramebuffer *framebuffer) cogl_framebuffer_get_depth_write_enabled (CoglFramebuffer *framebuffer)
{ {
@ -1258,30 +1219,6 @@ cogl_framebuffer_set_dither_enabled (CoglFramebuffer *framebuffer,
priv->dither_enabled = dither_enabled; priv->dither_enabled = dither_enabled;
} }
int
cogl_framebuffer_get_samples_per_pixel (CoglFramebuffer *framebuffer)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
if (priv->allocated)
return priv->samples_per_pixel;
else
return priv->config.samples_per_pixel;
}
void
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
int samples_per_pixel)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
g_return_if_fail (!priv->allocated);
priv->config.samples_per_pixel = samples_per_pixel;
}
void void
cogl_framebuffer_update_samples_per_pixel (CoglFramebuffer *framebuffer, cogl_framebuffer_update_samples_per_pixel (CoglFramebuffer *framebuffer,
int samples_per_pixel) int samples_per_pixel)
@ -1292,55 +1229,6 @@ cogl_framebuffer_update_samples_per_pixel (CoglFramebuffer *framebuffer,
priv->samples_per_pixel = samples_per_pixel; priv->samples_per_pixel = samples_per_pixel;
} }
void
cogl_framebuffer_resolve_samples (CoglFramebuffer *framebuffer)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
cogl_framebuffer_resolve_samples_region (framebuffer,
0, 0,
priv->width,
priv->height);
/* TODO: Make this happen implicitly when the resolve texture next gets used
* as a source, either via cogl_texture_get_data(), via cogl_read_pixels() or
* if used as a source for rendering. We would also implicitly resolve if
* necessary before freeing a CoglFramebuffer.
*
* This API should still be kept but it is optional, only necessary
* if the user wants to explicitly control when the resolve happens e.g.
* to ensure it's done in advance of it being used as a source.
*
* Every texture should have a CoglFramebuffer *needs_resolve member
* internally. When the texture gets validated before being used as a source
* we should first check the needs_resolve pointer and if set we'll
* automatically call cogl_framebuffer_resolve_samples ().
*
* Calling cogl_framebuffer_resolve_samples() or
* cogl_framebuffer_resolve_samples_region() should reset the textures
* needs_resolve pointer to NULL.
*
* Rendering anything to a framebuffer will cause the corresponding
* texture's ->needs_resolve pointer to be set.
*
* XXX: Note: we only need to address this TODO item when adding support for
* EXT_framebuffer_multisample because currently we only support hardware
* that resolves implicitly anyway.
*/
}
void
cogl_framebuffer_resolve_samples_region (CoglFramebuffer *framebuffer,
int x,
int y,
int width,
int height)
{
/* NOP for now since we don't support EXT_framebuffer_multisample yet which
* requires an explicit resolve. */
}
CoglContext * CoglContext *
cogl_framebuffer_get_context (CoglFramebuffer *framebuffer) cogl_framebuffer_get_context (CoglFramebuffer *framebuffer)
{ {
@ -1724,22 +1612,6 @@ cogl_framebuffer_pop_matrix (CoglFramebuffer *framebuffer)
} }
} }
void
cogl_framebuffer_identity_matrix (CoglFramebuffer *framebuffer)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
CoglMatrixStack *modelview_stack =
_cogl_framebuffer_get_modelview_stack (framebuffer);
cogl_matrix_stack_load_identity (modelview_stack);
if (priv->context->current_draw_buffer == framebuffer)
{
priv->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_MODELVIEW;
}
}
void void
cogl_framebuffer_scale (CoglFramebuffer *framebuffer, cogl_framebuffer_scale (CoglFramebuffer *framebuffer,
float x, float x,
@ -1798,23 +1670,6 @@ cogl_framebuffer_rotate (CoglFramebuffer *framebuffer,
} }
} }
void
cogl_framebuffer_rotate_euler (CoglFramebuffer *framebuffer,
const graphene_euler_t *euler)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
CoglMatrixStack *modelview_stack =
_cogl_framebuffer_get_modelview_stack (framebuffer);
cogl_matrix_stack_rotate_euler (modelview_stack, euler);
if (priv->context->current_draw_buffer == framebuffer)
{
priv->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_MODELVIEW;
}
}
void void
cogl_framebuffer_transform (CoglFramebuffer *framebuffer, cogl_framebuffer_transform (CoglFramebuffer *framebuffer,
const graphene_matrix_t *matrix) const graphene_matrix_t *matrix)
@ -2017,45 +1872,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer,
} }
} }
void
cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
CoglPrimitive *primitive,
float bounds_x1,
float bounds_y1,
float bounds_x2,
float bounds_y2)
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
CoglMatrixEntry *modelview_entry =
_cogl_framebuffer_get_modelview_entry (framebuffer);
CoglMatrixEntry *projection_entry =
_cogl_framebuffer_get_projection_entry (framebuffer);
/* XXX: It would be nicer if we stored the private viewport as a
* vec4 so we could avoid this redundant copy. */
float viewport[] = {
priv->viewport_x,
priv->viewport_y,
priv->viewport_width,
priv->viewport_height
};
priv->clip_stack =
_cogl_clip_stack_push_primitive (priv->clip_stack,
primitive,
bounds_x1, bounds_y1,
bounds_x2, bounds_y2,
modelview_entry,
projection_entry,
viewport);
if (priv->context->current_draw_buffer == framebuffer)
{
priv->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_CLIP;
}
}
void void
cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer, cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer,
MtkRegion *region) MtkRegion *region)

View file

@ -264,15 +264,6 @@ cogl_framebuffer_push_matrix (CoglFramebuffer *framebuffer);
COGL_EXPORT void COGL_EXPORT void
cogl_framebuffer_pop_matrix (CoglFramebuffer *framebuffer); cogl_framebuffer_pop_matrix (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_identity_matrix:
* @framebuffer: A #CoglFramebuffer pointer
*
* Resets the current model-view matrix to the identity matrix.
*/
COGL_EXPORT void
cogl_framebuffer_identity_matrix (CoglFramebuffer *framebuffer);
/** /**
* cogl_framebuffer_scale: * cogl_framebuffer_scale:
* @framebuffer: A #CoglFramebuffer pointer * @framebuffer: A #CoglFramebuffer pointer
@ -326,18 +317,6 @@ cogl_framebuffer_rotate (CoglFramebuffer *framebuffer,
float y, float y,
float z); float z);
/**
* cogl_framebuffer_rotate_euler:
* @framebuffer: A #CoglFramebuffer pointer
* @euler: A #graphene_euler_t
*
* Multiplies the current model-view matrix by one that rotates
* according to the rotation described by @euler.
*/
COGL_EXPORT void
cogl_framebuffer_rotate_euler (CoglFramebuffer *framebuffer,
const graphene_euler_t *euler);
/** /**
* cogl_framebuffer_transform: * cogl_framebuffer_transform:
* @framebuffer: A #CoglFramebuffer pointer * @framebuffer: A #CoglFramebuffer pointer
@ -494,40 +473,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer,
float x_2, float x_2,
float y_2); float y_2);
/**
* cogl_framebuffer_push_primitive_clip:
* @framebuffer: A #CoglFramebuffer pointer
* @primitive: A #CoglPrimitive describing a flat 2D shape
* @bounds_x1: x coordinate for the top-left corner of the primitives
* bounds
* @bounds_y1: y coordinate for the top-left corner of the primitives
* bounds
* @bounds_x2: x coordinate for the bottom-right corner of the
* primitives bounds.
* @bounds_y2: y coordinate for the bottom-right corner of the
* primitives bounds.
*
* Sets a new clipping area using a 2D shaped described with a
* #CoglPrimitive. The shape must not contain self overlapping
* geometry and must lie on a single 2D plane. A bounding box of the
* 2D shape in local coordinates (the same coordinates used to
* describe the shape) must be given. It is acceptable for the bounds
* to be larger than the true bounds but behaviour is undefined if the
* bounds are smaller than the true bounds.
*
* The primitive is transformed by the current model-view matrix and
* the silhouette is intersected with the previous clipping area. To
* restore the previous clipping area, call
* cogl_framebuffer_pop_clip().
*/
COGL_EXPORT void
cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
CoglPrimitive *primitive,
float bounds_x1,
float bounds_y1,
float bounds_x2,
float bounds_y2);
COGL_EXPORT void COGL_EXPORT void
cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer, cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer,
MtkRegion *region); MtkRegion *region);
@ -537,8 +482,7 @@ cogl_framebuffer_push_region_clip (CoglFramebuffer *framebuffer,
* @framebuffer: A #CoglFramebuffer pointer * @framebuffer: A #CoglFramebuffer pointer
* *
* Reverts the clipping region to the state before the last call to * Reverts the clipping region to the state before the last call to
* cogl_framebuffer_push_rectangle_clip(), or * cogl_framebuffer_push_rectangle_clip()
* cogl_framebuffer_push_primitive_clip().
*/ */
COGL_EXPORT void COGL_EXPORT void
cogl_framebuffer_pop_clip (CoglFramebuffer *framebuffer); cogl_framebuffer_pop_clip (CoglFramebuffer *framebuffer);
@ -591,31 +535,6 @@ cogl_framebuffer_get_blue_bits (CoglFramebuffer *framebuffer);
COGL_EXPORT int COGL_EXPORT int
cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer); cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_get_depth_bits:
* @framebuffer: a pointer to a #CoglFramebuffer
*
* Retrieves the number of depth bits of @framebuffer
*
* Return value: the number of bits
*/
COGL_EXPORT int
cogl_framebuffer_get_depth_bits (CoglFramebuffer *framebuffer);
/*
* cogl_framebuffer_get_is_stereo:
* @framebuffer: a pointer to a #CoglFramebuffer
*
* Retrieves whether @framebuffer has separate left and right
* buffers for use with stereo drawing. See
* cogl_framebuffer_set_stereo_mode().
*
* Return value: %TRUE if @framebuffer has separate left and
* right buffers.
*/
COGL_EXPORT gboolean
cogl_framebuffer_get_is_stereo (CoglFramebuffer *framebuffer);
/** /**
* cogl_framebuffer_get_dither_enabled: * cogl_framebuffer_get_dither_enabled:
* @framebuffer: a pointer to a #CoglFramebuffer * @framebuffer: a pointer to a #CoglFramebuffer
@ -689,166 +608,13 @@ cogl_framebuffer_set_depth_write_enabled (CoglFramebuffer *framebuffer,
* @framebuffer: a pointer to a #CoglFramebuffer * @framebuffer: a pointer to a #CoglFramebuffer
* *
* Gets the current #CoglStereoMode, which defines which stereo buffers * Gets the current #CoglStereoMode, which defines which stereo buffers
* should be drawn to. See cogl_framebuffer_set_stereo_mode(). * should be drawn to.
* *
* Returns: A #CoglStereoMode * Returns: A #CoglStereoMode
*/ */
COGL_EXPORT CoglStereoMode COGL_EXPORT CoglStereoMode
cogl_framebuffer_get_stereo_mode (CoglFramebuffer *framebuffer); cogl_framebuffer_get_stereo_mode (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_set_stereo_mode:
* @framebuffer: a pointer to a #CoglFramebuffer
* @stereo_mode: A #CoglStereoMode specifying which stereo buffers
* should be drawn tow.
*
* Sets which stereo buffers should be drawn to. The default
* is %COGL_STEREO_BOTH, which means that both the left and
* right buffers will be affected by drawing. For this to have
* an effect, the display system must support stereo drawables,
* and the framebuffer must have been created with stereo
* enabled. (See cogl_onscreen_template_set_stereo_enabled(),
* cogl_framebuffer_get_is_stereo().)
*/
COGL_EXPORT void
cogl_framebuffer_set_stereo_mode (CoglFramebuffer *framebuffer,
CoglStereoMode stereo_mode);
/**
* cogl_framebuffer_set_samples_per_pixel:
* @framebuffer: A #CoglFramebuffer framebuffer
* @samples_per_pixel: The minimum number of samples per pixel
*
* Requires that when rendering to @framebuffer then @n point samples
* should be made per pixel which will all contribute to the final
* resolved color for that pixel. The idea is that the hardware aims
* to get quality similar to what you would get if you rendered
* everything twice as big (for 4 samples per pixel) and then scaled
* that image back down with filtering. It can effectively remove the
* jagged edges of polygons and should be more efficient than if you
* were to manually render at a higher resolution and downscale
* because the hardware is often able to take some shortcuts. For
* example the GPU may only calculate a single texture sample for all
* points of a single pixel, and for tile based architectures all the
* extra sample data (such as depth and stencil samples) may be
* handled on-chip and so avoid increased demand on system memory
* bandwidth.
*
* By default this value is usually set to 0 and that is referred to
* as "single-sample" rendering. A value of 1 or greater is referred
* to as "multisample" rendering.
*
* There are some semantic differences between single-sample
* rendering and multisampling with just 1 point sample such as it
* being redundant to use the cogl_framebuffer_resolve_samples() and
* cogl_framebuffer_resolve_samples_region() apis with single-sample
* rendering.
*
* It's recommended that
* cogl_framebuffer_resolve_samples_region() be explicitly used at the
* end of rendering to a point sample buffer to minimize the number of
* samples that get resolved. By default Cogl will implicitly resolve
* all framebuffer samples but if only a small region of a
* framebuffer has changed this can lead to redundant work being
* done.
*
*/
COGL_EXPORT void
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
int samples_per_pixel);
/**
* cogl_framebuffer_get_samples_per_pixel:
* @framebuffer: A #CoglFramebuffer framebuffer
*
* Gets the number of points that are sampled per-pixel when
* rasterizing geometry. Usually by default this will return 0 which
* means that single-sample not multisample rendering has been chosen.
* When using a GPU supporting multisample rendering it's possible to
* increase the number of samples per pixel using
* cogl_framebuffer_set_samples_per_pixel().
*
* Calling cogl_framebuffer_get_samples_per_pixel() before the
* framebuffer has been allocated will simply return the value set
* using cogl_framebuffer_set_samples_per_pixel(). After the
* framebuffer has been allocated the value will reflect the actual
* number of samples that will be made by the GPU.
*
* Returns: The number of point samples made per pixel when
* rasterizing geometry or 0 if single-sample rendering
* has been chosen.
*/
COGL_EXPORT int
cogl_framebuffer_get_samples_per_pixel (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_resolve_samples:
* @framebuffer: A #CoglFramebuffer framebuffer
*
* When point sample rendering (also known as multisample rendering)
* has been enabled via cogl_framebuffer_set_samples_per_pixel()
* then you can optionally call this function (or
* cogl_framebuffer_resolve_samples_region()) to explicitly resolve
* the point samples into values for the final color buffer.
*
* Some GPUs will implicitly resolve the point samples during
* rendering and so this function is effectively a nop, but with other
* architectures it is desirable to defer the resolve step until the
* end of the frame.
*
* Since Cogl will automatically ensure samples are resolved if the
* target color buffer is used as a source this API only needs to be
* used if explicit control is desired - perhaps because you want to
* ensure that the resolve is completed in advance to avoid later
* having to wait for the resolve to complete.
*
* If you are performing incremental updates to a framebuffer you
* should consider using cogl_framebuffer_resolve_samples_region()
* instead to avoid resolving redundant pixels.
*
*/
COGL_EXPORT void
cogl_framebuffer_resolve_samples (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_resolve_samples_region:
* @framebuffer: A #CoglFramebuffer framebuffer
* @x: top-left x coordinate of region to resolve
* @y: top-left y coordinate of region to resolve
* @width: width of region to resolve
* @height: height of region to resolve
*
* When point sample rendering (also known as multisample rendering)
* has been enabled via cogl_framebuffer_set_samples_per_pixel()
* then you can optionally call this function (or
* cogl_framebuffer_resolve_samples()) to explicitly resolve the point
* samples into values for the final color buffer.
*
* Some GPUs will implicitly resolve the point samples during
* rendering and so this function is effectively a nop, but with other
* architectures it is desirable to defer the resolve step until the
* end of the frame.
*
* Use of this API is recommended if incremental, small updates to
* a framebuffer are being made because by default Cogl will
* implicitly resolve all the point samples of the framebuffer which
* can result in redundant work if only a small number of samples have
* changed.
*
* Because some GPUs implicitly resolve point samples this function
* only guarantees that at-least the region specified will be resolved
* and if you have rendered to a larger region then it's possible that
* other samples may be implicitly resolved.
*
*/
COGL_EXPORT void
cogl_framebuffer_resolve_samples_region (CoglFramebuffer *framebuffer,
int x,
int y,
int width,
int height);
/** /**
* cogl_framebuffer_get_context: * cogl_framebuffer_get_context:
* @framebuffer: A #CoglFramebuffer * @framebuffer: A #CoglFramebuffer

View file

@ -64,12 +64,6 @@ cogl_onscreen_template_new (void);
* By default this value is usually set to 0 and that is referred to * By default this value is usually set to 0 and that is referred to
* as "single-sample" rendering. A value of 1 or greater is referred * as "single-sample" rendering. A value of 1 or greater is referred
* to as "multisample" rendering. * to as "multisample" rendering.
*
* There are some semantic differences between single-sample
* rendering and multisampling with just 1 point sample such as it
* being redundant to use the cogl_framebuffer_resolve_samples() and
* cogl_framebuffer_resolve_samples_region() apis with single-sample
* rendering.
*/ */
COGL_EXPORT void COGL_EXPORT void
cogl_onscreen_template_set_samples_per_pixel ( cogl_onscreen_template_set_samples_per_pixel (

View file

@ -414,7 +414,7 @@ typedef enum /*< prefix=COGL_READ_PIXELS >*/
* @COGL_STEREO_RIGHT: draw only to the left stereo buffer * @COGL_STEREO_RIGHT: draw only to the left stereo buffer
* *
* Represents how draw should affect the two buffers * Represents how draw should affect the two buffers
* of a stereo framebuffer. See cogl_framebuffer_set_stereo_mode(). * of a stereo framebuffer.
*/ */
typedef enum typedef enum
{ {