[Mesa-dev] [PATCH 5/6] mesa: Implement a new GL_MESA_tile_raster_order extension.

Nicolai Hähnle nhaehnle at gmail.com
Fri Jul 28 06:14:45 UTC 2017


On 28.07.2017 04:30, Eric Anholt wrote:
> The intent is to use this extension on vc4 to allow X11 to do overlapping
> CopyArea() within a pixmap without first blitting the pixmap to a
> temporary.  With associated glamor patches, improves x11perf
> -copywinwin100 performance on a Raspberry Pi 3 from ~4700/sec to
> ~5130/sec, and is an even larger boost to uncomposited window movement
> performance (most copywinwin100 copies don't overlap).
> ---
>   docs/specs/MESA_tile_raster_order.spec        | 101 ++++++++++++++++++++++++++
>   docs/specs/enums.txt                          |   5 ++
>   include/GL/glext.h                            |   6 ++
>   src/mapi/glapi/gen/MESA_tile_raster_order.xml |  13 ++++
>   src/mapi/glapi/gen/Makefile.am                |   1 +
>   src/mesa/main/context.c                       |   2 +
>   src/mesa/main/enable.c                        |  27 +++++++
>   src/mesa/main/extensions_table.h              |   1 +
>   src/mesa/main/mtypes.h                        |  13 ++++
>   src/mesa/state_tracker/st_atom_rasterizer.c   |   5 ++
>   src/mesa/state_tracker/st_context.c           |   1 +
>   src/mesa/state_tracker/st_extensions.c        |   1 +
>   12 files changed, 176 insertions(+)
>   create mode 100644 docs/specs/MESA_tile_raster_order.spec
>   create mode 100644 src/mapi/glapi/gen/MESA_tile_raster_order.xml
> 
> diff --git a/docs/specs/MESA_tile_raster_order.spec b/docs/specs/MESA_tile_raster_order.spec
> new file mode 100644
> index 000000000000..b6362fc7e5a6
> --- /dev/null
> +++ b/docs/specs/MESA_tile_raster_order.spec
> @@ -0,0 +1,101 @@
> +Name
> +
> +    MESA_tile_raster_order
> +
> +Name Strings
> +
> +    GL_MESA_tile_raster_order
> +
> +Contact
> +
> +    Eric Anholt, Broadcom (eric at anholt.net)
> +
> +Status
> +
> +    Proposal
> +
> +Version
> +
> +    Last modified date: 26 July 2017
> +
> +Number
> +
> +    TBD
> +
> +Dependencies
> +
> +    GL_ARB_texture_barrier is required
> +
> +Overview
> +
> +    This extension extends the sampling-from-the-framebuffer behavior provided
> +    by GL_ARB_texture_barrier to allow setting the rasterization order of the
> +    scene, so that overlapping blits can be implemented.  This can be used for
> +    scrolling or window movement within in 2D scenes, without first copying to
> +    a temporary.
> +
> +IP Status
> +
> +    None
> +
> +Issues
> +
> +    1.  Should this extension also affect BlitFramebuffer?
> +
> +        NOT RESOLVED: BlitFramebuffer could use the same underlying
> +        functionality to provide defined results for 1:1 overlapping blits,
> +        but one could use the coordinates being copied to just produce the
> +        right result automatically, rather than requiring the state flags to
> +        be adjusted.
> +
> +New Procedures and Functions
> +
> +    None
> +
> +New Tokens
> +
> +    None
> +
> +Additions to Chapter 9 of the OpenGL 4.4 Specification (Per-Fragment
> +Operations and the Frame Buffer)
> +
> +    Modify Section 9.3.1 Rendering Feedback Loops, p. 289
> +
> +    Add the following exception to the list after "There is only a single read
> +    and write...":
> +
> +    - TILE_RASTER_ORDER_FIXED_MESA is enabled, and reads are only performed
> +      from texels offset from the current fragment shader invocation in the
> +      direction specified by TILE_RASTER_ORDER_INCREASING_X_MESA and
> +      TILE_RASTER_ORDER_INCREASING_Y_MESA (where those being disabled mean
> +      negative texel offsets), e.g. using "texelFetch2D(sampler,
> +      ivec2(gl_FragCoord.xy + vec2(dx, dy)), 0);".

I don't think we can implement any of this on our hardware, but 
regardless, I'm not sure that the spec language makes sense even for a 
tiled renderer.

Consider what happens when you're doing an overlapping blit in a 
maximally stupid way, by creating a pair of triangles for each pixel and 
then shuffling those triangles randomly. Is your hardware really capable 
of re-ordering all the generated fragments according to the prescribed 
raster order, even though they all originate from different primitives?

I suspect that a lot of hardware would even be challenged along the 
diagonal of a single pair of triangles covering the blit rectangle.

Cheers,
Nicolai


> +
> +Additions to the AGL/GLX/WGL Specifications
> +
> +    None
> +
> +GLX Protocol
> +
> +    None
> +
> +Errors
> +
> +    None
> +
> +New State
> +
> +    Get Value                            Type    Get Command    Initial Value Description                  Section   Attribute
> +    -----------------------------------  ------  -------------  ------------- ---------------------------  --------  ------------
> +    TILE_RASTER_ORDER_FIXED_MESA         B       IsEnabled      True          Tile rasterization order is  9.3.1     enable
> +                                                                              defined by
> +                                                                              TILE_RASTER_ORDER_INCREASING_*_MESA.
> +                                                                              in increasing X direction
> +    TILE_RASTER_ORDER_INCREASING_X_MESA  B       IsEnabled      True          Tiles are rasterized         9.3.1     enable
> +                                                                              in increasing X direction
> +    TILE_RASTER_ORDER_INCREASING_Y_MESA  B       IsEnabled      True          Tiles are rasterized         9.3.1     enable
> +                                                                              in increasing Y direction
> +
> +Revision History
> +
> +    26 July 2017 - Initial draft
> diff --git a/docs/specs/enums.txt b/docs/specs/enums.txt
> index 00d808483a43..4b0485f34901 100644
> --- a/docs/specs/enums.txt
> +++ b/docs/specs/enums.txt
> @@ -73,6 +73,11 @@ GL_MESA_program_debug
>   	GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA	0x8BB6
>   	GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA	0x8BB7
>   
> +GL_MESA_tile_raster_order
> +	GL_TILE_RASTER_ORDER_FIXED_MESA		0x8BB8
> +	GL_TILE_RASTER_ORDER_INCREASING_X_MESA	0x8BB9
> +	GL_TILE_RASTER_ORDER_INCREASING_Y_MESA	0x8BBA
> +
>   EGL_MESA_drm_image
>           EGL_DRM_BUFFER_FORMAT_MESA		0x31D0
>           EGL_DRM_BUFFER_USE_MESA			0x31D1
> diff --git a/include/GL/glext.h b/include/GL/glext.h
> index b7f611907211..a00f42c536b4 100644
> --- a/include/GL/glext.h
> +++ b/include/GL/glext.h
> @@ -12403,6 +12403,12 @@ GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (co
>   #define GL_FOG_SPECULAR_TEXTURE_WIN       0x80EC
>   #endif /* GL_WIN_specular_fog */
>   
> +/* XXX: Get a regenerated header with the enums properly present. */
> +#define GL_TILE_RASTER_ORDER_FIXED_MESA          0x8BB8
> +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA   0x8BB9
> +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA   0x8BBA
> +
> +
>   #ifdef __cplusplus
>   }
>   #endif
> diff --git a/src/mapi/glapi/gen/MESA_tile_raster_order.xml b/src/mapi/glapi/gen/MESA_tile_raster_order.xml
> new file mode 100644
> index 000000000000..a1f0cb89bee4
> --- /dev/null
> +++ b/src/mapi/glapi/gen/MESA_tile_raster_order.xml
> @@ -0,0 +1,13 @@
> +<?xml version="1.0"?>
> +<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
> +
> +<OpenGLAPI>
> +
> +<!-- XXX: need an extension number -->
> +<category name="GL_MESA_tile_rasterizer_order">
> +    <enum name="TILE_RASTER_ORDER_FIXED_MESA"              value="0x8BB8"/>
> +    <enum name="TILE_RASTER_ORDER_INCREASING_X_MESA"       value="0x8BB9"/>
> +    <enum name="TILE_RASTER_ORDER_INCREASING_Y_MESA"       value="0x8BBA"/>
> +</category>
> +
> +</OpenGLAPI>
> diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
> index bd04519f8042..45f30b7819c5 100644
> --- a/src/mapi/glapi/gen/Makefile.am
> +++ b/src/mapi/glapi/gen/Makefile.am
> @@ -208,6 +208,7 @@ API_XML = \
>   	KHR_robustness.xml \
>   	KHR_robustness_es.xml \
>   	KHR_texture_compression_astc.xml \
> +	MESA_tile_raster_order.xml \
>   	NV_conditional_render.xml \
>   	NV_primitive_restart.xml \
>   	NV_texture_barrier.xml \
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index fe527a0ae29b..f744801fc730 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -864,6 +864,8 @@ init_attrib_groups(struct gl_context *ctx)
>      _mesa_init_texture_s3tc( ctx );
>   
>      /* Miscellaneous */
> +   ctx->TileRasterOrderIncreasingX = GL_TRUE;
> +   ctx->TileRasterOrderIncreasingY = GL_TRUE;
>      ctx->NewState = _NEW_ALL;
>      ctx->NewDriverState = ~0;
>      ctx->ErrorValue = GL_NO_ERROR;
> diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
> index 2e5fb009314d..6d419b0013fa 100644
> --- a/src/mesa/main/enable.c
> +++ b/src/mesa/main/enable.c
> @@ -1040,6 +1040,33 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
>            }
>            break;
>   
> +      case GL_TILE_RASTER_ORDER_FIXED_MESA:
> +         CHECK_EXTENSION(MESA_tile_raster_order, cap);
> +         if (ctx->TileRasterOrderFixed != state) {
> +            FLUSH_VERTICES(ctx, 0);
> +            ctx->NewDriverState |= ctx->DriverFlags.NewTileRasterOrder;
> +            ctx->TileRasterOrderFixed = state;
> +         }
> +         break;
> +
> +      case GL_TILE_RASTER_ORDER_INCREASING_X_MESA:
> +         CHECK_EXTENSION(MESA_tile_raster_order, cap);
> +         if (ctx->TileRasterOrderIncreasingX != state) {
> +            FLUSH_VERTICES(ctx, 0);
> +            ctx->NewDriverState |= ctx->DriverFlags.NewTileRasterOrder;
> +            ctx->TileRasterOrderIncreasingX = state;
> +         }
> +         break;
> +
> +      case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA:
> +         CHECK_EXTENSION(MESA_tile_raster_order, cap);
> +         if (ctx->TileRasterOrderIncreasingY != state) {
> +            FLUSH_VERTICES(ctx, 0);
> +            ctx->NewDriverState |= ctx->DriverFlags.NewTileRasterOrder;
> +            ctx->TileRasterOrderIncreasingY = state;
> +         }
> +         break;
> +
>         /* GL 3.1 primitive restart.  Note: this enum is different from
>          * GL_PRIMITIVE_RESTART_NV (which is client state).
>          */
> diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
> index 757b7bf94239..08f7a3f49f07 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -310,6 +310,7 @@ EXT(KHR_texture_compression_astc_hdr        , KHR_texture_compression_astc_hdr
>   EXT(KHR_texture_compression_astc_ldr        , KHR_texture_compression_astc_ldr       , GLL, GLC,  x , ES2, 2012)
>   EXT(KHR_texture_compression_astc_sliced_3d  , KHR_texture_compression_astc_sliced_3d , GLL, GLC,  x , ES2, 2015)
>   
> +EXT(MESA_tile_raster_order                  , MESA_tile_raster_order                 , GLL, GLC,  x , ES2, 2017)
>   EXT(MESA_pack_invert                        , MESA_pack_invert                       , GLL, GLC,  x ,  x , 2002)
>   EXT(MESA_shader_integer_functions           , MESA_shader_integer_functions          , GLL, GLC,  x ,  30, 2016)
>   EXT(MESA_texture_signed_rgba                , EXT_texture_snorm                      , GLL, GLC,  x ,  x , 2009)
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 0d0536c7750e..34be919102ee 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -4166,6 +4166,7 @@ struct gl_extensions
>      GLboolean KHR_texture_compression_astc_hdr;
>      GLboolean KHR_texture_compression_astc_ldr;
>      GLboolean KHR_texture_compression_astc_sliced_3d;
> +   GLboolean MESA_tile_raster_order;
>      GLboolean MESA_pack_invert;
>      GLboolean MESA_shader_framebuffer_fetch;
>      GLboolean MESA_shader_framebuffer_fetch_non_coherent;
> @@ -4418,6 +4419,9 @@ struct gl_driver_flags
>      /** gl_context::RasterDiscard */
>      uint64_t NewRasterizerDiscard;
>   
> +   /** gl_context::TileRasterOrder* */
> +   uint64_t NewTileRasterOrder;
> +
>      /**
>       * gl_context::UniformBufferBindings
>       * gl_shader_program::UniformBlocks
> @@ -4958,6 +4962,15 @@ struct gl_context
>      GLboolean IntelConservativeRasterization; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
>   
>      /**
> +    * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
> +    * renderer's tiles should be excecuted, to meet the requirements of
> +    * GL_MESA_tile_raster_order.
> +    */
> +   GLboolean TileRasterOrderFixed;
> +   GLboolean TileRasterOrderIncreasingX;
> +   GLboolean TileRasterOrderIncreasingY;
> +
> +   /**
>       * \name Hooks for module contexts.
>       *
>       * These will eventually live in the driver or elsewhere.
> diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
> index 39be6b15a70e..4147340fd79a 100644
> --- a/src/mesa/state_tracker/st_atom_rasterizer.c
> +++ b/src/mesa/state_tracker/st_atom_rasterizer.c
> @@ -277,6 +277,11 @@ void st_update_rasterizer( struct st_context *st )
>   
>      /* ST_NEW_RASTERIZER */
>      raster->rasterizer_discard = ctx->RasterDiscard;
> +   if (ctx->TileRasterOrderFixed) {
> +      raster->tile_raster_order_fixed = true;
> +      raster->tile_raster_order_increasing_x = ctx->TileRasterOrderIncreasingX;
> +      raster->tile_raster_order_increasing_y = ctx->TileRasterOrderIncreasingY;
> +   }
>   
>      if (st->edgeflag_culls_prims) {
>         /* All edge flags are FALSE. Cull the affected faces. */
> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
> index 381ff9dae00d..ac214175b2cb 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -488,6 +488,7 @@ static void st_init_driver_flags(struct st_context *st)
>   
>      f->NewArray = ST_NEW_VERTEX_ARRAYS;
>      f->NewRasterizerDiscard = ST_NEW_RASTERIZER;
> +   f->NewTileRasterOrder = ST_NEW_RASTERIZER;
>      f->NewUniformBuffer = ST_NEW_UNIFORM_BUFFER;
>      f->NewDefaultTessLevels = ST_NEW_TESS_STATE;
>   
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 74193cc49285..f0fe7c2bb674 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -646,6 +646,7 @@ void st_init_extensions(struct pipe_screen *screen,
>         { o(AMD_seamless_cubemap_per_texture), PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE    },
>         { o(ATI_separate_stencil),             PIPE_CAP_TWO_SIDED_STENCIL                },
>         { o(ATI_texture_mirror_once),          PIPE_CAP_TEXTURE_MIRROR_CLAMP             },
> +      { o(MESA_tile_raster_order),           PIPE_CAP_TILE_RASTER_ORDER                },
>         { o(NV_conditional_render),            PIPE_CAP_CONDITIONAL_RENDER               },
>         { o(NV_fill_rectangle),                PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE      },
>         { o(NV_primitive_restart),             PIPE_CAP_PRIMITIVE_RESTART                },
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list