microsoft / D3D12TranslationLayer

A library containing utilities for mapping higher-level graphics work to D3D12
MIT License
327 stars 47 forks source link

Accessing command list on D3D9On12 #77

Open ManjitBeeSys opened 1 year ago

ManjitBeeSys commented 1 year ago

Hello

We have our engine on Directx9 and we want to migrate to Directx12. We want migration step wise so using D3D9On12 where we have access to Directx12 device, command queue but no access to Command List.

Is there any way of getting acccess of command list to recored my command.

jenatali commented 1 year ago

Not currently, no, it will need to be recorded into a separate command list.

ManjitBeeSys commented 1 year ago

Not currently, no, it will need to be recorded into a separate command list.

Thanks for your reply.

Can we have control over execution of command list created by D3D9On12. i.e. which function governs it ? We want our engine's directx12 component's command list to be executed along wtih default command list created by D3D9On12 layer. How could we achive this ?

jenatali commented 1 year ago

Can we have control over execution of command list created by D3D9On12. i.e. which function governs it ?

Command lists can be flushed at any point. They are done so when necessary, e.g. by Present, or when the CPU needs to wait for the GPU in Lock/LockRect, but can also be flushed opportunistically if the GPU is otherwise idle.

We want our engine's directx12 component's command list to be executed along wtih default command list created by D3D9On12 layer. How could we achive this ?

What do you mean by "along with"?

ManjitBeeSys commented 1 year ago

Can we have control over execution of command list created by D3D9On12. i.e. which function governs it ?

Command lists can be flushed at any point. They are done so when necessary, e.g. by Present, or when the CPU needs to wait for the GPU in Lock/LockRect, but can also be flushed opportunistically if the GPU is otherwise idle.

We want our engine's directx12 component's command list to be executed along wtih default command list created by D3D9On12 layer. How could we achive this ?

What do you mean by "along with"?

@jenatali thanks for reply.

along with means, executing Dx12 command list at the same time when D3D9On12 command list is executing.

jenatali commented 1 year ago

If you want your DX12 work to execute in sequence with DX9 work, you can use the interior APIs described here. If you want your work to execute in parallel, you can just submit it to a different queue. I'm still not entirely sure what you're trying to accomplish.

ManjitBeeSys commented 1 year ago

If you want your DX12 work to execute in sequence with DX9 work, you can use the interior APIs described here. If you want your work to execute in parallel, you can just submit it to a different queue. I'm still not entirely sure what you're trying to accomplish.

@jenatali thaks for reply.

Here we want our work to execute in parllel, but want some notification like GPU signal from D3D9On12 API to our new Directx12 created Queue.

We have following scenario. Let say we have 10 diffrent kinds of objects in a Scene, eache object's rendering written in Directx9. Our Engine renders each object in a ceratian FPS let say 25fps. Here, we have to convert our all 10 objects into Directx12, one by one. Say our 9 Objects are rendering in D3D9On12 default Queue and i have converted my 10th object's rendering complete in Directx12. Now all these 10 objects will be renderd by our Rendering Engine on 40 milliseconds. We need any mechanisim to render both D3D9On12 object and Directx12 object in a Synchronization.

Converting complete objects in Directx12 will take time so we want to go one by one.

jenatali commented 1 year ago

Right, the interop APIs I linked earlier are what you want. When you want to transition from D3D9 rendering to 12, you'd unwrap your render targets and depth buffer, which would insert a wait on your command queue for the D3D9 rendering to finish. When you finish and want to go back to D3D9 rendering, you'd insert a signal on your queue, and return the resources, passing the fence that you signaled which 9on12 will then wait on.

Until you're done, you'll probably want to keep your swapchain in D3D9 so that Present flushes all the work.

And just to be clear, this isn't truly parallel work, it'll end up sequenced/serialized on the GPU, but it sounds like that's what you want.

ManjitBeeSys commented 1 year ago

Right, the interop APIs I linked earlier are what you want. When you want to transition from D3D9 rendering to 12, you'd unwrap your render targets and depth buffer, which would insert a wait on your command queue for the D3D9 rendering to finish. When you finish and want to go back to D3D9 rendering, you'd insert a signal on your queue, and return the resources, passing the fence that you signaled which 9on12 will then wait on.

Until you're done, you'll probably want to keep your swapchain in D3D9 so that Present flushes all the work.

And just to be clear, this isn't truly parallel work, it'll end up sequenced/serialized on the GPU, but it sounds like that's what you want.

Thanks for your valuable reply.