2011-07-02 09:57:30 +01:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
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 16:27:50 +00:00
|
|
|
* Copyright 2008 VMware, Inc.
|
2011-07-02 09:57:30 +01:00
|
|
|
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
|
|
|
|
* Copyright 2010 LunarG, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
2005-04-22 22:09:39 +01:00
|
|
|
/**
|
|
|
|
* Surface-related functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2018-05-16 14:17:30 +01:00
|
|
|
#include "egldefines.h"
|
2009-07-17 18:48:27 +01:00
|
|
|
#include "egldisplay.h"
|
2012-12-13 20:59:24 +00:00
|
|
|
#include "egldriver.h"
|
2005-04-22 22:09:39 +01:00
|
|
|
#include "eglcontext.h"
|
|
|
|
#include "eglconfig.h"
|
2010-01-29 01:00:30 +00:00
|
|
|
#include "eglcurrent.h"
|
2005-11-27 23:57:19 +00:00
|
|
|
#include "egllog.h"
|
|
|
|
#include "eglsurface.h"
|
2005-04-22 22:09:39 +01:00
|
|
|
|
2018-05-16 14:17:30 +01:00
|
|
|
#include "util/macros.h"
|
2005-04-22 22:09:39 +01:00
|
|
|
|
2010-01-31 04:13:59 +00:00
|
|
|
/**
|
|
|
|
* Parse the list of surface attributes and return the proper error code.
|
|
|
|
*/
|
|
|
|
static EGLint
|
|
|
|
_eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
|
|
|
|
{
|
2019-02-02 11:38:45 +00:00
|
|
|
_EGLDisplay *disp = surf->Resource.Display;
|
2010-01-31 04:13:59 +00:00
|
|
|
EGLint type = surf->Type;
|
2010-05-07 03:40:25 +01:00
|
|
|
EGLint texture_type = EGL_PBUFFER_BIT;
|
2010-01-31 04:13:59 +00:00
|
|
|
EGLint i, err = EGL_SUCCESS;
|
2016-06-20 14:27:33 +01:00
|
|
|
EGLint attr = EGL_NONE;
|
|
|
|
EGLint val = EGL_NONE;
|
2010-01-31 04:13:59 +00:00
|
|
|
|
|
|
|
if (!attrib_list)
|
|
|
|
return EGL_SUCCESS;
|
|
|
|
|
2019-02-02 11:38:45 +00:00
|
|
|
if (disp->Extensions.NOK_texture_from_pixmap)
|
2010-05-07 03:40:25 +01:00
|
|
|
texture_type |= EGL_PIXMAP_BIT;
|
|
|
|
|
2010-01-31 04:13:59 +00:00
|
|
|
for (i = 0; attrib_list[i] != EGL_NONE; i++) {
|
2016-06-20 14:27:33 +01:00
|
|
|
attr = attrib_list[i++];
|
|
|
|
val = attrib_list[i];
|
2010-01-31 04:13:59 +00:00
|
|
|
|
|
|
|
switch (attr) {
|
2010-07-30 17:00:49 +01:00
|
|
|
/* common attributes */
|
2015-06-10 01:49:29 +01:00
|
|
|
case EGL_GL_COLORSPACE_KHR:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.KHR_gl_colorspace) {
|
2015-06-10 01:49:29 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (val) {
|
|
|
|
case EGL_GL_COLORSPACE_SRGB_KHR:
|
|
|
|
case EGL_GL_COLORSPACE_LINEAR_KHR:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
|
|
|
surf->GLColorspace = val;
|
|
|
|
break;
|
2018-04-05 11:02:36 +01:00
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.display_primary_r.x = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.display_primary_r.y = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.display_primary_g.x = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.display_primary_g.y = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.display_primary_b.x = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.display_primary_b.y = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_WHITE_POINT_X_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.white_point.x = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_WHITE_POINT_Y_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.white_point.y = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_MAX_LUMINANCE_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.max_luminance = val;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_MIN_LUMINANCE_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_SMPTE2086_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.min_luminance = val;
|
|
|
|
break;
|
|
|
|
case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_CTA861_3_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.max_cll = val;
|
|
|
|
break;
|
|
|
|
case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.EXT_surface_CTA861_3_metadata) {
|
2018-04-05 11:02:36 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->HdrMetadata.max_fall = val;
|
|
|
|
break;
|
2010-01-31 04:13:59 +00:00
|
|
|
case EGL_VG_COLORSPACE:
|
|
|
|
switch (val) {
|
|
|
|
case EGL_VG_COLORSPACE_sRGB:
|
|
|
|
case EGL_VG_COLORSPACE_LINEAR:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->VGColorspace = val;
|
2010-01-31 04:13:59 +00:00
|
|
|
break;
|
|
|
|
case EGL_VG_ALPHA_FORMAT:
|
|
|
|
switch (val) {
|
|
|
|
case EGL_VG_ALPHA_FORMAT_NONPRE:
|
|
|
|
case EGL_VG_ALPHA_FORMAT_PRE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->VGAlphaFormat = val;
|
2010-01-31 04:13:59 +00:00
|
|
|
break;
|
|
|
|
/* window surface attributes */
|
|
|
|
case EGL_RENDER_BUFFER:
|
|
|
|
if (type != EGL_WINDOW_BIT) {
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (val != EGL_BACK_BUFFER && val != EGL_SINGLE_BUFFER) {
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
egl: Simplify queries for EGL_RENDER_BUFFER
There exist *two* queryable EGL_RENDER_BUFFER states in EGL:
eglQuerySurface(EGL_RENDER_BUFFER) and
eglQueryContext(EGL_RENDER_BUFFER).
These changes eliminate potentially very fragile code in the upcoming
EGL_KHR_mutable_render_buffer implementation.
* eglQuerySurface(EGL_RENDER_BUFFER)
The implementation of eglQuerySurface(EGL_RENDER_BUFFER) contained
abstruse logic which required comprehending the specification
complexities of how the two EGL_RENDER_BUFFER states interact. The
function sometimes returned _EGLContext::WindowRenderBuffer, sometimes
_EGLSurface::RenderBuffer. Why? The function tried to encode the
actual logic from the EGL spec. When did the function return which
variable? Go study the EGL spec, hope you understand it, then hope
Mesa mutated the EGL_RENDER_BUFFER state in all the correct places.
Have fun.
To simplify eglQuerySurface(EGL_RENDER_BUFFER), and to improve
confidence in its correctness, flatten its indirect logic. For pixmap
and pbuffer surfaces, simply return a hard-coded literal value, as the
spec suggests. For window surfaces, simply return
_EGLSurface::RequestedRenderBuffer. Nothing difficult here.
* eglQueryContext(EGL_RENDER_BUFFER)
The implementation of this suffered from the same issues as
eglQuerySurface, and the solution is the same. confidence in its
correctness, flatten its indirect logic. For pixmap and pbuffer
surfaces, simply return a hard-coded literal value, as the spec
suggests. For window surfaces, simply return
_EGLSurface::ActiveRenderBuffer.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2018-04-07 22:23:48 +01:00
|
|
|
surf->RequestedRenderBuffer = val;
|
2018-05-01 06:32:25 +01:00
|
|
|
if (surf->Config->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR) {
|
|
|
|
/* Unlike normal EGLSurfaces, one with a mutable render buffer
|
|
|
|
* uses the application-chosen render buffer.
|
|
|
|
*/
|
|
|
|
surf->ActiveRenderBuffer = val;
|
|
|
|
}
|
2010-01-31 04:13:59 +00:00
|
|
|
break;
|
2011-12-14 20:24:09 +00:00
|
|
|
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.NV_post_sub_buffer ||
|
2011-12-14 20:24:09 +00:00
|
|
|
type != EGL_WINDOW_BIT) {
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (val != EGL_TRUE && val != EGL_FALSE) {
|
|
|
|
err = EGL_BAD_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->PostSubBufferSupportedNV = val;
|
|
|
|
break;
|
2010-01-31 04:13:59 +00:00
|
|
|
/* pbuffer surface attributes */
|
|
|
|
case EGL_WIDTH:
|
2010-07-30 17:00:49 +01:00
|
|
|
if (type != EGL_PBUFFER_BIT) {
|
2010-01-31 04:13:59 +00:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (val < 0) {
|
|
|
|
err = EGL_BAD_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->Width = val;
|
|
|
|
break;
|
|
|
|
case EGL_HEIGHT:
|
2010-07-30 17:00:49 +01:00
|
|
|
if (type != EGL_PBUFFER_BIT) {
|
2010-01-31 04:13:59 +00:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (val < 0) {
|
|
|
|
err = EGL_BAD_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
surf->Height = val;
|
|
|
|
break;
|
|
|
|
case EGL_LARGEST_PBUFFER:
|
|
|
|
if (type != EGL_PBUFFER_BIT) {
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->LargestPbuffer = !!val;
|
2010-01-31 04:13:59 +00:00
|
|
|
break;
|
2010-07-30 17:00:49 +01:00
|
|
|
/* for eglBindTexImage */
|
2010-01-31 04:13:59 +00:00
|
|
|
case EGL_TEXTURE_FORMAT:
|
2010-05-07 03:40:25 +01:00
|
|
|
if (!(type & texture_type)) {
|
2010-01-31 04:13:59 +00:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-25 17:29:55 +01:00
|
|
|
|
2010-01-31 09:56:30 +00:00
|
|
|
switch (val) {
|
|
|
|
case EGL_TEXTURE_RGB:
|
|
|
|
case EGL_TEXTURE_RGBA:
|
|
|
|
case EGL_NO_TEXTURE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
2010-01-31 04:13:59 +00:00
|
|
|
surf->TextureFormat = val;
|
|
|
|
break;
|
|
|
|
case EGL_TEXTURE_TARGET:
|
2010-05-07 03:40:25 +01:00
|
|
|
if (!(type & texture_type)) {
|
2010-01-31 04:13:59 +00:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-25 17:29:55 +01:00
|
|
|
|
2010-01-31 09:56:30 +00:00
|
|
|
switch (val) {
|
|
|
|
case EGL_TEXTURE_2D:
|
|
|
|
case EGL_NO_TEXTURE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
2010-01-31 04:13:59 +00:00
|
|
|
surf->TextureTarget = val;
|
|
|
|
break;
|
|
|
|
case EGL_MIPMAP_TEXTURE:
|
2010-05-07 03:40:25 +01:00
|
|
|
if (!(type & texture_type)) {
|
2010-01-31 04:13:59 +00:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->MipmapTexture = !!val;
|
2010-01-31 04:13:59 +00:00
|
|
|
break;
|
|
|
|
/* no pixmap surface specific attributes */
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-06-20 14:27:33 +01:00
|
|
|
if (err != EGL_SUCCESS)
|
2010-01-31 04:13:59 +00:00
|
|
|
break;
|
2016-06-20 14:27:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (err == EGL_SUCCESS && type == EGL_PBUFFER_BIT) {
|
|
|
|
if ((surf->TextureTarget == EGL_NO_TEXTURE && surf->TextureFormat != EGL_NO_TEXTURE) ||
|
|
|
|
(surf->TextureFormat == EGL_NO_TEXTURE && surf->TextureTarget != EGL_NO_TEXTURE)) {
|
|
|
|
attr = surf->TextureTarget == EGL_NO_TEXTURE ? EGL_TEXTURE_TARGET : EGL_TEXTURE_FORMAT;
|
|
|
|
err = EGL_BAD_MATCH;
|
2010-01-31 04:13:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 14:27:33 +01:00
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
_eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr);
|
|
|
|
|
2010-01-31 04:13:59 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-27 23:57:19 +00:00
|
|
|
/**
|
|
|
|
* Do error check on parameters and initialize the given _EGLSurface object.
|
|
|
|
* \return EGL_TRUE if no errors, EGL_FALSE otherwise.
|
|
|
|
*/
|
|
|
|
EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglInitSurface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type,
|
2019-05-01 23:42:26 +01:00
|
|
|
_EGLConfig *conf, const EGLint *attrib_list,
|
|
|
|
void *native_surface)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2005-11-27 23:57:19 +00:00
|
|
|
const char *func;
|
2006-01-30 00:10:55 +00:00
|
|
|
EGLint renderBuffer = EGL_BACK_BUFFER;
|
2016-10-26 11:54:51 +01:00
|
|
|
EGLint swapBehavior = EGL_BUFFER_DESTROYED;
|
2010-01-31 04:13:59 +00:00
|
|
|
EGLint err;
|
2005-11-27 23:57:19 +00:00
|
|
|
|
2016-10-26 11:54:51 +01:00
|
|
|
/* Swap behavior can be preserved only if config supports this. */
|
|
|
|
if (conf->SurfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)
|
|
|
|
swapBehavior = EGL_BUFFER_PRESERVED;
|
|
|
|
|
2005-11-27 23:57:19 +00:00
|
|
|
switch (type) {
|
|
|
|
case EGL_WINDOW_BIT:
|
|
|
|
func = "eglCreateWindowSurface";
|
2011-07-28 05:33:55 +01:00
|
|
|
swapBehavior = EGL_BUFFER_DESTROYED;
|
2005-11-27 23:57:19 +00:00
|
|
|
break;
|
|
|
|
case EGL_PIXMAP_BIT:
|
|
|
|
func = "eglCreatePixmapSurface";
|
2006-01-30 00:10:55 +00:00
|
|
|
renderBuffer = EGL_SINGLE_BUFFER;
|
2005-11-27 23:57:19 +00:00
|
|
|
break;
|
|
|
|
case EGL_PBUFFER_BIT:
|
|
|
|
func = "eglCreatePBufferSurface";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_eglLog(_EGL_WARNING, "Bad type in _eglInitSurface");
|
|
|
|
return EGL_FALSE;
|
|
|
|
}
|
|
|
|
|
2017-06-20 15:40:28 +01:00
|
|
|
if ((conf->SurfaceType & type) == 0)
|
2008-09-01 20:08:12 +01:00
|
|
|
/* The config can't be used to create a surface of this type */
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_MATCH, func);
|
2008-09-01 20:08:12 +01:00
|
|
|
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglInitResource(&surf->Resource, sizeof(*surf), disp);
|
2005-11-27 23:57:19 +00:00
|
|
|
surf->Type = type;
|
2010-01-31 04:13:59 +00:00
|
|
|
surf->Config = conf;
|
2017-05-05 01:46:33 +01:00
|
|
|
surf->Lost = EGL_FALSE;
|
2010-01-31 04:13:59 +00:00
|
|
|
|
|
|
|
surf->Width = 0;
|
|
|
|
surf->Height = 0;
|
|
|
|
surf->TextureFormat = EGL_NO_TEXTURE;
|
|
|
|
surf->TextureTarget = EGL_NO_TEXTURE;
|
|
|
|
surf->MipmapTexture = EGL_FALSE;
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->LargestPbuffer = EGL_FALSE;
|
egl: Simplify queries for EGL_RENDER_BUFFER
There exist *two* queryable EGL_RENDER_BUFFER states in EGL:
eglQuerySurface(EGL_RENDER_BUFFER) and
eglQueryContext(EGL_RENDER_BUFFER).
These changes eliminate potentially very fragile code in the upcoming
EGL_KHR_mutable_render_buffer implementation.
* eglQuerySurface(EGL_RENDER_BUFFER)
The implementation of eglQuerySurface(EGL_RENDER_BUFFER) contained
abstruse logic which required comprehending the specification
complexities of how the two EGL_RENDER_BUFFER states interact. The
function sometimes returned _EGLContext::WindowRenderBuffer, sometimes
_EGLSurface::RenderBuffer. Why? The function tried to encode the
actual logic from the EGL spec. When did the function return which
variable? Go study the EGL spec, hope you understand it, then hope
Mesa mutated the EGL_RENDER_BUFFER state in all the correct places.
Have fun.
To simplify eglQuerySurface(EGL_RENDER_BUFFER), and to improve
confidence in its correctness, flatten its indirect logic. For pixmap
and pbuffer surfaces, simply return a hard-coded literal value, as the
spec suggests. For window surfaces, simply return
_EGLSurface::RequestedRenderBuffer. Nothing difficult here.
* eglQueryContext(EGL_RENDER_BUFFER)
The implementation of this suffered from the same issues as
eglQuerySurface, and the solution is the same. confidence in its
correctness, flatten its indirect logic. For pixmap and pbuffer
surfaces, simply return a hard-coded literal value, as the spec
suggests. For window surfaces, simply return
_EGLSurface::ActiveRenderBuffer.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2018-04-07 22:23:48 +01:00
|
|
|
surf->RequestedRenderBuffer = renderBuffer;
|
|
|
|
surf->ActiveRenderBuffer = renderBuffer;
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->VGAlphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
|
|
|
|
surf->VGColorspace = EGL_VG_COLORSPACE_sRGB;
|
2015-06-10 01:49:29 +01:00
|
|
|
surf->GLColorspace = EGL_GL_COLORSPACE_LINEAR_KHR;
|
2010-01-31 09:56:30 +00:00
|
|
|
|
2005-11-27 23:57:19 +00:00
|
|
|
surf->MipmapLevel = 0;
|
2010-01-31 09:56:30 +00:00
|
|
|
surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT;
|
2011-07-28 05:33:55 +01:00
|
|
|
surf->SwapBehavior = swapBehavior;
|
2010-01-31 09:56:30 +00:00
|
|
|
|
|
|
|
surf->HorizontalResolution = EGL_UNKNOWN;
|
|
|
|
surf->VerticalResolution = EGL_UNKNOWN;
|
|
|
|
surf->AspectRatio = EGL_UNKNOWN;
|
|
|
|
|
2011-12-14 20:24:09 +00:00
|
|
|
surf->PostSubBufferSupportedNV = EGL_FALSE;
|
2017-06-09 15:43:34 +01:00
|
|
|
surf->SetDamageRegionCalled = EGL_FALSE;
|
|
|
|
surf->BufferAgeRead = EGL_FALSE;
|
2011-12-14 20:24:09 +00:00
|
|
|
|
2009-10-15 04:08:48 +01:00
|
|
|
/* the default swap interval is 1 */
|
2017-07-31 14:49:31 +01:00
|
|
|
surf->SwapInterval = 1;
|
2009-10-15 04:08:48 +01:00
|
|
|
|
2018-04-05 11:02:36 +01:00
|
|
|
surf->HdrMetadata.display_primary_r.x = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.display_primary_r.y = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.display_primary_g.x = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.display_primary_g.y = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.display_primary_b.x = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.display_primary_b.y = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.white_point.x = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.white_point.y = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.max_luminance = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.min_luminance = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.max_cll = EGL_DONT_CARE;
|
|
|
|
surf->HdrMetadata.max_fall = EGL_DONT_CARE;
|
|
|
|
|
2010-01-31 04:13:59 +00:00
|
|
|
err = _eglParseSurfaceAttribList(surf, attrib_list);
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
return _eglError(err, func);
|
|
|
|
|
2016-02-22 06:00:14 +00:00
|
|
|
/* if EGL_LARGEST_PBUFFER in use, clamp width and height */
|
|
|
|
if (surf->LargestPbuffer) {
|
|
|
|
surf->Width = MIN2(surf->Width, _EGL_MAX_PBUFFER_WIDTH);
|
|
|
|
surf->Height = MIN2(surf->Height, _EGL_MAX_PBUFFER_HEIGHT);
|
|
|
|
}
|
|
|
|
|
2019-05-01 23:42:26 +01:00
|
|
|
surf->NativeSurface = native_surface;
|
|
|
|
|
2005-11-27 23:57:19 +00:00
|
|
|
return EGL_TRUE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface,
|
2005-11-27 23:57:19 +00:00
|
|
|
EGLint attribute, EGLint *value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
|
|
|
switch (attribute) {
|
|
|
|
case EGL_WIDTH:
|
|
|
|
*value = surface->Width;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
case EGL_HEIGHT:
|
|
|
|
*value = surface->Height;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
case EGL_CONFIG_ID:
|
2010-10-14 09:38:58 +01:00
|
|
|
*value = surface->Config->ConfigID;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2008-06-20 17:20:25 +01:00
|
|
|
case EGL_LARGEST_PBUFFER:
|
2015-07-31 09:11:45 +01:00
|
|
|
if (surface->Type == EGL_PBUFFER_BIT)
|
|
|
|
*value = surface->LargestPbuffer;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
case EGL_TEXTURE_FORMAT:
|
|
|
|
/* texture attributes: only for pbuffers, no error otherwise */
|
|
|
|
if (surface->Type == EGL_PBUFFER_BIT)
|
|
|
|
*value = surface->TextureFormat;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
case EGL_TEXTURE_TARGET:
|
|
|
|
if (surface->Type == EGL_PBUFFER_BIT)
|
|
|
|
*value = surface->TextureTarget;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
case EGL_MIPMAP_TEXTURE:
|
|
|
|
if (surface->Type == EGL_PBUFFER_BIT)
|
|
|
|
*value = surface->MipmapTexture;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
case EGL_MIPMAP_LEVEL:
|
|
|
|
if (surface->Type == EGL_PBUFFER_BIT)
|
|
|
|
*value = surface->MipmapLevel;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2006-01-30 00:10:55 +00:00
|
|
|
case EGL_SWAP_BEHAVIOR:
|
|
|
|
*value = surface->SwapBehavior;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2006-01-30 00:10:55 +00:00
|
|
|
case EGL_RENDER_BUFFER:
|
2018-05-01 06:32:25 +01:00
|
|
|
/* From the EGL_KHR_mutable_render_buffer spec (v12):
|
egl: Simplify queries for EGL_RENDER_BUFFER
There exist *two* queryable EGL_RENDER_BUFFER states in EGL:
eglQuerySurface(EGL_RENDER_BUFFER) and
eglQueryContext(EGL_RENDER_BUFFER).
These changes eliminate potentially very fragile code in the upcoming
EGL_KHR_mutable_render_buffer implementation.
* eglQuerySurface(EGL_RENDER_BUFFER)
The implementation of eglQuerySurface(EGL_RENDER_BUFFER) contained
abstruse logic which required comprehending the specification
complexities of how the two EGL_RENDER_BUFFER states interact. The
function sometimes returned _EGLContext::WindowRenderBuffer, sometimes
_EGLSurface::RenderBuffer. Why? The function tried to encode the
actual logic from the EGL spec. When did the function return which
variable? Go study the EGL spec, hope you understand it, then hope
Mesa mutated the EGL_RENDER_BUFFER state in all the correct places.
Have fun.
To simplify eglQuerySurface(EGL_RENDER_BUFFER), and to improve
confidence in its correctness, flatten its indirect logic. For pixmap
and pbuffer surfaces, simply return a hard-coded literal value, as the
spec suggests. For window surfaces, simply return
_EGLSurface::RequestedRenderBuffer. Nothing difficult here.
* eglQueryContext(EGL_RENDER_BUFFER)
The implementation of this suffered from the same issues as
eglQuerySurface, and the solution is the same. confidence in its
correctness, flatten its indirect logic. For pixmap and pbuffer
surfaces, simply return a hard-coded literal value, as the spec
suggests. For window surfaces, simply return
_EGLSurface::ActiveRenderBuffer.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2018-04-07 22:23:48 +01:00
|
|
|
*
|
|
|
|
* Querying EGL_RENDER_BUFFER returns the buffer which client API
|
|
|
|
* rendering is requested to use. For a window surface, this is the
|
2018-05-01 06:32:25 +01:00
|
|
|
* attribute value specified when the surface was created or last set
|
|
|
|
* via eglSurfaceAttrib.
|
|
|
|
*
|
|
|
|
* In other words, querying a window surface returns the value most
|
|
|
|
* recently *requested* by the user.
|
|
|
|
*
|
|
|
|
* The paragraph continues in the EGL 1.5 spec (2014.08.27):
|
|
|
|
*
|
|
|
|
* For a pbuffer surface, it is always EGL_BACK_BUFFER . For a pixmap
|
egl: Simplify queries for EGL_RENDER_BUFFER
There exist *two* queryable EGL_RENDER_BUFFER states in EGL:
eglQuerySurface(EGL_RENDER_BUFFER) and
eglQueryContext(EGL_RENDER_BUFFER).
These changes eliminate potentially very fragile code in the upcoming
EGL_KHR_mutable_render_buffer implementation.
* eglQuerySurface(EGL_RENDER_BUFFER)
The implementation of eglQuerySurface(EGL_RENDER_BUFFER) contained
abstruse logic which required comprehending the specification
complexities of how the two EGL_RENDER_BUFFER states interact. The
function sometimes returned _EGLContext::WindowRenderBuffer, sometimes
_EGLSurface::RenderBuffer. Why? The function tried to encode the
actual logic from the EGL spec. When did the function return which
variable? Go study the EGL spec, hope you understand it, then hope
Mesa mutated the EGL_RENDER_BUFFER state in all the correct places.
Have fun.
To simplify eglQuerySurface(EGL_RENDER_BUFFER), and to improve
confidence in its correctness, flatten its indirect logic. For pixmap
and pbuffer surfaces, simply return a hard-coded literal value, as the
spec suggests. For window surfaces, simply return
_EGLSurface::RequestedRenderBuffer. Nothing difficult here.
* eglQueryContext(EGL_RENDER_BUFFER)
The implementation of this suffered from the same issues as
eglQuerySurface, and the solution is the same. confidence in its
correctness, flatten its indirect logic. For pixmap and pbuffer
surfaces, simply return a hard-coded literal value, as the spec
suggests. For window surfaces, simply return
_EGLSurface::ActiveRenderBuffer.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2018-04-07 22:23:48 +01:00
|
|
|
* surface, it is always EGL_SINGLE_BUFFER . To determine the actual
|
|
|
|
* buffer being rendered to by a context, call eglQueryContext.
|
|
|
|
*/
|
|
|
|
switch (surface->Type) {
|
|
|
|
default:
|
|
|
|
unreachable("bad EGLSurface type");
|
|
|
|
case EGL_WINDOW_BIT:
|
|
|
|
*value = surface->RequestedRenderBuffer;
|
|
|
|
break;
|
|
|
|
case EGL_PBUFFER_BIT:
|
|
|
|
*value = EGL_BACK_BUFFER;
|
|
|
|
break;
|
|
|
|
case EGL_PIXMAP_BIT:
|
|
|
|
*value = EGL_SINGLE_BUFFER;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2006-01-30 00:10:55 +00:00
|
|
|
case EGL_PIXEL_ASPECT_RATIO:
|
|
|
|
*value = surface->AspectRatio;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2006-01-30 00:10:55 +00:00
|
|
|
case EGL_HORIZONTAL_RESOLUTION:
|
|
|
|
*value = surface->HorizontalResolution;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
2006-01-30 00:10:55 +00:00
|
|
|
case EGL_VERTICAL_RESOLUTION:
|
|
|
|
*value = surface->VerticalResolution;
|
2010-01-31 09:56:30 +00:00
|
|
|
break;
|
|
|
|
case EGL_MULTISAMPLE_RESOLVE:
|
|
|
|
*value = surface->MultisampleResolve;
|
|
|
|
break;
|
|
|
|
case EGL_VG_ALPHA_FORMAT:
|
|
|
|
*value = surface->VGAlphaFormat;
|
|
|
|
break;
|
|
|
|
case EGL_VG_COLORSPACE:
|
|
|
|
*value = surface->VGColorspace;
|
|
|
|
break;
|
2015-06-10 01:49:29 +01:00
|
|
|
case EGL_GL_COLORSPACE_KHR:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.KHR_gl_colorspace)
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
|
|
|
|
|
2015-06-10 01:49:29 +01:00
|
|
|
*value = surface->GLColorspace;
|
|
|
|
break;
|
2011-12-14 20:24:09 +00:00
|
|
|
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
|
|
|
|
*value = surface->PostSubBufferSupportedNV;
|
|
|
|
break;
|
2012-12-13 20:59:24 +00:00
|
|
|
case EGL_BUFFER_AGE_EXT:
|
2019-02-07 23:11:57 +00:00
|
|
|
/* Both EXT_buffer_age and KHR_partial_update accept EGL_BUFFER_AGE_EXT.
|
|
|
|
* To be precise, the KHR one accepts EGL_BUFFER_AGE_KHR which is an
|
|
|
|
* alias with the same numeric value.
|
|
|
|
*/
|
|
|
|
if (!disp->Extensions.EXT_buffer_age &&
|
|
|
|
!disp->Extensions.KHR_partial_update)
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
|
|
|
|
|
2017-06-09 15:43:34 +01:00
|
|
|
_EGLContext *ctx = _eglGetCurrentContext();
|
2019-02-02 11:38:45 +00:00
|
|
|
EGLint result = drv->API.QueryBufferAge(drv, disp, surface);
|
2017-06-08 10:24:24 +01:00
|
|
|
/* error happened */
|
|
|
|
if (result < 0)
|
|
|
|
return EGL_FALSE;
|
2017-06-09 15:43:34 +01:00
|
|
|
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
|
2017-06-20 15:40:28 +01:00
|
|
|
ctx->DrawSurface != surface)
|
|
|
|
return _eglError(EGL_BAD_SURFACE, "eglQuerySurface");
|
|
|
|
|
2017-06-08 10:24:24 +01:00
|
|
|
*value = result;
|
2017-06-09 15:43:34 +01:00
|
|
|
surface->BufferAgeRead = EGL_TRUE;
|
2012-12-13 20:59:24 +00:00
|
|
|
break;
|
2018-04-05 11:02:36 +01:00
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT:
|
|
|
|
*value = surface->HdrMetadata.display_primary_r.x;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT:
|
|
|
|
*value = surface->HdrMetadata.display_primary_r.y;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT:
|
|
|
|
*value = surface->HdrMetadata.display_primary_g.x;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT:
|
|
|
|
*value = surface->HdrMetadata.display_primary_g.y;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT:
|
|
|
|
*value = surface->HdrMetadata.display_primary_b.x;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT:
|
|
|
|
*value = surface->HdrMetadata.display_primary_b.y;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_WHITE_POINT_X_EXT:
|
|
|
|
*value = surface->HdrMetadata.white_point.x;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_WHITE_POINT_Y_EXT:
|
|
|
|
*value = surface->HdrMetadata.white_point.y;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_MAX_LUMINANCE_EXT:
|
|
|
|
*value = surface->HdrMetadata.max_luminance;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_MIN_LUMINANCE_EXT:
|
|
|
|
*value = surface->HdrMetadata.min_luminance;
|
|
|
|
break;
|
|
|
|
case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT:
|
|
|
|
*value = surface->HdrMetadata.max_cll;
|
|
|
|
break;
|
|
|
|
case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT:
|
|
|
|
*value = surface->HdrMetadata.max_fall;
|
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
default:
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
2010-01-31 09:56:30 +00:00
|
|
|
|
|
|
|
return EGL_TRUE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default fallback routine - drivers might override this.
|
|
|
|
*/
|
|
|
|
EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface,
|
2008-09-01 20:08:12 +01:00
|
|
|
EGLint attribute, EGLint value)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2010-01-31 09:56:30 +00:00
|
|
|
EGLint confval;
|
|
|
|
EGLint err = EGL_SUCCESS;
|
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>
2012-11-20 21:43:11 +00:00
|
|
|
EGLint all_es_bits = EGL_OPENGL_ES_BIT |
|
|
|
|
EGL_OPENGL_ES2_BIT |
|
|
|
|
EGL_OPENGL_ES3_BIT_KHR;
|
2010-01-31 09:56:30 +00:00
|
|
|
|
2005-04-22 22:09:39 +01:00
|
|
|
switch (attribute) {
|
|
|
|
case EGL_MIPMAP_LEVEL:
|
2010-10-14 09:38:58 +01:00
|
|
|
confval = surface->Config->RenderableType;
|
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>
2012-11-20 21:43:11 +00:00
|
|
|
if (!(confval & all_es_bits)) {
|
2010-01-31 09:56:30 +00:00
|
|
|
err = EGL_BAD_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
2005-04-22 22:09:39 +01:00
|
|
|
surface->MipmapLevel = value;
|
|
|
|
break;
|
2010-01-31 09:56:30 +00:00
|
|
|
case EGL_MULTISAMPLE_RESOLVE:
|
|
|
|
switch (value) {
|
|
|
|
case EGL_MULTISAMPLE_RESOLVE_DEFAULT:
|
|
|
|
break;
|
|
|
|
case EGL_MULTISAMPLE_RESOLVE_BOX:
|
2010-10-14 09:38:58 +01:00
|
|
|
confval = surface->Config->SurfaceType;
|
2010-01-31 09:56:30 +00:00
|
|
|
if (!(confval & EGL_MULTISAMPLE_RESOLVE_BOX_BIT))
|
|
|
|
err = EGL_BAD_MATCH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
|
|
|
surface->MultisampleResolve = value;
|
|
|
|
break;
|
2018-05-01 06:32:25 +01:00
|
|
|
case EGL_RENDER_BUFFER:
|
2019-02-02 11:38:45 +00:00
|
|
|
if (!disp->Extensions.KHR_mutable_render_buffer) {
|
2018-05-01 06:32:25 +01:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value != EGL_BACK_BUFFER && value != EGL_SINGLE_BUFFER) {
|
|
|
|
err = EGL_BAD_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* From the EGL_KHR_mutable_render_buffer spec (v12):
|
|
|
|
*
|
|
|
|
* If attribute is EGL_RENDER_BUFFER, and the EGL_SURFACE_TYPE
|
|
|
|
* attribute of the EGLConfig used to create surface does not contain
|
|
|
|
* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR, [...] an EGL_BAD_MATCH error is
|
|
|
|
* generated [...].
|
|
|
|
*/
|
|
|
|
if (!(surface->Config->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR)) {
|
|
|
|
err = EGL_BAD_MATCH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->RequestedRenderBuffer = value;
|
|
|
|
break;
|
2010-01-31 09:56:30 +00:00
|
|
|
case EGL_SWAP_BEHAVIOR:
|
|
|
|
switch (value) {
|
|
|
|
case EGL_BUFFER_DESTROYED:
|
|
|
|
break;
|
|
|
|
case EGL_BUFFER_PRESERVED:
|
2010-10-14 09:38:58 +01:00
|
|
|
confval = surface->Config->SurfaceType;
|
2010-01-31 09:56:30 +00:00
|
|
|
if (!(confval & EGL_SWAP_BEHAVIOR_PRESERVED_BIT))
|
|
|
|
err = EGL_BAD_MATCH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
break;
|
|
|
|
surface->SwapBehavior = value;
|
|
|
|
break;
|
2018-04-05 11:02:36 +01:00
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT:
|
|
|
|
surface->HdrMetadata.display_primary_r.x = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT:
|
|
|
|
surface->HdrMetadata.display_primary_r.y = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT:
|
|
|
|
surface->HdrMetadata.display_primary_g.x = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT:
|
|
|
|
surface->HdrMetadata.display_primary_g.y = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT:
|
|
|
|
surface->HdrMetadata.display_primary_b.x = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT:
|
|
|
|
surface->HdrMetadata.display_primary_b.y = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_WHITE_POINT_X_EXT:
|
|
|
|
surface->HdrMetadata.white_point.x = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_WHITE_POINT_Y_EXT:
|
|
|
|
surface->HdrMetadata.white_point.y = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_MAX_LUMINANCE_EXT:
|
|
|
|
surface->HdrMetadata.max_luminance = value;
|
|
|
|
break;
|
|
|
|
case EGL_SMPTE2086_MIN_LUMINANCE_EXT:
|
|
|
|
surface->HdrMetadata.min_luminance = value;
|
|
|
|
break;
|
|
|
|
case EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT:
|
|
|
|
surface->HdrMetadata.max_cll = value;
|
|
|
|
break;
|
|
|
|
case EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT:
|
|
|
|
surface->HdrMetadata.max_fall = value;
|
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
default:
|
2010-01-31 09:56:30 +00:00
|
|
|
err = EGL_BAD_ATTRIBUTE;
|
|
|
|
break;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
2010-01-31 09:56:30 +00:00
|
|
|
|
|
|
|
if (err != EGL_SUCCESS)
|
|
|
|
return _eglError(err, "eglSurfaceAttrib");
|
2005-04-22 22:09:39 +01:00
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface,
|
2008-09-01 20:08:12 +01:00
|
|
|
EGLint buffer)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
2010-05-07 03:40:25 +01:00
|
|
|
EGLint texture_type = EGL_PBUFFER_BIT;
|
|
|
|
|
2008-09-01 20:08:12 +01:00
|
|
|
/* Just do basic error checking and return success/fail.
|
|
|
|
* Drivers must implement the real stuff.
|
|
|
|
*/
|
|
|
|
|
2019-02-02 11:38:45 +00:00
|
|
|
if (disp->Extensions.NOK_texture_from_pixmap)
|
2010-05-07 03:40:25 +01:00
|
|
|
texture_type |= EGL_PIXMAP_BIT;
|
|
|
|
|
2017-06-20 15:40:28 +01:00
|
|
|
if (!(surface->Type & texture_type))
|
|
|
|
return _eglError(EGL_BAD_SURFACE, "eglBindTexImage");
|
2008-09-01 20:08:12 +01:00
|
|
|
|
2017-06-20 15:40:28 +01:00
|
|
|
if (surface->TextureFormat == EGL_NO_TEXTURE)
|
|
|
|
return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
|
2008-09-01 20:08:12 +01:00
|
|
|
|
2017-06-20 15:40:28 +01:00
|
|
|
if (surface->TextureTarget == EGL_NO_TEXTURE)
|
|
|
|
return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
|
2010-05-07 03:40:25 +01:00
|
|
|
|
2017-06-20 15:40:28 +01:00
|
|
|
if (buffer != EGL_BACK_BUFFER)
|
|
|
|
return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage");
|
2008-09-01 20:08:12 +01:00
|
|
|
|
|
|
|
surface->BoundToTexture = EGL_TRUE;
|
|
|
|
|
|
|
|
return EGL_TRUE;
|
2005-04-22 22:09:39 +01:00
|
|
|
}
|
|
|
|
|
2014-02-18 03:04:03 +00:00
|
|
|
EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
|
2014-02-18 03:04:03 +00:00
|
|
|
EGLint buffer)
|
|
|
|
{
|
2016-10-01 00:23:26 +01:00
|
|
|
/* Just do basic error checking and return success/fail.
|
2014-02-18 03:04:03 +00:00
|
|
|
* Drivers must implement the real stuff.
|
|
|
|
*/
|
|
|
|
|
2016-10-01 00:23:26 +01:00
|
|
|
EGLint texture_type = EGL_PBUFFER_BIT;
|
|
|
|
|
|
|
|
if (surf == EGL_NO_SURFACE)
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage");
|
2016-10-01 00:23:26 +01:00
|
|
|
|
|
|
|
if (!surf->BoundToTexture)
|
|
|
|
{
|
|
|
|
/* Not an error, simply nothing to do */
|
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surf->TextureFormat == EGL_NO_TEXTURE)
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_MATCH, "eglReleaseTexImage");
|
2016-10-01 00:23:26 +01:00
|
|
|
|
|
|
|
if (buffer != EGL_BACK_BUFFER)
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage");
|
2016-10-01 00:23:26 +01:00
|
|
|
|
2019-02-02 11:38:45 +00:00
|
|
|
if (disp->Extensions.NOK_texture_from_pixmap)
|
2016-10-01 00:23:26 +01:00
|
|
|
texture_type |= EGL_PIXMAP_BIT;
|
|
|
|
|
|
|
|
if (!(surf->Type & texture_type))
|
2017-06-20 15:40:28 +01:00
|
|
|
return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage");
|
2016-10-01 00:23:26 +01:00
|
|
|
|
|
|
|
surf->BoundToTexture = EGL_FALSE;
|
|
|
|
|
|
|
|
return EGL_TRUE;
|
2014-02-18 03:04:03 +00:00
|
|
|
}
|
|
|
|
|
2005-04-22 22:09:39 +01:00
|
|
|
|
|
|
|
EGLBoolean
|
2019-02-02 11:38:45 +00:00
|
|
|
_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
|
2009-10-15 04:08:48 +01:00
|
|
|
EGLint interval)
|
2005-04-22 22:09:39 +01:00
|
|
|
{
|
|
|
|
return EGL_TRUE;
|
|
|
|
}
|
2018-05-01 06:32:25 +01:00
|
|
|
|
|
|
|
EGLBoolean
|
|
|
|
_eglSurfaceHasMutableRenderBuffer(_EGLSurface *surf)
|
|
|
|
{
|
|
|
|
return surf->Type == EGL_WINDOW_BIT &&
|
|
|
|
surf->Config &&
|
|
|
|
(surf->Config->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR);
|
|
|
|
}
|
|
|
|
|
|
|
|
EGLBoolean
|
|
|
|
_eglSurfaceInSharedBufferMode(_EGLSurface *surf)
|
|
|
|
{
|
|
|
|
return _eglSurfaceHasMutableRenderBuffer(surf) &&
|
|
|
|
surf->ActiveRenderBuffer == EGL_SINGLE_BUFFER;
|
|
|
|
}
|