Commit Graph

48 Commits

Author SHA1 Message Date
Jesse Hall
a4fb8a60b1 EmuGL: fix GL view position in window on OS X
The code that creates the GL-accelerated screen view wasn't converting
the upper-left-relative coordinates used within the emulator to the
lower-left coordinates used by the Cocoa APIs on OS X. Since most
skins have the screen view centered vertically this often just
happened to work.

Bug: 5782118
Change-Id: I2f96ee181e850df5676d10a82d86c94421149b40
2012-01-04 15:03:39 -08:00
David 'Digit' Turner
3abd13d4d6 emulator: opengl: Support named pipes on Win32
This patch adds support for Win32 named pipes for the communication
channel between the Opengl renderer library and its clients.

Named pipes should be much faster than local TCP sockets on this
platform. Note that by default, TCP sockets are still used. The
emulator needs to call setStreamMode(STREAM_MODE_PIPE) to be able
to use these.

Change-Id: I86d36624cf2b7fdd50f41e1e43c908348dca4657
2011-09-13 14:04:49 +02:00
David 'Digit' Turner
3d76ec1e3c emulator: opengl: Add support for unix sockets.
This patch allows the OpenGLES rendering library to use Unix
sockets instead of TCP ones when communicating with its clients.
On certain benchmarks (e.g. 0xBench teapot), this provides a
noticeable improvement (x1.05 fps) without any other changes.

On practice, Unix sockets are faster than TCP sockets, even
local ones. Also, this introduces a moderate amount of
abstraction that will allow us to use Win32 named pipes
on Windows (where TCP sockets are much slower than they
are on Unix).

Note that by default, TCP streams are still used.
The client (emulator) must call the new API 'setStreamMode'
to change it to STREAM_MODE_UNIX between 'initLibrary' and
'startOpenglRenderer' calls.

+ Adjust callers / user appropriately.

Change-Id: I4105bbf07541f3146b50a58d1a5b51e8cf044fab
2011-09-13 14:03:32 +02:00
David 'Digit' Turner
6ba16ba752 Merge "emulator: opengl: add initLibrary function to render library" 2011-08-29 08:01:42 -07:00
David 'Digit' Turner
5d1e8b2f28 emulator: opengl: add initLibrary function to render library
This adds an initLibrary() function to libOpenglRender.

It will be used by the emulator to fallback on software rendering
if the library cannot be initialized properly, e.g. if it is not
possible to load the host EGL/GLES libraries.

Change-Id: I41e8ad73a315166e4a15cbee1db72c2552370f46
2011-08-29 16:57:38 +02:00
David 'Digit' Turner
91572d15eb emulator: opengl: use bilinear filtering
This patch changes the filter used to scale the GL window
in the rendering library. Instead of nearest-neighbour, use
bi-linear, which will provide for much more pleasant results
when scaling the emulator UI window, or toggling to full-screen
mode.

Change-Id: If2d9e1300fa4878c25e1221eaedb565b9150431a
2011-08-26 17:31:58 +02:00
David 'Digit' Turner
20d5b0a857 emulator: oops, really fix the build
Change-Id: Id8de1b6a069cdc462681cf44bf8ebd84bbd1e6f0
2011-08-25 22:14:29 +02:00
David 'Digit' Turner
47cbdfb291 emulator: opengl: remove debug traces.
You can still re-enable them by uncommenting one line in
development/tools/emulator/opengl/Android.mk

Change-Id: Ie0a640b6f3359b437aba40b124da0892defb00ef
2011-08-24 16:06:21 +02:00
Guy Zadickario
4629d2412b opengles emulator: fixes flashing effect on Mac
There is a flashing effect we see on Mac when switching between
drawables (pbuffer and a window) on the same context.
This change make the FrameBuffer object in the renderer to use
two different OpenGL contexts, one which is used while the pbuffer
drawable is bound and another which is used when the subwindow is
bounded during swap. The two contexts share textures so both contexts
have access to all allocated color buffers.

While this fixes the flashing effect on Mac, it should be more effective on
other platforms as well.

Change-Id: I63b49f0cdae8e2785765503750bbf5fbd4d963a1
2011-08-18 13:36:38 +03:00
Guy Zadickario
b9a5baf42b opengles emulator: code cleanup removing dead code
This change removes the 'blitFromPbuffer' path in the renderer
which uses binding pbuffer to texture. This path does not work
on all platforms and is not relavent any more. It simplifies
a lot the FBConfig filtering code.

Also, added a check to fail the renderer initialization if
the translator plugin does not support EGL_KHR_gl_texture_2d_image
and GL_OES_EGL_IMAGE (by both GLES implementations [1 and 2])
since our implementation requires it.

Change-Id: Ifd4c66943a8da56308cfb7e38914c962b4f5befe
2011-08-16 12:14:02 +03:00
Guy Zadickario
8c962dce6c opengles emulator: replace the readback at end of frame with blit
That replaces the readback to host we do at the end of each frame
with two blits on the GPU, one to copy the pixels into a texture
and another to render the texture to another in order to flip
the image.

Change-Id: I7e0e10493d38944d0b613e245023f34236d3dfc4
2011-08-16 10:52:19 +03:00
Yochai Shefi Simchon
a6b033d19e opengles emulator: do single display connection for all subwindow
This is a workaround to a driver bug on Intel/Linux, when destroying
a subwindow do not close the X display connection, keep it for the
next call to createSubWindow. It happens that the intel/linux driver
caches the display connection for each window ID and use it during
swap or something similar. Using the same display connection for
all subwindows workaround the problem.

Also added a wait loop to wait until the window becomes mapped
instead of just calling XSync after calling XMapWindow. This
is more accurate and make sure we do not miss the first window
refresh.

Change-Id: I63c69d736df433666a8c79d71127afe72776e89f
2011-08-15 19:03:53 +02:00
Guy Zadickario
617416e693 opengles emulator: support display rotation and resize
Changes the render_api to support re-creating the display
sub-window and the ability to rotate the displayed framebuffer
image.
That currently works only when the renderer runs as a thread
and not as seperate process. Therefore we setup the library
to run the renderer as thread(s) inside the calling process
on *all* platforms for now.

Change-Id: Ifd009db903759042a7edcf89866d3c3fe076cae9
2011-08-11 17:36:20 +03:00
Guy Zadickario
9dcac079ce opengles emulator: mac support binding context to pbuffer
On Mac it happens that when a context is bound to a pbuffer
and you want to bind it to a window (NSView) instead you must
release it from the pbuffer before binding the window by calling
clearDrawable handle of NSOpenGLContext.
This change added an override of NSOpenGLContext in order to track
to which drawable type the context was previously bound and
call clearDrawable when necessary.

Change-Id: Iece5ab16a46aa0d107ccb773986a6b280d09d181
2011-08-11 17:36:20 +03:00
Guy Zadickario
13b3da879b opengles emulator: added FPS statistics printout
Make the renderer print FPS statistics every 1 second.
Need to set SHOW_FPS_STATS=1

Change-Id: I69e8c43a779e685ae0b34974d1ef33ad75e7a7e4
2011-08-11 17:36:13 +03:00
Liran
0fd3ee21c8 opengles emulator: GLES fix memory leaks
fix some memory leaks and potential risks
detected using valgrind

Change-Id: I0f69cf4d4b4ba5eeb9c735f6712c301bcd4d3d36
2011-08-10 10:53:06 +02:00
Guy Zadickario
f6b9241094 opengles emulator: support glEGLImageTargetRenderbufferStorageOES
needed changes to support glEGLImageTargetRenderbufferStorageOES,
added implementation in egl and added tokens to renderControl.

Also fixed function pointers returned by eglGetProcAddress to
return functions that works independant of the current context,
see system/egl/ClientAPIExts.cpp

That makes the egl_image conformance test to pass on the guest.

Change-Id: I580cda82ba0fb44f12b75aa0bbacf5cd9f15f744
2011-08-10 10:53:06 +02:00
Guy Zadickario
f1d98dd318 opengles emulator: filter-out non-RGB configs
some applications and conformance tests expects to have
non-zero bit counts for all red,green and blue channels.
The translator expose all EGL compliant configs, including
monochrome and RG configs.
We now filter those out and expose to the guest only the RGB
configs.

Change-Id: I9a293675359135a548ce1c089f31a48ea2b7f46e
2011-08-10 10:53:06 +02:00
Guy Zadickario
62c6532937 opengles emulator: handle window surface resize
resize the internal pbuffer we use for a WindowSurface
when a color buffer of different size is attached to the "window".
That fixes "Glyder 2 by glu" application view while loading.

Change-Id: I8f235f428e93077d57bd200f10b45b9a92f1a9d3
2011-08-10 10:13:38 +02:00
Guy Zadickario
ded8587d2d opengles emulator: Fixed Windows renderer termination
Make the event pump loop in the renderer process we do on Windows
exit when the Framebuffer's subwindow is destroyed.
Fixed TcpStream to close the socket using 'closesocket' on windows,
otherwise the other end of the socket does not sense that the socket
is closed.

+ Use WS_DISABLED to ensure that our GL subwindow doesn't receive
  any input events.

Change-Id: Icb477b3e1d7993a8880acb5e01bc5da29309ae50
2011-08-10 10:11:13 +02:00
Liran
5018365268 opengles emulator: GLES memory leaks
fix some memory leaks detected in valgrind

Change-Id: I48d91223c520c9c10b797a89a679eed7a950a3e6
2011-08-10 10:08:05 +02:00
Guy Zadickario
467e5fb162 opengles emulator: fixed renderer termination flow
Handling clean exit of the renderer when stopOpenGLRenderer
is called. This is done by openning a connection to the renderer
and flag that it should exit. Added 'clientFlags' field which must
be send after every connection is made to the renderer for this purpose.
The server will wait for running rendering threads to exit and then will
close all EGL/GL resources and will exit. The stopOpenGLRenderer will
return only when the renderer has exited.

Change-Id: I8272b8ea59d5fc78453bb7bd2d25908068869fa7
2011-08-10 10:03:07 +02:00
Stas Gurtovoy
6208854726 opengles emulator: dynamicaly grow ReadBuffer
In case we're receiving packets larger then the initial size
of the read buffer, we dynamicaly grow (X2 steps) the size of
the buffer. An example for this large buffer is a 4MB texture
in JetCarStunts.

Change-Id: I167caddb731583811c009321d4f8fb2f7eea032c
2011-08-09 17:14:12 +02:00
David 'Digit' Turner
3a064ab539 emulator: opengl: Make render_api.h C-compatible
This change modifies the function declarations under
developement/tools/emulator/opengl/host/include/render_api.h
to make them callable from C.

This is preparation work for integrating the rendering library
into the emulator. The plan is to dlopen() the library dynamically
and using non-mangled function names makes using dlsym() both
easier and more portable.

Change-Id: I34656ea4618dbb989fb6ff78df43e9bfb38a7799
2011-08-05 16:28:01 +02:00
Stas Gurtovoy
201584b1d4 egl emulator: fixes for covegl conformance test
Support for eglChooseConfig with configs==NULL.
Also added small change to query EGL_LARGEST_PBUFFER attrib of surfaces.
Fixed error print in QemuPipeStream::readFully.

Those changes make sure that covegl completes & passes on the emulator with Translator
on linux in the backend.

Change-Id: I892917ec102ae85d56a16a7cb321e8c12e7083f1
2011-07-12 00:46:06 +02:00
Guy Zadickario
64f8ae0369 opengl renderer: added option to dump GL stream to file.
This is a debugging tool which enables to dump the guest
command stream to a file which can be later be examined
and "played" using a seperate tool.

Change-Id: I3fec19c1a651f0ed4394c33a0c0cd9ba54384355
2011-07-07 16:32:04 +03:00
Amit Feller
15680c5e69 OpenGL renderer: handling subwindow messages
On windows we need to have a thread on the renderer process
which handles windows messages sent to the subwindow
we are creating during framebuffer initialization.
We run this message pump in the main renderer thread
and the server listener on a seperate thread.
2011-07-03 15:40:52 +03:00
Guy Zadickario
b68a421908 opengl renderer: Enable and fix renderer Mac support
The following enables the renderer build on darwin.
Moved platform specific type declarations from render_api.h
to render_api_platform_types.h so it can be included from the
objective c code.
Fixed subwindow to use EmuGLView which overrides NSView to prevent
background drawing of the view.
2011-07-03 15:40:52 +03:00
Stas Gurtovoy
440eb6e594 opengles host: some order in host gl debugging
Removed some debug prints in translator.
Added (remarked) options to enable gl debugging in decodes/renderer
2011-07-03 15:28:01 +03:00
Stas Gurtovoy
170eb97393 opengles renderer: added CHECK_GL_ERROR defie for gl debugging
This commit add CHECK_GL_ERROR define to decoders/renderer which enables various
glGetError() calls. Also changed emugen to add glGetError() after every dispatch call (based on
defintion of CHECK_GL_ERROR). Also cleaned some annoying printf's.
2011-07-03 15:21:48 +03:00
Amit Feller
1d3f5f58ce opengl renderer: create rendering subwindow
The application provides the window handle to which the
OpenglRenderer should render to however only a sub-region of
this window needs to be rendered. This change adds this functionality
by creating a native child subwindow into which rendering will happen.
2011-07-03 15:14:59 +03:00
Amit Feller
87363ca283 opengl translator: Fix windows runtime problems
fixed functions calling conventions in dispatch tables,
added link flag to translator libraries to produce an alias
function for all exported functions with stdcall name mangling.

Change-Id: I4360f26da1f897764ba6d4dd02c365ed00420b51
2011-06-30 09:14:16 +03:00
Amit Feller
a20ba0e4de Setting Renderer default libs to use translator libs
Change-Id: I853a30ce1aa7325d01a30b30c18f4e0bd5a5702f
2011-06-30 09:14:16 +03:00
Amit Feller
efcbbc3f28 emulator opengl: fix windows build
Change-Id: I145c7bf3a664fdb2c9e113cd977b4b2431d0668d
2011-06-30 09:14:16 +03:00
Stas Gurtovoy
62d074d9f8 emulator opengl: add GLESv2 support to driver + renderer
Added GLESv2 library to system.
Made fixes to the host libOpenGLRender to
compile and support GLESv2 (defined WITH_GLES2).
Other fixes required to make GLESv2 to work.

Change-Id: I9eb198e6092e7fa3550342c50929dd1714282cb3
2011-06-30 09:14:12 +03:00
Guy Zadikario
0536060b40 emulator opengl: guest/host rendering syncronization.
Added a return value for rcFlushWindowColorBuffer and
rcUpdateColorBuffer in order to make those calls to block
with a round-trip to the host. This is to make sure that
the color buffer is up-to-date before the flinger use it
for rendering.
Also added a call to the native windows's lock function after
EGL is attached and bound to render on the window. This call
was missed before.

This syncronization can be optimized by removing the round-trip
and insert sync primitive to the stream at every draw command that
reads from a color buffer to make the sync happen on the host
before rendering the color buffer and remove the need for the
guest to wait for that update.

Change-Id: I1c2d8bc407b69663e992a68d5aa755f19bbe0ec3
2011-06-25 16:56:08 +03:00
Guy Zadikario
4ef1f3474e emulator opengl: initialize new colorbuffers
Initialize new allocated color buffers with zeros.

Change-Id: I64a63c2eda83fdec1926c387e171324fb07ebe83
2011-06-25 16:56:08 +03:00
Stas Gurtovoy
fdcba322fe opengles emulator: Fixed upside-down gl image
This fix performs a flip software copy to match our coords with those expected by the flinger.
We may think of a better implementation in the future.

Change-Id: Ic09a5d0e22f7e209b33c07c993a3d56e328dd3ed
2011-06-25 16:28:58 +03:00
David 'Digit' Turner
8422a11a21 emulator: opengl: Update/simplify build scripts
This patch is a major rework of the build opengl-emulation
build scripts. See README for details.

In a nutshell, this introduces various functions that considerably
simplify the declaration of the 26+ modules in this implementation,
by handling auto-generation of sources and module imports/exports.

Change-Id: I827522d783c7b6cf5eafd37204a1025c235458cd
2011-06-23 00:35:54 +02:00
Stas Gurtovoy
5960b2717c emulator opengl: Added support for config_size 0 to FBConfig::chooseConfig
Fixed a bug in FBConfig::chooseConfig implementation

Change-Id: I4b8e98f43825c012f13d0a0684fe8f918e511400
2011-06-21 20:47:43 +02:00
Guy Zadikario
1ef706f96f emulator opengl: implement glGetString
Added rcGetGLString token to renderControl to query
a GL string constant from the current context from the host.
Implement glGetString functinality in EGL so that the string
value can be cached in the context structure and also
implementation can be shared between GLESv1 and GLESv2.

Also, fixed clientAPI context initialization check in
eglMakeCurrent. The check was for the previously bounded
context instead for the newly bounded context.

Change-Id: I41c0b4ad462c9ad5bd5c66719b41509bb1b7a947
2011-06-21 20:47:43 +02:00
Guy Zadikario
a2ec7339da emulator opengl: use eglGetProcAddress in EGL dispatch.
Initialize EGL extensions functions in the EGLDispatch
table using eglGetProcAddress instead of dlsym.
(try dlsym if eglGetProcAddress failed).

Change-Id: I256c4c5f9f3728a5b0e4d5bbcc75b83aa8a85f29
2011-06-21 14:48:44 +03:00
Guy Zadikario
f0dce80492 opengl renderer: Fixed colorBuffer texture creation.
The created texture format which represents the color buffer must
be of type GL_RGB or GL_RGBA also for the 565/5551 surface formats.

Change-Id: I7799a4824a0a5b8d57e3bfc507cac5664340725e
2011-06-21 14:48:44 +03:00
Stas Gurtovoy
613025efb3 emulator opengl: pool of fixups to the host side.
Those are the host side fixups required for the system to load
without failure to the point of bootanimation is run.

Change-Id: I42eebb123b05aaf6a0671e91e77a4ba6b330b852
2011-06-21 14:48:44 +03:00
Stas Gurtovoy
2220d27302 emulator opengl: added Bind texture to EGLImage/surface
added functionality to bind an EGLImage to a texture both
in the system and host sides.

Change-Id: I2dc26090b45da080ac4d0e8f5799c95f7cc54634
2011-06-21 01:41:50 +03:00
Stas Gurtovoy
a7b7e95b03 emulator opengl: implement eglChooseConfig functionality.
Added new RenderControl command to request the host to execute
the ChooseConfig functionality.

Change-Id: Ib92be313a6df740de69d671c6994ec6cae17ea13
2011-06-11 00:16:21 +03:00
David Turner
eff952cdbf Really fix the Mac build.
Damned!

Change-Id: Ice8295fb23beefe328207112b011489276b5b278
2011-04-16 22:21:57 +02:00
Guy Zadikario
1f0d3939ed emulatgor opengl: First commit of the host renderer library.
This is a library which includes all the OpenGL renderer functionality,
it is packaged in a library so that both the renderer process and the emulator
program will be able to use that functionality.

NOTES:
   1) gl_proc.h and GLDispatch.{h,cpp} in this commit will be replaced
      with the decoder auto-generated dispatch in a later commit, the
      auto-generated dispatch is currently missing some extension functions
      required for the renderer.
   2) look at host/include/libOpenglRender/render_api.h for the external
      interface defined for this library (to be used by the emulator).

The following is a description of each component:

FrameBuffer - The main object which manages the framebuffer and color buffers.
              This is a singleton which get initialized through its initialize
              static function. It initializes the OpenGL renderer and must be
              called first. This initialization function is not thread safe so
              it must be called before any thread that is calling to this
              library is created.

FBConfig - Includes a static set of configs supported by the renderer which get
           initialized during FrameBuffer initialization phase. Also,
           an instance of this class includes the a description of one frame
           buffer configuration supported by the renderer.

RenderContext - encapsulate a rendering context state.

ColorBuffer - implements a color buffer object as a texture which can be bind
              as render target or source.

WindowSurface - implements the functionality of a native window which can be
                bound to a rendering context and its target ColorBuffer can
                be specified and replaced.

ThreadInfo - holds per-thread information.

EGLDispatch - loads the EGL plugin library, all egl calls are made through
              this dispatch table which get initialized during initialization
              phase.

GLDispatch - loads the GLES plugin library, all GLES calls are made through
             this dispatch table which get initialized during initialization
             phase - This will be replaced by the auto-generated code of the
             decoder ...

RenderThread - implements a thread that reads command tokens from an IOStream
               and decode it.

RenderControl - implements the host side implementation of the renderControl
                API, when a renderControl token is decoded from the stream
                it is dispatched to this implementation.

RenderServer - implements a TCP server which listens to port number and
               launcges a RenderThread for each new connection.

Change-Id: I9f34d17bdfcb715893a13cd30086c767f499df87
2011-04-16 10:45:39 +03:00