Google Play New problem : 64bits

All topics about ZGameEditor goes here.

Moderator: Moderators

User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

So I simply tried to replace libzgeandroid.so by the new 64bits one but the apk just launch and close.
I think I have to say that the apk is for arm64 somewhere in this messy AndroidManifest.xml but I didn't find how to do that yet.
User avatar
VilleK
Site Admin
Posts: 2334
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

Did you check if there is any information in the Android log?

I would expect it to just be to include libzgeandroid.so in the correct folder, which probably is something like "arm64-linux". But you could be right it needs some additional setting in the manifest too.
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

Hello. Sorry to reopen that coffin... I completely abandoned Google Play at the time and went to itch.io instead, then I forgot about the 64 bits version of ZGE for Android. But now I'm starting to receive complaints about players unable to run the Android version of Omeganaut on strict 64 bits phones, such as the Pixel 7. So I checked my good old tutorial to build ZGE for Android, and yes, it is 32 bits armeabi-v7a. So today I converted my compilation script from 32 bits:

Code: Select all

pushd "%~dp0"
if not exist "java\libs\armeabi-v7a\" mkdir java\libs\armeabi-v7a
if not exist "lib\arm-linux\" mkdir lib\arm-linux
PATH=C:\Android\android-ndk-r21e\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin;
C:\FPC\trunk\bin\i386-win32\ppcrossarm -B -MDelphi -Sghi -O3 -Tandroid -Parm -XXis -vw -Filib\arm-linux -FlC:\Android\android-ndk-r21e\platforms\android-29\arch-arm\usr\lib -Fu. -Fu..\.. -FUlib\arm-linux\ -FEjava\libs\armeabi-v7a\ -olibzgeandroid.so -dANDROID -dMINIMAL -Xd -CpARMV6 -CfVFPv2 -FuC:\FPC\trunk\units\arm-android\fcl-base -FuC:\FPC\trunk\units\arm-android\hash -FuC:\FPC\trunk\units\arm-android\rtl-objpas -FuC:\FPC\trunk\units\arm-android\paszlib zgeandroid.pas
popd
pause
to 64 bits:

Code: Select all

pushd "%~dp0"
if not exist "java\libs\arm64-v8a\" mkdir java\libs\arm64-v8a
if not exist "lib\arm64-linux\" mkdir lib\arm64-linux
PATH=C:\Android\android-ndk-r21e\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin;
C:\FPC\trunk\bin\i386-win32\ppcrossa64 -B -MDelphi -Sghi -O3 -Tandroid -Paarch64 -XXis -vw -Filib\arm64-linux -FlC:\Android\android-ndk-r21e\platforms\android-29\arch-arm64\usr\lib -Fu. -Fu..\.. -FUlib\arm64-linux\ -FEjava\libs\arm64-v8a\ -olibzgeandroid.so -dANDROID -dMINIMAL -Xd -CpARMV8 -CfFPv4 -FuC:\FPC\trunk\units\aarch64-android\fcl-base -FuC:\FPC\trunk\units\aarch64-android\hash -FuC:\FPC\trunk\units\aarch64-android\rtl-objpas -FuC:\FPC\trunk\units\aarch64-android\paszlib zgeandroid.pas
popd
pause
And everything is working nicely until it starts compiling ZExpressions.pas :

Code: Select all

ZExpressions.pas(2307,13) Error: Unknown identifier "R0"
ZExpressions.pas(2308,13) Error: Unknown identifier "R1"
ZExpressions.pas(2309,13) Error: Unknown identifier "R3"
ZExpressions.pas(2311,13) Error: Unknown identifier "R2"
ZExpressions.pas(2311,16) Error: Invalid reference syntax
ZExpressions.pas(2311,22) Fatal: Internal error 2014122002
Fatal: Compilation aborted
But those identifiers are in pure assembly, so I'm kind of stuck :lol:
Last edited by Ats on Sun Aug 25, 2024 10:30 pm, edited 2 times in total.
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

Internet says that replacing R by X will do the trick. And also adjust the size of the registers. But I'm not sure about the $ifdef semantics. Should this work?

Code: Select all

// First parameters in registers, then on stack
if ArgCount > 4 then
begin
  {$IFDEF CPUARM} // 32-bit ARM
    P := @Args + 16; // Start after first 4 args (4 * 4 bytes = 16 bytes)
    Tmp := ArgCount - 4;
    asm
      ldr r0, Tmp
      ldr r1, P
      mov r3, #0
    .Lmyloop:
      ldr r2, [r1, r3]
      str r2, [r13, r3]
      add r3, r3, #4
      sub r0, r0, #1
      cmp r0, #0
      bgt .Lmyloop
    end;
  {$ENDIF}

  {$IFDEF CPUARM64} // 64-bit ARM
    P := @Args + 64; // Start after first 8 args (8 * 8 bytes = 64 bytes)
    Tmp := ArgCount - 8;
    asm
      ldr x0, Tmp
      ldr x1, P
      mov x3, #0
    .Lmyloop64:
      ldr x2, [x1, x3]
      str x2, [sp, x3]
      add x3, x3, #8
      sub x0, x0, #1
      cmp x0, #0
      bgt .Lmyloop64
    end;
  {$ENDIF}
end;

{$IFDEF CPUARM} // 32-bit ARM
  asm
    ldr r0, Args
    ldr r1, Args + 4
    ldr r2, Args + 8
    ldr r3, Args + 12

    ldr r4, TheFunc
    blx r4

    str r0, RetVal
  end;
{$ENDIF}

{$IFDEF CPUARM64} // 64-bit ARM
  asm
    ldr x0, Args
    ldr x1, Args + 8
    ldr x2, Args + 16
    ldr x3, Args + 24

    ldr x4, TheFunc
    blr x4

    str x0, RetVal
  end;
{$ENDIF}

I'll try that tomorrow, as it is super late.

Edit:
32 bits version is compiling and running fine, so the $ifdef statements should be ok. But I get another compilation problem with the 64 bits version:

Code: Select all

ZExpressions.pas(2953,32) Error: Overloaded functions have the same parameter list
ZExpressions.pas(2265,32) Error: Found declaration: Execute(PExecutionEnvironment);
ZExpressions.pas(2953,32) Error: Function header doesn't match any method of this class "Execute(PExecutionEnvironment);"
ZExpressions.pas(2265,32) Error: Found declaration: Execute(PExecutionEnvironment);
Edit 2:
I solved this by replacing line 2764

Code: Select all

{$endif}
{$if defined(cpuaarch64)}  // ARM64
by

Code: Select all

{$elseif defined(cpuaarch64)}  // ARM64 (not for Android)
So Android 64 doesn't enter the main 64 code. This needs to be reviewed, as there are a lot of $ifdef in this code... :?


Next compilation error:

Code: Select all

ZExpressions.pas(443,16) Error: Forward declaration not solved "destructor Destroy;"
coming from

Code: Select all

    {$if defined(cpux64) or defined(cpuaarch64)}
    destructor Destroy; override;
    {$endif}
And there, I don't understand exactly how Pascal works. I believe it's because the TExpExternalFuncCall.Destroy is now inaccessible for Android 64 due to previous modification:

Code: Select all

destructor TExpExternalFuncCall.Destroy;
begin
  fpmunmap(Trampoline,512);
end;
So let's add another $ifdef to handle 64 bits computers and android :lol:

Code: Select all

{$endif}

{$if defined(cpuaarch64)}  // ARM64

destructor TExpExternalFuncCall.Destroy;
begin
  fpmunmap(Trampoline,512);
end;

{$endif}
Last edited by Ats on Sun Aug 25, 2024 10:36 am, edited 1 time in total.
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

ZExpressions.pas is now compiling fine. But you should take a look at the $ifdef structure to verify that everything is fine, as there are a lot of imbricated tests...

Next errors are coming from ZPlatform_Android.inc:

Code: Select all

ZPlatform_Android.inc(522,38) Error: Call by var for arg no. 3 has to match exactly: Got "LongWord" expected "QWord"
ZPlatform_Android.inc(727,41) Error: Call by var for arg no. 3 has to match exactly: Got "LongWord" expected "QWord"
This should do:

Code: Select all

procedure Platform_InitAudio;
var
  {$IFDEF CPU64}
  id: QWord;
  {$ELSE}
  id: LongWord;
  {$ENDIF}
begin
  AudioTerminated := False;
  BeginThread(AudioCallback, nil, id);
end;
and

Code: Select all

function Platform_CreateThread(ZThread: TZThread): pointer;
var
  {$IFDEF CPU64}
  id: QWord;
  {$ELSE}
  id: LongWord;
  {$ENDIF}
begin
  BeginThread(ThreadWrapper, ZThread, id);
  Result := pointer(id);
end;
Next errors are directly linked to my previous change:

Code: Select all

ZPlatform_Android.inc(526,28) Error: Incompatible type for arg no. 1: Got "AudioCallback(Pointer):LongInt;", expected "<procedure variable type of function(Pointer):Int64;StdCall>"
ZPlatform_Android.inc(735,28) Error: Incompatible type for arg no. 1: Got "ThreadWrapper(Pointer):LongInt;", expected "<procedure variable type of function(Pointer):Int64;StdCall>"
Solved by adding some new $ifdef... By the way, there seems to be several ways to define the exact same thing in Pascal, and I don't know which semantic you prefer.

Code: Select all

{$IFDEF CPU64}
function AudioCallback(Data : pointer) : Int64;
{$ELSE}
function AudioCallback(P: Pointer): LongInt;
{$ENDIF}
and

Code: Select all

{$IFDEF CPU64}
function ThreadWrapper(Data : pointer) : Int64; stdcall;
{$ELSE}
function ThreadWrapper(Data : pointer) : longint;
{$ENDIF}
I don't know why this last one needs stdcall;, the compiler told me to add that.

And libs/arm64-v8a/libzgeandroid.so is now compiled!

Edit:
It's not working on my phone... I have both versions of libs in the project:
libs/armeabi/libzandroid.so
libs/arm64-v8a/libzandroid.so
The app doesn't crash, but it's just a black screen. Which means it tries to run the 64 version, which it is able to, otherwise it would fall back to the 32. But 64 version isn't rendering anything.

By the way, ZGE is looking for libs/armeabi/libzandroid.so in order to compile for Android, so I can't change the folder name to the official one "armeabi-v7a". It's not really a problem though.
Last edited by Ats on Sun Aug 25, 2024 10:32 pm, edited 1 time in total.
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Re: Google Play New problem : 64bits

Post by Kjell »

Hi Ats,
Ats wrote: Sun Aug 25, 2024 12:26 amInternet says that replacing R by X will do the trick.
Yep, the R registers are 32-bit while the X registers are 64-bit. However, i'd recommend using x8-x18 ( they are the 64-bit equivalent to r0-r10 ) instead of x0-x7 as these are generally used for function arguments ( by compilers ).

K
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

All right :)

Code: Select all

// First parameters in registers, then on stack
if ArgCount > 4 then
begin
  {$IFDEF CPUARM} // 32-bit ARM
    P := @Args + 16; // Start after first 4 args (4 * 4 bytes = 16 bytes)
    Tmp := ArgCount - 4;
    asm
      ldr r0, Tmp
      ldr r1, P
      mov r3, #0
    .Lmyloop:
      ldr r2, [r1, r3]
      str r2, [r13, r3]
      add r3, r3, #4
      sub r0, r0, #1
      cmp r0, #0
      bgt .Lmyloop
    end;
  {$ENDIF}

  {$IFDEF CPUARM64} // 64-bit ARM
    P := @Args + 64; // Start after first 8 args (8 * 8 bytes = 64 bytes)
    Tmp := ArgCount - 8;
    asm
      ldr x8, Tmp
      ldr x9, P
      mov x11, #0
    .Lmyloop64:
      ldr x10, [x9, x11]
      str x10, [sp, x11]
      add x11, x11, #8
      sub x8, x8, #1
      cmp x8, #0
      bgt .Lmyloop64
    end;
  {$ENDIF}
end;

{$IFDEF CPUARM} // 32-bit ARM
  asm
    ldr r0, Args
    ldr r1, Args + 4
    ldr r2, Args + 8
    ldr r3, Args + 12

    ldr r4, TheFunc
    blx r4

    str r0, RetVal
  end;
{$ENDIF}

{$IFDEF CPUARM64} // 64-bit ARM
  asm
    ldr x8, Args
    ldr x9, Args + 8
    ldr x10, Args + 16
    ldr x11, Args + 24

    ldr x12, TheFunc
    blr x12

    str x8, RetVal
  end;
{$ENDIF}
But unfortunately, it doesn't fix my issue. Here's the adb log:

Code: Select all

--------- beginning of main
08-25 14:35:52.423 27115 27115 E ZgeAndroid: /storage/emulated/0
08-25 14:35:52.423 27115 27115 E ZgeAndroid: /data/user/0/com.txori.cube/files/
08-25 14:35:52.423 27115 27115 E ZgeAndroid: /data/user/0/com.txori.cube/lib/
08-25 14:35:52.424 27115 27115 E ZgeAndroid: JNI_OnLoad
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBindTexture
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBlendFunc
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glClear
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glClearColor
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glColorPointer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCopyTexImage2D
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCopyTexSubImage2D
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCullFace
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteTextures
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDepthFunc
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDepthMask
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDepthRange
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDisable
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDisableClientState
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDrawArrays
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDrawElements
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glEnable
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glEnableClientState
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glFinish
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glFlush
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glFrontFace
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGenLists
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGenTextures
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetError
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetFloatv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetIntegerv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glMateriali
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexParameteri
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetString
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glHint
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glIndexMask
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLightModelf
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLightModelfv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLightfv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLineWidth
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glListBase
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLoadIdentity
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLoadMatrixf
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glMaterialf
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glMaterialfv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glMatrixMode
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glNormal3f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glNormalPointer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glOrthof
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glFrustumf
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBegin
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCallList
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexSubImage2D
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glColor3f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glColor3fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glColor4fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glEnd
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glColorMaterial
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteLists
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDrawBuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetTexImage
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPolygonMode
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPopAttrib
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPushAttrib
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glRasterPos2f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexCoord2f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glVertex2f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glVertex3f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPointSize
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPolygonOffset
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPopMatrix
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glPushMatrix
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glReadPixels
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glRotatef
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glScalef
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glScissor
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glShadeModel
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexCoordPointer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexGeni
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexImage2D
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexParameterf
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTranslatef
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glVertexPointer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glViewport
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glColor4f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: Non-implemented GL function called
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glAttachShader
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBindAttribLocation
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCompileShader
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCreateShader
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCreateProgram
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteShader
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteProgram
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDetachShader
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetProgramiv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetShaderiv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetShaderInfoLog
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetProgramInfoLog
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glValidateProgram
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGetUniformLocation
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glLinkProgram
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glShaderSource
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniform3fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniform1f
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniform4fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniform2fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniform1i
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniform1fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniformMatrix3fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUniformMatrix4fv
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glUseProgram
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glActiveTexture
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glClientActiveTexture
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBindBuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteBuffers
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGenBuffers
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBufferData
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBufferSubData
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glIsRenderbuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBindRenderbuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteRenderbuffers
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGenRenderbuffers
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glRenderbufferStorage
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBindFramebuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDeleteFramebuffers
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGenFramebuffers
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glCheckFramebufferStatus
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glFramebufferTexture2D
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glFramebufferRenderbuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glGenerateMipmap
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glRenderbufferStorageMultisample
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glTexImage2DMultisample
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glBlitFramebuffer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glDisableVertexAttribArray
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glEnableVertexAttribArray
08-25 14:35:52.425 27115 27115 E ZgeAndroid: glVertexAttribPointer
08-25 14:35:52.425 27115 27115 E ZgeAndroid: GLBase: 1.1
08-25 14:35:52.566 27115 27173 E ZgeAndroid: JNI_OnLoad
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glBindTexture
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glBlendFunc
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glClear
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glClearColor
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glColorPointer
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glCopyTexImage2D
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glCopyTexSubImage2D
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glCullFace
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDeleteTextures
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDepthFunc
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDepthMask
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDepthRange
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDisable
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDisableClientState
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDrawArrays
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDrawElements
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glEnable
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glEnableClientState
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glFinish
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glFlush
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glFrontFace
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGenLists
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGenTextures
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGetError
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGetFloatv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGetIntegerv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glMateriali
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexParameteri
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGetString
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glHint
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glIndexMask
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glLightModelf
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glLightModelfv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glLightfv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glLineWidth
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glListBase
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glLoadIdentity
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glLoadMatrixf
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glMaterialf
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glMaterialfv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glMatrixMode
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glNormal3f
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glNormalPointer
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glOrthof
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glFrustumf
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glBegin
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glCallList
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexSubImage2D
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glColor3f
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glColor3fv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glColor4fv
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glEnd
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glColorMaterial
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDeleteLists
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glDrawBuffer
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glGetTexImage
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPolygonMode
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPopAttrib
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPushAttrib
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glRasterPos2f
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexCoord2f
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glVertex2f
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glVertex3f
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPointSize
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPolygonOffset
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPopMatrix
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glPushMatrix
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glReadPixels
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glRotatef
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glScalef
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glScissor
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glShadeModel
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexCoordPointer
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexGeni
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexImage2D
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTexParameterf
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glTranslatef
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glVertexPointer
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glViewport
08-25 14:35:52.566 27115 27173 E ZgeAndroid: glColor4f
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glAttachShader
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBindAttribLocation
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glCompileShader
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glCreateShader
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glCreateProgram
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDeleteShader
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDeleteProgram
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDetachShader
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGetProgramiv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGetShaderiv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGetShaderInfoLog
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGetProgramInfoLog
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glValidateProgram
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGetUniformLocation
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glLinkProgram
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glShaderSource
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniform3fv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniform1f
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniform4fv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniform2fv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniform1i
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniform1fv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniformMatrix3fv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUniformMatrix4fv
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glUseProgram
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glActiveTexture
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glClientActiveTexture
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBindBuffer
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDeleteBuffers
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGenBuffers
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBufferData
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBufferSubData
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glIsRenderbuffer
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBindRenderbuffer
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDeleteRenderbuffers
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGenRenderbuffers
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glRenderbufferStorage
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBindFramebuffer
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDeleteFramebuffers
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGenFramebuffers
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glCheckFramebufferStatus
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glFramebufferTexture2D
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glFramebufferRenderbuffer
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glGenerateMipmap
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glRenderbufferStorageMultisample
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glTexImage2DMultisample
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glBlitFramebuffer
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glDisableVertexAttribArray
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glEnableVertexAttribArray
08-25 14:35:52.567 27115 27173 E ZgeAndroid: glVertexAttribPointer
So it seems to be running, but things aren't rendering. I'm pretty sure it's due to a #ifdef that runs a computer 64 function somewhere, but there are so much #ifdef that I don't even know where to look at.
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Re: Google Play New problem : 64bits

Post by Kjell »

Hi Ats,
Ats wrote: Sun Aug 25, 2024 12:37 pmSo it seems to be running, but things aren't rendering.
Judging from the adb log it's ( at the very least ) unable to load any of the OpenGL functions .. hence the black screen. :|

Maybe something in ZPlatform_Android.inc isn't adjusted to 64-bit properly still? Since JNI_OnLoad is listed among the errors .. perhaps in LoadModule?

K
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

I was reading through the documentations about your previous edition of your post, the one talking about linking the 64 bits version of OpenGL for Android, So I tried this without results :
C:\FPC\trunk\bin\i386-win32\ppcrossa64 -B -MDelphi -Sghi -O3 -Tandroid -Paarch64 -XXis -vw -Filib\arm64-linux -FlC:\Android\android-ndk-r21e\platforms\android-29\arch-arm64\usr\lib -Fu. -Fu..\.. -FlC:\Android\android-ndk-r21e\sources\third_party\opengl\src\lib\arm64-v8a -FlC:\Android\android-ndk-r21e\platforms\android-29\arch-arm64\usr\lib -FUlib\arm64-linux\ -FEjava\libs\arm64-v8a\ -olibzgeandroid.so -dANDROID -dMINIMAL -Xd -CpARMV8 -FlGLESv2 -FuC:\FPC\trunk\units\aarch64-android\fcl-base -FuC:\FPC\trunk\units\aarch64-android\hash -FuC:\FPC\trunk\units\aarch64-android\rtl-objpas -FuC:\FPC\trunk\units\aarch64-android\paszlib zgeandroid.pas

Edit: now that I'm browsing the ndk sources, there's no sources\third_party\opengl\ folder... In fact, I found no trace of opengl in any android-ndk version: https://android.googlesource.com/platform/ndk/
So I don't think this is it.


Regarding my adb log, those are not Errors, but Executions. I have the same list if I run the working 32 bit version of my apk test. I think everything is going well :wink: but not showing anything
Last edited by Ats on Sun Aug 25, 2024 5:28 pm, edited 4 times in total.
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Re: Google Play New problem : 64bits

Post by Kjell »

Hi Ats,
Ats wrote: Sun Aug 25, 2024 5:04 pmRegarding my adb log, those are not Errors, but Executions. I have the same list if I run the working 32 bit version of my apk test.
Oops .. i thought the E's in your log were equivalent to the red E's here:

Image

Never mind then :wink:

K
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

Hahaha everything is so confusing when it comes to Android... :roll:
Speaking of which, all needed libs are located in android-ndk-r21e\platforms\android-29\arch-arm64\usr\lib folder, including the 64 bits version of libGLESv2.so , and everything in this directory is already linked in my original compilation script.
(I already tried adding this libGLESv2.so to my Android app com.txori.cube\libs\arm64-v8a folder, not working)

So I really think the problem comes from some $ifdef 64 in the source code. And there are a bunch of lookalikes in it:
{$ifdef CPU64}
{$if defined(cpux64)}
{$if defined(cpuaarch64)}
{$ifdef CPUARM64}
User avatar
Kjell
Posts: 1911
Joined: Sat Feb 23, 2008 11:15 pm

Re: Google Play New problem : 64bits

Post by Kjell »

Hi Ats,
Ats wrote: Sun Aug 25, 2024 5:24 pmHahaha everything is so confusing when it comes to Android... :roll:
Yea .. plus i haven't done anything Android for years so i'm hopelessly out of the loop. Concerning the various definitions / constants you listed:

CPU64 = Any 64-bit CPU
cpux64 = x86-64 CPUs ( the 64-bit version of x86 )
cpuaarch64 = 64-bit ARM CPUs
CPUARM64* = 64-bit ARM CPUs

*Apparently some don't like the AArch64 ( ARM Architecture 64-bit ) name so they use ARM64 instead.

K
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

In ZOpenGL.pas, those lines are rather suspicious:

Code: Select all

{$ifdef android}
glOrtho : procedure (left, right, bottom, top, zNear, zFar: GLFLoat); {$IFDEF WIN32}stdcall;{$ELSE}cdecl;{$ENDIF}
glFrustum : procedure (left, right, bottom, top, zNear, zFar: GLFLoat); {$IFDEF WIN32}stdcall;{$ELSE}cdecl;{$ENDIF}
{$else}
glOrtho : procedure (left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WIN32}stdcall;{$ELSE}cdecl;{$ENDIF}
glFrustum : procedure (left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WIN32}stdcall;{$ELSE}cdecl;{$ENDIF}
{$endif}
Correct me if I'm wrong, but {$IFDEF WIN32} doesn't have anything to do inside a {$ifdef android}. I believe it should simply be:

Code: Select all

{$ifdef android}
glOrtho : procedure (left, right, bottom, top, zNear, zFar: GLFLoat); cdecl;
glFrustum : procedure (left, right, bottom, top, zNear, zFar: GLFLoat); cdecl;
{$else}
glOrtho : procedure (left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WIN32}stdcall;{$ELSE}cdecl;{$ENDIF}
glFrustum : procedure (left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WIN32}stdcall;{$ELSE}cdecl;{$ENDIF}
{$endif}
But that isn't solving my black screen problem...
User avatar
Ats
Posts: 727
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Google Play New problem : 64bits

Post by Ats »

I just remembered about logcat in order to check all the AndroidLog traces, so I had to test it before going to sleep... :x
So here are the logs for my simple cube apk 32 and 64 bits. I had to zip them as the forum doesn't support txt file upload.

The 64 version is throwing those errors:

Code: Select all

08-26 01:28:12.562 I/hwservicemanager(  701): getTransport: Cannot find entry android.hardware.graphics.mapper@4.0::IMapper/default in either framework or device VINTF manifest.
08-26 01:28:12.563 I/Gralloc4(22041): mapper 4.x is not supported
08-26 01:28:12.563 I/hwservicemanager(  701): getTransport: Cannot find entry android.hardware.graphics.mapper@3.0::IMapper/default in either framework or device VINTF manifest.
08-26 01:28:12.563 W/Gralloc3(22041): mapper 3.x is not supported
08-26 01:28:12.565 I/hwservicemanager(  701): getTransport: Cannot find entry android.hardware.graphics.allocator@4.0::IAllocator/default in either framework or device VINTF manifest.
08-26 01:28:12.565 W/Gralloc4(22041): allocator 4.x is not supported
08-26 01:28:12.566 I/hwservicemanager(  701): getTransport: Cannot find entry android.hardware.graphics.allocator@3.0::IAllocator/default in either framework or device VINTF manifest.
08-26 01:28:12.566 W/Gralloc3(22041): allocator 3.x is not supported
Attachments
logcat_cube_32_64.zip
(4.11 KiB) Downloaded 10 times
Last edited by Ats on Mon Aug 26, 2024 9:14 am, edited 2 times in total.
User avatar
VilleK
Site Admin
Posts: 2334
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Google Play New problem : 64bits

Post by VilleK »

Hi,

I'm on vacation for another week so I can only make some guesses why it is not working.

For ZExpressions then I think 64-bit Android should use the cpuaarch64 ifdef section.

The "getTransport" errors is not something I recognize.

Please try with the absolute minimal ZGE project. I would start with a project that has App.ClearColor set to red and nothing else. When you have that working then we can take it step by step from there.
Post Reply