summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-08-23Move glRenderbufferStorageMultisample to gles_common.entriesYahan Zhou
glRenderbufferStorageMultisample is used by both GLES1 and GLES2. Move it from gles3_only.entries to gles_common.entries. BUG: 64951203 Change-Id: Ifa422eb4336ba1733a697351710ac147e196d254
2018-08-23[gl] ES version from underlying GLES or core profile GL versionLingfeng Yang
bug: 64131077 - Use context creation trials to determine max GLES version - Use feature control for compatibility and to prevent making guests that don't support ES3 run ES3. - Edit the version string to match, too. - remove dlsym based dispatch - filter extensions based on known working set of ES2 extensions if in ES2 mode Change-Id: I02c36cb9bcddb0ebba82c98a5ab631bbfe15162e
2018-08-23[gl][snapshot] Use LazyLoadedEGLDispatchLingfeng Yang
Instead of duplicating the functionality of it. +fix build break on Mac due to non-void function with blank return Change-Id: If3159c23a4957f7cd3418ad1f435d06b7d019bdb
2018-08-23[egl] Use eglGetProcAddress as fallback for missing functionsLingfeng Yang
bug: 63908229 Change-Id: I69b832198ae6dd5d58cee842bafa6e3dc5a74fa1
2018-08-23[ANGLE Snapshot] GLES2 translator on top of ANGLEYahan Zhou
This patch modifies our GLES2 translator to allow it to mount on top of ANGLE. Because ANGLE is a GLES2 backend while previously our translator assumes desktop GL backend, some modifications are required. The main changes in this patch include: (1) Pass a flag to GLES translator to tell if it is running on top of another GLES backend (2) Desktop GL sometimes assume EXT postfix for some functions while GLES does not. Modify dispatcher so that it loads func as well funcEXT and funcOES as alias. (3) ANGLE does not like GL_RGB8 and GL_RGBA8 texture internal formats. Change them to GL_RGB and GL_RGBA. (4) Bypass some texture parameter validations when using ANGLE backend. (5) Ignore the parsed shader and use orignal shader source when using ANGLE backend. Change-Id: I6c5a770a0157c020920a432f3c949e2f8d67e0eb
2018-08-23[gl] Fix 'inout' variable qualification + complex readbackLingfeng Yang
- Can use variables with both input and output qualities - Allow readback of complex structures. 3 phases: - host_pack_tmp_alloc: custom expression to allocate aligned temporaries for the output structs - host_pack: custom expression to pack into stream (losing alignment) - guest_unpack: custom expression to unpack into object on guest (regaining alignment) Change-Id: I9073325efe6847762e8b2d42fd9803d81ff67374
2018-08-23Fix a series of compiler warningsErwin Jansen
- Fix a set of warnings from the mac build - Deleted unused variables - Marked methods as override Change-Id: I614f0a444b83de6ec978afc017cfb53d9ceafd62
2018-08-23[gl] Allow custom unpack in decoderLingfeng Yang
Encoder has custom pack, why not custom unpack as well? Change-Id: I955e0967dad6ee6e1c46bda51774463b67774744
2018-08-23[snapshot] Save if IOStream has |m_buf| setYurii Zubrytskyi
IOStream uses |m_buf| as a buffer pointer and as a flag at the same time: if it's not set then there's no need to flush. Previous snapshotting code didn't save this bit of information, so next time one tried to allocate a buffer from a just loaded empty IOStream, it thought it's not empty (as |m_buf| was not nullptr) and tried to flush garbage. This CL saves this separately, so now |m_buf| after snapshot loading is exactly in the same state as it was before. Bug=b/36700704 Change-Id: I7af309bb1d3c16ba20969f7bb3f9bfc067d0051d
2018-08-23unconditionally extern "C", update guest encoderLingfeng Yang
Change-Id: Ia1cc789acd1ec4d00b83950e0125de4e7957d097
2018-08-23Fix running with anything other than lib64GLES_V2_translatorLingfeng Yang
Change-Id: Id145c7fda144dcca34d9d61c1d6e465edc862535
2018-08-23[GPU snapshot] Snapshot translator GLES2 contextYahan Zhou
This patch snapshot the translator GLES2 context as it is. Namespaces and GL objects will be in another patch. Hardware GPU restore will be in another patch. Change-Id: I12cd6d0b7174414bce0bd9143fcdf21786f12ba4
2018-08-23Remove a bad assert() in IOStream dtorYurii Zubrytskyi
The assert was ok for the regular case, but it would fail if the guest closed the pipe in the middle of processing because of some logic error Change-Id: I9d69f8ea6d9cb0e0cca3b1607fa49b7876be6b14
2018-08-23ChecksumCalculator serializationYurii Zubrytskyi
Change-Id: Id135b7e226c0664c3bc2261f0f6b5ab28cb580c6
2018-08-23[GPU snapshot] Framebuffer and contexts snapshotYahan Zhou
This patch snapshot FrameBuffer and RenderContexts. With this patch, after from a GPU snapshot, the emulator should not crash but it will complain about invalid window surface handle. Next step: snapshot window surfaces TODO: call eglMakeCurrent after loading refactor objectNameManager so that shared groups are indexed by ID better interface for EglContext::onLoad clean up the code Change-Id: I7aa740f215f96c054634f08d5862bbc9534728c1
2018-08-23IOStream and ChannelStream serialization functionsYurii Zubrytskyi
- IOStream serializes its internal state first, then calls derived class' implementation. - ChannelStream just saves/loads internal buffers Change-Id: Iccb7302c9cfe1f0f5d2c592376d5498d1b586266
2018-08-23GL state snapshot - initial structureLingfeng Yang
- sit between udnerlying es driver and guest - work with any es backend (angle, swiftshader, etc) - snapshot clear color as a smoke test TODO - plug into rest of snapshot - snapshot minimum set of GL state necessary to get to home screen Change-Id: Idf2eb9822d62f9308275ff2df8d12f4402e085c3
2018-08-23[WIP] glesv31 hostside changesLingfeng Yang
Change-Id: I2710d1685e19071cdadf0d5eeb1f29fae6f68e9a
2018-08-23[test] OpenGL unit testsLingfeng Yang
This CL moves MyEGL/GLESv2/Dispatch into a more general location---emugl_common---allowing us to dispatch underlying GLESv2/EGL libs from other places in the emulator than qt gl widget, and introduces code for OpenGL unit tests, along with a basic context creation unit tests. We can now do offscreen-rendering type unit tests with OpenGL. This is very helpful for debugging host-side OpenGL issues, rather than going through X11 / WGL from the ground up to repro OpenGL cases. This should also be useful for testing snapshots. Usage: qemu dir -> cwd DYLD_LIBRARY_PATH (or platform equivalent)=objs/lib64 objs/lib64OpenglRender_unittests --gtest_also_run_disabled_tests should run at least basic context creation and dispatch. Change-Id: If89966156bb4978a302fd94a96d77e5ce1552c03
2018-08-23[GLESv3] fix build on older imagesLingfeng Yang
Change-Id: Ibef7263f881c55d9f79c0881bfa24c1f0c46eebf
2018-08-23[GLESv3] ES 3.x API implementation v1Lingfeng Yang
- ES 3.0 almost conformant (~80 failing tests not having to do w/ compressed texture support) - ES 3.1 has a first cut, still lots TODO Change-Id: I3aaafa6f42aba5ba7b1937556529b746d54cfb95
2018-08-23[GLESv3] dispatch, (en|de)coder, feature controlLingfeng Yang
This is an initial pass at GLES 3.x encoding. Some GLES 3.x functions like mapped buffers need tricky handling. See gles2.in for documentation of current encoder design and scoping of 3.x features and issues. Features: - Dynamic version detection of GLES 3.x support in both underlying GLESv2 lib (possibly SwiftShader or ANGLE) and the host OpenGL underneath the GLESv2 lib. Dynamic detection is put under feature control (currently off) to allow development while not breaking CTS. - Auto-generated translation of GLES 3.x functions to host OpenGL in android/scripts/gen-entries.py - Added all GLES 3.x buffer targets. - Enabled GLSL ES 300 -> GLSL compiler in ANGLE shader translator. Change-Id: Ib56ca6962466e6c21bfc45cdeb97ffa684c873c6
2018-08-23[getopt] Fixed our own implementation of getopt()Yurii Zubrytskyi
We have own code for getopt() that's not used now. But if we try compiling emugen on platform without native getopt(), e.g. Windows, we need to use ours. It had a bug where we were not advancing the |optind| variable if option's value was in the next |argv| item. This CL fixed it Change-Id: I4d1f4cf226f22817fdbba28a4fbc6f34ee78ea83
2018-08-23[build] Copy target CFLAGS into the host onesYurii Zubrytskyi
We use host CFLAGS to build emugen, and it was missing all flags one needs, including debug info and optimizations. This CL copies the flags we use for target build. + Fix build errors after enabling Werror Change-Id: I6be85210f3e9e447fb603e48dace074296b59d0e
2018-08-23[apigen] Fix the generated code for WITH_LARGE_SUPPORT=0Yurii Zubrytskyi
We've abandoned that mode for a while, but it is a good way to compare the performance of memcpy() buffers vs pass them through the pipe without copying Change-Id: I4a0b1b2332c93fd5484c8e82399e35686247a504
2018-08-23[video] Do YV12 conversion on the host with a shaderLingfeng Yang
Doing YV12 conversion in the guest makes gralloc unlock block for a very long time, which chokes MediaCodec. Doing YV12 conversion in shader, 1080p60 is achievable for short bursts, since the conversion is faster by over 10x (<3ms instead of ~30ms to convert a 1080p YV12 frame to RGB888). Still, at 1080p60, there are various stalls/hiccups... Change-Id: I031c4fd7b1260e89d9bc4398602ea1baea6f5e98
2018-08-23[video] goldfish_dma androidemu changesLingfeng Yang
This set of CLs instantiates the goldfish dma pipe extension's interface, and uses it to perform all color buffer updates, making video playback smoother. Change-Id: I543ba907fcc948d48d812146fa2e69a86cecb941
2018-08-23Move android-emugl from distrib/ to android/David 'Digit' Turner
Since this is no longer a side-project, move it under android/ where it logically belong. distrib/ should now only contains sources and build files related to third-party libraries used by the emulator. Change-Id: I012c2d8c875d018b0c97891773fa5e8e2811087e
2018-08-23emugl: Simplify RenderChannel interface.David 'Digit' Turner
This patch simplifies the RenderChannel interface and its implementation (a.k.a. RenderChannelImpl). This has several benefits: - The interface is now much closer to the one expected by an AndroidPipe instance, making EmuglPipe easier to implement (e.g. get rid of atomic variables in it). - RenderChannelImpl only uses a single lock instead of three, and doesn't use atomic variables anymore, thanks to the BufferQueue class. This makes the code a lot less confusing and removes risks of thread-racy behaviour due to the use of multiple locks and atomics at the same time. Performance wise, this seems to be comparable to the current implementation. The following numbers corresponds to the frames/s collected when running the Antutu3D 6.0 "Garden" benchmark, on an Android API level 23/x86 system image, 1920x1080 resultion, running on an HPz620 (32 cores at 2.7 GHz) with the "performance" scaling governor set on all CPUs: Official Current release Tip-of-tree With this patch 15.07 17.13 17.52 15.35 17.36 17.52 15.06 17.34 17.37 Change-Id: I1f0e998b23c38051c8de519a3cab3f6a961be930
2018-08-23emugl: Move IOStream.h to host/include/libOpenglRender/David 'Digit' Turner
There is no longer a reason to distinguish between include/libOpenglRender and include/OpenglRender/. Since the former only contains IOStream.h, move the header to include/libOpenglRender to get rid of one include directory during the build. Change-Id: I75b20025e79d25ed9dfb1c6e57c55566a5995c17
2018-08-23[GL] Minor optimizations and cleanupsYurii Zubrytskyi
- Make the IOStream's ctor and dtor protected - Remove unused virtual function in IOStream - writeFully() - Change ApiGen to privately inherit from std::vector<> (inheriting from vector is still bad, but I don't want too many unrelated changes in the CL) - Don't pass output parameter buffers from the guest to host in the GL protocol. We used to reserve memory for output buffers among the input parameters stream, and never actually read it on the host. Now we don't reserve it anymore (and don't pass it over!) - Add two conditional defines to ApiGen.cpp, INSTRUMENT_TIMING_{GUEST,HOST} When defined to 1, emugen generates timing printouts for each of the generated functions. Very useful for debugging. - Don't call eglMakeCurrent if the context we're making current is already one - Grab the thread-specific checksum calculator in the RenderThread's main function and pass it to decode() functions. This way we don't need to keep calling into TLS on every packet processing for several times to just get what we know is there and won't change 43 -> 44 fps in Antutu Change-Id: I9411cbd1758192b049f8f2e37b2d319e9f6a8593
2018-08-23SmallVector class for GLes pipe data transfersYurii Zubrytskyi
This CL adds a SmallVector class that allocates smaller data chunks on the stack, and falls back to heap memory for larger ones. For the ChannelBuffer class it makes the slow allocations almost disappear for my testing, only having them once in a couple minutes. SmallVector as of now only implements a tiny subset of vector<> interface, the one used in the code. Overall speedup is about 10% for Antutu benchmark, 15% for YouTube video player at 720p60Hz Change-Id: Ib64efe2ef7dac18263866069a5a5e67baec385cb
2018-08-23[gl] Slightly faster checksum calculationYurii Zubrytskyi
Checksum calculation is something we call on each gl command, so it has to be really fast. This CL gets rid of unneeded memcpy() calls, so it is slightly faster now Change-Id: Ib299580c167be1c94130a4fbda1e81fed88bf3a5
2018-08-23[gl] Update the emugen test data for the latest emugen changesYurii Zubrytskyi
Change-Id: I141d650302a7f0d984fd09b0be7bee09c0a9a65c
2018-08-23[emugen] Slightly better generated code for protocol decodersYurii Zubrytskyi
Change-Id: If9f45a5e0233c03fc1fbb02132e1375200d30121
2018-08-23[gl] Simpler implementation for Unpack() callYurii Zubrytskyi
+ fixed a wrong code for double, where it was read as 4-byte type Change-Id: I68785eae5234ced97cbb2890afcfeafaeb52f1ee
2018-08-23Refactor pre-process GL resource management (host)Yahan Zhou
Previously we bind a process unique id (puid) to the GL encoder / decoder commands when managing process owned GL resources. This patch simplify it by telling each rendering thread its puid at the beginning, and using that puid for resource management. It will make our life easier when we need to change other resources from owned-by-thread to owned-by-process (e.g. EglContext). This CL must work with guest CL: https://googleplex-android-review.git.corp.google.com/#/c/1472672/ Change-Id: I2d82f8b439d0fc2354989ac5a037e9b413fde5d4
2018-08-23goldfish_sync: properly clean up sync objectsLingfeng Yang
There can be issues that arise from sync objects not being destroyed properly, such as -gpu swiftshader leaking threads. This CL: - adds rcDestroySyncKHR to allow the guest to destroy EGL sync objects on the host. - adds a self-deleting FenceSync class that is expressly for wrapping underlying OpenGL sync operations and destroying sync objects at the proper time. - removes the FenceSyncInfo class; now all sync handles are passed as FenceSync objects. Now, no locks are needed when processing sync objects. - because changes in the system image and GL pipe protocol are also needed, it bumps the GLAsyncSwap extension string to "ANDROID_EMU_native_sync_v2", so that combinations of old/new emulator/system-image still work. If different version strings are detected, we fall back to disabling the sync feature. This scheme seems to have not broken CTS (so far), and fixes thread leakage while running -gpu swiftshader. Change-Id: If4bac1d8025731366bc090faf7ef837ca298fba8
2018-08-23goldfish_sync: more robust context creation/destructionLingfeng Yang
We are having problems with sync device running on things that are not z840 / K2200 at least, which could have to do with not cleaning up / creating sync device resources in a clean manner. This CL moves all sync device context creation/destruction logic to the same code paths as FrameBuffer's and RenderThread's; use createRenderContext / bindContext to create and set a context, and drainWindowSurface / drainRenderContext to tear it all down. It also adds glDeleteSync for -gpu host and calls eglDestroySyncKHR when a EGLSyncKHR object with ANDROID_NATIVE_FENCE nature is signaled, which helps to not leak sync objects (Overall, sync objects may still be leaking judging from -gpu swiftshader performance, but this is just a first step). Overall, this seems to fix intermittent (3-4 hr) segfaults and deadlocks (in the NVIDIA driver!) while running CTS on z420 / K600 workstations. Change-Id: Ie9ba252e1415f5c9e8e6c299076d581280256c3d
2018-08-23Add EGLImage clean up when guest process exitsYahan Zhou
This patch cleans up EGLImage when guest process exits. The implementation details are very similar to color buffer cleanup: https://android-review.googlesource.com/#/c/246823/ It associates each EGLImage with its process ID, and cleans them up when the process exits. This patch also renames GrallocPipe to GLProcessPipe. This is because the pipe is now used to release not only color buffers allocated by gralloc, but also EGLImages. It works with guest patch: https://googleplex-android-review.git.corp.google.com/#/c/1269309/ Tracking bug: https://buganizer.corp.google.com/issues/29457657 Change-Id: I3143b48e1b5dc5f57a4cb87c62e86eb11c1f534e
2018-08-23Add host-side EGL sync + GLESv3 supportLingfeng Yang
A "better solution" was alluded to in https://android-review.googlesource.com/#/c/221311/ A first step of which is to support host-side OpenGL sync commands glFenceSync and glClientWaitSync. One way to add them is to add GLESv3 types support and extend the GLESv2 implementation. This involves some changes to OpenGLESDispatch, and, for the emugl Translator backend, adding the functions to GLESv2Imp.cpp. We then include a trivial implementation of host-side eglCreateSyncKHR and eglClientWaitSyncKHR through wrapping these first two GLESv3 functions: glFenceSync and glClientWaitSync. Host Opengl 3.2+ is required. Note: I had thought that adding GLESv3 suggests a GLESv3Imp* and related set of things, but it seems popular (judging from ANGLE and Swiftshader) to combine the v2/v3 libraries in some way; if we use ANGLE as backend, for example, we will want to flip through ANGLE's libGLESv2.dll, there not being any libGLESv3.dll Note: This involves a change in the encoder. It should be backwards compatible among old + new versions of system images, though, as the actual use of the new renderControl functions does not happen unless the GLAsyncSwap feature is activated. This is part of a sequential, multi-CL change: external/qemu: https://android-review.googlesource.com/240119 https://android-review.googlesource.com/239442 https://android-review.googlesource.com/221593 <- this CL https://android-review.googlesource.com/248563 <- needs this https://android-review.googlesource.com/248564 <- needs this https://android-review.googlesource.com/223032 <- needs this external/qemu-android: https://android-review.googlesource.com/240155 https://android-review.googlesource.com/238790 kernel/goldfish: https://android-review.googlesource.com/232631 https://android-review.googlesource.com/238399 Change-Id: Iee6570709e70def813ff52a7745305e6fd0de58d
2018-08-23Fix Werrors in decoderLingfeng Yang
Change-Id: I9cf187c2cc8de168a470834cb3904e20dd555c05
2018-08-23Add flush to rcCloseColorBufferPuidYahan Zhou
It is needed to make sure all color buffers are closed correctly. Change-Id: Ib661f51a31c783edc5123e173bdfa81273be207a
2018-08-23[GLES1->2] Properly separate entry points / internal callsLingfeng Yang
Otherwise, gl*** calls in the GLESv1->2 translator that are internal calls might instead call completely different libraries, like system OpenGL. Change-Id: I89b7fd4461e5d6f50f82c2585638dc44bde2fa9f
2018-08-23[GLES1->2] Add GLES1->2 translation entry points and link themLingfeng Yang
...if the underlying backend does not support GLESv1 Change-Id: I19c077d2f26c6549bc3d0452314dc2c9ea23b24f
2018-08-23Add pre-process pipe for gralloc memory cleanupYahan Zhou
https://buganizer.corp.google.com/issues/29457657 This patch clean up color buffers allocated by gralloc when a guest process is killed. It did two things: (1) It creates a grallocPipe the first time gralloc registers any buffers in a host process. The pipe will be released when the process dies, which triggers a callback function to clean up its color buffers. (2) For color buffer create/open/close, add a new render control function, which passes the guest process id as an additional parameter. Then we keep track of which process is holding which color buffers. The guest processes are identified by generating a 64bit ID for each process from the host. It will need the guest side patch to work: https://googleplex-android-review.git.corp.google.com/#/c/1207896/ Change-Id: I8add9eb8f224cb32ffdfd309bf921c6921230a96
2018-08-23Make OpenGL logger thread safeLingfeng Yang
- our opengl command rate is now fast enough to raise STL exception when concurrently using push_back - also fix build error Change-Id: Ief7c2ffb09ea0e5fec300b1e1e3f2679bbd6ad02
2018-08-23Make generated encoder compatible with c++98Yahan Zhou
Make generated encoder compatible with c++98 for backporting GL changes. Change-Id: I03a5daff3f3766622637350f1264f26a2e5648b8
2018-08-23EGLDispatch.cpp: Remove compiler warning.David 'Digit' Turner
A function was returning NULL instead of false. Oh my :) Change-Id: I09ed8575add21fa850a9f7ec15208801be4c4f75
2018-08-23Fix gl encoder generatorYahan Zhou
This patch fix the gl encoder generator scripts. After the fix, the generated encoder should be almost the same as the current one in mnc. The only difference would be 3 flushes in glDraw*, which should be moved to non-generated code later. Change-Id: Ibdbfe6e5c259baae221a955d24fa76df4f2e03a3