blu
Posts: 55
Joined: Tue Jul 17, 2012 9:57 pm

Re: OpenGL ES as slow as SDL?

Fri Aug 24, 2012 7:34 am

Speaking of dispmanx overlay blending, I encountered a rather amusing bug the other day: if you create an EGL context of RGBA8888 config, over a native window with a dispmanx element which has no blending info, you end up with partial overlay translucency. I haven't investigated the full details of the effect, but I strongly suspect a relation to the GL framebuffer content.

JPDefault
Posts: 30
Joined: Mon Jul 30, 2012 8:12 am
Location: Wiltshire

Re: OpenGL ES as slow as SDL?

Fri Aug 24, 2012 7:56 am

Thanks blue and dattrax, your help is much appreciated.

Dattrax, my application generates a raw buffer of 256x239 pixels.

With GL ES I used to copy them onto a 256x256 texture and stretch it so that it would fill the screen, no matter which was the screen resolution.
Dispmanx sees the screen as 1280x1024 on my DVI monitor, and 750x572 on my small 5.6" screen over RCA.
For now, I'm doubling the raw buffer's pixels to 512x478 within a loop before I feed them to to vc_dispmanx_resource_write_data. Is that what you mean by "upscaling"?
This has to be done for each frame. However, if I just copy the pixels as they are, there is no impact on the FPS.

P.S.: In my config file I have set the framebuffer as 640x480, which does not seem to make any difference.

JPDefault
Posts: 30
Joined: Mon Jul 30, 2012 8:12 am
Location: Wiltshire

Re: OpenGL ES as slow as SDL?

Fri Aug 24, 2012 10:07 am

By the way, this is what I was using:

Code: Select all

VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 
                             255, /*alpha 0->255*/
                             DISPMANX_FLAGS_ALPHA_FROM_SOURCE };

vars->element = vc_dispmanx_element_add(    vars->update,
                                                vars->display,
                                                2000,               // layer
                                                &dst_rect,
                                                vars->resource,
                                                &src_rect,
                                                DISPMANX_PROTECTION_NONE,
                                                &alpha,
                                                NULL,             // clamp
                                                DISPMANX_NO_ROTATE);

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: OpenGL ES as slow as SDL?

Fri Aug 24, 2012 10:40 am

JPDefault wrote: Dattrax, my application generates a raw buffer of 256x239 pixels.

With GL ES I used to copy them onto a 256x256 texture and stretch it so that it would fill the screen, no matter which was the screen resolution.
Dispmanx sees the screen as 1280x1024 on my DVI monitor, and 750x572 on my small 5.6" screen over RCA.
For now, I'm doubling the raw buffer's pixels to 512x478 within a loop before I feed them to to vc_dispmanx_resource_write_data. Is that what you mean by "upscaling"?
This has to be done for each frame. However, if I just copy the pixels as they are, there is no impact on the FPS.
Just create the resource as 256x239 pixels. Set the src_rect to 256<<16, 239<<16. Set the dest_rect to screensize (from graphics_get_display_size) and the scaling will be done on GPU.

dattrax
Posts: 52
Joined: Sat Dec 24, 2011 5:09 pm

Re: OpenGL ES as slow as SDL?

Fri Aug 24, 2012 10:43 am

You can scale in hardware, so this will save you some cycles.

There is a src and dst rect parameter to vc_dispmanx_element_add

Set the src to 0,0,256,239 and leave dst as is.

Obviously remove your cpu scale.

Jim

dattrax
Posts: 52
Joined: Sat Dec 24, 2011 5:09 pm

Re: OpenGL ES as slow as SDL?

Fri Aug 24, 2012 10:44 am

Oops, forgot the shift. Thanks Dom

blu
Posts: 55
Joined: Tue Jul 17, 2012 9:57 pm

Re: OpenGL ES as slow as SDL?

Sat Aug 25, 2012 5:39 pm

I was wrong, turns out eglCreateGlobalImageBRCM actually produces 'native pixmaps' for eglCreateImageKHR. Now I'm trying to figuring out how to pass client data to such a global image. Hints are welcome.

JPDefault
Posts: 30
Joined: Mon Jul 30, 2012 8:12 am
Location: Wiltshire

Re: OpenGL ES as slow as SDL?

Sat Aug 25, 2012 6:48 pm

Thanks dom and dattrax, that works wonderfully well.
blue wrote: I was wrong, turns out eglCreateGlobalImageBRCM actually produces 'native pixmaps' for eglCreateImageKHR. Now I'm trying to figuring out how to pass client data to such a global image. Hints are welcome.
Would be nice if anyone could find out how to use it.
I'm trying myself, but I'm not experienced nor lucky enough.

blu
Posts: 55
Joined: Tue Jul 17, 2012 9:57 pm

Re: OpenGL ES as slow as SDL?

Sat Aug 25, 2012 9:46 pm

JPDefault wrote:Would be nice if anyone could find out how to use it.
I'm trying myself, but I'm not experienced nor lucky enough.
I'm out of ideas myself, so here's the current code, if you can figure out something which I've missed:
https://code.google.com/p/test-es/sourc ... ve_bcm.cpp

It fails currently at eglLockSurface(). Anyhow, if you decide to build it from within its tree, I'd strongly suggest..

Code: Select all

./build_bcm_image_native.sh debug
..for full diagnostics info.

Chips
Posts: 195
Joined: Sat Aug 18, 2012 8:21 pm

Re: OpenGL ES as slow as SDL?

Sat Sep 08, 2012 9:14 am

Did you succeed to make it works ?
I wanted to use GLES for an emulator too since SDL is giving me some trouble...

JPDefault
Posts: 30
Joined: Mon Jul 30, 2012 8:12 am
Location: Wiltshire

Re: OpenGL ES as slow as SDL?

Sat Sep 08, 2012 12:46 pm

Chips wrote:Did you succeed to make it works ?
I wanted to use GLES for an emulator too since SDL is giving me some trouble...
No luck here, so I've been using dispmanx for fast fullscreen hardware scaling instead. So far I've got Vice, Fceux, Doxbox and Snes9x running at decent speeds.
Sounds is another issue... managed to have it perfect in FceuxX, good enough in Vice, but still have huge latencies in Snes9x and Sound Blaster emulation in Dosbox.

Chips
Posts: 195
Joined: Sat Aug 18, 2012 8:21 pm

Re: OpenGL ES as slow as SDL?

Mon Sep 24, 2012 1:54 pm

Ok thanks. I got dispmanx running too. Is there some way to have some vsync handling ?

JPDefault
Posts: 30
Joined: Mon Jul 30, 2012 8:12 am
Location: Wiltshire

Re: OpenGL ES as slow as SDL?

Mon Sep 24, 2012 2:54 pm

Chips wrote:Ok thanks. I got dispmanx running too. Is there some way to have some vsync handling ?
If you are calling vc_dispmanx_update_submit_sync, that should wait for the next vsync before returning.
I'm not sure how it works as I'm not using it (the tearing is totally unnoticeable in my composite 5.6" LCD screen).

Andrey
Posts: 78
Joined: Sat Sep 01, 2012 9:52 am

Re: OpenGL ES as slow as SDL?

Mon Jan 28, 2013 3:56 pm

JPDefault wrote:I wanted to use GLES for an emulator too since SDL is giving me some trouble...
No luck here, so I've been using dispmanx for fast fullscreen hardware scaling instead. So far I've got Vice, Fceux, Doxbox and Snes9x running at decent speeds.
Sounds is another issue... managed to have it perfect in FceuxX, good enough in Vice, but still have huge latencies in Snes9x and Sound Blaster emulation in Dosbox.
Hi)

I got 50/60 fps (vsynced PAL/NTSC) in Atari800/Unreal Speccy Portable emulators with GLES2 rendering.
Source code & some explanations here:
http://www.raspberrypi.org/phpBB3/viewt ... 78&t=30889

JPDefault
Posts: 30
Joined: Mon Jul 30, 2012 8:12 am
Location: Wiltshire

Re: OpenGL ES as slow as SDL?

Thu Feb 14, 2013 1:00 pm

Andrey wrote:
JPDefault wrote:I wanted to use GLES for an emulator too since SDL is giving me some trouble...
No luck here, so I've been using dispmanx for fast fullscreen hardware scaling instead. So far I've got Vice, Fceux, Doxbox and Snes9x running at decent speeds.
Sounds is another issue... managed to have it perfect in FceuxX, good enough in Vice, but still have huge latencies in Snes9x and Sound Blaster emulation in Dosbox.
Hi)

I got 50/60 fps (vsynced PAL/NTSC) in Atari800/Unreal Speccy Portable emulators with GLES2 rendering.
Source code & some explanations here:
http://www.raspberrypi.org/phpBB3/viewt ... 78&t=30889
Sounds great! Looks like what I was initially trying to do, until I was told that rendering to texture without a native pixmap was slow.
Great job, Andrey!

Return to “OpenGLES”