amerkoleci / Vortice.Windows

.NET bindings for Direct3D12, Direct3D11, WIC, Direct2D1, XInput, XAudio, X3DAudio, DXC, Direct3D9 and DirectInput.
MIT License
999 stars 73 forks source link

Vortice.Direct3D12.CPUDescriptorHandle.Offset(int, int) not giving correct address. #436

Closed MarcioAB closed 3 months ago

MarcioAB commented 3 months ago

It seems Vortice.Direct3D12.CPUDescriptorHandle.Offset(int, int) is not giving correct address.

Check using 3 different ways to get this address:

var handle = rtvDescriptorHeap.GetCPUDescriptorHandleForHeapStart();

for (int i = 0; i < 10; i++) {
    handles1[i] = handle + i * rtvDescriptorSize; // OK
    handles2[i] = new CpuDescriptorHandle(handle, i, rtvDescriptorSize); // OK
    handles3[i] = handle.Offset(i, rtvDescriptorSize); // Not OK
}

handles1 and handles2 have correct address but not handles3.

amerkoleci commented 3 months ago

Found the issue, will push fix tomorrow.

Thanks!

amerkoleci commented 3 months ago

Can you try with https://github.com/amerkoleci/Vortice.Windows/commit/f49856e33e83d2a9470d38c674a4fa0293a70100 and tell me if it works?

MarcioAB commented 3 months ago

Sorry, I misunderstood the Offset function. I did not realize that it does not create a new handle but merely offsets the pointer of the current handle. I now realize the static CpuDescriptorHandle.InitOffsetted is the one to do that, besides the others I used to check. They are all working fine for me.