mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-05 06:53:57 +00:00
kdrive/fbdev: Don't try to accelerate rendering with glamor with a sw driver
It will likely be slower that unaccelerated rendering. Command-line flags were added for overriding this. Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
committed by
Enrico Weigelt
parent
f3c5b41161
commit
5adae6c3b3
189
glamor/glamor.c
189
glamor/glamor.c
@@ -835,75 +835,77 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
||||
if (!glamor_font_init(screen))
|
||||
goto fail;
|
||||
|
||||
glamor_priv->saved_procs.block_handler = screen->BlockHandler;
|
||||
screen->BlockHandler = _glamor_block_handler;
|
||||
if (!(flags & GLAMOR_NO_RENDER_ACCEL)) {
|
||||
glamor_priv->saved_procs.block_handler = screen->BlockHandler;
|
||||
screen->BlockHandler = _glamor_block_handler;
|
||||
|
||||
if (!glamor_composite_glyphs_init(screen)) {
|
||||
ErrorF("Failed to initialize composite masks\n");
|
||||
goto fail;
|
||||
if (!glamor_composite_glyphs_init(screen)) {
|
||||
ErrorF("Failed to initialize composite masks\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_priv->saved_procs.create_gc = screen->CreateGC;
|
||||
screen->CreateGC = glamor_create_gc;
|
||||
|
||||
glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
|
||||
screen->CreatePixmap = glamor_create_pixmap;
|
||||
|
||||
glamor_priv->saved_procs.get_spans = screen->GetSpans;
|
||||
screen->GetSpans = glamor_get_spans;
|
||||
|
||||
glamor_priv->saved_procs.get_image = screen->GetImage;
|
||||
screen->GetImage = glamor_get_image;
|
||||
|
||||
glamor_priv->saved_procs.change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||
|
||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
|
||||
glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
|
||||
if (ps) {
|
||||
glamor_priv->saved_procs.composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
|
||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
|
||||
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
|
||||
glamor_priv->saved_procs.addtraps = ps->AddTraps;
|
||||
ps->AddTraps = glamor_add_traps;
|
||||
|
||||
glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
|
||||
ps->CompositeRects = glamor_composite_rectangles;
|
||||
|
||||
glamor_priv->saved_procs.glyphs = ps->Glyphs;
|
||||
ps->Glyphs = glamor_composite_glyphs;
|
||||
}
|
||||
|
||||
glamor_init_vbo(screen);
|
||||
|
||||
glamor_priv->enable_gradient_shader = TRUE;
|
||||
|
||||
if (!glamor_init_gradient_shader(screen)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Cannot initialize gradient shader, falling back to software rendering for gradients\n",
|
||||
screen->myNum);
|
||||
glamor_priv->enable_gradient_shader = FALSE;
|
||||
}
|
||||
|
||||
glamor_pixmap_init(screen);
|
||||
glamor_sync_init(screen);
|
||||
|
||||
glamor_priv->screen = screen;
|
||||
|
||||
dixScreenHookClose(screen, glamor_close_screen);
|
||||
dixScreenHookPixmapDestroy(screen, glamor_pixmap_destroy);
|
||||
}
|
||||
|
||||
glamor_priv->saved_procs.create_gc = screen->CreateGC;
|
||||
screen->CreateGC = glamor_create_gc;
|
||||
|
||||
glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
|
||||
screen->CreatePixmap = glamor_create_pixmap;
|
||||
|
||||
glamor_priv->saved_procs.get_spans = screen->GetSpans;
|
||||
screen->GetSpans = glamor_get_spans;
|
||||
|
||||
glamor_priv->saved_procs.get_image = screen->GetImage;
|
||||
screen->GetImage = glamor_get_image;
|
||||
|
||||
glamor_priv->saved_procs.change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||
|
||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
|
||||
glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
|
||||
if (ps) {
|
||||
glamor_priv->saved_procs.composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
|
||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
|
||||
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
|
||||
glamor_priv->saved_procs.addtraps = ps->AddTraps;
|
||||
ps->AddTraps = glamor_add_traps;
|
||||
|
||||
glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
|
||||
ps->CompositeRects = glamor_composite_rectangles;
|
||||
|
||||
glamor_priv->saved_procs.glyphs = ps->Glyphs;
|
||||
ps->Glyphs = glamor_composite_glyphs;
|
||||
}
|
||||
|
||||
glamor_init_vbo(screen);
|
||||
|
||||
glamor_priv->enable_gradient_shader = TRUE;
|
||||
|
||||
if (!glamor_init_gradient_shader(screen)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Cannot initialize gradient shader, falling back to software rendering for gradients\n",
|
||||
screen->myNum);
|
||||
glamor_priv->enable_gradient_shader = FALSE;
|
||||
}
|
||||
|
||||
glamor_pixmap_init(screen);
|
||||
glamor_sync_init(screen);
|
||||
|
||||
glamor_priv->screen = screen;
|
||||
|
||||
dixScreenHookClose(screen, glamor_close_screen);
|
||||
dixScreenHookPixmapDestroy(screen, glamor_pixmap_destroy);
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
@@ -931,33 +933,38 @@ static void glamor_close_screen(CallbackListPtr *pcbl, ScreenPtr screen, void *u
|
||||
PixmapPtr screen_pixmap;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_sync_close(screen);
|
||||
glamor_composite_glyphs_fini(screen);
|
||||
glamor_set_glvnd_vendor(screen, NULL);
|
||||
|
||||
dixScreenUnhookClose(screen, glamor_close_screen);
|
||||
dixScreenUnhookPixmapDestroy(screen, glamor_pixmap_destroy);
|
||||
|
||||
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
||||
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
||||
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_priv->saved_procs.change_window_attributes;
|
||||
screen->CopyWindow = glamor_priv->saved_procs.copy_window;
|
||||
screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
|
||||
screen->BlockHandler = glamor_priv->saved_procs.block_handler;
|
||||
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
if (ps) {
|
||||
ps->Composite = glamor_priv->saved_procs.composite;
|
||||
ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
|
||||
ps->Triangles = glamor_priv->saved_procs.triangles;
|
||||
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
|
||||
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
||||
if (!(glamor_priv->flags & GLAMOR_NO_RENDER_ACCEL)) {
|
||||
glamor_sync_close(screen);
|
||||
glamor_composite_glyphs_fini(screen);
|
||||
}
|
||||
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_pixmap_destroy_fbo(screen_pixmap);
|
||||
glamor_set_glvnd_vendor(screen, NULL);
|
||||
|
||||
if (!(glamor_priv->flags & GLAMOR_NO_RENDER_ACCEL)) {
|
||||
dixScreenUnhookClose(screen, glamor_close_screen);
|
||||
dixScreenUnhookPixmapDestroy(screen, glamor_pixmap_destroy);
|
||||
|
||||
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
||||
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
||||
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_priv->saved_procs.change_window_attributes;
|
||||
screen->CopyWindow = glamor_priv->saved_procs.copy_window;
|
||||
screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
|
||||
screen->BlockHandler = glamor_priv->saved_procs.block_handler;
|
||||
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
if (ps) {
|
||||
ps->Composite = glamor_priv->saved_procs.composite;
|
||||
ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
|
||||
ps->Triangles = glamor_priv->saved_procs.triangles;
|
||||
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
|
||||
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
||||
}
|
||||
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_pixmap_destroy_fbo(screen_pixmap);
|
||||
}
|
||||
|
||||
glamor_release_screen_priv(screen);
|
||||
}
|
||||
|
||||
@@ -65,10 +65,12 @@ typedef Bool (*GetDrawableModifiersFuncPtr) (DrawablePtr draw,
|
||||
uint64_t **modifiers);
|
||||
|
||||
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
||||
#define GLAMOR_USE_EGL_SCREEN (1 << 0)
|
||||
#define GLAMOR_NO_DRI3 (1 << 1)
|
||||
#define GLAMOR_USE_EGL_SCREEN (1 << 0)
|
||||
#define GLAMOR_NO_DRI3 (1 << 1)
|
||||
#define GLAMOR_NO_RENDER_ACCEL (1 << 2)
|
||||
#define GLAMOR_VALID_FLAGS (GLAMOR_USE_EGL_SCREEN \
|
||||
| GLAMOR_NO_DRI3)
|
||||
| GLAMOR_NO_DRI3 \
|
||||
| GLAMOR_NO_RENDER_ACCEL)
|
||||
|
||||
/* until we need geometry shaders GL3.1 should suffice. */
|
||||
#define GLAMOR_GL_CORE_VER_MAJOR 3
|
||||
|
||||
@@ -24,6 +24,8 @@ char *fbdev_glvnd_provider = NULL;
|
||||
|
||||
Bool es_allowed = TRUE;
|
||||
Bool force_es = FALSE;
|
||||
Bool fbGlamorAllowed = TRUE;
|
||||
Bool fbForceGlamor = FALSE;
|
||||
Bool fbXVAllowed = TRUE;
|
||||
|
||||
static void
|
||||
@@ -97,7 +99,19 @@ fbdevInitAccel(ScreenPtr pScreen)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN | GLAMOR_NO_DRI3)) {
|
||||
int flags = GLAMOR_USE_EGL_SCREEN | GLAMOR_NO_DRI3;
|
||||
if (!fbGlamorAllowed) {
|
||||
flags |= GLAMOR_NO_RENDER_ACCEL;
|
||||
} else if (!fbForceGlamor){
|
||||
const char *renderer = (const char*)glGetString(GL_RENDERER);
|
||||
if (!renderer ||
|
||||
strstr(renderer, "softpipe") ||
|
||||
strstr(renderer, "llvmpipe")) {
|
||||
flags |= GLAMOR_NO_RENDER_ACCEL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glamor_init(pScreen, flags)) {
|
||||
fbdev_glamor_egl_cleanup(scrpriv);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -112,7 +126,8 @@ fbdevInitAccel(ScreenPtr pScreen)
|
||||
#endif
|
||||
|
||||
#ifdef XV
|
||||
if (fbXVAllowed) {
|
||||
/* X-Video needs glamor render accel */
|
||||
if (fbXVAllowed && !(flags & GLAMOR_NO_RENDER_ACCEL)) {
|
||||
kd_glamor_xv_init(pScreen);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -66,6 +66,8 @@ extern Bool fbDisableShadow;
|
||||
extern char *fbdev_glvnd_provider;
|
||||
extern Bool es_allowed;
|
||||
extern Bool force_es;
|
||||
extern Bool fbGlamorAllowed;
|
||||
extern Bool fbForceGlamor;
|
||||
#ifdef XV
|
||||
extern Bool fbXVAllowed;
|
||||
#endif
|
||||
|
||||
@@ -72,6 +72,10 @@ ddxUseMsg(void)
|
||||
("-fb path Framebuffer device to use. Defaults to /dev/fb0\n");
|
||||
ErrorF
|
||||
("-noshadow Disable the ShadowFB layer if possible\n");
|
||||
ErrorF
|
||||
("-glamor Force enable glamor render acceleration if possible\n");
|
||||
ErrorF
|
||||
("-noglamor Force disable glamor render acceleration\n");
|
||||
ErrorF
|
||||
("-glvendor Suggest what glvnd vendor library should be used\n");
|
||||
ErrorF
|
||||
@@ -101,6 +105,16 @@ ddxProcessArgument(int argc, char **argv, int i)
|
||||
}
|
||||
|
||||
#ifdef GLAMOR
|
||||
if (!strcmp(argv[i], "-glamor")) {
|
||||
fbForceGlamor = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-noglamor")) {
|
||||
fbGlamorAllowed = FALSE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-glvendor")) {
|
||||
if (i + 1 < argc) {
|
||||
fbdev_glvnd_provider = strdup(argv[i + 1]);
|
||||
|
||||
Reference in New Issue
Block a user