How to Pass Struct by Value?
Michael Ennen
mike.ennen at gmail.com
Wed Sep 30 06:36:31 UTC 2020
I am messing around with DirectX 12 more and I am getting stuck on how to
call the "GetCPUDescriptorHandleForHeapStart " method. It must take a
struct by-value and not as a pointer reference.
https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12descriptorheap-getcpudescriptorhandleforheapstart
There seems to be a bit of an issue with that method as I see some Github
issues talking about it's weird ABI, but I don't think I am hitting that
issue (see https://github.com/halide/Halide/issues/5156 for example).
I have the following:
MemorySegment heapDescriptorVtbl =
asSegment(ID3D12DescriptorHeap.lpVtbl$get(pHeapDescriptor),
ID3D12DescriptorHeapVtbl.$LAYOUT());
MemoryAddress getCPUDescriptorHandleForHeapStartAddr =
ID3D12DescriptorHeapVtbl.GetCPUDescriptorHandleForHeapStart$get(heapDescriptorVtbl);
var pRtvHandle = D3D12_CPU_DESCRIPTOR_HANDLE.allocate(scope);
MethodHandle ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart =
getInstance().downcallHandle(getCPUDescriptorHandleForHeapStartAddr,
MethodType.methodType(void.class, MemoryAddress.class, MemoryAddress.class),
FunctionDescriptor.ofVoid(C_POINTER, C_POINTER));
ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart.invokeExact(
pHeapDescriptor.address(), pRtvHandle.address());
But it is not right as I am passing in D3D12_CPU_DESCRIPTOR_HANDLE as a
pointer.
I tried exploring the Panama API and looking at tests but just didn't find
what I was looking for (how to pass a struct by value, if that's possible
with the ABI semantics).
My current work is here:
https://github.com/brcolow/java-dx12/
Thanks very much.
More information about the panama-dev
mailing list