mesa: Implement a new GL_MESA_tile_raster_order extension.
authorEric Anholt <eric@anholt.net>
Tue, 25 Jul 2017 23:13:57 +0000 (16:13 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 10 Oct 2017 17:45:22 +0000 (10:45 -0700)
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).

v2: Fix glIsEnabled() on the new enums.
v3: Drop the local spec since I'm upstreaming the spec.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
docs/specs/enums.txt
include/GL/glext.h
src/mapi/glapi/gen/MESA_tile_raster_order.xml [new file with mode: 0644]
src/mapi/glapi/gen/Makefile.am
src/mesa/main/context.c
src/mesa/main/enable.c
src/mesa/main/extensions_table.h
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_atom_rasterizer.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_extensions.c

index 00d808483a43c1e65c8cecaa430f15ef85921674..4b0485f349011139f83ef27516671ee786725803 100644 (file)
@@ -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
index 613a8d4eca5f3db2b8c0f2f20a898f9421cd9364..7f47a3780c48f9d83662af758b943e92aab7e952 100644 (file)
@@ -12470,6 +12470,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 (file)
index 0000000..a1f0cb8
--- /dev/null
@@ -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>
index 7f4a46930309fcc294932554e9ee9ea6cfa92694..87d8517b7ba28a118b525e75587f1383f9911d1a 100644 (file)
@@ -210,6 +210,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 \
index 676103d477818a6b07c33fb822f609af6e753c77..6d24b93c1926698239f3a31bcc8b00a8a084a06b 100644 (file)
@@ -867,6 +867,8 @@ init_attrib_groups(struct gl_context *ctx)
       return GL_FALSE;
 
    /* Miscellaneous */
+   ctx->TileRasterOrderIncreasingX = GL_TRUE;
+   ctx->TileRasterOrderIncreasingY = GL_TRUE;
    ctx->NewState = _NEW_ALL;
    ctx->NewDriverState = ~0;
    ctx->ErrorValue = GL_NO_ERROR;
index 2e5fb009314da022a6be99e859a2c7feecba153b..8e99f2504f19042c086bf78e76f6a28f080368ec 100644 (file)
@@ -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).
        */
@@ -1716,6 +1743,18 @@ _mesa_IsEnabled( GLenum cap )
          CHECK_EXTENSION(INTEL_conservative_rasterization);
          return ctx->IntelConservativeRasterization;
 
+      case GL_TILE_RASTER_ORDER_FIXED_MESA:
+         CHECK_EXTENSION(MESA_tile_raster_order);
+         return ctx->TileRasterOrderFixed;
+
+      case GL_TILE_RASTER_ORDER_INCREASING_X_MESA:
+         CHECK_EXTENSION(MESA_tile_raster_order);
+         return ctx->TileRasterOrderIncreasingX;
+
+      case GL_TILE_RASTER_ORDER_INCREASING_Y_MESA:
+         CHECK_EXTENSION(MESA_tile_raster_order);
+         return ctx->TileRasterOrderIncreasingY;
+
       default:
          goto invalid_enum_error;
    }
index c1c39f9a16d1110798c09e7d5d0c15c284d929c2..a8dab772341e738f6fb191456383eef5c76dd6c1 100644 (file)
@@ -314,6 +314,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)
index 455e7514ab97dc841fae436d16cf64a244d51242..ea62d0bfb7127ef8e2a4032836f8f0e2e25754aa 100644 (file)
@@ -4186,6 +4186,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;
@@ -4437,6 +4438,9 @@ struct gl_driver_flags
    /** gl_context::RasterDiscard */
    uint64_t NewRasterizerDiscard;
 
+   /** gl_context::TileRasterOrder* */
+   uint64_t NewTileRasterOrder;
+
    /**
     * gl_context::UniformBufferBindings
     * gl_shader_program::UniformBlocks
@@ -4983,6 +4987,15 @@ struct gl_context
    /** Does glVertexAttrib(0) alias glVertex()? */
    bool _AttribZeroAliasesVertex;
 
+   /**
+    * 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.  
     *
index 39be6b15a70e9e6d8f54cfbdf4607ccfe46807f7..4147340fd79a6ac06c1a5fe9719cd6d855b4066b 100644 (file)
@@ -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. */
index 9610ad301464d254fb3960ace01be8e473610f72..69dd396a1cb80a7e1a9cce12dc316747a8276fb1 100644 (file)
@@ -489,6 +489,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;
 
index 1fbae9234e5e1bf494a080cb5a42246bfd2ffaf8..3dec5a87d73a9e82a50aa38a9e3c6b1c7e1f3fcc 100644 (file)
@@ -651,6 +651,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                },