About Store Forum Documentation Contact



Post Reply 
Cache memory allocation does not work without XDisplay
Author Message
Fex Offline
Gold Supporter

Post: #1
Cache memory allocation does not work without XDisplay
On Ubuntu 22.04 (Desktop) using latest commit 06235fdd8ba82c1d190181389cc999bfe1612e16

Running Tutorial 04 - Graphics / 2D Effects

With InitPre() flags added:

Code:
void InitPre()
{
   INIT();
   App.flag=APP_ALLOW_NO_GPU|APP_ALLOW_NO_XDISPLAY;
}

Running from within the Esenthel Editor works.
Running from the terminal works e.g:

Code:
~/EsenthelEngine/Editor/Projects/_Build_/2D Effects$ 2./2D\ Effects

However logging in as ssh (no XDisplay):

Code:
$ ssh localhost
$ glxinfo | grep -i opengl
Error: unable to open display
~/EsenthelEngine/Editor/Projects/_Build_/2D Effects$ ./2D\ Effects
Can't load Image "hgn3m4u6#-e5h^w7n!1niah_"

This line in Cache.cpp fails:

Code:
if(Ptr data=get(file, path, counted))return data;


Leading to to the "Can't load Image" exit error. This also occurs with meshes. I haven't tested the other types.
04-13-2024 04:01 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: Cache memory allocation does not work without XDisplay
Images and meshes need GPU resources. So maybe this kind of operation won't work, unless you can have some GPU driver that will work in software and emulate things.
04-16-2024 07:27 AM
Find all posts by this user Quote this message in a reply
Fex Offline
Gold Supporter

Post: #3
RE: Cache memory allocation does not work without XDisplay
So the goal of this is to be able to run on systems without any X server installed. For anyone else that might want to run headless servers on Linux that can also load Worlds (for physics), and Skeletons (to animate to place hitboxes) .. here is what I have done so far..

Change Ptr _Cache::require in the Engine Cache.cpp to use CACHE_DUMMY instead of CACHE_EXIT, I also added some Logging to see what was going on:

Code:
/******************************************************************************/
Ptr _Cache::require(CChar *file, CChar *path, Bool counted)
{
   LogN(S+"Cache::require file " + file);
   LogN(S+"Cache::require path " + path);
   LogN(S+"Cache::require counted " + counted);
   LogN(S+"Cache::require _debug_name " + _debug_name);
  
   if(_mode==CACHE_EXIT){
       LogN(S+"Cache::require switch to dummy ");
       _mode = CACHE_DUMMY;
   }
   if(Ptr data=get(file, path, counted)){
       LogN(S+"return data!");
       return data;}
   if(Is(file) && _mode==CACHE_EXIT)
   {
       LogN(S+"Can't load..");
              Str error =MLT(S+"Can't load "+_debug_name+" \""+file+'"', PL,S+u"Nie można wczytać \""  +file+'"');
      if(Is(path))error+=MLT(S+"\nAdditional path \""         +path+'"', PL,S+u"\nDodatkowa ścieżka \""+path+'"');
             LogN(error);
              Exit(error);
   }
   LogN(S+"returning null! " +_debug_name+ " file " + file);
   return null;
}
/******************************************************************************/

This allowed the World to load, terrain and object physics appear to load. However things like Character skeletons would not load, because the character loading would give up after Images/Meshes failed. So the "skel" member had no bones.

To get around this I copied the objects with skeletons in the Editor, and deleted all the mesh parts in the editor of the copy. Then which object is loaded in code (Player class which is shared by the client and server for simplicity) is determined by a macro.
Code:
#ifdef CLIENT
            super.create(*ObjectPtr(UID(3515614368, 1307699862, 549994659, 1379013884))); //with MESH
            #else
            super::create(*ObjectPtr(UID(4120551111, 444656304, 4157660391, 458487660))); //MESH parts removed
            #endif

It is not pretty but so far it seems to work. Skeletons/animations are needed because the server needs both to determine the location of hitboxes, as all physics and hitboxes etc need to be server authoritative. A better solution would be some type of engine flag or something to both allow the dummy cache loading, and to simply parse through but not fail on Image/Mesh loading without an X server.
04-18-2024 03:31 PM
Find all posts by this user Quote this message in a reply
Post Reply