Jump to content
  • Advertisement
Sign in to follow this  
orphankill

XNA Questions and the DirectX Pipeline

This topic is 3674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Some quick XNA questions: 1. Can XNA be used with C++ instead of C#? (using VS 2005) 2. Can I develop an XBox 360 game without an XBox of my own? (and still test the game on my PC and my friends XBox) 3. Can XNA be used with VS 2008? And as for DirectX: I'm trying to optimize my graphics engine by rendering things in groups. What is the best way to group things to maximize FPS, and what order should I render in? By vertex shader, zbuffer, etc. I know that's a lotta questions, but I think they're pretty simple for you guys. I only need yes/no for the first three. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
1. XNA is a managed API, so you can only use it from a managed language. You should be able to use managed C++ on the PC, but I'm not so sure on the 360.

2. No, it's not practical. Your Xbox needs to be on the same network as your development PC in order to deploy your game. Plus you're going to need to do lots of testing, debugging, and profiling which doesn't make sense if the Xbox isn't right next to you.

3. XNA GS 2.0 doesn't work with VS 2008, since it has a different plugin system. XNA GS 3.0 will work with 2008, and is currently out for Community Preview. However you can't deploy to the Xbox with the CP version.


As for your sorting...you'll probably want to sort roughly in this order:

Render target->shader->texture->vertex/index buffer

Also make sure you do whatever you can to reduce the amount of DrawPrimtive calls. Lots of those will use up your CPU time very quickly. Instancing is crucial if you're going to be rendering lots of the same objects, especially on the Xbox 360.

Share this post


Link to post
Share on other sites
Thanks for those depressing, but accurate answers.

Can someone at least point me in the direction of my last question?

Share this post


Link to post
Share on other sites
Quote:
Original post by orphankill
Thanks for those depressing, but accurate answers.

Can someone at least point me in the direction of my last question?


I added some more to my last post.

Share this post


Link to post
Share on other sites
Thanks, could you clarify if you meant:

1. Group ALL Render targets sharing:
a. shader -> Render
b. texture -> Render
c. vertex/index buffer -> Render

Or

2. Individual render target -> first render the shader -> then the texture, then the buffer. Repeat for all objects.

Share this post


Link to post
Share on other sites
he means sort by render target first...

then sub sort by shader

then sort by texture

then you can render all things who are on the same render target with the same shader and the same texture together.

but not all necessary....you will want to profile while you are doing this to make sure that your sorting actually has the performance gains you are looking for.

Share this post


Link to post
Share on other sites
Ok, I follow almost everything so far. By profile do you mean keep track of the average FPS difference between when I sort and when I don't sort, so I can see if there's actually a gain or loss in performance? And by render target do you mean each individual polygon or model? For instance, would a house and all of the objects in the house be 1 render target, or would each individual triangle strip/list/fan of each polygon be a separate render target?

Share this post


Link to post
Share on other sites
Render target is a surface onto which you draw (render) the scene. So a "back buffer" is a render target, a shadow map could be another render target, a reflection texture could be another an so on.
So a render target is something completely different than a model or a primitive (triangle). Usually you don't even touch triangles individually, cause it's horribly slow. You put them in vertex buffers + index buffers and render them all at once.

So you do it like this:

Select shadow map as a current render target.
Render a shadow map.
Select reflection texture as a current render target.
Render a reflection texture.
Select back buffer as a current render target.
Render the scene.

Rendering a scene looks like this:
First sort by shader, then texture, then vertex buffer:
With shader 1 and texture 1 draw vertex buffer 1 (a house)
With shader 1 and texture 1 draw vertex buffer 2 (a second house)
With shader 1 and texture 2 draw vertex buffer 3 (car)
With shader 2 and texture 3 draw vertex buffer 4 (a guy)
With shader 2 and texture 4 draw vertex buffer 5 (another guy)
With shader 2 and texture 4 draw vertex buffer 5 (similar guy)
etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by orphankill
Ok, I follow almost everything so far. By profile do you mean keep track of the average FPS difference between when I sort and when I don't sort, so I can see if there's actually a gain or loss in performance? And by render target do you mean each individual polygon or model? For instance, would a house and all of the objects in the house be 1 render target, or would each individual triangle strip/list/fan of each polygon be a separate render target?


Yes, that's what he means by profiling. When you're talking about optimization, it's also important that you get hard data regarding the effects an optimization has on the running code. This is especially true when you're talking real-time 3D graphics, where you have two processors working in tandem and many areas whre bottlenecks can occur. So when you do eventually get into sorting your renderables, you'll want to something like "Okay, I want to sort by texture. Let me time a test scene without sorting, then time a test with the sorting. I'll also time how long it takes to do the sort to make sure I'm not wasting my time with it".

For render targets, I'm talking about the surface you're rendering to. In other words, where you're writing all the pixels to. It's possible to have games where you only render to the back-buffer and therefore you only have a single render-target, but modern games tend to render all kinds of stuff to render-targets.

As an example, take something like shadow mapping. With shadow maps, you create a render-target texture that's used to to store the depth of objects in the scene with regard to the light source. This means that for every frame the objects need to be rendered to the shadow-map as well as the back-buffer. Let's pretend you have 3 objects in then scene: what you would do is you would render all 3 objects to the shadow map render-target first, then render all 3 to the back-buffer. This is quicker than rendering an object to the shadow map, then to the back buffer, then another object to the shadow map, and so on.


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!