Giter Site home page Giter Site logo

Descent 3 & gl4es about gl4es HOT 15 CLOSED

JeodC avatar JeodC commented on July 30, 2024
Descent 3 & gl4es

from gl4es.

Comments (15)

ptitSeb avatar ptitSeb commented on July 30, 2024 2

Ok, I'll send a mail at this address.

For the record, I ported hundreds of stuffs for the OpenPandora, that's why I developped gl4es and then box86 in the first place :D

Portmaster is a nice project indeed.

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

Through debug print statements in HardwareOpenGL.cpp I have determined that the FBO is initialized and the game blits to scale properly (1920x1152 display).

// if we're rendering to an FBO, scale to the window framebuffer!
  mprintf(0, "Value of GOpenGLFBO: %d\n", GOpenGLFBO);
  if (GOpenGLFBO != 0) {
    dglBlitFramebufferEXT(0, 0, GOpenGLFBOWidth, GOpenGLFBOHeight,
                          centeredX, centeredY, centeredX + scaledWidth, centeredY + scaledHeight,
                          GL_COLOR_BUFFER_BIT, GL_LINEAR);
    mprintf(0, "Blit framebuffer at: (%d, %d) to (%d, %d)\n", centeredX, centeredY, centeredX + scaledWidth, centeredY + scaledHeight);
CFILE: Using "intro.mve" instead of "intro.mve"
FindArg: Did not find [-sdlSndSizeMovie] on command line.
FindArg: Did not find [-sdlSndSize] on command line.
OPENGL: Setting zbuffer state to 0.
OPENGL: Setting zbuffer state to 1.
Value of GOpenGLFBO: 1
Blit framebuffer at: (192, 0) to (1728, 1152)
OPENGL: Setting zbuffer state to 0.
OPENGL: Setting zbuffer state to 1.

Edit: Confirming the SDL window is also created:

if (!GSDLWindow) {
    mprintf(0, "Creating SDL window with size %dx%d and flags %d\n", winw, winh, flags);
    GSDLWindow = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, winw, winh, flags);
    if (!GSDLWindow) {
      mprintf(0, "OpenGL: SDL window creation failed: %s", SDL_GetError());
      return 0;
    }
  } else {
    int currentW, currentH;
    SDL_GetWindowSize(GSDLWindow, &currentW, &currentH);
    mprintf(0, "Current SDL Window size is %dx%d\n", currentW, currentH);
    
    mprintf(0, "Setting SDL Window to %dx%d\n", winw, winh);
    SDL_SetWindowSize(GSDLWindow, winw, winh);

    mprintf(0, "Setting SDL Window to fullscreen with flags %d\n", flags);
    SDL_SetWindowFullscreen(GSDLWindow, flags);

    // Retrieve and print the actual window size
    int actualW, actualH;
    SDL_GetWindowSize(GSDLWindow, &actualW, &actualH);
    mprintf(0, "Actual SDL Window size is %dx%d\n", actualW, actualH);
  }

  if (!GSDLGLContext) {
    mprintf(0, "Creating OpenGL context for the SDL window\n");
    GSDLGLContext = SDL_GL_CreateContext(GSDLWindow);
    if (!GSDLGLContext) {
      mprintf(0, "OpenGL: OpenGL context creation failed: %s", SDL_GetError());
      SDL_DestroyWindow(GSDLWindow);
      GSDLWindow = NULL;
      return 0;
    } else {
        mprintf(0, "OpenGL: OpenGL context created successfully\n");
    }
  }
Creating SDL window with size 640x480 and flags 2
Creating OpenGL context for the SDL window
OpenGL: OpenGL context created successfully

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

d3.log

Here is a newer, more detailed logfile.

from gl4es.

ptitSeb avatar ptitSeb commented on July 30, 2024

Oh, you are using FB=4, so gbm rendering?! That will be tricky to debug, I don't have hardware like that myself

from gl4es.

ptitSeb avatar ptitSeb commented on July 30, 2024

I don't see the gl4es initialisation string on that log, that's strange.

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

It's a partial log, the full one is rather large. Here it is. This log begins at game initialization, goes up to the main menu, then quits.

d3.log

Note that this log is generated by the game itself, so gl4es initialization string may not be present. Here is the full launch script:

#!/bin/bash

XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}

if [ -d "/opt/system/Tools/PortMaster/" ]; then
  controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
  controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
  controlfolder="$XDG_DATA_HOME/PortMaster"
else
  controlfolder="/roms/ports/PortMaster"
fi

source $controlfolder/control.txt
source $controlfolder/device_info.txt
[ -f "${controlfolder}/mod_${CFW_NAME}.txt" ] && source "${controlfolder}/mod_${CFW_NAME}.txt"
get_controls

GAMEDIR="/$directory/ports/descent3"
DEVICE_ARCH="${DEVICE_ARCH:-aarch64}"
GAME="Descent3"

cd $GAMEDIR

if [ -f "${controlfolder}/libgl_${CFW_NAME}.txt" ]; then 
  source "${controlfolder}/libgl_${CFW_NAME}.txt"
else
  source "${controlfolder}/libgl_default.txt"
fi

# Create config dir
rm -rf "$XDG_DATA_HOME/Outrage Entertainment/Descent 3"
ln -s $GAMEDIR "$XDG_DATA_HOME/Outrage Entertainment/Descent 3"

# Setup gl4es environment
export LIBGL_ES=2
export LIBGL_GL=21
export LIBGL_FB=4
export LIBGL_VBO=1
export LIBGL_STACKTRACE=1

export SDL_VIDEO_GL_DRIVER="$GAMEDIR/libs.$DEVICE_ARCH/libGL.so.1"
export LIBGL_DRIVERS_PATH="$GAMEDIR/libs.$DEVICE_ARCH/libGL.so.1"
export LD_LIBRARY_PATH="$GAMEDIR/libs.$DEVICE_ARCH:/usr/lib:$LD_LIBRARY_PATH"

# Setup controls
$ESUDO chmod 666 /dev/tty1
$ESUDO chmod 666 /dev/uinput

$GPTOKEYB "$GAME" -c "joy.gptk" & 
SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
./$GAME -setdir "$GAMEDIR/gamedata" -f -logfile -g $LIBGL_DRIVERS_PATH -gllogging

$ESUDO kill -9 $(pidof gptokeyb)
$ESUDO systemctl restart oga_events & 
printf "\033c" >> /dev/tty1

I've also walked through the render steps to the best of my ability, here's a brief summary of the order of operations:

SDL Window Creation and OpenGL Context Initialization:

SDL window creation with appropriate attributes (SDL_GL_SetAttribute calls).
Creation and management of the OpenGL context (SDL_GL_CreateContext).
Setting the OpenGL context as current (SDL_GL_MakeCurrent).

FBO Management:

Proper teardown of existing FBO and renderbuffers (dglDeleteFramebuffersEXT, dglDeleteRenderbuffersEXT).
Creation of new FBO and associated renderbuffers (dglGenFramebuffersEXT, dglGenRenderbuffersEXT, dglFramebufferRenderbufferEXT).

Viewport and Scissor Management:

Setting viewport and scissor to match the dimensions of the SDL window or the FBO, ensuring correct rendering area.

Blitting from FBO to SDL Window:

Proper use of dglBlitFramebufferEXT to blit the FBO content onto the SDL window when necessary.

Buffer Swapping:

Correct usage of SwapBuffers (on Windows) and SDL_GL_SwapWindow (on Linux) to swap the front and back buffers, presenting the rendered content to the screen.

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

d3.log

Another log, run via ssh, this one shows gl4es init strings.

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

A partner added a screenshot function to determine if the framebuffer renders correctly before blitting, and there was an oddity in the Descent 3 code. To quote him, "there is only one texture and it's 128x128 with some garbage". When building the FB, gl4es appears to be creating a texture with id 1 and attaches it to GL_COLOR_ATTACHMENT0_EXT, but later the game tries to overwrite that texture with another texture.

Setting cur_texture_object_num = 2; at https://github.com/JeodC/Descent3/blob/develop/renderer/HardwareOpenGL.cpp#L119 and https://github.com/JeodC/Descent3/blob/develop/renderer/HardwareOpenGL.cpp#L311 makes the first texture id the game uses equal 2, and then the FB renders correctly.

image

Unfortunately, the SDL window (FB0) still displays a blank screen. The problem seems to be in blitting, maybe: https://github.com/JeodC/Descent3/blob/develop/renderer/HardwareOpenGL.cpp#L2052C1-L2056

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

Another opinion:

"What if GL4ES doesn't have any direct support for renderbuffers and it's creating a texture under the hood? Well, if it is, we now have a problem. Old OpenGL let you use texture names freely, so Descent 3 is like "okay my first texture is texture #1. My second is texture #2" and so on. The modern way of doing it is that you have to ask OpenGL for those numbers with glGenTextures."

I'm not sure if this is a lead, but it seemed like a valid question.

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

I don't have hardware like that myself

PortMaster has hundreds of ports that rely on gl4es and gbm. We can surely arrange something for you if you would like hardware for testing. It would be our way of thanking you. 🙂

from gl4es.

ptitSeb avatar ptitSeb commented on July 30, 2024

I don't have hardware like that myself

PortMaster has hundreds of ports that rely on gl4es and gbm. We can surely arrange something for you if you would like hardware for testing. It would be our way of thanking you. 🙂

What kind of hardware use gl4es+gbm? ambernic console, this kind of things? (I have none anyway).

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

I don't have hardware like that myself

PortMaster has hundreds of ports that rely on gl4es and gbm. We can surely arrange something for you if you would like hardware for testing. It would be our way of thanking you. 🙂

What kind of hardware use gl4es+gbm? ambernic console, this kind of things? (I have none anyway).

Anbernic and Powkiddy devices officially. With some effort we've gotten ports to run on more niche handhelds like the Gameforce Chi and TrimUI Smart Pro. Like I said we're more than happy to send you hardware--I can't think of a better way to witness the fruits of your labor.

If you're interested, fire an email to [email protected] and our administrator will take care of the rest. 🙂

Ports background information: https://portmaster.games/porting.html

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

Right. I know this game ran on box86 with gl4es. The only differences now are no x11 requirement, sdl2, and fbo. I'm assuming the libGL that's been compiled by another is using the correct compiler definitions (nox11=true etc). With a cursory glance, does anything specific to check come to mind given we know the fbo is receiving the draws but the screen is blank?

from gl4es.

ptitSeb avatar ptitSeb commented on July 30, 2024

There might be an issue with the context creation, especialy if the game / sdl2 tries multiple context creation to find the best one. the GLX part is still a bit fragile in gl4es, especialy with gbm backend that receive very little testing.

from gl4es.

JeodC avatar JeodC commented on July 30, 2024

I reverted the framebuffer object commit entirely and just went with what currently existed. It works with gl4es, but you may wish to continue looking into this particular issue. If so, feel free to reopen for tracking. Thanks!

from gl4es.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.