Re: [PATCH 1/2] glamor: add support for allocating linear buffers
at which point you'd want to continue the versioning from the mesa point to avoid epochs. So I don't take your argument, the API version is what we ship in the gbm.pc file, compatible implementations should make the same API changes in their same versions. Other companies may use different versionning schemes (/MM/DD) and which they cannot shift away from for whatever reason. Based on that (plus the libEGL libgbm ABI mentioned above) sticking with use mesa's version seems a bit impossible/narrow minded imho. I think we can all agree things are less than perfect and checking the version in the pc file is not a good idea. gbm.pc is the gbm API version number. It isn't the Mesa version number, it just happens at the moment they are the same thing because nobody has split them, and because there isn't much value to Mesa in doing so. Other projects implementing the gbm API need to use the same version number for their gbm.pc file. it sucks but otherwise they are not API compatible. This doesn't mean they cannot use other versioning schemes for their project, but their gbm.pc needs to be compatible with Mesa. But yes checking the version sucks and I'd rather not do it, but it doesn't escape the fact that other gbm implementations are currently doing it wrong if they want to be API compatible. Dave. ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: composite_glyphs on vc4
Eric Anholt e...@anholt.net writes: After this series, I'm at 143000 glyphs/sec, up from 2640 glyphs/sec with the old always-fallbacks path. For the series: Reviewed-by: Keith Packard kei...@keithp.com -- -keith signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PULL] glamor VC4 crash fixes
The following changes since commit fa12f2c150b2f50de9dac4a2b09265f13af353af: glamor: don't do render ops with matching source/dest (v3) (2015-06-02 14:16:26 +1000) are available in the git repository at: git://people.freedesktop.org/~anholt/xserver glamor-next for you to fetch changes up to 790311cec30ac3d35e580b9f1266236f558033d4: glamor: Don't try to disable attrib divisors without the extension. (2015-06-19 19:11:05 -0700) Eric Anholt (4): glamor: Actually allow glyphs of dimension 65 to 128 in the cache. glamor: Clean up some declarations in glyph rendering. glamor: Skip actual FBO setup in our glyph atlas. glamor: Don't try to disable attrib divisors without the extension. glamor/glamor.c | 4 +++- glamor/glamor_composite_glyphs.c | 20 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH] modesetting: Fix a compiler warning about CARD32 vs uint32_t.
Signed-off-by: Eric Anholt e...@anholt.net --- hw/xfree86/drivers/modesetting/dri2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c index 63cb065..8dc12b7 100644 --- a/hw/xfree86/drivers/modesetting/dri2.c +++ b/hw/xfree86/drivers/modesetting/dri2.c @@ -138,7 +138,7 @@ ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, ScrnInfoPtr scrn = xf86ScreenToScrn(screen); DRI2Buffer2Ptr buffer; PixmapPtr pixmap; -uint32_t size; +CARD32 size; uint16_t pitch; ms_dri2_buffer_private_ptr private; -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 4/7] glamor: Use GL_EXT_map_buffer_range if present.
We were only looking for the desktop GL version of the extension, so GLES2 missed out. Signed-off-by: Eric Anholt e...@anholt.net --- glamor/glamor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 0378388..935fb74 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -454,7 +454,8 @@ glamor_init(ScreenPtr screen, unsigned int flags) glamor_priv-has_fbo_blit = epoxy_has_gl_extension(GL_EXT_framebuffer_blit); glamor_priv-has_map_buffer_range = -epoxy_has_gl_extension(GL_ARB_map_buffer_range); +epoxy_has_gl_extension(GL_ARB_map_buffer_range) || +epoxy_has_gl_extension(GL_EXT_map_buffer_range); glamor_priv-has_buffer_storage = epoxy_has_gl_extension(GL_ARB_buffer_storage); glamor_priv-has_nv_texture_barrier = -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 2/7] glamor: Drop CloseScreen-time GL resource cleanup code.
These will all be freed when the context is freed. Signed-off-by: Eric Anholt e...@anholt.net --- glamor/glamor.c | 5 - glamor/glamor_core.c | 11 --- glamor/glamor_gradient.c | 21 - glamor/glamor_priv.h | 3 --- glamor/glamor_render.c | 21 - glamor/glamor_vbo.c | 1 - 6 files changed, 62 deletions(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 71ca4f4..a951cec 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -585,13 +585,8 @@ glamor_release_screen_priv(ScreenPtr screen) glamor_screen_private *glamor_priv; glamor_priv = glamor_get_screen_private(screen); -glamor_fini_composite_shaders(screen); glamor_fini_vbo(screen); glamor_fini_pixmap_fbo(screen); -glamor_fini_finish_access_shaders(screen); -#ifdef GLAMOR_GRADIENT_SHADER -glamor_fini_gradient_shader(screen); -#endif glamor_pixmap_fini(screen); free(glamor_priv); diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c index 965024e..4f3526c 100644 --- a/glamor/glamor_core.c +++ b/glamor/glamor_core.c @@ -283,17 +283,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen) glUniform1i(glamor_priv-finish_access_swap_rb[1], 0); } -void -glamor_fini_finish_access_shaders(ScreenPtr screen) -{ -glamor_screen_private *glamor_priv; - -glamor_priv = glamor_get_screen_private(screen); -glamor_make_current(glamor_priv); -glDeleteProgram(glamor_priv-finish_access_prog[0]); -glDeleteProgram(glamor_priv-finish_access_prog[1]); -} - GCOps glamor_gc_ops = { .FillSpans = glamor_fill_spans, .SetSpans = glamor_set_spans, diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c index d34131d..30c29f6 100644 --- a/glamor/glamor_gradient.c +++ b/glamor/glamor_gradient.c @@ -582,27 +582,6 @@ glamor_init_gradient_shader(ScreenPtr screen) _glamor_create_radial_gradient_program(screen, RADIAL_LARGE_STOPS, 0); } -void -glamor_fini_gradient_shader(ScreenPtr screen) -{ -glamor_screen_private *glamor_priv; -int i = 0; - -glamor_priv = glamor_get_screen_private(screen); -glamor_make_current(glamor_priv); - -for (i = 0; i 3; i++) { -/* Linear Gradient */ -if (glamor_priv-gradient_prog[SHADER_GRADIENT_LINEAR][i]) -glDeleteProgram(glamor_priv-gradient_prog -[SHADER_GRADIENT_LINEAR][i]); - -if (glamor_priv-gradient_prog[SHADER_GRADIENT_RADIAL][i]) -glDeleteProgram(glamor_priv-gradient_prog -[SHADER_GRADIENT_RADIAL][i]); -} -} - static void _glamor_gradient_convert_trans_matrix(PictTransform *from, float to[3][3], int width, int height, int normalize) diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 480d13b..438d1e9 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -645,7 +645,6 @@ glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv, /* glamor_core.c */ void glamor_init_finish_access_shaders(ScreenPtr screen); -void glamor_fini_finish_access_shaders(ScreenPtr screen); Bool glamor_get_drawable_location(const DrawablePtr drawable); void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap, @@ -703,7 +702,6 @@ void glamor_composite(CARD8 op, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); void glamor_init_composite_shaders(ScreenPtr screen); -void glamor_fini_composite_shaders(ScreenPtr screen); void glamor_composite_rects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, xRectangle *rects); @@ -722,7 +720,6 @@ void glamor_trapezoids(CARD8 op, /* glamor_gradient.c */ void glamor_init_gradient_shader(ScreenPtr screen); -void glamor_fini_gradient_shader(ScreenPtr screen); PicturePtr glamor_generate_linear_gradient_picture(ScreenPtr screen, PicturePtr src_picture, int x_source, int y_source, diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 05eee91..1849cce 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -414,27 +414,6 @@ glamor_init_composite_shaders(ScreenPtr screen) free(eb); } -void -glamor_fini_composite_shaders(ScreenPtr screen) -{ -glamor_screen_private *glamor_priv; -glamor_composite_shader *shader; -int i, j, k; - -glamor_priv = glamor_get_screen_private(screen); -glamor_make_current(glamor_priv); -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -glDeleteBuffers(1, glamor_priv-ebo); - -for (i = 0; i SHADER_SOURCE_COUNT; i++) -for (j = 0; j SHADER_MASK_COUNT; j++) -for (k = 0; k SHADER_IN_COUNT; k++) { -shader = glamor_priv-composite_shader[i][j][k]; -if (shader-prog) -glDeleteProgram(shader-prog); -
[PATCH 3/7] Use the normal GL_QUADS drawing helper in the render code.
We use this for all of our other performance-sensitive rendering, too. Signed-off-by: Eric Anholt e...@anholt.net --- glamor/glamor.c| 1 - glamor/glamor_priv.h | 7 +++ glamor/glamor_render.c | 50 -- 3 files changed, 7 insertions(+), 51 deletions(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index a951cec..0378388 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -554,7 +554,6 @@ glamor_init(ScreenPtr screen, unsigned int flags) glamor_priv-saved_procs.destroy_picture = ps-DestroyPicture; ps-DestroyPicture = glamor_destroy_picture; -glamor_init_composite_shaders(screen); glamor_priv-saved_procs.set_window_pixmap = screen-SetWindowPixmap; screen-SetWindowPixmap = glamor_set_window_pixmap; diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 438d1e9..c80df22 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -248,8 +248,8 @@ typedef struct glamor_screen_private { int glyph_max_dim; char*glyph_defines; -/* vertext/elment_index buffer object for render */ -GLuint vbo, ebo; +/** Vertex buffer for all GPU rendering. */ +GLuint vbo; /** Next offset within the VBO that glamor_get_vbo_space() will use. */ int vbo_offset; int vbo_size; @@ -262,7 +262,7 @@ typedef struct glamor_screen_private { char *vb; int vb_stride; Bool has_source_coords, has_mask_coords; -int render_nr_verts; +int render_nr_quads; glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT] [SHADER_MASK_COUNT] [SHADER_IN_COUNT]; @@ -701,7 +701,6 @@ void glamor_composite(CARD8 op, INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height); -void glamor_init_composite_shaders(ScreenPtr screen); void glamor_composite_rects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRect, xRectangle *rects); diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 1849cce..4a82534 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -379,41 +379,6 @@ glamor_lookup_composite_shader(ScreenPtr screen, struct return shader; } -static void -glamor_init_eb(unsigned short *eb, int vert_cnt) -{ -int i, j; - -for (i = 0, j = 0; j vert_cnt; i += 6, j += 4) { -eb[i] = j; -eb[i + 1] = j + 1; -eb[i + 2] = j + 2; -eb[i + 3] = j; -eb[i + 4] = j + 2; -eb[i + 5] = j + 3; -} -} - -void -glamor_init_composite_shaders(ScreenPtr screen) -{ -glamor_screen_private *glamor_priv; -unsigned short *eb; -int eb_size; - -glamor_priv = glamor_get_screen_private(screen); -glamor_make_current(glamor_priv); -glGenBuffers(1, glamor_priv-ebo); -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv-ebo); - -eb_size = GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(short) * 2; - -eb = XNFalloc(eb_size); -glamor_init_eb(eb, GLAMOR_COMPOSITE_VBO_VERT_CNT); -glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW); -free(eb); -} - static Bool glamor_set_composite_op(ScreenPtr screen, CARD8 op, struct blendinfo *op_info_result, @@ -647,7 +612,7 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts) char *vbo_offset; float *vb; -glamor_priv-render_nr_verts = 0; +glamor_priv-render_nr_quads = 0; glamor_priv-vb_stride = 2 * sizeof(float); if (glamor_priv-has_source_coords) glamor_priv-vb_stride += 2 * sizeof(float); @@ -689,17 +654,10 @@ glamor_flush_composite_rects(ScreenPtr screen) glamor_make_current(glamor_priv); -if (!glamor_priv-render_nr_verts) +if (!glamor_priv-render_nr_quads) return; -if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) { -glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv-render_nr_verts, -(glamor_priv-render_nr_verts * 3) / 2, -GL_UNSIGNED_SHORT, NULL); -} else { -glDrawElements(GL_TRIANGLES, (glamor_priv-render_nr_verts * 3) / 2, - GL_UNSIGNED_SHORT, NULL); -} +glamor_glDrawArrays_GL_QUADS(glamor_priv, glamor_priv-render_nr_quads); } int pict_format_combine_tab[][3] = { @@ -1249,7 +1207,7 @@ glamor_composite_with_shader(CARD8 op, vertices, vb_stride); vertices += 2; } -glamor_priv-render_nr_verts += 4; +glamor_priv-render_nr_quads++; rects++; /* We've incremented by one of our 4 verts, now do the other 3. */ -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 1/7] glamor: Fix text rendering on GLES2.
The GL_QUADS helper takes a number of quads, not a number of vertices. --- glamor/glamor_composite_glyphs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c index 1f0d75e..e92f1d9 100644 --- a/glamor/glamor_composite_glyphs.c +++ b/glamor/glamor_composite_glyphs.c @@ -256,7 +256,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst, if (glamor_glyph_use_130(glamor_priv)) glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph); else -glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph * 4); +glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph); } } if (prog-alpha != glamor_program_alpha_ca_first) -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 6/7] glamor: Use proper Bools for some boolean values.
Signed-off-by: Eric Anholt e...@anholt.net --- glamor/glamor_priv.h | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 17f8253..681895f 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -194,16 +194,16 @@ typedef struct glamor_screen_private { unsigned int tick; enum glamor_gl_flavor gl_flavor; int glsl_version; -int has_pack_invert; -int has_fbo_blit; -int has_map_buffer_range; -int has_buffer_storage; -int has_khr_debug; -int has_nv_texture_barrier; -int has_pack_subimage; -int has_unpack_subimage; +Bool has_pack_invert; +Bool has_fbo_blit; +Bool has_map_buffer_range; +Bool has_buffer_storage; +Bool has_khr_debug; +Bool has_nv_texture_barrier; +Bool has_pack_subimage; +Bool has_unpack_subimage; +Bool has_rw_pbo; int max_fbo_size; -int has_rw_pbo; struct xorg_list fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT]; -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 5/7] glamor: Provide a fallback path for using an index buffer to do quads.
Improves x11perf -aa10text performance by 1377.59% +/- 23.8198% (n=93) on Intel with GLES2. Signed-off-by: Eric Anholt e...@anholt.net --- glamor/glamor.c | 62 +++ glamor/glamor_priv.h | 11 + glamor/glamor_utils.h | 4 +--- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 935fb74..fbb1d85 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -274,6 +274,68 @@ glamor_set_debug_level(int *debug_level) int glamor_debug_level; +void +glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv, +unsigned count) +{ +unsigned i; + +/* For a single quad, don't bother with an index buffer. */ +if (count == 1) +goto fallback; + +if (glamor_priv-ib_size count) { +/* Basic GLES2 doesn't have any way to map buffer objects for + * writing, but it's long past time for drivers to have + * MapBufferRange. + */ +if (!glamor_priv-has_map_buffer_range) +goto fallback; + +/* Lazy create the buffer name, and only bind it once since + * none of the glamor code binds it to anything else. + */ +if (!glamor_priv-ib) { +glGenBuffers(1, glamor_priv-ib); +glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv-ib); +} + +/* For now, only support GL_UNSIGNED_SHORTs. */ +if (count ((1 16) - 1) / 4) { +goto fallback; +} else { +uint16_t *data; +size_t size = count * 6 * sizeof(GLushort); + +glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW); +data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, +0, size, +GL_MAP_WRITE_BIT | +GL_MAP_INVALIDATE_BUFFER_BIT); +for (i = 0; i count; i++) { +data[i * 6 + 0] = i * 4 + 0; +data[i * 6 + 1] = i * 4 + 1; +data[i * 6 + 2] = i * 4 + 2; +data[i * 6 + 3] = i * 4 + 0; +data[i * 6 + 4] = i * 4 + 2; +data[i * 6 + 5] = i * 4 + 3; +} +glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + +glamor_priv-ib_size = count; +glamor_priv-ib_type = GL_UNSIGNED_SHORT; +} +} + +glDrawElements(GL_TRIANGLES, count * 6, glamor_priv-ib_type, NULL); +return; + +fallback: +for (i = 0; i count; i++) +glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); +} + + /** * Creates any pixmaps used internally by glamor, since those can't be * allocated at ScreenInit time. diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index c80df22..17f8253 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -261,6 +261,14 @@ typedef struct glamor_screen_private { */ char *vb; int vb_stride; + +/** Cached index buffer for translating GL_QUADS to triangles. */ +GLuint ib; +/** Index buffer type: GL_UNSIGNED_SHORT or GL_UNSIGNED_INT */ +GLenum ib_type; +/** Number of quads the index buffer has indices for. */ +unsigned ib_size; + Bool has_source_coords, has_mask_coords; int render_nr_quads; glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT] @@ -643,6 +651,9 @@ glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv, int flag, int block_w, int block_h, glamor_pixmap_private *); +void glamor_gldrawarrays_quads_using_indices(glamor_screen_private *glamor_priv, + unsigned count); + /* glamor_core.c */ void glamor_init_finish_access_shaders(ScreenPtr screen); diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index 0927ffb..73cda9c 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -1403,9 +1403,7 @@ glamor_glDrawArrays_GL_QUADS(glamor_screen_private *glamor_priv, unsigned count) if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) { glDrawArrays(GL_QUADS, 0, count * 4); } else { -unsigned i; -for (i = 0; i count; i++) -glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); +glamor_gldrawarrays_quads_using_indices(glamor_priv, count); } } -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 7/7] glamor: Avoid using GL_QUADS on VC4.
Improves text rendering from about 284k glyphs per second to 320k glyphs per second. There's no GL extension for probing this, because of the philosophy of Don't expose whether things are really in hardware or not. Signed-off-by: Eric Anholt e...@anholt.net --- glamor/glamor.c | 9 + glamor/glamor_priv.h | 1 + glamor/glamor_utils.h | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index fbb1d85..525249c 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -531,6 +531,15 @@ glamor_init(ScreenPtr screen, unsigned int flags) epoxy_gl_version() = 30 || epoxy_has_gl_extension(GL_NV_pack_subimage); +glamor_priv-use_quads = (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP); +/* Driver-specific hack: Avoid using GL_QUADS on VC4, where + * they'll be emulated more expensively than we can with our + * cached IB. + */ +if (strstr((char *)glGetString(GL_VENDOR), Broadcom) +strstr((char *)glGetString(GL_RENDERER), VC4)) +glamor_priv-use_quads = FALSE; + glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, glamor_priv-max_fbo_size); glGetIntegerv(GL_MAX_TEXTURE_SIZE, glamor_priv-max_fbo_size); glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size); diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index 681895f..3e666b4 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -203,6 +203,7 @@ typedef struct glamor_screen_private { Bool has_pack_subimage; Bool has_unpack_subimage; Bool has_rw_pbo; +Bool use_quads; int max_fbo_size; struct xorg_list diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h index 73cda9c..66c3492 100644 --- a/glamor/glamor_utils.h +++ b/glamor/glamor_utils.h @@ -1400,7 +1400,7 @@ glamor_make_current(glamor_screen_private *glamor_priv) static inline void glamor_glDrawArrays_GL_QUADS(glamor_screen_private *glamor_priv, unsigned count) { -if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) { +if (glamor_priv-use_quads) { glDrawArrays(GL_QUADS, 0, count * 4); } else { glamor_gldrawarrays_quads_using_indices(glamor_priv, count); -- 2.1.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 1/2] glamor: add support for allocating linear buffers
On 19 June 2015 at 02:12, Dave Airlie airl...@gmail.com wrote: On 19 June 2015 at 02:02, Emil Velikov emil.l.veli...@gmail.com wrote: On 15 June 2015 at 05:08, Michel Dänzer mic...@daenzer.net wrote: On 12.06.2015 08:48, Dave Airlie wrote: We need this for doing USB offload scenarios using glamor and modesetting driver. unfortunately only gbm in mesa 10.6 has support for the linear API. Signed-off-by: Dave Airlie airl...@redhat.com --- configure.ac | 5 + glamor/glamor.h | 3 ++- glamor/glamor_egl.c | 5 - glamor/glamor_egl_stubs.c | 2 +- glamor/glamor_fbo.c | 10 +- hw/xwayland/xwayland-glamor.c | 2 +- include/dix-config.h.in | 3 +++ 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index f760730..d0908e5 100644 --- a/configure.ac +++ b/configure.ac @@ -2105,6 +2105,11 @@ if test x$GLAMOR = xyes; then if test x$GBM = xyes; then AC_DEFINE(GLAMOR_HAS_GBM, 1, [Build glamor with GBM-based EGL support]) + PKG_CHECK_MODULES(GBM_HAS_LINEAR, gbm = 10.6.0, [GBM_HAS_LINEAR=yes], [GBM_HAS_LINEAR=no]) + if test x$GBM_HAS_LINEAR = xyes; then + AC_DEFINE(GLAMOR_HAS_GBM_LINEAR, 1, + [Build glamor/gbm has linear support]) + fi It would be better to use AC_CHECK_DECL for this, as is done in xf86-video-amdgpu. That way it does the right thing even if somebody backports GBM_BO_USE_LINEAR to an older version of Mesa. Fwiw I second this suggestion. As we know GBM is an API and others may provide alternative implementation of it (for example CrOS has minigbm). Imho using the mesa version in (m)any of the pc files is a bug, which should be addressed, rather than relied upon. I'll change it because I prefer the suggestion, but GBM is both an API and an ABI, Agreed. so really the pc.in represents the API version, What I'm saying is: considering the API/ABI changes introduced in the library, it seems wrong to have used the mesa version inside gbm.pc. Either way the deed is done, and there isn't much we can do about it. so any compatible API should use the mesa version in its gbm.pc file until such time as someone splits the gbm API out into a separate project, Considering the tight integration (dare I say it hidden, unversioned and unchecked ABI) between libEGL and libgbm, this might be a bit of a pain to achieve and/or maintain. at which point you'd want to continue the versioning from the mesa point to avoid epochs. So I don't take your argument, the API version is what we ship in the gbm.pc file, compatible implementations should make the same API changes in their same versions. Other companies may use different versionning schemes (/MM/DD) and which they cannot shift away from for whatever reason. Based on that (plus the libEGL libgbm ABI mentioned above) sticking with use mesa's version seems a bit impossible/narrow minded imho. I think we can all agree things are less than perfect and checking the version in the pc file is not a good idea. Now the problem I don't solve here, is how to know if the GBM ABI supports passing the linear flag in, since we don't bump the library version often, and I've no idea if there is any nice way to make it discoverable. I believe it's the packager's responsibility to ensure that the runtime library version is the same or greater than the build time one. Some projects have section for packagers in their release notes, to prevent/minimise slip-ups in the dependency handling/tracking. Cheers, Emil ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 2/6] modesetting: add output master support
Dave Airlie airl...@gmail.com writes: This allows a glamor enabled master device to have slave USB devices attached. Tested with modesetting on SNB + USB. It relies on the previous patch to export linear buffers from glamor. Signed-off-by: Dave Airlie airl...@redhat.com I don't know the slave stuff really, but it seems reasonable. Acked-by: Eric Anholt e...@anholt.net signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 5/6] cursor: add hw cursor support for prime
Dave Airlie airl...@gmail.com writes: Currently with PRIME if we detect a secondary GPU, we switch to using SW cursors, this isn't optimal, esp for the intel/nvidia combinations, we have no choice for the USB offload devices. This patch checks on each slave screen if hw cursors are enabled, and also calls set cursor and move cursor on all screens. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 2 + hw/xfree86/ramdac/xf86Cursor.c | 12 + hw/xfree86/ramdac/xf86CursorPriv.h | 1 + hw/xfree86/ramdac/xf86HWCurs.c | 92 -- 4 files changed, 94 insertions(+), 13 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 9208582..f3d0f19 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3920,6 +3920,8 @@ AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , update_desktop_dimensions(); +dixRegisterScreenPrivateKey(cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, +0); return i; } diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 2a54571..175bed7 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -337,17 +337,9 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, return; } -if (infoPtr-pScrn-vtSema xorg_list_is_empty(pScreen-pixmap_dirty_list) +if (infoPtr-pScrn-vtSema (ScreenPriv-ForceHWCursorCount || - (( - cursor-bits-argb - infoPtr-UseHWCursorARGB - (*infoPtr-UseHWCursorARGB)(pScreen, cursor)) || - (cursor-bits-argb == 0 - (cursor-bits-height = infoPtr-MaxHeight) - (cursor-bits-width = infoPtr-MaxWidth) - (!infoPtr-UseHWCursor || (*infoPtr-UseHWCursor) (pScreen, cursor)) { - + xf86CheckHWCursor(pScreen, cursor, infoPtr))) { if (ScreenPriv-SWCursor) /* remove the SW cursor */ (*ScreenPriv-spriteFuncs-SetCursor) (pDev, pScreen, NullCursor, x, y); diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h index f34c1c7..397d2a1 100644 --- a/hw/xfree86/ramdac/xf86CursorPriv.h +++ b/hw/xfree86/ramdac/xf86CursorPriv.h @@ -43,6 +43,7 @@ void xf86MoveCursor(ScreenPtr pScreen, int x, int y); void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed); Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr); +Bool xf86CheckHWCursor(ScreenPtr pScreen, CursorPtr cursor, xf86CursorInfoPtr infoPtr); extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec; #define xf86CursorScreenKey (xf86CursorScreenKeyRec) diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c index 84febe0..84d1ff7 100644 --- a/hw/xfree86/ramdac/xf86HWCurs.c +++ b/hw/xfree86/ramdac/xf86HWCurs.c @@ -119,8 +119,52 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr) return TRUE; } +static Bool +xf86CursorScreenCheckHW(ScreenPtr pScreen, CursorPtr cursor, xf86CursorInfoPtr infoPtr) This might be better renamed xf86ScreenCheckHWCursor, to match how you handled MoveCursor/SetCursor outside-loop versus screen functions. +{ +return (( + cursor-bits-argb + infoPtr-UseHWCursorARGB + (*infoPtr-UseHWCursorARGB)(pScreen, cursor)) || +(cursor-bits-argb == 0 +(cursor-bits-height = infoPtr-MaxHeight) +(cursor-bits-width = infoPtr-MaxWidth) + (!infoPtr-UseHWCursor || (*infoPtr-UseHWCursor) (pScreen, cursor; It might be nice to expand this out a little: if (cursor-bits-argb) { if (infoPtr-UseHWCursorARGB (*infoPtr-UseHWCursorARGB)(pScreen, cursor)) { return TRUE; } } else { if (cursor-bits-height = infoPtr-MaxHeight cursor-bits-width = infoPtr-MaxWidth (!infoPtr-UseHWCursor || (*infoPtr-UseHWCursor) (pScreen, cursor)) { return TRUE; } } return FALSE; but you're just moving the code around, not writing it in the first place, so either way. +} + Bool -xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) +xf86CheckHWCursor(ScreenPtr pScreen, CursorPtr cursor, xf86CursorInfoPtr infoPtr) +{ +ScreenPtr pSlave; +PixmapDirtyUpdatePtr ent; +Bool ret; +ret = xf86CursorScreenCheckHW(pScreen, cursor, infoPtr); +if (ret == FALSE) +return FALSE; + +if (xorg_list_is_empty(pScreen-pixmap_dirty_list)) +return TRUE; The empty check here seems gratuitous, since the list_for_each just won't do anything if it's empty, right? (same below) + +/* ask each driver consuming a
Re: [PATCH 1/6] glamor: add support for allocating linear buffers (v1.1)
Dave Airlie airl...@gmail.com writes: We need this for doing USB offload scenarios using glamor and modesetting driver. unfortunately only gbm in mesa 10.6 has support for the linear API. It seems like in the linear case, we should make the FBO as external so it doesn't get released back into the FBO cache. Other than that, Reviewed-by: Eric Anholt e...@anholt.net signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 3/6] glamor: egl: add function to back a pixmap with a dma-buf.
Dave Airlie airl...@gmail.com writes: Rather than create the pixmap, this uses the file descriptor to change an existing pixmaps backing store. This is required for reverse prime slaves, where we create the slave pixmap, then set the backing store. Signed-off-by: Dave Airlie airl...@redhat.com --- glamor/glamor.h | 19 +++ glamor/glamor_egl.c | 52 +++- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/glamor/glamor.h b/glamor/glamor.h index 657354d..f402d7d 100644 --- a/glamor/glamor.h +++ b/glamor/glamor.h @@ -218,6 +218,25 @@ extern _X_EXPORT PixmapPtr glamor_pixmap_from_fd(ScreenPtr screen, CARD8 depth, CARD8 bpp); +/* @glamor_back_pixmap_from_fd: Backs an existing pixmap with a dma-buf fd. + * + * @pixmap: Pixmap to change backing for + * @fd: The dma-buf fd to import. + * @width: The width of the buffer. + * @height: The height of the buffer. + * @stride: The stride of the buffer. + * @depth: The depth of the buffer. + * @bpp: The number of bpp of the buffer. + * + * Returns TRUE if successful, FALSE on failure. + * */ +extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr pixmap, + int fd, + CARD16 width, + CARD16 height, + CARD16 stride, + CARD8 depth, + CARD8 bpp); #ifdef GLAMOR_FOR_XORG #define GLAMOR_EGL_MODULE_NAME glamoregl diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 4c0db6a..994dbd2 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -461,19 +461,18 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen, #endif } -_X_EXPORT PixmapPtr -glamor_pixmap_from_fd(ScreenPtr screen, - int fd, - CARD16 width, - CARD16 height, - CARD16 stride, CARD8 depth, CARD8 bpp) +_X_EXPORT Bool +glamor_back_pixmap_from_fd(PixmapPtr pixmap, + int fd, + CARD16 width, + CARD16 height, + CARD16 stride, CARD8 depth, CARD8 bpp) { #ifdef GLAMOR_HAS_GBM -ScrnInfoPtr scrn = xf86ScreenToScrn(screen); +ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap-drawable.pScreen); I slightly prefer having a local ScreenPtr screen = pixmap-drawable.pScreen, but either way: Reviewed-by: Eric Anholt e...@annholt.net signature.asc Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 4/6] modesetting: reverse prime support
Dave Airlie airl...@gmail.com writes: This adds support for reverse prime to the modesetting driver. Reverse prime is where we have two GPUs in the display chain, but the second GPU can't scanout from the shared pixmap, so needs an extra copy to the on screen pixmap. This allows modesetting to support this scenario while still supporting the USB offload one. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/drivers/modesetting/driver.c | 17 +- hw/xfree86/drivers/modesetting/drmmode_display.c | 76 ++-- hw/xfree86/drivers/modesetting/drmmode_display.h | 4 +- 3 files changed, 88 insertions(+), 9 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index 092cc53..f421668 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -572,7 +572,7 @@ msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask) pScreen-BlockHandler(pScreen, pTimeout, pReadmask); ms-BlockHandler = pScreen-BlockHandler; pScreen-BlockHandler = msBlockHandler; -if (pScreen-isGPU) +if (pScreen-isGPU !ms-drmmode.reverse_prime_offload_mode) dispatch_slave_dirty(pScreen); else if (ms-dirty_enabled) dispatch_dirty(pScreen); @@ -999,10 +999,18 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle) ScrnInfoPtr scrn = xf86ScreenToScrn(screen); modesettingPtr ms = modesettingPTR(scrn); Bool ret; -int size = ppix-devKind * ppix-drawable.height; int ihandle = (int) (long) fd_handle; -ret = drmmode_SetSlaveBO(ppix, ms-drmmode, ihandle, ppix-devKind, size); +if (ms-drmmode.reverse_prime_offload_mode) { +ret = glamor_back_pixmap_from_fd(ppix, ihandle, + ppix-drawable.width, + ppix-drawable.height, + ppix-devKind, ppix-drawable.depth, + ppix-drawable.bitsPerPixel); +} else { +int size = ppix-devKind * ppix-drawable.height; +ret = drmmode_SetSlaveBO(ppix, ms-drmmode, ihandle, ppix-devKind, size); +} if (ret == FALSE) return ret; @@ -1190,6 +1198,9 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv) xf86DrvMsg(pScrn-scrnIndex, X_ERROR, Failed to initialize the Present extension.\n); } +/* enable reverse prime if we are a GPU screen, and accelerated */ +if (pScreen-isGPU) +ms-drmmode.reverse_prime_offload_mode = TRUE; } #endif diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index f3c9909..e36c092 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -50,6 +50,7 @@ #include driver.h +static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height); static int drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo) { @@ -343,10 +344,14 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, fb_id = drmmode-fb_id; if (crtc-randr_crtc-scanout_pixmap) { -msPixmapPrivPtr ppriv = -msGetPixmapPriv(drmmode, crtc-randr_crtc-scanout_pixmap); -fb_id = ppriv-fb_id; -x = y = 0; +if (!drmmode-reverse_prime_offload_mode) { +msPixmapPrivPtr ppriv = +msGetPixmapPriv(drmmode, crtc-randr_crtc-scanout_pixmap); +fb_id = ppriv-fb_id; +x = 0; +} else +x = drmmode_crtc-prime_pixmap_x; +y = 0; } else if (drmmode_crtc-rotate_fb_id) { fb_id = drmmode_crtc-rotate_fb_id; @@ -502,7 +507,56 @@ drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t * red, uint16_t * green, } static Bool -drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) +drmmode_set_scanout_pixmap_gpu(xf86CrtcPtr crtc, PixmapPtr ppix) +{ +ScreenPtr screen = xf86ScrnToScreen(crtc-scrn); +PixmapPtr screenpix = screen-GetScreenPixmap(screen); +xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc-scrn); +drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; +int c, total_width = 0, max_height = 0, this_x = 0; + +if (!ppix) { +if (crtc-randr_crtc-scanout_pixmap) +PixmapStopDirtyTracking(crtc-randr_crtc-scanout_pixmap, screenpix); +drmmode_crtc-prime_pixmap_x = 0; +return TRUE; +} +/* iterate over all the attached crtcs - + work out bounding box */ Funny formatting, how about just: /* iterate over all the attached crtcs to work out the bounding box */ +for (c = 0; c