[Mesa-dev] OSMesa Help

Brian Paul brianp at vmware.com
Wed Jul 10 11:53:19 PDT 2013


Please keep your replies on the list so that others can potentially
help/reply.

On 07/10/2013 12:05 PM, Andy Li wrote:
> Hi Brain,
> 
> Thank you for your reply.
> You were right, my plan is to use OSMesa and draw into malloc'd frame 
> buffer in my device, so I can display the image on the screen.
> 
> For base functions, what i meant are the drawline() or drawpix() functions.
> In other words, I am wondering which are the functions OSMesa used to 
> draw a line/pixel into the memory (changing the color/rgba value in 
> frame buffer)?


In the swrast code, look at s_lines.c, s_triangle.c, etc. to see how
lines and triangles are drawn.  In some (simple) cases we can write
directly into the framebuffer but other times we call functions like
_swrast_write_rgba_span() to do fragment processing/writing.

To access the framebuffer's memory we use the
ctx->Driver.Map/UnmapRenderbuffer() functions.


> Why am I trying to find these functions? The other part of my project is 
> to rewrite these functions with an accelerator, so that I can speed up 
> the rendering process with the embedded system I am using.
> 
> Would you be able to give me some info/ suggestions on what I am doing?

See above.  Otherwise, just study the code for a while.  It's not all
that complicated.

-Brian

> 
> Thanks,
> 
> Andy
> 
>  > Date: Wed, 10 Jul 2013 07:49:09 -0600
>  > From: brianp at vmware.com
>  > To: lilapkiu at hotmail.com
>  > CC: mesa-dev at lists.freedesktop.org
>  > Subject: Re: [Mesa-dev] OSMesa Help
>  >
>  > On 07/09/2013 11:20 PM, Andy Li wrote:
>  > > Hello everyone,
>  > >
>  > >
>  > > I have some questions regarding to OSMesa.
>  > >
>  > > I am currently working on a project which I have to use Mesa on an
>  > > embedded system.
>  > >
>  > > My current goal is to port the base functions over to the embedded
>  > > system, so that I can draw a line on a provided VGA screen.
>  > >
>  > > Since the embedded system I am using does not contain a GPU, 
> therefore I
>  > > have decided to use OSMesa for rendering process.
>  > >
>  > > I am wondering if there are any documentations/ specifications for 
> OSMesa?
>  >
>  > End users of OSMesa generally get by on the comments in osmesa.h and the
>  > example programs. But you're working on the driver implementation side.
>  >
>  >
>  > > Anyone know which are the base functions that OSMesa used for the
>  > > rendering process?
>  >
>  > I don't know what you mean by base functions. In Mesa/master git, the
>  > OSMesa can either be used with the legacy swrast driver or with the
>  > gallium softpipe/llvmpipe drivers.
>  >
>  >
>  > > I have looked into src/mesa/swrast/s_lines.c and s_drawpix.c and trying
>  > > to figure out how the code works, am I in the right direction?
>  >
>  > That code is used by the legacy OSMesa driver, but it's also used by the
>  > old Xlib driver too.
>  >
>  >
>  > > Moreover, for example, if I found a drawpix() function, how do I 
> know if
>  > > OSMesa actually used this function during rendering process? Is there
>  > > any tool/debugger I can use to confirm my findings?
>  >
>  > One would normally set a breakpoint on the function in gdb or another
>  > debugger.
>  >
>  > Let's take a few steps back here first. You said you want to display
>  > graphics on your VGA screen. OSMesa will not do that for you.
>  > OS=Off-Screen. The whole point of OSMesa is to draw into malloc'd
>  > framebuffer memory, rather than drawing to a real/displayed framebuffer.
>  >
>  > You could use OSMesa and then do some sort of memcpy of the image into
>  > your devices's actual frame buffer. Is that what you want to do?
>  >
>  > -Brian
>  >



More information about the mesa-dev mailing list