0
\$\begingroup\$

I would like to create cloth simulation. Which type of buffer should i use for vertices. I will need to update them on every frame. And how updates need to be done. I'm new to graphics programming, but still i'm mostly interesting in high level overview. If there is open-source project implementing it, reference to it would be of help.

For now i have only rigid body geometries. For this i create a resource with

    THROW_IF_FAILED(g_device->CreateCommittedResource(
        &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
        D3D12_HEAP_FLAG_NONE,
        &CD3DX12_RESOURCE_DESC::Buffer(byteSize),
        D3D12_RESOURCE_STATE_COPY_DEST,
        nullptr,
        IID_PPV_ARGS(buffer_.GetAddressOf())));

Then i update it with initial data using another upload buffer to initialize first buffer. Lastly i transition first buffer into D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER state.


Well, i got some comments directing me toward DirectX11, but for my purposes i will better use DirectX12, and again, i'm pretty matured programmer and just need a highlevel overview of what need to be done.

For example,

create default buffer with geometry, then create upload heap, and when needed create placed resource buffer to upload data into your default buffer.

But here a lot of questions arise. For now i use frame resources e.g. for transforms to update them on each frame and do not stall CPU. But if i will copy once a frame to the same default buffer will my it cause stalling? And should i use different queue for copying, and how then do resource state transitioning?

From what i understood for now, i need to implement this, but how to implement CopyResource functionality?

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Slightly off-topic: If you are new to graphics development you should most likely prefer using DX11. DX12 is intended for performance intensive applications (e.g.: games) and requires a lot of manual management from the programmer (while in older API versions those are handled by the OS and drivers). \$\endgroup\$ – UnholySheep Mar 28 '17 at 7:04
  • 1
    \$\begingroup\$ @UnholySheep i spent a lot of time to start with DirectX12, and now i have simple rendering system using it, and i would like to continue this way:) \$\endgroup\$ – Yola Mar 28 '17 at 7:07
  • \$\begingroup\$ In that case it's somewhat unclear what you want to do differently for your cloth simulation rendering (e.g.: what should be different from the way you render other objects, what have you tried doing and where are the problems). \$\endgroup\$ – UnholySheep Mar 28 '17 at 7:33
  • 1
    \$\begingroup\$ "I pushed a boulder halfway up a mountain instead of a small rock, but since I'm already halfway, I might as well just continue" tis is basically you, but instead of being halfway up, you're only 5% up the mountain. \$\endgroup\$ – Bálint Mar 28 '17 at 8:21
  • \$\begingroup\$ I agree with Sheep and Balint, DX 12 is only needed if you have cpu overhead issues, sure some of the advanced things like async compute and bindles resources can help but. In fact if you use it wrong then your perf will be lower than using DX11. If you are stuck here I would really go have a look at DX11. Why did you pick DX12? \$\endgroup\$ – Justin William Stanley Bryant Mar 28 '17 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.