<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Direct3D</title><link>http://forums.xna.com/forums/27.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: When does the surface UnlockRect</title><link>http://forums.xna.com/forums/thread/61861.aspx</link><pubDate>Wed, 14 May 2008 15:49:19 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:61861</guid><dc:creator>David Hunt</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/61861.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=61861</wfw:commentRss><description>&lt;P&gt;You cannot unlock the surface until you are done accessing the pixel data. Once unlocked, the memory pointed to can (and likely will) be&amp;nbsp;invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>When does the surface UnlockRect</title><link>http://forums.xna.com/forums/thread/61807.aspx</link><pubDate>Wed, 14 May 2008 11:13:41 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:61807</guid><dc:creator>akira32</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/61807.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=61807</wfw:commentRss><description>&lt;P&gt;Can I timely let surface UnlockRect after LockRect.&lt;BR&gt;Is the "&amp;lt;==position1"(line9) surface UnlockRect postion correct? Does it have any probelm about the pointer of "lrect_New.pBits"?&lt;/P&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;
&lt;TABLE style="BORDER-RIGHT:#e5e5e5 1px solid;BORDER-TOP:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;WIDTH:525px;BORDER-BOTTOM:#e5e5e5 1px solid;BACKGROUND-COLOR:white;" cellSpacing=0 cellPadding=0&gt;

&lt;TR style="VERTICAL-ALIGN:top;LINE-HEIGHT:normal;"&gt;
&lt;TD style="WIDTH:40px;TEXT-ALIGN:right;"&gt;&lt;PRE style="BORDER-RIGHT:#e7e7e7 1px solid;PADDING-RIGHT:2px;PADDING-LEFT:2px;FONT-SIZE:11px;PADDING-BOTTOM:2px;MARGIN:0px;COLOR:gray;PADDING-TOP:2px;FONT-FAMILY:courier new;"&gt;1&lt;BR&gt;2&lt;BR&gt;3&lt;BR&gt;4&lt;BR&gt;5&lt;BR&gt;6&lt;BR&gt;7&lt;BR&gt;8&lt;BR&gt;9&lt;BR&gt;10&lt;BR&gt;11&lt;BR&gt;12&lt;BR&gt;13&lt;BR&gt;14&lt;BR&gt;15&lt;BR&gt;16&lt;BR&gt;17&lt;BR&gt;18&lt;BR&gt;19&lt;BR&gt;20&lt;BR&gt;21&lt;BR&gt;22&lt;BR&gt;23&lt;BR&gt;24&lt;BR&gt;25&lt;BR&gt;26&lt;BR&gt;27&lt;BR&gt;28&lt;BR&gt; &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD style="WIDTH:465px;"&gt;
&lt;DIV style="PADDING-RIGHT:2px;OVERFLOW-Y:hidden;PADDING-LEFT:8px;PADDING-BOTTOM:2px;MARGIN:0px;OVERFLOW:scroll;WIDTH:465px;PADDING-TOP:2px;"&gt;&lt;PRE&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;&amp;nbsp;&amp;nbsp;HRESULT hr;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;LPDIRECT3DSURFACE9 pDestSurface_New;&lt;BR&gt;&amp;nbsp;&amp;nbsp;D3DLOCKED_RECT lrect_New;&lt;BR&gt;&amp;nbsp;&amp;nbsp;D3DSURFACE_DESC Desc;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;m_QVSM_pShadowMapSurf_Common-&amp;gt;GetDesc(&amp;amp;Desc);&lt;BR&gt;&amp;nbsp;&amp;nbsp;V(m_pd3dDevice-&amp;gt;CreateOffscreenPlainSurface(Desc.Width,Desc.Height,Desc.Format,D3DPOOL_SYSTEMMEM,&amp;amp;pDestSurface_New,NULL));&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;//Must be D3DPOOL_SYSTEMMEM for MSDN&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;V(m_pd3dDevice-&amp;gt;GetRenderTargetData(m_QVSM_pShadowMapSurf_Common,pDestSurface_New));&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;hr=pDestSurface_New-&amp;gt;LockRect(&amp;amp;lrect_New,NULL,D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_READONLY);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;//hr=pDestSurface_New-&amp;gt;UnlockRect();//&amp;lt;==position1&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;for&lt;/SPAN&gt; (LONG y=0;y&amp;lt;(LONG)Desc.Height;y++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DWORD dwOffset &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; y*Desc.Width;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;for&lt;/SPAN&gt; (LONG x=0;x&amp;lt;(LONG)Desc.Width;x++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;//float dwColor_New = ((float*)lrect_New.pBits)[y*(lrect_New.Pitch/sizeof(float))+x];//Y*Width+X&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;float&lt;/SPAN&gt; dwColor_New &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; ((&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;float&lt;/SPAN&gt;*)lrect_New.pBits)[y*Desc.Width+x];&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;//Y*Width+X&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;int&lt;/SPAN&gt; c=12;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;hr=pDestSurface_New-&amp;gt;UnlockRect();&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;//&amp;lt;==position2&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;SAFE_RELEASE(pDestSurface_New);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description></item></channel></rss>