Posts: 12
Joined: Apr 2015
Reputation:
0
athei
Junior Member
Posts: 12
I am completely new to to kodi and really want to sink in my teeth. Despite the fact that I have a strong C++ background I gain understanding very slowly from reading the source code.
As far as I see it in garbears branch it is hardcoded that the game client has to to return a YUV420P pixel matrix. You generalized this to all supported formats and added a mode where the game client gets an OpenGL context to render into instead of returning pixel data. Is this correct?
I think this is a good idea. But I have to ask myself: Doesn't the mupen64plus creates it's own context for rendering since it originally was a standalone emulator.
I am especially interested in passing through encoded video and audio streams and let kodi handle the decoding for example for implementing a limelight game client (I know there is a gsoc application).
Posts: 416
Joined: Oct 2014
Reputation:
16
a1rwulf
Team-Kodi Member
Posts: 416
2015-04-11, 07:55
(This post was last modified: 2015-04-11, 07:57 by a1rwulf.)
I was in the same situation last year and I still know very little about all this.
This is what I found out when trying to get n64 (thx to garbear, FernetMenta and the guys of libretro).
You are right mupen64 is a standalone emulator but we use mupen64libretro, it's the libretro port of it.
Libretro is designed to have a frontend (retroarch is the reference implementation), it does handle rendering, audio, input etc. and a backend, the libretro-cores.
They are loaded by the frontend as shared objects.
There is an API definition that must be implemented to clue them together.
The n64 core needs hardware acceleration and cannot be used like the other cores.
Libretro defines functions that allow you to feed a framebuffer into the backend.
The fact that the kodi renderer runs in a different thread then retroplayer results in a shared opengl context.
So I don't give the context into the mupen core I just let it render on my framebuffer. Then I share the rendered texture with kodi's renderer.
I did no change to the pixelmatrix part, at least not intended :-)
Hope this helps to understand.
Posts: 12
Joined: Apr 2015
Reputation:
0
athei
Junior Member
Posts: 12
So you mean there is an extra context for Retroplayer that shares a texture with the Kodi context which renders to screen.
I looked over your commits. At first glance I did not see any synchronization between the two contexts (i could easily overlooked ANYTHING). I have read about some flickering problems you have. Maybe they are coming from there. Easiest method to test would be calling glFinish() after rendering to the shared texture.
Posts: 416
Joined: Oct 2014
Reputation:
16
a1rwulf
Team-Kodi Member
Posts: 416
Exactly. In Opengl every thread needs its own gl context, afaik.
Flickering is fixed when switching to the gfx plugin rice within the mupen64 addon settings, so i'm not sure if it's my code or something else. When input is ready and we can actually play a game there will be lots of changes needed I guess. My code is still kind of a POC.
And yes there's no synchronisation (yet?, dunno if needed or not).
Posts: 12
Joined: Apr 2015
Reputation:
0
athei
Junior Member
Posts: 12
Synchronisation between contexts is definitely needed but I have no idea if it is already provided somehow by kodi. But the bug you are experiencing can be everything of course. Flickering often leads to the depth buffer (z fighting).
Posts: 416
Joined: Oct 2014
Reputation:
16
a1rwulf
Team-Kodi Member
Posts: 416
I didn't look into all this details yet - mostly because it's quite senseless until one can actually play a game.
Hunting bugs will be much more effective (and exciting) when we have more than a working intro.
I had a look at the retroarch project in the early stage of my research, but I couldn't really figure out how they synchronize.
IIRC it's single threaded there, so maybe it's not even needed there.
I think when input is ready (I don't know if it is already, but on my system something doesn't work out), it will be the right time to push further in this area too.
Posts: 3,030
Joined: Dec 2010
Reputation:
293
garbear
Team-Kodi Developer
Posts: 3,030
input is working at a basic level now. you'll need to press "t" to launch ActivateWindow(GamePeripherals), and from there configure the keyboard for the NES controller. Then, in game.libretro.nestopia, the keys you've chosen will control the emulator
Posts: 416
Joined: Oct 2014
Reputation:
16
a1rwulf
Team-Kodi Member
Posts: 416
thanks for your replay garbear.
I tried yesterday, but there are a few issues I have to investigate further on my system:
* my xbox360 joystick is not found (I hacked it in last night but it's not fixed)
* when trying to map buttons, kodi crashes
* the log says something like "there's no feature for button "x" in game.controller.default"
I don't want to hijack this thread - so I'll open a new one with logs, stacktrace, etc. when I have some time.
Posts: 3,030
Joined: Dec 2010
Reputation:
293
garbear
Team-Kodi Developer
Posts: 3,030
i'm debugging controller input. use the keyboard for now. it emulators a joystick with many buttons and no hats or axes, so much of the same code gets hit.