[692] | 1 | <HTML> |
---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 3 | <!-- Created on , 12 2006 by texi2html 1.64 --> |
---|
| 4 | <!-- |
---|
| 5 | Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) |
---|
| 6 | Karl Berry <karl@freefriends.org> |
---|
| 7 | Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
| 8 | and many others. |
---|
| 9 | Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
| 10 | Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> |
---|
| 11 | |
---|
| 12 | --> |
---|
| 13 | <HEAD> |
---|
| 14 | <TITLE>OGRE Manual v1.2.0 ('Dagon'): Locking buffers</TITLE> |
---|
| 15 | |
---|
| 16 | <META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Locking buffers"> |
---|
| 17 | <META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Locking buffers"> |
---|
| 18 | <META NAME="resource-type" CONTENT="document"> |
---|
| 19 | <META NAME="distribution" CONTENT="global"> |
---|
| 20 | <META NAME="Generator" CONTENT="texi2html 1.64"> |
---|
| 21 | <LINK TYPE="text/css" rel="stylesheet" href="../style.css"> |
---|
| 22 | </HEAD> |
---|
| 23 | |
---|
| 24 | <BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"> |
---|
| 25 | |
---|
| 26 | <A NAME="SEC234"></A> |
---|
| 27 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
| 28 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_44.html#SEC233"> < </A>]</TD> |
---|
| 29 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_41.html#SEC230"> Up </A>]</TD> |
---|
| 30 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_46.html#SEC236"> > </A>]</TD> |
---|
| 31 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
| 32 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
| 33 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
| 34 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
| 35 | </TR></TABLE> |
---|
| 36 | <HR SIZE=1> |
---|
| 37 | <H2> 5.4 Locking buffers </H2> |
---|
| 38 | <!--docid::SEC234::--> |
---|
| 39 | In order to read or update a hardware buffer, you have to 'lock' it. This performs 2 functions - it tells the card that you want access to the buffer (which can have an effect on its rendering queue), and it returns a pointer which you can manipulate. Note that if you've asked to read the buffer (and remember, you really shouldn't unless you've set the buffer up with a shadow buffer), the contents of the hardware buffer will have been copied into system memory somewhere in order for you to get access to it. For the same reason, when you're finished with the buffer you must unlock it; if you locked the buffer for writing this will trigger the process of uploading the modified information to the graphics hardware. |
---|
| 40 | <BR><BR> |
---|
| 41 | <A NAME="SEC235"></A> |
---|
| 42 | <H3> Lock parameters </H3> |
---|
| 43 | <!--docid::SEC235::--> |
---|
| 44 | When you lock a buffer, you call one of the following methods: |
---|
| 45 | <TABLE><tr><td> </td><td class=example><pre>// Lock the entire buffer |
---|
| 46 | pBuffer->lock(lockType); |
---|
| 47 | // Lock only part of the buffer |
---|
| 48 | pBuffer->lock(start, length, lockType); |
---|
| 49 | </pre></td></tr></table>The first call locks the entire buffer, the second locks only the section from 'start' (as a byte offset), for 'length' bytes. This could be faster than locking the entire buffer since less is transferred, but not if you later update the rest of the buffer too, because doing it in small chunks like this means you cannot use HBL_DISCARD (see below). |
---|
| 50 | <BR><BR> |
---|
| 51 | The lockType parameter can have a large effect on the performance of your application, especially if you are not using a shadow buffer. |
---|
| 52 | <DL COMPACT> |
---|
| 53 | <DT><CODE>HBL_NORMAL</CODE> |
---|
| 54 | <DD>This kind of lock allows reading and writing from the buffer - it's also the least optimal because basically you're telling the card you could be doing anything at all. If you're not using a shadow buffer, it requires the buffer to be transferred from the card and back again. If you're using a shadow buffer the effect is minimal. |
---|
| 55 | <DT><CODE>HBL_READ_ONLY</CODE> |
---|
| 56 | <DD>This means you only want to read the contents of the buffer. Best used when you created the buffer with a shadow buffer because in that case the data does not have to be downloaded from the card. |
---|
| 57 | <DT><CODE>HBL_DISCARD</CODE> |
---|
| 58 | <DD>This means you are happy for the card to discard the <EM>entire current contents</EM> of the buffer. Implicitly this means you are not going to read the data - it also means that the card can avoid any stalls if the buffer is currently being rendered from, because it will actually give you an entirely different one. Use this wherever possible when you are locking a buffer which was not created with a shadow buffer. If you are using a shadow buffer it matters less, although with a shadow buffer it's preferable to lock the entire buffer at once, because that allows the shadow buffer to use HBL_DISCARD when it uploads the updated contents to the real buffer. |
---|
| 59 | <DT><CODE>HBL_NO_OVERWRITE</CODE> |
---|
| 60 | <DD>This is useful if you are locking just part of the buffer and thus cannot use HBL_DISCARD. It tells the card that you promise not to modify any section of the buffer which has already been used in a rendering operation this frame. Again this is only useful on buffers with no shadow buffer. |
---|
| 61 | </DL> |
---|
| 62 | <P> |
---|
| 63 | |
---|
| 64 | Once you have locked a buffer, you can use the pointer returned however you wish (just don't bother trying to read the data that's there if you've used HBL_DISCARD, or write the data if you've used HBL_READ_ONLY). Modifying the contents depends on the type of buffer, See section <A HREF="manual_47.html#SEC237">5.6 Hardware Vertex Buffers</A> and See section <A HREF="manual_52.html#SEC245">5.7 Hardware Index Buffers</A> |
---|
| 65 | </P><P> |
---|
| 66 | |
---|
| 67 | <A NAME="Practical Buffer Tips"></A> |
---|
| 68 | <HR SIZE=1> |
---|
| 69 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
| 70 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_44.html#SEC233"> < </A>]</TD> |
---|
| 71 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_41.html#SEC230"> Up </A>]</TD> |
---|
| 72 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_46.html#SEC236"> > </A>]</TD> |
---|
| 73 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
| 74 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
| 75 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
| 76 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
| 77 | </TR></TABLE> |
---|
| 78 | <BR> |
---|
| 79 | <FONT SIZE="-1"> |
---|
| 80 | This document was generated |
---|
| 81 | by <I>Steve Streeting</I> on <I>, 12 2006</I> |
---|
| 82 | using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html |
---|
| 83 | "><I>texi2html</I></A> |
---|
| 84 | |
---|
| 85 | </BODY> |
---|
| 86 | </HTML> |
---|