Re: [Mesa-dev] OSMesa Help

2013-07-16 Thread Brian Paul
On 07/15/2013 05:38 PM, Andy Li wrote:
 Hi Brian,
 
 Thank you so much for your time and help along, up to this point, the 
 code make much more sense to me.
 However, I have a few more questions here, hope that you will be able to 
 help me out.
 
   I am wondering
 
 Where the aa_general_rgba_line() and aa_rgba_line() functions defined?

In s_aaline.c, see:

#define NAME(x) aa_rgba_##x
#define DO_Z
#include s_aalinetemp.h


#define NAME(x)  aa_general_rgba_##x
#define DO_Z
#define DO_ATTRIBS
#include s_aalinetemp.h

the NAME macro is used by the template code in the .h file to name the
functions.

 When and where the functions in s_aalinetemp.h and s_aaline.c are 
 called/used?

Called via swrast-Line().  You could run an AA line test program in
gdb, set a breakpoint on aa_rgba_line() and look at the stack trace.


 Are the draw_line, draw_triangle, draw_point functions in OSMesa some 
 how connected with src/mesa/main/line.c or point.c?

Not really.  The later files just set state related to those prims.


 Is it possible to take out some required functions for example 
 aa_rgba_line(), gl_context, etc. and compile it on my system so that I 
 can draw a line into the framebuffer? (Or since there are too many 
 functions linked together, you would not recommend me to do that?)

I don't think that's feasible.

-Brian

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] OSMesa Help

2013-07-15 Thread Jonathan Liu

On 10/07/2013 3: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?

Anyone know which are the base functions that OSMesa used for the 
rendering process?


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?


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?



Thank you for your time.


Andy.

See http://cgit.freedesktop.org/mesa/demos/tree/src/osdemos for example 
of using OSMesa.


Regards,
Jonathan
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] OSMesa Help

2013-07-15 Thread Brian Paul
On 07/14/2013 09:34 PM, Andy Li wrote:
 Hi,
 
 I have some questions on the OSMesa code.
 As you suggested, I have continue looking into the swrast code.
 However, I have trouble figuring out how the code works exactly.
 Now I am now only focusing on the functions which draw lines.
 As I look into s_lines.c, I saw the _swrast_choose_line().
 And depends on different cases, it will call
 
 _swrast_choose_aa_line_function(ctx)
 or
   USE(general_line)
 or
 USE(rgba_line)
 or
 USE(simple_no_z_rgba_line)
 etc.
 
 The first thing I did is looking into the 
 _swrast_choose_aa_line_function() and it direct me to s_aaline.c
 In that file, I saw the struct of LineInfo and other computation 
 functions for plane.
 Then I looked at the _swrast_choose_aa_line_function()
 
 and when I saw the code:
 swrast-Line = aa_general_rgba_line;
 and
 swrast-Line = aa_rgba_line;
 
 I am not sure what do they mean. And I won't be able to continue finding 
 useful info.

aa_rgba_line() drawns a simple RGBA antialiased line while
aa_general_rgba_line() also computes texture coords, fog coord, etc.



 I think the main problem I am having is I am not sure what are the steps 
 OSMesa have to take in order to draw a line into the frame buffer.
 Would you be able to explain a bit on that? (what are the steps OSMesa 
 have to take in order to draw a line into the frame buffer?)
 Does drawing a line involve computing the plane?

AA lines are drawn by drawing a quadrilateral and computing pixel
coverage involves computing plane equations.

 What do s_aaline.c and s_aalinetemp.h actually mean?

the temp files contain template code that's re-used multiple times in
the .c file.


 What is USE(general_line) ? Where is USE() define?

grep define USE src/mesa/swrast/*.[ch]


 What is swrast-Line = aa_general_rgba_line;?

swrast-Line is a function pointer that points to the current line
drawing function.  The function is chosen by examining current GL
rasterization state.


 Would you suggest any debugging tool for me so that I can trace which 
 functions are called while the program is running?
 For example I have the code below:
 glBegin(GL_LINES);
 glVertex3f(0.0, 0.0, 0.0);
 glVertex3f(15, 0, 0);
 glEnd();
 Is there any debugging tool which can trace glVertex3f back in the 
 library and see how OSMesa works?
 I have tried using gdb, however, it would only by-pass the call the go 
 to the next command.

You'll need to build mesa for debugging (CFLAGS=-g -O0
--enable-debug).  But I don't really have time to explain all the
nuances of debugging/tracing in Mesa.  I'm not sure that'd really help
you anyway.

In general, when you drawing points/lines/triangles the s_points.c or
s_lines.c or s_triangle.c code winds up calling _swrast_write_rgba()
span.  This function does Z testing, texturing, stippling, etc before
calling a put_pixels or put_row function.  Those functions call a
pack function to pack an array of RGBA ubyte/float values into the
framebuffer.  Packing involves converting a canonical RGBA format into a
specific pixel format, like RGBA, or RGB565, etc.  The color buffer
address, stride, etc. is obtained earlier through a call to
ctx-Driver.MapRenderbuffer().  In the case of OSMesa, the color buffer
is ordinary malloc'd memory that the user allocated.

-Brian



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] OSMesa Help

2013-07-15 Thread Andy Li
Hi Brian,
Thank you so much for your time and help along, up to this point, the code make 
much more sense to me.However, I have a few more questions here, hope that you 
will be able to help me out.
 I am wondering
Where the aa_general_rgba_line() and aa_rgba_line() functions defined?When and 
where the functions in s_aalinetemp.h and s_aaline.c are called/used?Are the 
draw_line, draw_triangle, draw_point functions in OSMesa some how connected 
with src/mesa/main/line.c or point.c?Is it possible to take out some required 
functions for example aa_rgba_line(), gl_context, etc. and compile it on my 
system so that I can draw a line into the framebuffer? (Or since there are too 
many functions linked together, you would not recommend me to do that?)
Thanks 
Andy.

 Date: Mon, 15 Jul 2013 08:24:58 -0600
 From: bri...@vmware.com
 To: lilap...@hotmail.com
 CC: mesa-dev@lists.freedesktop.org
 Subject: Re: [Mesa-dev] OSMesa Help
 
 On 07/14/2013 09:34 PM, Andy Li wrote:
  Hi,
  
  I have some questions on the OSMesa code.
  As you suggested, I have continue looking into the swrast code.
  However, I have trouble figuring out how the code works exactly.
  Now I am now only focusing on the functions which draw lines.
  As I look into s_lines.c, I saw the _swrast_choose_line().
  And depends on different cases, it will call
  
  _swrast_choose_aa_line_function(ctx)
  or
USE(general_line)
  or
  USE(rgba_line)
  or
  USE(simple_no_z_rgba_line)
  etc.
  
  The first thing I did is looking into the 
  _swrast_choose_aa_line_function() and it direct me to s_aaline.c
  In that file, I saw the struct of LineInfo and other computation 
  functions for plane.
  Then I looked at the _swrast_choose_aa_line_function()
  
  and when I saw the code:
  swrast-Line = aa_general_rgba_line;
  and
  swrast-Line = aa_rgba_line;
  
  I am not sure what do they mean. And I won't be able to continue finding 
  useful info.
 
 aa_rgba_line() drawns a simple RGBA antialiased line while
 aa_general_rgba_line() also computes texture coords, fog coord, etc.
 
 
 
  I think the main problem I am having is I am not sure what are the steps 
  OSMesa have to take in order to draw a line into the frame buffer.
  Would you be able to explain a bit on that? (what are the steps OSMesa 
  have to take in order to draw a line into the frame buffer?)
  Does drawing a line involve computing the plane?
 
 AA lines are drawn by drawing a quadrilateral and computing pixel
 coverage involves computing plane equations.
 
  What do s_aaline.c and s_aalinetemp.h actually mean?
 
 the temp files contain template code that's re-used multiple times in
 the .c file.
 
 
  What is USE(general_line) ? Where is USE() define?
 
 grep define USE src/mesa/swrast/*.[ch]
 
 
  What is swrast-Line = aa_general_rgba_line;?
 
 swrast-Line is a function pointer that points to the current line
 drawing function.  The function is chosen by examining current GL
 rasterization state.
 
 
  Would you suggest any debugging tool for me so that I can trace which 
  functions are called while the program is running?
  For example I have the code below:
  glBegin(GL_LINES);
  glVertex3f(0.0, 0.0, 0.0);
  glVertex3f(15, 0, 0);
  glEnd();
  Is there any debugging tool which can trace glVertex3f back in the 
  library and see how OSMesa works?
  I have tried using gdb, however, it would only by-pass the call the go 
  to the next command.
 
 You'll need to build mesa for debugging (CFLAGS=-g -O0
 --enable-debug).  But I don't really have time to explain all the
 nuances of debugging/tracing in Mesa.  I'm not sure that'd really help
 you anyway.
 
 In general, when you drawing points/lines/triangles the s_points.c or
 s_lines.c or s_triangle.c code winds up calling _swrast_write_rgba()
 span.  This function does Z testing, texturing, stippling, etc before
 calling a put_pixels or put_row function.  Those functions call a
 pack function to pack an array of RGBA ubyte/float values into the
 framebuffer.  Packing involves converting a canonical RGBA format into a
 specific pixel format, like RGBA, or RGB565, etc.  The color buffer
 address, stride, etc. is obtained earlier through a call to
 ctx-Driver.MapRenderbuffer().  In the case of OSMesa, the color buffer
 is ordinary malloc'd memory that the user allocated.
 
 -Brian
 
 
 
  ___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] OSMesa Help

2013-07-14 Thread Andy Li
Hi,
I have some questions on the OSMesa code.As you suggested, I have continue 
looking into the swrast code.However, I have trouble figuring out how the code 
works exactly.Now I am now only focusing on the functions which draw lines.As I 
look into s_lines.c, I saw the _swrast_choose_line().And depends on different 
cases, it will call
_swrast_choose_aa_line_function(ctx)or  
USE(general_line)orUSE(rgba_line)orUSE(simple_no_z_rgba_line)etc.
The first thing I did is looking into the _swrast_choose_aa_line_function() and 
it direct me to s_aaline.cIn that file, I saw the struct of LineInfo and other 
computation functions for plane.Then I looked at the 
_swrast_choose_aa_line_function()
and when I saw the code:swrast-Line = aa_general_rgba_line;andswrast-Line = 
aa_rgba_line;
I am not sure what do they mean. And I won't be able to continue finding useful 
info.
I think the main problem I am having is I am not sure what are the steps OSMesa 
have to take in order to draw a line into the frame buffer. Would you be able 
to explain a bit on that? ( what are the steps OSMesa have to take in order to 
draw a line into the frame buffer?)Does drawing a line involve computing the 
plane?What do s_aaline.c and s_aalinetemp.h actually mean? What is 
USE(general_line) ? Where is USE() define?What is swrast-Line = 
aa_general_rgba_line;?Would you suggest any debugging tool for me so that I can 
trace which functions are called while the program is running?For example I 
have the code below:glBegin(GL_LINES);glVertex3f(0.0, 0.0, 0.0);  
glVertex3f(15, 0, 0);glEnd();Is there any debugging tool which can trace 
glVertex3f back in the library and see how OSMesa works?I have tried using gdb, 
however, it would only by-pass the call the go to the next command.
Thank you so much for your time.
Andy.

 Date: Wed, 10 Jul 2013 12:53:19 -0600
 From: bri...@vmware.com
 To: lilap...@hotmail.com; mesa-dev@lists.freedesktop.org
 Subject: Re: [Mesa-dev] OSMesa Help
 
 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: bri...@vmware.com
To: lilap...@hotmail.com
CC: mesa-dev@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

Re: [Mesa-dev] OSMesa Help

2013-07-10 Thread Brian Paul

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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] OSMesa Help

2013-07-10 Thread Brian Paul
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: bri...@vmware.com
   To: lilap...@hotmail.com
   CC: mesa-dev@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
  

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] OSMesa Help

2013-07-09 Thread Matt Turner
On Tue, Jul 9, 2013 at 10:20 PM, Andy Li lilap...@hotmail.com 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?

 Anyone know which are the base functions that OSMesa used for the rendering
 process?

 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?

 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?

I suspect simply using one of the software drivers would be better.
Maybe you'll want to run this program on a real GPU some day, and then
it will run unmodified.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev