Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Platforms split into separate modules: PLATFORM_DRM status #3344

Closed
michaelfiber opened this issue Sep 23, 2023 · 9 comments
Closed

Comments

@michaelfiber
Copy link
Contributor

michaelfiber commented Sep 23, 2023

Following @ubkp I'm starting this to track the PLATFORM_DRM split status

Modules checked status

module drm comment
raylib ✔️ -
examples/audio ✔️ -
examples/core ✔️ -
examples/models ✔️ -
examples/others
examples/shaders ✔️ -
examples/shapes ✔️ -
examples/text ✔️ -
examples/textures ✔️ -

Functions checked status

function drm comment
InitGraphicsDevice ✔️ -
SetupViewport ✔️ -
SetupFramebuffer ✔️ -
InitTimer - -
InitWindow - -
WindowShouldClose - -
CloseWindow - -
IsWindowReady - -
IsWindowFullscreen - -
IsWindowHidden - -
IsWindowMinimized - -
IsWindowMaximized - -
IsWindowFocused - -
IsWindowResized - -
IsWindowState - -
ToggleFullscreen - -
MaximizeWindow - -
MinimizeWindow - -
RestoreWindow - -
ToggleBorderlessWindowed - -
SetWindowState - -
ClearWindowState - -
SetWindowIcon - -
SetWindowIcons - -
SetWindowTitle - -
SetWindowPosition - -
SetWindowMonitor - -
SetWindowMinSize - -
SetWindowMaxSize - -
SetWindowSize - -
SetWindowOpacity - -
SetWindowFocused - -
GetWindowHandle - -
GetScreenWidth - -
GetScreenHeight - -
GetRenderWidth - -
GetRenderHeight - -
GetMonitorCount - -
GetCurrentMonitor - -
GetMonitorPosition - -
GetMonitorWidth - -
GetMonitorHeight - -
GetMonitorPhysicalWidth - -
GetMonitorPhysicalHeight - -
GetMonitorRefreshRate - -
GetWindowPosition - -
GetWindowScaleDPI - -
GetMonitorName - -
SetClipboardText - -
GetClipboardText - -
EnableEventWaiting - -
DisableEventWaiting - -
SwapScreenBuffer - -
PollInputEvents - -
WaitTime - -
ShowCursor - -
HideCursor - -
IsCursorHidden - -
EnableCursor - -
DisableCursor - -
IsCursorOnScreen - -
ClearBackground - -
BeginDrawing - -
EndDrawing - -
BeginMode2D - -
EndMode2D - -
BeginMode3D - -
EndMode3D - -
BeginTextureMode - -
EndTextureMode - -
BeginShaderMode - -
EndShaderMode - -
BeginBlendMode - -
EndBlendMode - -
BeginScissorMode - -
EndScissorMode - -
BeginVrStereoMode - -
EndVrStereoMode - -
LoadVrStereoConfig - -
UnloadVrStereoConfig - -
LoadShader - -
LoadShaderFromMemory - -
IsShaderReady - -
UnloadShader - -
GetShaderLocation - -
GetShaderLocationAttrib - -
SetShaderValue - -
SetShaderValueV - -
SetShaderValueMatrix - -
SetShaderValueTexture - -
GetMouseRay - -
GetCameraMatrix - -
GetCameraMatrix2D - -
GetWorldToScreen - -
GetWorldToScreenEx - -
GetWorldToScreen2D - -
GetScreenToWorld2D - -
SetTargetFPS - -
GetFPS - -
GetFrameTime - -
GetTime - -
SetConfigFlags - -
TakeScreenshot - -
GetRandomValue - -
SetRandomSeed - -
OpenURL - -
FileExists - -
IsFileExtension - -
DirectoryExists - -
GetFileLength - -
GetFileExtension - -
GetFileName - -
GetFileNameWithoutExt - -
GetDirectoryPath - -
GetPrevDirectoryPath - -
GetWorkingDirectory - -
GetApplicationDirectory - -
LoadDirectoryFiles - -
LoadDirectoryFilesEx - -
UnloadDirectoryFiles - -
ChangeDirectory - -
IsPathFile - -
IsFileDropped - -
LoadDroppedFiles - -
UnloadDroppedFiles - -
GetFileModTime - -
ScanDirectoryFiles - -
ScanDirectoryFilesRecursively - -
CompressData - -
DecompressData - -
EncodeDataBase64 - -
DecodeDataBase64 - -
IsKeyPressed - -
IsKeyDown - -
IsKeyReleased - -
IsKeyUp - -
GetKeyPressed - -
GetCharPressed - -
SetExitKey - -
IsGamepadAvailable - -
GetGamepadName - -
GetGamepadAxisCount - -
GetGamepadAxisMovement - -
IsGamepadButtonPressed - -
IsGamepadButtonDown - -
IsGamepadButtonReleased - -
IsGamepadButtonUp - -
GetGamepadButtonPressed - -
SetGamepadMappings - -
IsMouseButtonPressed - -
IsMouseButtonDown - -
IsMouseButtonReleased - -
IsMouseButtonUp - -
GetMouseX - -
GetMouseY - -
GetMousePosition - -
GetMouseDelta - -
SetMousePosition - -
SetMouseOffset - -
SetMouseScale - -
GetMouseWheelMove - -
GetMouseWheelMoveV - -
SetMouseCursor - -
GetTouchX - -
GetTouchY - -
GetTouchPosition - -
GetTouchPointId - -
GetTouchPointCount - -
@michaelfiber
Copy link
Contributor Author

michaelfiber commented Sep 23, 2023

I feel like I must be missing something obvious. I can compile PLATFORM_DRM on my fork without issue but I can't compile any examples without hitting this:

/usr/bin/ld: /tmp/cc3CeBqR.o: in function `main':
core_basic_window.c:(.text.startup+0x28): undefined reference to `InitWindow'
/usr/bin/ld: core_basic_window.c:(.text.startup+0x70): undefined reference to `WindowShouldClose'
/usr/bin/ld: core_basic_window.c:(.text.startup+0x7c): undefined reference to `CloseWindow'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `rgGetCurrentTime':
rcore.c:(.text+0x11a3c): undefined reference to `GetTime'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `UpdateCamera':
rcore.c:(.text+0x12c4c): undefined reference to `GetMouseWheelMove'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `BeginDrawing':
rcore.c:(.text+0x19328): undefined reference to `GetTime'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `EndDrawing':
rcore.c:(.text+0x19454): undefined reference to `GetWindowScaleDPI'
/usr/bin/ld: rcore.c:(.text+0x195d0): undefined reference to `SwapScreenBuffer'
/usr/bin/ld: rcore.c:(.text+0x195d4): undefined reference to `GetTime'
/usr/bin/ld: rcore.c:(.text+0x19690): undefined reference to `GetTime'
/usr/bin/ld: rcore.c:(.text+0x196f8): undefined reference to `PollInputEvents'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `BeginScissorMode':
rcore.c:(.text+0x19cd0): undefined reference to `GetWindowScaleDPI'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `GetFPS':
rcore.c:(.text+0x1b5f0): undefined reference to `GetTime'
/usr/bin/ld: rcore.c:(.text+0x1b620): undefined reference to `GetTime'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `GetTouchX':
rcore.c:(.text+0x1d6f8): undefined reference to `GetMouseX'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `GetTouchY':
rcore.c:(.text+0x1d70c): undefined reference to `GetMouseY'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `InitTimer':
rcore.c:(.text+0x1dde4): undefined reference to `GetTime'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `WaitTime':
rcore.c:(.text+0x1de0c): undefined reference to `GetTime'
/usr/bin/ld: rcore.c:(.text+0x1dea4): undefined reference to `GetTime'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `ProcessKeyboard':
rcore.c:(.text+0x1ea24): undefined reference to `TakeScreenshot'
/usr/bin/ld: ../src/libraylib.a(rcore.o): in function `PollKeyboardEvents':
rcore.c:(.text+0x1f4d8): undefined reference to `TakeScreenshot'
collect2: error: ld returned 1 exit status
make: *** [Makefile:535: core/core_basic_window] Error 1

@raysan5 @ubkp any ideas? It seems to be specifically happening with rcore_drm.c and I can't figure out why. If I compile raylib for PLATFORM_DESKTOP and compile the examples I have no issues. But repeating the steps for PLATFORM_DRM results in this and I can't see any issue.

@ghost
Copy link

ghost commented Sep 23, 2023

@michaelfiber Perhaps it could be here: L227-L229. Could you try this:

# Define additional directories containing required header files
ifeq ($(PLATFORM),PLATFORM_DRM)
    INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH)
    INCLUDE_PATHS += -I/usr/include/libdrm
endif

@michaelfiber
Copy link
Contributor Author

@ubkp - Thanks for the suggestion, that didn't do it but I think I'm on the right path now.

A bunch of code that should be defined in rcore_drm.c was accidentally still left in rcore.c. I'm going to move them first and see if that has an effect. These are functions that are only called by code in rcore_drm.c so moving them should be of little impact to other submodules.

Also the makefile does not include as many warning flags for PLATFORM_DRM as it does for others so I added the missing one for PLATFORM_DRM and it revealed some useful info.

@raysan5 raysan5 changed the title [split] PLATFORM_DRM status [core] Platforms split into separate modules: PLATFORM_DRM status Sep 24, 2023
@michaelfiber
Copy link
Contributor Author

michaelfiber commented Sep 24, 2023

Got everything cleaned up, found the 1 letter typo that was causing my issues, and am now doing a final rundown of checking examples to make sure they compile and work. Updated the first post here to have a nice table like @ubkp did. And the code changes are in draft form over in #3347

@ghost
Copy link

ghost commented Sep 25, 2023

@michaelfiber @raysan5

  1. Tested [split] rcore, drm changes #3347 and it worked perfectly! Fantastic job! Both raylib and all examples compiled without issues.
    Sidenote: the others/raylib_opengl_interop and others/rlgl_standalone examples didn't compile, but they also don't compile for PLATFORM_DRM on current master branch (f7c3035), so them not compiling is totally unrelated to the split. They also don't compile on PLATFORM_WEB. Not sure if they are even meant to.

  2. Tested all examples and they all worked!
    Sidenote: some had some issues on PLATFORM_DRM. But all these issues also happen on current master branch (f7c3035), so their issues are completely unrelated to the split.

  3. @raysan5 When you can, could you please update the Wishlist (raylib 5.0 wishlist! #2952) examples section with:

Issues with several examples not working on `PLATFORM_DRM`:

- [ ] **REVIEW: Examples with 3D cameras (e.g.: `models_first_person_maze`, `core_3d_camera_free`)**. Camera moving uncontrollably.
- [ ] **REVIEW: Examples with visible cursors (e.g.: `shapes_draw_circle_sector`, `shapes_draw_ring`)**. Cursor not showing.
- [ ] **REVIEW: Examples with type inputs (e.g.: `text_draw_3d`, `text_input_box`)**. Can't type.
- [ ] **REVIEW: Example: `audio_module_playing`**. Crashing the Raspberry Pi after a few seconds.
- [ ] **REVIEW: Example: `core_custom_frame_control`**. Flickering and not working.
- [ ] **REVIEW: Example: `core_vr_simulator`**. Not rendering.
- [ ] **REVIEW: Example: `models_skybox`**. Not rendering.
- [ ] **REVIEW: Example: `shaders_raymarching`**. Not rendering.
- [ ] **REVIEW: Example: `shaders_mesh_instancing`**. Segmentation fault.
- [ ] **REVIEW: Example: `rlgl_compute_shader`**. Not working
- [ ] **REVIEW: Example: `raylib_opengl_interop`**. Not compiling.
- [ ] **REVIEW: Example: `rlgl_standalone`**. Not compiling.

Environment

Tested PLATFORM_DRM on Raspberry Pi 3 Model B 1.2 with Raspberry Pi OS (11 Bullseye) 32-bit armhf.

@michaelfiber
Copy link
Contributor Author

@ubkp Thanks so much for doing so much testing! I haven't gotten a chance to yet but I'm glad its working. I marked it ready to merge for now.

I was looking over CoreData again. Right now everything is using one static instance of CoreData called CORE. My first thought for potentially splitting the PLATFORM_DRM data out of CoreData was to simply have a static instance of a struct called DrmData stored in a DRM variable and move the data that PLATFORM_DRM needs there. After that stuff is moved out of CoreData the overall structure of CoreData is almost completely clear with just a small amount of platform specific code for the other platforms.

And I think a decent chunk of the DRM specific stuff will eventually change as I think the input system can be streamlined and simplified a bit now. Having it split out would be great for that effort.

Is there a pitfall I am missing to having that data split out? I know there was a concern about multiple windows but I'm not sure exactly how CORE is manipulated to make multiple windows work now.

@ghost
Copy link

ghost commented Sep 25, 2023

@michaelfiber No problem, glad I could help! 👍

I think one advantage of CoreData would be simplicity (and a hint to try to reuse its members as much as possible). But I don't have enough experience to elaborate more than that, so I trust what you guys think is best.

Just would like to suggest that if CoreData was to be split, maybe it could be done on a "second phase", after the split is merged. That way, if there's some problem, it would be easier to rollback.

@raysan5
Copy link
Owner

raysan5 commented Sep 26, 2023

@michaelfiber @ubkp Thank you very much for all the work you put on this BIG redesign! Glad to know that most examples are already working as expected! Also, many thanks for all the testing and the detailed reports.

Is there a pitfall I am missing to having that data split out? I know there was a concern about multiple windows but I'm not sure exactly how CORE is manipulated to make multiple windows work now.

@michaelfiber I think it's a good idea to move CoreDataDrm specifics to rcode_drm, specially considering it's a big chunk of data. Maybe it can be also considered for some other platform with big specific structures. My main concern was the creation of secondary windows for afaik, that could be only relevant for PLATFORM_DESKTOP, so, no problem in moving the custom structures.

Just would like to suggest that if CoreData was to be split, maybe it could be done on a "second phase", after the split is merged. That way, if there's some problem, it would be easier to rollback.

I agree that moving those big structures, like the DRM one, can be done in a separate batch of after merging. Also, after the merge, it can be reviewed to simplify/standarize possible variables to use the CoreData provided ones, trying to avoid/minimize the custom structures when possible.

@michaelfiber
Copy link
Contributor Author

With the DRM PR merged I think this can be closed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants