Requesting help and permission to use code

Discussion and questions about programming with Ultibo.
User avatar
Ultibo
Site Admin
Posts: 1932
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Requesting help and permission to use code

Postby Ultibo » Fri May 11, 2018 12:04 am

JPNotADragon wrote:Working on cannibalizing VC4.pas for my first test program... found a problem at line 595: the comment is not being closed.

Thanks for that, fix will be in the next commit.

JPNotADragon wrote:I found the datatype cunsigned int the bcm_host section of VC4.pas. That type appears to be specific to your fork of the compiler, correct ? I have replaced it with NativeUInt for now.

The cunsigned type comes from the Ctypes unit which is part of the FPC RTL, NativeUInt will be okay as long as you never try to use it on a 64 bit build because it will be the wrong size then, Longword would be the correct translation.

JPNotADragon wrote:I have experimentally reduced VC4.pas to a form that compiles, but I'm getting linker errors. It should be easy to remove those, and I'll try that tomorrow, but could you tell me a little about what they are, and why my linker can't find them ?

That list just happens to line up with the list of libraries that Raspberry Pi don't include in their build of the VC4 userland, you can see the libraries that are provided by Raspbian here.

You should simply remove the LINKLIB directive for each of those and the problem will go away, in fact you don't need most of those LINKLIB directives and you can probably leave out all of them except bcm_host and maybe one or two others (like GLESv2 and EGL).

There is another source you can look at which might be helpful, the Asphyre/PXL library supports OpenGL ES on Raspbian and the PXL.Boards.PI.BCM.pas unit includes all of the definitions from bcm_host and dispmanx that are required, that link is from the Ultibo port but that file has not changed much from the original.
Ultibo.org | Make something amazing
https://ultibo.org
JPNotADragon
Posts: 10
Joined: Tue May 08, 2018 11:05 am

Re: Requesting help and permission to use code

Postby JPNotADragon » Fri May 11, 2018 12:41 am

The cunsigned type comes from the Ctypes unit which is part of the FPC RTL, NativeUInt will be okay as long as you never try to use it on a 64 bit build because it will be the wrong size then, Longword would be the correct translation.

This is rather subtle. I just had a look at the compiler files, and there are two files that define the C types: ctypes.pp and ctypes.inc. The first actually seems to support 16-bit processors (if such a thing still exists), and in that case, and that case only, cunsigned (= cuint) = cuint16!
Setting 16-bit cpus aside though, you are absolutely right: cunsigned is apparently designed to be 32 bit except on 16-bit CPUs, but does *not* grow to 64 bit on 64-bit platforms like NativeUInt most probably would.

That list just happens to line up with the list of libraries that Raspberry Pi don't include in their build of the VC4 userland, you can see the libraries that are provided by Raspbian here.

So that's where all the goodness comes from! That's real good to know, and, aha, there are files there that are newer than the ones on my Raspbian Stretch... Thanks!
JPNotADragon
Posts: 10
Joined: Tue May 08, 2018 11:05 am

Re: Requesting help and permission to use code

Postby JPNotADragon » Thu May 17, 2018 8:43 pm

I've been working some more on this (had to start from scratch after accidentally destroying my SD card), and have come across the egl.pas unit now. I managed to make it work, but I was wondering why Ultibo manually links to the shared object procedures ? (I used {$linklib 'brcmEGL'} and {$linklib 'brcmGLESv2'}.)
User avatar
Ultibo
Site Admin
Posts: 1932
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Requesting help and permission to use code

Postby Ultibo » Thu May 17, 2018 11:56 pm

JPNotADragon wrote:I've been working some more on this (had to start from scratch after accidentally destroying my SD card), and have come across the egl.pas unit now. I managed to make it work, but I was wondering why Ultibo manually links to the shared object procedures ? (I used {$linklib 'brcmEGL'} and {$linklib 'brcmGLESv2'}.)

You are correct that in a broad sense it is possible to just define the imported functions and add the library name as part of the external directive in each function and the linker will resolve everything from there.

Occasionally however there are cases where dependencies between libraries are such that one must be listed before the other in order for the linker to resolve all of the symbols, this case exists with the relationship between EGL and GLESv2 so to ensure the correct result we list them explicitly in LINKLIB directives.

For safety sake we usually end up doing the same thing for most other libraries as well just to avoid any possibility of strange results if people order the units differently in the uses clause etc.
Ultibo.org | Make something amazing
https://ultibo.org
JPNotADragon
Posts: 10
Joined: Tue May 08, 2018 11:05 am

Re: Requesting help and permission to use code

Postby JPNotADragon » Fri May 18, 2018 11:14 am

Ultibo wrote:
JPNotADragon wrote:Occasionally however there are cases where dependencies between libraries are such that one must be listed before the other in order for the linker to resolve all of the symbols, this case exists with the relationship between EGL and GLESv2 so to ensure the correct result we list them explicitly in LINKLIB directives.

Ah, I seem to have misunderstood something here. The egl.pas file contains code for *explicit* dynamic loading (procedure LoadEGL), but that is only compiled when the unit is used outside of ultibo. I had missed that.

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest