Commit Graph

70 Commits

Author SHA1 Message Date
Adam Jackson d9f5b1915b egl: Rename MESA_configless_context bit to KHR_no_config_context
Keep the old name in the extension string, but refer to the KHR
extension internally.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-09-12 11:29:09 -04:00
Adam Jackson cc45a5c308 egl: QueryContext on a configless context returns zero
MESA_configless_context does not specify the interaction with
QueryContext at all, and the code to generate an error in this case
predates the Mesa extension. Since EGL_NO_CONFIG_{KHR,MESA} are
numerically identical there's no way to distinguish which one the
application asked for, so use the KHR behaviour.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-09-12 11:28:38 -04:00
Adam Jackson dbda375d6f egl: Fix up indentation on previous commit
This was requested in review but I pushed the wrong version.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-09-08 13:21:27 -04:00
Adam Jackson a279760536 egl: Document why EGL_OPENGL{, _ES}_API are mostly identical
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
2016-09-08 13:19:58 -04:00
Kyle Brenneman 6e066f76ee EGL: Combine the GL and GLES current contexts (v2)
Only keep track of a single current context, instead of separate
contexts for GL and GLES.

In EGL 1.4 (and 1.5), EGL_OPENGL_API and EGL_OPENGL_ES_API are supposed
to be interchangeable for all purposes except for eglCreateContext.

The _EGLThreadInfo::CurrentContexts array is now a single pointer to the
current context, which may be a GL or GLES context. In addition, it now
keeps track of the current API as an enum instead of an index.

eglMakeCurrent will now replace the current context, regardless of which
client API is used for for the current and new contexts. It no longer
checks for a conflicting context. In addition, calling eglMakeCurrent
with EGL_NO_CONTEXT will now release the current context regardless of
the current API.

v2: Rebased against master (Adam Jackson)

Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-09-07 11:56:48 -04:00
Matthew Waters 11cabc45b7 egl: rework handling EGL_CONTEXT_FLAGS
As of version 15 of the EGL_KHR_create_context spec, debug contexts
are allowed for ES contexts.  We should allow creation instead of
erroring.

While we're here provide a more comprehensive checking for the other two
flags - ROBUST_ACCESS_BIT_KHR and FORWARD_COMPATIBLE_BIT_KHR

v2 [Emil Velikov] Rebase. Minor tweak in commit message.

Cc: Boyan Ding <boyan.j.ding@gmail.com>
Cc: Chad Versace <chad.versace@intel.com>
Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91044
Signed-off-by: Matthew Waters <ystreet00@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-10-03 12:30:13 +01:00
Frank Binns d9603be038 egl: improve attribute checking for eglCreateContext
The EGL 1.4 spec states for eglCreateContext:

	"attribute EGL_CONTEXT_CLIENT_VERSION is only valid when the current
	 rendering API is EGL_OPENGL_ES_API"

Additionally, if the EGL_KHR_create_context EGL extension is supported
(this is mandatory in EGL 1.5) then the EGL_CONTEXT_MAJOR_VERSION_KHR,
which is an alias for EGL_CONTEXT_CLIENT_VERSION, and
EGL_CONTEXT_MINOR_VERSION_KHR attributes are also accepted by
eglCreateContext with the extension spec stating:

	"The values for attributes EGL_CONTEXT_MAJOR_VERSION_KHR and
	 EGL_CONTEXT_MINOR_VERSION_KHR specify the requested client API
	 version. They are only meaningful for OpenGL and OpenGL ES
	 contexts, and specifying them for other types of contexts will
	 generate an error."

Add the necessary checks against the extension and rendering APIs when
validating these attributes as part of eglCreateContext.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
[Emil Velikov: Add newline before the spec quote (Matt)]
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-08-13 17:36:06 +01:00
Marek Olšák 706466f461 egl: add context attribs from EGL 1.5
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2015-06-05 19:44:33 +02:00
Marek Olšák f9f894447e egl: fix setting context flags
Cc: 10.6 10.5 10.4 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2015-06-05 19:44:33 +02:00
Anuj Phogat d308f57fe7 egl: Fix OpenGL ES version checks in _eglParseContextAttribList()
We would generate EGL_BAD_CONFIG because _eglGetContextAPIBit
returns zero for the combination of EGL_OPENGL_ES_API and a major
version > 3.  By just returning zero, the caller can't tell the
difference between a bad version (which should generate
EGL_BAD_MATCH) and a bad API (which should generate
EGL_BAD_CONFIG).  This patch causes us to filter out major
versions > 3 at a point where we can generate the correct error.

Fixes gles3 Khronos CTS test:
egl_create_context.egl_create_context

V2: Fix commit message as suggested by Ian.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-08-04 18:31:26 -07:00
Neil Roberts 551d459af4 Add the EGL_MESA_configless_context extension
This extension provides a way for an application to render to multiple
surfaces with different buffer formats without having to use multiple
contexts. An EGLContext can be created without an EGLConfig by passing
EGL_NO_CONFIG_MESA. In that case there are no restrictions on the surfaces
that can be used with the context apart from that they must be using the same
EGLDisplay.

_mesa_initialze_context can now take a NULL gl_config which will mark the
context as ‘configless’. It will memset the visual to zero in that case.
Previously the i965 and i915 drivers were explicitly creating a zeroed visual
whenever 0 is passed for the EGLConfig. Mesa needs to be aware that the
context is configless because it affects the initial value to use for
glDrawBuffer. The first time the context is bound it will set the initial
value for configless contexts depending on whether the framebuffer used is
double-buffered.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-12 14:40:47 -07:00
Chia-I Wu dc97e54d97 Revert "egl: Unhide functionality in _eglInitContext()"
This reverts commit 1456ed85f0.
_eglInitResource can and is supposed to be called on subclass objects.

Acked-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
2014-02-19 13:08:52 +08:00
Juha-Pekka Heikkila 1456ed85f0 egl: Unhide functionality in _eglInitContext()
_eglInitResource() was used to memset entire _EGLContext by
writing more than size of pointed target. This does work
as long as Resource is the first element in _EGLContext,
this patch fixes such dependency.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-02-07 08:14:05 -07:00
José Fonseca 8771285054 s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008.  Leaving the
old copyright name is creating unnecessary confusion, hence this change.

This was the sed script I used:

    $ cat tg2vmw.sed
    # Run as:
    #
    #   git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
    #

    # Rename copyrights
    s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
    /Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
    s/TUNGSTEN GRAPHICS/VMWARE/g

    # Rename emails
    s/alanh@tungstengraphics.com/alanh@vmware.com/
    s/jens@tungstengraphics.com/jowen@vmware.com/g
    s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
    s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
    s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
    s/michel@tungstengraphics.com/daenzer@vmware.com/g
    s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
    s/zack@tungstengraphics.com/zackr@vmware.com/

    # Remove dead links
    s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g

    # C string src/gallium/state_trackers/vega/api_misc.c
    s/"Tungsten Graphics, Inc"/"VMware, Inc"/

Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 20:00:32 +00:00
Chad Versace eb09940e55 egl/dri2: Add plumbing for EGL_OPENGL_ES3_BIT_KHR
Fixes error EGL_BAD_ATTRIBUTE in the tests below on Intel Sandybridge:
    * piglit egl-create-context-verify-gl-flavor, testcase OpenGL ES 3.0
    * gles3conform, revision 19700, when runnning GL3Tests with -fbo

This plumbing is added in order to comply with the EGL_KHR_create_context
spec. According to the EGL_KHR_create_context spec, it is illegal to call
eglCreateContext(EGL_CONTEXT_MAJOR_VERSION_KHR=3) with a config whose
EGL_RENDERABLE_TYPE does not contain the EGL_OPENGL_ES3_BIT_KHR. The
pertinent
portion of the spec is quoted below; the key word is "respectively".

  * If <config> is not a valid EGLConfig, or does not support the
    requested client API, then an EGL_BAD_CONFIG error is generated
    (this includes requesting creation of an OpenGL ES 1.x, 2.0, or
    3.0 context when the EGL_RENDERABLE_TYPE attribute of <config>
    does not contain EGL_OPENGL_ES_BIT, EGL_OPENGL_ES2_BIT, or
    EGL_OPENGL_ES3_BIT_KHR respectively).

To create this patch, I searched for all the ES2 bit plumbing by calling
`git grep "ES2_BIT\|DRI_API_GLES2" src/egl`, and then at each location
added a case for ES3.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-01-15 13:45:54 -08:00
Matt Turner 587d5db11d egl: Return EGL_BAD_MATCH for invalid profile attributes
Version 12 of the EGL_KHR_create_context spec changed this behavior.

NOTE: This is a candidate for the 9.0 branch
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-10 13:15:06 -07:00
Matt Turner 971750e1cd egl: fix invalid flag detection for EGL_KHR_create_context
We want to check whether there are bits set outside of the valid flags.

Fixes piglit test egl-create-context-invalid-flag-gl

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-08-27 15:11:11 -07:00
Ian Romanick dbecb41300 egl: Allow OpenGL ES 3.0 as a version
In the DRI2 back-end this will get the same API as GLES 2.0.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:03 -07:00
Ian Romanick f171571bfc egl: Implement front-end support for EGL_EXT_create_context_robustness
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:03 -07:00
Ian Romanick 63beb3df98 egl: Implement front-end support for EGL_KHR_create_context
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:03 -07:00
Ian Romanick 3fd79dd988 egl: Rename ClientVersion to ClientMajorVersion, add ClientMinorVersion
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:03 -07:00
Ian Romanick b50703aea5 egl: Replace KHR_surfaceless_* extensions with KHR_surfaceless_context
KHR extension name is reserved for Khronos ratified extensions, and there is
no such thing as EGL_KHR_surfaceless_{gles1,gles2,opengl}.  Replace these
three extensions with EGL_KHR_surfaceless_context since that extension
actually exists.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-08-06 15:37:04 -07:00
Chia-I Wu f957cac772 egl: remove #ifdef's for official extensions
There is no point in having them when we distribute eglext.h.

As for unofficial extensions, there is a chance that we might remove some of
them evetually.  Keeping the #ifdef's for now should make that easier.
2011-12-20 16:59:09 +08:00
Chia-I Wu f2001df508 egl: add copyright notices
The list of copyright holders could be incomplete.  Please update
directly or notify me if your name is missing.
2011-07-02 18:21:31 +09:00
Chia-I Wu 0d43cbed2f egl: Fix a false negative check in _eglCheckMakeCurrent.
This call sequence

  eglMakeCurrent(dpy, surf, surf, ctx1);
  eglMakeCurrent(dpy, surf, surf, ctx2);

should be valid if ctx1 and ctx2 have the same client API and are not
current in another thread.
2010-10-23 16:58:38 +08:00
Chia-I Wu d19afc57fe egl: Use reference counting to replace IsLinked or IsBound.
Remove all _egl<Res>IsLinked and _egl<Res>IsBound.  Update
_eglBindContext and drivers to do reference counting.
2010-10-23 15:26:28 +08:00
Chia-I Wu dc4f845c37 egl: Add reference count for resources.
This is a really simple mechanism.  There is no atomicity and the caller
is expected to hold the display lock.
2010-10-23 15:19:34 +08:00
Chia-I Wu 25328509c9 egl: Move fallback routines to eglfallbacks.c.
We do not want them to be all over the places.
2010-10-22 18:38:30 +08:00
Chia-I Wu 3fa21881b1 egl: Access config attributes directly.
Replace SET_CONFIG_ATTRIB/GET_CONFIG_ATTRIB by direct dereferences.
2010-10-14 17:16:14 +08:00
Chia-I Wu ea9e5dbbc2 egl: Simplify _eglBindContext.
Remove the hard-to-get-right _eglBindContextToSurfaces.  As well as fix
an assertion failure from b90a3e7d8b when
such call sequence is hit

  eglMakeCurrent(dpy, surf1, surf1, ctx1);
  eglMakeCurrent(dpy, surf2, surf2, ctx2);
  eglMakeCurrent(dpy, surf1, surf1, ctx1);
2010-09-10 18:41:14 +08:00
Chia-I Wu 5eb33596a0 egl: Fix context API check and be verbose.
The API of the context was not checked against EGL_RENDERABLE_TYPE when there
was no attribute list.  Move the check to _eglInitContext, and be verbose about
common mistakes (EGL_RENDERABLE_TYPE not set, EGL_CONTEXT_CLIENT_VERSION not
set, or eglBindAPI not called).
2010-08-20 19:22:51 +08:00
Kristian Høgsberg 2c343af098 egl: Fix deref before NULL-check 2010-07-28 23:54:16 -04:00
Kristian Høgsberg b90a3e7d8b egl: EGL_KHR_surfaceless_* extensions
These extensions allow an application to make a context current by
passing EGL_NO_SURFACE for the write and read surface in the call to
eglMakeCurrent.  The motivation is that applications that only want to
render to client API targets (such as OpenGL framebuffer objects)
should not need to create a throw-away EGL surface just to get a
current context.
2010-07-28 23:07:00 -04:00
Chia-I Wu 848945e5d6 egl: Unbind the old context in _eglBindContext.
The last commit incorrectly moved the code under an "else".
2010-04-06 11:55:40 +08:00
Chia-I Wu bbe459b14d egl: Fix eglMakeCurrent with different surfaces.
0a82fadcdd seems to trigger a bug in
_eglBindContext.  Rework the logics yet again.  It is simpler, and
hopefully correct this time.
2010-04-06 11:37:58 +08:00
Chia-I Wu 0a82fadcdd egl: Make _eglBindContextToSurfaces more readable.
There is no effective changes given how the function is called.  It is
still not trivial, but it should be more readable and resemble
_eglBindContextToThread a lot.
2010-03-28 03:37:28 +08:00
Chia-I Wu 551bfe7a09 egl: Always return the previously bound context.
When a newly bound context is the same as the previously bound one,
_eglBindContextToThread should still return the context instead of NULL.
This gives the driver a chance to flush the context.
2010-03-28 03:37:28 +08:00
Chia-I Wu d69242be55 egl: Initialize display resources with their display.
Change _eglInitSurface, _eglInitContext, and _eglInitImage to take an
_EGLDisplay instead of an _EGLDriver.  This is a more natural form, and
plus, the display encodes information such as the extensions supported
that might be required for attribute list parsing.
2010-01-31 14:46:14 +08:00
Chia-I Wu caa5c8dfe8 egl: Refactor _eglInitContext.
Refactor attribute list parsing code to _eglParseContextAttribList.  Add
a check to make sure the config supports the client API.
2010-01-31 14:46:14 +08:00
Chia-I Wu 996fd61442 egl: Remove code blocks that are commented out.
They are either unit tests or to demonstrate how functions are supposed
to be used.  The unit test is outdated and it should be better to take a
look at any of the working drivers to see how a function is used.
2010-01-31 11:31:58 +08:00
Chia-I Wu 00e1790f32 egl: Rename Binding to CurrentContext in _EGLSurface.
A context can be bound to a surface just like it can be bound to a
thread.  CurrentContext is a more consistent name.
2010-01-30 22:57:18 +08:00
Chia-I Wu 94cb321b5d egl: Clean up header inclusions.
Mainly to remove eglcurrent.h and egldisplay.h from eglglobals.h.
2010-01-30 22:55:49 +08:00
Chia-I Wu 6baa2c8d02 egl: Migrate drivers to use _eglBindContext.
_eglMakeCurrent is a big hammer that is not easy to use.  Migrate
drivers to use _eglBindContext and un-export _eglMakeCurrent.
2010-01-28 17:28:48 +08:00
Chia-I Wu 17330479b3 egl: eglMakeCurrent should accept an uninitialized display.
When no context or surface are given, the display is allowed to be
uninitialized.  Most drivers cannot handle an uninitialized display.
But they are updated to at least throw a fatal message.
2010-01-28 17:28:47 +08:00
Chia-I Wu 959481ad70 egl: Add _eglBindContext.
It works similar to _eglMakeCurrent, except that the old context and
surfaces are returned instead of destroyed.  _eglMakeCurrent is now
calling the new _eglBindContext.
2010-01-28 17:28:47 +08:00
Chia-I Wu 7c09296d4c egl: Refactor _eglMakeCurrent.
Refactor _eglMakeCurrent into _eglCheckMakeCurrent,
_eglBindContextToSurface, and _eglBindContextToThread.
2010-01-26 18:46:05 +08:00
Chia-I Wu ecb3b3102a egl: Make surfaces and contexts resources.
Turn _EGLSurface and _EGLContext into _EGLResource so that they can be
managed uniformly.
2010-01-24 20:38:16 +08:00
Chia-I Wu 5e66d18932 egl: Move context functions in egldisplay.[ch] to eglcontext.[ch].
Move functions to where they should be.  There should be no real change
here.
2010-01-24 20:38:15 +08:00
Chia-I Wu d845f2754b egl: Add support for querying render buffer.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
2009-09-29 08:10:48 -06:00
Chia-I Wu 2f2cf461c5 egl: Overhaul driver API.
The motivation is so that drivers do not need to look up and check for
bad display, context, and etc.  It also becomes unnecessary for drivers
to call the link functions.

This commit makes eglapi.[ch] do the lookup and check.  As a result, the
driver API is overhauled, and almost all sources and drivers need
update.  The updates are mainly find and replace with human brains.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
2009-08-18 08:44:34 -06:00