<?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 10 </title><link>http://forums.xna.com/forums/29.aspx</link><description>Only questions about the Direct3D 10 API are permitted here.</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/187159.aspx</link><pubDate>Mon, 08 Jun 2009 03:21:23 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:187159</guid><dc:creator>trogo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/187159.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=187159</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Nightmare:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:13px;"&gt;so the update thread does:&lt;br /&gt;
- Wait for &amp;#39;FrameTick&amp;#39; event&lt;br /&gt;
- Update renderable object (fill the command que)&lt;br /&gt;
- Fire &amp;#39;BeginRender&amp;#39; event&lt;br /&gt;
- Update non renderable objects&lt;br /&gt;
- Wait for &amp;#39;RenderComplete&amp;#39; event&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
So, with this algorithm, you are using just 1 buffer, isn&amp;#39;t?&lt;br /&gt;
&lt;br /&gt;
&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Nightmare:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Now i wonder, how much will buffering increase my game code?&lt;br /&gt;
i could make something like this:&lt;br /&gt;
- Wait for &amp;#39;FrameTick&amp;#39; event&lt;br /&gt;
- Update renderable objects (fill the command que)&lt;br /&gt;
- Fire &amp;#39;SwapRenderBuffer&amp;#39; event (this make the render thread to copy the command que)&lt;br /&gt;
- Update non renderable object&lt;br /&gt;
&lt;br /&gt;
this would make the render thread keep looping without delays and keep processing the same command que till the &amp;#39;SwatRenderBuffer&amp;#39; even is called to make copy of the new command list.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
And, with this one you would use 2 buffer at least.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size:13px;"&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Nightmare:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/span&gt;so the first method i currently testing with is pretty simple, its just allow the update thread to do some stuff while im rendering instead of waiting for the render code to complete before continue. While the second method would probably have a higher render FPS as update FPS (is this a good thing or asking for problems?)&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
That&amp;#39;s it. &lt;strong&gt;With multithreading you will be able to do other things while some other thread is rendering&lt;/strong&gt;. &lt;span style="text-decoration:underline;"&gt;Using 2 buffers is nosense to me if you are not using multithreading&lt;/span&gt;. So, as you are using multithreading, multi-buffering should work fine with you.&lt;br /&gt;
&lt;br /&gt;
Multibuffering allows you to make a scene more complex. While rendered-buffer is being drawing, updated-buffer should be updated. And, &lt;strong&gt;the scene could become as complex as more and more buffers are added to your engine&lt;/strong&gt;. Recommended are 2 buffers for the update thread and one for the rendering thread. This way, your render thread can consume an already just processed buffer, while you are working with the other one. All of this while maintaining your fps or even improving it.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size:13px;"&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Nightmare:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/span&gt;Next to my update/render thread i also wanna add a paralel thread for the networking system and add some kind of thread pool with background workers for loading data on the background.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
Just test it. But take note that &lt;strong&gt;you should not create more hard-working threads than cores are on the system&lt;/strong&gt;. So, if running a Athlon 64 X2 (for example), you should not create more than 2 threads. &lt;em&gt;Side-note: I am using a Athlon 64 with just 1 core and my engine works fine. Obviously the game using it doesn&amp;#39;t use very complex scenes&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size:13px;"&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Nightmare:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/span&gt;so my main questions: Sync threads or use buffering and will render/update at different FPS improve performance or is that a bad idea?&lt;/span&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
Nope. Allways sync threads. Because if not done this way, you are going to loose control over your FPS rates. The main question here is: sync by using just 1 buffer (no sync needed at all) or sync by using multiple buffers? I tested both of them, and performance improved a lot by using multiple buffers.&lt;br /&gt;
&lt;br /&gt;
Finally, there are people knowing much more than I, so wait for a answer from them while testing your solution.</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/150805.aspx</link><pubDate>Tue, 17 Mar 2009 09:27:41 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:150805</guid><dc:creator>Nightmare</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/150805.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=150805</wfw:commentRss><description>im trying to implement multithreading as well in my application and after reading this post i wonder if im doing it the right way.&lt;br /&gt;
&lt;span style="font-size:13px;"&gt;&lt;br /&gt;
im not using multi buffers on the D3D part but working with some self made buffer thingy.&lt;br /&gt;
&lt;br /&gt;
currently im still testing whats the best way.&lt;br /&gt;
&lt;br /&gt;
First of all my render thread using a &amp;quot;renderQue&amp;quot;,  wich is a list of commands to execute by the render thread.&lt;br /&gt;
For example, when i call RenderManager::SetVertexBuffer() it will create a add a new command to the list, rather then directly execute the code.&lt;br /&gt;
&lt;br /&gt;
The command code is pretty simple using derived classes&lt;br /&gt;
class IRenderCommand&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
   virtual void ExecuteCommand();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
sample of the SetIndexBuffer code&lt;br /&gt;
class CmdSetIB : public IRenderCommand&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    void ExecuteCommand()&lt;br /&gt;
    {&lt;br /&gt;
        pD3DDevice-&amp;gt;IASetIndexBuffer( pBuffer );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
    ID3D10Device    pDevice;&lt;br /&gt;
    ID3D10Buffer    pBuffer;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The render thread just loops trough the command list and execute each command.&lt;br /&gt;
&lt;br /&gt;
Currently the update/render thread running at the same speed.&lt;br /&gt;
&lt;br /&gt;
so the update thread does:&lt;br /&gt;
- Wait for &amp;#39;FrameTick&amp;#39; event&lt;br /&gt;
- Update renderable object (fill the command que)&lt;br /&gt;
- Fire &amp;#39;BeginRender&amp;#39; event&lt;br /&gt;
- Update non renderable objects&lt;br /&gt;
- Wait for &amp;#39;RenderComplete&amp;#39; event&lt;br /&gt;
&lt;br /&gt;
this make my update/render thread run at the same speed.&lt;br /&gt;
So i fill my render command list, fire up the render thread (wich should be idle at this point) and process/empty the command list)&lt;br /&gt;
&lt;br /&gt;
Now i wonder, how much will buffering increase my game code?&lt;br /&gt;
i could make something like this:&lt;br /&gt;
- Wait for &amp;#39;FrameTick&amp;#39; event&lt;br /&gt;
- Update renderable objects (fill the command que)&lt;br /&gt;
- Fire &amp;#39;SwapRenderBuffer&amp;#39; event (this make the render thread to copy the command que)&lt;br /&gt;
- Update non renderable object&lt;br /&gt;
&lt;br /&gt;
this would make the render thread keep looping without delays and keep processing the same command que till the &amp;#39;SwatRenderBuffer&amp;#39; even is called to make copy of the new command list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
so the first method i currently testing with is pretty simple, its just allow the update thread to do some stuff while im rendering instead of waiting for the render code to complete before continue. While the second method would probably have a higher render FPS as update FPS (is this a good thing or asking for problems?)&lt;br /&gt;
&lt;br /&gt;
Next to my update/render thread i also wanna add a paralel thread for the networking system and add some kind of thread pool with background workers for loading data on the background.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
so my main questions: Sync threads or use buffering and will render/update at different FPS improve performance or is that a bad idea?&lt;/span&gt;</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/114583.aspx</link><pubDate>Tue, 02 Dec 2008 22:40:23 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:114583</guid><dc:creator>trogo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/114583.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=114583</wfw:commentRss><description>OMG! Thank you a lot jwatte.&lt;br /&gt;
&lt;br /&gt;
Nowadays I am restructuring my codebase (switching it to OOP), so it will last some time until I implement &lt;span style="color:red;cursor:hand;font-weight:bold;text-decoration:underline;"&gt;this&lt;/span&gt; &lt;span style="color:red;cursor:hand;font-weight:bold;text-decoration:underline;"&gt;algorithm&lt;/span&gt;.</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/114169.aspx</link><pubDate>Tue, 02 Dec 2008 01:52:11 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:114169</guid><dc:creator>jwatte</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/114169.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=114169</wfw:commentRss><description>It sounds like you need to double-buffer at the application layer, which has nothing to do with Direct3D.&lt;br /&gt;
Your Update function will want to mutate the state of the game (a bunch of combinations of position/orientation/velocity/model/effect information in a scene graph, typically).&lt;br /&gt;
Your Render function will want to present a scene based on that same scene graph information.&lt;br /&gt;
To avoid a read/write hazard, you have to create a copy of your scene graph data, and hand off to the render thread, for each frame, while the Update function goes on mutating the scene graph in place. Alternatively, you can create two scene graphs, and copy from old to new each frame, but it boils down to the same thing.&lt;br /&gt;
&lt;br /&gt;
So, your update will look something like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;nbsp; update_loop() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!rendering_running) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; copy_data_to_renderer(game_state);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rendering_kickoff();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; update_one_physics_step();&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; render_loop() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; wait_for_kickoff();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; render_state(game_state_copy);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rendering_running = false;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; rendering_kickoff() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rendering_running = true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set_event(render_event);&lt;br /&gt;&amp;nbsp; }&lt;/pre&gt;
&lt;br /&gt;
Yes, you&amp;#39;ll have to figure out what the proper primitive is for each part of those loops (rendering_running needs to be volatile, you&amp;#39;ll need to handle termination requests, etc), but this sketch should show you how it can be made to work at the application level.&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/114159.aspx</link><pubDate>Tue, 02 Dec 2008 00:58:59 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:114159</guid><dc:creator>trogo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/114159.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=114159</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;duodevil:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Hi trogo&lt;br /&gt;
&lt;br /&gt;
I wanna implement double buffering..&lt;br /&gt;
&lt;br /&gt;
COuld u tell me hoe i can create a thread for rendering..&lt;br /&gt;
&lt;br /&gt;
thank you&lt;br /&gt;
&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
Sure.&lt;br /&gt;
&lt;br /&gt;
I have &lt;a href="http://pastebin.com/mfad584b" target="_blank"&gt;post the code&lt;/a&gt; about how the thread is created in pastebin.com. The same about how the threaded function &lt;a href="http://pastebin.com/m2d81ce27" target="_blank"&gt;here&lt;/a&gt;.</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/111210.aspx</link><pubDate>Mon, 24 Nov 2008 02:19:53 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:111210</guid><dc:creator>duodevil</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/111210.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=111210</wfw:commentRss><description>Hi trogo&lt;br /&gt;
&lt;br /&gt;
I wanna implement double buffering..&lt;br /&gt;
&lt;br /&gt;
COuld u tell me hoe i can create a thread for rendering..&lt;br /&gt;
&lt;br /&gt;
thank you&lt;br /&gt;</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/99640.aspx</link><pubDate>Thu, 23 Oct 2008 23:07:37 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:99640</guid><dc:creator>trogo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/99640.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=99640</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Brian Klamik:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;The general concept of multibuffering is to have two pieces of data and ping-pong between the two, such that Update can concurrently generate data, while Render works on the previous data.n&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;This was what I refered to. any hint about&amp;nbsp;how to achieve it?&lt;/p&gt;</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/84586.aspx</link><pubDate>Thu, 21 Aug 2008 23:40:41 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:84586</guid><dc:creator>Brian Klamik</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/84586.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=84586</wfw:commentRss><description>I&amp;#39;m unsure what your &amp;#39;typical&amp;#39; Update/Render paradigm entails, but the concept is rather simple. The Update thread usually hands off data to the Render thread. If you only have one piece of data, then&amp;nbsp;the data is usually protected with synchronization (which would only let one thread manipulate it at a time); and the Update thread would not be able to concurrently generate the data while the Render thread worked on it. The general concept of multibuffering is to have two pieces of data and ping-pong between the two, such that Update can concurrently generate data, while Render works on the previous data.&amp;nbsp;In the past, it has been&amp;nbsp;intuitive to multi-buffer D3D resources, such as textures and queries. But, recently, it has become more popular for people to attempt to multi-buffer the graphics command stream, itself.</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/83996.aspx</link><pubDate>Tue, 19 Aug 2008 16:08:02 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:83996</guid><dc:creator>trogo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/83996.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=83996</wfw:commentRss><description>Ok, thank you.
&lt;p&gt;&amp;nbsp;I am interested in enabling parallelism between some threads (the typical Update/Render paradigm). Could you tell me some advice about it?&lt;/p&gt;
&lt;p&gt;The fact is that I have researched &amp;#39;bout this, but every page I found talks about double buffer in DirectX 9. You know, the application updates one frame, while the runtime manages the front buffer, not talking about managing multiple buffers.&lt;/p&gt;</description></item><item><title>Re: Multiple buffering</title><link>http://forums.xna.com/forums/thread/83025.aspx</link><pubDate>Fri, 15 Aug 2008 05:30:50 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:83025</guid><dc:creator>Brian Klamik</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/83025.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=83025</wfw:commentRss><description>There are multiple forms of multi-buffering. The multi-buffering the swap chain does has more to do with preventing rendering to a front buffer (which is typically slow and can produce tearing). Multi-buffering&amp;nbsp;also is used to enable parallelism between multiple processing units. Traditionally, muti-buffering was used to ensure the GPU would be able to work on frame N, while the CPU worked on frame N+1. Now with multicore CPUs, the same technique is being discussed in light of enabling parallelism between CPU cores. DXGI manages the swap chain aspects, while the application must manage the parallelism aspects.</description></item><item><title>Multiple buffering</title><link>http://forums.xna.com/forums/thread/82944.aspx</link><pubDate>Thu, 14 Aug 2008 22:15:59 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:82944</guid><dc:creator>trogo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/82944.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=29&amp;PostID=82944</wfw:commentRss><description>Hello.
&lt;p&gt;My app uses a thread to render and the main thread to update. After see some Gamefest presentations, I am trying to implement multiple buffering. The fact is that when creating the swap-chain with more that 1 buffer (I assume that if introducing 1 as the BufferCount, it is the front-buffer) the performance is quite improved.&lt;/p&gt;
&lt;p&gt;So, is that the way to implement multiple-buffering, DXGI just manages it?&lt;/p&gt;</description></item></channel></rss>