I have a large scene in a B3D model, which includes about 120 meshes as in the following pictures:
large B3D scene http://s22.postimg.org/d1h75hr0v/Untitled.png
Each mesh contain a vertex buffer and material information such as diffuse, specular, ambient...
I'm using Directx 11 for rendering, and it takes me about 120 IndexedDraw calls per frame, and the frame rate is down to 30f/s. This speed is so slow and I can't apply physics to the application.
Now I want to group these IndexedDraw call into only one DrawCall per frame. To do this, I'm thinking about creating multiple vertex buffers in Directx, and each of these will own its own material information. For each draw call, DirectX will loop over such vertex buffers and pass the corresponding material information.
I want to ask you there's any way to do this in DirectX11, and if not, could you please suggest me some way to optimize my application.
Detail information of IndexedDraw calls.
19 ID3D11DeviceContext::DrawIndexed(5898,0,0)
25 ID3D11DeviceContext::DrawIndexed(20664,0,0)
31 ID3D11DeviceContext::DrawIndexed(3000,0,0)
37 ID3D11DeviceContext::DrawIndexed(5340,0,0)
43 ID3D11DeviceContext::DrawIndexed(3540,0,0)
51 ID3D11DeviceContext::DrawIndexed(2760,0,0)
59 ID3D11DeviceContext::DrawIndexed(3444,0,0)
65 ID3D11DeviceContext::DrawIndexed(1680,0,0)
71 ID3D11DeviceContext::DrawIndexed(1680,0,0)
79 ID3D11DeviceContext::DrawIndexed(72,0,0)
85 ID3D11DeviceContext::DrawIndexed(1920,0,0)
91 ID3D11DeviceContext::DrawIndexed(1332,0,0)
97 ID3D11DeviceContext::DrawIndexed(618,0,0)
105 ID3D11DeviceContext::DrawIndexed(720,0,0)
111 ID3D11DeviceContext::DrawIndexed(6,0,0)
117 ID3D11DeviceContext::DrawIndexed(174,0,0)
123 ID3D11DeviceContext::DrawIndexed(360,0,0)
129 ID3D11DeviceContext::DrawIndexed(78,0,0)
137 ID3D11DeviceContext::DrawIndexed(1368,0,0)
143 ID3D11DeviceContext::DrawIndexed(324,0,0)
151 ID3D11DeviceContext::DrawIndexed(900,0,0)
157 ID3D11DeviceContext::DrawIndexed(216,0,0)
165 ID3D11DeviceContext::DrawIndexed(900,0,0)
171 ID3D11DeviceContext::DrawIndexed(216,0,0)
179 ID3D11DeviceContext::DrawIndexed(900,0,0)
185 ID3D11DeviceContext::DrawIndexed(216,0,0)
193 ID3D11DeviceContext::DrawIndexed(504,0,0)
199 ID3D11DeviceContext::DrawIndexed(6,0,0)
205 ID3D11DeviceContext::DrawIndexed(174,0,0)
211 ID3D11DeviceContext::DrawIndexed(360,0,0)
217 ID3D11DeviceContext::DrawIndexed(78,0,0)
225 ID3D11DeviceContext::DrawIndexed(108,0,0)
231 ID3D11DeviceContext::DrawIndexed(24,0,0)
239 ID3D11DeviceContext::DrawIndexed(900,0,0)
245 ID3D11DeviceContext::DrawIndexed(216,0,0)
253 ID3D11DeviceContext::DrawIndexed(108,0,0)
259 ID3D11DeviceContext::DrawIndexed(24,0,0)
267 ID3D11DeviceContext::DrawIndexed(144,0,0)
273 ID3D11DeviceContext::DrawIndexed(504,0,0)
279 ID3D11DeviceContext::DrawIndexed(6,0,0)
285 ID3D11DeviceContext::DrawIndexed(174,0,0)
291 ID3D11DeviceContext::DrawIndexed(360,0,0)
296 ID3D11DeviceContext::DrawIndexed(78,0,0)
304 ID3D11DeviceContext::DrawIndexed(372,0,0)
310 ID3D11DeviceContext::DrawIndexed(30,0,0)
316 ID3D11DeviceContext::DrawIndexed(360,0,0)
321 ID3D11DeviceContext::DrawIndexed(78,0,0)
327 ID3D11DeviceContext::DrawIndexed(144,0,0)
335 ID3D11DeviceContext::DrawIndexed(108,0,0)
341 ID3D11DeviceContext::DrawIndexed(24,0,0)
349 ID3D11DeviceContext::DrawIndexed(540,0,0)
355 ID3D11DeviceContext::DrawIndexed(540,0,0)
363 ID3D11DeviceContext::DrawIndexed(5322,0,0)
369 ID3D11DeviceContext::DrawIndexed(540,0,0)
377 ID3D11DeviceContext::DrawIndexed(792,0,0)
385 ID3D11DeviceContext::DrawIndexed(1800,0,0)
393 ID3D11DeviceContext::DrawIndexed(540,0,0)
399 ID3D11DeviceContext::DrawIndexed(540,0,0)
407 ID3D11DeviceContext::DrawIndexed(36,0,0)
413 ID3D11DeviceContext::DrawIndexed(36,0,0)
420 ID3D11DeviceContext::DrawIndexed(36,0,0)
428 ID3D11DeviceContext::DrawIndexed(450,0,0)
436 ID3D11DeviceContext::DrawIndexed(36,0,0)
442 ID3D11DeviceContext::DrawIndexed(36,0,0)
449 ID3D11DeviceContext::DrawIndexed(36,0,0)
456 ID3D11DeviceContext::DrawIndexed(36,0,0)
464 ID3D11DeviceContext::DrawIndexed(396,0,0)
470 ID3D11DeviceContext::DrawIndexed(396,0,0)
476 ID3D11DeviceContext::DrawIndexed(396,0,0)
482 ID3D11DeviceContext::DrawIndexed(396,0,0)
488 ID3D11DeviceContext::DrawIndexed(396,0,0)
494 ID3D11DeviceContext::DrawIndexed(396,0,0)
500 ID3D11DeviceContext::DrawIndexed(396,0,0)
506 ID3D11DeviceContext::DrawIndexed(396,0,0)
512 ID3D11DeviceContext::DrawIndexed(396,0,0)
518 ID3D11DeviceContext::DrawIndexed(396,0,0)
524 ID3D11DeviceContext::DrawIndexed(396,0,0)
530 ID3D11DeviceContext::DrawIndexed(396,0,0)
536 ID3D11DeviceContext::DrawIndexed(396,0,0)
544 ID3D11DeviceContext::DrawIndexed(1512,0,0)
548 ID3D11DeviceContext::DrawIndexed(1512,0,0)
556 ID3D11DeviceContext::DrawIndexed(78,0,0)
562 ID3D11DeviceContext::DrawIndexed(540,0,0)
568 ID3D11DeviceContext::DrawIndexed(36,0,0)
576 ID3D11DeviceContext::DrawIndexed(78,0,0)
582 ID3D11DeviceContext::DrawIndexed(360,0,0)
588 ID3D11DeviceContext::DrawIndexed(24,0,0)
596 ID3D11DeviceContext::DrawIndexed(180,0,0)
602 ID3D11DeviceContext::DrawIndexed(12,0,0)
608 ID3D11DeviceContext::DrawIndexed(624,0,0)
616 ID3D11DeviceContext::DrawIndexed(180,0,0)
622 ID3D11DeviceContext::DrawIndexed(12,0,0)
628 ID3D11DeviceContext::DrawIndexed(624,0,0)
636 ID3D11DeviceContext::DrawIndexed(180,0,0)
642 ID3D11DeviceContext::DrawIndexed(12,0,0)
648 ID3D11DeviceContext::DrawIndexed(624,0,0)
656 ID3D11DeviceContext::DrawIndexed(180,0,0)
662 ID3D11DeviceContext::DrawIndexed(12,0,0)
668 ID3D11DeviceContext::DrawIndexed(624,0,0)
676 ID3D11DeviceContext::DrawIndexed(180,0,0)
682 ID3D11DeviceContext::DrawIndexed(12,0,0)
690 ID3D11DeviceContext::DrawIndexed(864,0,0)
698 ID3D11DeviceContext::DrawIndexed(648,0,0)
704 ID3D11DeviceContext::DrawIndexed(648,0,0)
710 ID3D11DeviceContext::DrawIndexed(648,0,0)
718 ID3D11DeviceContext::DrawIndexed(216,0,0)
726 ID3D11DeviceContext::DrawIndexed(180,0,0)
732 ID3D11DeviceContext::DrawIndexed(12,0,0)
740 ID3D11DeviceContext::DrawIndexed(180,0,0)
746 ID3D11DeviceContext::DrawIndexed(12,0,0)
754 ID3D11DeviceContext::DrawIndexed(180,0,0)
760 ID3D11DeviceContext::DrawIndexed(12,0,0)
766 ID3D11DeviceContext::DrawIndexed(624,0,0)
774 ID3D11DeviceContext::DrawIndexed(180,0,0)
780 ID3D11DeviceContext::DrawIndexed(12,0,0)
786 ID3D11DeviceContext::DrawIndexed(624,0,0)
Thanks in advance.
DrawIndexedInstanced
not using a additional Instance vertex buffer, but storing the matrices/material in aStructuredBuffer<T>
. And defining aunsigned int InstanceId : SV_InstanceID;
in theVertexIn
struct of the HLSL. With these reference words, you're able to find some examples. \$\endgroup\$