[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Dead code removal: removing code for unsupporte

From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] Dead code removal: removing code for unsupported DEPTH.
Date: Fri, 24 Mar 2017 13:36:58 +0000

On Thu, Mar 16, 2017 at 2:12 PM, Gerd Hoffmann <address@hidden> wrote:
>> > -#define DEPTH 8
>> > -#include "cirrus_vga_rop2.h"
>> > -
>> > -#define DEPTH 16
>> > -#include "cirrus_vga_rop2.h"
>> > -
>> > -#define DEPTH 24
>> > -#include "cirrus_vga_rop2.h"
>> > -
>> >  #define DEPTH 32
>> >  #include "cirrus_vga_rop2.h"
> No.  It isn't *that* simple.  The cirrus blitter operates on the guest
> framebuffer, which can have any format the guest wishes it to have.
> This is *not* about rendering into a 32bpp DisplaySurface.

Gerd, please reply if this is wrong, but here is a summary of the task:

Some emulated graphics cards use qemu_console_surface() and that
surface is always in 32 bits per pixel format.  Therefore, code for
dealing with other pixel formats can be removed.

When looking for emulated graphics cards where this cleanup is
possible, keep in mind that some of the code operates on the guest's
frame buffer, whose pixel format is not under QEMU's control.
Therefore we cannot assume that 32bpp is always used and this cleanup
doesn't apply there.  Limit yourself to code that uses
qemu_console_surface() exclusively to access the surface and you
should be fine.  Other code is likely to need support for additional
pixel formats.

One example is hw/display/milkymist-vgafb.c:

static void vgafb_update_display(void *opaque)
    DisplaySurface *surface = qemu_console_surface(s->con);
    switch (surface_bits_per_pixel(surface)) {
    case 0:
    case 8:
        fn = draw_line_8;
    case 15:
        fn = draw_line_15;
        dest_width *= 2;
    case 16:
        fn = draw_line_16;
        dest_width *= 2;
    case 24:
        fn = draw_line_24;
        dest_width *= 3;
    case 32:
        fn = draw_line_32;
        dest_width *= 4;

All cases except for 32 are dead code (they will never execute).  The
hw/display/milkymist-vgafb_template.h file can be deleted.
draw_line_32() can be macro expanded and moved into


reply via email to

[Prev in Thread] Current Thread [Next in Thread]