Commit Graph

188 Commits

Author SHA1 Message Date
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
Yochai Shefi Simchon
29994cba1a opengles emulator: make glFramebufferTexture2D work
The GLES and OpenGL specs for glFramebufferTexture2D are different, which
caused valid GLES calls to fail when moved over to OpenGL. Specifically,
a framebuffer in OpenGL must have a color attachment in order to be valid
for draw, while in GLES it doesn't. So add a validate function, and call
it from each drawing API call.
This patch also contains a workaround for a bug in the ATI driver, where
changing the framebuffer attachments requires a rebind of the framebuffer.

Change-Id: I011fbe0e2b1c66564322268868a24a9d5958a434
2011-08-10 10:43:25 +02:00
Yochai Shefi Simchon
aac306dfbb opengles emulator: Separate FramebufferData to header and source files
Change-Id: I5baefa87fb086d6250c29fa55e58ad129bc8f02a
2011-08-10 10:43:25 +02:00
Yochai Shefi Simchon
14d40b879d opengles emulator: GLESv2: glGetShaderPrecision
to overcome a bug in intel driver which returnes incorrect precision
and range for integers. query the driver for precision format only
for floats. for integers, we return values defined in gles spec.

Change-Id: Idfec2826d811220873c18f301cf4268fc54dabee
2011-08-10 10:41:20 +02:00
Yochai Shefi Simchon
142ed5bf31 opengles emulator: fix initialization of vertex attribute
fix the default values of vertex attrib array to match gles spec
size should be initialized to 4, and type should be initialized to GL_FLOAT

Change-Id: If23b3aec574ca660181be2ef1c91de1de2b07a70
2011-08-10 10:41:20 +02:00
Yochai Shefi Simchon
aaac179eb5 opengles emulator: object name manager name generation
genName in the globalNameSpace now calls the glGen* function of opengl
to generate a global name instead of inventing one.
this is to overcome a bug in intel driver which raises glError when
binding a framebuffer/renderbuffer with a name that was not generated
by opengl.

Change-Id: Ia0c2fefbf3538c185c380ba62d74eb94f2b28254
2011-08-10 10:41:20 +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
Stas Gurtovoy
af8fb702d5 opengles emulator: fix bug in glTranslatex
We need to convert the fixed values to floats before we call glTranslatef

Change-Id: If164a8f67b32177e7229f4c5c2f6eff99680d685
2011-08-10 10:13:38 +02:00
Stas Gurtovoy
42b6b44939 opengles emulator: fix printf's
On guest we use LOGD and on host fprintf to stderr.

Change-Id: I1f419ef3e5af5358f0dc8368d246254393acb674
2011-08-10 10:13:38 +02:00
Stas Gurtovoy
0957f4acda opengles emulator: fix a bug in RangeList
When an intersection is found, we want to add it to the output list, if splitting is needed and if not.

Change-Id: I9c9827b1c0ecd434925ff5698dd42bc1025dbedf
2011-08-10 10:11:13 +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
d2fae7055e opengles emulator: libEGL fixes for ATI driver on windows.
Removed calling into opengl/wgl from the initialiation code
of libEGL (was made during creation for the EglGlobalInfo object
during global variable initialization) !
That causes issues on ATI driver on windows since we might call into
the driver before it gets initialized. Instead we initialie the EglGlobalInfo
during the first call into libEGL.

Also ATI's version of wglChoosePixelFormatARB does not accept
NULL in the attribute list arguments.

Change-Id: I508263dc0440561ee1cd1311ed5ce37cee4d407e
2011-08-10 10:08:05 +02:00
Yochai Shefi Simchon
a22010c0f4 opengles emulator: limit X11 configs some more
On Linux/Intel, some configurations are returned which make no sense.
Also, no use for single buffer config, and we don't support pixmap
visuals.

Change-Id: I11f37c8ba612ee10dd654141e6f167add1675dce
2011-08-10 10:08:05 +02:00
Guy Zadickario
e2dfd84f1f opengles emulator: remove compilation warning.
There was very few compilation warning on Windows and Linux.
This change just fixes those warnings.

Change-Id: I0428aa3dd33b2add40aa6cd12da76910950533b8
2011-08-10 10:03:07 +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
Guy Zadickario
ee2388cb94 opengles emulator: forced GLSL version to be 120.
GLSL ES 1.0.17 spec states that its written against
OpenGL GLSL version 1.2, that means that #version 100
in GLSL ES should be mapped to #version 120 in OpenGL
GLSL.
We now force "$version 120" in all shaders except if
higher version has been requested in the shader source
or when GOOGLE_GLES_FORCE_GLSL_VERSION is defines.
(Note that GOOGLE_GLES_DEFAULT_GLSL_VERSION is renamed
 to GOOGLE_GLES_FORCE_GLSL_VERSION).

That fixes "Aqua Slash GL Demo" application !!

Change-Id: I0f61ba3aa1c5591df3dacd3afd7f216dba13b56e
2011-08-09 17:38:48 +02:00
Liran
e1a6d10a54 opengles emulator: GLES2 codec - glFinishRoundTrip
fix glFinishRoundTrip
the function was not implemented on the host side,
calling glFinish caused segfault

Change-Id: Ic3a726d22a499f6560d905d177dcb7f997397628
2011-08-09 17:38:48 +02:00
Guy Zadickario
6d0f92b88d opengles emulator: support glEGLImageTargetRenderbufferStorageOES
That adds support to create a renderbuffer storage from an EGL
image (previously only texture was supported).
For that we have added Renderbuffer and Framebuffer attachment points
state tracking and when a renderbuffer which attached to an EGLImage
get attached to a framebuffer we attach the underlying EGLImage's
texture instead.

Also fixed some egl_image related bugs.
That makes the egl_image conformance test to pass on host.

Change-Id: I4e8c4935e45b27214038ecf1c1187ed96c5cea5b
2011-08-09 17:38:48 +02:00
Stas Gurtovoy
9254c7adc1 opengles emulator: fix bugs in CUBE_MAP implementation in GLES_CM
We save the texData->target in original format, but use our internal format
(using GLTextureTargetToLocal) to make sure we're not mixing 2D and CUBE_MAP textures on
glBindTexture.
Also added the GL_S/R/T/Q constants where needed.
This fixes the Cube Map test in Api Demos.

Change-Id: Id5de45581f2227fe0978d7982a147cb6b4b595c4
2011-08-09 17:36:35 +02:00
Yochai Shefi Simchon
65f8c50cbb opengles emulator: add GL_OES_depth_texture extension
Change-Id: I4f254be743b61ba00ebf58d136aa91f4eaf8b643
2011-08-09 17:33:04 +02:00
Yochai Shefi Simchon
c8dfd865fc opengles emulator: fix GL_EXT_packed_depth_stencil string
It used to be a GL_NV_packed_depth_stencil string extension, but
now it's GL_EXT_packed_depth_stencil and implemented by everyone. on
nVidia drivers both are exported.

Change-Id: I1b4af8a776f9957838d466b24fe73fa873ea85e4
2011-08-09 17:33:04 +02:00
Yochai Shefi Simchon
70d6f3e2b9 opengles emulator: 2.0: handle texture=0 on glFramebufferTexture2D
texture=0 has a special meaning - detach texture. Therefore we should pass
it on as 0 rather than look for the global name in the name space.

Change-Id: If7d0174a7fd07fc13a75430312b605497653f01b
2011-08-09 17:33:04 +02:00
Yochai Shefi Simchon
a182a1a7e4 opengles emulator: limit GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
A bug in the ATI OpenGL driver causes glGet(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
to return 32, although the driver supports only 16. The minimum required
by the spec is 2, so limit the number to 16.

Change-Id: Ife99dc5544f80ad872362414e9a5d9d2722d8a42
2011-08-09 17:33:03 +02:00
Liran
833ce70718 opengles emulator: Call XInitThreads on Linux.
All the X calls we do on linux are made from the FrameBuffer
object which is locked however OpenGL implementations may call
to Xlib during gl function calls. In order to be thread safe
we initialize Xlib to support multi-threading.

Change-Id: I3bc6a6378d7558fec44052bd67388beaf270c107
2011-08-09 17:29:17 +02:00
Guy Zadickario
fb1868addc opengles emulator: fix eglGetProcAddress
eglGetProcAddress should return a function pointer that does not
depends on the current bounded context (if any), when the user
calls one of the function pointers returned from eglGetProcAddress
for one of the GLES extension functions, the GLESv1 or GLESv2
version of the extension function shold be called depending on
the current bounded context.

For this we have added a ClientAPI (GLES) extension dispatch
table in the EGL level which points to static functions in libEGL
where each function checks in runtime the current bound context and
calls down to the GLES_CM -or- GLESv2 library function.
See ClientAPIExts.cpp, when new GLES extension functions are added
to GLESv1 or GLESv2 its definition should be added to
ClientAPIExts.in as well.

This fixes the segfault in egl_image conformance test.

Change-Id: I8464d87c2fcbe57d67bd8b891b695a690dec89f3
2011-08-09 17:14:20 +02:00
Guy Zadickario
d8b376d76d opengles emulator: fixed EGLContext and EGLSurface ref-counting.
Handle EGL context and surfaces destrouction using ref counting
pointer (SmartPtr) rather then maintaining a "markForDeletion" flag.
This has required to re-arrange the ThreadInfo structure to be local
to EGL rather then in the GLcommon area so that we will be able to
place a ref-counted pointer to the current context in the TLS.

That fixes the crash during exit of covgl conformance test.

Change-Id: I6f0a2e49c6f21eb75b654cab4346c764715c449b
2011-08-09 17:14:20 +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
Amit Feller
25b3794419 2.0 translator: link only if both shaders compile
A program should be linked only if both vertex and fragment shaders
compiled succesfully.
Change-Id: I9793da85847fd606883e1e3bef05485ce6037c21
2011-08-04 16:10:12 +02:00
Guy Zadickario
e8c7a055f7 opengl translator: Added GLSL ES builtin constants.
Adds GLSL built in constants defined in GLSL ES but not in GLSL.
Makes biConstant conformance test to pass on Mac (where ES2_compatability is not
present).

Also fixed the GLSL parser to insert our additions to the shader
only after the "#version" token if exist in the original shader.
Also renamed env var GOOGLE_GLES_FORCE_GLSL_VERSION to
GOOGLE_GLES_DEFAULT_GLSL_VERSION to better match its functionality since
we use it only if no specific version exist in the shader code.

Change-Id: If9485da16da2808245943a7295f8fb22a6f631aa
2011-08-04 12:01:49 +02:00
Yochai Shefi Simchon
7e04a2421c 1.1 translator: WAR for GL_ALPHA_TEST_REF bug
Both the ATI and nVidia OpenGL drivers return the wrong answer on
glGetIntegerv(GL_ALPHA_TEST_REF). So Implement this functionality
in our code.

Change-Id: I022b1475f7edb9f1d0f48ebcaf9f6e9f5c4f344e
2011-08-04 12:01:49 +02:00
Yochai Shefi Simchon
926db88dd1 1.1 translator: glGet(GL_MAX_CLIP_PLANES) returns max 6
This is a WAR for an ATI OpenGL driver bug.

Change-Id: I0b54317873ed8c60fe835a993c2c8f32321ff8e2
2011-08-04 12:01:49 +02:00
Liran
ceb7fc9140 remove NV_WAR defines
enable workarounds by default
added environemnt variable GOOGLE_GLSL_FORCE_GLES_VERSION
to the shader parser

Change-Id: If1dbc10722436659295c40a40bd630a72e575799
2011-08-04 12:01:49 +02:00
Liran
772468f2b6 GLES2 translator: workaround for nvidia bug with GL_VALIDATE_STAUS
nvidia may return GL_VALIDATE_STATUS = GL_TRUE even when the program does not link
this change checks for GL_LINK_STATUS when GL_VALIDATE_STATUS is queried

Change-Id: Ia9f5da9c71b8666ce929d8cc2a44639bc947eecb
2011-07-27 15:19:11 +03:00
Liran
715c4898df 2.0 translator: workaround for nVidia "bug"
This is not really a bug, but the nVidia shader compiler is much more
liberal than the GLSL spec, and allows compilation of shaders which
do not comply with the spec. This is an issue for passing the
conformance tests, but more importantly it will allow bad shader written
by the app developer to pass on the emulator and then to fail on the device.

Adding "#version 100" definition to the head of a shader source disables
this liberal behavior. For now this is activated in run time by the "NV_WAR"
environment variable.

Change-Id: I1c322d4221d313d3ee70592bc15ea0e340853990
2011-07-27 15:19:11 +03:00
Liran
dd954c869c GLES2 translator: host does not support RGB565
When calling RenderbufferStorage with internalformat=GL_RGB565
we will create one with internal format GL_RGB
the same for glTexImage2D

Change-Id: I1e464dd36142f586beef6bf895456c7aab1b8237
2011-07-27 15:19:11 +03:00
Liran
31b99df283 GLES translator - enable binding to multiple texture targets
support different binding to GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP
targets

create 2 default texture object, to be bound when BindTexture( ... ,0)
is called.
in order to do this, we must ensure their names are internal only, so the user can't
use these names by accident.
the object name manager local name is now 64 bit to allow generation of internal names

Change-Id: I29d000a67042051706e13dc3ef3aa34a1a24f8ca
2011-07-27 15:19:10 +03:00
Liran
3c457bda2f GLES2 translaotr: fix glLinkProgram and object names
Do not allow glLinkProgram to succeed if only one shader type has been
attached to the program, GL allows this, but GLES2 does not.
added state tracking for program objects to check which shaders are
attached to the program object.

add a way to define object data type being held for each object in objectNameManager
ProgramData and ShaderParser are both valid objectData for objects in SHADER namespace
we need a way to determine object type to generate correct errors

Change-Id: Ic232549df0bb6daf6ec528cb039482cd68e896bb
2011-07-27 15:19:04 +03:00
Stas Gurtovoy
99ef052675 use Translator's glTexImage2D in doCompressedTexImage2D
Instead of calling the dispatcher directly. This will make sure all Translator's
internals (such as TextureData data) are updated properly.
This also fixes the bug in "Replica Island" - when the green robot was invisible,
because it's TextureData wasn't updated by doCompressedTexImage2D

The pointer to glTexImage2D is passed as a parameter to doCompressedTexImage2D,
otherwise Windows resolve the glTexImage2D symbol in the external libGL rather
than the translator's code. Longer term, we will remove the translator's link
to libGL, at which point this parameter will be removed.
2011-07-14 13:42:13 +03:00
Yochai Shefi Simchon
31bf4fac95 2.0 Translator:GL_INVALID_VALUE on bad program/shader
The getGlobalName function returns 0 on error. There are many places
were no error checking is done after calling it to get a shader or
program name. Typically this shouldn't be an issue, since the follwing
OpenGL call using a value of 0 will generated the required GL_INVALID_VALUE,
but this does not always happen.

Change-Id: I8edf2b152978ffd8626f8b4d778cc624f2a3bec3
2011-07-14 03:05:38 +02:00
Stas Gurtovoy
76007c3b0e Fix parameter parsing in renderer
Change-Id: I14533cea4a29eff2b3dec3a68e80fc1ae7f44da3
2011-07-14 03:05:38 +02:00
Stas Gurtovoy
0dad64d939 opengles Translator: DrawTex impl - don't draw if no textures enabled.
This fixes a crash caused by covgl (on Nvidia linux driver) when our implementation
of glDrawTexOES calls glDrawArrays with GL_TEXTURE_COORD_ARRAY enabled - but none of texture
units are enabled and no data passed by glTexCoordPointer

Change-Id: Id28b0c35a5a17b139ab196db0e434d2f0a490132
2011-07-14 03:05:38 +02:00
Yochai Shefi Simchon
79b1bad09a 2.0 translator: support ARB_ES2_compatibility stuff
The ARB_ES2_compatibility extension supports several GLES 2.0 enums
and functions on OpenGL 2.0. Seems it exists on nVidia drivers, but
not on ATI's. So implement its functionality in case it doesn't
exist on the host.

Change-Id: Id96f0c8036a7a7d36fca0c85ab5f57bf4b1583aa
2011-07-14 03:05:38 +02:00
Amit Feller
1d8465c245 translator EGL:fixing bug in eglGetDisplay caused in Windows Platform
in Windows platform we previously defined EGLNativeDisplaytype to be WinDisplay*
( this was defined in include/EGL/eglplatform.h) this was OK as long as we used the
the EGL_DEFAULT_DISPLAY as parameter for eglGetDisplay meaning we were generating
a native display by oureselv and wrapping it, but there was aproblem when we got the
EGLNativeDisplayType from the user (as HDC in Windows) but interpret it as WinDisplay*
this caused a big memory corupption.
so to overcome this problem we now define two types EGLNativeDisplayType to be
HDC and EGLNativeInternalDisplayTypeto be WinDisplay*, and when we get in eglGetDisplay
a parameter different from EGL_DEFAULT_DISPLAY we wrap it with the struct of WinDisplay
and return it to the user.

this change caused a change in all the declerations of EglOsApi.h changing
EGLNativeDisplayType -> EGLNativeInternalDisplayType

Change-Id: I3522c3d507b084c5c211e10ddb6f512d1b90c65e
2011-07-14 03:05:38 +02:00
Stas Gurtovoy
1d9dc99abb opengles Translator: get Compressed texture handling out from GLEScontext
This commit does few things:
1. Gets doCompressedTexImage2D out of the context and TextureUtils
2. Gets palette textures out of TextureUtils and into PaletteTexture
3. Makes TextureUtils generic for all compressed textures
4. Moves the glGet's dealing with compressed textures from GLEScontext to the impl.

Change-Id: Ibbde6968810a66a4f3488f3887ee3f015fc32c11
2011-07-14 03:05:38 +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
Liran
5dd421c56b GLESv2 Translator: fix glGet*
Override glGet* for parameters that request information that have local namespace
convert global names to local names before returning the value

Change-Id: Ie334419b6a5ffe4904d8efe0827a30beaf8b2f6c
2011-07-12 00:46:06 +02:00
David Turner
c559f7612f Merge "GLES2 translator: fix glUseProgram error" 2011-07-11 15:43:40 -07:00