microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.89k stars 2k forks source link

FrameResource #826

Closed KaMiletic closed 1 year ago

KaMiletic commented 1 year ago

Hello

I am learning direct3d 12 and I have seen both here and Frank Luna book use frame resources to keep CPU and GPU busy while building and submiting commands to the GPU for execution. Is this approach good enough for production quality applications or another approach would be better ? In MiniEngine what class is responsible for rendering 3d models , and where would be a good to place to insert brake point to see rendering calls. Thank you!

walbourn commented 1 year ago

Frank Luna's FrameResource is his equivalent of DeviceResources which is used in many Microsoft samples. You can find DirectX 12 versions of it for Win32, UWP, and even Xbox. This is not necessarily a design intended for full engines, but a learning tool abstraction. You could certainly use it as the basis of creating a game engine singleton, but most cross-platform engines already have established abstractions.

MiniEngine is intended as a' full engine' demonstration. If you are just looking for some examples of rendering 3D models with DirectX 12, take a look at DirectX Tool Kit for DX12 and the Model class.

KaMiletic commented 1 year ago

@walbourn thank you for your answer. In win32 samples, multithreading there is FrameResource.h and FrameResource.cpp. In Frank Luna book they explain it as a circular buffer holding rendering constant buffer per frame and model object and command allocator. If i would write render engine could I use same pattern or is it inefficient? In MiniEngine I have seen an issue here where to put brake point for init of engine, but could I put brake point somewhere where I could see rendering calls. Thank you

walbourn commented 1 year ago

In DirectX 12, the application is responsible for ensuring all resources like constant buffers are kept 'alive' until the GPU is done rendering them, which can take up to 3 frames. The samples all tend to use a fairly simplistic model for this. For a "generalized' solution, see LinearAllocator in the DirectX Tool Kit for DX12.

MiniEngine uses a similar approach LinearAllocator.cpp / .h.