Error Running jextract on d3d12.h
Michael Ennen
mike.ennen at gmail.com
Fri Sep 11 21:28:19 UTC 2020
I have a question. Sorry for using Java based terminology:
Say I have obtained an object which is a MemorySegment, in this case
DXGIFactory1:
try (var scope = NativeScope.unboundedScope()) {
var dxgiFactory = scope.allocate(C_POINTER);
int hresult = dxgi_h.CreateDXGIFactory1(GUID(IID.IID_IDXGIFactory1),
dxgiFactory);
// Now I want to call equivalent of
dxgiFactory->EnumAdapters1(adapterIndex, &dxgiAdapter)
}
How does one call the EnumAdapters1 method on the dxgiFactory
MemorySegment? I searched through the generated Java source files
from running jextract on dxgi.h and the only MethodHandles I see are to the
"global methods" CreateDXGIFactory and CreateDXGIFactory1.
Basically my question is how does one call a member's method (non-global
method)?
Thanks very much.
On Fri, Sep 11, 2020 at 4:27 AM Jorn Vernee <jorn.vernee at oracle.com> wrote:
> Nice!
>
> Jorn
> On 11/09/2020 07:08, Michael Ennen wrote:
>
> It worked!
>
> https://github.com/brcolow/java-dx12
> <https://urldefense.com/v3/__https://github.com/brcolow/java-dx12__;!!GqivPVa7Brio!MxEvxXjOEK6JnUNO__rKTvjNPfYqHSKDwWdQ0BTjtwXS2QaQwU4ATOo_0I7zghUb$>
>
> Now I am going to mess with it!
>
> On Thu, Sep 10, 2020 at 9:11 PM Michael Ennen <mike.ennen at gmail.com>
> wrote:
>
>> Just wanted to say that I tried building again and this time it was
>> successful. Maybe it was a spurious error.
>>
>> Anyways I will try running jextract now :).
>>
>> Thanks for all the assistance and great work.
>>
>> On Wed, Sep 9, 2020 at 12:07 PM Michael Ennen <mike.ennen at gmail.com>
>> wrote:
>>
>>> I hate the fact that Cygwin seems to be difficult to uninstall (as it
>>> creates a Windows user as well as new drives), it just seems heavy on the
>>> system. I prefer WSL.
>>>
>>> I could try and install Cygwin on some sort of virtual container perhaps.
>>>
>>> I am also trying to convince AdoptOpenJDK to add a Panama build :).
>>>
>>> On Wed, Sep 9, 2020 at 2:16 AM Jorn Vernee <jorn.vernee at oracle.com>
>>> wrote:
>>>
>>>> Hi Michael,
>>>>
>>>> Too bad that you couldn't get it working. FWIW, the WSL support is
>>>> still a bit of a work in progress, and the Cygwin support has been tested a
>>>> lot more. I'm using Cygwin to build the JDK as well, and though I have been
>>>> able to build with WSL in the past, it doesn't seem to work out-of-the-box
>>>> for compiling a Windows JDK currently (though I have successfully used it
>>>> for Linux JDKs). I get a different error as well.
>>>>
>>>> Will see if I can get it working again (on my machine at least).
>>>>
>>>> Jorn
>>>> On 09/09/2020 03:41, Michael Ennen wrote:
>>>>
>>>> Unfortunately I ran into an error trying to build the JDK on my local
>>>> Windows machine:
>>>>
>>>> /bin/bash: fork: Invalid argument
>>>> lib/CoreLibraries.gmk:42: recipe for target
>>>> '/mnt/c/Users/mikee/dev/panama-foreign/build/windows-x86_64-server-release/support/native/java.base/libfdlibm/s_ilogb.obj'
>>>> failed
>>>> make[3]: ***
>>>> [/mnt/c/Users/mikee/dev/panama-foreign/build/windows-x86_64-server-release/support/native/java.base/libfdlibm/s_ilogb.obj]
>>>> Error 254
>>>> make[3]: *** Deleting file
>>>> '/mnt/c/Users/mikee/dev/panama-foreign/build/windows-x86_64-server-release/support/native/java.base/libfdlibm/s_ilogb.obj'
>>>> make[3]: *** Waiting for unfinished jobs....
>>>> make/Main.gmk:203: recipe for target 'java.base-libs' failed
>>>> make[2]: *** [java.base-libs] Error 2
>>>>
>>>> I will have to try and get AdoptOpenJDK to add nightly builds for
>>>> foreign-jextract branch.
>>>>
>>>> On Tue, Sep 8, 2020 at 1:12 PM Michael Ennen <mike.ennen at gmail.com>
>>>> wrote:
>>>>
>>>>> Fantastic. I will give building it a try and see what happens. Thanks
>>>>> for fixing the issue already!
>>>>>
>>>>> On Tue, Sep 8, 2020 at 3:41 AM Jorn Vernee <jorn.vernee at oracle.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Michael,
>>>>>>
>>>>>> Thanks for trying out jextract!
>>>>>>
>>>>>> > Sorry if it is too early to post feedback like this.
>>>>>>
>>>>>> Not at all :)
>>>>>>
>>>>>> It looks like you are using the pre-built binary from jdk.java.net
>>>>>> <https://urldefense.com/v3/__http://jdk.java.net__;!!GqivPVa7Brio!JqlklYM5FZERg9DSRRy9c_gEWiojjqKemNRfUt4BBC-cb3SZUyCKxW7XRpZp9rPK$>?
>>>>>> Note
>>>>>> that that one is pretty old. We are planning to update it in the near
>>>>>> future, but if you don't want to wait, you can also try building the
>>>>>> panama JDK yourself. The repo is found at:
>>>>>> https://github.com/openjdk/panama-foreign
>>>>>> <https://urldefense.com/v3/__https://github.com/openjdk/panama-foreign__;!!GqivPVa7Brio!JqlklYM5FZERg9DSRRy9c_gEWiojjqKemNRfUt4BBC-cb3SZUyCKxW7XRgdSwLuQ$>
>>>>>> See doc/building.md [1] for
>>>>>> instructions (though you'll have to substitute mercurial for git, as
>>>>>> the
>>>>>> doc has not yet been updated after the recent mainline transition [2])
>>>>>>
>>>>>> In the time between that binary coming out and now, there has been a
>>>>>> complete re-write of jextract. With the current version I gave
>>>>>> extracting d3d12.h a try, using the following commands (powershell):
>>>>>>
>>>>>> $jdk = <path to built jdk>
>>>>>> nal -Name jextract -Value "$jdk\bin\jextract.exe"
>>>>>> $I = "C:\Program Files (x86)\Windows
>>>>>> Kits\10\Include\10.0.18362.0"
>>>>>> jextract -d out -t org.jextract -I "$I\um" --filter "d3d12.h" --
>>>>>> "$I\um\d3d12.h"
>>>>>>
>>>>>> But I ran into a problem for which I've filed:
>>>>>> https://bugs.openjdk.java.net/browse/JDK-8252899
>>>>>>
>>>>>> I'll try and see if I can get the extraction of d3d12.h working.
>>>>>>
>>>>>> Thanks,
>>>>>> Jorn
>>>>>>
>>>>>> [1] :
>>>>>>
>>>>>> https://github.com/openjdk/panama-foreign/blob/foreign-jextract/doc/building.md
>>>>>> <https://urldefense.com/v3/__https://github.com/openjdk/panama-foreign/blob/foreign-jextract/doc/building.md__;!!GqivPVa7Brio!JqlklYM5FZERg9DSRRy9c_gEWiojjqKemNRfUt4BBC-cb3SZUyCKxW7XRiq855ms$>
>>>>>> [2] : https://github.com/openjdk/jdk/pull/21
>>>>>> <https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/21__;!!GqivPVa7Brio!JqlklYM5FZERg9DSRRy9c_gEWiojjqKemNRfUt4BBC-cb3SZUyCKxW7XRob2igXb$>
>>>>>>
>>>>>> On 08/09/2020 08:27, Michael Ennen wrote:
>>>>>> > Sorry for the consecutive replies to my own message. I read some
>>>>>> more docs
>>>>>> > and believe the following should work in theory:
>>>>>> >
>>>>>> > $inc ="C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0"
>>>>>> > $lib = "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0"
>>>>>> > $panamaHome = "C:\Program Files\Java\jdk-14-panama"
>>>>>> > & $panamaHome\bin\jextract -J-Xmx8G --log FINEST -L
>>>>>> "C:\Windows\System32"
>>>>>> > -L "$lib\um\x64" -I "$inc\um" -l d3d12 -o d3d12.jar
>>>>>> --record-library-path
>>>>>> > $inc\um\d3d12.h
>>>>>> >
>>>>>> > The same error occurs.
>>>>>> >
>>>>>> > Log:
>>>>>> >
>>>>>> > Package clang_support is selected for C:\Program
>>>>>> > Files\Java\jdk-14-panama\conf\jextract
>>>>>> >
>>>>>> > Package is selected for C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um
>>>>>> >
>>>>>> > Parsing header file C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um\d3d12.h with following args:
>>>>>> >
>>>>>> > arg[0] = -IC:\Program Files (x86)\Windows
>>>>>> Kits\10\Include\10.0.17763.0\um
>>>>>> >
>>>>>> >
>>>>>> > arg[1] = -IC:\Program Files\Java\jdk-14-panama\conf\jextract
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12.h:33:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"Windows.h"'; specified path differs in case from f
>>>>>> > ile name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12.h:34:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"Ole2.h"'; specified path differs in case from file
>>>>>> > name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12.h:334:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"OAIdl.h"'; specified path differs in case from fi
>>>>>> > le name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12.h:335:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"OCIdl.h"'; specified path differs in case from fi
>>>>>> > le name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/ocidl.h:29:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"Windows.h"'; specified path differs in case from f
>>>>>> > ile name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/ocidl.h:30:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"Ole2.h"'; specified path differs in case from file
>>>>>> > name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/ocidl.h:324:10: warning:
>>>>>> non-portable path
>>>>>> > to file '"OAIdl.h"'; specified path differs in case from fi
>>>>>> > le name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3dcommon.h:29:10: warning:
>>>>>> non-portable
>>>>>> > path to file '"Windows.h"'; specified path differs in case fr
>>>>>> > om file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3dcommon.h:30:10: warning:
>>>>>> non-portable
>>>>>> > path to file '"Ole2.h"'; specified path differs in case from
>>>>>> > file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3dcommon.h:57:10: warning:
>>>>>> non-portable
>>>>>> > path to file '"OAIdl.h"'; specified path differs in case from
>>>>>> > file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3dcommon.h:58:10: warning:
>>>>>> non-portable
>>>>>> > path to file '"OCIdl.h"'; specified path differs in case from
>>>>>> > file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:33:10: warning:
>>>>>> > non-portable path to file '"Windows.h"'; specified path differs in
>>>>>> ca
>>>>>> > se from file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:34:10: warning:
>>>>>> > non-portable path to file '"Ole2.h"'; specified path differs in case
>>>>>> > from file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:138:10: warning:
>>>>>> > non-portable path to file '"OAIdl.h"'; specified path differs in cas
>>>>>> > e from file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:139:10: warning:
>>>>>> > non-portable path to file '"OCIdl.h"'; specified path differs in cas
>>>>>> > e from file name on disk [-Wnonportable-include-path]
>>>>>> >
>>>>>> >
>>>>>> > Clang diagnostic: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:2730:15: error:
>>>>>> unknown
>>>>>> > type name 'D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UNSUPPORTED'
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > java.lang.RuntimeException: C:\Program Files (x86)\Windows
>>>>>> > Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:2730:15: error:
>>>>>> unknown
>>>>>> > type name 'D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UN
>>>>>> > SUPPORTED'
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > Thanks.
>>>>>> >
>>>>>> > On Mon, Sep 7, 2020 at 11:05 PM Michael Ennen <mike.ennen at gmail.com>
>>>>>> wrote:
>>>>>> >
>>>>>> >> I should note that I also tried adding the DirectX 12 libraries
>>>>>> like so:
>>>>>> >>
>>>>>> >> & $panamaHome\bin\jextract -J-Xmx8G -L $inc\um\x64 -L
>>>>>> C:\Windows\System32\
>>>>>> >> -I $inc\um -l d3d12 -o d3d12.jar --record-library-path
>>>>>> $inc\um\d3d12.h
>>>>>> >>
>>>>>> >> (first -L argument)
>>>>>> >>
>>>>>> >> On Mon, Sep 7, 2020 at 4:29 PM Michael Ennen <mike.ennen at gmail.com>
>>>>>> wrote:
>>>>>> >>
>>>>>> >>> Hi Panama Devs,
>>>>>> >>>
>>>>>> >>> Sorry if it is too early to post feedback like this.
>>>>>> >>>
>>>>>> >>> I am attempting to run `jextract` on the d3d12.h DirectX 12
>>>>>> header file
>>>>>> >>> so that I can use panama to interact with native DirectX 12 from
>>>>>> Java.
>>>>>> >>>
>>>>>> >>> I am attempting to run jextract as follows:
>>>>>> >>>
>>>>>> >>> $inc ="C:\Program Files (x86)\Windows
>>>>>> Kits\10\Include\10.0.17763.0"
>>>>>> >>> $panamaHome = "C:\Program Files\Java\jdk-14-panama"
>>>>>> >>> & $panamaHome\bin\jextract -J-Xmx8G -L C:\Windows\System32\ -I
>>>>>> $inc\um -l
>>>>>> >>> d3d12 -o d3d12.jar --record-library-path $inc\um\d3d12.h
>>>>>> >>>
>>>>>> >>> When I do I get the following error:
>>>>>> >>>
>>>>>> >>> java.lang.RuntimeException: C:\Program Files (x86)\Windows
>>>>>> >>> Kits\10\Include\10.0.17763.0\um/d3d12sdklayers.h:2730:15: error:
>>>>>> unknown
>>>>>> >>> type name 'D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UNSUPPORTED'
>>>>>> >>>
>>>>>> >>> It is quite probable I have the command line arguments wrong. I
>>>>>> read the
>>>>>> >>> jextract --help arguments list and the examples document (for the
>>>>>> 2 Windows
>>>>>> >>> examples) and this is what I came up with.
>>>>>> >>>
>>>>>> >>> Thanks for your work.
>>>>>> >>> --
>>>>>> >>> Michael Ennen
>>>>>> >>>
>>>>>> >>
>>>>>> >> --
>>>>>> >> Michael Ennen
>>>>>> >>
>>>>>> >
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Michael Ennen
>>>>>
>>>>
>>>>
>>>> --
>>>> Michael Ennen
>>>>
>>>>
>>>
>>> --
>>> Michael Ennen
>>>
>>
>>
>> --
>> Michael Ennen
>>
>
>
> --
> Michael Ennen
>
>
--
Michael Ennen
More information about the panama-dev
mailing list