Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a huge model I want to draw in my XNA application; due to its size I am experiencing a tremendous loss of performance.

The model has about 50,000,000 edges and has a size on disk of 205 MB in the .x format. Yes, the model has to be this big.

Is there a way to transfer the model directly to my GPU in order to let the GPU do the drawing like when transferring a VertexBuffer? When I try to fill a vertex buffer with the object I am getting an OutOfMemoryException.

share|improve this question
1  
Probably not possible without chunking the model and loading and unloading the chunks dynamically. –  API-Beast Nov 19 '12 at 14:32
    
@Mr.Beast these are really bad news ... –  marc wellman Nov 19 '12 at 14:35
    
Could you give some more detail about your situation? At a certain point you aren't going to be able to see the details on the screen if the whole thing is there, and if you're only ever looking at a subsection, there might be some ways to only send the necessary pieces to the GPU (yet have the whole model loaded in non GPU memory if you need it there) –  Lunin Nov 20 '12 at 19:33

1 Answer 1

The out-of-memory exception likely occurs because the vertex buffer must be backed by system memory in order to handle device loss in the underlying D3D9 implementation of XNA (it's probably in the D3DPOOL_MANAGED pool).

Transferring the data to the GPU and filling a vertex buffer with the data are the same thing (a vertex buffer is the only place in XNA's API you can store this data).

You're going to have to chunk the model file up into multiple vertex buffers when you load the data off the disk. The best way to do this is probably not to the naive thing and chunk it up sequentially, but rather to partition the model using some kind of spatial partitioning scheme (octree, bsp, what have you) so that you can completely avoid issuing draw calls for chunks of the model that are outside the view frustum.

This approach will:

  • Alleviate (but not solve) your system memory issues by requiring smaller allocations to hold the system-backed resources (even though the total memory usage will be the same or larger).

  • Improve your rendering performance by allowing you to make only the needed draw calls for only the needed parts of the model, based on frustum culling techniques. If you aren't clear on what frustum culling is, that might be a good topic to research or ask a new question about.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.