mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
primitives: make sure to update texture storage before drawing
We want to make sure that the material state flushing code will never result in changes to the texture storage for that material. So for example mipmaps need to be ensured by the primitives code. Changes to the texture storage will invalidate the texture coordinates in the journal and we want to avoid a recursion of journal flushing.
This commit is contained in:
parent
1047c1c082
commit
a21d909129
@ -1817,8 +1817,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
|
|||||||
|
|
||||||
unit = _cogl_get_texture_unit (i);
|
unit = _cogl_get_texture_unit (i);
|
||||||
|
|
||||||
_cogl_material_layer_ensure_mipmaps (layer_handle);
|
|
||||||
|
|
||||||
new_gl_layer_info.layer0_overridden =
|
new_gl_layer_info.layer0_overridden =
|
||||||
layer0_override_texture ? TRUE : FALSE;
|
layer0_override_texture ? TRUE : FALSE;
|
||||||
new_gl_layer_info.fallback =
|
new_gl_layer_info.fallback =
|
||||||
|
@ -523,9 +523,45 @@ _cogl_rectangles_with_multitexture_coords (
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* We need to ensure the mipmaps are ready before deciding
|
/* We need to ensure the mipmaps are ready before deciding
|
||||||
anything else about the texture because it could become
|
* anything else about the texture because the texture storage
|
||||||
something completely different if it needs to be migrated out
|
* could completely change if it needs to be migrated out of the
|
||||||
of the atlas */
|
* atlas and will affect how we validate the layer.
|
||||||
|
*
|
||||||
|
* FIXME: this needs to be generalized. There could be any
|
||||||
|
* number of things that might require a shuffling of the
|
||||||
|
* underlying texture storage. We could add two mechanisms to
|
||||||
|
* generalize this a bit...
|
||||||
|
*
|
||||||
|
* 1) add a _cogl_material_layer_update_storage() function that
|
||||||
|
* would for instance consider if mipmapping is necessary and
|
||||||
|
* potentially migrate the texture from an atlas.
|
||||||
|
*
|
||||||
|
* 2) allow setting of transient primitive-flags on a material
|
||||||
|
* that may affect the outcome of _update_storage(). One flag
|
||||||
|
* could indicate that we expect to sample beyond the bounds of
|
||||||
|
* the texture border.
|
||||||
|
*
|
||||||
|
* flags = COGL_MATERIAL_PRIMITIVE_FLAG_VALID_BORDERS;
|
||||||
|
* _cogl_material_layer_assert_primitive_flags (layer, flags)
|
||||||
|
* _cogl_material_layer_update_storage (layer)
|
||||||
|
* enqueue primitive in journal
|
||||||
|
*
|
||||||
|
* when the primitive is dequeued and drawn we should:
|
||||||
|
* _cogl_material_flush_gl_state (material)
|
||||||
|
* draw primitive
|
||||||
|
* _cogl_material_unassert_primitive_flags (layer, flags);
|
||||||
|
*
|
||||||
|
* _cogl_material_layer_update_storage should take into
|
||||||
|
* consideration all the asserted primitive requirements. (E.g.
|
||||||
|
* there could be multiple primitives in the journal - or in a
|
||||||
|
* renderlist in the future - that need mipmaps or that need
|
||||||
|
* valid contents beyond their borders (for cogl_polygon)
|
||||||
|
* meaning they can't work with textures in an atas, so
|
||||||
|
* _cogl_material_layer_update_storage would pass on these
|
||||||
|
* requirements to the texture atlas backend which would make
|
||||||
|
* sure the referenced texture is migrated out of the atlas and
|
||||||
|
* mipmaps are generated.)
|
||||||
|
*/
|
||||||
_cogl_material_layer_ensure_mipmaps (layer);
|
_cogl_material_layer_ensure_mipmaps (layer);
|
||||||
|
|
||||||
tex_handle = cogl_material_layer_get_texture (layer);
|
tex_handle = cogl_material_layer_get_texture (layer);
|
||||||
@ -1041,10 +1077,22 @@ cogl_polygon (const CoglTextureVertex *vertices,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Give the texture a chance to know that we're rendering
|
/* Give the texture a chance to know that we're rendering
|
||||||
non-quad shaped primitives. If the texture is in an atlas it
|
* non-quad shaped primitives. If the texture is in an atlas it
|
||||||
will be migrated */
|
* will be migrated
|
||||||
|
*
|
||||||
|
* FIXME: this needs to be generalized. There could be any
|
||||||
|
* number of things that might require a shuffling of the
|
||||||
|
* underlying texture storage.
|
||||||
|
*/
|
||||||
_cogl_texture_ensure_non_quad_rendering (tex_handle);
|
_cogl_texture_ensure_non_quad_rendering (tex_handle);
|
||||||
|
|
||||||
|
/* We need to ensure the mipmaps are ready before deciding
|
||||||
|
* anything else about the texture because the texture storate
|
||||||
|
* could completely change if it needs to be migrated out of the
|
||||||
|
* atlas and will affect how we validate the layer.
|
||||||
|
*/
|
||||||
|
_cogl_material_layer_ensure_mipmaps (layer);
|
||||||
|
|
||||||
if (i == 0 && cogl_texture_is_sliced (tex_handle))
|
if (i == 0 && cogl_texture_is_sliced (tex_handle))
|
||||||
{
|
{
|
||||||
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
|
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
|
||||||
|
@ -1652,6 +1652,13 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
|
|||||||
will be migrated */
|
will be migrated */
|
||||||
_cogl_texture_ensure_non_quad_rendering (tex_handle);
|
_cogl_texture_ensure_non_quad_rendering (tex_handle);
|
||||||
|
|
||||||
|
/* We need to ensure the mipmaps are ready before deciding
|
||||||
|
* anything else about the texture because the texture storate
|
||||||
|
* could completely change if it needs to be migrated out of the
|
||||||
|
* atlas and will affect how we validate the layer.
|
||||||
|
*/
|
||||||
|
_cogl_material_layer_ensure_mipmaps (layer);
|
||||||
|
|
||||||
if (!_cogl_texture_can_hardware_repeat (tex_handle))
|
if (!_cogl_texture_can_hardware_repeat (tex_handle))
|
||||||
{
|
{
|
||||||
g_warning ("Disabling layer %d of the current source material, "
|
g_warning ("Disabling layer %d of the current source material, "
|
||||||
|
Loading…
Reference in New Issue
Block a user