I'm a little confused on buffers.. IM Ok with the back buffer(s) created in the swap chain..But Im not sure about the buffers created with ID3D10Buffer using the CreateBuffer function.. Im learning using a few books I have found.. Some say I can only have 1 or a few of these buffers to store vertices in. I have read in forums that people have created hundreds of these buffers.. for their programs.. but have complained of performance issues when a lot are used..
My question is is this buffer type stored in video memory or computer RAM ?
How many can I have ? is there a set number ?
I am a beginner learning this but it seems to me If I had a program with Terrain ,, Objects on the terrain.. and models moving about and the models were different types I would have to have a separate buffer for the terrain, separate ones for the models etc. Or do I really have to cram all this in one buffer and try to keep track of what is what and where in the buffer ? (I think I said that right )
I started out with directX9 using fixed pipeline..and figured I should not waste time on that and learn DX 10.. Im still trying to wrap my head around the HLSL that I have to learn for DX 10.. Anyway in DX 9 I had made a class which was comprised of a transformed quad that I could map different parts of a texture on it at any time , change the size and position and transpose font on it at will.. I then made other classes that were derived from the quad class... ( I was building a GUI system for dx9 ) anyway each quad class had its own vertex buffer and it all seemed to work fine..but I was not sure if this was really the right thing to do.. So I really need to get this clear on what is right or wrong as far as buffers go before I build anything more in DX10
Let's start with some terminology, assuming a DX10/DX11 point of view:
Resource: a block of memory allocated for use with the device ----Buffer: a resource containing a contiguous array of elements --------Vertex Buffer: a buffer containing vertex data to be used by the input assembler for rendering primitives --------Index Buffer: a buffer containing index data to be used by the input assembler for rendering primitives --------Constant Buffer: a buffer containing variables that can be set by the CPU directly accessed by shader programs on the GPU ----Texture: a multi-dimension resource containing texels, and that can have --------Texture1D: a 1D texture --------Texture2D: a 2D texture --------Texture3D: a 3D texture --------TextureCube: an array of 6 2D textures that act like faces of a cube
A back buffer used with a swap chain is actually a Texture2D resource, not a buffer resource. Typically a Texture2D is what you'll use as a render target, or as a shader resource that can be sampled by a shader. A vertex buffer is an actual Buffer resource that you create with CreateBuffer. You can certainly have many of them that you switch between during a frame...switching used to be a performance issue a long time ago but that is no longer the case on modern hardware. Where they are stored depends on how you create them...if it's an IMMUTABLE or DEFAULT buffer then it will likely be in GPU memory, however if you make a DYNAMIC buffer then it may be stored off the GPU in location that is accessible by the both the GPU and the CPU.