ANGLE: upgrade to 2.1~07d49ef5350a
This version of ANGLE provides partial ES3 support, numerous bug fixes, and several potentially useful vendor extensions. All patches have been rebased. The following changes are noted: 0000-General-fixes-for-ANGLE-2.1.patch contains compile fixes for the new ANGLE 0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch has incorporated patch 0015. 0007-Make-DX9-DX11-mutually-exclusive.patch has been removed as it was fixed upstream. 0007-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch has been moved up to fill the patch number gap. 0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch now contains patch 0014 and 0017. 0013-ANGLE-Allow-for-universal-program-binaries.patch has been removed as it is no longer relevant. 0014-ANGLE-D3D11-Fix-internal-index-buffer-for-level-9-ha.patch has been merged with patch 0010. 0015-ANGLE-Don-t-export-DLLMain-functions-for-static-buil.patch has been merged with patch 0004. 0016-ANGLE-WinRT-Call-Trim-when-application-suspends.patch has been removed and will be replaced by a follow-up patch using a different technique. 0017-ANGLE-D3D11-Don-t-use-mipmaps-in-level-9-textures.patch has been merged with patch 0010. 0018-ANGLE-WinRT-Create-swap-chain-using-physical-resolut.patch has been removed and will be replaced by a follow-up patch extending the EGL_ANGLE_window_fixed_size extension. 0019-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch is now patch 0007. [ChangeLog][Third-party libraries] ANGLE has been upgraded to version 2.1, bringing partial support for OpenGL ES3 over Direct3D 11, numerous bug fixes, and several new vendor extensions. Change-Id: I6d95ce1480462d67228d83c1e5c74a1706b5b21c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
14f9c09542
commit
a6a12d8c0f
25
src/3rdparty/angle/.gitignore
vendored
25
src/3rdparty/angle/.gitignore
vendored
@ -16,28 +16,17 @@ DEPS
|
||||
*.gypi
|
||||
*.sh
|
||||
*.bat
|
||||
*.patch
|
||||
*.py
|
||||
codereview.settings
|
||||
|
||||
# Generated by flex/bison
|
||||
src/compiler/preprocessor/Tokenizer.cpp
|
||||
src/compiler/preprocessor/ExpressionParser.cpp
|
||||
src/compiler/glslang_lex.cpp
|
||||
src/compiler/glslang_tab.cpp
|
||||
src/compiler/glslang_tab.h
|
||||
src/compiler/translator/glslang_lex.cpp
|
||||
src/compiler/translator/glslang_tab.cpp
|
||||
src/compiler/translator/glslang_tab.h
|
||||
|
||||
# Generated by FXC
|
||||
src/libGLESv2/renderer/shaders/compiled/standardvs.h
|
||||
src/libGLESv2/renderer/shaders/compiled/flipyvs.h
|
||||
src/libGLESv2/renderer/shaders/compiled/luminanceps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/componentmaskps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/passthroughps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/PassthroughRGBA11ps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/PassthroughRGB11ps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/PassthroughLumAlpha11ps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/PassthroughLum11ps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/Passthrough11vs.h
|
||||
src/libGLESv2/renderer/shaders/compiled/clear11vs.h
|
||||
src/libGLESv2/renderer/shaders/compiled/clearmultiple11ps.h
|
||||
src/libGLESv2/renderer/shaders/compiled/clearsingle11ps.h
|
||||
|
||||
|
||||
src/libGLESv2/renderer/d3d/d3d9/shaders/compiled/*.h
|
||||
src/libGLESv2/renderer/d3d/d3d11/shaders/compiled/*.h
|
||||
|
3
src/3rdparty/angle/CONTRIBUTORS
vendored
3
src/3rdparty/angle/CONTRIBUTORS
vendored
@ -52,6 +52,9 @@ Autodesk, Inc.
|
||||
Cloud Party, Inc.
|
||||
Conor Dickinson
|
||||
|
||||
Digia Plc
|
||||
Andrew Knight
|
||||
|
||||
Intel Corporation
|
||||
Jin Yang
|
||||
Andy Chen
|
||||
|
487
src/3rdparty/angle/include/EGL/egl.h
vendored
487
src/3rdparty/angle/include/EGL/egl.h
vendored
@ -1,11 +1,12 @@
|
||||
/* -*- mode: c; tab-width: 8; -*- */
|
||||
/* vi: set sw=4 ts=8: */
|
||||
/* Reference version of egl.h for EGL 1.4.
|
||||
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
|
||||
*/
|
||||
#ifndef __egl_h_
|
||||
#define __egl_h_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2007-2009 The Khronos Group Inc.
|
||||
** Copyright (c) 2013-2014 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -26,56 +27,39 @@
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
#ifndef __egl_h_
|
||||
#define __egl_h_
|
||||
|
||||
/* All platform-dependent types and macro boilerplate (such as EGLAPI
|
||||
* and EGLAPIENTRY) should go in eglplatform.h.
|
||||
/*
|
||||
** This header is generated from the Khronos OpenGL / OpenGL ES XML
|
||||
** API Registry. The current version of the Registry, generator scripts
|
||||
** used to make the header, and the header can be found at
|
||||
** http://www.opengl.org/registry/
|
||||
**
|
||||
** Khronos $Revision: 27018 $ on $Date: 2014-06-10 08:06:12 -0700 (Tue, 10 Jun 2014) $
|
||||
*/
|
||||
|
||||
#include <EGL/eglplatform.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Generated on date 20140610 */
|
||||
|
||||
/* EGL Types */
|
||||
/* EGLint is defined in eglplatform.h */
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
typedef void *EGLConfig;
|
||||
typedef void *EGLContext;
|
||||
typedef void *EGLDisplay;
|
||||
typedef void *EGLSurface;
|
||||
typedef void *EGLClientBuffer;
|
||||
|
||||
/* EGL Versioning */
|
||||
#define EGL_VERSION_1_0 1
|
||||
#define EGL_VERSION_1_1 1
|
||||
#define EGL_VERSION_1_2 1
|
||||
#define EGL_VERSION_1_3 1
|
||||
#define EGL_VERSION_1_4 1
|
||||
|
||||
/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
|
||||
* enums are assigned unique values starting at 0x3000.
|
||||
/* Generated C header for:
|
||||
* API: egl
|
||||
* Versions considered: .*
|
||||
* Versions emitted: .*
|
||||
* Default extensions included: None
|
||||
* Additional extensions included: _nomatch_^
|
||||
* Extensions removed: _nomatch_^
|
||||
*/
|
||||
|
||||
/* EGL aliases */
|
||||
#define EGL_FALSE 0
|
||||
#define EGL_TRUE 1
|
||||
|
||||
/* Out-of-band handle values */
|
||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
||||
#define EGL_NO_CONTEXT ((EGLContext)0)
|
||||
#define EGL_NO_DISPLAY ((EGLDisplay)0)
|
||||
#define EGL_NO_SURFACE ((EGLSurface)0)
|
||||
|
||||
/* Out-of-band attribute value */
|
||||
#define EGL_DONT_CARE ((EGLint)-1)
|
||||
|
||||
/* Errors / GetError return values */
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
#ifndef EGL_VERSION_1_0
|
||||
#define EGL_VERSION_1_0 1
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef void *EGLDisplay;
|
||||
#include <KHR/khrplatform.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
typedef void *EGLConfig;
|
||||
typedef void *EGLSurface;
|
||||
typedef void *EGLContext;
|
||||
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BAD_ACCESS 0x3002
|
||||
#define EGL_BAD_ALLOC 0x3003
|
||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||
@ -88,20 +72,19 @@ typedef void *EGLClientBuffer;
|
||||
#define EGL_BAD_NATIVE_WINDOW 0x300B
|
||||
#define EGL_BAD_PARAMETER 0x300C
|
||||
#define EGL_BAD_SURFACE 0x300D
|
||||
#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */
|
||||
|
||||
/* Reserved 0x300F-0x301F for additional errors */
|
||||
|
||||
/* Config attributes */
|
||||
#define EGL_BUFFER_SIZE 0x3020
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_BUFFER_SIZE 0x3020
|
||||
#define EGL_CONFIG_CAVEAT 0x3027
|
||||
#define EGL_CONFIG_ID 0x3028
|
||||
#define EGL_CORE_NATIVE_ENGINE 0x305B
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_DONT_CARE ((EGLint)-1)
|
||||
#define EGL_DRAW 0x3059
|
||||
#define EGL_EXTENSIONS 0x3055
|
||||
#define EGL_FALSE 0
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_HEIGHT 0x3056
|
||||
#define EGL_LARGEST_PBUFFER 0x3058
|
||||
#define EGL_LEVEL 0x3029
|
||||
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
|
||||
#define EGL_MAX_PBUFFER_PIXELS 0x302B
|
||||
@ -109,221 +92,207 @@ typedef void *EGLClientBuffer;
|
||||
#define EGL_NATIVE_RENDERABLE 0x302D
|
||||
#define EGL_NATIVE_VISUAL_ID 0x302E
|
||||
#define EGL_NATIVE_VISUAL_TYPE 0x302F
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_NON_CONFORMANT_CONFIG 0x3051
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
#define EGL_NO_CONTEXT ((EGLContext)0)
|
||||
#define EGL_NO_DISPLAY ((EGLDisplay)0)
|
||||
#define EGL_NO_SURFACE ((EGLSurface)0)
|
||||
#define EGL_PBUFFER_BIT 0x0001
|
||||
#define EGL_PIXMAP_BIT 0x0002
|
||||
#define EGL_READ 0x305A
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_SAMPLES 0x3031
|
||||
#define EGL_SAMPLE_BUFFERS 0x3032
|
||||
#define EGL_SLOW_CONFIG 0x3050
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_TRANSPARENT_TYPE 0x3034
|
||||
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
|
||||
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
|
||||
#define EGL_TRANSPARENT_RED_VALUE 0x3037
|
||||
#define EGL_NONE 0x3038 /* Attrib list terminator */
|
||||
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
|
||||
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
|
||||
#define EGL_MIN_SWAP_INTERVAL 0x303B
|
||||
#define EGL_MAX_SWAP_INTERVAL 0x303C
|
||||
#define EGL_LUMINANCE_SIZE 0x303D
|
||||
#define EGL_ALPHA_MASK_SIZE 0x303E
|
||||
#define EGL_COLOR_BUFFER_TYPE 0x303F
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */
|
||||
#define EGL_CONFORMANT 0x3042
|
||||
|
||||
/* Reserved 0x3041-0x304F for additional config attributes */
|
||||
|
||||
/* Config attribute values */
|
||||
#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
|
||||
#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */
|
||||
#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
|
||||
#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */
|
||||
#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */
|
||||
|
||||
/* More config attribute values, for EGL_TEXTURE_FORMAT */
|
||||
#define EGL_NO_TEXTURE 0x305C
|
||||
#define EGL_TEXTURE_RGB 0x305D
|
||||
#define EGL_TEXTURE_RGBA 0x305E
|
||||
#define EGL_TEXTURE_2D 0x305F
|
||||
|
||||
/* Config attribute mask bits */
|
||||
#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */
|
||||
#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */
|
||||
#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */
|
||||
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
|
||||
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
|
||||
|
||||
#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */
|
||||
#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */
|
||||
#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */
|
||||
#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */
|
||||
|
||||
/* QueryString targets */
|
||||
#define EGL_TRANSPARENT_RGB 0x3052
|
||||
#define EGL_TRANSPARENT_TYPE 0x3034
|
||||
#define EGL_TRUE 1
|
||||
#define EGL_VENDOR 0x3053
|
||||
#define EGL_VERSION 0x3054
|
||||
#define EGL_EXTENSIONS 0x3055
|
||||
#define EGL_CLIENT_APIS 0x308D
|
||||
|
||||
/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
|
||||
#define EGL_HEIGHT 0x3056
|
||||
#define EGL_WIDTH 0x3057
|
||||
#define EGL_LARGEST_PBUFFER 0x3058
|
||||
#define EGL_TEXTURE_FORMAT 0x3080
|
||||
#define EGL_TEXTURE_TARGET 0x3081
|
||||
#define EGL_MIPMAP_TEXTURE 0x3082
|
||||
#define EGL_MIPMAP_LEVEL 0x3083
|
||||
#define EGL_RENDER_BUFFER 0x3086
|
||||
#define EGL_VG_COLORSPACE 0x3087
|
||||
#define EGL_VG_ALPHA_FORMAT 0x3088
|
||||
#define EGL_HORIZONTAL_RESOLUTION 0x3090
|
||||
#define EGL_VERTICAL_RESOLUTION 0x3091
|
||||
#define EGL_PIXEL_ASPECT_RATIO 0x3092
|
||||
#define EGL_SWAP_BEHAVIOR 0x3093
|
||||
#define EGL_MULTISAMPLE_RESOLVE 0x3099
|
||||
|
||||
/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
|
||||
#define EGL_BACK_BUFFER 0x3084
|
||||
#define EGL_SINGLE_BUFFER 0x3085
|
||||
|
||||
/* OpenVG color spaces */
|
||||
#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */
|
||||
#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */
|
||||
|
||||
/* OpenVG alpha formats */
|
||||
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */
|
||||
|
||||
/* Constant scale factor by which fractional display resolutions &
|
||||
* aspect ratio are scaled when queried as integer values.
|
||||
*/
|
||||
#define EGL_DISPLAY_SCALING 10000
|
||||
|
||||
/* Unknown display resolution/aspect ratio */
|
||||
#define EGL_UNKNOWN ((EGLint)-1)
|
||||
|
||||
/* Back buffer swap behaviors */
|
||||
#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
|
||||
#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */
|
||||
|
||||
/* CreatePbufferFromClientBuffer buffer types */
|
||||
#define EGL_OPENVG_IMAGE 0x3096
|
||||
|
||||
/* QueryContext targets */
|
||||
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
|
||||
|
||||
/* CreateContext attributes */
|
||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||
|
||||
/* Multisample resolution behaviors */
|
||||
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */
|
||||
|
||||
/* BindAPI/QueryAPI targets */
|
||||
#define EGL_OPENGL_ES_API 0x30A0
|
||||
#define EGL_OPENVG_API 0x30A1
|
||||
#define EGL_OPENGL_API 0x30A2
|
||||
|
||||
/* GetCurrentSurface targets */
|
||||
#define EGL_DRAW 0x3059
|
||||
#define EGL_READ 0x305A
|
||||
|
||||
/* WaitNative engines */
|
||||
#define EGL_CORE_NATIVE_ENGINE 0x305B
|
||||
|
||||
/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
|
||||
#define EGL_COLORSPACE EGL_VG_COLORSPACE
|
||||
#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT
|
||||
#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB
|
||||
#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR
|
||||
#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE
|
||||
#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE
|
||||
|
||||
/* EGL extensions must request enum blocks from the Khronos
|
||||
* API Registrar, who maintains the enumerant registry. Submit
|
||||
* a bug in Khronos Bugzilla against task "Registry".
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* EGL Functions */
|
||||
|
||||
EGLAPI EGLint EGLAPIENTRY eglGetError(void);
|
||||
|
||||
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
|
||||
|
||||
EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
|
||||
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
|
||||
EGLint config_size, EGLint *num_config);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
|
||||
EGLConfig *configs, EGLint config_size,
|
||||
EGLint *num_config);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
|
||||
EGLint attribute, EGLint *value);
|
||||
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
|
||||
EGLNativeWindowType win,
|
||||
const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
|
||||
const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
|
||||
EGLNativePixmapType pixmap,
|
||||
const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
|
||||
EGLint attribute, EGLint *value);
|
||||
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
|
||||
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
|
||||
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
|
||||
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
|
||||
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
|
||||
EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
|
||||
EGLConfig config, const EGLint *attrib_list);
|
||||
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
|
||||
EGLint attribute, EGLint value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
|
||||
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
|
||||
|
||||
|
||||
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
|
||||
EGLContext share_context,
|
||||
const EGLint *attrib_list);
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
|
||||
EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
|
||||
EGLSurface read, EGLContext ctx);
|
||||
|
||||
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
|
||||
EGLint attribute, EGLint *value);
|
||||
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw);
|
||||
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id);
|
||||
EGLAPI EGLint EGLAPIENTRY eglGetError (void);
|
||||
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
|
||||
EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
|
||||
EGLNativePixmapType target);
|
||||
#endif /* EGL_VERSION_1_0 */
|
||||
|
||||
/* This is a generic function pointer type, whose name indicates it must
|
||||
* be cast to the proper type *and calling convention* before use.
|
||||
*/
|
||||
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
|
||||
#ifndef EGL_VERSION_1_1
|
||||
#define EGL_VERSION_1_1 1
|
||||
#define EGL_BACK_BUFFER 0x3084
|
||||
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
|
||||
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
|
||||
#define EGL_CONTEXT_LOST 0x300E
|
||||
#define EGL_MIN_SWAP_INTERVAL 0x303B
|
||||
#define EGL_MAX_SWAP_INTERVAL 0x303C
|
||||
#define EGL_MIPMAP_TEXTURE 0x3082
|
||||
#define EGL_MIPMAP_LEVEL 0x3083
|
||||
#define EGL_NO_TEXTURE 0x305C
|
||||
#define EGL_TEXTURE_2D 0x305F
|
||||
#define EGL_TEXTURE_FORMAT 0x3080
|
||||
#define EGL_TEXTURE_RGB 0x305D
|
||||
#define EGL_TEXTURE_RGBA 0x305E
|
||||
#define EGL_TEXTURE_TARGET 0x3081
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval);
|
||||
#endif /* EGL_VERSION_1_1 */
|
||||
|
||||
/* Now, define eglGetProcAddress using the generic function ptr. type */
|
||||
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
|
||||
eglGetProcAddress(const char *procname);
|
||||
#ifndef EGL_VERSION_1_2
|
||||
#define EGL_VERSION_1_2 1
|
||||
typedef unsigned int EGLenum;
|
||||
typedef void *EGLClientBuffer;
|
||||
#define EGL_ALPHA_FORMAT 0x3088
|
||||
#define EGL_ALPHA_FORMAT_NONPRE 0x308B
|
||||
#define EGL_ALPHA_FORMAT_PRE 0x308C
|
||||
#define EGL_ALPHA_MASK_SIZE 0x303E
|
||||
#define EGL_BUFFER_PRESERVED 0x3094
|
||||
#define EGL_BUFFER_DESTROYED 0x3095
|
||||
#define EGL_CLIENT_APIS 0x308D
|
||||
#define EGL_COLORSPACE 0x3087
|
||||
#define EGL_COLORSPACE_sRGB 0x3089
|
||||
#define EGL_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_COLOR_BUFFER_TYPE 0x303F
|
||||
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
|
||||
#define EGL_DISPLAY_SCALING 10000
|
||||
#define EGL_HORIZONTAL_RESOLUTION 0x3090
|
||||
#define EGL_LUMINANCE_BUFFER 0x308F
|
||||
#define EGL_LUMINANCE_SIZE 0x303D
|
||||
#define EGL_OPENGL_ES_BIT 0x0001
|
||||
#define EGL_OPENVG_BIT 0x0002
|
||||
#define EGL_OPENGL_ES_API 0x30A0
|
||||
#define EGL_OPENVG_API 0x30A1
|
||||
#define EGL_OPENVG_IMAGE 0x3096
|
||||
#define EGL_PIXEL_ASPECT_RATIO 0x3092
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_RENDER_BUFFER 0x3086
|
||||
#define EGL_RGB_BUFFER 0x308E
|
||||
#define EGL_SINGLE_BUFFER 0x3085
|
||||
#define EGL_SWAP_BEHAVIOR 0x3093
|
||||
#define EGL_UNKNOWN ((EGLint)-1)
|
||||
#define EGL_VERTICAL_RESOLUTION 0x3091
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api);
|
||||
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
|
||||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
#ifndef EGL_VERSION_1_3
|
||||
#define EGL_VERSION_1_3 1
|
||||
#define EGL_CONFORMANT 0x3042
|
||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||
#define EGL_MATCH_NATIVE_PIXMAP 0x3041
|
||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||
#define EGL_VG_ALPHA_FORMAT 0x3088
|
||||
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040
|
||||
#define EGL_VG_COLORSPACE 0x3087
|
||||
#define EGL_VG_COLORSPACE_sRGB 0x3089
|
||||
#define EGL_VG_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020
|
||||
#endif /* EGL_VERSION_1_3 */
|
||||
|
||||
#ifndef EGL_VERSION_1_4
|
||||
#define EGL_VERSION_1_4 1
|
||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200
|
||||
#define EGL_MULTISAMPLE_RESOLVE 0x3099
|
||||
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B
|
||||
#define EGL_OPENGL_API 0x30A2
|
||||
#define EGL_OPENGL_BIT 0x0008
|
||||
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400
|
||||
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void);
|
||||
#endif /* EGL_VERSION_1_4 */
|
||||
|
||||
#ifndef EGL_VERSION_1_5
|
||||
#define EGL_VERSION_1_5 1
|
||||
typedef void *EGLSync;
|
||||
typedef khronos_intptr_t EGLAttrib;
|
||||
typedef khronos_utime_nanoseconds_t EGLTime;
|
||||
#define EGL_CONTEXT_MAJOR_VERSION 0x3098
|
||||
#define EGL_CONTEXT_MINOR_VERSION 0x30FB
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
|
||||
#define EGL_NO_RESET_NOTIFICATION 0x31BE
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2
|
||||
#define EGL_OPENGL_ES3_BIT 0x00000040
|
||||
#define EGL_CL_EVENT_HANDLE 0x309C
|
||||
#define EGL_SYNC_CL_EVENT 0x30FE
|
||||
#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF
|
||||
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0
|
||||
#define EGL_SYNC_TYPE 0x30F7
|
||||
#define EGL_SYNC_STATUS 0x30F1
|
||||
#define EGL_SYNC_CONDITION 0x30F8
|
||||
#define EGL_SIGNALED 0x30F2
|
||||
#define EGL_UNSIGNALED 0x30F3
|
||||
#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001
|
||||
#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull
|
||||
#define EGL_TIMEOUT_EXPIRED 0x30F5
|
||||
#define EGL_CONDITION_SATISFIED 0x30F6
|
||||
#define EGL_NO_SYNC ((EGLSync)0)
|
||||
#define EGL_SYNC_FENCE 0x30F9
|
||||
#define EGL_GL_COLORSPACE 0x309D
|
||||
#define EGL_GL_COLORSPACE_SRGB 0x3089
|
||||
#define EGL_GL_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_GL_RENDERBUFFER 0x30B9
|
||||
#define EGL_GL_TEXTURE_2D 0x30B1
|
||||
#define EGL_GL_TEXTURE_LEVEL 0x30BC
|
||||
#define EGL_GL_TEXTURE_3D 0x30B2
|
||||
#define EGL_GL_TEXTURE_ZOFFSET 0x30BD
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
|
||||
EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync);
|
||||
EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
|
||||
EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags);
|
||||
#endif /* EGL_VERSION_1_5 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __egl_h_ */
|
||||
#endif
|
||||
|
866
src/3rdparty/angle/include/EGL/eglext.h
vendored
866
src/3rdparty/angle/include/EGL/eglext.h
vendored
@ -1,12 +1,12 @@
|
||||
#ifndef __eglext_h_
|
||||
#define __eglext_h_
|
||||
#define __eglext_h_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2007-2012 The Khronos Group Inc.
|
||||
** Copyright (c) 2013-2014 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -27,106 +27,211 @@ extern "C" {
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
/*
|
||||
** This header is generated from the Khronos OpenGL / OpenGL ES XML
|
||||
** API Registry. The current version of the Registry, generator scripts
|
||||
** used to make the header, and the header can be found at
|
||||
** http://www.opengl.org/registry/
|
||||
**
|
||||
** Khronos $Revision: 27018 $ on $Date: 2014-06-10 08:06:12 -0700 (Tue, 10 Jun 2014) $
|
||||
*/
|
||||
|
||||
#include <EGL/eglplatform.h>
|
||||
|
||||
/*************************************************************/
|
||||
#define EGL_EGLEXT_VERSION 20140610
|
||||
|
||||
/* Header file version number */
|
||||
/* Current version at http://www.khronos.org/registry/egl/ */
|
||||
/* $Revision: 16473 $ on $Date: 2012-01-04 02:20:48 -0800 (Wed, 04 Jan 2012) $ */
|
||||
#define EGL_EGLEXT_VERSION 11
|
||||
/* Generated C header for:
|
||||
* API: egl
|
||||
* Versions considered: .*
|
||||
* Versions emitted: _nomatch_^
|
||||
* Default extensions included: egl
|
||||
* Additional extensions included: _nomatch_^
|
||||
* Extensions removed: _nomatch_^
|
||||
*/
|
||||
|
||||
#ifndef EGL_KHR_cl_event
|
||||
#define EGL_KHR_cl_event 1
|
||||
#define EGL_CL_EVENT_HANDLE_KHR 0x309C
|
||||
#define EGL_SYNC_CL_EVENT_KHR 0x30FE
|
||||
#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF
|
||||
#endif /* EGL_KHR_cl_event */
|
||||
|
||||
#ifndef EGL_KHR_cl_event2
|
||||
#define EGL_KHR_cl_event2 1
|
||||
typedef void *EGLSyncKHR;
|
||||
typedef khronos_intptr_t EGLAttribKHR;
|
||||
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list);
|
||||
#endif
|
||||
#endif /* EGL_KHR_cl_event2 */
|
||||
|
||||
#ifndef EGL_KHR_client_get_all_proc_addresses
|
||||
#define EGL_KHR_client_get_all_proc_addresses 1
|
||||
#endif /* EGL_KHR_client_get_all_proc_addresses */
|
||||
|
||||
#ifndef EGL_KHR_config_attribs
|
||||
#define EGL_KHR_config_attribs 1
|
||||
#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */
|
||||
#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */
|
||||
#endif
|
||||
#define EGL_CONFORMANT_KHR 0x3042
|
||||
#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040
|
||||
#endif /* EGL_KHR_config_attribs */
|
||||
|
||||
#ifndef EGL_KHR_lock_surface
|
||||
#define EGL_KHR_lock_surface 1
|
||||
#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
|
||||
#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
|
||||
#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */
|
||||
#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */
|
||||
#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */
|
||||
#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */
|
||||
#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */
|
||||
#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */
|
||||
#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */
|
||||
#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */
|
||||
#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */
|
||||
#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */
|
||||
#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */
|
||||
#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */
|
||||
#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
|
||||
#endif
|
||||
#ifndef EGL_KHR_create_context
|
||||
#define EGL_KHR_create_context 1
|
||||
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
|
||||
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
|
||||
#define EGL_CONTEXT_FLAGS_KHR 0x30FC
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
|
||||
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
||||
#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
|
||||
#endif /* EGL_KHR_create_context */
|
||||
|
||||
#ifndef EGL_KHR_image
|
||||
#define EGL_KHR_image 1
|
||||
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
|
||||
typedef void *EGLImageKHR;
|
||||
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
|
||||
#endif
|
||||
#ifndef EGL_KHR_fence_sync
|
||||
#define EGL_KHR_fence_sync 1
|
||||
#ifdef KHRONOS_SUPPORT_INT64
|
||||
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
|
||||
#define EGL_SYNC_CONDITION_KHR 0x30F8
|
||||
#define EGL_SYNC_FENCE_KHR 0x30F9
|
||||
#endif /* KHRONOS_SUPPORT_INT64 */
|
||||
#endif /* EGL_KHR_fence_sync */
|
||||
|
||||
#ifndef EGL_KHR_vg_parent_image
|
||||
#define EGL_KHR_vg_parent_image 1
|
||||
#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */
|
||||
#endif
|
||||
#ifndef EGL_KHR_get_all_proc_addresses
|
||||
#define EGL_KHR_get_all_proc_addresses 1
|
||||
#endif /* EGL_KHR_get_all_proc_addresses */
|
||||
|
||||
#ifndef EGL_KHR_gl_texture_2D_image
|
||||
#define EGL_KHR_gl_texture_2D_image 1
|
||||
#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */
|
||||
#endif
|
||||
|
||||
#ifndef EGL_KHR_gl_texture_cubemap_image
|
||||
#define EGL_KHR_gl_texture_cubemap_image 1
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */
|
||||
#endif
|
||||
|
||||
#ifndef EGL_KHR_gl_texture_3D_image
|
||||
#define EGL_KHR_gl_texture_3D_image 1
|
||||
#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */
|
||||
#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */
|
||||
#endif
|
||||
#ifndef EGL_KHR_gl_colorspace
|
||||
#define EGL_KHR_gl_colorspace 1
|
||||
#define EGL_GL_COLORSPACE_KHR 0x309D
|
||||
#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
|
||||
#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A
|
||||
#endif /* EGL_KHR_gl_colorspace */
|
||||
|
||||
#ifndef EGL_KHR_gl_renderbuffer_image
|
||||
#define EGL_KHR_gl_renderbuffer_image 1
|
||||
#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
|
||||
#endif
|
||||
#define EGL_GL_RENDERBUFFER_KHR 0x30B9
|
||||
#endif /* EGL_KHR_gl_renderbuffer_image */
|
||||
|
||||
#ifndef EGL_KHR_gl_texture_2D_image
|
||||
#define EGL_KHR_gl_texture_2D_image 1
|
||||
#define EGL_GL_TEXTURE_2D_KHR 0x30B1
|
||||
#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC
|
||||
#endif /* EGL_KHR_gl_texture_2D_image */
|
||||
|
||||
#ifndef EGL_KHR_gl_texture_3D_image
|
||||
#define EGL_KHR_gl_texture_3D_image 1
|
||||
#define EGL_GL_TEXTURE_3D_KHR 0x30B2
|
||||
#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD
|
||||
#endif /* EGL_KHR_gl_texture_3D_image */
|
||||
|
||||
#ifndef EGL_KHR_gl_texture_cubemap_image
|
||||
#define EGL_KHR_gl_texture_cubemap_image 1
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8
|
||||
#endif /* EGL_KHR_gl_texture_cubemap_image */
|
||||
|
||||
#ifndef EGL_KHR_image
|
||||
#define EGL_KHR_image 1
|
||||
typedef void *EGLImageKHR;
|
||||
#define EGL_NATIVE_PIXMAP_KHR 0x30B0
|
||||
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
|
||||
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
|
||||
#endif
|
||||
#endif /* EGL_KHR_image */
|
||||
|
||||
#ifndef EGL_KHR_image_base
|
||||
#define EGL_KHR_image_base 1
|
||||
#define EGL_IMAGE_PRESERVED_KHR 0x30D2
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
||||
#ifndef EGL_KHR_image_pixmap
|
||||
#define EGL_KHR_image_pixmap 1
|
||||
#endif /* EGL_KHR_image_pixmap */
|
||||
|
||||
#ifndef EGL_KHR_lock_surface
|
||||
#define EGL_KHR_lock_surface 1
|
||||
#define EGL_READ_SURFACE_BIT_KHR 0x0001
|
||||
#define EGL_WRITE_SURFACE_BIT_KHR 0x0002
|
||||
#define EGL_LOCK_SURFACE_BIT_KHR 0x0080
|
||||
#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100
|
||||
#define EGL_MATCH_FORMAT_KHR 0x3043
|
||||
#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0
|
||||
#define EGL_FORMAT_RGB_565_KHR 0x30C1
|
||||
#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2
|
||||
#define EGL_FORMAT_RGBA_8888_KHR 0x30C3
|
||||
#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4
|
||||
#define EGL_LOCK_USAGE_HINT_KHR 0x30C5
|
||||
#define EGL_BITMAP_POINTER_KHR 0x30C6
|
||||
#define EGL_BITMAP_PITCH_KHR 0x30C7
|
||||
#define EGL_BITMAP_ORIGIN_KHR 0x30C8
|
||||
#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9
|
||||
#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA
|
||||
#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB
|
||||
#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC
|
||||
#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD
|
||||
#define EGL_LOWER_LEFT_KHR 0x30CE
|
||||
#define EGL_UPPER_LEFT_KHR 0x30CF
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface);
|
||||
#endif
|
||||
#endif /* EGL_KHR_lock_surface */
|
||||
|
||||
#ifndef EGL_KHR_lock_surface2
|
||||
#define EGL_KHR_lock_surface2 1
|
||||
#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
|
||||
#endif /* EGL_KHR_lock_surface2 */
|
||||
|
||||
#ifndef EGL_KHR_lock_surface3
|
||||
#define EGL_KHR_lock_surface3 1
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value);
|
||||
#endif
|
||||
#endif /* EGL_KHR_lock_surface3 */
|
||||
|
||||
#ifndef EGL_KHR_platform_android
|
||||
#define EGL_KHR_platform_android 1
|
||||
#define EGL_PLATFORM_ANDROID_KHR 0x3141
|
||||
#endif /* EGL_KHR_platform_android */
|
||||
|
||||
#ifndef EGL_KHR_platform_gbm
|
||||
#define EGL_KHR_platform_gbm 1
|
||||
#define EGL_PLATFORM_GBM_KHR 0x31D7
|
||||
#endif /* EGL_KHR_platform_gbm */
|
||||
|
||||
#ifndef EGL_KHR_platform_wayland
|
||||
#define EGL_KHR_platform_wayland 1
|
||||
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
|
||||
#endif /* EGL_KHR_platform_wayland */
|
||||
|
||||
#ifndef EGL_KHR_platform_x11
|
||||
#define EGL_KHR_platform_x11 1
|
||||
#define EGL_PLATFORM_X11_KHR 0x31D5
|
||||
#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6
|
||||
#endif /* EGL_KHR_platform_x11 */
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
|
||||
#ifndef EGL_KHR_reusable_sync
|
||||
#define EGL_KHR_reusable_sync 1
|
||||
|
||||
typedef void* EGLSyncKHR;
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
|
||||
|
||||
#ifdef KHRONOS_SUPPORT_INT64
|
||||
#define EGL_SYNC_STATUS_KHR 0x30F1
|
||||
#define EGL_SIGNALED_KHR 0x30F2
|
||||
#define EGL_UNSIGNALED_KHR 0x30F3
|
||||
@ -134,34 +239,359 @@ typedef khronos_utime_nanoseconds_t EGLTimeKHR;
|
||||
#define EGL_CONDITION_SATISFIED_KHR 0x30F6
|
||||
#define EGL_SYNC_TYPE_KHR 0x30F7
|
||||
#define EGL_SYNC_REUSABLE_KHR 0x30FA
|
||||
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */
|
||||
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001
|
||||
#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
|
||||
#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
|
||||
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
|
||||
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync);
|
||||
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
|
||||
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* KHRONOS_SUPPORT_INT64 */
|
||||
#endif /* EGL_KHR_reusable_sync */
|
||||
|
||||
#ifndef EGL_KHR_image_base
|
||||
#define EGL_KHR_image_base 1
|
||||
/* Most interfaces defined by EGL_KHR_image_pixmap above */
|
||||
#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */
|
||||
#ifndef EGL_KHR_stream
|
||||
#define EGL_KHR_stream 1
|
||||
typedef void *EGLStreamKHR;
|
||||
typedef khronos_uint64_t EGLuint64KHR;
|
||||
#ifdef KHRONOS_SUPPORT_INT64
|
||||
#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
|
||||
#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
|
||||
#define EGL_PRODUCER_FRAME_KHR 0x3212
|
||||
#define EGL_CONSUMER_FRAME_KHR 0x3213
|
||||
#define EGL_STREAM_STATE_KHR 0x3214
|
||||
#define EGL_STREAM_STATE_CREATED_KHR 0x3215
|
||||
#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216
|
||||
#define EGL_STREAM_STATE_EMPTY_KHR 0x3217
|
||||
#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218
|
||||
#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219
|
||||
#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A
|
||||
#define EGL_BAD_STREAM_KHR 0x321B
|
||||
#define EGL_BAD_STATE_KHR 0x321C
|
||||
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
|
||||
#endif
|
||||
#endif /* KHRONOS_SUPPORT_INT64 */
|
||||
#endif /* EGL_KHR_stream */
|
||||
|
||||
#ifndef EGL_KHR_image_pixmap
|
||||
#define EGL_KHR_image_pixmap 1
|
||||
/* Interfaces defined by EGL_KHR_image above */
|
||||
#ifndef EGL_KHR_stream_consumer_gltexture
|
||||
#define EGL_KHR_stream_consumer_gltexture 1
|
||||
#ifdef EGL_KHR_stream
|
||||
#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
#endif
|
||||
#endif /* EGL_KHR_stream */
|
||||
#endif /* EGL_KHR_stream_consumer_gltexture */
|
||||
|
||||
#ifndef EGL_KHR_stream_cross_process_fd
|
||||
#define EGL_KHR_stream_cross_process_fd 1
|
||||
typedef int EGLNativeFileDescriptorKHR;
|
||||
#ifdef EGL_KHR_stream
|
||||
#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
|
||||
typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream);
|
||||
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
|
||||
#endif
|
||||
#endif /* EGL_KHR_stream */
|
||||
#endif /* EGL_KHR_stream_cross_process_fd */
|
||||
|
||||
#ifndef EGL_KHR_stream_fifo
|
||||
#define EGL_KHR_stream_fifo 1
|
||||
#ifdef EGL_KHR_stream
|
||||
#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC
|
||||
#define EGL_STREAM_TIME_NOW_KHR 0x31FD
|
||||
#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE
|
||||
#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
|
||||
#endif
|
||||
#endif /* EGL_KHR_stream */
|
||||
#endif /* EGL_KHR_stream_fifo */
|
||||
|
||||
#ifndef EGL_KHR_stream_producer_aldatalocator
|
||||
#define EGL_KHR_stream_producer_aldatalocator 1
|
||||
#ifdef EGL_KHR_stream
|
||||
#endif /* EGL_KHR_stream */
|
||||
#endif /* EGL_KHR_stream_producer_aldatalocator */
|
||||
|
||||
#ifndef EGL_KHR_stream_producer_eglsurface
|
||||
#define EGL_KHR_stream_producer_eglsurface 1
|
||||
#ifdef EGL_KHR_stream
|
||||
#define EGL_STREAM_BIT_KHR 0x0800
|
||||
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
|
||||
#endif
|
||||
#endif /* EGL_KHR_stream */
|
||||
#endif /* EGL_KHR_stream_producer_eglsurface */
|
||||
|
||||
#ifndef EGL_KHR_surfaceless_context
|
||||
#define EGL_KHR_surfaceless_context 1
|
||||
#endif /* EGL_KHR_surfaceless_context */
|
||||
|
||||
#ifndef EGL_KHR_vg_parent_image
|
||||
#define EGL_KHR_vg_parent_image 1
|
||||
#define EGL_VG_PARENT_IMAGE_KHR 0x30BA
|
||||
#endif /* EGL_KHR_vg_parent_image */
|
||||
|
||||
#ifndef EGL_KHR_wait_sync
|
||||
#define EGL_KHR_wait_sync 1
|
||||
typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
|
||||
#endif
|
||||
#endif /* EGL_KHR_wait_sync */
|
||||
|
||||
#ifndef EGL_ANDROID_blob_cache
|
||||
#define EGL_ANDROID_blob_cache 1
|
||||
typedef khronos_ssize_t EGLsizeiANDROID;
|
||||
typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
|
||||
typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
|
||||
typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
|
||||
#endif
|
||||
#endif /* EGL_ANDROID_blob_cache */
|
||||
|
||||
#ifndef EGL_ANDROID_framebuffer_target
|
||||
#define EGL_ANDROID_framebuffer_target 1
|
||||
#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147
|
||||
#endif /* EGL_ANDROID_framebuffer_target */
|
||||
|
||||
#ifndef EGL_ANDROID_image_native_buffer
|
||||
#define EGL_ANDROID_image_native_buffer 1
|
||||
#define EGL_NATIVE_BUFFER_ANDROID 0x3140
|
||||
#endif /* EGL_ANDROID_image_native_buffer */
|
||||
|
||||
#ifndef EGL_ANDROID_native_fence_sync
|
||||
#define EGL_ANDROID_native_fence_sync 1
|
||||
#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
|
||||
#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
|
||||
#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
|
||||
#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
|
||||
typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync);
|
||||
#endif
|
||||
#endif /* EGL_ANDROID_native_fence_sync */
|
||||
|
||||
#ifndef EGL_ANDROID_recordable
|
||||
#define EGL_ANDROID_recordable 1
|
||||
#define EGL_RECORDABLE_ANDROID 0x3142
|
||||
#endif /* EGL_ANDROID_recordable */
|
||||
|
||||
#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
|
||||
#define EGL_ANGLE_d3d_share_handle_client_buffer 1
|
||||
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
|
||||
#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */
|
||||
|
||||
#ifndef EGL_ANGLE_window_fixed_size
|
||||
#define EGL_ANGLE_window_fixed_size 1
|
||||
#define EGL_FIXED_SIZE_ANGLE 0x3201
|
||||
#endif /* EGL_ANGLE_window_fixed_size */
|
||||
|
||||
#ifndef EGL_ANGLE_query_surface_pointer
|
||||
#define EGL_ANGLE_query_surface_pointer 1
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
|
||||
#endif
|
||||
#endif /* EGL_ANGLE_query_surface_pointer */
|
||||
|
||||
#ifndef EGL_ANGLE_software_display
|
||||
#define EGL_ANGLE_software_display 1
|
||||
#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
|
||||
#endif /* EGL_ANGLE_software_display */
|
||||
|
||||
#ifndef EGL_ANGLE_direct3d_display
|
||||
#define EGL_ANGLE_direct3d_display 1
|
||||
#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2)
|
||||
#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3)
|
||||
#endif /* EGL_ANGLE_direct3d_display */
|
||||
|
||||
#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
|
||||
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
|
||||
#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */
|
||||
|
||||
#ifndef EGL_ANGLE_platform_angle
|
||||
#define EGL_ANGLE_platform_angle 1
|
||||
#define EGL_PLATFORM_ANGLE_ANGLE 0x3201
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3202
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3203
|
||||
#endif /* EGL_ANGLE_platform_angle */
|
||||
|
||||
#ifndef EGL_ANGLE_platform_angle_d3d
|
||||
#define EGL_ANGLE_platform_angle_d3d 1
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3204
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3205
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE 0x3206
|
||||
#endif /* EGL_ANGLE_platform_angle_d3d */
|
||||
|
||||
#ifndef EGL_ANGLE_platform_angle_opengl
|
||||
#define EGL_ANGLE_platform_angle_opengl 1
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x3207
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x3208
|
||||
#endif /* EGL_ANGLE_platform_angle_opengl */
|
||||
|
||||
#ifndef EGL_ARM_pixmap_multisample_discard
|
||||
#define EGL_ARM_pixmap_multisample_discard 1
|
||||
#define EGL_DISCARD_SAMPLES_ARM 0x3286
|
||||
#endif /* EGL_ARM_pixmap_multisample_discard */
|
||||
|
||||
#ifndef EGL_EXT_buffer_age
|
||||
#define EGL_EXT_buffer_age 1
|
||||
#define EGL_BUFFER_AGE_EXT 0x313D
|
||||
#endif /* EGL_EXT_buffer_age */
|
||||
|
||||
#ifndef EGL_EXT_client_extensions
|
||||
#define EGL_EXT_client_extensions 1
|
||||
#endif /* EGL_EXT_client_extensions */
|
||||
|
||||
#ifndef EGL_EXT_create_context_robustness
|
||||
#define EGL_EXT_create_context_robustness 1
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
|
||||
#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF
|
||||
#endif /* EGL_EXT_create_context_robustness */
|
||||
|
||||
#ifndef EGL_EXT_device_base
|
||||
#define EGL_EXT_device_base 1
|
||||
typedef void *EGLDeviceEXT;
|
||||
#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0))
|
||||
#define EGL_BAD_DEVICE_EXT 0x322B
|
||||
#define EGL_DEVICE_EXT 0x322C
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value);
|
||||
typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value);
|
||||
EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
|
||||
#endif
|
||||
#endif /* EGL_EXT_device_base */
|
||||
|
||||
#ifndef EGL_EXT_image_dma_buf_import
|
||||
#define EGL_EXT_image_dma_buf_import 1
|
||||
#define EGL_LINUX_DMA_BUF_EXT 0x3270
|
||||
#define EGL_LINUX_DRM_FOURCC_EXT 0x3271
|
||||
#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272
|
||||
#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273
|
||||
#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274
|
||||
#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275
|
||||
#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276
|
||||
#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277
|
||||
#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278
|
||||
#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279
|
||||
#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A
|
||||
#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B
|
||||
#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C
|
||||
#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D
|
||||
#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E
|
||||
#define EGL_ITU_REC601_EXT 0x327F
|
||||
#define EGL_ITU_REC709_EXT 0x3280
|
||||
#define EGL_ITU_REC2020_EXT 0x3281
|
||||
#define EGL_YUV_FULL_RANGE_EXT 0x3282
|
||||
#define EGL_YUV_NARROW_RANGE_EXT 0x3283
|
||||
#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284
|
||||
#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285
|
||||
#endif /* EGL_EXT_image_dma_buf_import */
|
||||
|
||||
#ifndef EGL_EXT_multiview_window
|
||||
#define EGL_EXT_multiview_window 1
|
||||
#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
|
||||
#endif /* EGL_EXT_multiview_window */
|
||||
|
||||
#ifndef EGL_EXT_platform_base
|
||||
#define EGL_EXT_platform_base 1
|
||||
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
|
||||
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
|
||||
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list);
|
||||
#endif
|
||||
#endif /* EGL_EXT_platform_base */
|
||||
|
||||
#ifndef EGL_EXT_platform_device
|
||||
#define EGL_EXT_platform_device 1
|
||||
#define EGL_PLATFORM_DEVICE_EXT 0x313F
|
||||
#endif /* EGL_EXT_platform_device */
|
||||
|
||||
#ifndef EGL_EXT_platform_wayland
|
||||
#define EGL_EXT_platform_wayland 1
|
||||
#define EGL_PLATFORM_WAYLAND_EXT 0x31D8
|
||||
#endif /* EGL_EXT_platform_wayland */
|
||||
|
||||
#ifndef EGL_EXT_platform_x11
|
||||
#define EGL_EXT_platform_x11 1
|
||||
#define EGL_PLATFORM_X11_EXT 0x31D5
|
||||
#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6
|
||||
#endif /* EGL_EXT_platform_x11 */
|
||||
|
||||
#ifndef EGL_EXT_protected_surface
|
||||
#define EGL_EXT_protected_surface 1
|
||||
#define EGL_PROTECTED_CONTENT_EXT 0x32C0
|
||||
#endif /* EGL_EXT_protected_surface */
|
||||
|
||||
#ifndef EGL_EXT_swap_buffers_with_damage
|
||||
#define EGL_EXT_swap_buffers_with_damage 1
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
|
||||
#endif
|
||||
#endif /* EGL_EXT_swap_buffers_with_damage */
|
||||
|
||||
#ifndef EGL_HI_clientpixmap
|
||||
#define EGL_HI_clientpixmap 1
|
||||
struct EGLClientPixmapHI {
|
||||
void *pData;
|
||||
EGLint iWidth;
|
||||
EGLint iHeight;
|
||||
EGLint iStride;
|
||||
};
|
||||
#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
|
||||
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap);
|
||||
#endif
|
||||
#endif /* EGL_HI_clientpixmap */
|
||||
|
||||
#ifndef EGL_HI_colorformats
|
||||
#define EGL_HI_colorformats 1
|
||||
#define EGL_COLOR_FORMAT_HI 0x8F70
|
||||
#define EGL_COLOR_RGB_HI 0x8F71
|
||||
#define EGL_COLOR_RGBA_HI 0x8F72
|
||||
#define EGL_COLOR_ARGB_HI 0x8F73
|
||||
#endif /* EGL_HI_colorformats */
|
||||
|
||||
#ifndef EGL_IMG_context_priority
|
||||
#define EGL_IMG_context_priority 1
|
||||
@ -169,29 +599,115 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG
|
||||
#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
|
||||
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
|
||||
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
|
||||
#endif
|
||||
#endif /* EGL_IMG_context_priority */
|
||||
|
||||
#ifndef EGL_KHR_lock_surface2
|
||||
#define EGL_KHR_lock_surface2 1
|
||||
#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
|
||||
#ifndef EGL_MESA_drm_image
|
||||
#define EGL_MESA_drm_image 1
|
||||
#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0
|
||||
#define EGL_DRM_BUFFER_USE_MESA 0x31D1
|
||||
#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2
|
||||
#define EGL_DRM_BUFFER_MESA 0x31D3
|
||||
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
|
||||
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001
|
||||
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002
|
||||
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
|
||||
#endif
|
||||
#endif /* EGL_MESA_drm_image */
|
||||
|
||||
#ifndef EGL_MESA_platform_gbm
|
||||
#define EGL_MESA_platform_gbm 1
|
||||
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
||||
#endif /* EGL_MESA_platform_gbm */
|
||||
|
||||
#ifndef EGL_NOK_swap_region
|
||||
#define EGL_NOK_swap_region 1
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
|
||||
#endif
|
||||
#endif /* EGL_NOK_swap_region */
|
||||
|
||||
#ifndef EGL_NOK_swap_region2
|
||||
#define EGL_NOK_swap_region2 1
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
|
||||
#endif
|
||||
#endif /* EGL_NOK_swap_region2 */
|
||||
|
||||
#ifndef EGL_NOK_texture_from_pixmap
|
||||
#define EGL_NOK_texture_from_pixmap 1
|
||||
#define EGL_Y_INVERTED_NOK 0x307F
|
||||
#endif /* EGL_NOK_texture_from_pixmap */
|
||||
|
||||
#ifndef EGL_NV_3dvision_surface
|
||||
#define EGL_NV_3dvision_surface 1
|
||||
#define EGL_AUTO_STEREO_NV 0x3136
|
||||
#endif /* EGL_NV_3dvision_surface */
|
||||
|
||||
#ifndef EGL_NV_coverage_sample
|
||||
#define EGL_NV_coverage_sample 1
|
||||
#define EGL_COVERAGE_BUFFERS_NV 0x30E0
|
||||
#define EGL_COVERAGE_SAMPLES_NV 0x30E1
|
||||
#endif
|
||||
#endif /* EGL_NV_coverage_sample */
|
||||
|
||||
#ifndef EGL_NV_coverage_sample_resolve
|
||||
#define EGL_NV_coverage_sample_resolve 1
|
||||
#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
|
||||
#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
|
||||
#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
|
||||
#endif /* EGL_NV_coverage_sample_resolve */
|
||||
|
||||
#ifndef EGL_NV_depth_nonlinear
|
||||
#define EGL_NV_depth_nonlinear 1
|
||||
#define EGL_DEPTH_ENCODING_NV 0x30E2
|
||||
#define EGL_DEPTH_ENCODING_NONE_NV 0
|
||||
#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
|
||||
#endif
|
||||
#endif /* EGL_NV_depth_nonlinear */
|
||||
|
||||
#ifndef EGL_NV_native_query
|
||||
#define EGL_NV_native_query 1
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);
|
||||
#endif
|
||||
#endif /* EGL_NV_native_query */
|
||||
|
||||
#ifndef EGL_NV_post_convert_rounding
|
||||
#define EGL_NV_post_convert_rounding 1
|
||||
#endif /* EGL_NV_post_convert_rounding */
|
||||
|
||||
#ifndef EGL_NV_post_sub_buffer
|
||||
#define EGL_NV_post_sub_buffer 1
|
||||
#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
|
||||
#endif
|
||||
#endif /* EGL_NV_post_sub_buffer */
|
||||
|
||||
#ifndef EGL_NV_stream_sync
|
||||
#define EGL_NV_stream_sync 1
|
||||
#define EGL_SYNC_NEW_FRAME_NV 0x321F
|
||||
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list);
|
||||
#endif
|
||||
#endif /* EGL_NV_stream_sync */
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */
|
||||
#ifndef EGL_NV_sync
|
||||
#define EGL_NV_sync 1
|
||||
typedef void *EGLSyncNV;
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeNV;
|
||||
#ifdef KHRONOS_SUPPORT_INT64
|
||||
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6
|
||||
#define EGL_SYNC_STATUS_NV 0x30E7
|
||||
#define EGL_SIGNALED_NV 0x30E8
|
||||
@ -205,147 +721,35 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG
|
||||
#define EGL_SYNC_CONDITION_NV 0x30EE
|
||||
#define EGL_SYNC_FENCE_NV 0x30EF
|
||||
#define EGL_NO_SYNC_NV ((EGLSyncNV)0)
|
||||
typedef void* EGLSyncNV;
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeNV;
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
|
||||
EGLBoolean eglDestroySyncNV (EGLSyncNV sync);
|
||||
EGLBoolean eglFenceNV (EGLSyncNV sync);
|
||||
EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
|
||||
EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
|
||||
EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
|
||||
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
|
||||
#ifndef EGL_KHR_fence_sync
|
||||
#define EGL_KHR_fence_sync 1
|
||||
/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
|
||||
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
|
||||
#define EGL_SYNC_CONDITION_KHR 0x30F8
|
||||
#define EGL_SYNC_FENCE_KHR 0x30F9
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EGL_HI_clientpixmap
|
||||
#define EGL_HI_clientpixmap 1
|
||||
|
||||
/* Surface Attribute */
|
||||
#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
|
||||
/*
|
||||
* Structure representing a client pixmap
|
||||
* (pixmap's data is in client-space memory).
|
||||
*/
|
||||
struct EGLClientPixmapHI
|
||||
{
|
||||
void* pData;
|
||||
EGLint iWidth;
|
||||
EGLint iHeight;
|
||||
EGLint iStride;
|
||||
};
|
||||
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
|
||||
#endif /* EGL_HI_clientpixmap */
|
||||
|
||||
#ifndef EGL_HI_colorformats
|
||||
#define EGL_HI_colorformats 1
|
||||
/* Config Attribute */
|
||||
#define EGL_COLOR_FORMAT_HI 0x8F70
|
||||
/* Color Formats */
|
||||
#define EGL_COLOR_RGB_HI 0x8F71
|
||||
#define EGL_COLOR_RGBA_HI 0x8F72
|
||||
#define EGL_COLOR_ARGB_HI 0x8F73
|
||||
#endif /* EGL_HI_colorformats */
|
||||
|
||||
#ifndef EGL_MESA_drm_image
|
||||
#define EGL_MESA_drm_image 1
|
||||
#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */
|
||||
#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */
|
||||
#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */
|
||||
#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */
|
||||
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
|
||||
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
|
||||
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
|
||||
EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
|
||||
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
|
||||
#endif
|
||||
#endif /* KHRONOS_SUPPORT_INT64 */
|
||||
#endif /* EGL_NV_sync */
|
||||
|
||||
#ifndef EGL_NV_post_sub_buffer
|
||||
#define EGL_NV_post_sub_buffer 1
|
||||
#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
|
||||
#endif
|
||||
|
||||
#ifndef EGL_ANGLE_query_surface_pointer
|
||||
#define EGL_ANGLE_query_surface_pointer 1
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
|
||||
#endif
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
|
||||
#endif
|
||||
|
||||
#ifndef EGL_ANGLE_software_display
|
||||
#define EGL_ANGLE_software_display 1
|
||||
#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
|
||||
#endif
|
||||
|
||||
#ifndef EGL_ANGLE_direct3d_display
|
||||
#define EGL_ANGLE_direct3d_display 1
|
||||
#define EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE ((EGLNativeDisplayType)-2)
|
||||
#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((EGLNativeDisplayType)-3)
|
||||
#endif
|
||||
|
||||
#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
|
||||
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
|
||||
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
|
||||
#endif
|
||||
|
||||
#ifndef EGL_NV_coverage_sample_resolve
|
||||
#define EGL_NV_coverage_sample_resolve 1
|
||||
#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
|
||||
#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
|
||||
#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
|
||||
#ifndef EGL_NV_system_time
|
||||
#define EGL_NV_system_time 1
|
||||
|
||||
typedef khronos_utime_nanoseconds_t EGLuint64NV;
|
||||
|
||||
#ifdef KHRONOS_SUPPORT_INT64
|
||||
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
|
||||
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void);
|
||||
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
|
||||
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EGL_EXT_create_context_robustness
|
||||
#define EGL_EXT_create_context_robustness 1
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
|
||||
#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF
|
||||
#endif
|
||||
#endif /* KHRONOS_SUPPORT_INT64 */
|
||||
#endif /* EGL_NV_system_time */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
30
src/3rdparty/angle/include/EGL/eglplatform.h
vendored
30
src/3rdparty/angle/include/EGL/eglplatform.h
vendored
@ -2,7 +2,7 @@
|
||||
#define __eglplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2007-2009 The Khronos Group Inc.
|
||||
** Copyright (c) 2007-2013 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
/* Platform-specific types and definitions for egl.h
|
||||
* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
|
||||
* $Revision: 23432 $ on $Date: 2013-10-09 00:57:24 -0700 (Wed, 09 Oct 2013) $
|
||||
*
|
||||
* Adopters may modify khrplatform.h and this file to suit their platform.
|
||||
* You are encouraged to submit all modifications to the Khronos group so that
|
||||
@ -67,11 +67,11 @@
|
||||
* implementations.
|
||||
*/
|
||||
|
||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) /* Windows Runtime */
|
||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) /* Windows Runtime */
|
||||
|
||||
struct IUnknown;
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef IUnknown *EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef IUnknown *EGLNativeWindowType;
|
||||
|
||||
@ -91,13 +91,17 @@ typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
|
||||
#elif defined(WL_EGL_PLATFORM)
|
||||
#elif defined(__ANDROID__) || defined(ANDROID)
|
||||
|
||||
typedef struct wl_display *EGLNativeDisplayType;
|
||||
typedef struct wl_egl_pixmap *EGLNativePixmapType;
|
||||
typedef struct wl_egl_window *EGLNativeWindowType;
|
||||
#include <android/native_window.h>
|
||||
|
||||
#elif defined(__unix__) && !defined(ANDROID)
|
||||
struct egl_native_pixmap_t;
|
||||
|
||||
typedef struct ANativeWindow* EGLNativeWindowType;
|
||||
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
|
||||
typedef void* EGLNativeDisplayType;
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
/* X11 (tentative) */
|
||||
#include <X11/Xlib.h>
|
||||
@ -107,14 +111,6 @@ typedef Display *EGLNativeDisplayType;
|
||||
typedef Pixmap EGLNativePixmapType;
|
||||
typedef Window EGLNativeWindowType;
|
||||
|
||||
#elif defined(ANDROID)
|
||||
|
||||
struct egl_native_pixmap_t;
|
||||
|
||||
typedef struct ANativeWindow* EGLNativeWindowType;
|
||||
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
|
||||
typedef void* EGLNativeDisplayType;
|
||||
|
||||
#else
|
||||
#error "Platform not recognized"
|
||||
#endif
|
||||
|
9
src/3rdparty/angle/include/GLES2/gl2.h
vendored
9
src/3rdparty/angle/include/GLES2/gl2.h
vendored
@ -1,7 +1,7 @@
|
||||
#ifndef __gl2_h_
|
||||
#define __gl2_h_
|
||||
|
||||
/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
|
||||
/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */
|
||||
|
||||
#include <GLES2/gl2platform.h>
|
||||
|
||||
@ -431,7 +431,6 @@ typedef khronos_ssize_t GLsizeiptr;
|
||||
#define GL_RGB5_A1 0x8057
|
||||
#define GL_RGB565 0x8D62
|
||||
#define GL_DEPTH_COMPONENT16 0x81A5
|
||||
#define GL_STENCIL_INDEX 0x1901
|
||||
#define GL_STENCIL_INDEX8 0x8D48
|
||||
|
||||
#define GL_RENDERBUFFER_WIDTH 0x8D42
|
||||
@ -528,7 +527,7 @@ GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
|
||||
GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
|
||||
GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
|
||||
GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
|
||||
GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
|
||||
GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
|
||||
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
|
||||
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
|
||||
GL_APICALL GLenum GL_APIENTRY glGetError (void);
|
||||
@ -547,7 +546,7 @@ GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum p
|
||||
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
|
||||
GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
|
||||
GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
|
||||
GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
|
||||
GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
|
||||
GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
|
||||
GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
|
||||
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
|
||||
@ -569,7 +568,7 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum
|
||||
GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
|
||||
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
|
||||
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
|
||||
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
|
||||
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
|
||||
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
|
||||
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
|
||||
|
577
src/3rdparty/angle/include/GLES2/gl2ext.h
vendored
577
src/3rdparty/angle/include/GLES2/gl2ext.h
vendored
@ -1,7 +1,7 @@
|
||||
#ifndef __gl2ext_h_
|
||||
#define __gl2ext_h_
|
||||
|
||||
/* $Revision: 16482 $ on $Date:: 2012-01-04 13:44:55 -0500 #$ */
|
||||
/* $Revision: 20795 $ on $Date:: 2013-03-07 01:01:58 -0800 #$ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -93,6 +93,25 @@ typedef void* GLeglImageOES;
|
||||
#define GL_DEPTH24_STENCIL8_OES 0x88F0
|
||||
#endif
|
||||
|
||||
/* GL_OES_required_internalformat */
|
||||
#ifndef GL_OES_required_internalformat
|
||||
#define GL_ALPHA8_OES 0x803C
|
||||
#define GL_DEPTH_COMPONENT16_OES 0x81A5
|
||||
/* reuse GL_DEPTH_COMPONENT24_OES */
|
||||
/* reuse GL_DEPTH24_STENCIL8_OES */
|
||||
/* reuse GL_DEPTH_COMPONENT32_OES */
|
||||
#define GL_LUMINANCE4_ALPHA4_OES 0x8043
|
||||
#define GL_LUMINANCE8_ALPHA8_OES 0x8045
|
||||
#define GL_LUMINANCE8_OES 0x8040
|
||||
#define GL_RGBA4_OES 0x8056
|
||||
#define GL_RGB5_A1_OES 0x8057
|
||||
#define GL_RGB565_OES 0x8D62
|
||||
/* reuse GL_RGB8_OES */
|
||||
/* reuse GL_RGBA8_OES */
|
||||
/* reuse GL_RGB10_EXT */
|
||||
/* reuse GL_RGB10_A2_EXT */
|
||||
#endif
|
||||
|
||||
/* GL_OES_rgb8_rgba8 */
|
||||
#ifndef GL_OES_rgb8_rgba8
|
||||
#define GL_RGB8_OES 0x8051
|
||||
@ -114,6 +133,10 @@ typedef void* GLeglImageOES;
|
||||
#define GL_STENCIL_INDEX4_OES 0x8D47
|
||||
#endif
|
||||
|
||||
#ifndef GL_OES_surfaceless_context
|
||||
#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
|
||||
#endif
|
||||
|
||||
/* GL_OES_texture_3D */
|
||||
#ifndef GL_OES_texture_3D
|
||||
#define GL_TEXTURE_WRAP_R_OES 0x8072
|
||||
@ -155,6 +178,85 @@ typedef void* GLeglImageOES;
|
||||
#define GL_INT_10_10_10_2_OES 0x8DF7
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* KHR extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef GL_KHR_debug
|
||||
typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
|
||||
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
|
||||
#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
|
||||
#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
|
||||
#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
|
||||
#define GL_DEBUG_SOURCE_API 0x8246
|
||||
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
|
||||
#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
|
||||
#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
|
||||
#define GL_DEBUG_SOURCE_APPLICATION 0x824A
|
||||
#define GL_DEBUG_SOURCE_OTHER 0x824B
|
||||
#define GL_DEBUG_TYPE_ERROR 0x824C
|
||||
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
|
||||
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
|
||||
#define GL_DEBUG_TYPE_PORTABILITY 0x824F
|
||||
#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
|
||||
#define GL_DEBUG_TYPE_OTHER 0x8251
|
||||
#define GL_DEBUG_TYPE_MARKER 0x8268
|
||||
#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
|
||||
#define GL_DEBUG_TYPE_POP_GROUP 0x826A
|
||||
#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
|
||||
#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
|
||||
#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
|
||||
#define GL_BUFFER 0x82E0
|
||||
#define GL_SHADER 0x82E1
|
||||
#define GL_PROGRAM 0x82E2
|
||||
#define GL_QUERY 0x82E3
|
||||
/* PROGRAM_PIPELINE only in GL */
|
||||
#define GL_SAMPLER 0x82E6
|
||||
/* DISPLAY_LIST only in GL */
|
||||
#define GL_MAX_LABEL_LENGTH 0x82E8
|
||||
#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
|
||||
#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
|
||||
#define GL_DEBUG_LOGGED_MESSAGES 0x9145
|
||||
#define GL_DEBUG_SEVERITY_HIGH 0x9146
|
||||
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
|
||||
#define GL_DEBUG_SEVERITY_LOW 0x9148
|
||||
#define GL_DEBUG_OUTPUT 0x92E0
|
||||
#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
|
||||
#define GL_STACK_OVERFLOW 0x0503
|
||||
#define GL_STACK_UNDERFLOW 0x0504
|
||||
#endif
|
||||
|
||||
#ifndef GL_KHR_texture_compression_astc_ldr
|
||||
#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
|
||||
#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
|
||||
#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
|
||||
#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
|
||||
#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
|
||||
#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
|
||||
#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
|
||||
#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
|
||||
#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
|
||||
#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
|
||||
#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
|
||||
#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
|
||||
#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
|
||||
#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
|
||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* AMD extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
@ -192,6 +294,18 @@ typedef void* GLeglImageOES;
|
||||
* ANGLE extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_ANGLE_depth_texture */
|
||||
#ifndef GL_ANGLE_depth_texture
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
#define GL_DEPTH_STENCIL_OES 0x84F9
|
||||
#define GL_UNSIGNED_SHORT 0x1403
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#define GL_UNSIGNED_INT_24_8_OES 0x84FA
|
||||
#define GL_DEPTH_COMPONENT16 0x81A5
|
||||
#define GL_DEPTH_COMPONENT32_OES 0x81A7
|
||||
#define GL_DEPTH24_STENCIL8_OES 0x88F0
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_framebuffer_blit */
|
||||
#ifndef GL_ANGLE_framebuffer_blit
|
||||
#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
|
||||
@ -207,11 +321,21 @@ typedef void* GLeglImageOES;
|
||||
#define GL_MAX_SAMPLES_ANGLE 0x8D57
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_instanced_arrays */
|
||||
#ifndef GL_ANGLE_instanced_arrays
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_pack_reverse_row_order */
|
||||
#ifndef GL_ANGLE_pack_reverse_row_order
|
||||
#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_program_binary */
|
||||
#ifndef GL_ANGLE_program_binary
|
||||
#define GL_PROGRAM_BINARY_ANGLE 0x93A6
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_texture_compression_dxt3 */
|
||||
#ifndef GL_ANGLE_texture_compression_dxt3
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
|
||||
@ -222,37 +346,23 @@ typedef void* GLeglImageOES;
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_translated_shader_source */
|
||||
#ifndef GL_ANGLE_translated_shader_source
|
||||
#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_texture_usage */
|
||||
#ifndef GL_ANGLE_texture_usage
|
||||
#define GL_TEXTURE_USAGE_ANGLE 0x93A2
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_instanced_arrays */
|
||||
#ifndef GL_ANGLE_instanced_arrays
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_program_binary */
|
||||
#ifndef GL_ANGLE_program_binary
|
||||
#define GL_PROGRAM_BINARY_ANGLE 0x93A6
|
||||
/* GL_ANGLE_translated_shader_source */
|
||||
#ifndef GL_ANGLE_translated_shader_source
|
||||
#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* APPLE extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_APPLE_rgb_422 */
|
||||
#ifndef GL_APPLE_rgb_422
|
||||
#define GL_RGB_422_APPLE 0x8A1F
|
||||
#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
|
||||
#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
|
||||
#endif
|
||||
/* GL_APPLE_copy_texture_levels */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
/* GL_APPLE_framebuffer_multisample */
|
||||
#ifndef GL_APPLE_framebuffer_multisample
|
||||
@ -265,6 +375,47 @@ typedef void* GLeglImageOES;
|
||||
#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_rgb_422 */
|
||||
#ifndef GL_APPLE_rgb_422
|
||||
#define GL_RGB_422_APPLE 0x8A1F
|
||||
#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
|
||||
#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_sync */
|
||||
#ifndef GL_APPLE_sync
|
||||
|
||||
#ifndef __gl3_h_
|
||||
/* These types are defined with reference to <inttypes.h>
|
||||
* in the Apple extension spec, but here we use the Khronos
|
||||
* portable types in khrplatform.h, and assume those types
|
||||
* are always defined.
|
||||
* If any other extensions using these types are defined,
|
||||
* the typedefs must move out of this block and be shared.
|
||||
*/
|
||||
typedef khronos_int64_t GLint64;
|
||||
typedef khronos_uint64_t GLuint64;
|
||||
typedef struct __GLsync *GLsync;
|
||||
#endif
|
||||
|
||||
#define GL_SYNC_OBJECT_APPLE 0x8A53
|
||||
#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
|
||||
#define GL_OBJECT_TYPE_APPLE 0x9112
|
||||
#define GL_SYNC_CONDITION_APPLE 0x9113
|
||||
#define GL_SYNC_STATUS_APPLE 0x9114
|
||||
#define GL_SYNC_FLAGS_APPLE 0x9115
|
||||
#define GL_SYNC_FENCE_APPLE 0x9116
|
||||
#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
|
||||
#define GL_UNSIGNALED_APPLE 0x9118
|
||||
#define GL_SIGNALED_APPLE 0x9119
|
||||
#define GL_ALREADY_SIGNALED_APPLE 0x911A
|
||||
#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
|
||||
#define GL_CONDITION_SATISFIED_APPLE 0x911C
|
||||
#define GL_WAIT_FAILED_APPLE 0x911D
|
||||
#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
|
||||
#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_texture_format_BGRA8888 */
|
||||
#ifndef GL_APPLE_texture_format_BGRA8888
|
||||
#define GL_BGRA_EXT 0x80E1
|
||||
@ -279,6 +430,11 @@ typedef void* GLeglImageOES;
|
||||
* ARM extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_ARM_mali_program_binary */
|
||||
#ifndef GL_ARM_mali_program_binary
|
||||
#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61
|
||||
#endif
|
||||
|
||||
/* GL_ARM_mali_shader_binary */
|
||||
#ifndef GL_ARM_mali_shader_binary
|
||||
#define GL_MALI_SHADER_BINARY_ARM 0x8F60
|
||||
@ -327,12 +483,32 @@ typedef void* GLeglImageOES;
|
||||
#define GL_STENCIL_EXT 0x1802
|
||||
#endif
|
||||
|
||||
/* GL_EXT_map_buffer_range */
|
||||
#ifndef GL_EXT_map_buffer_range
|
||||
#define GL_MAP_READ_BIT_EXT 0x0001
|
||||
#define GL_MAP_WRITE_BIT_EXT 0x0002
|
||||
#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
|
||||
#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
|
||||
#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
|
||||
#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
|
||||
#endif
|
||||
|
||||
/* GL_EXT_multisampled_render_to_texture */
|
||||
#ifndef GL_EXT_multisampled_render_to_texture
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
|
||||
#define GL_RENDERBUFFER_SAMPLES_EXT 0x9133
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x9134
|
||||
#define GL_MAX_SAMPLES_EXT 0x9135
|
||||
/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */
|
||||
#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
|
||||
#define GL_MAX_SAMPLES_EXT 0x8D57
|
||||
#endif
|
||||
|
||||
/* GL_EXT_multiview_draw_buffers */
|
||||
#ifndef GL_EXT_multiview_draw_buffers
|
||||
#define GL_COLOR_ATTACHMENT_EXT 0x90F0
|
||||
#define GL_MULTIVIEW_EXT 0x90F1
|
||||
#define GL_DRAW_BUFFER_EXT 0x0C01
|
||||
#define GL_READ_BUFFER_EXT 0x0C02
|
||||
#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
|
||||
#endif
|
||||
|
||||
/* GL_EXT_multi_draw_arrays */
|
||||
@ -376,6 +552,11 @@ typedef void* GLeglImageOES;
|
||||
#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
|
||||
#endif
|
||||
|
||||
/* GL_EXT_shader_framebuffer_fetch */
|
||||
#ifndef GL_EXT_shader_framebuffer_fetch
|
||||
#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
|
||||
#endif
|
||||
|
||||
/* GL_EXT_shader_texture_lod */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
@ -384,6 +565,7 @@ typedef void* GLeglImageOES;
|
||||
#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
|
||||
#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
|
||||
#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
|
||||
#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
|
||||
#endif
|
||||
|
||||
/* GL_EXT_sRGB */
|
||||
@ -431,13 +613,19 @@ typedef void* GLeglImageOES;
|
||||
#define GL_LUMINANCE32F_EXT 0x8818
|
||||
#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
|
||||
/* reuse GL_RGBA16F_EXT */
|
||||
#define GL_RGB16F_EXT 0x881B
|
||||
/* reuse GL_RGB16F_EXT */
|
||||
#define GL_ALPHA16F_EXT 0x881C
|
||||
#define GL_LUMINANCE16F_EXT 0x881E
|
||||
#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
|
||||
#define GL_RGB10_A2_EXT 0x8059
|
||||
#define GL_RGB10_EXT 0x8052
|
||||
#define GL_BGRA8_EXT 0x93A1
|
||||
#define GL_R8_EXT 0x8229
|
||||
#define GL_RG8_EXT 0x822B
|
||||
#define GL_R32F_EXT 0x822E
|
||||
#define GL_RG32F_EXT 0x8230
|
||||
#define GL_R16F_EXT 0x822D
|
||||
#define GL_RG16F_EXT 0x822F
|
||||
#endif
|
||||
|
||||
/* GL_EXT_texture_type_2_10_10_10_REV */
|
||||
@ -447,9 +635,9 @@ typedef void* GLeglImageOES;
|
||||
|
||||
/* GL_EXT_unpack_subimage */
|
||||
#ifndef GL_EXT_unpack_subimage
|
||||
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||
#define GL_UNPACK_SKIP_ROWS 0x0CF3
|
||||
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
|
||||
#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
|
||||
#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
|
||||
#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
@ -461,6 +649,15 @@ typedef void* GLeglImageOES;
|
||||
#define GL_SHADER_BINARY_DMP 0x9250
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* FJ extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_FJ_shader_binary_GCCSO */
|
||||
#ifndef GL_FJ_shader_binary_GCCSO
|
||||
#define GL_GCCSO_SHADER_BINARY_F 0x9260
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* IMG extension tokens
|
||||
*------------------------------------------------------------------------*/
|
||||
@ -489,6 +686,12 @@ typedef void* GLeglImageOES;
|
||||
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
||||
#endif
|
||||
|
||||
/* GL_IMG_texture_compression_pvrtc2 */
|
||||
#ifndef GL_IMG_texture_compression_pvrtc2
|
||||
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
|
||||
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
|
||||
#endif
|
||||
|
||||
/* GL_IMG_multisampled_render_to_texture */
|
||||
#ifndef GL_IMG_multisampled_render_to_texture
|
||||
#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
|
||||
@ -594,6 +797,9 @@ typedef void* GLeglImageOES;
|
||||
#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
|
||||
#endif
|
||||
|
||||
/* GL_NV_draw_instanced */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
/* GL_NV_fbo_color_attachments */
|
||||
#ifndef GL_NV_fbo_color_attachments
|
||||
#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
|
||||
@ -607,6 +813,29 @@ typedef void* GLeglImageOES;
|
||||
#define GL_FENCE_CONDITION_NV 0x84F4
|
||||
#endif
|
||||
|
||||
/* GL_NV_framebuffer_blit */
|
||||
#ifndef GL_NV_framebuffer_blit
|
||||
#define GL_READ_FRAMEBUFFER_NV 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6
|
||||
#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA
|
||||
#endif
|
||||
|
||||
/* GL_NV_framebuffer_multisample */
|
||||
#ifndef GL_NV_framebuffer_multisample
|
||||
#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56
|
||||
#define GL_MAX_SAMPLES_NV 0x8D57
|
||||
#endif
|
||||
|
||||
/* GL_NV_generate_mipmap_sRGB */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
/* GL_NV_instanced_arrays */
|
||||
#ifndef GL_NV_instanced_arrays
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE
|
||||
#endif
|
||||
|
||||
/* GL_NV_read_buffer */
|
||||
#ifndef GL_NV_read_buffer
|
||||
#define GL_READ_BUFFER_NV 0x0C02
|
||||
@ -624,6 +853,36 @@ typedef void* GLeglImageOES;
|
||||
/* GL_NV_read_stencil */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
/* GL_NV_shadow_samplers_array */
|
||||
#ifndef GL_NV_shadow_samplers_array
|
||||
#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4
|
||||
#endif
|
||||
|
||||
/* GL_NV_shadow_samplers_cube */
|
||||
#ifndef GL_NV_shadow_samplers_cube
|
||||
#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5
|
||||
#endif
|
||||
|
||||
/* GL_NV_sRGB_formats */
|
||||
#ifndef GL_NV_sRGB_formats
|
||||
#define GL_SLUMINANCE_NV 0x8C46
|
||||
#define GL_SLUMINANCE_ALPHA_NV 0x8C44
|
||||
#define GL_SRGB8_NV 0x8C41
|
||||
#define GL_SLUMINANCE8_NV 0x8C47
|
||||
#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45
|
||||
#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C
|
||||
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D
|
||||
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E
|
||||
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F
|
||||
#define GL_ETC1_SRGB8_NV 0x88EE
|
||||
#endif
|
||||
|
||||
/* GL_NV_texture_border_clamp */
|
||||
#ifndef GL_NV_texture_border_clamp
|
||||
#define GL_TEXTURE_BORDER_COLOR_NV 0x1004
|
||||
#define GL_CLAMP_TO_BORDER_NV 0x812D
|
||||
#endif
|
||||
|
||||
/* GL_NV_texture_compression_s3tc_update */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
@ -641,6 +900,14 @@ typedef void* GLeglImageOES;
|
||||
#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
|
||||
#endif
|
||||
|
||||
/* GL_QCOM_binning_control */
|
||||
#ifndef GL_QCOM_binning_control
|
||||
#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0
|
||||
#define GL_CPU_OPTIMIZED_QCOM 0x8FB1
|
||||
#define GL_GPU_OPTIMIZED_QCOM 0x8FB2
|
||||
#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3
|
||||
#endif
|
||||
|
||||
/* GL_QCOM_driver_control */
|
||||
/* No new tokens introduced by this extension. */
|
||||
|
||||
@ -811,6 +1078,11 @@ typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum
|
||||
#define GL_OES_packed_depth_stencil 1
|
||||
#endif
|
||||
|
||||
/* GL_OES_required_internalformat */
|
||||
#ifndef GL_OES_required_internalformat
|
||||
#define GL_OES_required_internalformat 1
|
||||
#endif
|
||||
|
||||
/* GL_OES_rgb8_rgba8 */
|
||||
#ifndef GL_OES_rgb8_rgba8
|
||||
#define GL_OES_rgb8_rgba8 1
|
||||
@ -831,6 +1103,10 @@ typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum
|
||||
#define GL_OES_stencil4 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_OES_surfaceless_context
|
||||
#define GL_OES_surfaceless_context 1
|
||||
#endif
|
||||
|
||||
/* GL_OES_texture_3D */
|
||||
#ifndef GL_OES_texture_3D
|
||||
#define GL_OES_texture_3D 1
|
||||
@ -900,6 +1176,43 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
|
||||
#define GL_OES_vertex_type_10_10_10_2 1
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* KHR extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef GL_KHR_debug
|
||||
#define GL_KHR_debug 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
||||
GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
||||
GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
|
||||
GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
||||
GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
|
||||
GL_APICALL void GL_APIENTRY glPopDebugGroup (void);
|
||||
GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
|
||||
GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||
GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
|
||||
GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||
GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
||||
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
||||
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
|
||||
typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
||||
typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
|
||||
typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
|
||||
typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
|
||||
typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||
typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
|
||||
typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||
typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params);
|
||||
#endif
|
||||
|
||||
#ifndef GL_KHR_texture_compression_astc_ldr
|
||||
#define GL_KHR_texture_compression_astc_ldr 1
|
||||
#endif
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* AMD extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
@ -952,6 +1265,11 @@ typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monito
|
||||
* ANGLE extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_ANGLE_depth_texture */
|
||||
#ifndef GL_ANGLE_depth_texture
|
||||
#define GL_ANGLE_depth_texture 1
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_framebuffer_blit */
|
||||
#ifndef GL_ANGLE_framebuffer_blit
|
||||
#define GL_ANGLE_framebuffer_blit 1
|
||||
@ -970,11 +1288,28 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ANGLE_instanced_arrays
|
||||
#define GL_ANGLE_instanced_arrays 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
|
||||
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
|
||||
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_pack_reverse_row_order */
|
||||
#ifndef GL_ANGLE_pack_reverse_row_order
|
||||
#define GL_ANGLE_pack_reverse_row_order 1
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_program_binary */
|
||||
#ifndef GL_ANGLE_program_binary
|
||||
#define GL_ANGLE_program_binary 1
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_texture_compression_dxt3 */
|
||||
#ifndef GL_ANGLE_texture_compression_dxt3
|
||||
#define GL_ANGLE_texture_compression_dxt3 1
|
||||
@ -985,7 +1320,11 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum
|
||||
#define GL_ANGLE_texture_compression_dxt5 1
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_translated_shader_source */
|
||||
/* GL_ANGLE_texture_usage */
|
||||
#ifndef GL_ANGLE_texture_usage
|
||||
#define GL_ANGLE_texture_usage 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ANGLE_translated_shader_source
|
||||
#define GL_ANGLE_translated_shader_source 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
@ -994,31 +1333,17 @@ GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLs
|
||||
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_texture_usage */
|
||||
#ifndef GL_ANGLE_texture_usage
|
||||
#define GL_ANGLE_texture_usage 1
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_instanced_arrays */
|
||||
#ifndef GL_ANGLE_instanced_arrays
|
||||
#define GL_ANGLE_instanced_arrays 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor);
|
||||
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* APPLE extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_APPLE_rgb_422 */
|
||||
#ifndef GL_APPLE_rgb_422
|
||||
#define GL_APPLE_rgb_422 1
|
||||
/* GL_APPLE_copy_texture_levels */
|
||||
#ifndef GL_APPLE_copy_texture_levels
|
||||
#define GL_APPLE_copy_texture_levels 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_framebuffer_multisample */
|
||||
@ -1032,6 +1357,32 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum
|
||||
typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_rgb_422 */
|
||||
#ifndef GL_APPLE_rgb_422
|
||||
#define GL_APPLE_rgb_422 1
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_sync */
|
||||
#ifndef GL_APPLE_sync
|
||||
#define GL_APPLE_sync 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
|
||||
GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
|
||||
GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync);
|
||||
GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
|
||||
GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
|
||||
#endif
|
||||
typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
|
||||
typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
|
||||
typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
|
||||
typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
|
||||
typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
|
||||
#endif
|
||||
|
||||
/* GL_APPLE_texture_format_BGRA8888 */
|
||||
#ifndef GL_APPLE_texture_format_BGRA8888
|
||||
#define GL_APPLE_texture_format_BGRA8888 1
|
||||
@ -1046,6 +1397,11 @@ typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
|
||||
* ARM extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_ARM_mali_program_binary */
|
||||
#ifndef GL_ARM_mali_program_binary
|
||||
#define GL_ARM_mali_program_binary 1
|
||||
#endif
|
||||
|
||||
/* GL_ARM_mali_shader_binary */
|
||||
#ifndef GL_ARM_mali_shader_binary
|
||||
#define GL_ARM_mali_shader_binary 1
|
||||
@ -1103,6 +1459,17 @@ GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numA
|
||||
typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
|
||||
#endif
|
||||
|
||||
/* GL_EXT_map_buffer_range */
|
||||
#ifndef GL_EXT_map_buffer_range
|
||||
#define GL_EXT_map_buffer_range 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
|
||||
#endif
|
||||
typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
|
||||
#endif
|
||||
|
||||
/* GL_EXT_multisampled_render_to_texture */
|
||||
#ifndef GL_EXT_multisampled_render_to_texture
|
||||
#define GL_EXT_multisampled_render_to_texture 1
|
||||
@ -1114,10 +1481,23 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum t
|
||||
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
|
||||
#endif
|
||||
|
||||
/* GL_EXT_multiview_draw_buffers */
|
||||
#ifndef GL_EXT_multiview_draw_buffers
|
||||
#define GL_EXT_multiview_draw_buffers 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
|
||||
GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
|
||||
GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices);
|
||||
typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data);
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_multi_draw_arrays
|
||||
#define GL_EXT_multi_draw_arrays 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
|
||||
GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
|
||||
GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
|
||||
@ -1232,6 +1612,11 @@ typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline
|
||||
typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
#endif
|
||||
|
||||
/* GL_EXT_shader_framebuffer_fetch */
|
||||
#ifndef GL_EXT_shader_framebuffer_fetch
|
||||
#define GL_EXT_shader_framebuffer_fetch 1
|
||||
#endif
|
||||
|
||||
/* GL_EXT_shader_texture_lod */
|
||||
#ifndef GL_EXT_shader_texture_lod
|
||||
#define GL_EXT_shader_texture_lod 1
|
||||
@ -1305,6 +1690,15 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum
|
||||
#define GL_DMP_shader_binary 1
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* FJ extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
|
||||
/* GL_FJ_shader_binary_GCCSO */
|
||||
#ifndef GL_FJ_shader_binary_GCCSO
|
||||
#define GL_FJ_shader_binary_GCCSO 1
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* IMG extension functions
|
||||
*------------------------------------------------------------------------*/
|
||||
@ -1329,6 +1723,11 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum
|
||||
#define GL_IMG_texture_compression_pvrtc 1
|
||||
#endif
|
||||
|
||||
/* GL_IMG_texture_compression_pvrtc2 */
|
||||
#ifndef GL_IMG_texture_compression_pvrtc2
|
||||
#define GL_IMG_texture_compression_pvrtc2 1
|
||||
#endif
|
||||
|
||||
/* GL_IMG_multisampled_render_to_texture */
|
||||
#ifndef GL_IMG_multisampled_render_to_texture
|
||||
#define GL_IMG_multisampled_render_to_texture 1
|
||||
@ -1336,8 +1735,8 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum
|
||||
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
|
||||
GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
@ -1369,6 +1768,7 @@ GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
|
||||
#endif
|
||||
|
||||
/* GL_EXT_draw_buffers */
|
||||
#ifndef GL_EXT_draw_buffers
|
||||
#define GL_EXT_draw_buffers 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
@ -1377,6 +1777,17 @@ GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs);
|
||||
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
|
||||
#endif
|
||||
|
||||
/* GL_NV_draw_instanced */
|
||||
#ifndef GL_NV_draw_instanced
|
||||
#define GL_NV_draw_instanced 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
|
||||
#endif
|
||||
|
||||
/* GL_NV_fbo_color_attachments */
|
||||
#ifndef GL_NV_fbo_color_attachments
|
||||
#define GL_NV_fbo_color_attachments 1
|
||||
@ -1403,6 +1814,38 @@ typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
|
||||
typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
|
||||
#endif
|
||||
|
||||
/* GL_NV_framebuffer_blit */
|
||||
#ifndef GL_NV_framebuffer_blit
|
||||
#define GL_NV_framebuffer_blit 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif
|
||||
|
||||
/* GL_NV_framebuffer_multisample */
|
||||
#ifndef GL_NV_framebuffer_multisample
|
||||
#define GL_NV_framebuffer_multisample 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
#endif
|
||||
|
||||
/* GL_NV_generate_mipmap_sRGB */
|
||||
#ifndef GL_NV_generate_mipmap_sRGB
|
||||
#define GL_NV_generate_mipmap_sRGB 1
|
||||
#endif
|
||||
|
||||
/* GL_NV_instanced_arrays */
|
||||
#ifndef GL_NV_instanced_arrays
|
||||
#define GL_NV_instanced_arrays 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
|
||||
#endif
|
||||
|
||||
/* GL_NV_read_buffer */
|
||||
#ifndef GL_NV_read_buffer
|
||||
#define GL_NV_read_buffer 1
|
||||
@ -1432,6 +1875,26 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
|
||||
#define GL_NV_read_stencil 1
|
||||
#endif
|
||||
|
||||
/* GL_NV_shadow_samplers_array */
|
||||
#ifndef GL_NV_shadow_samplers_array
|
||||
#define GL_NV_shadow_samplers_array 1
|
||||
#endif
|
||||
|
||||
/* GL_NV_shadow_samplers_cube */
|
||||
#ifndef GL_NV_shadow_samplers_cube
|
||||
#define GL_NV_shadow_samplers_cube 1
|
||||
#endif
|
||||
|
||||
/* GL_NV_sRGB_formats */
|
||||
#ifndef GL_NV_sRGB_formats
|
||||
#define GL_NV_sRGB_formats 1
|
||||
#endif
|
||||
|
||||
/* GL_NV_texture_border_clamp */
|
||||
#ifndef GL_NV_texture_border_clamp
|
||||
#define GL_NV_texture_border_clamp 1
|
||||
#endif
|
||||
|
||||
/* GL_NV_texture_compression_s3tc_update */
|
||||
#ifndef GL_NV_texture_compression_s3tc_update
|
||||
#define GL_NV_texture_compression_s3tc_update 1
|
||||
@ -1455,6 +1918,11 @@ GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
|
||||
typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
|
||||
#endif
|
||||
|
||||
/* GL_QCOM_binning_control */
|
||||
#ifndef GL_QCOM_binning_control
|
||||
#define GL_QCOM_binning_control 1
|
||||
#endif
|
||||
|
||||
/* GL_QCOM_driver_control */
|
||||
#ifndef GL_QCOM_driver_control
|
||||
#define GL_QCOM_driver_control 1
|
||||
@ -1538,11 +2006,6 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
|
||||
#define GL_VIV_shader_binary 1
|
||||
#endif
|
||||
|
||||
/* GL_ANGLE_program_binary */
|
||||
#ifndef GL_ANGLE_program_binary
|
||||
#define GL_ANGLE_program_binary 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
1061
src/3rdparty/angle/include/GLES3/gl3.h
vendored
Normal file
1061
src/3rdparty/angle/include/GLES3/gl3.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
src/3rdparty/angle/include/GLES3/gl3ext.h
vendored
Normal file
24
src/3rdparty/angle/include/GLES3/gl3ext.h
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __gl3ext_h_
|
||||
#define __gl3ext_h_
|
||||
|
||||
/* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */
|
||||
|
||||
/*
|
||||
* This document is licensed under the SGI Free Software B License Version
|
||||
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
|
||||
*/
|
||||
|
||||
/* OpenGL ES 3 Extensions
|
||||
*
|
||||
* After an OES extension's interactions with OpenGl ES 3.0 have been documented,
|
||||
* its tokens and function definitions should be added to this file in a manner
|
||||
* that does not conflict with gl2ext.h or gl3.h.
|
||||
*
|
||||
* Tokens and function definitions for extensions that have become standard
|
||||
* features in OpenGL ES 3.0 will not be added to this file.
|
||||
*
|
||||
* Applications using OpenGL-ES-2-only extensions should include gl2ext.h
|
||||
*/
|
||||
|
||||
#endif /* __gl3ext_h_ */
|
||||
|
30
src/3rdparty/angle/include/GLES3/gl3platform.h
vendored
Normal file
30
src/3rdparty/angle/include/GLES3/gl3platform.h
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __gl3platform_h_
|
||||
#define __gl3platform_h_
|
||||
|
||||
/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */
|
||||
|
||||
/*
|
||||
* This document is licensed under the SGI Free Software B License Version
|
||||
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
|
||||
*/
|
||||
|
||||
/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h
|
||||
*
|
||||
* Adopters may modify khrplatform.h and this file to suit their platform.
|
||||
* You are encouraged to submit all modifications to the Khronos group so that
|
||||
* they can be included in future versions of this file. Please submit changes
|
||||
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
|
||||
* by filing a bug against product "OpenGL-ES" component "Registry".
|
||||
*/
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
|
||||
#ifndef GL_APICALL
|
||||
#define GL_APICALL KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
#ifndef GL_APIENTRY
|
||||
#define GL_APIENTRY KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
#endif /* __gl3platform_h_ */
|
118
src/3rdparty/angle/include/GLSLANG/ShaderLang.h
vendored
118
src/3rdparty/angle/include/GLSLANG/ShaderLang.h
vendored
@ -31,24 +31,19 @@
|
||||
// and the shading language compiler.
|
||||
//
|
||||
|
||||
namespace sh
|
||||
{
|
||||
// GLenum alias
|
||||
typedef unsigned int GLenum;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Version number for shader translation API.
|
||||
// It is incremented every time the API changes.
|
||||
#define ANGLE_SH_VERSION 112
|
||||
|
||||
//
|
||||
// The names of the following enums have been derived by replacing GL prefix
|
||||
// with SH. For example, SH_INFO_LOG_LENGTH is equivalent to GL_INFO_LOG_LENGTH.
|
||||
// The enum values are also equal to the values of their GL counterpart. This
|
||||
// is done to make it easier for applications to use the shader library.
|
||||
//
|
||||
typedef enum {
|
||||
SH_FRAGMENT_SHADER = 0x8B30,
|
||||
SH_VERTEX_SHADER = 0x8B31
|
||||
} ShShaderType;
|
||||
#define ANGLE_SH_VERSION 128
|
||||
|
||||
typedef enum {
|
||||
SH_GLES2_SPEC = 0x8B40,
|
||||
@ -85,29 +80,6 @@ typedef enum {
|
||||
SH_HLSL11_OUTPUT = 0x8B48
|
||||
} ShShaderOutput;
|
||||
|
||||
typedef enum {
|
||||
SH_NONE = 0,
|
||||
SH_INT = 0x1404,
|
||||
SH_FLOAT = 0x1406,
|
||||
SH_FLOAT_VEC2 = 0x8B50,
|
||||
SH_FLOAT_VEC3 = 0x8B51,
|
||||
SH_FLOAT_VEC4 = 0x8B52,
|
||||
SH_INT_VEC2 = 0x8B53,
|
||||
SH_INT_VEC3 = 0x8B54,
|
||||
SH_INT_VEC4 = 0x8B55,
|
||||
SH_BOOL = 0x8B56,
|
||||
SH_BOOL_VEC2 = 0x8B57,
|
||||
SH_BOOL_VEC3 = 0x8B58,
|
||||
SH_BOOL_VEC4 = 0x8B59,
|
||||
SH_FLOAT_MAT2 = 0x8B5A,
|
||||
SH_FLOAT_MAT3 = 0x8B5B,
|
||||
SH_FLOAT_MAT4 = 0x8B5C,
|
||||
SH_SAMPLER_2D = 0x8B5E,
|
||||
SH_SAMPLER_CUBE = 0x8B60,
|
||||
SH_SAMPLER_2D_RECT_ARB = 0x8B63,
|
||||
SH_SAMPLER_EXTERNAL_OES = 0x8D66
|
||||
} ShDataType;
|
||||
|
||||
typedef enum {
|
||||
SH_PRECISION_HIGHP = 0x5001,
|
||||
SH_PRECISION_MEDIUMP = 0x5002,
|
||||
@ -128,7 +100,14 @@ typedef enum {
|
||||
SH_NAME_MAX_LENGTH = 0x6001,
|
||||
SH_HASHED_NAME_MAX_LENGTH = 0x6002,
|
||||
SH_HASHED_NAMES_COUNT = 0x6003,
|
||||
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004
|
||||
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004,
|
||||
SH_SHADER_VERSION = 0x6005,
|
||||
SH_ACTIVE_INTERFACE_BLOCKS_ARRAY = 0x6006,
|
||||
SH_ACTIVE_OUTPUT_VARIABLES_ARRAY = 0x6007,
|
||||
SH_ACTIVE_ATTRIBUTES_ARRAY = 0x6008,
|
||||
SH_ACTIVE_VARYINGS_ARRAY = 0x6009,
|
||||
SH_RESOURCES_STRING_LENGTH = 0x600A,
|
||||
SH_OUTPUT_TYPE = 0x600B
|
||||
} ShShaderInfo;
|
||||
|
||||
// Compile options.
|
||||
@ -140,8 +119,12 @@ typedef enum {
|
||||
SH_VARIABLES = 0x0008,
|
||||
SH_LINE_DIRECTIVES = 0x0010,
|
||||
SH_SOURCE_PATH = 0x0020,
|
||||
SH_MAP_LONG_VARIABLE_NAMES = 0x0040,
|
||||
SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0080,
|
||||
SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0040,
|
||||
// If a sampler array index happens to be a loop index,
|
||||
// 1) if its type is integer, unroll the loop.
|
||||
// 2) if its type is float, fail the shader compile.
|
||||
// This is to work around a mac driver bug.
|
||||
SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX = 0x0080,
|
||||
|
||||
// This is needed only as a workaround for certain OpenGL driver bugs.
|
||||
SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100,
|
||||
@ -159,7 +142,7 @@ typedef enum {
|
||||
// This flag only has an effect if all of the following are true:
|
||||
// - The shader spec is SH_WEBGL_SPEC.
|
||||
// - The compile options contain the SH_TIMING_RESTRICTIONS flag.
|
||||
// - The shader type is SH_FRAGMENT_SHADER.
|
||||
// - The shader type is GL_FRAGMENT_SHADER.
|
||||
SH_DEPENDENCY_GRAPH = 0x0400,
|
||||
|
||||
// Enforce the GLSL 1.017 Appendix A section 7 packing restrictions.
|
||||
@ -202,6 +185,10 @@ typedef enum {
|
||||
// It is intended as a workaround for drivers which incorrectly optimize
|
||||
// out such varyings and cause a link failure.
|
||||
SH_INIT_VARYINGS_WITHOUT_STATIC_USE = 0x20000,
|
||||
|
||||
// This flag scalarizes vec/ivec/bvec/mat constructor args.
|
||||
// It is intended as a workaround for Linux/Mac driver bugs.
|
||||
SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS = 0x40000,
|
||||
} ShCompileOptions;
|
||||
|
||||
// Defines alternate strategies for implementing array index clamping.
|
||||
@ -252,11 +239,18 @@ typedef struct
|
||||
int ARB_texture_rectangle;
|
||||
int EXT_draw_buffers;
|
||||
int EXT_frag_depth;
|
||||
int EXT_shader_texture_lod;
|
||||
|
||||
// Set to 1 if highp precision is supported in the fragment language.
|
||||
// Default is 0.
|
||||
int FragmentPrecisionHigh;
|
||||
|
||||
// GLSL ES 3.0 constants.
|
||||
int MaxVertexOutputVectors;
|
||||
int MaxFragmentInputVectors;
|
||||
int MinProgramTexelOffset;
|
||||
int MaxProgramTexelOffset;
|
||||
|
||||
// Name Hashing.
|
||||
// Set a 64 bit hash function to enable user-defined name hashing.
|
||||
// Default is NULL.
|
||||
@ -280,27 +274,38 @@ COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources* resources);
|
||||
|
||||
//
|
||||
// ShHandle held by but opaque to the driver. It is allocated,
|
||||
// managed, and de-allocated by the compiler. It's contents
|
||||
// managed, and de-allocated by the compiler. Its contents
|
||||
// are defined by and used by the compiler.
|
||||
//
|
||||
// If handle creation fails, 0 will be returned.
|
||||
//
|
||||
typedef void* ShHandle;
|
||||
|
||||
//
|
||||
// Returns the a concatenated list of the items in ShBuiltInResources as a string.
|
||||
// This function must be updated whenever ShBuiltInResources is changed.
|
||||
// Parameters:
|
||||
// handle: Specifies the handle of the compiler to be used.
|
||||
// outStringLen: Specifies the size of the buffer, in number of characters. The size
|
||||
// of the buffer required to store the resources string can be obtained
|
||||
// by calling ShGetInfo with SH_RESOURCES_STRING_LENGTH.
|
||||
// outStr: Returns a null-terminated string representing all the built-in resources.
|
||||
COMPILER_EXPORT void ShGetBuiltInResourcesString(const ShHandle handle, size_t outStringLen, char *outStr);
|
||||
|
||||
//
|
||||
// Driver calls these to create and destroy compiler objects.
|
||||
//
|
||||
// Returns the handle of constructed compiler, null if the requested compiler is
|
||||
// not supported.
|
||||
// Parameters:
|
||||
// type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER.
|
||||
// type: Specifies the type of shader - GL_FRAGMENT_SHADER or GL_VERTEX_SHADER.
|
||||
// spec: Specifies the language spec the compiler must conform to -
|
||||
// SH_GLES2_SPEC or SH_WEBGL_SPEC.
|
||||
// output: Specifies the output code type - SH_ESSL_OUTPUT, SH_GLSL_OUTPUT,
|
||||
// SH_HLSL9_OUTPUT or SH_HLSL11_OUTPUT.
|
||||
// resources: Specifies the built-in resources.
|
||||
COMPILER_EXPORT ShHandle ShConstructCompiler(
|
||||
ShShaderType type,
|
||||
sh::GLenum type,
|
||||
ShShaderSpec spec,
|
||||
ShShaderOutput output,
|
||||
const ShBuiltInResources* resources);
|
||||
@ -364,6 +369,8 @@ COMPILER_EXPORT int ShCompile(
|
||||
// SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the
|
||||
// null termination character.
|
||||
// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
|
||||
// SH_SHADER_VERSION: the version of the shader language
|
||||
// SH_OUTPUT_TYPE: the currently set language output type
|
||||
//
|
||||
// params: Requested parameter
|
||||
COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
|
||||
@ -422,7 +429,7 @@ COMPILER_EXPORT void ShGetVariableInfo(const ShHandle handle,
|
||||
int index,
|
||||
size_t* length,
|
||||
int* size,
|
||||
ShDataType* type,
|
||||
sh::GLenum* type,
|
||||
ShPrecisionType* precision,
|
||||
int* staticUse,
|
||||
char* name,
|
||||
@ -460,7 +467,7 @@ COMPILER_EXPORT void ShGetInfoPointer(const ShHandle handle,
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ShDataType type;
|
||||
sh::GLenum type;
|
||||
int size;
|
||||
} ShVariableInfo;
|
||||
|
||||
@ -477,6 +484,29 @@ COMPILER_EXPORT int ShCheckVariablesWithinPackingLimits(
|
||||
ShVariableInfo* varInfoArray,
|
||||
size_t varInfoArraySize);
|
||||
|
||||
// Gives the compiler-assigned register for an interface block.
|
||||
// The method writes the value to the output variable "indexOut".
|
||||
// Returns true if it found a valid interface block, false otherwise.
|
||||
// Parameters:
|
||||
// handle: Specifies the compiler
|
||||
// interfaceBlockName: Specifies the interface block
|
||||
// indexOut: output variable that stores the assigned register
|
||||
COMPILER_EXPORT bool ShGetInterfaceBlockRegister(const ShHandle handle,
|
||||
const char *interfaceBlockName,
|
||||
unsigned int *indexOut);
|
||||
|
||||
// Gives the compiler-assigned register for uniforms in the default
|
||||
// interface block.
|
||||
// The method writes the value to the output variable "indexOut".
|
||||
// Returns true if it found a valid default uniform, false otherwise.
|
||||
// Parameters:
|
||||
// handle: Specifies the compiler
|
||||
// interfaceBlockName: Specifies the uniform
|
||||
// indexOut: output variable that stores the assigned register
|
||||
COMPILER_EXPORT bool ShGetUniformRegister(const ShHandle handle,
|
||||
const char *uniformName,
|
||||
unsigned int *indexOut);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
26
src/3rdparty/angle/include/angle_gl.h
vendored
Normal file
26
src/3rdparty/angle/include/angle_gl.h
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// angle_gl.h:
|
||||
// Includes all necessary GL headers and definitions for ANGLE.
|
||||
//
|
||||
|
||||
#ifndef ANGLE_GL_H_
|
||||
#define ANGLE_GL_H_
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#define GL_APICALL
|
||||
|
||||
#include "GLES2/gl2.h"
|
||||
#include "GLES2/gl2ext.h"
|
||||
#include "GLES3/gl3.h"
|
||||
#include "GLES3/gl3ext.h"
|
||||
|
||||
// The following enum is used in ANGLE, but is from desktop GL
|
||||
#ifndef GL_SAMPLER_2D_RECT_ARB
|
||||
#define GL_SAMPLER_2D_RECT_ARB 0x8B63
|
||||
#endif
|
||||
|
||||
#endif // ANGLE_GL_H_
|
12
src/3rdparty/angle/src/commit.h
vendored
12
src/3rdparty/angle/src/commit.h
vendored
@ -1,2 +1,12 @@
|
||||
#define ANGLE_COMMIT_HASH "5bb7ec572d0a"
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// commit.h:
|
||||
// This is a default commit hash header, when git is not available.
|
||||
//
|
||||
|
||||
#define ANGLE_COMMIT_HASH "07d49ef5350a"
|
||||
#define ANGLE_COMMIT_HASH_SIZE 12
|
||||
#define ANGLE_COMMIT_DATE "2014-07-25 16:01:42 +0000"
|
||||
|
34
src/3rdparty/angle/src/common/RefCountObject.h
vendored
34
src/3rdparty/angle/src/common/RefCountObject.h
vendored
@ -14,8 +14,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#define GL_APICALL
|
||||
#include <GLES2/gl2.h>
|
||||
#include "angle_gl.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
|
||||
@ -62,4 +61,35 @@ class BindingPointer : public RefCountObjectBindingPointer
|
||||
ObjectType *operator->() const { return get(); }
|
||||
};
|
||||
|
||||
template <class ObjectType>
|
||||
class OffsetBindingPointer : public RefCountObjectBindingPointer
|
||||
{
|
||||
public:
|
||||
OffsetBindingPointer() : mOffset(0), mSize(0) { }
|
||||
|
||||
void set(ObjectType *newObject)
|
||||
{
|
||||
RefCountObjectBindingPointer::set(newObject);
|
||||
mOffset = 0;
|
||||
mSize = 0;
|
||||
}
|
||||
|
||||
void set(ObjectType *newObject, GLintptr offset, GLsizeiptr size)
|
||||
{
|
||||
RefCountObjectBindingPointer::set(newObject);
|
||||
mOffset = offset;
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
GLintptr getOffset() const { return mOffset; }
|
||||
GLsizeiptr getSize() const { return mSize; }
|
||||
|
||||
ObjectType *get() const { return static_cast<ObjectType*>(RefCountObjectBindingPointer::get()); }
|
||||
ObjectType *operator->() const { return get(); }
|
||||
|
||||
private:
|
||||
GLintptr mOffset;
|
||||
GLsizeiptr mSize;
|
||||
};
|
||||
|
||||
#endif // COMMON_REFCOUNTOBJECT_H_
|
||||
|
79
src/3rdparty/angle/src/common/angleutils.h
vendored
79
src/3rdparty/angle/src/common/angleutils.h
vendored
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -9,7 +9,13 @@
|
||||
#ifndef COMMON_ANGLEUTILS_H_
|
||||
#define COMMON_ANGLEUTILS_H_
|
||||
|
||||
#include "common/platform.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
// A macro to disallow the copy constructor and operator= functions
|
||||
// This must be used in the private: declarations for a class
|
||||
@ -49,6 +55,16 @@ void SafeDelete(T*& resource)
|
||||
resource = NULL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SafeDeleteContainer(T& resource)
|
||||
{
|
||||
for (typename T::iterator i = resource.begin(); i != resource.end(); i++)
|
||||
{
|
||||
SafeDelete(*i);
|
||||
}
|
||||
resource.clear();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SafeDeleteArray(T*& resource)
|
||||
{
|
||||
@ -56,6 +72,65 @@ void SafeDeleteArray(T*& resource)
|
||||
resource = NULL;
|
||||
}
|
||||
|
||||
// Provide a less-than function for comparing structs
|
||||
// Note: struct memory must be initialized to zero, because of packing gaps
|
||||
template <typename T>
|
||||
inline bool StructLessThan(const T &a, const T &b)
|
||||
{
|
||||
return (memcmp(&a, &b, sizeof(T)) < 0);
|
||||
}
|
||||
|
||||
// Provide a less-than function for comparing structs
|
||||
// Note: struct memory must be initialized to zero, because of packing gaps
|
||||
template <typename T>
|
||||
inline bool StructEquals(const T &a, const T &b)
|
||||
{
|
||||
return (memcmp(&a, &b, sizeof(T)) == 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void StructZero(T *obj)
|
||||
{
|
||||
memset(obj, 0, sizeof(T));
|
||||
}
|
||||
|
||||
inline const char* MakeStaticString(const std::string &str)
|
||||
{
|
||||
static std::set<std::string> strings;
|
||||
std::set<std::string>::iterator it = strings.find(str);
|
||||
if (it != strings.end())
|
||||
{
|
||||
return it->c_str();
|
||||
}
|
||||
|
||||
return strings.insert(str).first->c_str();
|
||||
}
|
||||
|
||||
inline std::string ArrayString(unsigned int i)
|
||||
{
|
||||
// We assume UINT_MAX and GL_INVALID_INDEX are equal
|
||||
// See DynamicHLSL.cpp
|
||||
if (i == UINT_MAX)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream strstr;
|
||||
|
||||
strstr << "[";
|
||||
strstr << i;
|
||||
strstr << "]";
|
||||
|
||||
return strstr.str();
|
||||
}
|
||||
|
||||
inline std::string Str(int i)
|
||||
{
|
||||
std::stringstream strstr;
|
||||
strstr << i;
|
||||
return strstr.str();
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
@ -66,5 +141,7 @@ void SafeDeleteArray(T*& resource)
|
||||
|
||||
#define GL_BGRA4_ANGLEX 0x6ABC
|
||||
#define GL_BGR5_A1_ANGLEX 0x6ABD
|
||||
#define GL_INT_64_ANGLEX 0x6ABE
|
||||
#define GL_STRUCT_ANGLEX 0x6ABF
|
||||
|
||||
#endif // COMMON_ANGLEUTILS_H_
|
||||
|
289
src/3rdparty/angle/src/common/blocklayout.cpp
vendored
Normal file
289
src/3rdparty/angle/src/common/blocklayout.cpp
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
//
|
||||
// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// blocklayout.cpp:
|
||||
// Implementation for block layout classes and methods.
|
||||
//
|
||||
|
||||
#include "common/blocklayout.h"
|
||||
#include "common/shadervars.h"
|
||||
#include "common/mathutil.h"
|
||||
#include "common/utilities.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
BlockLayoutEncoder::BlockLayoutEncoder()
|
||||
: mCurrentOffset(0)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields)
|
||||
{
|
||||
for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
|
||||
{
|
||||
const InterfaceBlockField &variable = fields[fieldIndex];
|
||||
|
||||
if (variable.fields.size() > 0)
|
||||
{
|
||||
const unsigned int elementCount = std::max(1u, variable.arraySize);
|
||||
|
||||
for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++)
|
||||
{
|
||||
enterAggregateType();
|
||||
encodeInterfaceBlockFields(variable.fields);
|
||||
exitAggregateType();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
encodeInterfaceBlockField(variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockMemberInfo BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field)
|
||||
{
|
||||
int arrayStride;
|
||||
int matrixStride;
|
||||
|
||||
ASSERT(field.fields.empty());
|
||||
getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride);
|
||||
|
||||
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
|
||||
|
||||
advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride);
|
||||
|
||||
return memberInfo;
|
||||
}
|
||||
|
||||
void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
|
||||
{
|
||||
int arrayStride;
|
||||
int matrixStride;
|
||||
|
||||
getBlockLayoutInfo(type, arraySize, isRowMajorMatrix, &arrayStride, &matrixStride);
|
||||
|
||||
const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
|
||||
|
||||
advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride);
|
||||
}
|
||||
|
||||
void BlockLayoutEncoder::nextRegister()
|
||||
{
|
||||
mCurrentOffset = rx::roundUp<size_t>(mCurrentOffset, ComponentsPerRegister);
|
||||
}
|
||||
|
||||
Std140BlockEncoder::Std140BlockEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
void Std140BlockEncoder::enterAggregateType()
|
||||
{
|
||||
nextRegister();
|
||||
}
|
||||
|
||||
void Std140BlockEncoder::exitAggregateType()
|
||||
{
|
||||
nextRegister();
|
||||
}
|
||||
|
||||
void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
|
||||
{
|
||||
// We assume we are only dealing with 4 byte components (no doubles or half-words currently)
|
||||
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent);
|
||||
|
||||
size_t baseAlignment = 0;
|
||||
int matrixStride = 0;
|
||||
int arrayStride = 0;
|
||||
|
||||
if (gl::IsMatrixType(type))
|
||||
{
|
||||
baseAlignment = ComponentsPerRegister;
|
||||
matrixStride = ComponentsPerRegister;
|
||||
|
||||
if (arraySize > 0)
|
||||
{
|
||||
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
|
||||
arrayStride = ComponentsPerRegister * numRegisters;
|
||||
}
|
||||
}
|
||||
else if (arraySize > 0)
|
||||
{
|
||||
baseAlignment = ComponentsPerRegister;
|
||||
arrayStride = ComponentsPerRegister;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int numComponents = gl::VariableComponentCount(type);
|
||||
baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
|
||||
}
|
||||
|
||||
mCurrentOffset = rx::roundUp(mCurrentOffset, baseAlignment);
|
||||
|
||||
*matrixStrideOut = matrixStride;
|
||||
*arrayStrideOut = arrayStride;
|
||||
}
|
||||
|
||||
void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
|
||||
{
|
||||
if (arraySize > 0)
|
||||
{
|
||||
mCurrentOffset += arrayStride * arraySize;
|
||||
}
|
||||
else if (gl::IsMatrixType(type))
|
||||
{
|
||||
ASSERT(matrixStride == ComponentsPerRegister);
|
||||
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
|
||||
mCurrentOffset += ComponentsPerRegister * numRegisters;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentOffset += gl::VariableComponentCount(type);
|
||||
}
|
||||
}
|
||||
|
||||
HLSLBlockEncoder::HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy)
|
||||
: mEncoderStrategy(strategy)
|
||||
{
|
||||
}
|
||||
|
||||
void HLSLBlockEncoder::enterAggregateType()
|
||||
{
|
||||
nextRegister();
|
||||
}
|
||||
|
||||
void HLSLBlockEncoder::exitAggregateType()
|
||||
{
|
||||
}
|
||||
|
||||
void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
|
||||
{
|
||||
// We assume we are only dealing with 4 byte components (no doubles or half-words currently)
|
||||
ASSERT(gl::VariableComponentSize(gl::VariableComponentType(type)) == BytesPerComponent);
|
||||
|
||||
int matrixStride = 0;
|
||||
int arrayStride = 0;
|
||||
|
||||
// if variables are not to be packed, or we're about to
|
||||
// pack a matrix or array, skip to the start of the next
|
||||
// register
|
||||
if (!isPacked() ||
|
||||
gl::IsMatrixType(type) ||
|
||||
arraySize > 0)
|
||||
{
|
||||
nextRegister();
|
||||
}
|
||||
|
||||
if (gl::IsMatrixType(type))
|
||||
{
|
||||
matrixStride = ComponentsPerRegister;
|
||||
|
||||
if (arraySize > 0)
|
||||
{
|
||||
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
|
||||
arrayStride = ComponentsPerRegister * numRegisters;
|
||||
}
|
||||
}
|
||||
else if (arraySize > 0)
|
||||
{
|
||||
arrayStride = ComponentsPerRegister;
|
||||
}
|
||||
else if (isPacked())
|
||||
{
|
||||
int numComponents = gl::VariableComponentCount(type);
|
||||
if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
|
||||
{
|
||||
nextRegister();
|
||||
}
|
||||
}
|
||||
|
||||
*matrixStrideOut = matrixStride;
|
||||
*arrayStrideOut = arrayStride;
|
||||
}
|
||||
|
||||
void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
|
||||
{
|
||||
if (arraySize > 0)
|
||||
{
|
||||
mCurrentOffset += arrayStride * (arraySize - 1);
|
||||
}
|
||||
|
||||
if (gl::IsMatrixType(type))
|
||||
{
|
||||
ASSERT(matrixStride == ComponentsPerRegister);
|
||||
const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
|
||||
const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix);
|
||||
mCurrentOffset += ComponentsPerRegister * (numRegisters - 1);
|
||||
mCurrentOffset += numComponents;
|
||||
}
|
||||
else if (isPacked())
|
||||
{
|
||||
mCurrentOffset += gl::VariableComponentCount(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentOffset += ComponentsPerRegister;
|
||||
}
|
||||
}
|
||||
|
||||
void HLSLBlockEncoder::skipRegisters(unsigned int numRegisters)
|
||||
{
|
||||
mCurrentOffset += (numRegisters * ComponentsPerRegister);
|
||||
}
|
||||
|
||||
HLSLBlockEncoder::HLSLBlockEncoderStrategy HLSLBlockEncoder::GetStrategyFor(ShShaderOutput outputType)
|
||||
{
|
||||
switch (outputType)
|
||||
{
|
||||
case SH_HLSL9_OUTPUT: return ENCODE_LOOSE;
|
||||
case SH_HLSL11_OUTPUT: return ENCODE_PACKED;
|
||||
default: UNREACHABLE(); return ENCODE_PACKED;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ShaderVarType>
|
||||
void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *encoder)
|
||||
{
|
||||
if (variable.isStruct())
|
||||
{
|
||||
for (size_t arrayElement = 0; arrayElement < variable.elementCount(); arrayElement++)
|
||||
{
|
||||
encoder->enterAggregateType();
|
||||
|
||||
for (size_t fieldIndex = 0; fieldIndex < variable.fields.size(); fieldIndex++)
|
||||
{
|
||||
HLSLVariableRegisterCount(variable.fields[fieldIndex], encoder);
|
||||
}
|
||||
|
||||
encoder->exitAggregateType();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We operate only on varyings and uniforms, which do not have matrix layout qualifiers
|
||||
encoder->encodeType(variable.type, variable.arraySize, false);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int HLSLVariableRegisterCount(const Varying &variable)
|
||||
{
|
||||
HLSLBlockEncoder encoder(HLSLBlockEncoder::ENCODE_PACKED);
|
||||
HLSLVariableRegisterCount(variable, &encoder);
|
||||
|
||||
const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
|
||||
return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes);
|
||||
}
|
||||
|
||||
unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType)
|
||||
{
|
||||
HLSLBlockEncoder encoder(HLSLBlockEncoder::GetStrategyFor(outputType));
|
||||
HLSLVariableRegisterCount(variable, &encoder);
|
||||
|
||||
const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
|
||||
return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes);
|
||||
}
|
||||
|
||||
}
|
128
src/3rdparty/angle/src/common/blocklayout.h
vendored
Normal file
128
src/3rdparty/angle/src/common/blocklayout.h
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
//
|
||||
// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// blocklayout.h:
|
||||
// Methods and classes related to uniform layout and packing in GLSL and HLSL.
|
||||
//
|
||||
|
||||
#ifndef COMMON_BLOCKLAYOUT_H_
|
||||
#define COMMON_BLOCKLAYOUT_H_
|
||||
|
||||
#include <vector>
|
||||
#include "angle_gl.h"
|
||||
#include <GLSLANG/ShaderLang.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace sh
|
||||
{
|
||||
struct ShaderVariable;
|
||||
struct InterfaceBlockField;
|
||||
struct Uniform;
|
||||
struct Varying;
|
||||
struct InterfaceBlock;
|
||||
|
||||
struct BlockMemberInfo
|
||||
{
|
||||
BlockMemberInfo(int offset, int arrayStride, int matrixStride, bool isRowMajorMatrix)
|
||||
: offset(offset),
|
||||
arrayStride(arrayStride),
|
||||
matrixStride(matrixStride),
|
||||
isRowMajorMatrix(isRowMajorMatrix)
|
||||
{}
|
||||
|
||||
static BlockMemberInfo getDefaultBlockInfo()
|
||||
{
|
||||
return BlockMemberInfo(-1, -1, -1, false);
|
||||
}
|
||||
|
||||
int offset;
|
||||
int arrayStride;
|
||||
int matrixStride;
|
||||
bool isRowMajorMatrix;
|
||||
};
|
||||
|
||||
class BlockLayoutEncoder
|
||||
{
|
||||
public:
|
||||
BlockLayoutEncoder();
|
||||
|
||||
void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields);
|
||||
BlockMemberInfo encodeInterfaceBlockField(const InterfaceBlockField &field);
|
||||
void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
|
||||
|
||||
size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
|
||||
size_t getCurrentRegister() const { return mCurrentOffset / ComponentsPerRegister; }
|
||||
size_t getCurrentElement() const { return mCurrentOffset % ComponentsPerRegister; }
|
||||
|
||||
virtual void enterAggregateType() = 0;
|
||||
virtual void exitAggregateType() = 0;
|
||||
|
||||
static const size_t BytesPerComponent = 4u;
|
||||
static const unsigned int ComponentsPerRegister = 4u;
|
||||
|
||||
protected:
|
||||
size_t mCurrentOffset;
|
||||
|
||||
void nextRegister();
|
||||
|
||||
virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0;
|
||||
virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0;
|
||||
};
|
||||
|
||||
// Block layout according to the std140 block layout
|
||||
// See "Standard Uniform Block Layout" in Section 2.11.6 of the OpenGL ES 3.0 specification
|
||||
|
||||
class Std140BlockEncoder : public BlockLayoutEncoder
|
||||
{
|
||||
public:
|
||||
Std140BlockEncoder();
|
||||
|
||||
virtual void enterAggregateType();
|
||||
virtual void exitAggregateType();
|
||||
|
||||
protected:
|
||||
virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
|
||||
virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
|
||||
};
|
||||
|
||||
// Block layout packed according to the D3D9 or default D3D10+ register packing rules
|
||||
// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx
|
||||
// The strategy should be ENCODE_LOOSE for D3D9 constant blocks, and ENCODE_PACKED
|
||||
// for everything else (D3D10+ constant blocks and all attributes/varyings).
|
||||
|
||||
class HLSLBlockEncoder : public BlockLayoutEncoder
|
||||
{
|
||||
public:
|
||||
enum HLSLBlockEncoderStrategy
|
||||
{
|
||||
ENCODE_PACKED,
|
||||
ENCODE_LOOSE
|
||||
};
|
||||
|
||||
HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy);
|
||||
|
||||
virtual void enterAggregateType();
|
||||
virtual void exitAggregateType();
|
||||
void skipRegisters(unsigned int numRegisters);
|
||||
|
||||
bool isPacked() const { return mEncoderStrategy == ENCODE_PACKED; }
|
||||
|
||||
static HLSLBlockEncoderStrategy GetStrategyFor(ShShaderOutput outputType);
|
||||
|
||||
protected:
|
||||
virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
|
||||
virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
|
||||
|
||||
HLSLBlockEncoderStrategy mEncoderStrategy;
|
||||
};
|
||||
|
||||
// This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
|
||||
// class to count the number of used registers in a struct (which are individually packed according to the same rules).
|
||||
unsigned int HLSLVariableRegisterCount(const Varying &variable);
|
||||
unsigned int HLSLVariableRegisterCount(const Uniform &variable, ShShaderOutput outputType);
|
||||
|
||||
}
|
||||
|
||||
#endif // COMMON_BLOCKLAYOUT_H_
|
53
src/3rdparty/angle/src/common/debug.cpp
vendored
53
src/3rdparty/angle/src/common/debug.cpp
vendored
@ -7,11 +7,12 @@
|
||||
// debug.cpp: Debugging utilities.
|
||||
|
||||
#include "common/debug.h"
|
||||
#include <stdarg.h>
|
||||
#include "common/platform.h"
|
||||
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
#include <d3d9.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cstdio>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
@ -23,25 +24,38 @@ typedef void (*PerfOutputFunction)(unsigned int, const wchar_t*);
|
||||
|
||||
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
|
||||
{
|
||||
#if defined(ANGLE_ENABLE_PERF) || defined(ANGLE_ENABLE_TRACE)
|
||||
static std::vector<char> asciiMessageBuffer(512);
|
||||
|
||||
// Attempt to just print to the current buffer
|
||||
int len = vsnprintf(&asciiMessageBuffer[0], asciiMessageBuffer.size(), format, vararg);
|
||||
if (len < 0 || static_cast<size_t>(len) >= asciiMessageBuffer.size())
|
||||
{
|
||||
// Buffer was not large enough, calculate the required size and resize the buffer
|
||||
len = vsnprintf(NULL, 0, format, vararg);
|
||||
asciiMessageBuffer.resize(len + 1);
|
||||
|
||||
// Print again
|
||||
vsnprintf(&asciiMessageBuffer[0], asciiMessageBuffer.size(), format, vararg);
|
||||
}
|
||||
|
||||
// NULL terminate the buffer to be safe
|
||||
asciiMessageBuffer[len] = '\0';
|
||||
#endif
|
||||
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
char message[32768];
|
||||
int len = vsprintf_s(message, format, vararg);
|
||||
if (len < 0)
|
||||
// The perf function only accepts wide strings, widen the ascii message
|
||||
static std::wstring wideMessage;
|
||||
if (wideMessage.capacity() < asciiMessageBuffer.size())
|
||||
{
|
||||
return;
|
||||
wideMessage.reserve(asciiMessageBuffer.size());
|
||||
}
|
||||
|
||||
// There are no ASCII variants of these D3DPERF functions.
|
||||
wchar_t wideMessage[32768];
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
wideMessage[i] = message[i];
|
||||
}
|
||||
wideMessage[len] = 0;
|
||||
wideMessage.assign(asciiMessageBuffer.begin(), asciiMessageBuffer.begin() + len);
|
||||
|
||||
perfFunc(0, wideMessage);
|
||||
perfFunc(0, wideMessage.c_str());
|
||||
}
|
||||
#endif // ANGLE_ENABLE_PERF
|
||||
|
||||
@ -53,12 +67,13 @@ static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const c
|
||||
}
|
||||
#endif // NDEBUG
|
||||
|
||||
FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
|
||||
static std::ofstream file(TRACE_OUTPUT_FILE, std::ofstream::app);
|
||||
if (file)
|
||||
{
|
||||
vfprintf(file, format, vararg);
|
||||
fclose(file);
|
||||
file.write(&asciiMessageBuffer[0], len);
|
||||
file.flush();
|
||||
}
|
||||
|
||||
#endif // ANGLE_ENABLE_TRACE
|
||||
}
|
||||
|
||||
|
32
src/3rdparty/angle/src/common/debug.h
vendored
32
src/3rdparty/angle/src/common/debug.h
vendored
@ -62,7 +62,7 @@ namespace gl
|
||||
// A macro to log a performance event around a scope.
|
||||
#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
|
||||
#if defined(_MSC_VER)
|
||||
#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__(__FUNCTION__ message "\n", __VA_ARGS__);
|
||||
#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper ## __LINE__("%s" message "\n", __FUNCTION__, __VA_ARGS__);
|
||||
#else
|
||||
#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper(message "\n", ##__VA_ARGS__);
|
||||
#endif // _MSC_VER
|
||||
@ -77,15 +77,30 @@ namespace gl
|
||||
ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
|
||||
assert(expression); \
|
||||
} while(0)
|
||||
#define UNUSED_ASSERTION_VARIABLE(variable)
|
||||
#else
|
||||
#define ASSERT(expression) (void(0))
|
||||
#define UNUSED_ASSERTION_VARIABLE(variable) ((void)variable)
|
||||
#endif
|
||||
|
||||
#ifndef ANGLE_ENABLE_TRACE
|
||||
#define UNUSED_TRACE_VARIABLE(variable) ((void)variable)
|
||||
#else
|
||||
#define UNUSED_TRACE_VARIABLE(variable)
|
||||
#endif
|
||||
|
||||
// A macro to indicate unimplemented functionality
|
||||
|
||||
// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks
|
||||
// This will allow us to test with some automated test suites (eg dEQP) without crashing
|
||||
#ifndef NOASSERT_UNIMPLEMENTED
|
||||
#define NOASSERT_UNIMPLEMENTED 0
|
||||
#endif
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
#define UNIMPLEMENTED() do { \
|
||||
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
|
||||
assert(false); \
|
||||
assert(NOASSERT_UNIMPLEMENTED); \
|
||||
} while(0)
|
||||
#else
|
||||
#define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
|
||||
@ -101,9 +116,7 @@ namespace gl
|
||||
#define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
|
||||
#endif
|
||||
|
||||
// A macro that determines whether an object has a given runtime type. MSVC uses _CPPRTTI.
|
||||
// GCC uses __GXX_RTTI, but the macro was introduced in version 4.3, so we assume that all older
|
||||
// versions support RTTI.
|
||||
// A macro that determines whether an object has a given runtime type.
|
||||
#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI))
|
||||
#define HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type >(obj) != NULL)
|
||||
#else
|
||||
@ -111,6 +124,13 @@ namespace gl
|
||||
#endif
|
||||
|
||||
// A macro functioning as a compile-time assert to validate constant conditions
|
||||
#define META_ASSERT(condition) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast<bool>(condition)?1:-1]
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600
|
||||
#define META_ASSERT_MSG(condition, msg) static_assert(condition, msg)
|
||||
#else
|
||||
#define META_ASSERT_CONCAT(a, b) a ## b
|
||||
#define META_ASSERT_CONCAT2(a, b) META_ASSERT_CONCAT(a, b)
|
||||
#define META_ASSERT_MSG(condition, msg) typedef int META_ASSERT_CONCAT2(COMPILE_TIME_ASSERT_, __LINE__)[static_cast<bool>(condition)?1:-1]
|
||||
#endif
|
||||
#define META_ASSERT(condition) META_ASSERT_MSG(condition, "compile time assertion failed.")
|
||||
|
||||
#endif // COMMON_DEBUG_H_
|
||||
|
6
src/3rdparty/angle/src/common/event_tracer.h
vendored
6
src/3rdparty/angle/src/common/event_tracer.h
vendored
@ -5,12 +5,14 @@
|
||||
#ifndef COMMON_EVENT_TRACER_H_
|
||||
#define COMMON_EVENT_TRACER_H_
|
||||
|
||||
#include "common/platform.h"
|
||||
|
||||
#if !defined(TRACE_ENTRY)
|
||||
#if defined(_WIN32)
|
||||
# ifdef ANGLE_PLATFORM_WINDOWS
|
||||
# define TRACE_ENTRY __stdcall
|
||||
# else
|
||||
# define TRACE_ENTRY
|
||||
#endif // // _WIN32
|
||||
# endif // ANGLE_PLATFORM_WINDOWS
|
||||
#endif //TRACE_ENTRY
|
||||
|
||||
extern "C" {
|
||||
|
66
src/3rdparty/angle/src/common/mathutil.cpp
vendored
Normal file
66
src/3rdparty/angle/src/common/mathutil.cpp
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// mathutil.cpp: Math and bit manipulation functions.
|
||||
|
||||
#include "common/mathutil.h"
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
struct RGB9E5Data
|
||||
{
|
||||
unsigned int R : 9;
|
||||
unsigned int G : 9;
|
||||
unsigned int B : 9;
|
||||
unsigned int E : 5;
|
||||
};
|
||||
|
||||
// B is the exponent bias (15)
|
||||
static const int g_sharedexp_bias = 15;
|
||||
|
||||
// N is the number of mantissa bits per component (9)
|
||||
static const int g_sharedexp_mantissabits = 9;
|
||||
|
||||
// Emax is the maximum allowed biased exponent value (31)
|
||||
static const int g_sharedexp_maxexponent = 31;
|
||||
|
||||
static const float g_sharedexp_max = ((pow(2.0f, g_sharedexp_mantissabits) - 1) /
|
||||
pow(2.0f, g_sharedexp_mantissabits)) *
|
||||
pow(2.0f, g_sharedexp_maxexponent - g_sharedexp_bias);
|
||||
|
||||
unsigned int convertRGBFloatsTo999E5(float red, float green, float blue)
|
||||
{
|
||||
const float red_c = std::max<float>(0, std::min(g_sharedexp_max, red));
|
||||
const float green_c = std::max<float>(0, std::min(g_sharedexp_max, green));
|
||||
const float blue_c = std::max<float>(0, std::min(g_sharedexp_max, blue));
|
||||
|
||||
const float max_c = std::max<float>(std::max<float>(red_c, green_c), blue_c);
|
||||
const float exp_p = std::max<float>(-g_sharedexp_bias - 1, floor(log(max_c))) + 1 + g_sharedexp_bias;
|
||||
const int max_s = floor((max_c / (pow(2.0f, exp_p - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
|
||||
const int exp_s = (max_s < pow(2.0f, g_sharedexp_mantissabits)) ? exp_p : exp_p + 1;
|
||||
|
||||
RGB9E5Data output;
|
||||
output.R = floor((red_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
|
||||
output.G = floor((green_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
|
||||
output.B = floor((blue_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f);
|
||||
output.E = exp_s;
|
||||
|
||||
return *reinterpret_cast<unsigned int*>(&output);
|
||||
}
|
||||
|
||||
void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float *blue)
|
||||
{
|
||||
const RGB9E5Data *inputData = reinterpret_cast<const RGB9E5Data*>(&input);
|
||||
|
||||
*red = inputData->R * pow(2.0f, (int)inputData->E - g_sharedexp_bias - g_sharedexp_mantissabits);
|
||||
*green = inputData->G * pow(2.0f, (int)inputData->E - g_sharedexp_bias - g_sharedexp_mantissabits);
|
||||
*blue = inputData->B * pow(2.0f, (int)inputData->E - g_sharedexp_bias - g_sharedexp_mantissabits);
|
||||
}
|
||||
|
||||
}
|
545
src/3rdparty/angle/src/common/mathutil.h
vendored
Normal file
545
src/3rdparty/angle/src/common/mathutil.h
vendored
Normal file
@ -0,0 +1,545 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// mathutil.h: Math and bit manipulation functions.
|
||||
|
||||
#ifndef LIBGLESV2_MATHUTIL_H_
|
||||
#define LIBGLESV2_MATHUTIL_H_
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/platform.h"
|
||||
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
const unsigned int Float32One = 0x3F800000;
|
||||
const unsigned short Float16One = 0x3C00;
|
||||
|
||||
struct Vector4
|
||||
{
|
||||
Vector4() {}
|
||||
Vector4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
|
||||
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
};
|
||||
|
||||
inline bool isPow2(int x)
|
||||
{
|
||||
return (x & (x - 1)) == 0 && (x != 0);
|
||||
}
|
||||
|
||||
inline int log2(int x)
|
||||
{
|
||||
int r = 0;
|
||||
while ((x >> r) > 1) r++;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline unsigned int ceilPow2(unsigned int x)
|
||||
{
|
||||
if (x != 0) x--;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
inline int clampToInt(unsigned int x)
|
||||
{
|
||||
return static_cast<int>(std::min(x, static_cast<unsigned int>(std::numeric_limits<int>::max())));
|
||||
}
|
||||
|
||||
template <typename DestT, typename SrcT>
|
||||
inline DestT clampCast(SrcT value)
|
||||
{
|
||||
// This assumes SrcT can properly represent DestT::min/max
|
||||
// Unfortunately we can't use META_ASSERT without C++11 constexpr support
|
||||
ASSERT(static_cast<DestT>(static_cast<SrcT>(std::numeric_limits<DestT>::min())) == std::numeric_limits<DestT>::min());
|
||||
ASSERT(static_cast<DestT>(static_cast<SrcT>(std::numeric_limits<DestT>::max())) == std::numeric_limits<DestT>::max());
|
||||
|
||||
SrcT lo = static_cast<SrcT>(std::numeric_limits<DestT>::min());
|
||||
SrcT hi = static_cast<SrcT>(std::numeric_limits<DestT>::max());
|
||||
return static_cast<DestT>(value > lo ? (value > hi ? hi : value) : lo);
|
||||
}
|
||||
|
||||
template<typename T, typename MIN, typename MAX>
|
||||
inline T clamp(T x, MIN min, MAX max)
|
||||
{
|
||||
// Since NaNs fail all comparison tests, a NaN value will default to min
|
||||
return x > min ? (x > max ? max : x) : min;
|
||||
}
|
||||
|
||||
inline float clamp01(float x)
|
||||
{
|
||||
return clamp(x, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
template<const int n>
|
||||
inline unsigned int unorm(float x)
|
||||
{
|
||||
const unsigned int max = 0xFFFFFFFF >> (32 - n);
|
||||
|
||||
if (x > 1)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (x < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (unsigned int)(max * x + 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool supportsSSE2()
|
||||
{
|
||||
#ifdef ANGLE_PLATFORM_WINDOWS
|
||||
static bool checked = false;
|
||||
static bool supports = false;
|
||||
|
||||
if (checked)
|
||||
{
|
||||
return supports;
|
||||
}
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) // ARM doesn't provide __cpuid()
|
||||
int info[4];
|
||||
__cpuid(info, 0);
|
||||
|
||||
if (info[0] >= 1)
|
||||
{
|
||||
__cpuid(info, 1);
|
||||
|
||||
supports = (info[3] >> 26) & 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
checked = true;
|
||||
|
||||
return supports;
|
||||
#else
|
||||
UNIMPLEMENTED();
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename destType, typename sourceType>
|
||||
destType bitCast(const sourceType &source)
|
||||
{
|
||||
size_t copySize = std::min(sizeof(destType), sizeof(sourceType));
|
||||
destType output;
|
||||
memcpy(&output, &source, copySize);
|
||||
return output;
|
||||
}
|
||||
|
||||
inline unsigned short float32ToFloat16(float fp32)
|
||||
{
|
||||
unsigned int fp32i = (unsigned int&)fp32;
|
||||
unsigned int sign = (fp32i & 0x80000000) >> 16;
|
||||
unsigned int abs = fp32i & 0x7FFFFFFF;
|
||||
|
||||
if(abs > 0x47FFEFFF) // Infinity
|
||||
{
|
||||
return sign | 0x7FFF;
|
||||
}
|
||||
else if(abs < 0x38800000) // Denormal
|
||||
{
|
||||
unsigned int mantissa = (abs & 0x007FFFFF) | 0x00800000;
|
||||
int e = 113 - (abs >> 23);
|
||||
|
||||
if(e < 24)
|
||||
{
|
||||
abs = mantissa >> e;
|
||||
}
|
||||
else
|
||||
{
|
||||
abs = 0;
|
||||
}
|
||||
|
||||
return sign | (abs + 0x00000FFF + ((abs >> 13) & 1)) >> 13;
|
||||
}
|
||||
else
|
||||
{
|
||||
return sign | (abs + 0xC8000000 + 0x00000FFF + ((abs >> 13) & 1)) >> 13;
|
||||
}
|
||||
}
|
||||
|
||||
float float16ToFloat32(unsigned short h);
|
||||
|
||||
unsigned int convertRGBFloatsTo999E5(float red, float green, float blue);
|
||||
void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float *blue);
|
||||
|
||||
inline unsigned short float32ToFloat11(float fp32)
|
||||
{
|
||||
const unsigned int float32MantissaMask = 0x7FFFFF;
|
||||
const unsigned int float32ExponentMask = 0x7F800000;
|
||||
const unsigned int float32SignMask = 0x80000000;
|
||||
const unsigned int float32ValueMask = ~float32SignMask;
|
||||
const unsigned int float32ExponentFirstBit = 23;
|
||||
const unsigned int float32ExponentBias = 127;
|
||||
|
||||
const unsigned short float11Max = 0x7BF;
|
||||
const unsigned short float11MantissaMask = 0x3F;
|
||||
const unsigned short float11ExponentMask = 0x7C0;
|
||||
const unsigned short float11BitMask = 0x7FF;
|
||||
const unsigned int float11ExponentBias = 14;
|
||||
|
||||
const unsigned int float32Maxfloat11 = 0x477E0000;
|
||||
const unsigned int float32Minfloat11 = 0x38800000;
|
||||
|
||||
const unsigned int float32Bits = bitCast<unsigned int>(fp32);
|
||||
const bool float32Sign = (float32Bits & float32SignMask) == float32SignMask;
|
||||
|
||||
unsigned int float32Val = float32Bits & float32ValueMask;
|
||||
|
||||
if ((float32Val & float32ExponentMask) == float32ExponentMask)
|
||||
{
|
||||
// INF or NAN
|
||||
if ((float32Val & float32MantissaMask) != 0)
|
||||
{
|
||||
return float11ExponentMask | (((float32Val >> 17) | (float32Val >> 11) | (float32Val >> 6) | (float32Val)) & float11MantissaMask);
|
||||
}
|
||||
else if (float32Sign)
|
||||
{
|
||||
// -INF is clamped to 0 since float11 is positive only
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return float11ExponentMask;
|
||||
}
|
||||
}
|
||||
else if (float32Sign)
|
||||
{
|
||||
// float11 is positive only, so clamp to zero
|
||||
return 0;
|
||||
}
|
||||
else if (float32Val > float32Maxfloat11)
|
||||
{
|
||||
// The number is too large to be represented as a float11, set to max
|
||||
return float11Max;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (float32Val < float32Minfloat11)
|
||||
{
|
||||
// The number is too small to be represented as a normalized float11
|
||||
// Convert it to a denormalized value.
|
||||
const unsigned int shift = (float32ExponentBias - float11ExponentBias) - (float32Val >> float32ExponentFirstBit);
|
||||
float32Val = ((1 << float32ExponentFirstBit) | (float32Val & float32MantissaMask)) >> shift;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rebias the exponent to represent the value as a normalized float11
|
||||
float32Val += 0xC8000000;
|
||||
}
|
||||
|
||||
return ((float32Val + 0xFFFF + ((float32Val >> 17) & 1)) >> 17) & float11BitMask;
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned short float32ToFloat10(float fp32)
|
||||
{
|
||||
const unsigned int float32MantissaMask = 0x7FFFFF;
|
||||
const unsigned int float32ExponentMask = 0x7F800000;
|
||||
const unsigned int float32SignMask = 0x80000000;
|
||||
const unsigned int float32ValueMask = ~float32SignMask;
|
||||
const unsigned int float32ExponentFirstBit = 23;
|
||||
const unsigned int float32ExponentBias = 127;
|
||||
|
||||
const unsigned short float10Max = 0x3DF;
|
||||
const unsigned short float10MantissaMask = 0x1F;
|
||||
const unsigned short float10ExponentMask = 0x3E0;
|
||||
const unsigned short float10BitMask = 0x3FF;
|
||||
const unsigned int float10ExponentBias = 14;
|
||||
|
||||
const unsigned int float32Maxfloat10 = 0x477C0000;
|
||||
const unsigned int float32Minfloat10 = 0x38800000;
|
||||
|
||||
const unsigned int float32Bits = bitCast<unsigned int>(fp32);
|
||||
const bool float32Sign = (float32Bits & float32SignMask) == float32SignMask;
|
||||
|
||||
unsigned int float32Val = float32Bits & float32ValueMask;
|
||||
|
||||
if ((float32Val & float32ExponentMask) == float32ExponentMask)
|
||||
{
|
||||
// INF or NAN
|
||||
if ((float32Val & float32MantissaMask) != 0)
|
||||
{
|
||||
return float10ExponentMask | (((float32Val >> 18) | (float32Val >> 13) | (float32Val >> 3) | (float32Val)) & float10MantissaMask);
|
||||
}
|
||||
else if (float32Sign)
|
||||
{
|
||||
// -INF is clamped to 0 since float11 is positive only
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return float10ExponentMask;
|
||||
}
|
||||
}
|
||||
else if (float32Sign)
|
||||
{
|
||||
// float10 is positive only, so clamp to zero
|
||||
return 0;
|
||||
}
|
||||
else if (float32Val > float32Maxfloat10)
|
||||
{
|
||||
// The number is too large to be represented as a float11, set to max
|
||||
return float10Max;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (float32Val < float32Minfloat10)
|
||||
{
|
||||
// The number is too small to be represented as a normalized float11
|
||||
// Convert it to a denormalized value.
|
||||
const unsigned int shift = (float32ExponentBias - float10ExponentBias) - (float32Val >> float32ExponentFirstBit);
|
||||
float32Val = ((1 << float32ExponentFirstBit) | (float32Val & float32MantissaMask)) >> shift;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rebias the exponent to represent the value as a normalized float11
|
||||
float32Val += 0xC8000000;
|
||||
}
|
||||
|
||||
return ((float32Val + 0x1FFFF + ((float32Val >> 18) & 1)) >> 18) & float10BitMask;
|
||||
}
|
||||
}
|
||||
|
||||
inline float float11ToFloat32(unsigned short fp11)
|
||||
{
|
||||
unsigned short exponent = (fp11 >> 6) & 0x1F;
|
||||
unsigned short mantissa = fp11 & 0x3F;
|
||||
|
||||
if (exponent == 0x1F)
|
||||
{
|
||||
// INF or NAN
|
||||
return bitCast<float>(0x7f800000 | (mantissa << 17));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exponent != 0)
|
||||
{
|
||||
// normalized
|
||||
}
|
||||
else if (mantissa != 0)
|
||||
{
|
||||
// The value is denormalized
|
||||
exponent = 1;
|
||||
|
||||
do
|
||||
{
|
||||
exponent--;
|
||||
mantissa <<= 1;
|
||||
}
|
||||
while ((mantissa & 0x40) == 0);
|
||||
|
||||
mantissa = mantissa & 0x3F;
|
||||
}
|
||||
else // The value is zero
|
||||
{
|
||||
exponent = -112;
|
||||
}
|
||||
|
||||
return bitCast<float>(((exponent + 112) << 23) | (mantissa << 17));
|
||||
}
|
||||
}
|
||||
|
||||
inline float float10ToFloat32(unsigned short fp11)
|
||||
{
|
||||
unsigned short exponent = (fp11 >> 5) & 0x1F;
|
||||
unsigned short mantissa = fp11 & 0x1F;
|
||||
|
||||
if (exponent == 0x1F)
|
||||
{
|
||||
// INF or NAN
|
||||
return bitCast<float>(0x7f800000 | (mantissa << 17));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exponent != 0)
|
||||
{
|
||||
// normalized
|
||||
}
|
||||
else if (mantissa != 0)
|
||||
{
|
||||
// The value is denormalized
|
||||
exponent = 1;
|
||||
|
||||
do
|
||||
{
|
||||
exponent--;
|
||||
mantissa <<= 1;
|
||||
}
|
||||
while ((mantissa & 0x20) == 0);
|
||||
|
||||
mantissa = mantissa & 0x1F;
|
||||
}
|
||||
else // The value is zero
|
||||
{
|
||||
exponent = -112;
|
||||
}
|
||||
|
||||
return bitCast<float>(((exponent + 112) << 23) | (mantissa << 18));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline float normalizedToFloat(T input)
|
||||
{
|
||||
META_ASSERT(std::numeric_limits<T>::is_integer);
|
||||
|
||||
const float inverseMax = 1.0f / std::numeric_limits<T>::max();
|
||||
return input * inverseMax;
|
||||
}
|
||||
|
||||
template <unsigned int inputBitCount, typename T>
|
||||
inline float normalizedToFloat(T input)
|
||||
{
|
||||
META_ASSERT(std::numeric_limits<T>::is_integer);
|
||||
META_ASSERT(inputBitCount < (sizeof(T) * 8));
|
||||
|
||||
const float inverseMax = 1.0f / ((1 << inputBitCount) - 1);
|
||||
return input * inverseMax;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T floatToNormalized(float input)
|
||||
{
|
||||
return std::numeric_limits<T>::max() * input + 0.5f;
|
||||
}
|
||||
|
||||
template <unsigned int outputBitCount, typename T>
|
||||
inline T floatToNormalized(float input)
|
||||
{
|
||||
META_ASSERT(outputBitCount < (sizeof(T) * 8));
|
||||
return ((1 << outputBitCount) - 1) * input + 0.5f;
|
||||
}
|
||||
|
||||
template <unsigned int inputBitCount, unsigned int inputBitStart, typename T>
|
||||
inline T getShiftedData(T input)
|
||||
{
|
||||
META_ASSERT(inputBitCount + inputBitStart <= (sizeof(T) * 8));
|
||||
const T mask = (1 << inputBitCount) - 1;
|
||||
return (input >> inputBitStart) & mask;
|
||||
}
|
||||
|
||||
template <unsigned int inputBitCount, unsigned int inputBitStart, typename T>
|
||||
inline T shiftData(T input)
|
||||
{
|
||||
META_ASSERT(inputBitCount + inputBitStart <= (sizeof(T) * 8));
|
||||
const T mask = (1 << inputBitCount) - 1;
|
||||
return (input & mask) << inputBitStart;
|
||||
}
|
||||
|
||||
|
||||
inline unsigned char average(unsigned char a, unsigned char b)
|
||||
{
|
||||
return ((a ^ b) >> 1) + (a & b);
|
||||
}
|
||||
|
||||
inline signed char average(signed char a, signed char b)
|
||||
{
|
||||
return ((short)a + (short)b) / 2;
|
||||
}
|
||||
|
||||
inline unsigned short average(unsigned short a, unsigned short b)
|
||||
{
|
||||
return ((a ^ b) >> 1) + (a & b);
|
||||
}
|
||||
|
||||
inline signed short average(signed short a, signed short b)
|
||||
{
|
||||
return ((int)a + (int)b) / 2;
|
||||
}
|
||||
|
||||
inline unsigned int average(unsigned int a, unsigned int b)
|
||||
{
|
||||
return ((a ^ b) >> 1) + (a & b);
|
||||
}
|
||||
|
||||
inline signed int average(signed int a, signed int b)
|
||||
{
|
||||
return ((long long)a + (long long)b) / 2;
|
||||
}
|
||||
|
||||
inline float average(float a, float b)
|
||||
{
|
||||
return (a + b) * 0.5f;
|
||||
}
|
||||
|
||||
inline unsigned short averageHalfFloat(unsigned short a, unsigned short b)
|
||||
{
|
||||
return float32ToFloat16((float16ToFloat32(a) + float16ToFloat32(b)) * 0.5f);
|
||||
}
|
||||
|
||||
inline unsigned int averageFloat11(unsigned int a, unsigned int b)
|
||||
{
|
||||
return float32ToFloat11((float11ToFloat32(a) + float11ToFloat32(b)) * 0.5f);
|
||||
}
|
||||
|
||||
inline unsigned int averageFloat10(unsigned int a, unsigned int b)
|
||||
{
|
||||
return float32ToFloat10((float10ToFloat32(a) + float10ToFloat32(b)) * 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace rx
|
||||
{
|
||||
|
||||
struct Range
|
||||
{
|
||||
Range() {}
|
||||
Range(int lo, int hi) : start(lo), end(hi) { ASSERT(lo <= hi); }
|
||||
|
||||
int start;
|
||||
int end;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T roundUp(const T value, const T alignment)
|
||||
{
|
||||
return value + alignment - 1 - (value - 1) % alignment;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsUnsignedAdditionSafe(T lhs, T rhs)
|
||||
{
|
||||
META_ASSERT(!std::numeric_limits<T>::is_signed);
|
||||
return (rhs <= std::numeric_limits<T>::max() - lhs);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsUnsignedMultiplicationSafe(T lhs, T rhs)
|
||||
{
|
||||
META_ASSERT(!std::numeric_limits<T>::is_signed);
|
||||
return (lhs == T(0) || rhs == T(0) || (rhs <= std::numeric_limits<T>::max() / lhs));
|
||||
}
|
||||
|
||||
template <class SmallIntT, class BigIntT>
|
||||
inline bool IsIntegerCastSafe(BigIntT bigValue)
|
||||
{
|
||||
return (static_cast<BigIntT>(static_cast<SmallIntT>(bigValue)) == bigValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // LIBGLESV2_MATHUTIL_H_
|
73
src/3rdparty/angle/src/common/platform.h
vendored
Normal file
73
src/3rdparty/angle/src/common/platform.h
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// platform.h: Operating system specific includes and defines.
|
||||
|
||||
#ifndef COMMON_PLATFORM_H_
|
||||
#define COMMON_PLATFORM_H_
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# define ANGLE_PLATFORM_WINDOWS 1
|
||||
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
|
||||
# define ANGLE_PLATFORM_WINRT 1
|
||||
# endif
|
||||
#elif defined(__APPLE__)
|
||||
# define ANGLE_PLATFORM_APPLE 1
|
||||
# define ANGLE_PLATFORM_POSIX 1
|
||||
#elif defined(__linux__)
|
||||
# define ANGLE_PLATFORM_LINUX 1
|
||||
# define ANGLE_PLATFORM_POSIX 1
|
||||
#elif defined(ANDROID)
|
||||
# define ANGLE_PLATFORM_ANDROID 1
|
||||
# define ANGLE_PLATFORM_POSIX 1
|
||||
#elif defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__DragonFly__) || \
|
||||
defined(__sun) || \
|
||||
defined(__GLIBC__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__QNX__)
|
||||
# define ANGLE_PLATFORM_POSIX 1
|
||||
#else
|
||||
# error Unsupported platform.
|
||||
#endif
|
||||
|
||||
#ifdef ANGLE_PLATFORM_WINDOWS
|
||||
# ifndef STRICT
|
||||
# define STRICT 1
|
||||
# endif
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN 1
|
||||
# endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX 1
|
||||
# endif
|
||||
|
||||
# include <windows.h>
|
||||
# include <intrin.h>
|
||||
|
||||
# if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_PERF)
|
||||
# include <d3d9.h>
|
||||
# endif
|
||||
|
||||
# if defined(ANGLE_ENABLE_D3D11)
|
||||
# include <d3d10_1.h>
|
||||
# include <d3d11.h>
|
||||
# include <dxgi.h>
|
||||
# include <dxgi1_2.h>
|
||||
# include <d3dcompiler.h>
|
||||
# endif
|
||||
|
||||
# undef near
|
||||
# undef far
|
||||
# undef NEAR
|
||||
# define NEAR
|
||||
# undef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#endif // COMMON_PLATFORM_H_
|
157
src/3rdparty/angle/src/common/shadervars.h
vendored
Normal file
157
src/3rdparty/angle/src/common/shadervars.h
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
//
|
||||
// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// shadervars.h:
|
||||
// Types to represent GL variables (varyings, uniforms, etc)
|
||||
//
|
||||
|
||||
#ifndef COMMON_SHADERVARIABLE_H_
|
||||
#define COMMON_SHADERVARIABLE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
|
||||
enum InterpolationType
|
||||
{
|
||||
INTERPOLATION_SMOOTH,
|
||||
INTERPOLATION_CENTROID,
|
||||
INTERPOLATION_FLAT
|
||||
};
|
||||
|
||||
// Uniform block layout qualifier, see section 4.3.8.3 of the ESSL 3.00.4 spec
|
||||
enum BlockLayoutType
|
||||
{
|
||||
BLOCKLAYOUT_STANDARD,
|
||||
BLOCKLAYOUT_PACKED,
|
||||
BLOCKLAYOUT_SHARED
|
||||
};
|
||||
|
||||
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
|
||||
struct ShaderVariable
|
||||
{
|
||||
ShaderVariable()
|
||||
: type(0),
|
||||
precision(0),
|
||||
arraySize(0),
|
||||
staticUse(false)
|
||||
{}
|
||||
|
||||
ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
|
||||
: type(typeIn),
|
||||
precision(precisionIn),
|
||||
name(nameIn),
|
||||
arraySize(arraySizeIn),
|
||||
staticUse(false)
|
||||
{}
|
||||
|
||||
bool isArray() const { return arraySize > 0; }
|
||||
unsigned int elementCount() const { return std::max(1u, arraySize); }
|
||||
|
||||
GLenum type;
|
||||
GLenum precision;
|
||||
std::string name;
|
||||
std::string mappedName;
|
||||
unsigned int arraySize;
|
||||
bool staticUse;
|
||||
};
|
||||
|
||||
struct Uniform : public ShaderVariable
|
||||
{
|
||||
Uniform()
|
||||
{}
|
||||
|
||||
Uniform(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
|
||||
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn)
|
||||
{}
|
||||
|
||||
bool isStruct() const { return !fields.empty(); }
|
||||
|
||||
std::vector<Uniform> fields;
|
||||
};
|
||||
|
||||
struct Attribute : public ShaderVariable
|
||||
{
|
||||
Attribute()
|
||||
: location(-1)
|
||||
{}
|
||||
|
||||
Attribute(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, int locationIn)
|
||||
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
|
||||
location(locationIn)
|
||||
{}
|
||||
|
||||
int location;
|
||||
};
|
||||
|
||||
struct InterfaceBlockField : public ShaderVariable
|
||||
{
|
||||
InterfaceBlockField()
|
||||
: isRowMajorMatrix(false)
|
||||
{}
|
||||
|
||||
InterfaceBlockField(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, bool isRowMajorMatrix)
|
||||
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
|
||||
isRowMajorMatrix(isRowMajorMatrix)
|
||||
{}
|
||||
|
||||
bool isStruct() const { return !fields.empty(); }
|
||||
|
||||
bool isRowMajorMatrix;
|
||||
std::vector<InterfaceBlockField> fields;
|
||||
};
|
||||
|
||||
struct Varying : public ShaderVariable
|
||||
{
|
||||
Varying()
|
||||
: interpolation(INTERPOLATION_SMOOTH)
|
||||
{}
|
||||
|
||||
Varying(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn, InterpolationType interpolationIn)
|
||||
: ShaderVariable(typeIn, precisionIn, nameIn, arraySizeIn),
|
||||
interpolation(interpolationIn)
|
||||
{}
|
||||
|
||||
bool isStruct() const { return !fields.empty(); }
|
||||
|
||||
InterpolationType interpolation;
|
||||
std::vector<Varying> fields;
|
||||
std::string structName;
|
||||
};
|
||||
|
||||
struct InterfaceBlock
|
||||
{
|
||||
InterfaceBlock()
|
||||
: arraySize(0),
|
||||
layout(BLOCKLAYOUT_PACKED),
|
||||
isRowMajorLayout(false),
|
||||
staticUse(false)
|
||||
{}
|
||||
|
||||
InterfaceBlock(const char *name, unsigned int arraySize)
|
||||
: name(name),
|
||||
arraySize(arraySize),
|
||||
layout(BLOCKLAYOUT_SHARED),
|
||||
isRowMajorLayout(false),
|
||||
staticUse(false)
|
||||
{}
|
||||
|
||||
std::string name;
|
||||
std::string mappedName;
|
||||
unsigned int arraySize;
|
||||
BlockLayoutType layout;
|
||||
bool isRowMajorLayout;
|
||||
bool staticUse;
|
||||
std::vector<InterfaceBlockField> fields;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COMMON_SHADERVARIABLE_H_
|
103
src/3rdparty/angle/src/common/tls.cpp
vendored
Normal file
103
src/3rdparty/angle/src/common/tls.cpp
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// tls.cpp: Simple cross-platform interface for thread local storage.
|
||||
|
||||
#include "common/tls.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
#include <vector>
|
||||
std::vector<void *> *tls = nullptr;
|
||||
std::vector<TLSIndex> *freeIndices = nullptr;
|
||||
#endif
|
||||
|
||||
TLSIndex CreateTLSIndex()
|
||||
{
|
||||
TLSIndex index;
|
||||
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
if (!tls)
|
||||
tls = new std::vector<void *>;
|
||||
if (freeIndices && !freeIndices->empty()) {
|
||||
index = freeIndices->back();
|
||||
freeIndices->pop_back();
|
||||
return index;
|
||||
} else {
|
||||
tls->push_back(nullptr);
|
||||
return tls->size() - 1;
|
||||
}
|
||||
#elif defined(ANGLE_PLATFORM_WINDOWS)
|
||||
index = TlsAlloc();
|
||||
#elif defined(ANGLE_PLATFORM_POSIX)
|
||||
// Create global pool key
|
||||
if ((pthread_key_create(&index, NULL)) != 0)
|
||||
{
|
||||
index = TLS_INVALID_INDEX;
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(index != TLS_INVALID_INDEX && "CreateTLSIndex(): Unable to allocate Thread Local Storage");
|
||||
return index;
|
||||
}
|
||||
|
||||
bool DestroyTLSIndex(TLSIndex index)
|
||||
{
|
||||
assert(index != TLS_INVALID_INDEX && "DestroyTLSIndex(): Invalid TLS Index");
|
||||
if (index == TLS_INVALID_INDEX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
if (!freeIndices)
|
||||
freeIndices = new std::vector<TLSIndex>;
|
||||
freeIndices->push_back(index);
|
||||
return true;
|
||||
#elif ANGLE_PLATFORM_WINDOWS
|
||||
return (TlsFree(index) == TRUE);
|
||||
#elif defined(ANGLE_PLATFORM_POSIX)
|
||||
return (pthread_key_delete(index) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SetTLSValue(TLSIndex index, void *value)
|
||||
{
|
||||
assert(index != TLS_INVALID_INDEX && "SetTLSValue(): Invalid TLS Index");
|
||||
if (index == TLS_INVALID_INDEX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
tls->at(index) = value;
|
||||
return true;
|
||||
#elif defined(ANGLE_PLATFORM_WINDOWS)
|
||||
return (TlsSetValue(index, value) == TRUE);
|
||||
#elif defined(ANGLE_PLATFORM_POSIX)
|
||||
return (pthread_setspecific(index, value) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void *GetTLSValue(TLSIndex index)
|
||||
{
|
||||
#if !defined(ANGLE_PLATFORM_WINRT) // Valid on WinRT, as Alloc handles the index creation
|
||||
assert(index != TLS_INVALID_INDEX && "GetTLSValue(): Invalid TLS Index");
|
||||
#endif
|
||||
if (index == TLS_INVALID_INDEX)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
return tls->at(index);
|
||||
#elif defined(ANGLE_PLATFORM_WINDOWS)
|
||||
return TlsGetValue(index);
|
||||
#elif defined(ANGLE_PLATFORM_POSIX)
|
||||
return pthread_getspecific(index);
|
||||
#endif
|
||||
}
|
37
src/3rdparty/angle/src/common/tls.h
vendored
Normal file
37
src/3rdparty/angle/src/common/tls.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// tls.h: Simple cross-platform interface for thread local storage.
|
||||
|
||||
#ifndef COMMON_TLS_H_
|
||||
#define COMMON_TLS_H_
|
||||
|
||||
#include "common/platform.h"
|
||||
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
typedef size_t TLSIndex;
|
||||
# define TLS_OUT_OF_INDEXES (static_cast<TLSIndex>(-1))
|
||||
# define TLS_INVALID_INDEX TLS_OUT_OF_INDEXES
|
||||
#elif defined(ANGLE_PLATFORM_WINDOWS)
|
||||
typedef DWORD TLSIndex;
|
||||
# define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES)
|
||||
#elif defined(ANGLE_PLATFORM_POSIX)
|
||||
# include <pthread.h>
|
||||
# include <semaphore.h>
|
||||
# include <errno.h>
|
||||
typedef pthread_key_t TLSIndex;
|
||||
# define TLS_INVALID_INDEX (static_cast<TLSIndex>(-1))
|
||||
#else
|
||||
# error Unsupported platform.
|
||||
#endif
|
||||
|
||||
TLSIndex CreateTLSIndex();
|
||||
bool DestroyTLSIndex(TLSIndex index);
|
||||
|
||||
bool SetTLSValue(TLSIndex index, void *value);
|
||||
void *GetTLSValue(TLSIndex index);
|
||||
|
||||
#endif // COMMON_TLS_H_
|
527
src/3rdparty/angle/src/common/utilities.cpp
vendored
Normal file
527
src/3rdparty/angle/src/common/utilities.cpp
vendored
Normal file
@ -0,0 +1,527 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// utilities.cpp: Conversion functions and other utility routines.
|
||||
|
||||
#include "common/utilities.h"
|
||||
#include "common/mathutil.h"
|
||||
#include "common/platform.h"
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
# include <locale>
|
||||
# include <codecvt>
|
||||
# include <wrl.h>
|
||||
# include <windows.storage.h>
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace ABI::Windows::Storage;
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
int VariableComponentCount(GLenum type)
|
||||
{
|
||||
return VariableRowCount(type) * VariableColumnCount(type);
|
||||
}
|
||||
|
||||
GLenum VariableComponentType(GLenum type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case GL_BOOL:
|
||||
case GL_BOOL_VEC2:
|
||||
case GL_BOOL_VEC3:
|
||||
case GL_BOOL_VEC4:
|
||||
return GL_BOOL;
|
||||
case GL_FLOAT:
|
||||
case GL_FLOAT_VEC2:
|
||||
case GL_FLOAT_VEC3:
|
||||
case GL_FLOAT_VEC4:
|
||||
case GL_FLOAT_MAT2:
|
||||
case GL_FLOAT_MAT3:
|
||||
case GL_FLOAT_MAT4:
|
||||
case GL_FLOAT_MAT2x3:
|
||||
case GL_FLOAT_MAT3x2:
|
||||
case GL_FLOAT_MAT2x4:
|
||||
case GL_FLOAT_MAT4x2:
|
||||
case GL_FLOAT_MAT3x4:
|
||||
case GL_FLOAT_MAT4x3:
|
||||
return GL_FLOAT;
|
||||
case GL_INT:
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_3D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
case GL_SAMPLER_2D_ARRAY:
|
||||
case GL_INT_SAMPLER_2D:
|
||||
case GL_INT_SAMPLER_3D:
|
||||
case GL_INT_SAMPLER_CUBE:
|
||||
case GL_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_3D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_CUBE:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
case GL_SAMPLER_CUBE_SHADOW:
|
||||
case GL_SAMPLER_2D_ARRAY_SHADOW:
|
||||
case GL_INT_VEC2:
|
||||
case GL_INT_VEC3:
|
||||
case GL_INT_VEC4:
|
||||
return GL_INT;
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
return GL_UNSIGNED_INT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return GL_NONE;
|
||||
}
|
||||
|
||||
size_t VariableComponentSize(GLenum type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case GL_BOOL: return sizeof(GLint);
|
||||
case GL_FLOAT: return sizeof(GLfloat);
|
||||
case GL_INT: return sizeof(GLint);
|
||||
case GL_UNSIGNED_INT: return sizeof(GLuint);
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t VariableInternalSize(GLenum type)
|
||||
{
|
||||
// Expanded to 4-element vectors
|
||||
return VariableComponentSize(VariableComponentType(type)) * VariableRowCount(type) * 4;
|
||||
}
|
||||
|
||||
size_t VariableExternalSize(GLenum type)
|
||||
{
|
||||
return VariableComponentSize(VariableComponentType(type)) * VariableComponentCount(type);
|
||||
}
|
||||
|
||||
GLenum VariableBoolVectorType(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_FLOAT:
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
return GL_BOOL;
|
||||
case GL_FLOAT_VEC2:
|
||||
case GL_INT_VEC2:
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
return GL_BOOL_VEC2;
|
||||
case GL_FLOAT_VEC3:
|
||||
case GL_INT_VEC3:
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
return GL_BOOL_VEC3;
|
||||
case GL_FLOAT_VEC4:
|
||||
case GL_INT_VEC4:
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
return GL_BOOL_VEC4;
|
||||
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
int VariableRowCount(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_NONE:
|
||||
case GL_STRUCT_ANGLEX:
|
||||
return 0;
|
||||
case GL_BOOL:
|
||||
case GL_FLOAT:
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_BOOL_VEC2:
|
||||
case GL_FLOAT_VEC2:
|
||||
case GL_INT_VEC2:
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
case GL_BOOL_VEC3:
|
||||
case GL_FLOAT_VEC3:
|
||||
case GL_INT_VEC3:
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
case GL_BOOL_VEC4:
|
||||
case GL_FLOAT_VEC4:
|
||||
case GL_INT_VEC4:
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_3D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
case GL_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_EXTERNAL_OES:
|
||||
case GL_SAMPLER_2D_RECT_ARB:
|
||||
case GL_INT_SAMPLER_2D:
|
||||
case GL_INT_SAMPLER_3D:
|
||||
case GL_INT_SAMPLER_CUBE:
|
||||
case GL_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_3D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_CUBE:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
case GL_SAMPLER_CUBE_SHADOW:
|
||||
case GL_SAMPLER_2D_ARRAY_SHADOW:
|
||||
return 1;
|
||||
case GL_FLOAT_MAT2:
|
||||
case GL_FLOAT_MAT3x2:
|
||||
case GL_FLOAT_MAT4x2:
|
||||
return 2;
|
||||
case GL_FLOAT_MAT3:
|
||||
case GL_FLOAT_MAT2x3:
|
||||
case GL_FLOAT_MAT4x3:
|
||||
return 3;
|
||||
case GL_FLOAT_MAT4:
|
||||
case GL_FLOAT_MAT2x4:
|
||||
case GL_FLOAT_MAT3x4:
|
||||
return 4;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VariableColumnCount(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_NONE:
|
||||
case GL_STRUCT_ANGLEX:
|
||||
return 0;
|
||||
case GL_BOOL:
|
||||
case GL_FLOAT:
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_3D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
case GL_SAMPLER_2D_ARRAY:
|
||||
case GL_INT_SAMPLER_2D:
|
||||
case GL_INT_SAMPLER_3D:
|
||||
case GL_INT_SAMPLER_CUBE:
|
||||
case GL_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_EXTERNAL_OES:
|
||||
case GL_SAMPLER_2D_RECT_ARB:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_3D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_CUBE:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
case GL_SAMPLER_CUBE_SHADOW:
|
||||
case GL_SAMPLER_2D_ARRAY_SHADOW:
|
||||
return 1;
|
||||
case GL_BOOL_VEC2:
|
||||
case GL_FLOAT_VEC2:
|
||||
case GL_INT_VEC2:
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
case GL_FLOAT_MAT2:
|
||||
case GL_FLOAT_MAT2x3:
|
||||
case GL_FLOAT_MAT2x4:
|
||||
return 2;
|
||||
case GL_BOOL_VEC3:
|
||||
case GL_FLOAT_VEC3:
|
||||
case GL_INT_VEC3:
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
case GL_FLOAT_MAT3:
|
||||
case GL_FLOAT_MAT3x2:
|
||||
case GL_FLOAT_MAT3x4:
|
||||
return 3;
|
||||
case GL_BOOL_VEC4:
|
||||
case GL_FLOAT_VEC4:
|
||||
case GL_INT_VEC4:
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
case GL_FLOAT_MAT4:
|
||||
case GL_FLOAT_MAT4x2:
|
||||
case GL_FLOAT_MAT4x3:
|
||||
return 4;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsSampler(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_3D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
case GL_SAMPLER_2D_ARRAY:
|
||||
case GL_INT_SAMPLER_2D:
|
||||
case GL_INT_SAMPLER_3D:
|
||||
case GL_INT_SAMPLER_CUBE:
|
||||
case GL_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_3D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_CUBE:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
case GL_SAMPLER_CUBE_SHADOW:
|
||||
case GL_SAMPLER_2D_ARRAY_SHADOW:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsMatrixType(GLenum type)
|
||||
{
|
||||
return VariableRowCount(type) > 1;
|
||||
}
|
||||
|
||||
GLenum TransposeMatrixType(GLenum type)
|
||||
{
|
||||
if (!IsMatrixType(type))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GL_FLOAT_MAT2: return GL_FLOAT_MAT2;
|
||||
case GL_FLOAT_MAT3: return GL_FLOAT_MAT3;
|
||||
case GL_FLOAT_MAT4: return GL_FLOAT_MAT4;
|
||||
case GL_FLOAT_MAT2x3: return GL_FLOAT_MAT3x2;
|
||||
case GL_FLOAT_MAT3x2: return GL_FLOAT_MAT2x3;
|
||||
case GL_FLOAT_MAT2x4: return GL_FLOAT_MAT4x2;
|
||||
case GL_FLOAT_MAT4x2: return GL_FLOAT_MAT2x4;
|
||||
case GL_FLOAT_MAT3x4: return GL_FLOAT_MAT4x3;
|
||||
case GL_FLOAT_MAT4x3: return GL_FLOAT_MAT3x4;
|
||||
default: UNREACHABLE(); return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix)
|
||||
{
|
||||
ASSERT(IsMatrixType(type));
|
||||
return isRowMajorMatrix ? VariableRowCount(type) : VariableColumnCount(type);
|
||||
}
|
||||
|
||||
int MatrixComponentCount(GLenum type, bool isRowMajorMatrix)
|
||||
{
|
||||
ASSERT(IsMatrixType(type));
|
||||
return isRowMajorMatrix ? VariableColumnCount(type) : VariableRowCount(type);
|
||||
}
|
||||
|
||||
int VariableRegisterCount(GLenum type)
|
||||
{
|
||||
return IsMatrixType(type) ? VariableColumnCount(type) : 1;
|
||||
}
|
||||
|
||||
int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize)
|
||||
{
|
||||
ASSERT(allocationSize <= bitsSize);
|
||||
|
||||
unsigned int mask = std::numeric_limits<unsigned int>::max() >> (std::numeric_limits<unsigned int>::digits - allocationSize);
|
||||
|
||||
for (unsigned int i = 0; i < bitsSize - allocationSize + 1; i++)
|
||||
{
|
||||
if ((*bits & mask) == 0)
|
||||
{
|
||||
*bits |= mask;
|
||||
return i;
|
||||
}
|
||||
|
||||
mask <<= 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool IsCubemapTextureTarget(GLenum target)
|
||||
{
|
||||
return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
|
||||
}
|
||||
|
||||
bool IsTriangleMode(GLenum drawMode)
|
||||
{
|
||||
switch (drawMode)
|
||||
{
|
||||
case GL_TRIANGLES:
|
||||
case GL_TRIANGLE_FAN:
|
||||
case GL_TRIANGLE_STRIP:
|
||||
return true;
|
||||
case GL_POINTS:
|
||||
case GL_LINES:
|
||||
case GL_LINE_LOOP:
|
||||
case GL_LINE_STRIP:
|
||||
return false;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// [OpenGL ES SL 3.00.4] Section 11 p. 120
|
||||
// Vertex Outs/Fragment Ins packing priorities
|
||||
int VariableSortOrder(GLenum type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
// 1. Arrays of mat4 and mat4
|
||||
// Non-square matrices of type matCxR consume the same space as a square
|
||||
// matrix of type matN where N is the greater of C and R
|
||||
case GL_FLOAT_MAT4:
|
||||
case GL_FLOAT_MAT2x4:
|
||||
case GL_FLOAT_MAT3x4:
|
||||
case GL_FLOAT_MAT4x2:
|
||||
case GL_FLOAT_MAT4x3:
|
||||
return 0;
|
||||
|
||||
// 2. Arrays of mat2 and mat2 (since they occupy full rows)
|
||||
case GL_FLOAT_MAT2:
|
||||
return 1;
|
||||
|
||||
// 3. Arrays of vec4 and vec4
|
||||
case GL_FLOAT_VEC4:
|
||||
case GL_INT_VEC4:
|
||||
case GL_BOOL_VEC4:
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
return 2;
|
||||
|
||||
// 4. Arrays of mat3 and mat3
|
||||
case GL_FLOAT_MAT3:
|
||||
case GL_FLOAT_MAT2x3:
|
||||
case GL_FLOAT_MAT3x2:
|
||||
return 3;
|
||||
|
||||
// 5. Arrays of vec3 and vec3
|
||||
case GL_FLOAT_VEC3:
|
||||
case GL_INT_VEC3:
|
||||
case GL_BOOL_VEC3:
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
return 4;
|
||||
|
||||
// 6. Arrays of vec2 and vec2
|
||||
case GL_FLOAT_VEC2:
|
||||
case GL_INT_VEC2:
|
||||
case GL_BOOL_VEC2:
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
return 5;
|
||||
|
||||
// 7. Single component types
|
||||
case GL_FLOAT:
|
||||
case GL_INT:
|
||||
case GL_BOOL:
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
case GL_SAMPLER_EXTERNAL_OES:
|
||||
case GL_SAMPLER_2D_RECT_ARB:
|
||||
case GL_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_3D:
|
||||
case GL_INT_SAMPLER_2D:
|
||||
case GL_INT_SAMPLER_3D:
|
||||
case GL_INT_SAMPLER_CUBE:
|
||||
case GL_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_3D:
|
||||
case GL_UNSIGNED_INT_SAMPLER_CUBE:
|
||||
case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
||||
case GL_SAMPLER_2D_SHADOW:
|
||||
case GL_SAMPLER_2D_ARRAY_SHADOW:
|
||||
case GL_SAMPLER_CUBE_SHADOW:
|
||||
return 6;
|
||||
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string getTempPath()
|
||||
{
|
||||
#if defined(ANGLE_PLATFORM_WINRT)
|
||||
static std::string path;
|
||||
|
||||
while (path.empty())
|
||||
{
|
||||
ComPtr<IApplicationDataStatics> factory;
|
||||
Wrappers::HStringReference classId(RuntimeClass_Windows_Storage_ApplicationData);
|
||||
HRESULT result = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory));
|
||||
if (FAILED(result))
|
||||
break;
|
||||
|
||||
ComPtr<IApplicationData> applicationData;
|
||||
result = factory->get_Current(&applicationData);
|
||||
if (FAILED(result))
|
||||
break;
|
||||
|
||||
ComPtr<IStorageFolder> storageFolder;
|
||||
result = applicationData->get_LocalFolder(&storageFolder);
|
||||
if (FAILED(result))
|
||||
break;
|
||||
|
||||
ComPtr<IStorageItem> localFolder;
|
||||
result = storageFolder.As(&localFolder);
|
||||
if (FAILED(result))
|
||||
break;
|
||||
|
||||
HSTRING localFolderPath;
|
||||
result = localFolder->get_Path(&localFolderPath);
|
||||
if (FAILED(result))
|
||||
break;
|
||||
|
||||
std::wstring_convert< std::codecvt_utf8<wchar_t> > converter;
|
||||
path = converter.to_bytes(WindowsGetStringRawBuffer(localFolderPath, NULL));
|
||||
if (path.empty())
|
||||
{
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
#elif defined(ANGLE_PLATFORM_WINDOWS)
|
||||
char path[MAX_PATH];
|
||||
DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path);
|
||||
if (pathLen == 0)
|
||||
{
|
||||
UNREACHABLE();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
UINT unique = GetTempFileNameA(path, "sh", 0, path);
|
||||
if (unique == 0)
|
||||
{
|
||||
UNREACHABLE();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return path;
|
||||
#else
|
||||
UNIMPLEMENTED();
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
void writeFile(const char* path, const void* content, size_t size)
|
||||
{
|
||||
FILE* file = fopen(path, "w");
|
||||
if (!file)
|
||||
{
|
||||
UNREACHABLE();
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite(content, sizeof(char), size, file);
|
||||
fclose(file);
|
||||
}
|
52
src/3rdparty/angle/src/common/utilities.h
vendored
Normal file
52
src/3rdparty/angle/src/common/utilities.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// utilities.h: Conversion functions and other utility routines.
|
||||
|
||||
#ifndef LIBGLESV2_UTILITIES_H
|
||||
#define LIBGLESV2_UTILITIES_H
|
||||
|
||||
#include "angle_gl.h"
|
||||
#include <string>
|
||||
#include <math.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
int VariableComponentCount(GLenum type);
|
||||
GLenum VariableComponentType(GLenum type);
|
||||
size_t VariableComponentSize(GLenum type);
|
||||
size_t VariableInternalSize(GLenum type);
|
||||
size_t VariableExternalSize(GLenum type);
|
||||
GLenum VariableBoolVectorType(GLenum type);
|
||||
int VariableRowCount(GLenum type);
|
||||
int VariableColumnCount(GLenum type);
|
||||
bool IsSampler(GLenum type);
|
||||
bool IsMatrixType(GLenum type);
|
||||
GLenum TransposeMatrixType(GLenum type);
|
||||
int VariableRegisterCount(GLenum type);
|
||||
int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
|
||||
int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
|
||||
int VariableSortOrder(GLenum type);
|
||||
|
||||
int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
|
||||
|
||||
bool IsCubemapTextureTarget(GLenum target);
|
||||
|
||||
bool IsTriangleMode(GLenum drawMode);
|
||||
|
||||
// [OpenGL ES 3.0.2] Section 2.3.1 page 14
|
||||
// Data Conversion For State-Setting Commands
|
||||
// Floating-point values are rounded to the nearest integer, instead of truncated, as done by static_cast.
|
||||
template <typename outT> outT iround(GLfloat value) { return static_cast<outT>(value > 0.0f ? floor(value + 0.5f) : ceil(value - 0.5f)); }
|
||||
template <typename outT> outT uiround(GLfloat value) { return static_cast<outT>(value + 0.5f); }
|
||||
|
||||
}
|
||||
|
||||
std::string getTempPath();
|
||||
void writeFile(const char* path, const void* data, size_t size);
|
||||
|
||||
#endif // LIBGLESV2_UTILITIES_H
|
6
src/3rdparty/angle/src/common/version.h
vendored
6
src/3rdparty/angle/src/common/version.h
vendored
@ -1,7 +1,7 @@
|
||||
#include "commit.h"
|
||||
#include "../commit.h"
|
||||
|
||||
#define ANGLE_MAJOR_VERSION 1
|
||||
#define ANGLE_MINOR_VERSION 3
|
||||
#define ANGLE_MAJOR_VERSION 2
|
||||
#define ANGLE_MINOR_VERSION 1
|
||||
|
||||
#define ANGLE_STRINGIFY(x) #x
|
||||
#define ANGLE_MACRO_STRINGIFY(x) ANGLE_STRINGIFY(x)
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -35,9 +35,8 @@ enum DirectiveType
|
||||
DIRECTIVE_VERSION,
|
||||
DIRECTIVE_LINE
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static DirectiveType getDirective(const pp::Token* token)
|
||||
DirectiveType getDirective(const pp::Token *token)
|
||||
{
|
||||
static const std::string kDirectiveDefine("define");
|
||||
static const std::string kDirectiveUndef("undef");
|
||||
@ -58,35 +57,35 @@ static DirectiveType getDirective(const pp::Token* token)
|
||||
|
||||
if (token->text == kDirectiveDefine)
|
||||
return DIRECTIVE_DEFINE;
|
||||
else if (token->text == kDirectiveUndef)
|
||||
if (token->text == kDirectiveUndef)
|
||||
return DIRECTIVE_UNDEF;
|
||||
else if (token->text == kDirectiveIf)
|
||||
if (token->text == kDirectiveIf)
|
||||
return DIRECTIVE_IF;
|
||||
else if (token->text == kDirectiveIfdef)
|
||||
if (token->text == kDirectiveIfdef)
|
||||
return DIRECTIVE_IFDEF;
|
||||
else if (token->text == kDirectiveIfndef)
|
||||
if (token->text == kDirectiveIfndef)
|
||||
return DIRECTIVE_IFNDEF;
|
||||
else if (token->text == kDirectiveElse)
|
||||
if (token->text == kDirectiveElse)
|
||||
return DIRECTIVE_ELSE;
|
||||
else if (token->text == kDirectiveElif)
|
||||
if (token->text == kDirectiveElif)
|
||||
return DIRECTIVE_ELIF;
|
||||
else if (token->text == kDirectiveEndif)
|
||||
if (token->text == kDirectiveEndif)
|
||||
return DIRECTIVE_ENDIF;
|
||||
else if (token->text == kDirectiveError)
|
||||
if (token->text == kDirectiveError)
|
||||
return DIRECTIVE_ERROR;
|
||||
else if (token->text == kDirectivePragma)
|
||||
if (token->text == kDirectivePragma)
|
||||
return DIRECTIVE_PRAGMA;
|
||||
else if (token->text == kDirectiveExtension)
|
||||
if (token->text == kDirectiveExtension)
|
||||
return DIRECTIVE_EXTENSION;
|
||||
else if (token->text == kDirectiveVersion)
|
||||
if (token->text == kDirectiveVersion)
|
||||
return DIRECTIVE_VERSION;
|
||||
else if (token->text == kDirectiveLine)
|
||||
if (token->text == kDirectiveLine)
|
||||
return DIRECTIVE_LINE;
|
||||
|
||||
return DIRECTIVE_NONE;
|
||||
}
|
||||
|
||||
static bool isConditionalDirective(DirectiveType directive)
|
||||
bool isConditionalDirective(DirectiveType directive)
|
||||
{
|
||||
switch (directive)
|
||||
{
|
||||
@ -103,12 +102,12 @@ static bool isConditionalDirective(DirectiveType directive)
|
||||
}
|
||||
|
||||
// Returns true if the token represents End Of Directive.
|
||||
static bool isEOD(const pp::Token* token)
|
||||
bool isEOD(const pp::Token *token)
|
||||
{
|
||||
return (token->type == '\n') || (token->type == pp::Token::LAST);
|
||||
}
|
||||
|
||||
static void skipUntilEOD(pp::Lexer* lexer, pp::Token* token)
|
||||
void skipUntilEOD(pp::Lexer *lexer, pp::Token *token)
|
||||
{
|
||||
while(!isEOD(token))
|
||||
{
|
||||
@ -116,7 +115,7 @@ static void skipUntilEOD(pp::Lexer* lexer, pp::Token* token)
|
||||
}
|
||||
}
|
||||
|
||||
static bool isMacroNameReserved(const std::string& name)
|
||||
bool isMacroNameReserved(const std::string &name)
|
||||
{
|
||||
// Names prefixed with "GL_" are reserved.
|
||||
if (name.substr(0, 3) == "GL_")
|
||||
@ -129,13 +128,15 @@ static bool isMacroNameReserved(const std::string& name)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isMacroPredefined(const std::string& name,
|
||||
bool isMacroPredefined(const std::string &name,
|
||||
const pp::MacroSet ¯oSet)
|
||||
{
|
||||
pp::MacroSet::const_iterator iter = macroSet.find(name);
|
||||
return iter != macroSet.end() ? iter->second.predefined : false;
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
namespace pp
|
||||
{
|
||||
|
||||
@ -144,8 +145,8 @@ class DefinedParser : public Lexer
|
||||
public:
|
||||
DefinedParser(Lexer *lexer,
|
||||
const MacroSet *macroSet,
|
||||
Diagnostics* diagnostics) :
|
||||
mLexer(lexer),
|
||||
Diagnostics *diagnostics)
|
||||
: mLexer(lexer),
|
||||
mMacroSet(macroSet),
|
||||
mDiagnostics(diagnostics)
|
||||
{
|
||||
@ -207,8 +208,8 @@ class DefinedParser : public Lexer
|
||||
DirectiveParser::DirectiveParser(Tokenizer *tokenizer,
|
||||
MacroSet *macroSet,
|
||||
Diagnostics *diagnostics,
|
||||
DirectiveHandler* directiveHandler) :
|
||||
mPastFirstStatement(false),
|
||||
DirectiveHandler *directiveHandler)
|
||||
: mPastFirstStatement(false),
|
||||
mTokenizer(tokenizer),
|
||||
mMacroSet(macroSet),
|
||||
mDiagnostics(diagnostics),
|
||||
@ -239,7 +240,8 @@ void DirectiveParser::lex(Token* token)
|
||||
break;
|
||||
}
|
||||
|
||||
} while (skipping() || (token->type == '\n'));
|
||||
}
|
||||
while (skipping() || (token->type == '\n'));
|
||||
|
||||
mPastFirstStatement = true;
|
||||
}
|
||||
@ -357,14 +359,16 @@ void DirectiveParser::parseDefine(Token* token)
|
||||
{
|
||||
// Function-like macro. Collect arguments.
|
||||
macro.type = Macro::kTypeFunc;
|
||||
do {
|
||||
do
|
||||
{
|
||||
mTokenizer->lex(token);
|
||||
if (token->type != Token::IDENTIFIER)
|
||||
break;
|
||||
macro.parameters.push_back(token->text);
|
||||
|
||||
mTokenizer->lex(token); // Get ','.
|
||||
} while (token->type == ',');
|
||||
}
|
||||
while (token->type == ',');
|
||||
|
||||
if (token->type != ')')
|
||||
{
|
||||
@ -708,7 +712,9 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
|
||||
enum State
|
||||
{
|
||||
VERSION_NUMBER
|
||||
VERSION_NUMBER,
|
||||
VERSION_PROFILE,
|
||||
VERSION_ENDLINE
|
||||
};
|
||||
|
||||
bool valid = true;
|
||||
@ -716,12 +722,12 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
int state = VERSION_NUMBER;
|
||||
|
||||
mTokenizer->lex(token);
|
||||
while ((token->type != '\n') && (token->type != Token::LAST))
|
||||
while (valid && (token->type != '\n') && (token->type != Token::LAST))
|
||||
{
|
||||
switch (state++)
|
||||
switch (state)
|
||||
{
|
||||
case VERSION_NUMBER:
|
||||
if (valid && (token->type != Token::CONST_INT))
|
||||
if (token->type != Token::CONST_INT)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER,
|
||||
token->location, token->text);
|
||||
@ -733,27 +739,42 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (valid)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
state = (version < 300) ? VERSION_ENDLINE : VERSION_PROFILE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
mTokenizer->lex(token);
|
||||
}
|
||||
if (valid && (state != VERSION_NUMBER + 1))
|
||||
case VERSION_PROFILE:
|
||||
if (token->type != Token::IDENTIFIER || token->text != "es")
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
state = VERSION_ENDLINE;
|
||||
break;
|
||||
default:
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
|
||||
mTokenizer->lex(token);
|
||||
}
|
||||
|
||||
if (valid && (state != VERSION_ENDLINE))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
mDirectiveHandler->handleVersion(token->location, version);
|
||||
}
|
||||
}
|
||||
|
||||
void DirectiveParser::parseLine(Token *token)
|
||||
{
|
||||
@ -824,13 +845,15 @@ void DirectiveParser::parseLine(Token* token)
|
||||
if (valid)
|
||||
{
|
||||
mTokenizer->setLineNumber(line);
|
||||
if (state == FILE_NUMBER + 1) mTokenizer->setFileNumber(file);
|
||||
if (state == FILE_NUMBER + 1)
|
||||
mTokenizer->setFileNumber(file);
|
||||
}
|
||||
}
|
||||
|
||||
bool DirectiveParser::skipping() const
|
||||
{
|
||||
if (mConditionalStack.empty()) return false;
|
||||
if (mConditionalStack.empty())
|
||||
return false;
|
||||
|
||||
const ConditionalBlock& block = mConditionalStack.back();
|
||||
return block.skipBlock || block.skipGroup;
|
||||
|
@ -61,8 +61,8 @@ class DirectiveParser : public Lexer
|
||||
bool foundValidGroup;
|
||||
bool foundElseGroup;
|
||||
|
||||
ConditionalBlock() :
|
||||
skipBlock(false),
|
||||
ConditionalBlock()
|
||||
: skipBlock(false),
|
||||
skipGroup(false),
|
||||
foundValidGroup(false),
|
||||
foundElseGroup(false)
|
||||
|
@ -202,8 +202,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
|
||||
pp::Token *token = context->token;
|
||||
switch (token->type)
|
||||
{
|
||||
case pp::Token::CONST_INT:
|
||||
{
|
||||
case pp::Token::CONST_INT: {
|
||||
unsigned int val = 0;
|
||||
if (!token->uValue(&val))
|
||||
{
|
||||
@ -214,34 +213,54 @@ int yylex(YYSTYPE* lvalp, Context* context)
|
||||
type = TOK_CONST_INT;
|
||||
break;
|
||||
}
|
||||
case pp::Token::OP_OR: type = TOK_OP_OR; break;
|
||||
case pp::Token::OP_AND: type = TOK_OP_AND; break;
|
||||
case pp::Token::OP_NE: type = TOK_OP_NE; break;
|
||||
case pp::Token::OP_EQ: type = TOK_OP_EQ; break;
|
||||
case pp::Token::OP_GE: type = TOK_OP_GE; break;
|
||||
case pp::Token::OP_LE: type = TOK_OP_LE; break;
|
||||
case pp::Token::OP_RIGHT: type = TOK_OP_RIGHT; break;
|
||||
case pp::Token::OP_LEFT: type = TOK_OP_LEFT; break;
|
||||
case '|': type = '|'; break;
|
||||
case '^': type = '^'; break;
|
||||
case '&': type = '&'; break;
|
||||
case '>': type = '>'; break;
|
||||
case '<': type = '<'; break;
|
||||
case '-': type = '-'; break;
|
||||
case '+': type = '+'; break;
|
||||
case '%': type = '%'; break;
|
||||
case '/': type = '/'; break;
|
||||
case '*': type = '*'; break;
|
||||
case '!': type = '!'; break;
|
||||
case '~': type = '~'; break;
|
||||
case '(': type = '('; break;
|
||||
case ')': type = ')'; break;
|
||||
case pp::Token::OP_OR:
|
||||
type = TOK_OP_OR;
|
||||
break;
|
||||
case pp::Token::OP_AND:
|
||||
type = TOK_OP_AND;
|
||||
break;
|
||||
case pp::Token::OP_NE:
|
||||
type = TOK_OP_NE;
|
||||
break;
|
||||
case pp::Token::OP_EQ:
|
||||
type = TOK_OP_EQ;
|
||||
break;
|
||||
case pp::Token::OP_GE:
|
||||
type = TOK_OP_GE;
|
||||
break;
|
||||
case pp::Token::OP_LE:
|
||||
type = TOK_OP_LE;
|
||||
break;
|
||||
case pp::Token::OP_RIGHT:
|
||||
type = TOK_OP_RIGHT;
|
||||
break;
|
||||
case pp::Token::OP_LEFT:
|
||||
type = TOK_OP_LEFT;
|
||||
break;
|
||||
case '|':
|
||||
case '^':
|
||||
case '&':
|
||||
case '>':
|
||||
case '<':
|
||||
case '-':
|
||||
case '+':
|
||||
case '%':
|
||||
case '/':
|
||||
case '*':
|
||||
case '!':
|
||||
case '~':
|
||||
case '(':
|
||||
case ')':
|
||||
type = token->type;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Advance to the next token if the current one is valid.
|
||||
if (type != 0) context->lexer->lex(token);
|
||||
if (type != 0)
|
||||
context->lexer->lex(token);
|
||||
|
||||
return type;
|
||||
}
|
||||
@ -255,8 +274,8 @@ void yyerror(Context* context, const char* reason)
|
||||
|
||||
namespace pp {
|
||||
|
||||
ExpressionParser::ExpressionParser(Lexer* lexer, Diagnostics* diagnostics) :
|
||||
mLexer(lexer),
|
||||
ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
|
||||
: mLexer(lexer),
|
||||
mDiagnostics(diagnostics)
|
||||
{
|
||||
}
|
||||
|
@ -20,9 +20,18 @@ class Input
|
||||
Input();
|
||||
Input(size_t count, const char *const string[], const int length[]);
|
||||
|
||||
size_t count() const { return mCount; }
|
||||
const char* string(size_t index) const { return mString[index]; }
|
||||
size_t length(size_t index) const { return mLength[index]; }
|
||||
size_t count() const
|
||||
{
|
||||
return mCount;
|
||||
}
|
||||
const char *string(size_t index) const
|
||||
{
|
||||
return mString[index];
|
||||
}
|
||||
size_t length(size_t index) const
|
||||
{
|
||||
return mLength[index];
|
||||
}
|
||||
|
||||
size_t read(char *buf, size_t maxSize);
|
||||
|
||||
@ -31,7 +40,11 @@ class Input
|
||||
size_t sIndex; // String index;
|
||||
size_t cIndex; // Char index.
|
||||
|
||||
Location() : sIndex(0), cIndex(0) { }
|
||||
Location()
|
||||
: sIndex(0),
|
||||
cIndex(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
const Location &readLoc() const { return mReadLoc; }
|
||||
|
||||
|
@ -26,7 +26,12 @@ struct Macro
|
||||
typedef std::vector<std::string> Parameters;
|
||||
typedef std::vector<Token> Replacements;
|
||||
|
||||
Macro() : predefined(false), disabled(false), type(kTypeObj) { }
|
||||
Macro()
|
||||
: predefined(false),
|
||||
disabled(false),
|
||||
type(kTypeObj)
|
||||
{
|
||||
}
|
||||
bool equals(const Macro &other) const;
|
||||
|
||||
bool predefined;
|
||||
|
@ -48,8 +48,8 @@ class TokenLexer : public Lexer
|
||||
|
||||
MacroExpander::MacroExpander(Lexer *lexer,
|
||||
MacroSet *macroSet,
|
||||
Diagnostics* diagnostics) :
|
||||
mLexer(lexer),
|
||||
Diagnostics *diagnostics)
|
||||
: mLexer(lexer),
|
||||
mMacroSet(macroSet),
|
||||
mDiagnostics(diagnostics)
|
||||
{
|
||||
@ -276,7 +276,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
|
||||
// The individual arguments are separated by comma tokens, but
|
||||
// the comma tokens between matching inner parentheses do not
|
||||
// seperate arguments.
|
||||
if (openParens == 1) args->push_back(MacroArg());
|
||||
if (openParens == 1)
|
||||
args->push_back(MacroArg());
|
||||
isArg = openParens != 1;
|
||||
break;
|
||||
default:
|
||||
@ -287,7 +288,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
|
||||
{
|
||||
MacroArg &arg = args->back();
|
||||
// Initial whitespace is not part of the argument.
|
||||
if (arg.empty()) token.setHasLeadingSpace(false);
|
||||
if (arg.empty())
|
||||
token.setHasLeadingSpace(false);
|
||||
arg.push_back(token);
|
||||
}
|
||||
}
|
||||
|
@ -56,10 +56,24 @@ class MacroExpander : public Lexer
|
||||
std::size_t index;
|
||||
std::vector<Token> replacements;
|
||||
|
||||
MacroContext() : macro(0), index(0) { }
|
||||
bool empty() const { return index == replacements.size(); }
|
||||
const Token& get() { return replacements[index++]; }
|
||||
void unget() { assert(index > 0); --index; }
|
||||
MacroContext()
|
||||
: macro(0),
|
||||
index(0)
|
||||
{
|
||||
}
|
||||
bool empty() const
|
||||
{
|
||||
return index == replacements.size();
|
||||
}
|
||||
const Token &get()
|
||||
{
|
||||
return replacements[index++];
|
||||
}
|
||||
void unget()
|
||||
{
|
||||
assert(index > 0);
|
||||
--index;
|
||||
}
|
||||
};
|
||||
|
||||
Lexer *mLexer;
|
||||
|
@ -28,8 +28,8 @@ struct PreprocessorImpl
|
||||
MacroExpander macroExpander;
|
||||
|
||||
PreprocessorImpl(Diagnostics *diag,
|
||||
DirectiveHandler* directiveHandler) :
|
||||
diagnostics(diag),
|
||||
DirectiveHandler *directiveHandler)
|
||||
: diagnostics(diag),
|
||||
tokenizer(diag),
|
||||
directiveParser(&tokenizer, ¯oSet, diag, directiveHandler),
|
||||
macroExpander(&directiveParser, ¯oSet, diag)
|
||||
@ -81,11 +81,6 @@ void Preprocessor::predefineMacro(const char* name, int value)
|
||||
mImpl->macroSet[name] = macro;
|
||||
}
|
||||
|
||||
void Preprocessor::setMaxTokenLength(size_t maxLength)
|
||||
{
|
||||
mImpl->tokenizer.setMaxTokenLength(maxLength);
|
||||
}
|
||||
|
||||
void Preprocessor::lex(Token *token)
|
||||
{
|
||||
bool validToken = false;
|
||||
@ -115,5 +110,9 @@ void Preprocessor::lex(Token* token)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pp
|
||||
void Preprocessor::setMaxTokenSize(size_t maxTokenSize)
|
||||
{
|
||||
mImpl->tokenizer.setMaxTokenSize(maxTokenSize);
|
||||
}
|
||||
|
||||
} // namespace pp
|
||||
|
@ -37,15 +37,12 @@ class Preprocessor
|
||||
bool init(size_t count, const char * const string[], const int length[]);
|
||||
// Adds a pre-defined macro.
|
||||
void predefineMacro(const char *name, int value);
|
||||
// Sets maximum allowed token length.
|
||||
// If token length exceeds this limit,
|
||||
// the token text will be truncated to the given maximum length, and
|
||||
// TOKEN_TOO_LONG diagnostic will be generated.
|
||||
// The maximum length defaults to 256.
|
||||
void setMaxTokenLength(size_t maxLength);
|
||||
|
||||
void lex(Token *token);
|
||||
|
||||
// Set maximum preprocessor token size
|
||||
void setMaxTokenSize(size_t maxTokenSize);
|
||||
|
||||
private:
|
||||
PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
|
||||
|
||||
|
@ -12,8 +12,16 @@ namespace pp
|
||||
|
||||
struct SourceLocation
|
||||
{
|
||||
SourceLocation() : file(0), line(0) { }
|
||||
SourceLocation(int f, int l) : file(f), line(l) { }
|
||||
SourceLocation()
|
||||
: file(0),
|
||||
line(0)
|
||||
{
|
||||
}
|
||||
SourceLocation(int f, int l)
|
||||
: file(f),
|
||||
line(l)
|
||||
{
|
||||
}
|
||||
|
||||
bool equals(const SourceLocation &other) const
|
||||
{
|
||||
|
@ -62,20 +62,33 @@ struct Token
|
||||
EXPANSION_DISABLED = 1 << 2
|
||||
};
|
||||
|
||||
Token() : type(0), flags(0) { }
|
||||
Token()
|
||||
: type(0),
|
||||
flags(0)
|
||||
{
|
||||
}
|
||||
|
||||
void reset();
|
||||
bool equals(const Token &other) const;
|
||||
|
||||
// Returns true if this is the first token on line.
|
||||
// It disregards any leading whitespace.
|
||||
bool atStartOfLine() const { return (flags & AT_START_OF_LINE) != 0; }
|
||||
bool atStartOfLine() const
|
||||
{
|
||||
return (flags & AT_START_OF_LINE) != 0;
|
||||
}
|
||||
void setAtStartOfLine(bool start);
|
||||
|
||||
bool hasLeadingSpace() const { return (flags & HAS_LEADING_SPACE) != 0; }
|
||||
bool hasLeadingSpace() const
|
||||
{
|
||||
return (flags & HAS_LEADING_SPACE) != 0;
|
||||
}
|
||||
void setHasLeadingSpace(bool space);
|
||||
|
||||
bool expansionDisabled() const { return (flags & EXPANSION_DISABLED) != 0; }
|
||||
bool expansionDisabled() const
|
||||
{
|
||||
return (flags & EXPANSION_DISABLED) != 0;
|
||||
}
|
||||
void setExpansionDisabled(bool disable);
|
||||
|
||||
// Converts text into numeric value for CONST_INT and CONST_FLOAT token.
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -38,9 +38,9 @@ class Tokenizer : public Lexer
|
||||
|
||||
bool init(size_t count, const char * const string[], const int length[]);
|
||||
|
||||
void setMaxTokenLength(size_t maxLength) { mMaxTokenLength = maxLength; }
|
||||
void setFileNumber(int file);
|
||||
void setLineNumber(int line);
|
||||
void setMaxTokenSize(size_t maxTokenSize);
|
||||
|
||||
virtual void lex(Token *token);
|
||||
|
||||
@ -51,7 +51,7 @@ class Tokenizer : public Lexer
|
||||
|
||||
void *mHandle; // Scanner handle.
|
||||
Context mContext; // Scanner extra.
|
||||
size_t mMaxTokenLength;
|
||||
size_t mMaxTokenSize; // Maximum token size
|
||||
};
|
||||
|
||||
} // namespace pp
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -14,7 +14,7 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
|
||||
|
||||
%top{
|
||||
//
|
||||
// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2011-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -78,9 +78,9 @@ NEWLINE \n|\r|\r\n
|
||||
IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
|
||||
PUNCTUATOR [][<>(){}.+-/*%^|&~=!:;,?]
|
||||
|
||||
DECIMAL_CONSTANT [1-9][0-9]*
|
||||
OCTAL_CONSTANT 0[0-7]*
|
||||
HEXADECIMAL_CONSTANT 0[xX][0-9a-fA-F]+
|
||||
DECIMAL_CONSTANT [1-9][0-9]*[uU]?
|
||||
OCTAL_CONSTANT 0[0-7]*[uU]?
|
||||
HEXADECIMAL_CONSTANT 0[xX][0-9a-fA-F]+[uU]?
|
||||
|
||||
DIGIT [0-9]
|
||||
EXPONENT_PART [eE][+-]?{DIGIT}+
|
||||
@ -114,12 +114,12 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
|
||||
return pp::Token::IDENTIFIER;
|
||||
}
|
||||
|
||||
{DECIMAL_CONSTANT}|{OCTAL_CONSTANT}|{HEXADECIMAL_CONSTANT} {
|
||||
({DECIMAL_CONSTANT}[uU]?)|({OCTAL_CONSTANT}[uU]?)|({HEXADECIMAL_CONSTANT}[uU]?) {
|
||||
yylval->assign(yytext, yyleng);
|
||||
return pp::Token::CONST_INT;
|
||||
}
|
||||
|
||||
({DIGIT}+{EXPONENT_PART})|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?) {
|
||||
({DIGIT}+{EXPONENT_PART}[fF]?)|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?[fF]?) {
|
||||
yylval->assign(yytext, yyleng);
|
||||
return pp::Token::CONST_FLOAT;
|
||||
}
|
||||
@ -267,9 +267,7 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
|
||||
|
||||
namespace pp {
|
||||
|
||||
Tokenizer::Tokenizer(Diagnostics* diagnostics)
|
||||
: mHandle(0),
|
||||
mMaxTokenLength(256)
|
||||
Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(0)
|
||||
{
|
||||
mContext.diagnostics = diagnostics;
|
||||
}
|
||||
@ -281,7 +279,8 @@ Tokenizer::~Tokenizer()
|
||||
|
||||
bool Tokenizer::init(size_t count, const char * const string[], const int length[])
|
||||
{
|
||||
if ((count > 0) && (string == 0)) return false;
|
||||
if ((count > 0) && (string == 0))
|
||||
return false;
|
||||
|
||||
mContext.input = Input(count, string, length);
|
||||
return initScanner();
|
||||
@ -299,14 +298,19 @@ void Tokenizer::setLineNumber(int line)
|
||||
yyset_lineno(line, mHandle);
|
||||
}
|
||||
|
||||
void Tokenizer::setMaxTokenSize(size_t maxTokenSize)
|
||||
{
|
||||
mMaxTokenSize = maxTokenSize;
|
||||
}
|
||||
|
||||
void Tokenizer::lex(Token *token)
|
||||
{
|
||||
token->type = yylex(&token->text, &token->location, mHandle);
|
||||
if (token->text.size() > mMaxTokenLength)
|
||||
if (token->text.size() > mMaxTokenSize)
|
||||
{
|
||||
mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
|
||||
token->location, token->text);
|
||||
token->text.erase(mMaxTokenLength);
|
||||
token->text.erase(mMaxTokenSize);
|
||||
}
|
||||
|
||||
token->flags = 0;
|
||||
|
@ -21,7 +21,7 @@ inline std::ios::fmtflags numeric_base_int(const std::string& str)
|
||||
{
|
||||
return std::ios::hex;
|
||||
}
|
||||
else if ((str.size() >= 1) && (str[0] == '0'))
|
||||
if ((str.size() >= 1) && (str[0] == '0'))
|
||||
{
|
||||
return std::ios::oct;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -7,6 +7,8 @@
|
||||
#ifndef _BASICTYPES_INCLUDED_
|
||||
#define _BASICTYPES_INCLUDED_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// Precision qualifiers
|
||||
//
|
||||
@ -38,14 +40,34 @@ enum TBasicType
|
||||
EbtVoid,
|
||||
EbtFloat,
|
||||
EbtInt,
|
||||
EbtUInt,
|
||||
EbtBool,
|
||||
EbtGVec4, // non type: represents vec4, ivec4 and uvec4
|
||||
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
|
||||
EbtSampler2D,
|
||||
EbtSampler3D,
|
||||
EbtSamplerCube,
|
||||
EbtSampler2DArray,
|
||||
EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
|
||||
EbtSampler2DRect, // Only valid if GL_ARB_texture_rectangle exists.
|
||||
EbtISampler2D,
|
||||
EbtISampler3D,
|
||||
EbtISamplerCube,
|
||||
EbtISampler2DArray,
|
||||
EbtUSampler2D,
|
||||
EbtUSampler3D,
|
||||
EbtUSamplerCube,
|
||||
EbtUSampler2DArray,
|
||||
EbtSampler2DShadow,
|
||||
EbtSamplerCubeShadow,
|
||||
EbtSampler2DArrayShadow,
|
||||
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
|
||||
EbtGSampler2D, // non type: represents sampler2D, isampler2D and usampler2D
|
||||
EbtGSampler3D, // non type: represents sampler3D, isampler3D and usampler3D
|
||||
EbtGSamplerCube, // non type: represents samplerCube, isamplerCube and usamplerCube
|
||||
EbtGSampler2DArray, // non type: represents sampler2DArray, isampler2DArray and usampler2DArray
|
||||
EbtStruct,
|
||||
EbtInterfaceBlock,
|
||||
EbtAddress, // should be deprecated??
|
||||
EbtInvariant // used as a type when qualifying a previously declared variable as being invariant
|
||||
};
|
||||
@ -57,12 +79,27 @@ inline const char* getBasicString(TBasicType t)
|
||||
case EbtVoid: return "void"; break;
|
||||
case EbtFloat: return "float"; break;
|
||||
case EbtInt: return "int"; break;
|
||||
case EbtUInt: return "uint"; break;
|
||||
case EbtBool: return "bool"; break;
|
||||
case EbtSampler2D: return "sampler2D"; break;
|
||||
case EbtSampler3D: return "sampler3D"; break;
|
||||
case EbtSamplerCube: return "samplerCube"; break;
|
||||
case EbtSamplerExternalOES: return "samplerExternalOES"; break;
|
||||
case EbtSampler2DRect: return "sampler2DRect"; break;
|
||||
case EbtSampler2DArray: return "sampler2DArray"; break;
|
||||
case EbtISampler2D: return "isampler2D"; break;
|
||||
case EbtISampler3D: return "isampler3D"; break;
|
||||
case EbtISamplerCube: return "isamplerCube"; break;
|
||||
case EbtISampler2DArray: return "isampler2DArray"; break;
|
||||
case EbtUSampler2D: return "usampler2D"; break;
|
||||
case EbtUSampler3D: return "usampler3D"; break;
|
||||
case EbtUSamplerCube: return "usamplerCube"; break;
|
||||
case EbtUSampler2DArray: return "usampler2DArray"; break;
|
||||
case EbtSampler2DShadow: return "sampler2DShadow"; break;
|
||||
case EbtSamplerCubeShadow: return "samplerCubeShadow"; break;
|
||||
case EbtSampler2DArrayShadow: return "sampler2DArrayShadow"; break;
|
||||
case EbtStruct: return "structure"; break;
|
||||
case EbtInterfaceBlock: return "interface block"; break;
|
||||
default: return "unknown type";
|
||||
}
|
||||
}
|
||||
@ -72,6 +109,191 @@ inline bool IsSampler(TBasicType type)
|
||||
return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
|
||||
}
|
||||
|
||||
inline bool IsIntegerSampler(TBasicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EbtISampler2D:
|
||||
case EbtISampler3D:
|
||||
case EbtISamplerCube:
|
||||
case EbtISampler2DArray:
|
||||
case EbtUSampler2D:
|
||||
case EbtUSampler3D:
|
||||
case EbtUSamplerCube:
|
||||
case EbtUSampler2DArray:
|
||||
return true;
|
||||
case EbtSampler2D:
|
||||
case EbtSampler3D:
|
||||
case EbtSamplerCube:
|
||||
case EbtSamplerExternalOES:
|
||||
case EbtSampler2DRect:
|
||||
case EbtSampler2DArray:
|
||||
case EbtSampler2DShadow:
|
||||
case EbtSamplerCubeShadow:
|
||||
case EbtSampler2DArrayShadow:
|
||||
return false;
|
||||
default:
|
||||
assert(!IsSampler(type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool IsSampler2D(TBasicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EbtSampler2D:
|
||||
case EbtISampler2D:
|
||||
case EbtUSampler2D:
|
||||
case EbtSampler2DArray:
|
||||
case EbtISampler2DArray:
|
||||
case EbtUSampler2DArray:
|
||||
case EbtSampler2DRect:
|
||||
case EbtSamplerExternalOES:
|
||||
case EbtSampler2DShadow:
|
||||
case EbtSampler2DArrayShadow:
|
||||
return true;
|
||||
case EbtSampler3D:
|
||||
case EbtISampler3D:
|
||||
case EbtUSampler3D:
|
||||
case EbtISamplerCube:
|
||||
case EbtUSamplerCube:
|
||||
case EbtSamplerCube:
|
||||
case EbtSamplerCubeShadow:
|
||||
return false;
|
||||
default:
|
||||
assert(!IsSampler(type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool IsSamplerCube(TBasicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EbtSamplerCube:
|
||||
case EbtISamplerCube:
|
||||
case EbtUSamplerCube:
|
||||
case EbtSamplerCubeShadow:
|
||||
return true;
|
||||
case EbtSampler2D:
|
||||
case EbtSampler3D:
|
||||
case EbtSamplerExternalOES:
|
||||
case EbtSampler2DRect:
|
||||
case EbtSampler2DArray:
|
||||
case EbtISampler2D:
|
||||
case EbtISampler3D:
|
||||
case EbtISampler2DArray:
|
||||
case EbtUSampler2D:
|
||||
case EbtUSampler3D:
|
||||
case EbtUSampler2DArray:
|
||||
case EbtSampler2DShadow:
|
||||
case EbtSampler2DArrayShadow:
|
||||
return false;
|
||||
default:
|
||||
assert(!IsSampler(type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool IsSampler3D(TBasicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EbtSampler3D:
|
||||
case EbtISampler3D:
|
||||
case EbtUSampler3D:
|
||||
return true;
|
||||
case EbtSampler2D:
|
||||
case EbtSamplerCube:
|
||||
case EbtSamplerExternalOES:
|
||||
case EbtSampler2DRect:
|
||||
case EbtSampler2DArray:
|
||||
case EbtISampler2D:
|
||||
case EbtISamplerCube:
|
||||
case EbtISampler2DArray:
|
||||
case EbtUSampler2D:
|
||||
case EbtUSamplerCube:
|
||||
case EbtUSampler2DArray:
|
||||
case EbtSampler2DShadow:
|
||||
case EbtSamplerCubeShadow:
|
||||
case EbtSampler2DArrayShadow:
|
||||
return false;
|
||||
default:
|
||||
assert(!IsSampler(type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool IsSamplerArray(TBasicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EbtSampler2DArray:
|
||||
case EbtISampler2DArray:
|
||||
case EbtUSampler2DArray:
|
||||
case EbtSampler2DArrayShadow:
|
||||
return true;
|
||||
case EbtSampler2D:
|
||||
case EbtISampler2D:
|
||||
case EbtUSampler2D:
|
||||
case EbtSampler2DRect:
|
||||
case EbtSamplerExternalOES:
|
||||
case EbtSampler3D:
|
||||
case EbtISampler3D:
|
||||
case EbtUSampler3D:
|
||||
case EbtISamplerCube:
|
||||
case EbtUSamplerCube:
|
||||
case EbtSamplerCube:
|
||||
case EbtSampler2DShadow:
|
||||
case EbtSamplerCubeShadow:
|
||||
return false;
|
||||
default:
|
||||
assert(!IsSampler(type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool IsShadowSampler(TBasicType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EbtSampler2DShadow:
|
||||
case EbtSamplerCubeShadow:
|
||||
case EbtSampler2DArrayShadow:
|
||||
return true;
|
||||
case EbtISampler2D:
|
||||
case EbtISampler3D:
|
||||
case EbtISamplerCube:
|
||||
case EbtISampler2DArray:
|
||||
case EbtUSampler2D:
|
||||
case EbtUSampler3D:
|
||||
case EbtUSamplerCube:
|
||||
case EbtUSampler2DArray:
|
||||
case EbtSampler2D:
|
||||
case EbtSampler3D:
|
||||
case EbtSamplerCube:
|
||||
case EbtSamplerExternalOES:
|
||||
case EbtSampler2DRect:
|
||||
case EbtSampler2DArray:
|
||||
return false;
|
||||
default:
|
||||
assert(!IsSampler(type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool SupportsPrecision(TBasicType type)
|
||||
{
|
||||
return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
|
||||
}
|
||||
|
||||
//
|
||||
// Qualifiers and built-ins. These are mainly used to see what can be read
|
||||
// or written, and by the machine dependent translator to know which registers
|
||||
@ -91,6 +313,11 @@ enum TQualifier
|
||||
EvqInvariantVaryingOut, // vertex shaders only read/write
|
||||
EvqUniform, // Readonly, vertex and fragment
|
||||
|
||||
EvqVertexIn, // Vertex shader input
|
||||
EvqFragmentOut, // Fragment shader output
|
||||
EvqVertexOut, // Vertex shader output
|
||||
EvqFragmentIn, // Fragment shader input
|
||||
|
||||
// parameters
|
||||
EvqIn,
|
||||
EvqOut,
|
||||
@ -111,10 +338,58 @@ enum TQualifier
|
||||
EvqFragData,
|
||||
EvqFragDepth,
|
||||
|
||||
// GLSL ES 3.0 vertex output and fragment input
|
||||
EvqSmooth, // Incomplete qualifier, smooth is the default
|
||||
EvqFlat, // Incomplete qualifier
|
||||
EvqSmoothOut = EvqSmooth,
|
||||
EvqFlatOut = EvqFlat,
|
||||
EvqCentroidOut, // Implies smooth
|
||||
EvqSmoothIn,
|
||||
EvqFlatIn,
|
||||
EvqCentroidIn, // Implies smooth
|
||||
|
||||
// end of list
|
||||
EvqLast
|
||||
};
|
||||
|
||||
enum TLayoutMatrixPacking
|
||||
{
|
||||
EmpUnspecified,
|
||||
EmpRowMajor,
|
||||
EmpColumnMajor
|
||||
};
|
||||
|
||||
enum TLayoutBlockStorage
|
||||
{
|
||||
EbsUnspecified,
|
||||
EbsShared,
|
||||
EbsPacked,
|
||||
EbsStd140
|
||||
};
|
||||
|
||||
struct TLayoutQualifier
|
||||
{
|
||||
int location;
|
||||
TLayoutMatrixPacking matrixPacking;
|
||||
TLayoutBlockStorage blockStorage;
|
||||
|
||||
static TLayoutQualifier create()
|
||||
{
|
||||
TLayoutQualifier layoutQualifier;
|
||||
|
||||
layoutQualifier.location = -1;
|
||||
layoutQualifier.matrixPacking = EmpUnspecified;
|
||||
layoutQualifier.blockStorage = EbsUnspecified;
|
||||
|
||||
return layoutQualifier;
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
return location == -1 && matrixPacking == EmpUnspecified && blockStorage == EbsUnspecified;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// This is just for debug print out, carried along with the definitions above.
|
||||
//
|
||||
@ -132,6 +407,10 @@ inline const char* getQualifierString(TQualifier q)
|
||||
case EvqInvariantVaryingIn: return "invariant varying"; break;
|
||||
case EvqInvariantVaryingOut:return "invariant varying"; break;
|
||||
case EvqUniform: return "uniform"; break;
|
||||
case EvqVertexIn: return "in"; break;
|
||||
case EvqFragmentOut: return "out"; break;
|
||||
case EvqVertexOut: return "out"; break;
|
||||
case EvqFragmentIn: return "in"; break;
|
||||
case EvqIn: return "in"; break;
|
||||
case EvqOut: return "out"; break;
|
||||
case EvqInOut: return "inout"; break;
|
||||
@ -142,8 +421,51 @@ inline const char* getQualifierString(TQualifier q)
|
||||
case EvqFragColor: return "FragColor"; break;
|
||||
case EvqFragData: return "FragData"; break;
|
||||
case EvqFragDepth: return "FragDepth"; break;
|
||||
case EvqSmoothOut: return "smooth out"; break;
|
||||
case EvqCentroidOut: return "centroid out"; break;
|
||||
case EvqFlatOut: return "flat out"; break;
|
||||
case EvqSmoothIn: return "smooth in"; break;
|
||||
case EvqCentroidIn: return "centroid in"; break;
|
||||
case EvqFlatIn: return "flat in"; break;
|
||||
default: return "unknown qualifier";
|
||||
}
|
||||
}
|
||||
|
||||
inline const char* getMatrixPackingString(TLayoutMatrixPacking mpq)
|
||||
{
|
||||
switch (mpq)
|
||||
{
|
||||
case EmpUnspecified: return "mp_unspecified";
|
||||
case EmpRowMajor: return "row_major";
|
||||
case EmpColumnMajor: return "column_major";
|
||||
default: return "unknown matrix packing";
|
||||
}
|
||||
}
|
||||
|
||||
inline const char* getBlockStorageString(TLayoutBlockStorage bsq)
|
||||
{
|
||||
switch (bsq)
|
||||
{
|
||||
case EbsUnspecified: return "bs_unspecified";
|
||||
case EbsShared: return "shared";
|
||||
case EbsPacked: return "packed";
|
||||
case EbsStd140: return "std140";
|
||||
default: return "unknown block storage";
|
||||
}
|
||||
}
|
||||
|
||||
inline const char* getInterpolationString(TQualifier q)
|
||||
{
|
||||
switch(q)
|
||||
{
|
||||
case EvqSmoothOut: return "smooth"; break;
|
||||
case EvqCentroidOut: return "centroid"; break;
|
||||
case EvqFlatOut: return "flat"; break;
|
||||
case EvqSmoothIn: return "smooth"; break;
|
||||
case EvqCentroidIn: return "centroid"; break;
|
||||
case EvqFlatIn: return "flat"; break;
|
||||
default: return "unknown interpolation";
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _BASICTYPES_INCLUDED_
|
||||
|
@ -4,8 +4,8 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "angle_gl.h"
|
||||
#include "compiler/translator/BuiltInFunctionEmulator.h"
|
||||
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
namespace {
|
||||
@ -243,7 +243,7 @@ public:
|
||||
default:
|
||||
return true;
|
||||
};
|
||||
const TIntermSequence& sequence = node->getSequence();
|
||||
const TIntermSequence& sequence = *(node->getSequence());
|
||||
// Right now we only handle built-in functions with two parameters.
|
||||
if (sequence.size() != 2)
|
||||
return true;
|
||||
@ -265,9 +265,9 @@ private:
|
||||
|
||||
} // anonymous namepsace
|
||||
|
||||
BuiltInFunctionEmulator::BuiltInFunctionEmulator(ShShaderType shaderType)
|
||||
BuiltInFunctionEmulator::BuiltInFunctionEmulator(sh::GLenum shaderType)
|
||||
{
|
||||
if (shaderType == SH_FRAGMENT_SHADER) {
|
||||
if (shaderType == GL_FRAGMENT_SHADER) {
|
||||
mFunctionMask = kFunctionEmulationFragmentMask;
|
||||
mFunctionSource = kFunctionEmulationFragmentSource;
|
||||
} else {
|
||||
@ -327,7 +327,7 @@ BuiltInFunctionEmulator::TBuiltInFunction
|
||||
BuiltInFunctionEmulator::IdentifyFunction(
|
||||
TOperator op, const TType& param)
|
||||
{
|
||||
if (param.getNominalSize() > 4)
|
||||
if (param.getNominalSize() > 4 || param.getSecondarySize() > 4)
|
||||
return TFunctionUnknown;
|
||||
unsigned int function = TFunctionUnknown;
|
||||
switch (op) {
|
||||
@ -356,9 +356,9 @@ BuiltInFunctionEmulator::IdentifyFunction(
|
||||
{
|
||||
// Right now for all the emulated functions with two parameters, the two
|
||||
// parameters have the same type.
|
||||
if (param1.isVector() != param2.isVector() ||
|
||||
param1.getNominalSize() != param2.getNominalSize() ||
|
||||
param1.getNominalSize() > 4)
|
||||
if (param1.getNominalSize() != param2.getNominalSize() ||
|
||||
param1.getSecondarySize() != param2.getSecondarySize() ||
|
||||
param1.getNominalSize() > 4 || param1.getSecondarySize() > 4)
|
||||
return TFunctionUnknown;
|
||||
|
||||
unsigned int function = TFunctionUnknown;
|
||||
|
@ -7,8 +7,6 @@
|
||||
#ifndef COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
|
||||
#define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
@ -19,7 +17,7 @@
|
||||
//
|
||||
class BuiltInFunctionEmulator {
|
||||
public:
|
||||
BuiltInFunctionEmulator(ShShaderType shaderType);
|
||||
BuiltInFunctionEmulator(sh::GLenum shaderType);
|
||||
// Records that a function is called by the shader and might needs to be
|
||||
// emulated. If the function's group is not in mFunctionGroupFilter, this
|
||||
// becomes an no-op.
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -14,7 +14,7 @@
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(
|
||||
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
|
||||
sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
|
||||
{
|
||||
switch (output) {
|
||||
case SH_ESSL_OUTPUT:
|
||||
|
@ -1,33 +1,50 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/translator/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/translator/Compiler.h"
|
||||
#include "compiler/translator/DetectCallDepth.h"
|
||||
#include "compiler/translator/ForLoopUnroll.h"
|
||||
#include "compiler/translator/Initialize.h"
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
#include "compiler/translator/InitializeVariables.h"
|
||||
#include "compiler/translator/MapLongVariableNames.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
#include "compiler/translator/RenameFunction.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
|
||||
#include "compiler/translator/UnfoldShortCircuitAST.h"
|
||||
#include "compiler/translator/ValidateLimitations.h"
|
||||
#include "compiler/translator/ValidateOutputs.h"
|
||||
#include "compiler/translator/VariablePacker.h"
|
||||
#include "compiler/translator/depgraph/DependencyGraph.h"
|
||||
#include "compiler/translator/depgraph/DependencyGraphOutput.h"
|
||||
#include "compiler/translator/timing/RestrictFragmentShaderTiming.h"
|
||||
#include "compiler/translator/timing/RestrictVertexShaderTiming.h"
|
||||
#include "third_party/compiler/ArrayBoundsClamper.h"
|
||||
#include "angle_gl.h"
|
||||
#include "common/utilities.h"
|
||||
|
||||
bool isWebGLBasedSpec(ShShaderSpec spec)
|
||||
bool IsWebGLBasedSpec(ShShaderSpec spec)
|
||||
{
|
||||
return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC;
|
||||
}
|
||||
|
||||
size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
|
||||
{
|
||||
// WebGL defines a max token legnth of 256, while ES2 leaves max token
|
||||
// size undefined. ES3 defines a max size of 1024 characters.
|
||||
if (IsWebGLBasedSpec(spec))
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
class TScopedPoolAllocator
|
||||
{
|
||||
@ -78,9 +95,10 @@ TShHandleBase::~TShHandleBase()
|
||||
allocator.popAll();
|
||||
}
|
||||
|
||||
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
|
||||
TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
|
||||
: shaderType(type),
|
||||
shaderSpec(spec),
|
||||
outputType(output),
|
||||
maxUniformVectors(0),
|
||||
maxExpressionComplexity(0),
|
||||
maxCallStackDepth(0),
|
||||
@ -88,18 +106,16 @@ TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
|
||||
clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
|
||||
builtInFunctionEmulator(type)
|
||||
{
|
||||
longNameMap = LongNameMap::GetInstance();
|
||||
}
|
||||
|
||||
TCompiler::~TCompiler()
|
||||
{
|
||||
ASSERT(longNameMap);
|
||||
longNameMap->Release();
|
||||
}
|
||||
|
||||
bool TCompiler::Init(const ShBuiltInResources& resources)
|
||||
{
|
||||
maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
|
||||
shaderVersion = 100;
|
||||
maxUniformVectors = (shaderType == GL_VERTEX_SHADER) ?
|
||||
resources.MaxVertexUniformVectors :
|
||||
resources.MaxFragmentUniformVectors;
|
||||
maxExpressionComplexity = resources.MaxExpressionComplexity;
|
||||
@ -132,7 +148,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
return true;
|
||||
|
||||
// If compiling for WebGL, validate loop and indexing as well.
|
||||
if (isWebGLBasedSpec(shaderSpec))
|
||||
if (IsWebGLBasedSpec(shaderSpec))
|
||||
compileOptions |= SH_VALIDATE_LOOP_INDEXING;
|
||||
|
||||
// First string is path of source file if flag is set. The actual source follows.
|
||||
@ -159,14 +175,24 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
bool success =
|
||||
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
|
||||
(parseContext.treeRoot != NULL);
|
||||
|
||||
shaderVersion = parseContext.getShaderVersion();
|
||||
|
||||
if (success)
|
||||
{
|
||||
TIntermNode* root = parseContext.treeRoot;
|
||||
success = intermediate.postProcess(root);
|
||||
|
||||
// Disallow expressions deemed too complex.
|
||||
if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY))
|
||||
success = limitExpressionComplexity(root);
|
||||
|
||||
if (success)
|
||||
success = detectCallDepth(root, infoSink, (compileOptions & SH_LIMIT_CALL_STACK_DEPTH) != 0);
|
||||
|
||||
if (success && shaderVersion == 300 && shaderType == GL_FRAGMENT_SHADER)
|
||||
success = validateOutputs(root);
|
||||
|
||||
if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
|
||||
success = validateLimitations(root);
|
||||
|
||||
@ -178,7 +204,21 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
|
||||
// Unroll for-loop markup needs to happen after validateLimitations pass.
|
||||
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
|
||||
ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(root);
|
||||
{
|
||||
ForLoopUnrollMarker marker(ForLoopUnrollMarker::kIntegerIndex);
|
||||
root->traverse(&marker);
|
||||
}
|
||||
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX))
|
||||
{
|
||||
ForLoopUnrollMarker marker(ForLoopUnrollMarker::kSamplerArrayIndex);
|
||||
root->traverse(&marker);
|
||||
if (marker.samplerArrayIndexIsFloatLoopIndex())
|
||||
{
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "sampler array index is float loop index";
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Built-in function emulation needs to happen after validateLimitations pass.
|
||||
if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS))
|
||||
@ -188,18 +228,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS))
|
||||
arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
|
||||
|
||||
// Disallow expressions deemed too complex.
|
||||
if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY))
|
||||
success = limitExpressionComplexity(root);
|
||||
|
||||
// Call mapLongVariableNames() before collectAttribsUniforms() so in
|
||||
// collectAttribsUniforms() we already have the mapped symbol names and
|
||||
// we could composite mapped and original variable names.
|
||||
// Also, if we hash all the names, then no need to do this for long names.
|
||||
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
|
||||
mapLongVariableNames(root);
|
||||
|
||||
if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
|
||||
if (success && shaderType == GL_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
|
||||
initializeGLPosition(root);
|
||||
|
||||
if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT))
|
||||
@ -221,11 +250,17 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
infoSink.info << "too many uniforms";
|
||||
}
|
||||
}
|
||||
if (success && shaderType == SH_VERTEX_SHADER &&
|
||||
if (success && shaderType == GL_VERTEX_SHADER &&
|
||||
(compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
|
||||
initializeVaryingsWithoutStaticUse(root);
|
||||
}
|
||||
|
||||
if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS))
|
||||
{
|
||||
ScalarizeVecAndMatConstructorArgs scalarizer;
|
||||
root->traverse(&scalarizer);
|
||||
}
|
||||
|
||||
if (success && (compileOptions & SH_INTERMEDIATE_TREE))
|
||||
intermediate.outputTree(root);
|
||||
|
||||
@ -235,40 +270,43 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
|
||||
// Cleanup memory.
|
||||
intermediate.remove(parseContext.treeRoot);
|
||||
|
||||
SetGlobalParseContext(NULL);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
|
||||
{
|
||||
compileResources = resources;
|
||||
setResourceString();
|
||||
|
||||
assert(symbolTable.isEmpty());
|
||||
symbolTable.push();
|
||||
symbolTable.push(); // COMMON_BUILTINS
|
||||
symbolTable.push(); // ESSL1_BUILTINS
|
||||
symbolTable.push(); // ESSL3_BUILTINS
|
||||
|
||||
TPublicType integer;
|
||||
integer.type = EbtInt;
|
||||
integer.size = 1;
|
||||
integer.matrix = false;
|
||||
integer.primarySize = 1;
|
||||
integer.secondarySize = 1;
|
||||
integer.array = false;
|
||||
|
||||
TPublicType floatingPoint;
|
||||
floatingPoint.type = EbtFloat;
|
||||
floatingPoint.size = 1;
|
||||
floatingPoint.matrix = false;
|
||||
floatingPoint.primarySize = 1;
|
||||
floatingPoint.secondarySize = 1;
|
||||
floatingPoint.array = false;
|
||||
|
||||
TPublicType sampler;
|
||||
sampler.size = 1;
|
||||
sampler.matrix = false;
|
||||
sampler.primarySize = 1;
|
||||
sampler.secondarySize = 1;
|
||||
sampler.array = false;
|
||||
|
||||
switch(shaderType)
|
||||
{
|
||||
case SH_FRAGMENT_SHADER:
|
||||
case GL_FRAGMENT_SHADER:
|
||||
symbolTable.setDefaultPrecision(integer, EbpMedium);
|
||||
break;
|
||||
case SH_VERTEX_SHADER:
|
||||
case GL_VERTEX_SHADER:
|
||||
symbolTable.setDefaultPrecision(integer, EbpHigh);
|
||||
symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
|
||||
break;
|
||||
@ -291,6 +329,34 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCompiler::setResourceString()
|
||||
{
|
||||
std::ostringstream strstream;
|
||||
strstream << ":MaxVertexAttribs:" << compileResources.MaxVertexAttribs
|
||||
<< ":MaxVertexUniformVectors:" << compileResources.MaxVertexUniformVectors
|
||||
<< ":MaxVaryingVectors:" << compileResources.MaxVaryingVectors
|
||||
<< ":MaxVertexTextureImageUnits:" << compileResources.MaxVertexTextureImageUnits
|
||||
<< ":MaxCombinedTextureImageUnits:" << compileResources.MaxCombinedTextureImageUnits
|
||||
<< ":MaxTextureImageUnits:" << compileResources.MaxTextureImageUnits
|
||||
<< ":MaxFragmentUniformVectors:" << compileResources.MaxFragmentUniformVectors
|
||||
<< ":MaxDrawBuffers:" << compileResources.MaxDrawBuffers
|
||||
<< ":OES_standard_derivatives:" << compileResources.OES_standard_derivatives
|
||||
<< ":OES_EGL_image_external:" << compileResources.OES_EGL_image_external
|
||||
<< ":ARB_texture_rectangle:" << compileResources.ARB_texture_rectangle
|
||||
<< ":EXT_draw_buffers:" << compileResources.EXT_draw_buffers
|
||||
<< ":FragmentPrecisionHigh:" << compileResources.FragmentPrecisionHigh
|
||||
<< ":MaxExpressionComplexity:" << compileResources.MaxExpressionComplexity
|
||||
<< ":MaxCallStackDepth:" << compileResources.MaxCallStackDepth
|
||||
<< ":EXT_frag_depth:" << compileResources.EXT_frag_depth
|
||||
<< ":EXT_shader_texture_lod:" << compileResources.EXT_shader_texture_lod
|
||||
<< ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors
|
||||
<< ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors
|
||||
<< ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset
|
||||
<< ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset;
|
||||
|
||||
builtInResourcesString = strstream.str();
|
||||
}
|
||||
|
||||
void TCompiler::clearResults()
|
||||
{
|
||||
arrayBoundsClamper.Cleanup();
|
||||
@ -298,9 +364,13 @@ void TCompiler::clearResults()
|
||||
infoSink.obj.erase();
|
||||
infoSink.debug.erase();
|
||||
|
||||
attribs.clear();
|
||||
attributes.clear();
|
||||
outputVariables.clear();
|
||||
uniforms.clear();
|
||||
expandedUniforms.clear();
|
||||
varyings.clear();
|
||||
expandedVaryings.clear();
|
||||
interfaceBlocks.clear();
|
||||
|
||||
builtInFunctionEmulator.Cleanup();
|
||||
|
||||
@ -333,6 +403,13 @@ bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool lim
|
||||
}
|
||||
}
|
||||
|
||||
bool TCompiler::validateOutputs(TIntermNode* root)
|
||||
{
|
||||
ValidateOutputs validateOutputs(infoSink.info, compileResources.MaxDrawBuffers);
|
||||
root->traverse(&validateOutputs);
|
||||
return (validateOutputs.numErrors() == 0);
|
||||
}
|
||||
|
||||
void TCompiler::rewriteCSSShader(TIntermNode* root)
|
||||
{
|
||||
RenameFunction renamer("main(", "css_main(");
|
||||
@ -354,7 +431,7 @@ bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shaderType == SH_FRAGMENT_SHADER)
|
||||
if (shaderType == GL_FRAGMENT_SHADER)
|
||||
{
|
||||
TDependencyGraph graph(root);
|
||||
|
||||
@ -378,8 +455,15 @@ bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
|
||||
|
||||
bool TCompiler::limitExpressionComplexity(TIntermNode* root)
|
||||
{
|
||||
TIntermTraverser traverser;
|
||||
TMaxDepthTraverser traverser(maxExpressionComplexity+1);
|
||||
root->traverse(&traverser);
|
||||
|
||||
if (traverser.getMaxDepth() > maxExpressionComplexity)
|
||||
{
|
||||
infoSink.info << "Expression too complex.";
|
||||
return false;
|
||||
}
|
||||
|
||||
TDependencyGraph graph(root);
|
||||
|
||||
for (TFunctionCallVector::const_iterator iter = graph.beginUserDefinedFunctionCalls();
|
||||
@ -391,11 +475,6 @@ bool TCompiler::limitExpressionComplexity(TIntermNode* root)
|
||||
samplerSymbol->traverse(&graphTraverser);
|
||||
}
|
||||
|
||||
if (traverser.getMaxDepth() > maxExpressionComplexity)
|
||||
{
|
||||
infoSink.info << "Expression too complex.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -415,14 +494,24 @@ bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
|
||||
|
||||
void TCompiler::collectVariables(TIntermNode* root)
|
||||
{
|
||||
CollectVariables collect(attribs, uniforms, varyings, hashFunction);
|
||||
CollectVariables collect(&attributes,
|
||||
&outputVariables,
|
||||
&uniforms,
|
||||
&varyings,
|
||||
&interfaceBlocks,
|
||||
hashFunction);
|
||||
root->traverse(&collect);
|
||||
|
||||
// For backwards compatiblity with ShGetVariableInfo, expand struct
|
||||
// uniforms and varyings into separate variables for each field.
|
||||
ExpandVariables(uniforms, &expandedUniforms);
|
||||
ExpandVariables(varyings, &expandedVaryings);
|
||||
}
|
||||
|
||||
bool TCompiler::enforcePackingRestrictions()
|
||||
{
|
||||
VariablePacker packer;
|
||||
return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
|
||||
return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, expandedUniforms);
|
||||
}
|
||||
|
||||
void TCompiler::initializeGLPosition(TIntermNode* root)
|
||||
@ -440,45 +529,16 @@ void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
|
||||
InitializeVariables::InitVariableInfoList variables;
|
||||
for (size_t ii = 0; ii < varyings.size(); ++ii)
|
||||
{
|
||||
const TVariableInfo& varying = varyings[ii];
|
||||
const sh::Varying& varying = varyings[ii];
|
||||
if (varying.staticUse)
|
||||
continue;
|
||||
unsigned char size = 0;
|
||||
bool matrix = false;
|
||||
switch (varying.type)
|
||||
{
|
||||
case SH_FLOAT:
|
||||
size = 1;
|
||||
break;
|
||||
case SH_FLOAT_VEC2:
|
||||
size = 2;
|
||||
break;
|
||||
case SH_FLOAT_VEC3:
|
||||
size = 3;
|
||||
break;
|
||||
case SH_FLOAT_VEC4:
|
||||
size = 4;
|
||||
break;
|
||||
case SH_FLOAT_MAT2:
|
||||
size = 2;
|
||||
matrix = true;
|
||||
break;
|
||||
case SH_FLOAT_MAT3:
|
||||
size = 3;
|
||||
matrix = true;
|
||||
break;
|
||||
case SH_FLOAT_MAT4:
|
||||
size = 4;
|
||||
matrix = true;
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
}
|
||||
TType type(EbtFloat, EbpUndefined, EvqVaryingOut, size, matrix, varying.isArray);
|
||||
unsigned char primarySize = static_cast<unsigned char>(gl::VariableColumnCount(varying.type));
|
||||
unsigned char secondarySize = static_cast<unsigned char>(gl::VariableRowCount(varying.type));
|
||||
TType type(EbtFloat, EbpUndefined, EvqVaryingOut, primarySize, secondarySize, varying.isArray());
|
||||
TString name = varying.name.c_str();
|
||||
if (varying.isArray)
|
||||
if (varying.isArray())
|
||||
{
|
||||
type.setArraySize(varying.size);
|
||||
type.setArraySize(varying.arraySize);
|
||||
name = name.substr(0, name.find_first_of('['));
|
||||
}
|
||||
|
||||
@ -489,18 +549,6 @@ void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
|
||||
root->traverse(&initializer);
|
||||
}
|
||||
|
||||
void TCompiler::mapLongVariableNames(TIntermNode* root)
|
||||
{
|
||||
ASSERT(longNameMap);
|
||||
MapLongVariableNames map(longNameMap);
|
||||
root->traverse(&map);
|
||||
}
|
||||
|
||||
int TCompiler::getMappedNameMaxLength() const
|
||||
{
|
||||
return MAX_SHORTENED_IDENTIFIER_SIZE + 1;
|
||||
}
|
||||
|
||||
const TExtensionBehavior& TCompiler::getExtensionBehavior() const
|
||||
{
|
||||
return extensionBehavior;
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -14,8 +14,6 @@
|
||||
// This should not be included by driver code.
|
||||
//
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/translator/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/translator/ExtensionBehavior.h"
|
||||
#include "compiler/translator/HashNames.h"
|
||||
@ -24,7 +22,6 @@
|
||||
#include "compiler/translator/VariableInfo.h"
|
||||
#include "third_party/compiler/ArrayBoundsClamper.h"
|
||||
|
||||
class LongNameMap;
|
||||
class TCompiler;
|
||||
class TDependencyGraph;
|
||||
class TranslatorHLSL;
|
||||
@ -33,7 +30,7 @@ class TranslatorHLSL;
|
||||
// Helper function to identify specs that are based on the WebGL spec,
|
||||
// like the CSS Shaders spec.
|
||||
//
|
||||
bool isWebGLBasedSpec(ShShaderSpec spec);
|
||||
bool IsWebGLBasedSpec(ShShaderSpec spec);
|
||||
|
||||
//
|
||||
// The base class used to back handles returned to the driver.
|
||||
@ -55,9 +52,10 @@ protected:
|
||||
// The base class for the machine dependent compiler to derive from
|
||||
// for managing object code from the compile.
|
||||
//
|
||||
class TCompiler : public TShHandleBase {
|
||||
class TCompiler : public TShHandleBase
|
||||
{
|
||||
public:
|
||||
TCompiler(ShShaderType type, ShShaderSpec spec);
|
||||
TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
|
||||
virtual ~TCompiler();
|
||||
virtual TCompiler* getAsCompiler() { return this; }
|
||||
|
||||
@ -67,25 +65,36 @@ public:
|
||||
int compileOptions);
|
||||
|
||||
// Get results of the last compilation.
|
||||
int getShaderVersion() const { return shaderVersion; }
|
||||
TInfoSink& getInfoSink() { return infoSink; }
|
||||
const TVariableInfoList& getAttribs() const { return attribs; }
|
||||
const TVariableInfoList& getUniforms() const { return uniforms; }
|
||||
const TVariableInfoList& getVaryings() const { return varyings; }
|
||||
int getMappedNameMaxLength() const;
|
||||
|
||||
const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
|
||||
const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; }
|
||||
const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
|
||||
const std::vector<sh::Uniform> &getExpandedUniforms() const { return expandedUniforms; }
|
||||
const std::vector<sh::Varying> &getVaryings() const { return varyings; }
|
||||
const std::vector<sh::Varying> &getExpandedVaryings() const { return expandedVaryings; }
|
||||
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
|
||||
|
||||
ShHashFunction64 getHashFunction() const { return hashFunction; }
|
||||
NameMap& getNameMap() { return nameMap; }
|
||||
TSymbolTable& getSymbolTable() { return symbolTable; }
|
||||
ShShaderSpec getShaderSpec() const { return shaderSpec; }
|
||||
ShShaderOutput getOutputType() const { return outputType; }
|
||||
std::string getBuiltInResourcesString() const { return builtInResourcesString; }
|
||||
|
||||
protected:
|
||||
ShShaderType getShaderType() const { return shaderType; }
|
||||
ShShaderSpec getShaderSpec() const { return shaderSpec; }
|
||||
sh::GLenum getShaderType() const { return shaderType; }
|
||||
// Initialize symbol-table with built-in symbols.
|
||||
bool InitBuiltInSymbolTable(const ShBuiltInResources& resources);
|
||||
// Compute the string representation of the built-in resources
|
||||
void setResourceString();
|
||||
// Clears the results from the previous compilation.
|
||||
void clearResults();
|
||||
// Return true if function recursion is detected or call depth exceeded.
|
||||
bool detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool limitCallStackDepth);
|
||||
// Returns true if a program has no conflicting or missing fragment outputs
|
||||
bool validateOutputs(TIntermNode* root);
|
||||
// Rewrites a shader's intermediate tree according to the CSS Shaders spec.
|
||||
void rewriteCSSShader(TIntermNode* root);
|
||||
// Returns true if the given shader does not exceed the minimum
|
||||
@ -93,8 +102,6 @@ protected:
|
||||
bool validateLimitations(TIntermNode* root);
|
||||
// Collect info for all attribs, uniforms, varyings.
|
||||
void collectVariables(TIntermNode* root);
|
||||
// Map long variable names into shorter ones.
|
||||
void mapLongVariableNames(TIntermNode* root);
|
||||
// Translate to object code.
|
||||
virtual void translate(TIntermNode* root) = 0;
|
||||
// Returns true if, after applying the packing rules in the GLSL 1.017 spec
|
||||
@ -117,7 +124,7 @@ protected:
|
||||
// Returns true if the shader does not use sampler dependent values to affect control
|
||||
// flow or in operations whose time can depend on the input values.
|
||||
bool enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph);
|
||||
// Return true if the maximum expression complexity below the limit.
|
||||
// Return true if the maximum expression complexity is below the limit.
|
||||
bool limitExpressionComplexity(TIntermNode* root);
|
||||
// Get built-in extensions with default behavior.
|
||||
const TExtensionBehavior& getExtensionBehavior() const;
|
||||
@ -128,15 +135,25 @@ protected:
|
||||
ShArrayIndexClampingStrategy getArrayIndexClampingStrategy() const;
|
||||
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
|
||||
|
||||
std::vector<sh::Attribute> attributes;
|
||||
std::vector<sh::Attribute> outputVariables;
|
||||
std::vector<sh::Uniform> uniforms;
|
||||
std::vector<sh::Uniform> expandedUniforms;
|
||||
std::vector<sh::Varying> varyings;
|
||||
std::vector<sh::Varying> expandedVaryings;
|
||||
std::vector<sh::InterfaceBlock> interfaceBlocks;
|
||||
|
||||
private:
|
||||
ShShaderType shaderType;
|
||||
sh::GLenum shaderType;
|
||||
ShShaderSpec shaderSpec;
|
||||
ShShaderOutput outputType;
|
||||
|
||||
int maxUniformVectors;
|
||||
int maxExpressionComplexity;
|
||||
int maxCallStackDepth;
|
||||
|
||||
ShBuiltInResources compileResources;
|
||||
std::string builtInResourcesString;
|
||||
|
||||
// Built-in symbol table for the given language, spec, and resources.
|
||||
// It is preserved from compile-to-compile.
|
||||
@ -150,13 +167,8 @@ private:
|
||||
BuiltInFunctionEmulator builtInFunctionEmulator;
|
||||
|
||||
// Results of compilation.
|
||||
int shaderVersion;
|
||||
TInfoSink infoSink; // Output sink.
|
||||
TVariableInfoList attribs; // Active attributes in the compiled shader.
|
||||
TVariableInfoList uniforms; // Active uniforms in the compiled shader.
|
||||
TVariableInfoList varyings; // Varyings in the compiled shader.
|
||||
|
||||
// Cached copy of the ref-counted singleton.
|
||||
LongNameMap* longNameMap;
|
||||
|
||||
// name hashing.
|
||||
ShHashFunction64 hashFunction;
|
||||
@ -173,7 +185,7 @@ private:
|
||||
// above machine independent information.
|
||||
//
|
||||
TCompiler* ConstructCompiler(
|
||||
ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
|
||||
sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
|
||||
void DeleteCompiler(TCompiler*);
|
||||
|
||||
#endif // _SHHANDLE_INCLUDED_
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -18,14 +18,74 @@ public:
|
||||
type = EbtVoid;
|
||||
}
|
||||
|
||||
bool cast(TBasicType newType, const ConstantUnion &constant)
|
||||
{
|
||||
switch (newType)
|
||||
{
|
||||
case EbtFloat:
|
||||
switch (constant.type)
|
||||
{
|
||||
case EbtInt: setFConst(static_cast<float>(constant.getIConst())); break;
|
||||
case EbtUInt: setFConst(static_cast<float>(constant.getUConst())); break;
|
||||
case EbtBool: setFConst(static_cast<float>(constant.getBConst())); break;
|
||||
case EbtFloat: setFConst(static_cast<float>(constant.getFConst())); break;
|
||||
default: return false;
|
||||
}
|
||||
break;
|
||||
case EbtInt:
|
||||
switch (constant.type)
|
||||
{
|
||||
case EbtInt: setIConst(static_cast<int>(constant.getIConst())); break;
|
||||
case EbtUInt: setIConst(static_cast<int>(constant.getUConst())); break;
|
||||
case EbtBool: setIConst(static_cast<int>(constant.getBConst())); break;
|
||||
case EbtFloat: setIConst(static_cast<int>(constant.getFConst())); break;
|
||||
default: return false;
|
||||
}
|
||||
break;
|
||||
case EbtUInt:
|
||||
switch (constant.type)
|
||||
{
|
||||
case EbtInt: setUConst(static_cast<unsigned int>(constant.getIConst())); break;
|
||||
case EbtUInt: setUConst(static_cast<unsigned int>(constant.getUConst())); break;
|
||||
case EbtBool: setUConst(static_cast<unsigned int>(constant.getBConst())); break;
|
||||
case EbtFloat: setUConst(static_cast<unsigned int>(constant.getFConst())); break;
|
||||
default: return false;
|
||||
}
|
||||
break;
|
||||
case EbtBool:
|
||||
switch (constant.type)
|
||||
{
|
||||
case EbtInt: setBConst(constant.getIConst() != 0); break;
|
||||
case EbtUInt: setBConst(constant.getUConst() != 0); break;
|
||||
case EbtBool: setBConst(constant.getBConst()); break;
|
||||
case EbtFloat: setBConst(constant.getFConst() != 0.0f); break;
|
||||
default: return false;
|
||||
}
|
||||
break;
|
||||
case EbtStruct: // Struct fields don't get cast
|
||||
switch (constant.type)
|
||||
{
|
||||
case EbtInt: setIConst(constant.getIConst()); break;
|
||||
case EbtUInt: setUConst(constant.getUConst()); break;
|
||||
case EbtBool: setBConst(constant.getBConst()); break;
|
||||
case EbtFloat: setFConst(constant.getFConst()); break;
|
||||
default: return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void setIConst(int i) {iConst = i; type = EbtInt; }
|
||||
void setUConst(unsigned int u) { uConst = u; type = EbtUInt; }
|
||||
void setFConst(float f) {fConst = f; type = EbtFloat; }
|
||||
void setBConst(bool b) {bConst = b; type = EbtBool; }
|
||||
|
||||
int getIConst() { return iConst; }
|
||||
float getFConst() { return fConst; }
|
||||
bool getBConst() { return bConst; }
|
||||
int getIConst() const { return iConst; }
|
||||
unsigned int getUConst() const { return uConst; }
|
||||
float getFConst() const { return fConst; }
|
||||
bool getBConst() const { return bConst; }
|
||||
|
||||
@ -34,6 +94,11 @@ public:
|
||||
return i == iConst;
|
||||
}
|
||||
|
||||
bool operator==(const unsigned int u) const
|
||||
{
|
||||
return u == uConst;
|
||||
}
|
||||
|
||||
bool operator==(const float f) const
|
||||
{
|
||||
return f == fConst;
|
||||
@ -52,6 +117,8 @@ public:
|
||||
switch (type) {
|
||||
case EbtInt:
|
||||
return constant.iConst == iConst;
|
||||
case EbtUInt:
|
||||
return constant.uConst == uConst;
|
||||
case EbtFloat:
|
||||
return constant.fConst == fConst;
|
||||
case EbtBool:
|
||||
@ -66,6 +133,11 @@ public:
|
||||
return !operator==(i);
|
||||
}
|
||||
|
||||
bool operator!=(const unsigned int u) const
|
||||
{
|
||||
return !operator==(u);
|
||||
}
|
||||
|
||||
bool operator!=(const float f) const
|
||||
{
|
||||
return !operator==(f);
|
||||
@ -87,6 +159,8 @@ public:
|
||||
switch (type) {
|
||||
case EbtInt:
|
||||
return iConst > constant.iConst;
|
||||
case EbtUInt:
|
||||
return uConst > constant.uConst;
|
||||
case EbtFloat:
|
||||
return fConst > constant.fConst;
|
||||
default:
|
||||
@ -100,6 +174,8 @@ public:
|
||||
switch (type) {
|
||||
case EbtInt:
|
||||
return iConst < constant.iConst;
|
||||
case EbtUInt:
|
||||
return uConst < constant.uConst;
|
||||
case EbtFloat:
|
||||
return fConst < constant.fConst;
|
||||
default:
|
||||
@ -113,6 +189,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst + constant.uConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
@ -126,6 +203,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst - constant.uConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
@ -139,6 +217,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst * constant.uConst); break;
|
||||
case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
@ -152,6 +231,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst % constant.uConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
@ -164,6 +244,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst >> constant.uConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
@ -176,6 +257,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst << constant.uConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
@ -188,6 +270,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst & constant.uConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
@ -200,6 +283,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst | constant.uConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
@ -212,6 +296,7 @@ public:
|
||||
assert(type == constant.type);
|
||||
switch (type) {
|
||||
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
|
||||
case EbtUInt: returnValue.setUConst(uConst ^ constant.uConst); break;
|
||||
default: assert(false && "Default missing");
|
||||
}
|
||||
|
||||
@ -247,6 +332,7 @@ private:
|
||||
|
||||
union {
|
||||
int iConst; // used for ivec, scalar ints
|
||||
unsigned int uConst; // used for uvec, scalar uints
|
||||
bool bConst; // used for bvec, scalar bools
|
||||
float fConst; // used for vec, mat, scalar floats
|
||||
} ;
|
||||
|
@ -7,8 +7,6 @@
|
||||
#ifndef COMPILER_DETECT_RECURSION_H_
|
||||
#define COMPILER_DETECT_RECURSION_H_
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/VariableInfo.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -26,9 +26,11 @@ static TBehavior getBehavior(const std::string& str)
|
||||
}
|
||||
|
||||
TDirectiveHandler::TDirectiveHandler(TExtensionBehavior& extBehavior,
|
||||
TDiagnostics& diagnostics)
|
||||
TDiagnostics& diagnostics,
|
||||
int& shaderVersion)
|
||||
: mExtensionBehavior(extBehavior),
|
||||
mDiagnostics(diagnostics)
|
||||
mDiagnostics(diagnostics),
|
||||
mShaderVersion(shaderVersion)
|
||||
{
|
||||
}
|
||||
|
||||
@ -148,9 +150,12 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
|
||||
void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc,
|
||||
int version)
|
||||
{
|
||||
static const int kVersion = 100;
|
||||
|
||||
if (version != kVersion)
|
||||
if (version == 100 ||
|
||||
version == 300)
|
||||
{
|
||||
mShaderVersion = version;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << version;
|
||||
|
@ -17,7 +17,8 @@ class TDirectiveHandler : public pp::DirectiveHandler
|
||||
{
|
||||
public:
|
||||
TDirectiveHandler(TExtensionBehavior& extBehavior,
|
||||
TDiagnostics& diagnostics);
|
||||
TDiagnostics& diagnostics,
|
||||
int& shaderVersion);
|
||||
virtual ~TDirectiveHandler();
|
||||
|
||||
const TPragma& pragma() const { return mPragma; }
|
||||
@ -41,6 +42,7 @@ class TDirectiveHandler : public pp::DirectiveHandler
|
||||
TPragma mPragma;
|
||||
TExtensionBehavior& mExtensionBehavior;
|
||||
TDiagnostics& mDiagnostics;
|
||||
int& mShaderVersion;
|
||||
};
|
||||
|
||||
#endif // COMPILER_DIRECTIVE_HANDLER_H_
|
||||
|
77
src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.cpp
vendored
Normal file
77
src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.cpp
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/translator/FlagStd140Structs.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
bool FlagStd140Structs::visitBinary(Visit visit, TIntermBinary *binaryNode)
|
||||
{
|
||||
if (binaryNode->getRight()->getBasicType() == EbtStruct)
|
||||
{
|
||||
switch (binaryNode->getOp())
|
||||
{
|
||||
case EOpIndexDirectInterfaceBlock:
|
||||
case EOpIndexDirectStruct:
|
||||
if (isInStd140InterfaceBlock(binaryNode->getLeft()))
|
||||
{
|
||||
mFlaggedNodes.push_back(binaryNode);
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (binaryNode->getOp() == EOpIndexDirectStruct)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return visit == PreVisit;
|
||||
}
|
||||
|
||||
void FlagStd140Structs::visitSymbol(TIntermSymbol *symbol)
|
||||
{
|
||||
if (isInStd140InterfaceBlock(symbol) && symbol->getBasicType() == EbtStruct)
|
||||
{
|
||||
mFlaggedNodes.push_back(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
bool FlagStd140Structs::isInStd140InterfaceBlock(TIntermTyped *node) const
|
||||
{
|
||||
TIntermBinary *binaryNode = node->getAsBinaryNode();
|
||||
|
||||
if (binaryNode)
|
||||
{
|
||||
return isInStd140InterfaceBlock(binaryNode->getLeft());
|
||||
}
|
||||
|
||||
const TType &type = node->getType();
|
||||
|
||||
// determine if we are in the standard layout
|
||||
const TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
|
||||
if (interfaceBlock)
|
||||
{
|
||||
return (interfaceBlock->blockStorage() == EbsStd140);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<TIntermTyped *> FlagStd140ValueStructs(TIntermNode *node)
|
||||
{
|
||||
FlagStd140Structs flaggingTraversal;
|
||||
|
||||
node->traverse(&flaggingTraversal);
|
||||
|
||||
return flaggingTraversal.getFlaggedNodes();
|
||||
}
|
||||
|
||||
}
|
37
src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.h
vendored
Normal file
37
src/3rdparty/angle/src/compiler/translator/FlagStd140Structs.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_FLAGSTD140STRUCTS_H_
|
||||
#define COMPILER_FLAGSTD140STRUCTS_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
// This class finds references to nested structs of std140 blocks that access
|
||||
// the nested struct "by value", where the padding added in the translator
|
||||
// conflicts with the "natural" unpadded type.
|
||||
class FlagStd140Structs : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
const std::vector<TIntermTyped *> getFlaggedNodes() const { return mFlaggedNodes; }
|
||||
|
||||
protected:
|
||||
virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
|
||||
virtual void visitSymbol(TIntermSymbol *symbol);
|
||||
|
||||
private:
|
||||
bool isInStd140InterfaceBlock(TIntermTyped *node) const;
|
||||
|
||||
std::vector<TIntermTyped *> mFlaggedNodes;
|
||||
};
|
||||
|
||||
std::vector<TIntermTyped *> FlagStd140ValueStructs(TIntermNode *node);
|
||||
|
||||
}
|
||||
|
||||
#endif // COMPILER_FLAGSTD140STRUCTS_H_
|
@ -6,210 +6,77 @@
|
||||
|
||||
#include "compiler/translator/ForLoopUnroll.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class IntegerForLoopUnrollMarker : public TIntermTraverser {
|
||||
public:
|
||||
|
||||
virtual bool visitLoop(Visit, TIntermLoop* node)
|
||||
bool ForLoopUnrollMarker::visitBinary(Visit, TIntermBinary *node)
|
||||
{
|
||||
// This is called after ValidateLimitations pass, so all the ASSERT
|
||||
// should never fail.
|
||||
// See ValidateLimitations::validateForLoopInit().
|
||||
ASSERT(node);
|
||||
ASSERT(node->getType() == ELoopFor);
|
||||
ASSERT(node->getInit());
|
||||
TIntermAggregate* decl = node->getInit()->getAsAggregate();
|
||||
ASSERT(decl && decl->getOp() == EOpDeclaration);
|
||||
TIntermSequence& declSeq = decl->getSequence();
|
||||
ASSERT(declSeq.size() == 1);
|
||||
TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
|
||||
ASSERT(declInit && declInit->getOp() == EOpInitialize);
|
||||
ASSERT(declInit->getLeft());
|
||||
TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
|
||||
ASSERT(symbol);
|
||||
TBasicType type = symbol->getBasicType();
|
||||
ASSERT(type == EbtInt || type == EbtFloat);
|
||||
if (type == EbtInt)
|
||||
if (mUnrollCondition != kSamplerArrayIndex)
|
||||
return true;
|
||||
|
||||
// If a sampler array index is also the loop index,
|
||||
// 1) if the index type is integer, mark the loop for unrolling;
|
||||
// 2) if the index type if float, set a flag to later fail compile.
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpIndexIndirect:
|
||||
if (node->getLeft() != NULL && node->getRight() != NULL && node->getLeft()->getAsSymbolNode())
|
||||
{
|
||||
TIntermSymbol *symbol = node->getLeft()->getAsSymbolNode();
|
||||
if (IsSampler(symbol->getBasicType()) && symbol->isArray() && !mLoopStack.empty())
|
||||
{
|
||||
mVisitSamplerArrayIndexNodeInsideLoop = true;
|
||||
node->getRight()->traverse(this);
|
||||
mVisitSamplerArrayIndexNodeInsideLoop = false;
|
||||
// We have already visited all the children.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ForLoopUnrollMarker::visitLoop(Visit, TIntermLoop *node)
|
||||
{
|
||||
if (mUnrollCondition == kIntegerIndex)
|
||||
{
|
||||
// Check if loop index type is integer.
|
||||
// This is called after ValidateLimitations pass, so all the calls
|
||||
// should be valid. See ValidateLimitations::validateForLoopInit().
|
||||
TIntermSequence *declSeq = node->getInit()->getAsAggregate()->getSequence();
|
||||
TIntermSymbol *symbol = (*declSeq)[0]->getAsBinaryNode()->getLeft()->getAsSymbolNode();
|
||||
if (symbol->getBasicType() == EbtInt)
|
||||
node->setUnrollFlag(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // anonymous namepsace
|
||||
|
||||
void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info)
|
||||
TIntermNode *body = node->getBody();
|
||||
if (body != NULL)
|
||||
{
|
||||
ASSERT(node->getType() == ELoopFor);
|
||||
ASSERT(node->getUnrollFlag());
|
||||
|
||||
TIntermNode* init = node->getInit();
|
||||
ASSERT(init != NULL);
|
||||
TIntermAggregate* decl = init->getAsAggregate();
|
||||
ASSERT((decl != NULL) && (decl->getOp() == EOpDeclaration));
|
||||
TIntermSequence& declSeq = decl->getSequence();
|
||||
ASSERT(declSeq.size() == 1);
|
||||
TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
|
||||
ASSERT((declInit != NULL) && (declInit->getOp() == EOpInitialize));
|
||||
TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
|
||||
ASSERT(symbol != NULL);
|
||||
ASSERT(symbol->getBasicType() == EbtInt);
|
||||
|
||||
info.id = symbol->getId();
|
||||
|
||||
ASSERT(declInit->getRight() != NULL);
|
||||
TIntermConstantUnion* initNode = declInit->getRight()->getAsConstantUnion();
|
||||
ASSERT(initNode != NULL);
|
||||
|
||||
info.initValue = evaluateIntConstant(initNode);
|
||||
info.currentValue = info.initValue;
|
||||
|
||||
TIntermNode* cond = node->getCondition();
|
||||
ASSERT(cond != NULL);
|
||||
TIntermBinary* binOp = cond->getAsBinaryNode();
|
||||
ASSERT(binOp != NULL);
|
||||
ASSERT(binOp->getRight() != NULL);
|
||||
ASSERT(binOp->getRight()->getAsConstantUnion() != NULL);
|
||||
|
||||
info.incrementValue = getLoopIncrement(node);
|
||||
info.stopValue = evaluateIntConstant(
|
||||
binOp->getRight()->getAsConstantUnion());
|
||||
info.op = binOp->getOp();
|
||||
mLoopStack.push(node);
|
||||
body->traverse(this);
|
||||
mLoopStack.pop();
|
||||
}
|
||||
// The loop is fully processed - no need to visit children.
|
||||
return false;
|
||||
}
|
||||
|
||||
void ForLoopUnroll::Step()
|
||||
void ForLoopUnrollMarker::visitSymbol(TIntermSymbol* symbol)
|
||||
{
|
||||
ASSERT(mLoopIndexStack.size() > 0);
|
||||
TLoopIndexInfo& info = mLoopIndexStack[mLoopIndexStack.size() - 1];
|
||||
info.currentValue += info.incrementValue;
|
||||
}
|
||||
|
||||
bool ForLoopUnroll::SatisfiesLoopCondition()
|
||||
if (!mVisitSamplerArrayIndexNodeInsideLoop)
|
||||
return;
|
||||
TIntermLoop *loop = mLoopStack.findLoop(symbol);
|
||||
if (loop)
|
||||
{
|
||||
ASSERT(mLoopIndexStack.size() > 0);
|
||||
TLoopIndexInfo& info = mLoopIndexStack[mLoopIndexStack.size() - 1];
|
||||
// Relational operator is one of: > >= < <= == or !=.
|
||||
switch (info.op) {
|
||||
case EOpEqual:
|
||||
return (info.currentValue == info.stopValue);
|
||||
case EOpNotEqual:
|
||||
return (info.currentValue != info.stopValue);
|
||||
case EOpLessThan:
|
||||
return (info.currentValue < info.stopValue);
|
||||
case EOpGreaterThan:
|
||||
return (info.currentValue > info.stopValue);
|
||||
case EOpLessThanEqual:
|
||||
return (info.currentValue <= info.stopValue);
|
||||
case EOpGreaterThanEqual:
|
||||
return (info.currentValue >= info.stopValue);
|
||||
switch (symbol->getBasicType())
|
||||
{
|
||||
case EbtFloat:
|
||||
mSamplerArrayIndexIsFloatLoopIndex = true;
|
||||
break;
|
||||
case EbtInt:
|
||||
loop->setUnrollFlag(true);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ForLoopUnroll::NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol)
|
||||
{
|
||||
for (TVector<TLoopIndexInfo>::iterator i = mLoopIndexStack.begin();
|
||||
i != mLoopIndexStack.end();
|
||||
++i) {
|
||||
if (i->id == symbol->getId())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int ForLoopUnroll::GetLoopIndexValue(TIntermSymbol* symbol)
|
||||
{
|
||||
for (TVector<TLoopIndexInfo>::iterator i = mLoopIndexStack.begin();
|
||||
i != mLoopIndexStack.end();
|
||||
++i) {
|
||||
if (i->id == symbol->getId())
|
||||
return i->currentValue;
|
||||
}
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
|
||||
void ForLoopUnroll::Push(TLoopIndexInfo& info)
|
||||
{
|
||||
mLoopIndexStack.push_back(info);
|
||||
}
|
||||
|
||||
void ForLoopUnroll::Pop()
|
||||
{
|
||||
mLoopIndexStack.pop_back();
|
||||
}
|
||||
|
||||
// static
|
||||
void ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(
|
||||
TIntermNode* root)
|
||||
{
|
||||
ASSERT(root);
|
||||
|
||||
IntegerForLoopUnrollMarker marker;
|
||||
root->traverse(&marker);
|
||||
}
|
||||
|
||||
int ForLoopUnroll::getLoopIncrement(TIntermLoop* node)
|
||||
{
|
||||
TIntermNode* expr = node->getExpression();
|
||||
ASSERT(expr != NULL);
|
||||
// for expression has one of the following forms:
|
||||
// loop_index++
|
||||
// loop_index--
|
||||
// loop_index += constant_expression
|
||||
// loop_index -= constant_expression
|
||||
// ++loop_index
|
||||
// --loop_index
|
||||
// The last two forms are not specified in the spec, but I am assuming
|
||||
// its an oversight.
|
||||
TIntermUnary* unOp = expr->getAsUnaryNode();
|
||||
TIntermBinary* binOp = unOp ? NULL : expr->getAsBinaryNode();
|
||||
|
||||
TOperator op = EOpNull;
|
||||
TIntermConstantUnion* incrementNode = NULL;
|
||||
if (unOp != NULL) {
|
||||
op = unOp->getOp();
|
||||
} else if (binOp != NULL) {
|
||||
op = binOp->getOp();
|
||||
ASSERT(binOp->getRight() != NULL);
|
||||
incrementNode = binOp->getRight()->getAsConstantUnion();
|
||||
ASSERT(incrementNode != NULL);
|
||||
}
|
||||
|
||||
int increment = 0;
|
||||
// The operator is one of: ++ -- += -=.
|
||||
switch (op) {
|
||||
case EOpPostIncrement:
|
||||
case EOpPreIncrement:
|
||||
ASSERT((unOp != NULL) && (binOp == NULL));
|
||||
increment = 1;
|
||||
break;
|
||||
case EOpPostDecrement:
|
||||
case EOpPreDecrement:
|
||||
ASSERT((unOp != NULL) && (binOp == NULL));
|
||||
increment = -1;
|
||||
break;
|
||||
case EOpAddAssign:
|
||||
ASSERT((unOp == NULL) && (binOp != NULL));
|
||||
increment = evaluateIntConstant(incrementNode);
|
||||
break;
|
||||
case EOpSubAssign:
|
||||
ASSERT((unOp == NULL) && (binOp != NULL));
|
||||
increment = - evaluateIntConstant(incrementNode);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
return increment;
|
||||
}
|
||||
|
||||
int ForLoopUnroll::evaluateIntConstant(TIntermConstantUnion* node)
|
||||
{
|
||||
ASSERT((node != NULL) && (node->getUnionArrayPointer() != NULL));
|
||||
return node->getIConst(0);
|
||||
}
|
||||
|
||||
|
@ -7,46 +7,44 @@
|
||||
#ifndef COMPILER_FORLOOPUNROLL_H_
|
||||
#define COMPILER_FORLOOPUNROLL_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/LoopInfo.h"
|
||||
|
||||
struct TLoopIndexInfo {
|
||||
int id;
|
||||
int initValue;
|
||||
int stopValue;
|
||||
int incrementValue;
|
||||
TOperator op;
|
||||
int currentValue;
|
||||
// This class detects for-loops that needs to be unrolled.
|
||||
// Currently we support two unroll conditions:
|
||||
// 1) kForLoopWithIntegerIndex: unroll if the index type is integer.
|
||||
// 2) kForLoopWithSamplerArrayIndex: unroll where a sampler array index
|
||||
// is also the loop integer index, and reject and fail a compile
|
||||
// where a sampler array index is also the loop float index.
|
||||
class ForLoopUnrollMarker : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
enum UnrollCondition
|
||||
{
|
||||
kIntegerIndex,
|
||||
kSamplerArrayIndex
|
||||
};
|
||||
|
||||
class ForLoopUnroll {
|
||||
public:
|
||||
ForLoopUnroll() { }
|
||||
ForLoopUnrollMarker(UnrollCondition condition)
|
||||
: mUnrollCondition(condition),
|
||||
mSamplerArrayIndexIsFloatLoopIndex(false),
|
||||
mVisitSamplerArrayIndexNodeInsideLoop(false)
|
||||
{
|
||||
}
|
||||
|
||||
void FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info);
|
||||
virtual bool visitBinary(Visit, TIntermBinary *node);
|
||||
virtual bool visitLoop(Visit, TIntermLoop *node);
|
||||
virtual void visitSymbol(TIntermSymbol *node);
|
||||
|
||||
// Update the info.currentValue for the next loop iteration.
|
||||
void Step();
|
||||
|
||||
// Return false if loop condition is no longer satisfied.
|
||||
bool SatisfiesLoopCondition();
|
||||
|
||||
// Check if the symbol is the index of a loop that's unrolled.
|
||||
bool NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol);
|
||||
|
||||
// Return the current value of a given loop index symbol.
|
||||
int GetLoopIndexValue(TIntermSymbol* symbol);
|
||||
|
||||
void Push(TLoopIndexInfo& info);
|
||||
void Pop();
|
||||
|
||||
static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root);
|
||||
bool samplerArrayIndexIsFloatLoopIndex() const
|
||||
{
|
||||
return mSamplerArrayIndexIsFloatLoopIndex;
|
||||
}
|
||||
|
||||
private:
|
||||
int getLoopIncrement(TIntermLoop* node);
|
||||
|
||||
int evaluateIntConstant(TIntermConstantUnion* node);
|
||||
|
||||
TVector<TLoopIndexInfo> mLoopIndexStack;
|
||||
UnrollCondition mUnrollCondition;
|
||||
TLoopStack mLoopStack;
|
||||
bool mSamplerArrayIndexIsFloatLoopIndex;
|
||||
bool mVisitSamplerArrayIndexNodeInsideLoop;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <map>
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#define HASHED_NAME_PREFIX "webgl_"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,12 +8,12 @@
|
||||
#define _INITIALIZE_INCLUDED_
|
||||
|
||||
#include "compiler/translator/Common.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/Compiler.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table);
|
||||
void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table);
|
||||
|
||||
void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
|
||||
void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
|
||||
const ShBuiltInResources& resources,
|
||||
TSymbolTable& symbolTable);
|
||||
|
||||
|
@ -5,10 +5,12 @@
|
||||
//
|
||||
|
||||
#include "compiler/translator/InitializeDll.h"
|
||||
|
||||
#include "compiler/translator/InitializeGlobals.h"
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
#include "compiler/translator/osinclude.h"
|
||||
|
||||
#include "common/platform.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
bool InitProcess()
|
||||
{
|
||||
|
@ -6,35 +6,37 @@
|
||||
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
|
||||
#include "compiler/translator/osinclude.h"
|
||||
#include "common/tls.h"
|
||||
|
||||
OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
|
||||
#include <assert.h>
|
||||
|
||||
TLSIndex GlobalParseContextIndex = TLS_INVALID_INDEX;
|
||||
|
||||
bool InitializeParseContextIndex()
|
||||
{
|
||||
assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX);
|
||||
assert(GlobalParseContextIndex == TLS_INVALID_INDEX);
|
||||
|
||||
GlobalParseContextIndex = OS_AllocTLSIndex();
|
||||
return GlobalParseContextIndex != OS_INVALID_TLS_INDEX;
|
||||
GlobalParseContextIndex = CreateTLSIndex();
|
||||
return GlobalParseContextIndex != TLS_INVALID_INDEX;
|
||||
}
|
||||
|
||||
void FreeParseContextIndex()
|
||||
{
|
||||
assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
|
||||
assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
|
||||
|
||||
OS_FreeTLSIndex(GlobalParseContextIndex);
|
||||
GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
|
||||
DestroyTLSIndex(GlobalParseContextIndex);
|
||||
GlobalParseContextIndex = TLS_INVALID_INDEX;
|
||||
}
|
||||
|
||||
void SetGlobalParseContext(TParseContext* context)
|
||||
{
|
||||
assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
|
||||
OS_SetTLSValue(GlobalParseContextIndex, context);
|
||||
assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
|
||||
SetTLSValue(GlobalParseContextIndex, context);
|
||||
}
|
||||
|
||||
TParseContext* GetGlobalParseContext()
|
||||
{
|
||||
assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
|
||||
return static_cast<TParseContext*>(OS_GetTLSValue(GlobalParseContextIndex));
|
||||
assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
|
||||
return static_cast<TParseContext*>(GetTLSValue(GlobalParseContextIndex));
|
||||
}
|
||||
|
||||
|
@ -51,17 +51,17 @@ bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
ASSERT(visit == PreVisit);
|
||||
if (node->getName() == "main(")
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
|
||||
TIntermSequence *sequence = node->getSequence();
|
||||
ASSERT((sequence->size() == 1) || (sequence->size() == 2));
|
||||
TIntermAggregate *body = NULL;
|
||||
if (sequence.size() == 1)
|
||||
if (sequence->size() == 1)
|
||||
{
|
||||
body = new TIntermAggregate(EOpSequence);
|
||||
sequence.push_back(body);
|
||||
sequence->push_back(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
body = sequence[1]->getAsAggregate();
|
||||
body = (*sequence)[1]->getAsAggregate();
|
||||
}
|
||||
ASSERT(body);
|
||||
insertInitCode(body->getSequence());
|
||||
@ -76,7 +76,7 @@ bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
return visitChildren;
|
||||
}
|
||||
|
||||
void InitializeVariables::insertInitCode(TIntermSequence& sequence)
|
||||
void InitializeVariables::insertInitCode(TIntermSequence *sequence)
|
||||
{
|
||||
for (size_t ii = 0; ii < mVariables.size(); ++ii)
|
||||
{
|
||||
@ -87,7 +87,7 @@ void InitializeVariables::insertInitCode(TIntermSequence& sequence)
|
||||
for (int index = varInfo.type.getArraySize() - 1; index >= 0; --index)
|
||||
{
|
||||
TIntermBinary *assign = new TIntermBinary(EOpAssign);
|
||||
sequence.insert(sequence.begin(), assign);
|
||||
sequence->insert(sequence->begin(), assign);
|
||||
|
||||
TIntermBinary *indexDirect = new TIntermBinary(EOpIndexDirect);
|
||||
TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
|
||||
@ -104,7 +104,7 @@ void InitializeVariables::insertInitCode(TIntermSequence& sequence)
|
||||
else
|
||||
{
|
||||
TIntermBinary *assign = new TIntermBinary(EOpAssign);
|
||||
sequence.insert(sequence.begin(), assign);
|
||||
sequence->insert(sequence->begin(), assign);
|
||||
TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
|
||||
assign->setLeft(symbol);
|
||||
TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
|
||||
|
@ -32,16 +32,16 @@ class InitializeVariables : public TIntermTraverser
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool visitBinary(Visit visit, TIntermBinary* node) { return false; }
|
||||
virtual bool visitUnary(Visit visit, TIntermUnary* node) { return false; }
|
||||
virtual bool visitSelection(Visit visit, TIntermSelection* node) { return false; }
|
||||
virtual bool visitLoop(Visit visit, TIntermLoop* node) { return false; }
|
||||
virtual bool visitBranch(Visit visit, TIntermBranch* node) { return false; }
|
||||
virtual bool visitBinary(Visit, TIntermBinary *node) { return false; }
|
||||
virtual bool visitUnary(Visit, TIntermUnary *node) { return false; }
|
||||
virtual bool visitSelection(Visit, TIntermSelection *node) { return false; }
|
||||
virtual bool visitLoop(Visit, TIntermLoop *node) { return false; }
|
||||
virtual bool visitBranch(Visit, TIntermBranch *node) { return false; }
|
||||
|
||||
virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
|
||||
|
||||
private:
|
||||
void insertInitCode(TIntermSequence& sequence);
|
||||
void insertInitCode(TIntermSequence *sequence);
|
||||
|
||||
InitVariableInfoList mVariables;
|
||||
bool mCodeInserted;
|
||||
|
@ -55,25 +55,25 @@ void TIntermBinary::traverse(TIntermTraverser *it)
|
||||
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (right)
|
||||
right->traverse(it);
|
||||
if (mRight)
|
||||
mRight->traverse(it);
|
||||
|
||||
if (it->inVisit)
|
||||
visit = it->visitBinary(InVisit, this);
|
||||
|
||||
if (visit && left)
|
||||
left->traverse(it);
|
||||
if (visit && mLeft)
|
||||
mLeft->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left)
|
||||
left->traverse(it);
|
||||
if (mLeft)
|
||||
mLeft->traverse(it);
|
||||
|
||||
if (it->inVisit)
|
||||
visit = it->visitBinary(InVisit, this);
|
||||
|
||||
if (visit && right)
|
||||
right->traverse(it);
|
||||
if (visit && mRight)
|
||||
mRight->traverse(it);
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
@ -99,7 +99,7 @@ void TIntermUnary::traverse(TIntermTraverser *it)
|
||||
|
||||
if (visit) {
|
||||
it->incrementDepth(this);
|
||||
operand->traverse(it);
|
||||
mOperand->traverse(it);
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
@ -123,26 +123,28 @@ void TIntermAggregate::traverse(TIntermTraverser *it)
|
||||
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
for (TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++)
|
||||
for (TIntermSequence::reverse_iterator sit = mSequence.rbegin();
|
||||
sit != mSequence.rend(); sit++)
|
||||
{
|
||||
(*sit)->traverse(it);
|
||||
|
||||
if (visit && it->inVisit)
|
||||
{
|
||||
if (*sit != sequence.front())
|
||||
if (*sit != mSequence.front())
|
||||
visit = it->visitAggregate(InVisit, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
|
||||
for (TIntermSequence::iterator sit = mSequence.begin();
|
||||
sit != mSequence.end(); sit++)
|
||||
{
|
||||
(*sit)->traverse(it);
|
||||
|
||||
if (visit && it->inVisit)
|
||||
{
|
||||
if (*sit != sequence.back())
|
||||
if (*sit != mSequence.back())
|
||||
visit = it->visitAggregate(InVisit, this);
|
||||
}
|
||||
}
|
||||
@ -165,20 +167,24 @@ void TIntermSelection::traverse(TIntermTraverser *it)
|
||||
if (it->preVisit)
|
||||
visit = it->visitSelection(PreVisit, this);
|
||||
|
||||
if (visit) {
|
||||
if (visit)
|
||||
{
|
||||
it->incrementDepth(this);
|
||||
if (it->rightToLeft) {
|
||||
if (falseBlock)
|
||||
falseBlock->traverse(it);
|
||||
if (trueBlock)
|
||||
trueBlock->traverse(it);
|
||||
condition->traverse(it);
|
||||
} else {
|
||||
condition->traverse(it);
|
||||
if (trueBlock)
|
||||
trueBlock->traverse(it);
|
||||
if (falseBlock)
|
||||
falseBlock->traverse(it);
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (mFalseBlock)
|
||||
mFalseBlock->traverse(it);
|
||||
if (mTrueBlock)
|
||||
mTrueBlock->traverse(it);
|
||||
mCondition->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCondition->traverse(it);
|
||||
if (mTrueBlock)
|
||||
mTrueBlock->traverse(it);
|
||||
if (mFalseBlock)
|
||||
mFalseBlock->traverse(it);
|
||||
}
|
||||
it->decrementDepth();
|
||||
}
|
||||
@ -203,31 +209,31 @@ void TIntermLoop::traverse(TIntermTraverser *it)
|
||||
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (expr)
|
||||
expr->traverse(it);
|
||||
if (mExpr)
|
||||
mExpr->traverse(it);
|
||||
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
if (mBody)
|
||||
mBody->traverse(it);
|
||||
|
||||
if (cond)
|
||||
cond->traverse(it);
|
||||
if (mCond)
|
||||
mCond->traverse(it);
|
||||
|
||||
if (init)
|
||||
init->traverse(it);
|
||||
if (mInit)
|
||||
mInit->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (init)
|
||||
init->traverse(it);
|
||||
if (mInit)
|
||||
mInit->traverse(it);
|
||||
|
||||
if (cond)
|
||||
cond->traverse(it);
|
||||
if (mCond)
|
||||
mCond->traverse(it);
|
||||
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
if (mBody)
|
||||
mBody->traverse(it);
|
||||
|
||||
if (expr)
|
||||
expr->traverse(it);
|
||||
if (mExpr)
|
||||
mExpr->traverse(it);
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
@ -247,9 +253,9 @@ void TIntermBranch::traverse(TIntermTraverser *it)
|
||||
if (it->preVisit)
|
||||
visit = it->visitBranch(PreVisit, this);
|
||||
|
||||
if (visit && expression) {
|
||||
if (visit && mExpression) {
|
||||
it->incrementDepth(this);
|
||||
expression->traverse(it);
|
||||
mExpression->traverse(it);
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
@ -257,3 +263,7 @@ void TIntermBranch::traverse(TIntermTraverser *it)
|
||||
it->visitBranch(PostVisit, this);
|
||||
}
|
||||
|
||||
void TIntermRaw::traverse(TIntermTraverser *it)
|
||||
{
|
||||
it->visitRaw(this);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
211
src/3rdparty/angle/src/compiler/translator/LoopInfo.cpp
vendored
Normal file
211
src/3rdparty/angle/src/compiler/translator/LoopInfo.cpp
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
//
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/translator/LoopInfo.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
int EvaluateIntConstant(TIntermConstantUnion *node)
|
||||
{
|
||||
ASSERT(node && node->getUnionArrayPointer());
|
||||
return node->getIConst(0);
|
||||
}
|
||||
|
||||
int GetLoopIntIncrement(TIntermLoop *node)
|
||||
{
|
||||
TIntermNode *expr = node->getExpression();
|
||||
// for expression has one of the following forms:
|
||||
// loop_index++
|
||||
// loop_index--
|
||||
// loop_index += constant_expression
|
||||
// loop_index -= constant_expression
|
||||
// ++loop_index
|
||||
// --loop_index
|
||||
// The last two forms are not specified in the spec, but I am assuming
|
||||
// its an oversight.
|
||||
TIntermUnary *unOp = expr->getAsUnaryNode();
|
||||
TIntermBinary *binOp = unOp ? NULL : expr->getAsBinaryNode();
|
||||
|
||||
TOperator op = EOpNull;
|
||||
TIntermConstantUnion *incrementNode = NULL;
|
||||
if (unOp)
|
||||
{
|
||||
op = unOp->getOp();
|
||||
}
|
||||
else if (binOp)
|
||||
{
|
||||
op = binOp->getOp();
|
||||
ASSERT(binOp->getRight());
|
||||
incrementNode = binOp->getRight()->getAsConstantUnion();
|
||||
ASSERT(incrementNode);
|
||||
}
|
||||
|
||||
int increment = 0;
|
||||
// The operator is one of: ++ -- += -=.
|
||||
switch (op)
|
||||
{
|
||||
case EOpPostIncrement:
|
||||
case EOpPreIncrement:
|
||||
ASSERT(unOp && !binOp);
|
||||
increment = 1;
|
||||
break;
|
||||
case EOpPostDecrement:
|
||||
case EOpPreDecrement:
|
||||
ASSERT(unOp && !binOp);
|
||||
increment = -1;
|
||||
break;
|
||||
case EOpAddAssign:
|
||||
ASSERT(!unOp && binOp);
|
||||
increment = EvaluateIntConstant(incrementNode);
|
||||
break;
|
||||
case EOpSubAssign:
|
||||
ASSERT(!unOp && binOp);
|
||||
increment = - EvaluateIntConstant(incrementNode);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return increment;
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
TLoopIndexInfo::TLoopIndexInfo()
|
||||
: mId(-1),
|
||||
mType(EbtVoid),
|
||||
mInitValue(0),
|
||||
mStopValue(0),
|
||||
mIncrementValue(0),
|
||||
mOp(EOpNull),
|
||||
mCurrentValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
void TLoopIndexInfo::fillInfo(TIntermLoop *node)
|
||||
{
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
||||
// Here we assume all the operations are valid, because the loop node is
|
||||
// already validated in ValidateLimitations.
|
||||
TIntermSequence *declSeq =
|
||||
node->getInit()->getAsAggregate()->getSequence();
|
||||
TIntermBinary *declInit = (*declSeq)[0]->getAsBinaryNode();
|
||||
TIntermSymbol *symbol = declInit->getLeft()->getAsSymbolNode();
|
||||
|
||||
mId = symbol->getId();
|
||||
mType = symbol->getBasicType();
|
||||
|
||||
if (mType == EbtInt)
|
||||
{
|
||||
TIntermConstantUnion* initNode = declInit->getRight()->getAsConstantUnion();
|
||||
mInitValue = EvaluateIntConstant(initNode);
|
||||
mCurrentValue = mInitValue;
|
||||
mIncrementValue = GetLoopIntIncrement(node);
|
||||
|
||||
TIntermBinary* binOp = node->getCondition()->getAsBinaryNode();
|
||||
mStopValue = EvaluateIntConstant(
|
||||
binOp->getRight()->getAsConstantUnion());
|
||||
mOp = binOp->getOp();
|
||||
}
|
||||
}
|
||||
|
||||
bool TLoopIndexInfo::satisfiesLoopCondition() const
|
||||
{
|
||||
// Relational operator is one of: > >= < <= == or !=.
|
||||
switch (mOp)
|
||||
{
|
||||
case EOpEqual:
|
||||
return (mCurrentValue == mStopValue);
|
||||
case EOpNotEqual:
|
||||
return (mCurrentValue != mStopValue);
|
||||
case EOpLessThan:
|
||||
return (mCurrentValue < mStopValue);
|
||||
case EOpGreaterThan:
|
||||
return (mCurrentValue > mStopValue);
|
||||
case EOpLessThanEqual:
|
||||
return (mCurrentValue <= mStopValue);
|
||||
case EOpGreaterThanEqual:
|
||||
return (mCurrentValue >= mStopValue);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
TLoopInfo::TLoopInfo()
|
||||
: loop(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
TLoopInfo::TLoopInfo(TIntermLoop *node)
|
||||
: loop(node)
|
||||
{
|
||||
index.fillInfo(node);
|
||||
}
|
||||
|
||||
TIntermLoop *TLoopStack::findLoop(TIntermSymbol *symbol)
|
||||
{
|
||||
if (!symbol)
|
||||
return NULL;
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
if (iter->index.getId() == symbol->getId())
|
||||
return iter->loop;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TLoopIndexInfo *TLoopStack::getIndexInfo(TIntermSymbol *symbol)
|
||||
{
|
||||
if (!symbol)
|
||||
return NULL;
|
||||
for (iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
if (iter->index.getId() == symbol->getId())
|
||||
return &(iter->index);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TLoopStack::step()
|
||||
{
|
||||
ASSERT(!empty());
|
||||
rbegin()->index.step();
|
||||
}
|
||||
|
||||
bool TLoopStack::satisfiesLoopCondition()
|
||||
{
|
||||
ASSERT(!empty());
|
||||
return rbegin()->index.satisfiesLoopCondition();
|
||||
}
|
||||
|
||||
bool TLoopStack::needsToReplaceSymbolWithValue(TIntermSymbol *symbol)
|
||||
{
|
||||
TIntermLoop *loop = findLoop(symbol);
|
||||
return loop && loop->getUnrollFlag();
|
||||
}
|
||||
|
||||
int TLoopStack::getLoopIndexValue(TIntermSymbol *symbol)
|
||||
{
|
||||
TLoopIndexInfo *info = getIndexInfo(symbol);
|
||||
ASSERT(info);
|
||||
return info->getCurrentValue();
|
||||
}
|
||||
|
||||
void TLoopStack::push(TIntermLoop *loop)
|
||||
{
|
||||
TLoopInfo info(loop);
|
||||
push_back(info);
|
||||
}
|
||||
|
||||
void TLoopStack::pop()
|
||||
{
|
||||
pop_back();
|
||||
}
|
||||
|
80
src/3rdparty/angle/src/compiler/translator/LoopInfo.h
vendored
Normal file
80
src/3rdparty/angle/src/compiler/translator/LoopInfo.h
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
//
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_TRANSLATOR_LOOP_INFO_H_
|
||||
#define COMPILER_TRANSLATOR_LOOP_INFO_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
class TLoopIndexInfo
|
||||
{
|
||||
public:
|
||||
TLoopIndexInfo();
|
||||
|
||||
// If type is EbtInt, fill all fields of the structure with info
|
||||
// extracted from a loop node.
|
||||
// If type is not EbtInt, only fill id and type.
|
||||
void fillInfo(TIntermLoop *node);
|
||||
|
||||
int getId() const { return mId; }
|
||||
void setId(int id) { mId = id; }
|
||||
TBasicType getType() const { return mType; }
|
||||
void setType(TBasicType type) { mType = type; }
|
||||
int getCurrentValue() const { return mCurrentValue; }
|
||||
|
||||
void step() { mCurrentValue += mIncrementValue; }
|
||||
|
||||
// Check if the current value satisfies the loop condition.
|
||||
bool satisfiesLoopCondition() const;
|
||||
|
||||
private:
|
||||
int mId;
|
||||
TBasicType mType; // Either EbtInt or EbtFloat
|
||||
|
||||
// Below fields are only valid if the index's type is int.
|
||||
int mInitValue;
|
||||
int mStopValue;
|
||||
int mIncrementValue;
|
||||
TOperator mOp;
|
||||
int mCurrentValue;
|
||||
};
|
||||
|
||||
struct TLoopInfo
|
||||
{
|
||||
TLoopIndexInfo index;
|
||||
TIntermLoop *loop;
|
||||
|
||||
TLoopInfo();
|
||||
TLoopInfo(TIntermLoop *node);
|
||||
};
|
||||
|
||||
class TLoopStack : public TVector<TLoopInfo>
|
||||
{
|
||||
public:
|
||||
// Search loop stack for a loop whose index matches the input symbol.
|
||||
TIntermLoop *findLoop(TIntermSymbol *symbol);
|
||||
|
||||
// Find the loop index info in the loop stack by the input symbol.
|
||||
TLoopIndexInfo *getIndexInfo(TIntermSymbol *symbol);
|
||||
|
||||
// Update the currentValue for the next loop iteration.
|
||||
void step();
|
||||
|
||||
// Return false if loop condition is no longer satisfied.
|
||||
bool satisfiesLoopCondition();
|
||||
|
||||
// Check if the symbol is the index of a loop that's unrolled.
|
||||
bool needsToReplaceSymbolWithValue(TIntermSymbol *symbol);
|
||||
|
||||
// Return the current value of a given loop index symbol.
|
||||
int getLoopIndexValue(TIntermSymbol *symbol);
|
||||
|
||||
void push(TIntermLoop *info);
|
||||
void pop();
|
||||
};
|
||||
|
||||
#endif // COMPILER_TRANSLATOR_LOOP_INDEX_H_
|
||||
|
@ -1,115 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/translator/MapLongVariableNames.h"
|
||||
|
||||
namespace {
|
||||
|
||||
TString mapLongName(size_t id, const TString& name, bool isGlobal)
|
||||
{
|
||||
ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
|
||||
TStringStream stream;
|
||||
stream << "webgl_";
|
||||
if (isGlobal)
|
||||
stream << "g";
|
||||
stream << id;
|
||||
if (name[0] != '_')
|
||||
stream << "_";
|
||||
stream << name.substr(0, MAX_SHORTENED_IDENTIFIER_SIZE - stream.str().size());
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
LongNameMap* gLongNameMapInstance = NULL;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
LongNameMap::LongNameMap()
|
||||
: refCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
LongNameMap::~LongNameMap()
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
LongNameMap* LongNameMap::GetInstance()
|
||||
{
|
||||
if (gLongNameMapInstance == NULL)
|
||||
gLongNameMapInstance = new LongNameMap;
|
||||
gLongNameMapInstance->refCount++;
|
||||
return gLongNameMapInstance;
|
||||
}
|
||||
|
||||
void LongNameMap::Release()
|
||||
{
|
||||
ASSERT(gLongNameMapInstance == this);
|
||||
ASSERT(refCount > 0);
|
||||
refCount--;
|
||||
if (refCount == 0) {
|
||||
delete gLongNameMapInstance;
|
||||
gLongNameMapInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char* LongNameMap::Find(const char* originalName) const
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator it = mLongNameMap.find(
|
||||
originalName);
|
||||
if (it != mLongNameMap.end())
|
||||
return (*it).second.c_str();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LongNameMap::Insert(const char* originalName, const char* mappedName)
|
||||
{
|
||||
mLongNameMap.insert(std::map<std::string, std::string>::value_type(
|
||||
originalName, mappedName));
|
||||
}
|
||||
|
||||
size_t LongNameMap::Size() const
|
||||
{
|
||||
return mLongNameMap.size();
|
||||
}
|
||||
|
||||
MapLongVariableNames::MapLongVariableNames(LongNameMap* globalMap)
|
||||
{
|
||||
ASSERT(globalMap);
|
||||
mGlobalMap = globalMap;
|
||||
}
|
||||
|
||||
void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
|
||||
{
|
||||
ASSERT(symbol != NULL);
|
||||
if (symbol->getSymbol().size() > MAX_SHORTENED_IDENTIFIER_SIZE) {
|
||||
switch (symbol->getQualifier()) {
|
||||
case EvqVaryingIn:
|
||||
case EvqVaryingOut:
|
||||
case EvqInvariantVaryingIn:
|
||||
case EvqInvariantVaryingOut:
|
||||
case EvqUniform:
|
||||
symbol->setSymbol(
|
||||
mapGlobalLongName(symbol->getSymbol()));
|
||||
break;
|
||||
default:
|
||||
symbol->setSymbol(
|
||||
mapLongName(symbol->getId(), symbol->getSymbol(), false));
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
TString MapLongVariableNames::mapGlobalLongName(const TString& name)
|
||||
{
|
||||
ASSERT(mGlobalMap);
|
||||
const char* mappedName = mGlobalMap->Find(name.c_str());
|
||||
if (mappedName != NULL)
|
||||
return mappedName;
|
||||
size_t id = mGlobalMap->Size();
|
||||
TString rt = mapLongName(id, name, true);
|
||||
mGlobalMap->Insert(name.c_str(), rt.c_str());
|
||||
return rt;
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_MAP_LONG_VARIABLE_NAMES_H_
|
||||
#define COMPILER_MAP_LONG_VARIABLE_NAMES_H_
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/VariableInfo.h"
|
||||
|
||||
// This size does not include '\0' in the end.
|
||||
#define MAX_SHORTENED_IDENTIFIER_SIZE 32
|
||||
|
||||
// This is a ref-counted singleton. GetInstance() returns a pointer to the
|
||||
// singleton, and after use, call Release(). GetInstance() and Release() should
|
||||
// be paired.
|
||||
class LongNameMap {
|
||||
public:
|
||||
static LongNameMap* GetInstance();
|
||||
void Release();
|
||||
|
||||
// Return the mapped name if <originalName, mappedName> is in the map;
|
||||
// otherwise, return NULL.
|
||||
const char* Find(const char* originalName) const;
|
||||
|
||||
// Insert a pair into the map.
|
||||
void Insert(const char* originalName, const char* mappedName);
|
||||
|
||||
// Return the number of entries in the map.
|
||||
size_t Size() const;
|
||||
|
||||
private:
|
||||
LongNameMap();
|
||||
~LongNameMap();
|
||||
|
||||
size_t refCount;
|
||||
std::map<std::string, std::string> mLongNameMap;
|
||||
};
|
||||
|
||||
// Traverses intermediate tree to map attributes and uniforms names that are
|
||||
// longer than MAX_SHORTENED_IDENTIFIER_SIZE to MAX_SHORTENED_IDENTIFIER_SIZE.
|
||||
class MapLongVariableNames : public TIntermTraverser {
|
||||
public:
|
||||
MapLongVariableNames(LongNameMap* globalMap);
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol*);
|
||||
|
||||
private:
|
||||
TString mapGlobalLongName(const TString& name);
|
||||
|
||||
LongNameMap* mGlobalMap;
|
||||
};
|
||||
|
||||
#endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -10,8 +10,9 @@ TOutputESSL::TOutputESSL(TInfoSinkBase& objSink,
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable)
|
||||
: TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable)
|
||||
TSymbolTable& symbolTable,
|
||||
int shaderVersion)
|
||||
: TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable, shaderVersion)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -16,7 +16,8 @@ public:
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable);
|
||||
TSymbolTable& symbolTable,
|
||||
int shaderVersion);
|
||||
|
||||
protected:
|
||||
virtual bool writeVariablePrecision(TPrecision precision);
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -10,8 +10,9 @@ TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink,
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable)
|
||||
: TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable)
|
||||
TSymbolTable& symbolTable,
|
||||
int shaderVersion)
|
||||
: TOutputGLSLBase(objSink, clampingStrategy, hashFunction, nameMap, symbolTable, shaderVersion)
|
||||
{
|
||||
}
|
||||
|
||||
@ -33,3 +34,24 @@ void TOutputGLSL::visitSymbol(TIntermSymbol* node)
|
||||
TOutputGLSLBase::visitSymbol(node);
|
||||
}
|
||||
}
|
||||
|
||||
TString TOutputGLSL::translateTextureFunction(TString& name)
|
||||
{
|
||||
static const char *simpleRename[] = {
|
||||
"texture2DLodEXT", "texture2DLod",
|
||||
"texture2DProjLodEXT", "texture2DProjLod",
|
||||
"textureCubeLodEXT", "textureCubeLod",
|
||||
"texture2DGradEXT", "texture2DGradARB",
|
||||
"texture2DProjGradEXT", "texture2DProjGradARB",
|
||||
"textureCubeGradEXT", "textureCubeGradARB",
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
for (int i = 0; simpleRename[i] != NULL; i += 2) {
|
||||
if (name == simpleRename[i]) {
|
||||
return simpleRename[i+1];
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -16,11 +16,13 @@ public:
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap& nameMap,
|
||||
TSymbolTable& symbolTable);
|
||||
TSymbolTable& symbolTable,
|
||||
int shaderVersion);
|
||||
|
||||
protected:
|
||||
virtual bool writeVariablePrecision(TPrecision);
|
||||
virtual void visitSymbol(TIntermSymbol* node);
|
||||
virtual TString translateTextureFunction(TString& name);
|
||||
};
|
||||
|
||||
#endif // CROSSCOMPILERGLSL_OUTPUTGLSL_H_
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -19,7 +19,8 @@ TString arrayBrackets(const TType& type)
|
||||
return TString(out.c_str());
|
||||
}
|
||||
|
||||
bool isSingleStatement(TIntermNode* node) {
|
||||
bool isSingleStatement(TIntermNode *node)
|
||||
{
|
||||
if (const TIntermAggregate *aggregate = node->getAsAggregate())
|
||||
{
|
||||
return (aggregate->getOp() != EOpFunction) &&
|
||||
@ -43,32 +44,37 @@ TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink,
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap &nameMap,
|
||||
TSymbolTable& symbolTable)
|
||||
TSymbolTable &symbolTable,
|
||||
int shaderVersion)
|
||||
: TIntermTraverser(true, true, true),
|
||||
mObjSink(objSink),
|
||||
mDeclaringVariables(false),
|
||||
mClampingStrategy(clampingStrategy),
|
||||
mHashFunction(hashFunction),
|
||||
mNameMap(nameMap),
|
||||
mSymbolTable(symbolTable)
|
||||
mSymbolTable(symbolTable),
|
||||
mShaderVersion(shaderVersion)
|
||||
{
|
||||
}
|
||||
|
||||
void TOutputGLSLBase::writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr)
|
||||
void TOutputGLSLBase::writeTriplet(
|
||||
Visit visit, const char *preStr, const char *inStr, const char *postStr)
|
||||
{
|
||||
TInfoSinkBase &out = objSink();
|
||||
if (visit == PreVisit && preStr)
|
||||
{
|
||||
out << preStr;
|
||||
}
|
||||
else if (visit == InVisit && inStr)
|
||||
{
|
||||
out << inStr;
|
||||
}
|
||||
else if (visit == PostVisit && postStr)
|
||||
{
|
||||
out << postStr;
|
||||
}
|
||||
|
||||
void TOutputGLSLBase::writeBuiltInFunctionTriplet(
|
||||
Visit visit, const char *preStr, bool useEmulatedFunction)
|
||||
{
|
||||
TString preString = useEmulatedFunction ?
|
||||
BuiltInFunctionEmulator::GetEmulatedFunctionName(preStr) : preStr;
|
||||
writeTriplet(visit, preString.c_str(), ", ", ")");
|
||||
}
|
||||
|
||||
void TOutputGLSLBase::writeVariableType(const TType &type)
|
||||
@ -76,12 +82,19 @@ void TOutputGLSLBase::writeVariableType(const TType& type)
|
||||
TInfoSinkBase &out = objSink();
|
||||
TQualifier qualifier = type.getQualifier();
|
||||
// TODO(alokp): Validate qualifier for variable declarations.
|
||||
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
|
||||
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
|
||||
out << type.getQualifierString() << " ";
|
||||
// Declare the struct if we have not done so already.
|
||||
if ((type.getBasicType() == EbtStruct) && !structDeclared(type.getStruct()))
|
||||
if (type.getBasicType() == EbtStruct && !structDeclared(type.getStruct()))
|
||||
{
|
||||
declareStruct(type.getStruct());
|
||||
TStructure *structure = type.getStruct();
|
||||
|
||||
declareStruct(structure);
|
||||
|
||||
if (!structure->name().empty())
|
||||
{
|
||||
mDeclaredStructs.insert(structure->uniqueId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -115,8 +128,8 @@ void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence& args)
|
||||
}
|
||||
}
|
||||
|
||||
const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
|
||||
const ConstantUnion* pConstUnion)
|
||||
const ConstantUnion *TOutputGLSLBase::writeConstantUnion(
|
||||
const TType &type, const ConstantUnion *pConstUnion)
|
||||
{
|
||||
TInfoSinkBase &out = objSink();
|
||||
|
||||
@ -131,7 +144,8 @@ const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
|
||||
const TType *fieldType = fields[i]->type();
|
||||
ASSERT(fieldType != NULL);
|
||||
pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
|
||||
if (i != fields.size() - 1) out << ", ";
|
||||
if (i != fields.size() - 1)
|
||||
out << ", ";
|
||||
}
|
||||
out << ")";
|
||||
}
|
||||
@ -139,19 +153,28 @@ const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
|
||||
{
|
||||
size_t size = type.getObjectSize();
|
||||
bool writeType = size > 1;
|
||||
if (writeType) out << getTypeName(type) << "(";
|
||||
if (writeType)
|
||||
out << getTypeName(type) << "(";
|
||||
for (size_t i = 0; i < size; ++i, ++pConstUnion)
|
||||
{
|
||||
switch (pConstUnion->getType())
|
||||
{
|
||||
case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, pConstUnion->getFConst())); break;
|
||||
case EbtInt: out << pConstUnion->getIConst(); break;
|
||||
case EbtBool: out << pConstUnion->getBConst(); break;
|
||||
case EbtFloat:
|
||||
out << std::min(FLT_MAX, std::max(-FLT_MAX, pConstUnion->getFConst()));
|
||||
break;
|
||||
case EbtInt:
|
||||
out << pConstUnion->getIConst();
|
||||
break;
|
||||
case EbtBool:
|
||||
out << pConstUnion->getBConst();
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
if (i != size - 1) out << ", ";
|
||||
if (i != size - 1)
|
||||
out << ", ";
|
||||
}
|
||||
if (writeType) out << ")";
|
||||
if (writeType)
|
||||
out << ")";
|
||||
}
|
||||
return pConstUnion;
|
||||
}
|
||||
@ -159,8 +182,8 @@ const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
|
||||
void TOutputGLSLBase::visitSymbol(TIntermSymbol *node)
|
||||
{
|
||||
TInfoSinkBase &out = objSink();
|
||||
if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node))
|
||||
out << mLoopUnroll.GetLoopIndexValue(node);
|
||||
if (mLoopUnrollStack.needsToReplaceSymbolWithValue(node))
|
||||
out << mLoopUnrollStack.getLoopIndexValue(node);
|
||||
else
|
||||
out << hashVariableName(node->getSymbol());
|
||||
|
||||
@ -187,10 +210,18 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
mDeclaringVariables = false;
|
||||
}
|
||||
break;
|
||||
case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break;
|
||||
case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break;
|
||||
case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break;
|
||||
case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break;
|
||||
case EOpAssign:
|
||||
writeTriplet(visit, "(", " = ", ")");
|
||||
break;
|
||||
case EOpAddAssign:
|
||||
writeTriplet(visit, "(", " += ", ")");
|
||||
break;
|
||||
case EOpSubAssign:
|
||||
writeTriplet(visit, "(", " -= ", ")");
|
||||
break;
|
||||
case EOpDivAssign:
|
||||
writeTriplet(visit, "(", " /= ", ")");
|
||||
break;
|
||||
// Notice the fall-through.
|
||||
case EOpMulAssign:
|
||||
case EOpVectorTimesMatrixAssign:
|
||||
@ -208,12 +239,11 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
{
|
||||
if (visit == InVisit)
|
||||
{
|
||||
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC) {
|
||||
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC)
|
||||
out << "[int(clamp(float(";
|
||||
} else {
|
||||
else
|
||||
out << "[webgl_int_clamp(";
|
||||
}
|
||||
}
|
||||
else if (visit == PostVisit)
|
||||
{
|
||||
int maxSize;
|
||||
@ -230,13 +260,12 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
maxSize = leftType.getNominalSize() - 1;
|
||||
}
|
||||
|
||||
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC) {
|
||||
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC)
|
||||
out << "), 0.0, float(" << maxSize << ")))]";
|
||||
} else {
|
||||
else
|
||||
out << ", 0, " << maxSize << ")]";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writeTriplet(visit, NULL, "[", "]");
|
||||
@ -256,7 +285,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
const TField *field = structure->fields()[index->getIConst(0)];
|
||||
|
||||
TString fieldName = field->name();
|
||||
if (!mSymbolTable.findBuiltIn(structure->name()))
|
||||
if (!mSymbolTable.findBuiltIn(structure->name(), mShaderVersion))
|
||||
fieldName = hashName(fieldName);
|
||||
|
||||
out << fieldName;
|
||||
@ -268,8 +297,8 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
{
|
||||
out << ".";
|
||||
TIntermAggregate *rightChild = node->getRight()->getAsAggregate();
|
||||
TIntermSequence& sequence = rightChild->getSequence();
|
||||
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
|
||||
TIntermSequence *sequence = rightChild->getSequence();
|
||||
for (TIntermSequence::iterator sit = sequence->begin(); sit != sequence->end(); ++sit)
|
||||
{
|
||||
TIntermConstantUnion *element = (*sit)->getAsConstantUnion();
|
||||
ASSERT(element->getBasicType() == EbtInt);
|
||||
@ -278,28 +307,59 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
ASSERT(data.getType() == EbtInt);
|
||||
switch (data.getIConst())
|
||||
{
|
||||
case 0: out << "x"; break;
|
||||
case 1: out << "y"; break;
|
||||
case 2: out << "z"; break;
|
||||
case 3: out << "w"; break;
|
||||
default: UNREACHABLE(); break;
|
||||
case 0:
|
||||
out << "x";
|
||||
break;
|
||||
case 1:
|
||||
out << "y";
|
||||
break;
|
||||
case 2:
|
||||
out << "z";
|
||||
break;
|
||||
case 3:
|
||||
out << "w";
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
visitChildren = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break;
|
||||
case EOpSub: writeTriplet(visit, "(", " - ", ")"); break;
|
||||
case EOpMul: writeTriplet(visit, "(", " * ", ")"); break;
|
||||
case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break;
|
||||
case EOpMod: UNIMPLEMENTED(); break;
|
||||
case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break;
|
||||
case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break;
|
||||
case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break;
|
||||
case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break;
|
||||
case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break;
|
||||
case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break;
|
||||
case EOpAdd:
|
||||
writeTriplet(visit, "(", " + ", ")");
|
||||
break;
|
||||
case EOpSub:
|
||||
writeTriplet(visit, "(", " - ", ")");
|
||||
break;
|
||||
case EOpMul:
|
||||
writeTriplet(visit, "(", " * ", ")");
|
||||
break;
|
||||
case EOpDiv:
|
||||
writeTriplet(visit, "(", " / ", ")");
|
||||
break;
|
||||
case EOpMod:
|
||||
UNIMPLEMENTED();
|
||||
break;
|
||||
case EOpEqual:
|
||||
writeTriplet(visit, "(", " == ", ")");
|
||||
break;
|
||||
case EOpNotEqual:
|
||||
writeTriplet(visit, "(", " != ", ")");
|
||||
break;
|
||||
case EOpLessThan:
|
||||
writeTriplet(visit, "(", " < ", ")");
|
||||
break;
|
||||
case EOpGreaterThan:
|
||||
writeTriplet(visit, "(", " > ", ")");
|
||||
break;
|
||||
case EOpLessThanEqual:
|
||||
writeTriplet(visit, "(", " <= ", ")");
|
||||
break;
|
||||
case EOpGreaterThanEqual:
|
||||
writeTriplet(visit, "(", " >= ", ")");
|
||||
break;
|
||||
|
||||
// Notice the fall-through.
|
||||
case EOpVectorTimesScalar:
|
||||
@ -310,10 +370,17 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
|
||||
writeTriplet(visit, "(", " * ", ")");
|
||||
break;
|
||||
|
||||
case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break;
|
||||
case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break;
|
||||
case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break;
|
||||
default: UNREACHABLE(); break;
|
||||
case EOpLogicalOr:
|
||||
writeTriplet(visit, "(", " || ", ")");
|
||||
break;
|
||||
case EOpLogicalXor:
|
||||
writeTriplet(visit, "(", " ^^ ", ")");
|
||||
break;
|
||||
case EOpLogicalAnd:
|
||||
writeTriplet(visit, "(", " && ", ")");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return visitChildren;
|
||||
@ -335,73 +402,92 @@ bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary* node)
|
||||
case EOpPreIncrement: preString = "(++"; break;
|
||||
case EOpPreDecrement: preString = "(--"; break;
|
||||
|
||||
case EOpConvIntToBool:
|
||||
case EOpConvFloatToBool:
|
||||
switch (node->getOperand()->getType().getNominalSize())
|
||||
{
|
||||
case 1: preString = "bool("; break;
|
||||
case 2: preString = "bvec2("; break;
|
||||
case 3: preString = "bvec3("; break;
|
||||
case 4: preString = "bvec4("; break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
case EOpRadians:
|
||||
preString = "radians(";
|
||||
break;
|
||||
case EOpConvBoolToFloat:
|
||||
case EOpConvIntToFloat:
|
||||
switch (node->getOperand()->getType().getNominalSize())
|
||||
{
|
||||
case 1: preString = "float("; break;
|
||||
case 2: preString = "vec2("; break;
|
||||
case 3: preString = "vec3("; break;
|
||||
case 4: preString = "vec4("; break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
case EOpDegrees:
|
||||
preString = "degrees(";
|
||||
break;
|
||||
case EOpConvFloatToInt:
|
||||
case EOpConvBoolToInt:
|
||||
switch (node->getOperand()->getType().getNominalSize())
|
||||
{
|
||||
case 1: preString = "int("; break;
|
||||
case 2: preString = "ivec2("; break;
|
||||
case 3: preString = "ivec3("; break;
|
||||
case 4: preString = "ivec4("; break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
case EOpSin:
|
||||
preString = "sin(";
|
||||
break;
|
||||
case EOpCos:
|
||||
preString = "cos(";
|
||||
break;
|
||||
case EOpTan:
|
||||
preString = "tan(";
|
||||
break;
|
||||
case EOpAsin:
|
||||
preString = "asin(";
|
||||
break;
|
||||
case EOpAcos:
|
||||
preString = "acos(";
|
||||
break;
|
||||
case EOpAtan:
|
||||
preString = "atan(";
|
||||
break;
|
||||
|
||||
case EOpRadians: preString = "radians("; break;
|
||||
case EOpDegrees: preString = "degrees("; break;
|
||||
case EOpSin: preString = "sin("; break;
|
||||
case EOpCos: preString = "cos("; break;
|
||||
case EOpTan: preString = "tan("; break;
|
||||
case EOpAsin: preString = "asin("; break;
|
||||
case EOpAcos: preString = "acos("; break;
|
||||
case EOpAtan: preString = "atan("; break;
|
||||
case EOpExp:
|
||||
preString = "exp(";
|
||||
break;
|
||||
case EOpLog:
|
||||
preString = "log(";
|
||||
break;
|
||||
case EOpExp2:
|
||||
preString = "exp2(";
|
||||
break;
|
||||
case EOpLog2:
|
||||
preString = "log2(";
|
||||
break;
|
||||
case EOpSqrt:
|
||||
preString = "sqrt(";
|
||||
break;
|
||||
case EOpInverseSqrt:
|
||||
preString = "inversesqrt(";
|
||||
break;
|
||||
|
||||
case EOpExp: preString = "exp("; break;
|
||||
case EOpLog: preString = "log("; break;
|
||||
case EOpExp2: preString = "exp2("; break;
|
||||
case EOpLog2: preString = "log2("; break;
|
||||
case EOpSqrt: preString = "sqrt("; break;
|
||||
case EOpInverseSqrt: preString = "inversesqrt("; break;
|
||||
case EOpAbs:
|
||||
preString = "abs(";
|
||||
break;
|
||||
case EOpSign:
|
||||
preString = "sign(";
|
||||
break;
|
||||
case EOpFloor:
|
||||
preString = "floor(";
|
||||
break;
|
||||
case EOpCeil:
|
||||
preString = "ceil(";
|
||||
break;
|
||||
case EOpFract:
|
||||
preString = "fract(";
|
||||
break;
|
||||
|
||||
case EOpAbs: preString = "abs("; break;
|
||||
case EOpSign: preString = "sign("; break;
|
||||
case EOpFloor: preString = "floor("; break;
|
||||
case EOpCeil: preString = "ceil("; break;
|
||||
case EOpFract: preString = "fract("; break;
|
||||
case EOpLength:
|
||||
preString = "length(";
|
||||
break;
|
||||
case EOpNormalize:
|
||||
preString = "normalize(";
|
||||
break;
|
||||
|
||||
case EOpLength: preString = "length("; break;
|
||||
case EOpNormalize: preString = "normalize("; break;
|
||||
case EOpDFdx:
|
||||
preString = "dFdx(";
|
||||
break;
|
||||
case EOpDFdy:
|
||||
preString = "dFdy(";
|
||||
break;
|
||||
case EOpFwidth:
|
||||
preString = "fwidth(";
|
||||
break;
|
||||
|
||||
case EOpDFdx: preString = "dFdx("; break;
|
||||
case EOpDFdy: preString = "dFdy("; break;
|
||||
case EOpFwidth: preString = "fwidth("; break;
|
||||
case EOpAny:
|
||||
preString = "any(";
|
||||
break;
|
||||
case EOpAll:
|
||||
preString = "all(";
|
||||
break;
|
||||
|
||||
case EOpAny: preString = "any("; break;
|
||||
case EOpAll: preString = "all("; break;
|
||||
|
||||
default: UNREACHABLE(); break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
if (visit == PreVisit && node->getUseEmulatedFunction())
|
||||
@ -453,17 +539,19 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
bool visitChildren = true;
|
||||
TInfoSinkBase &out = objSink();
|
||||
TString preString;
|
||||
bool delayedWrite = false;
|
||||
bool useEmulatedFunction = (visit == PreVisit && node->getUseEmulatedFunction());
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence: {
|
||||
case EOpSequence:
|
||||
// Scope the sequences except when at the global scope.
|
||||
if (depth > 0) out << "{\n";
|
||||
if (mDepth > 0)
|
||||
{
|
||||
out << "{\n";
|
||||
}
|
||||
|
||||
incrementDepth(node);
|
||||
const TIntermSequence& sequence = node->getSequence();
|
||||
for (TIntermSequence::const_iterator iter = sequence.begin();
|
||||
iter != sequence.end(); ++iter)
|
||||
for (TIntermSequence::const_iterator iter = node->getSequence()->begin();
|
||||
iter != node->getSequence()->end(); ++iter)
|
||||
{
|
||||
TIntermNode *node = *iter;
|
||||
ASSERT(node != NULL);
|
||||
@ -475,23 +563,24 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
decrementDepth();
|
||||
|
||||
// Scope the sequences except when at the global scope.
|
||||
if (depth > 0) out << "}\n";
|
||||
if (mDepth > 0)
|
||||
{
|
||||
out << "}\n";
|
||||
}
|
||||
visitChildren = false;
|
||||
break;
|
||||
}
|
||||
case EOpPrototype: {
|
||||
case EOpPrototype:
|
||||
// Function declaration.
|
||||
ASSERT(visit == PreVisit);
|
||||
writeVariableType(node->getType());
|
||||
out << " " << hashName(node->getName());
|
||||
|
||||
out << "(";
|
||||
writeFunctionParameters(node->getSequence());
|
||||
writeFunctionParameters(*(node->getSequence()));
|
||||
out << ")";
|
||||
|
||||
visitChildren = false;
|
||||
break;
|
||||
}
|
||||
case EOpFunction: {
|
||||
// Function definition.
|
||||
ASSERT(visit == PreVisit);
|
||||
@ -502,7 +591,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
// Function definition node contains one or two children nodes
|
||||
// representing function parameters and function body. The latter
|
||||
// is not present in case of empty function bodies.
|
||||
const TIntermSequence& sequence = node->getSequence();
|
||||
const TIntermSequence &sequence = *(node->getSequence());
|
||||
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
|
||||
TIntermSequence::const_iterator seqIter = sequence.begin();
|
||||
|
||||
@ -525,32 +614,25 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
case EOpFunctionCall:
|
||||
// Function call.
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
out << hashFunctionName(node->getName()) << "(";
|
||||
}
|
||||
else if (visit == InVisit)
|
||||
{
|
||||
out << ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << ")";
|
||||
}
|
||||
break;
|
||||
case EOpParameters: {
|
||||
case EOpParameters:
|
||||
// Function parameters.
|
||||
ASSERT(visit == PreVisit);
|
||||
out << "(";
|
||||
writeFunctionParameters(node->getSequence());
|
||||
writeFunctionParameters(*(node->getSequence()));
|
||||
out << ")";
|
||||
visitChildren = false;
|
||||
break;
|
||||
}
|
||||
case EOpDeclaration: {
|
||||
case EOpDeclaration:
|
||||
// Variable declaration.
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
const TIntermSequence& sequence = node->getSequence();
|
||||
const TIntermSequence &sequence = *(node->getSequence());
|
||||
const TIntermTyped *variable = sequence.front()->getAsTyped();
|
||||
writeVariableType(variable->getType());
|
||||
out << " ";
|
||||
@ -566,22 +648,51 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
mDeclaringVariables = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EOpConstructFloat: writeTriplet(visit, "float(", NULL, ")"); break;
|
||||
case EOpConstructVec2: writeTriplet(visit, "vec2(", ", ", ")"); break;
|
||||
case EOpConstructVec3: writeTriplet(visit, "vec3(", ", ", ")"); break;
|
||||
case EOpConstructVec4: writeTriplet(visit, "vec4(", ", ", ")"); break;
|
||||
case EOpConstructBool: writeTriplet(visit, "bool(", NULL, ")"); break;
|
||||
case EOpConstructBVec2: writeTriplet(visit, "bvec2(", ", ", ")"); break;
|
||||
case EOpConstructBVec3: writeTriplet(visit, "bvec3(", ", ", ")"); break;
|
||||
case EOpConstructBVec4: writeTriplet(visit, "bvec4(", ", ", ")"); break;
|
||||
case EOpConstructInt: writeTriplet(visit, "int(", NULL, ")"); break;
|
||||
case EOpConstructIVec2: writeTriplet(visit, "ivec2(", ", ", ")"); break;
|
||||
case EOpConstructIVec3: writeTriplet(visit, "ivec3(", ", ", ")"); break;
|
||||
case EOpConstructIVec4: writeTriplet(visit, "ivec4(", ", ", ")"); break;
|
||||
case EOpConstructMat2: writeTriplet(visit, "mat2(", ", ", ")"); break;
|
||||
case EOpConstructMat3: writeTriplet(visit, "mat3(", ", ", ")"); break;
|
||||
case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break;
|
||||
case EOpConstructFloat:
|
||||
writeTriplet(visit, "float(", NULL, ")");
|
||||
break;
|
||||
case EOpConstructVec2:
|
||||
writeBuiltInFunctionTriplet(visit, "vec2(", false);
|
||||
break;
|
||||
case EOpConstructVec3:
|
||||
writeBuiltInFunctionTriplet(visit, "vec3(", false);
|
||||
break;
|
||||
case EOpConstructVec4:
|
||||
writeBuiltInFunctionTriplet(visit, "vec4(", false);
|
||||
break;
|
||||
case EOpConstructBool:
|
||||
writeTriplet(visit, "bool(", NULL, ")");
|
||||
break;
|
||||
case EOpConstructBVec2:
|
||||
writeBuiltInFunctionTriplet(visit, "bvec2(", false);
|
||||
break;
|
||||
case EOpConstructBVec3:
|
||||
writeBuiltInFunctionTriplet(visit, "bvec3(", false);
|
||||
break;
|
||||
case EOpConstructBVec4:
|
||||
writeBuiltInFunctionTriplet(visit, "bvec4(", false);
|
||||
break;
|
||||
case EOpConstructInt:
|
||||
writeTriplet(visit, "int(", NULL, ")");
|
||||
break;
|
||||
case EOpConstructIVec2:
|
||||
writeBuiltInFunctionTriplet(visit, "ivec2(", false);
|
||||
break;
|
||||
case EOpConstructIVec3:
|
||||
writeBuiltInFunctionTriplet(visit, "ivec3(", false);
|
||||
break;
|
||||
case EOpConstructIVec4:
|
||||
writeBuiltInFunctionTriplet(visit, "ivec4(", false);
|
||||
break;
|
||||
case EOpConstructMat2:
|
||||
writeBuiltInFunctionTriplet(visit, "mat2(", false);
|
||||
break;
|
||||
case EOpConstructMat3:
|
||||
writeBuiltInFunctionTriplet(visit, "mat3(", false);
|
||||
break;
|
||||
case EOpConstructMat4:
|
||||
writeBuiltInFunctionTriplet(visit, "mat4(", false);
|
||||
break;
|
||||
case EOpConstructStruct:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
@ -599,38 +710,80 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLessThan: preString = "lessThan("; delayedWrite = true; break;
|
||||
case EOpGreaterThan: preString = "greaterThan("; delayedWrite = true; break;
|
||||
case EOpLessThanEqual: preString = "lessThanEqual("; delayedWrite = true; break;
|
||||
case EOpGreaterThanEqual: preString = "greaterThanEqual("; delayedWrite = true; break;
|
||||
case EOpVectorEqual: preString = "equal("; delayedWrite = true; break;
|
||||
case EOpVectorNotEqual: preString = "notEqual("; delayedWrite = true; break;
|
||||
case EOpComma: writeTriplet(visit, NULL, ", ", NULL); break;
|
||||
case EOpLessThan:
|
||||
writeBuiltInFunctionTriplet(visit, "lessThan(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpGreaterThan:
|
||||
writeBuiltInFunctionTriplet(visit, "greaterThan(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpLessThanEqual:
|
||||
writeBuiltInFunctionTriplet(visit, "lessThanEqual(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpGreaterThanEqual:
|
||||
writeBuiltInFunctionTriplet(visit, "greaterThanEqual(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpVectorEqual:
|
||||
writeBuiltInFunctionTriplet(visit, "equal(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpVectorNotEqual:
|
||||
writeBuiltInFunctionTriplet(visit, "notEqual(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpComma:
|
||||
writeTriplet(visit, NULL, ", ", NULL);
|
||||
break;
|
||||
|
||||
case EOpMod: preString = "mod("; delayedWrite = true; break;
|
||||
case EOpPow: preString = "pow("; delayedWrite = true; break;
|
||||
case EOpAtan: preString = "atan("; delayedWrite = true; break;
|
||||
case EOpMin: preString = "min("; delayedWrite = true; break;
|
||||
case EOpMax: preString = "max("; delayedWrite = true; break;
|
||||
case EOpClamp: preString = "clamp("; delayedWrite = true; break;
|
||||
case EOpMix: preString = "mix("; delayedWrite = true; break;
|
||||
case EOpStep: preString = "step("; delayedWrite = true; break;
|
||||
case EOpSmoothStep: preString = "smoothstep("; delayedWrite = true; break;
|
||||
case EOpMod:
|
||||
writeBuiltInFunctionTriplet(visit, "mod(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpPow:
|
||||
writeBuiltInFunctionTriplet(visit, "pow(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpAtan:
|
||||
writeBuiltInFunctionTriplet(visit, "atan(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpMin:
|
||||
writeBuiltInFunctionTriplet(visit, "min(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpMax:
|
||||
writeBuiltInFunctionTriplet(visit, "max(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpClamp:
|
||||
writeBuiltInFunctionTriplet(visit, "clamp(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpMix:
|
||||
writeBuiltInFunctionTriplet(visit, "mix(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpStep:
|
||||
writeBuiltInFunctionTriplet(visit, "step(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpSmoothStep:
|
||||
writeBuiltInFunctionTriplet(visit, "smoothstep(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpDistance:
|
||||
writeBuiltInFunctionTriplet(visit, "distance(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpDot:
|
||||
writeBuiltInFunctionTriplet(visit, "dot(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpCross:
|
||||
writeBuiltInFunctionTriplet(visit, "cross(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpFaceForward:
|
||||
writeBuiltInFunctionTriplet(visit, "faceforward(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpReflect:
|
||||
writeBuiltInFunctionTriplet(visit, "reflect(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpRefract:
|
||||
writeBuiltInFunctionTriplet(visit, "refract(", useEmulatedFunction);
|
||||
break;
|
||||
case EOpMul:
|
||||
writeBuiltInFunctionTriplet(visit, "matrixCompMult(", useEmulatedFunction);
|
||||
break;
|
||||
|
||||
case EOpDistance: preString = "distance("; delayedWrite = true; break;
|
||||
case EOpDot: preString = "dot("; delayedWrite = true; break;
|
||||
case EOpCross: preString = "cross("; delayedWrite = true; break;
|
||||
case EOpFaceForward: preString = "faceforward("; delayedWrite = true; break;
|
||||
case EOpReflect: preString = "reflect("; delayedWrite = true; break;
|
||||
case EOpRefract: preString = "refract("; delayedWrite = true; break;
|
||||
case EOpMul: preString = "matrixCompMult("; delayedWrite = true; break;
|
||||
|
||||
default: UNREACHABLE(); break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
if (delayedWrite && visit == PreVisit && node->getUseEmulatedFunction())
|
||||
preString = BuiltInFunctionEmulator::GetEmulatedFunctionName(preString);
|
||||
if (delayedWrite)
|
||||
writeTriplet(visit, preString.c_str(), ", ", ")");
|
||||
return visitChildren;
|
||||
}
|
||||
|
||||
@ -643,7 +796,8 @@ bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node)
|
||||
TLoopType loopType = node->getType();
|
||||
if (loopType == ELoopFor) // for loop
|
||||
{
|
||||
if (!node->getUnrollFlag()) {
|
||||
if (!node->getUnrollFlag())
|
||||
{
|
||||
out << "for (";
|
||||
if (node->getInit())
|
||||
node->getInit()->traverse(this);
|
||||
@ -657,6 +811,18 @@ bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node)
|
||||
node->getExpression()->traverse(this);
|
||||
out << ")\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Need to put a one-iteration loop here to handle break.
|
||||
TIntermSequence *declSeq =
|
||||
node->getInit()->getAsAggregate()->getSequence();
|
||||
TIntermSymbol *indexSymbol =
|
||||
(*declSeq)[0]->getAsBinaryNode()->getLeft()->getAsSymbolNode();
|
||||
TString name = hashVariableName(indexSymbol->getSymbol());
|
||||
out << "for (int " << name << " = 0; "
|
||||
<< name << " < 1; "
|
||||
<< "++" << name << ")\n";
|
||||
}
|
||||
}
|
||||
else if (loopType == ELoopWhile) // while loop
|
||||
{
|
||||
@ -674,15 +840,15 @@ bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node)
|
||||
// Loop body.
|
||||
if (node->getUnrollFlag())
|
||||
{
|
||||
TLoopIndexInfo indexInfo;
|
||||
mLoopUnroll.FillLoopIndexInfo(node, indexInfo);
|
||||
mLoopUnroll.Push(indexInfo);
|
||||
while (mLoopUnroll.SatisfiesLoopCondition())
|
||||
out << "{\n";
|
||||
mLoopUnrollStack.push(node);
|
||||
while (mLoopUnrollStack.satisfiesLoopCondition())
|
||||
{
|
||||
visitCodeBlock(node->getBody());
|
||||
mLoopUnroll.Step();
|
||||
mLoopUnrollStack.step();
|
||||
}
|
||||
mLoopUnroll.Pop();
|
||||
mLoopUnrollStack.pop();
|
||||
out << "}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -708,17 +874,27 @@ bool TOutputGLSLBase::visitBranch(Visit visit, TIntermBranch* node)
|
||||
{
|
||||
switch (node->getFlowOp())
|
||||
{
|
||||
case EOpKill: writeTriplet(visit, "discard", NULL, NULL); break;
|
||||
case EOpBreak: writeTriplet(visit, "break", NULL, NULL); break;
|
||||
case EOpContinue: writeTriplet(visit, "continue", NULL, NULL); break;
|
||||
case EOpReturn: writeTriplet(visit, "return ", NULL, NULL); break;
|
||||
default: UNREACHABLE(); break;
|
||||
case EOpKill:
|
||||
writeTriplet(visit, "discard", NULL, NULL);
|
||||
break;
|
||||
case EOpBreak:
|
||||
writeTriplet(visit, "break", NULL, NULL);
|
||||
break;
|
||||
case EOpContinue:
|
||||
writeTriplet(visit, "continue", NULL, NULL);
|
||||
break;
|
||||
case EOpReturn:
|
||||
writeTriplet(visit, "return ", NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TOutputGLSLBase::visitCodeBlock(TIntermNode* node) {
|
||||
void TOutputGLSLBase::visitCodeBlock(TIntermNode *node)
|
||||
{
|
||||
TInfoSinkBase &out = objSink();
|
||||
if (node != NULL)
|
||||
{
|
||||
@ -746,10 +922,17 @@ TString TOutputGLSLBase::getTypeName(const TType& type)
|
||||
{
|
||||
switch (type.getBasicType())
|
||||
{
|
||||
case EbtFloat: out << "vec"; break;
|
||||
case EbtInt: out << "ivec"; break;
|
||||
case EbtBool: out << "bvec"; break;
|
||||
default: UNREACHABLE(); break;
|
||||
case EbtFloat:
|
||||
out << "vec";
|
||||
break;
|
||||
case EbtInt:
|
||||
out << "ivec";
|
||||
break;
|
||||
case EbtBool:
|
||||
out << "bvec";
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
out << type.getNominalSize();
|
||||
}
|
||||
@ -777,7 +960,7 @@ TString TOutputGLSLBase::hashName(const TString& name)
|
||||
|
||||
TString TOutputGLSLBase::hashVariableName(const TString &name)
|
||||
{
|
||||
if (mSymbolTable.findBuiltIn(name) != NULL)
|
||||
if (mSymbolTable.findBuiltIn(name, mShaderVersion) != NULL)
|
||||
return name;
|
||||
return hashName(name);
|
||||
}
|
||||
@ -785,14 +968,20 @@ TString TOutputGLSLBase::hashVariableName(const TString& name)
|
||||
TString TOutputGLSLBase::hashFunctionName(const TString &mangled_name)
|
||||
{
|
||||
TString name = TFunction::unmangleName(mangled_name);
|
||||
if (mSymbolTable.findBuiltIn(mangled_name) != NULL || name == "main")
|
||||
return name;
|
||||
if (mSymbolTable.findBuiltIn(mangled_name, mShaderVersion) != NULL || name == "main")
|
||||
return translateTextureFunction(name);
|
||||
return hashName(name);
|
||||
}
|
||||
|
||||
bool TOutputGLSLBase::structDeclared(const TStructure *structure) const
|
||||
{
|
||||
return mDeclaredStructs.find(structure->name()) != mDeclaredStructs.end();
|
||||
ASSERT(structure);
|
||||
if (structure->name().empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (mDeclaredStructs.count(structure->uniqueId()) > 0);
|
||||
}
|
||||
|
||||
void TOutputGLSLBase::declareStruct(const TStructure *structure)
|
||||
@ -812,6 +1001,5 @@ void TOutputGLSLBase::declareStruct(const TStructure* structure)
|
||||
out << ";\n";
|
||||
}
|
||||
out << "}";
|
||||
|
||||
mDeclaredStructs.insert(structure->name());
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -9,8 +9,8 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "compiler/translator/ForLoopUnroll.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/LoopInfo.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
|
||||
class TOutputGLSLBase : public TIntermTraverser
|
||||
@ -20,7 +20,8 @@ public:
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
||||
ShHashFunction64 hashFunction,
|
||||
NameMap &nameMap,
|
||||
TSymbolTable& symbolTable);
|
||||
TSymbolTable& symbolTable,
|
||||
int shaderVersion);
|
||||
|
||||
protected:
|
||||
TInfoSinkBase &objSink() { return mObjSink; }
|
||||
@ -42,7 +43,6 @@ protected:
|
||||
|
||||
void visitCodeBlock(TIntermNode *node);
|
||||
|
||||
|
||||
// Return the original name if hash function pointer is NULL;
|
||||
// otherwise return the hashed name.
|
||||
TString hashName(const TString &name);
|
||||
@ -50,21 +50,23 @@ protected:
|
||||
TString hashVariableName(const TString &name);
|
||||
// Same as hashName(), but without hashing built-in functions.
|
||||
TString hashFunctionName(const TString &mangled_name);
|
||||
// Used to translate function names for differences between ESSL and GLSL
|
||||
virtual TString translateTextureFunction(TString &name) { return name; }
|
||||
|
||||
private:
|
||||
bool structDeclared(const TStructure *structure) const;
|
||||
void declareStruct(const TStructure *structure);
|
||||
|
||||
void writeBuiltInFunctionTriplet(Visit visit, const char *preStr, bool useEmulatedFunction);
|
||||
|
||||
TInfoSinkBase &mObjSink;
|
||||
bool mDeclaringVariables;
|
||||
|
||||
// Structs are declared as the tree is traversed. This set contains all
|
||||
// the structs already declared. It is maintained so that a struct is
|
||||
// declared only once.
|
||||
typedef std::set<TString> DeclaredStructs;
|
||||
DeclaredStructs mDeclaredStructs;
|
||||
// This set contains all the ids of the structs from every scope.
|
||||
std::set<int> mDeclaredStructs;
|
||||
|
||||
ForLoopUnroll mLoopUnroll;
|
||||
// Stack of loops that need to be unrolled.
|
||||
TLoopStack mLoopUnrollStack;
|
||||
|
||||
ShArrayIndexClampingStrategy mClampingStrategy;
|
||||
|
||||
@ -74,6 +76,8 @@ private:
|
||||
NameMap &mNameMap;
|
||||
|
||||
TSymbolTable &mSymbolTable;
|
||||
|
||||
const int mShaderVersion;
|
||||
};
|
||||
|
||||
#endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -11,16 +11,18 @@
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#define GL_APICALL
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
#include "angle_gl.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
#include "compiler/translator/Uniform.h"
|
||||
#include "common/shadervars.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
class UnfoldShortCircuit;
|
||||
class StructureHLSL;
|
||||
class UniformHLSL;
|
||||
|
||||
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
|
||||
|
||||
class OutputHLSL : public TIntermTraverser
|
||||
{
|
||||
@ -31,22 +33,23 @@ class OutputHLSL : public TIntermTraverser
|
||||
void output();
|
||||
|
||||
TInfoSinkBase &getBodyStream();
|
||||
const ActiveUniforms &getUniforms();
|
||||
const std::vector<sh::Uniform> &getUniforms();
|
||||
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
|
||||
const std::vector<sh::Attribute> &getOutputVariables() const;
|
||||
const std::vector<sh::Attribute> &getAttributes() const;
|
||||
const std::vector<sh::Varying> &getVaryings() const;
|
||||
|
||||
const std::map<std::string, unsigned int> &getInterfaceBlockRegisterMap() const;
|
||||
const std::map<std::string, unsigned int> &getUniformRegisterMap() const;
|
||||
|
||||
TString typeString(const TType &type);
|
||||
TString textureString(const TType &type);
|
||||
static TString qualifierString(TQualifier qualifier);
|
||||
static TString arrayString(const TType &type);
|
||||
static TString initializer(const TType &type);
|
||||
static TString decorate(const TString &string); // Prepends an underscore to avoid naming clashes
|
||||
static TString decorateUniform(const TString &string, const TType &type);
|
||||
static TString decorateField(const TString &string, const TType &structure);
|
||||
|
||||
protected:
|
||||
void header();
|
||||
|
||||
// Visit AST nodes and output their code to the body stream
|
||||
void visitSymbol(TIntermSymbol*);
|
||||
void visitRaw(TIntermRaw*);
|
||||
void visitConstantUnion(TIntermConstantUnion*);
|
||||
bool visitBinary(Visit visit, TIntermBinary*);
|
||||
bool visitUnary(Visit visit, TIntermUnary*);
|
||||
@ -63,13 +66,9 @@ class OutputHLSL : public TIntermTraverser
|
||||
TString argumentString(const TIntermSymbol *symbol);
|
||||
int vectorSize(const TType &type) const;
|
||||
|
||||
void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters);
|
||||
void outputConstructor(Visit visit, const TType &type, const TString &name, const TIntermSequence *parameters);
|
||||
const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *constUnion);
|
||||
|
||||
TString scopeString(unsigned int depthLimit);
|
||||
TString scopedStruct(const TString &typeName);
|
||||
TString structLookup(const TString &typeName);
|
||||
|
||||
TParseContext &mContext;
|
||||
const ShShaderOutput mOutputType;
|
||||
UnfoldShortCircuit *mUnfoldShortCircuit;
|
||||
@ -80,27 +79,44 @@ class OutputHLSL : public TIntermTraverser
|
||||
TInfoSinkBase mBody;
|
||||
TInfoSinkBase mFooter;
|
||||
|
||||
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
|
||||
ReferencedSymbols mReferencedUniforms;
|
||||
ReferencedSymbols mReferencedInterfaceBlocks;
|
||||
ReferencedSymbols mReferencedAttributes;
|
||||
ReferencedSymbols mReferencedVaryings;
|
||||
ReferencedSymbols mReferencedOutputVariables;
|
||||
|
||||
StructureHLSL *mStructureHLSL;
|
||||
UniformHLSL *mUniformHLSL;
|
||||
|
||||
struct TextureFunction
|
||||
{
|
||||
enum Method
|
||||
{
|
||||
IMPLICIT, // Mipmap LOD determined implicitly (standard lookup)
|
||||
BIAS,
|
||||
LOD,
|
||||
LOD0,
|
||||
LOD0BIAS,
|
||||
SIZE, // textureSize()
|
||||
FETCH,
|
||||
GRAD
|
||||
};
|
||||
|
||||
TBasicType sampler;
|
||||
int coords;
|
||||
bool proj;
|
||||
bool offset;
|
||||
Method method;
|
||||
|
||||
TString name() const;
|
||||
|
||||
bool operator<(const TextureFunction &rhs) const;
|
||||
};
|
||||
|
||||
typedef std::set<TextureFunction> TextureFunctionSet;
|
||||
|
||||
// Parameters determining what goes in the header output
|
||||
bool mUsesTexture2D;
|
||||
bool mUsesTexture2D_bias;
|
||||
bool mUsesTexture2DLod;
|
||||
bool mUsesTexture2DProj;
|
||||
bool mUsesTexture2DProj_bias;
|
||||
bool mUsesTexture2DProjLod;
|
||||
bool mUsesTextureCube;
|
||||
bool mUsesTextureCube_bias;
|
||||
bool mUsesTextureCubeLod;
|
||||
bool mUsesTexture2DLod0;
|
||||
bool mUsesTexture2DLod0_bias;
|
||||
bool mUsesTexture2DProjLod0;
|
||||
bool mUsesTexture2DProjLod0_bias;
|
||||
bool mUsesTextureCubeLod0;
|
||||
bool mUsesTextureCubeLod0_bias;
|
||||
TextureFunctionSet mUsesTexture;
|
||||
bool mUsesFragColor;
|
||||
bool mUsesFragData;
|
||||
bool mUsesDepthRange;
|
||||
@ -126,42 +142,32 @@ class OutputHLSL : public TIntermTraverser
|
||||
bool mUsesAtan2_3;
|
||||
bool mUsesAtan2_4;
|
||||
bool mUsesDiscardRewriting;
|
||||
bool mUsesNestedBreak;
|
||||
|
||||
int mNumRenderTargets;
|
||||
|
||||
typedef std::set<TString> Constructors;
|
||||
Constructors mConstructors;
|
||||
|
||||
typedef std::set<TString> StructNames;
|
||||
StructNames mStructNames;
|
||||
|
||||
typedef std::list<TString> StructDeclarations;
|
||||
StructDeclarations mStructDeclarations;
|
||||
|
||||
typedef std::vector<int> ScopeBracket;
|
||||
ScopeBracket mScopeBracket;
|
||||
unsigned int mScopeDepth;
|
||||
|
||||
int mUniqueIndex; // For creating unique names
|
||||
|
||||
bool mContainsLoopDiscontinuity;
|
||||
bool mOutputLod0Function;
|
||||
bool mInsideDiscontinuousLoop;
|
||||
int mNestedLoopDepth;
|
||||
|
||||
TIntermSymbol *mExcessiveLoopIndex;
|
||||
|
||||
int mUniformRegister;
|
||||
int mSamplerRegister;
|
||||
void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<sh::Varying>& fieldsOut);
|
||||
|
||||
TString registerString(TIntermSymbol *operand);
|
||||
int samplerRegister(TIntermSymbol *sampler);
|
||||
int uniformRegister(TIntermSymbol *uniform);
|
||||
void declareUniform(const TType &type, const TString &name, int index);
|
||||
static GLenum glVariableType(const TType &type);
|
||||
static GLenum glVariablePrecision(const TType &type);
|
||||
TString structInitializerString(int indent, const TStructure &structure, const TString &rhsStructName);
|
||||
|
||||
ActiveUniforms mActiveUniforms;
|
||||
std::vector<sh::Attribute> mActiveOutputVariables;
|
||||
std::vector<sh::Attribute> mActiveAttributes;
|
||||
std::vector<sh::Varying> mActiveVaryings;
|
||||
std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
|
||||
std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;
|
||||
|
||||
void makeFlaggedStructMaps(const std::vector<TIntermTyped *> &flaggedStructs);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COMPILER_OUTPUTHLSL_H_
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,17 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
#ifndef _PARSER_HELPER_INCLUDED_
|
||||
#define _PARSER_HELPER_INCLUDED_
|
||||
|
||||
#include "compiler/translator/Compiler.h"
|
||||
#include "compiler/translator/Diagnostics.h"
|
||||
#include "compiler/translator/DirectiveHandler.h"
|
||||
#include "compiler/translator/localintermediate.h"
|
||||
#include "compiler/preprocessor/Preprocessor.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
#include "compiler/preprocessor/Preprocessor.h"
|
||||
|
||||
struct TMatrixFields {
|
||||
bool wholeRow;
|
||||
@ -25,7 +25,7 @@ struct TMatrixFields {
|
||||
// they can be passed to the parser without needing a global.
|
||||
//
|
||||
struct TParseContext {
|
||||
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
|
||||
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, sh::GLenum type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
|
||||
intermediate(interm),
|
||||
symbolTable(symt),
|
||||
shaderType(type),
|
||||
@ -38,14 +38,18 @@ struct TParseContext {
|
||||
currentFunctionType(NULL),
|
||||
functionReturnsValue(false),
|
||||
checksPrecisionErrors(checksPrecErrors),
|
||||
defaultMatrixPacking(EmpColumnMajor),
|
||||
defaultBlockStorage(EbsShared),
|
||||
diagnostics(is),
|
||||
directiveHandler(ext, diagnostics),
|
||||
shaderVersion(100),
|
||||
directiveHandler(ext, diagnostics, shaderVersion),
|
||||
preprocessor(&diagnostics, &directiveHandler),
|
||||
scanner(NULL) { }
|
||||
TIntermediate& intermediate; // to hold and build a parse tree
|
||||
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
|
||||
ShShaderType shaderType; // vertex or fragment language (future: pack or unpack)
|
||||
sh::GLenum shaderType; // vertex or fragment language (future: pack or unpack)
|
||||
ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
|
||||
int shaderVersion;
|
||||
int compileOptions;
|
||||
const char* sourcePath; // Path of source file or NULL.
|
||||
TIntermNode* treeRoot; // root of parse tree being created
|
||||
@ -55,12 +59,15 @@ struct TParseContext {
|
||||
bool functionReturnsValue; // true if a non-void function has a return
|
||||
bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
|
||||
bool fragmentPrecisionHigh; // true if highp precision is supported in the fragment language.
|
||||
TLayoutMatrixPacking defaultMatrixPacking;
|
||||
TLayoutBlockStorage defaultBlockStorage;
|
||||
TString HashErrMsg;
|
||||
TDiagnostics diagnostics;
|
||||
TDirectiveHandler directiveHandler;
|
||||
pp::Preprocessor preprocessor;
|
||||
void* scanner;
|
||||
|
||||
int getShaderVersion() const { return shaderVersion; }
|
||||
int numErrors() const { return diagnostics.numErrors(); }
|
||||
TInfoSink& infoSink() { return diagnostics.infoSink(); }
|
||||
void error(const TSourceLoc& loc, const char *reason, const char* token,
|
||||
@ -71,7 +78,7 @@ struct TParseContext {
|
||||
void recover();
|
||||
|
||||
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc& line);
|
||||
bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, const TSourceLoc& line);
|
||||
bool parseMatrixFields(const TString&, int matCols, int matRows, TMatrixFields&, const TSourceLoc& line);
|
||||
|
||||
bool reservedErrorCheck(const TSourceLoc& line, const TString& identifier);
|
||||
void assignError(const TSourceLoc& line, const char* op, TString left, TString right);
|
||||
@ -86,38 +93,64 @@ struct TParseContext {
|
||||
bool arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* expr, int& size);
|
||||
bool arrayQualifierErrorCheck(const TSourceLoc& line, TPublicType type);
|
||||
bool arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type);
|
||||
bool arrayErrorCheck(const TSourceLoc& line, TString& identifier, TPublicType type, TVariable*& variable);
|
||||
bool arrayErrorCheck(const TSourceLoc& line, const TString& identifier, const TPublicType &type, TVariable*& variable);
|
||||
bool voidErrorCheck(const TSourceLoc&, const TString&, const TPublicType&);
|
||||
bool boolErrorCheck(const TSourceLoc&, const TIntermTyped*);
|
||||
bool boolErrorCheck(const TSourceLoc&, const TPublicType&);
|
||||
bool samplerErrorCheck(const TSourceLoc& line, const TPublicType& pType, const char* reason);
|
||||
bool structQualifierErrorCheck(const TSourceLoc& line, const TPublicType& pType);
|
||||
bool locationDeclaratorListCheck(const TSourceLoc& line, const TPublicType &pType);
|
||||
bool parameterSamplerErrorCheck(const TSourceLoc& line, TQualifier qualifier, const TType& type);
|
||||
bool nonInitConstErrorCheck(const TSourceLoc& line, TString& identifier, TPublicType& type, bool array);
|
||||
bool nonInitErrorCheck(const TSourceLoc& line, TString& identifier, TPublicType& type, TVariable*& variable);
|
||||
bool nonInitConstErrorCheck(const TSourceLoc& line, const TString& identifier, TPublicType& type, bool array);
|
||||
bool nonInitErrorCheck(const TSourceLoc& line, const TString& identifier, const TPublicType& type, TVariable*& variable);
|
||||
bool paramErrorCheck(const TSourceLoc& line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
|
||||
bool extensionErrorCheck(const TSourceLoc& line, const TString&);
|
||||
bool singleDeclarationErrorCheck(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier);
|
||||
bool layoutLocationErrorCheck(const TSourceLoc& location, const TLayoutQualifier &layoutQualifier);
|
||||
|
||||
const TPragma& pragma() const { return directiveHandler.pragma(); }
|
||||
const TExtensionBehavior& extensionBehavior() const { return directiveHandler.extensionBehavior(); }
|
||||
bool supportsExtension(const char* extension);
|
||||
bool isExtensionEnabled(const char* extension) const;
|
||||
void handleExtensionDirective(const TSourceLoc& loc, const char* extName, const char* behavior);
|
||||
void handlePragmaDirective(const TSourceLoc& loc, const char* name, const char* value);
|
||||
|
||||
bool containsSampler(TType& type);
|
||||
bool areAllChildConst(TIntermAggregate* aggrNode);
|
||||
const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, bool *builtIn = 0);
|
||||
bool executeInitializer(const TSourceLoc& line, TString& identifier, TPublicType& pType,
|
||||
const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int shaderVersion, bool *builtIn = 0);
|
||||
bool executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType,
|
||||
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
|
||||
|
||||
TPublicType addFullySpecifiedType(TQualifier qualifier, const TPublicType& typeSpecifier);
|
||||
TPublicType addFullySpecifiedType(TQualifier qualifier, TLayoutQualifier layoutQualifier, const TPublicType& typeSpecifier);
|
||||
TIntermAggregate* parseSingleDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier);
|
||||
TIntermAggregate* parseSingleArrayDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& indexLocation, TIntermTyped *indexExpression);
|
||||
TIntermAggregate* parseSingleInitDeclaration(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& initLocation, TIntermTyped *initializer);
|
||||
TIntermAggregate* parseDeclarator(TPublicType &publicType, TIntermAggregate *aggregateDeclaration, TSymbol *identifierSymbol, const TSourceLoc& identifierLocation, const TString &identifier);
|
||||
TIntermAggregate* parseArrayDeclarator(TPublicType &publicType, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& arrayLocation, TIntermNode *declaratorList, TIntermTyped *indexExpression);
|
||||
TIntermAggregate* parseInitDeclarator(TPublicType &publicType, TIntermAggregate *declaratorList, const TSourceLoc& identifierLocation, const TString &identifier, const TSourceLoc& initLocation, TIntermTyped *initializer);
|
||||
void parseGlobalLayoutQualifier(const TPublicType &typeQualifier);
|
||||
TFunction *addConstructorFunc(TPublicType publicType);
|
||||
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&);
|
||||
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
|
||||
TIntermTyped* constructStruct(TIntermNode*, TType*, int, const TSourceLoc&, bool subset);
|
||||
TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, const TSourceLoc&, bool subset);
|
||||
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&);
|
||||
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&);
|
||||
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line);
|
||||
TIntermTyped* addConstStruct(TString& , TIntermTyped*, const TSourceLoc&);
|
||||
TIntermTyped* addConstStruct(const TString &identifier, TIntermTyped *node, const TSourceLoc& line);
|
||||
TIntermTyped* addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc& location, TIntermTyped *indexExpression);
|
||||
TIntermTyped* addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc& dotLocation, const TString &fieldString, const TSourceLoc& fieldLocation);
|
||||
|
||||
TFieldList *addStructDeclaratorList(const TPublicType& typeSpecifier, TFieldList *fieldList);
|
||||
TPublicType addStructure(const TSourceLoc& structLine, const TSourceLoc& nameLine, const TString *structName, TFieldList* fieldList);
|
||||
|
||||
TIntermAggregate* addInterfaceBlock(const TPublicType& typeQualifier, const TSourceLoc& nameLine, const TString& blockName, TFieldList* fieldList,
|
||||
const TString* instanceName, const TSourceLoc& instanceLine, TIntermTyped* arrayIndex, const TSourceLoc& arrayIndexLine);
|
||||
|
||||
TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine);
|
||||
TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc& intValueLine);
|
||||
TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier);
|
||||
TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier,
|
||||
const TSourceLoc &storageLoc, TQualifier storageQualifier);
|
||||
|
||||
// Performs an error check for embedded struct declarations.
|
||||
// Returns true if an error was raised due to the declaration of
|
||||
|
@ -6,43 +6,44 @@
|
||||
|
||||
#include "compiler/translator/PoolAlloc.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/angleutils.h"
|
||||
#include "compiler/translator/InitializeGlobals.h"
|
||||
#include "compiler/translator/osinclude.h"
|
||||
|
||||
OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX;
|
||||
#include "common/platform.h"
|
||||
#include "common/angleutils.h"
|
||||
#include "common/tls.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
TLSIndex PoolIndex = TLS_INVALID_INDEX;
|
||||
|
||||
bool InitializePoolIndex()
|
||||
{
|
||||
assert(PoolIndex == OS_INVALID_TLS_INDEX);
|
||||
assert(PoolIndex == TLS_INVALID_INDEX);
|
||||
|
||||
PoolIndex = OS_AllocTLSIndex();
|
||||
return PoolIndex != OS_INVALID_TLS_INDEX;
|
||||
PoolIndex = CreateTLSIndex();
|
||||
return PoolIndex != TLS_INVALID_INDEX;
|
||||
}
|
||||
|
||||
void FreePoolIndex()
|
||||
{
|
||||
assert(PoolIndex != OS_INVALID_TLS_INDEX);
|
||||
assert(PoolIndex != TLS_INVALID_INDEX);
|
||||
|
||||
OS_FreeTLSIndex(PoolIndex);
|
||||
PoolIndex = OS_INVALID_TLS_INDEX;
|
||||
DestroyTLSIndex(PoolIndex);
|
||||
PoolIndex = TLS_INVALID_INDEX;
|
||||
}
|
||||
|
||||
TPoolAllocator* GetGlobalPoolAllocator()
|
||||
{
|
||||
assert(PoolIndex != OS_INVALID_TLS_INDEX);
|
||||
return static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex));
|
||||
assert(PoolIndex != TLS_INVALID_INDEX);
|
||||
return static_cast<TPoolAllocator*>(GetTLSValue(PoolIndex));
|
||||
}
|
||||
|
||||
void SetGlobalPoolAllocator(TPoolAllocator* poolAllocator)
|
||||
{
|
||||
assert(PoolIndex != OS_INVALID_TLS_INDEX);
|
||||
OS_SetTLSValue(PoolIndex, poolAllocator);
|
||||
assert(PoolIndex != TLS_INVALID_INDEX);
|
||||
SetTLSValue(PoolIndex, poolAllocator);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -8,70 +8,22 @@
|
||||
#include "compiler/translator/RemoveTree.h"
|
||||
|
||||
//
|
||||
// Code to recursively delete the intermediate tree.
|
||||
//
|
||||
|
||||
class RemoveTree : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
RemoveTree() : TIntermTraverser(false, false, true)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void visitSymbol(TIntermSymbol*);
|
||||
void visitConstantUnion(TIntermConstantUnion*);
|
||||
bool visitBinary(Visit visit, TIntermBinary*);
|
||||
bool visitUnary(Visit visit, TIntermUnary*);
|
||||
bool visitSelection(Visit visit, TIntermSelection*);
|
||||
bool visitAggregate(Visit visit, TIntermAggregate*);
|
||||
};
|
||||
|
||||
void RemoveTree::visitSymbol(TIntermSymbol* node)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node)
|
||||
{
|
||||
delete node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoveTree::visitConstantUnion(TIntermConstantUnion* node)
|
||||
{
|
||||
delete node;
|
||||
}
|
||||
|
||||
//
|
||||
// Entry point.
|
||||
// Code to delete the intermediate tree.
|
||||
//
|
||||
void RemoveAllTreeNodes(TIntermNode* root)
|
||||
{
|
||||
RemoveTree it;
|
||||
std::queue<TIntermNode*> nodeQueue;
|
||||
|
||||
root->traverse(&it);
|
||||
nodeQueue.push(root);
|
||||
|
||||
while (!nodeQueue.empty())
|
||||
{
|
||||
TIntermNode *node = nodeQueue.front();
|
||||
nodeQueue.pop();
|
||||
|
||||
node->enqueueChildren(&nodeQueue);
|
||||
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,24 @@
|
||||
namespace sh
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class ElseBlockRewriter : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
ElseBlockRewriter();
|
||||
|
||||
protected:
|
||||
bool visitAggregate(Visit visit, TIntermAggregate *aggregate);
|
||||
|
||||
private:
|
||||
int mTemporaryIndex;
|
||||
const TType *mFunctionType;
|
||||
|
||||
TIntermNode *rewriteSelection(TIntermSelection *selection);
|
||||
};
|
||||
|
||||
TIntermSymbol *MakeNewTemporary(const TString &name, TBasicType type)
|
||||
{
|
||||
TType variableType(type, EbpHigh, EvqInternal);
|
||||
@ -36,25 +54,45 @@ TIntermUnary *MakeNewUnary(TOperator op, TIntermTyped *operand)
|
||||
return unary;
|
||||
}
|
||||
|
||||
ElseBlockRewriter::ElseBlockRewriter()
|
||||
: TIntermTraverser(true, false, true, false),
|
||||
mTemporaryIndex(0),
|
||||
mFunctionType(NULL)
|
||||
{}
|
||||
|
||||
bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence:
|
||||
if (visit == PostVisit)
|
||||
{
|
||||
for (size_t statementIndex = 0; statementIndex != node->getSequence().size(); statementIndex++)
|
||||
for (size_t statementIndex = 0; statementIndex != node->getSequence()->size(); statementIndex++)
|
||||
{
|
||||
TIntermNode *statement = node->getSequence()[statementIndex];
|
||||
TIntermNode *statement = (*node->getSequence())[statementIndex];
|
||||
TIntermSelection *selection = statement->getAsSelectionNode();
|
||||
if (selection && selection->getFalseBlock() != NULL)
|
||||
{
|
||||
node->getSequence()[statementIndex] = rewriteSelection(selection);
|
||||
// Check for if / else if
|
||||
TIntermSelection *elseIfBranch = selection->getFalseBlock()->getAsSelectionNode();
|
||||
if (elseIfBranch)
|
||||
{
|
||||
selection->replaceChildNode(elseIfBranch, rewriteSelection(elseIfBranch));
|
||||
delete elseIfBranch;
|
||||
}
|
||||
|
||||
(*node->getSequence())[statementIndex] = rewriteSelection(selection);
|
||||
delete selection;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpFunction:
|
||||
// Store the current function context (see comment below)
|
||||
mFunctionType = ((visit == PreVisit) ? &node->getType() : NULL);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
@ -63,32 +101,54 @@ bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
|
||||
|
||||
TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection)
|
||||
{
|
||||
ASSERT(selection->getFalseBlock() != NULL);
|
||||
ASSERT(selection != NULL);
|
||||
|
||||
TString temporaryName = "cond_" + str(mTemporaryIndex++);
|
||||
TIntermTyped *typedCondition = selection->getCondition()->getAsTyped();
|
||||
TType resultType(EbtBool, EbpUndefined);
|
||||
TIntermSymbol *conditionSymbolA = MakeNewTemporary(temporaryName, EbtBool);
|
||||
TIntermSymbol *conditionSymbolB = MakeNewTemporary(temporaryName, EbtBool);
|
||||
TIntermSymbol *conditionSymbolC = MakeNewTemporary(temporaryName, EbtBool);
|
||||
TIntermBinary *storeCondition = MakeNewBinary(EOpInitialize, conditionSymbolA,
|
||||
TIntermSymbol *conditionSymbolInit = MakeNewTemporary(temporaryName, EbtBool);
|
||||
TIntermBinary *storeCondition = MakeNewBinary(EOpInitialize, conditionSymbolInit,
|
||||
typedCondition, resultType);
|
||||
TIntermUnary *negatedCondition = MakeNewUnary(EOpLogicalNot, conditionSymbolB);
|
||||
TIntermSelection *falseBlock = new TIntermSelection(negatedCondition,
|
||||
selection->getFalseBlock(), NULL);
|
||||
TIntermSelection *newIfElse = new TIntermSelection(conditionSymbolC,
|
||||
TIntermNode *negatedElse = NULL;
|
||||
|
||||
TIntermSelection *falseBlock = NULL;
|
||||
|
||||
if (selection->getFalseBlock())
|
||||
{
|
||||
// crbug.com/346463
|
||||
// D3D generates error messages claiming a function has no return value, when rewriting
|
||||
// an if-else clause that returns something non-void in a function. By appending dummy
|
||||
// returns (that are unreachable) we can silence this compile error.
|
||||
if (mFunctionType && mFunctionType->getBasicType() != EbtVoid)
|
||||
{
|
||||
TString typeString = mFunctionType->getStruct() ? mFunctionType->getStruct()->name() :
|
||||
mFunctionType->getBasicString();
|
||||
TString rawText = "return (" + typeString + ")0";
|
||||
negatedElse = new TIntermRaw(*mFunctionType, rawText);
|
||||
}
|
||||
|
||||
TIntermSymbol *conditionSymbolElse = MakeNewTemporary(temporaryName, EbtBool);
|
||||
TIntermUnary *negatedCondition = MakeNewUnary(EOpLogicalNot, conditionSymbolElse);
|
||||
falseBlock = new TIntermSelection(negatedCondition,
|
||||
selection->getFalseBlock(), negatedElse);
|
||||
}
|
||||
|
||||
TIntermSymbol *conditionSymbolSel = MakeNewTemporary(temporaryName, EbtBool);
|
||||
TIntermSelection *newSelection = new TIntermSelection(conditionSymbolSel,
|
||||
selection->getTrueBlock(), falseBlock);
|
||||
|
||||
TIntermAggregate *declaration = new TIntermAggregate(EOpDeclaration);
|
||||
declaration->getSequence().push_back(storeCondition);
|
||||
declaration->getSequence()->push_back(storeCondition);
|
||||
|
||||
TIntermAggregate *block = new TIntermAggregate(EOpSequence);
|
||||
block->getSequence().push_back(declaration);
|
||||
block->getSequence().push_back(newIfElse);
|
||||
block->getSequence()->push_back(declaration);
|
||||
block->getSequence()->push_back(newSelection);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RewriteElseBlocks(TIntermNode *node)
|
||||
{
|
||||
ElseBlockRewriter rewriter;
|
||||
|
@ -15,23 +15,6 @@
|
||||
namespace sh
|
||||
{
|
||||
|
||||
class ElseBlockRewriter : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
ElseBlockRewriter()
|
||||
: TIntermTraverser(false, false, true, false)
|
||||
, mTemporaryIndex(0)
|
||||
{}
|
||||
|
||||
protected:
|
||||
bool visitAggregate(Visit visit, TIntermAggregate *aggregate);
|
||||
|
||||
private:
|
||||
int mTemporaryIndex;
|
||||
|
||||
TIntermNode *rewriteSelection(TIntermSelection *selection);
|
||||
};
|
||||
|
||||
void RewriteElseBlocks(TIntermNode *node);
|
||||
|
||||
}
|
||||
|
266
src/3rdparty/angle/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
vendored
Normal file
266
src/3rdparty/angle/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
//
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "common/angleutils.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool ContainsMatrixNode(const TIntermSequence &sequence)
|
||||
{
|
||||
for (size_t ii = 0; ii < sequence.size(); ++ii)
|
||||
{
|
||||
TIntermTyped *node = sequence[ii]->getAsTyped();
|
||||
if (node && node->isMatrix())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContainsVectorNode(const TIntermSequence &sequence)
|
||||
{
|
||||
for (size_t ii = 0; ii < sequence.size(); ++ii)
|
||||
{
|
||||
TIntermTyped *node = sequence[ii]->getAsTyped();
|
||||
if (node && node->isVector())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TIntermConstantUnion *ConstructIndexNode(int index)
|
||||
{
|
||||
ConstantUnion *u = new ConstantUnion[1];
|
||||
u[0].setIConst(index);
|
||||
|
||||
TType type(EbtInt, EbpUndefined, EvqConst, 1);
|
||||
TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
|
||||
return node;
|
||||
}
|
||||
|
||||
TIntermBinary *ConstructVectorIndexBinaryNode(TIntermSymbol *symbolNode, int index)
|
||||
{
|
||||
TIntermBinary *binary = new TIntermBinary(EOpIndexDirect);
|
||||
binary->setLeft(symbolNode);
|
||||
TIntermConstantUnion *indexNode = ConstructIndexNode(index);
|
||||
binary->setRight(indexNode);
|
||||
return binary;
|
||||
}
|
||||
|
||||
TIntermBinary *ConstructMatrixIndexBinaryNode(
|
||||
TIntermSymbol *symbolNode, int colIndex, int rowIndex)
|
||||
{
|
||||
TIntermBinary *colVectorNode =
|
||||
ConstructVectorIndexBinaryNode(symbolNode, colIndex);
|
||||
|
||||
TIntermBinary *binary = new TIntermBinary(EOpIndexDirect);
|
||||
binary->setLeft(colVectorNode);
|
||||
TIntermConstantUnion *rowIndexNode = ConstructIndexNode(rowIndex);
|
||||
binary->setRight(rowIndexNode);
|
||||
return binary;
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
bool ScalarizeVecAndMatConstructorArgs::visitAggregate(Visit visit, TIntermAggregate *node)
|
||||
{
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence:
|
||||
mSequenceStack.push_back(TIntermSequence());
|
||||
{
|
||||
for (TIntermSequence::const_iterator iter = node->getSequence()->begin();
|
||||
iter != node->getSequence()->end(); ++iter)
|
||||
{
|
||||
TIntermNode *child = *iter;
|
||||
ASSERT(child != NULL);
|
||||
child->traverse(this);
|
||||
mSequenceStack.back().push_back(child);
|
||||
}
|
||||
}
|
||||
if (mSequenceStack.back().size() > node->getSequence()->size())
|
||||
{
|
||||
node->getSequence()->clear();
|
||||
*(node->getSequence()) = mSequenceStack.back();
|
||||
}
|
||||
mSequenceStack.pop_back();
|
||||
return false;
|
||||
case EOpConstructVec2:
|
||||
case EOpConstructVec3:
|
||||
case EOpConstructVec4:
|
||||
case EOpConstructBVec2:
|
||||
case EOpConstructBVec3:
|
||||
case EOpConstructBVec4:
|
||||
case EOpConstructIVec2:
|
||||
case EOpConstructIVec3:
|
||||
case EOpConstructIVec4:
|
||||
if (ContainsMatrixNode(*(node->getSequence())))
|
||||
scalarizeArgs(node, false, true);
|
||||
break;
|
||||
case EOpConstructMat2:
|
||||
case EOpConstructMat3:
|
||||
case EOpConstructMat4:
|
||||
if (ContainsVectorNode(*(node->getSequence())))
|
||||
scalarizeArgs(node, true, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScalarizeVecAndMatConstructorArgs::scalarizeArgs(
|
||||
TIntermAggregate *aggregate, bool scalarizeVector, bool scalarizeMatrix)
|
||||
{
|
||||
ASSERT(aggregate);
|
||||
int size = 0;
|
||||
switch (aggregate->getOp())
|
||||
{
|
||||
case EOpConstructVec2:
|
||||
case EOpConstructBVec2:
|
||||
case EOpConstructIVec2:
|
||||
size = 2;
|
||||
break;
|
||||
case EOpConstructVec3:
|
||||
case EOpConstructBVec3:
|
||||
case EOpConstructIVec3:
|
||||
size = 3;
|
||||
break;
|
||||
case EOpConstructVec4:
|
||||
case EOpConstructBVec4:
|
||||
case EOpConstructIVec4:
|
||||
case EOpConstructMat2:
|
||||
size = 4;
|
||||
break;
|
||||
case EOpConstructMat3:
|
||||
size = 9;
|
||||
break;
|
||||
case EOpConstructMat4:
|
||||
size = 16;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TIntermSequence *sequence = aggregate->getSequence();
|
||||
TIntermSequence original(*sequence);
|
||||
sequence->clear();
|
||||
for (size_t ii = 0; ii < original.size(); ++ii)
|
||||
{
|
||||
ASSERT(size > 0);
|
||||
TIntermTyped *node = original[ii]->getAsTyped();
|
||||
ASSERT(node);
|
||||
TString varName = createTempVariable(node);
|
||||
if (node->isScalar())
|
||||
{
|
||||
TIntermSymbol *symbolNode =
|
||||
new TIntermSymbol(-1, varName, node->getType());
|
||||
sequence->push_back(symbolNode);
|
||||
size--;
|
||||
}
|
||||
else if (node->isVector())
|
||||
{
|
||||
if (scalarizeVector)
|
||||
{
|
||||
int repeat = std::min(size, node->getNominalSize());
|
||||
size -= repeat;
|
||||
for (int index = 0; index < repeat; ++index)
|
||||
{
|
||||
TIntermSymbol *symbolNode =
|
||||
new TIntermSymbol(-1, varName, node->getType());
|
||||
TIntermBinary *newNode = ConstructVectorIndexBinaryNode(
|
||||
symbolNode, index);
|
||||
sequence->push_back(newNode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TIntermSymbol *symbolNode =
|
||||
new TIntermSymbol(-1, varName, node->getType());
|
||||
sequence->push_back(symbolNode);
|
||||
size -= node->getNominalSize();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(node->isMatrix());
|
||||
if (scalarizeMatrix)
|
||||
{
|
||||
int colIndex = 0, rowIndex = 0;
|
||||
int repeat = std::min(size, node->getCols() * node->getRows());
|
||||
size -= repeat;
|
||||
while (repeat > 0)
|
||||
{
|
||||
TIntermSymbol *symbolNode =
|
||||
new TIntermSymbol(-1, varName, node->getType());
|
||||
TIntermBinary *newNode = ConstructMatrixIndexBinaryNode(
|
||||
symbolNode, colIndex, rowIndex);
|
||||
sequence->push_back(newNode);
|
||||
rowIndex++;
|
||||
if (rowIndex >= node->getRows())
|
||||
{
|
||||
rowIndex = 0;
|
||||
colIndex++;
|
||||
}
|
||||
repeat--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TIntermSymbol *symbolNode =
|
||||
new TIntermSymbol(-1, varName, node->getType());
|
||||
sequence->push_back(symbolNode);
|
||||
size -= node->getCols() * node->getRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TString ScalarizeVecAndMatConstructorArgs::createTempVariable(TIntermTyped *original)
|
||||
{
|
||||
TString tempVarName = "_webgl_tmp_";
|
||||
if (original->isScalar())
|
||||
{
|
||||
tempVarName += "scalar_";
|
||||
}
|
||||
else if (original->isVector())
|
||||
{
|
||||
tempVarName += "vec_";
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(original->isMatrix());
|
||||
tempVarName += "mat_";
|
||||
}
|
||||
tempVarName += Str(mTempVarCount).c_str();
|
||||
mTempVarCount++;
|
||||
|
||||
ASSERT(original);
|
||||
TType type = original->getType();
|
||||
type.setQualifier(EvqTemporary);
|
||||
|
||||
TIntermBinary *init = new TIntermBinary(EOpInitialize);
|
||||
TIntermSymbol *symbolNode = new TIntermSymbol(-1, tempVarName, type);
|
||||
init->setLeft(symbolNode);
|
||||
init->setRight(original);
|
||||
init->setType(type);
|
||||
|
||||
TIntermAggregate *decl = new TIntermAggregate(EOpDeclaration);
|
||||
decl->getSequence()->push_back(init);
|
||||
|
||||
ASSERT(mSequenceStack.size() > 0);
|
||||
TIntermSequence &sequence = mSequenceStack.back();
|
||||
sequence.push_back(decl);
|
||||
|
||||
return tempVarName;
|
||||
}
|
41
src/3rdparty/angle/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.h
vendored
Normal file
41
src/3rdparty/angle/src/compiler/translator/ScalarizeVecAndMatConstructorArgs.h
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_
|
||||
#define COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
ScalarizeVecAndMatConstructorArgs()
|
||||
: mTempVarCount(0) {}
|
||||
|
||||
protected:
|
||||
virtual bool visitAggregate(Visit visit, TIntermAggregate *node);
|
||||
|
||||
private:
|
||||
void scalarizeArgs(TIntermAggregate *aggregate,
|
||||
bool scalarizeVector, bool scalarizeMatrix);
|
||||
|
||||
// If we have the following code:
|
||||
// mat4 m(0);
|
||||
// vec4 v(1, m);
|
||||
// We will rewrite to:
|
||||
// mat4 m(0);
|
||||
// mat4 _webgl_tmp_mat_0 = m;
|
||||
// vec4 v(1, _webgl_tmp_mat_0[0][0], _webgl_tmp_mat_0[0][1], _webgl_tmp_mat_0[0][2]);
|
||||
// This function is to create nodes for "mat4 _webgl_tmp_mat_0 = m;" and insert it to
|
||||
// the code sequence.
|
||||
// Return the temporary variable name.
|
||||
TString createTempVariable(TIntermTyped *original);
|
||||
|
||||
std::vector<TIntermSequence> mSequenceStack;
|
||||
int mTempVarCount;
|
||||
};
|
||||
|
||||
#endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -11,11 +11,14 @@
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/translator/Compiler.h"
|
||||
#include "compiler/translator/InitializeDll.h"
|
||||
#include "compiler/preprocessor/length_limits.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/length_limits.h"
|
||||
#include "compiler/translator/TranslatorHLSL.h"
|
||||
#include "compiler/translator/VariablePacker.h"
|
||||
#include "angle_gl.h"
|
||||
|
||||
static bool isInitialized = false;
|
||||
|
||||
//
|
||||
// This is the platform independent interface between an OGL driver
|
||||
@ -43,22 +46,74 @@ static bool checkMappedNameMaxLength(const ShHandle handle, size_t expectedValue
|
||||
return (expectedValue == mappedNameMaxLength);
|
||||
}
|
||||
|
||||
template <typename VarT>
|
||||
static const sh::ShaderVariable *ReturnVariable(const std::vector<VarT> &infoList, int index)
|
||||
{
|
||||
if (index < 0 || static_cast<size_t>(index) >= infoList.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &infoList[index];
|
||||
}
|
||||
|
||||
static const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShaderInfo varType, int index)
|
||||
{
|
||||
switch (varType)
|
||||
{
|
||||
case SH_ACTIVE_ATTRIBUTES:
|
||||
return ReturnVariable(compiler->getAttributes(), index);
|
||||
case SH_ACTIVE_UNIFORMS:
|
||||
return ReturnVariable(compiler->getExpandedUniforms(), index);
|
||||
case SH_VARYINGS:
|
||||
return ReturnVariable(compiler->getExpandedVaryings(), index);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static ShPrecisionType ConvertPrecision(sh::GLenum precision)
|
||||
{
|
||||
switch (precision)
|
||||
{
|
||||
case GL_HIGH_FLOAT:
|
||||
case GL_HIGH_INT:
|
||||
return SH_PRECISION_HIGHP;
|
||||
case GL_MEDIUM_FLOAT:
|
||||
case GL_MEDIUM_INT:
|
||||
return SH_PRECISION_MEDIUMP;
|
||||
case GL_LOW_FLOAT:
|
||||
case GL_LOW_INT:
|
||||
return SH_PRECISION_LOWP;
|
||||
default:
|
||||
return SH_PRECISION_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Driver must call this first, once, before doing any other compiler operations.
|
||||
// Subsequent calls to this function are no-op.
|
||||
//
|
||||
int ShInitialize()
|
||||
{
|
||||
static const bool kInitialized = InitProcess();
|
||||
return kInitialized ? 1 : 0;
|
||||
if (!isInitialized)
|
||||
{
|
||||
isInitialized = InitProcess();
|
||||
}
|
||||
return isInitialized ? 1 : 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup symbol tables
|
||||
//
|
||||
int ShFinalize()
|
||||
{
|
||||
if (isInitialized)
|
||||
{
|
||||
DetachProcess();
|
||||
isInitialized = false;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -83,10 +138,17 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
|
||||
resources->ARB_texture_rectangle = 0;
|
||||
resources->EXT_draw_buffers = 0;
|
||||
resources->EXT_frag_depth = 0;
|
||||
resources->EXT_shader_texture_lod = 0;
|
||||
|
||||
// Disable highp precision in fragment shader by default.
|
||||
resources->FragmentPrecisionHigh = 0;
|
||||
|
||||
// GLSL ES 3.0 constants.
|
||||
resources->MaxVertexOutputVectors = 16;
|
||||
resources->MaxFragmentInputVectors = 15;
|
||||
resources->MinProgramTexelOffset = -8;
|
||||
resources->MaxProgramTexelOffset = 7;
|
||||
|
||||
// Disable name hashing by default.
|
||||
resources->HashFunction = NULL;
|
||||
|
||||
@ -99,7 +161,7 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
|
||||
//
|
||||
// Driver calls these to create and destroy compiler objects.
|
||||
//
|
||||
ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
|
||||
ShHandle ShConstructCompiler(sh::GLenum type, ShShaderSpec spec,
|
||||
ShShaderOutput output,
|
||||
const ShBuiltInResources* resources)
|
||||
{
|
||||
@ -128,6 +190,23 @@ void ShDestruct(ShHandle handle)
|
||||
DeleteCompiler(base->getAsCompiler());
|
||||
}
|
||||
|
||||
void ShGetBuiltInResourcesString(const ShHandle handle, size_t outStringLen, char *outString)
|
||||
{
|
||||
if (!handle || !outString)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TShHandleBase *base = static_cast<TShHandleBase*>(handle);
|
||||
TCompiler *compiler = base->getAsCompiler();
|
||||
if (!compiler)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(outString, compiler->getBuiltInResourcesString().c_str(), outStringLen);
|
||||
outString[outStringLen - 1] = '\0';
|
||||
}
|
||||
//
|
||||
// Do an actual compile on the given strings. The result is left
|
||||
// in the given compile object.
|
||||
@ -171,30 +250,30 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
|
||||
*params = compiler->getInfoSink().obj.size() + 1;
|
||||
break;
|
||||
case SH_ACTIVE_UNIFORMS:
|
||||
*params = compiler->getUniforms().size();
|
||||
*params = compiler->getExpandedUniforms().size();
|
||||
break;
|
||||
case SH_ACTIVE_UNIFORM_MAX_LENGTH:
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
break;
|
||||
case SH_ACTIVE_ATTRIBUTES:
|
||||
*params = compiler->getAttribs().size();
|
||||
*params = compiler->getAttributes().size();
|
||||
break;
|
||||
case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
break;
|
||||
case SH_VARYINGS:
|
||||
*params = compiler->getVaryings().size();
|
||||
*params = compiler->getExpandedVaryings().size();
|
||||
break;
|
||||
case SH_VARYING_MAX_LENGTH:
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
break;
|
||||
case SH_MAPPED_NAME_MAX_LENGTH:
|
||||
// Use longer length than MAX_SHORTENED_IDENTIFIER_SIZE to
|
||||
// handle array and struct dereferences.
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
break;
|
||||
case SH_NAME_MAX_LENGTH:
|
||||
*params = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
*params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
break;
|
||||
case SH_HASHED_NAME_MAX_LENGTH:
|
||||
if (compiler->getHashFunction() == NULL) {
|
||||
@ -203,12 +282,22 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
|
||||
// 64 bits hashing output requires 16 bytes for hex
|
||||
// representation.
|
||||
const char HashedNamePrefix[] = HASHED_NAME_PREFIX;
|
||||
(void)HashedNamePrefix;
|
||||
*params = 16 + sizeof(HashedNamePrefix);
|
||||
}
|
||||
break;
|
||||
case SH_HASHED_NAMES_COUNT:
|
||||
*params = compiler->getNameMap().size();
|
||||
break;
|
||||
case SH_SHADER_VERSION:
|
||||
*params = compiler->getShaderVersion();
|
||||
break;
|
||||
case SH_RESOURCES_STRING_LENGTH:
|
||||
*params = compiler->getBuiltInResourcesString().length() + 1;
|
||||
break;
|
||||
case SH_OUTPUT_TYPE:
|
||||
*params = compiler->getOutputType();
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
}
|
||||
@ -250,7 +339,7 @@ void ShGetVariableInfo(const ShHandle handle,
|
||||
int index,
|
||||
size_t* length,
|
||||
int* size,
|
||||
ShDataType* type,
|
||||
sh::GLenum* type,
|
||||
ShPrecisionType* precision,
|
||||
int* staticUse,
|
||||
char* name,
|
||||
@ -267,47 +356,32 @@ void ShGetVariableInfo(const ShHandle handle,
|
||||
if (compiler == 0)
|
||||
return;
|
||||
|
||||
const TVariableInfoList& varList =
|
||||
varType == SH_ACTIVE_ATTRIBUTES ? compiler->getAttribs() :
|
||||
(varType == SH_ACTIVE_UNIFORMS ? compiler->getUniforms() :
|
||||
compiler->getVaryings());
|
||||
if (index < 0 || index >= static_cast<int>(varList.size()))
|
||||
const sh::ShaderVariable *varInfo = GetVariable(compiler, varType, index);
|
||||
if (!varInfo)
|
||||
{
|
||||
return;
|
||||
|
||||
const TVariableInfo& varInfo = varList[index];
|
||||
if (length) *length = varInfo.name.size();
|
||||
*size = varInfo.size;
|
||||
*type = varInfo.type;
|
||||
switch (varInfo.precision) {
|
||||
case EbpLow:
|
||||
*precision = SH_PRECISION_LOWP;
|
||||
break;
|
||||
case EbpMedium:
|
||||
*precision = SH_PRECISION_MEDIUMP;
|
||||
break;
|
||||
case EbpHigh:
|
||||
*precision = SH_PRECISION_HIGHP;
|
||||
break;
|
||||
default:
|
||||
// Some types does not support precision, for example, boolean.
|
||||
*precision = SH_PRECISION_UNDEFINED;
|
||||
break;
|
||||
}
|
||||
*staticUse = varInfo.staticUse ? 1 : 0;
|
||||
|
||||
if (length) *length = varInfo->name.size();
|
||||
*size = varInfo->elementCount();
|
||||
*type = varInfo->type;
|
||||
*precision = ConvertPrecision(varInfo->precision);
|
||||
*staticUse = varInfo->staticUse ? 1 : 0;
|
||||
|
||||
// This size must match that queried by
|
||||
// SH_ACTIVE_UNIFORM_MAX_LENGTH, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_VARYING_MAX_LENGTH
|
||||
// in ShGetInfo, below.
|
||||
size_t variableLength = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
size_t variableLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
ASSERT(checkVariableMaxLengths(handle, variableLength));
|
||||
strncpy(name, varInfo.name.c_str(), variableLength);
|
||||
strncpy(name, varInfo->name.c_str(), variableLength);
|
||||
name[variableLength - 1] = 0;
|
||||
if (mappedName) {
|
||||
if (mappedName)
|
||||
{
|
||||
// This size must match that queried by
|
||||
// SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
|
||||
size_t maxMappedNameLength = 1 + MAX_SYMBOL_NAME_LEN;
|
||||
size_t maxMappedNameLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
|
||||
ASSERT(checkMappedNameMaxLength(handle, maxMappedNameLength));
|
||||
strncpy(mappedName, varInfo.mappedName.c_str(), maxMappedNameLength);
|
||||
strncpy(mappedName, varInfo->mappedName.c_str(), maxMappedNameLength);
|
||||
mappedName[maxMappedNameLength - 1] = 0;
|
||||
}
|
||||
}
|
||||
@ -369,6 +443,18 @@ void ShGetInfoPointer(const ShHandle handle, ShShaderInfo pname, void** params)
|
||||
case SH_ACTIVE_UNIFORMS_ARRAY:
|
||||
*params = (void*)&translator->getUniforms();
|
||||
break;
|
||||
case SH_ACTIVE_INTERFACE_BLOCKS_ARRAY:
|
||||
*params = (void*)&translator->getInterfaceBlocks();
|
||||
break;
|
||||
case SH_ACTIVE_OUTPUT_VARIABLES_ARRAY:
|
||||
*params = (void*)&translator->getOutputVariables();
|
||||
break;
|
||||
case SH_ACTIVE_ATTRIBUTES_ARRAY:
|
||||
*params = (void*)&translator->getAttributes();
|
||||
break;
|
||||
case SH_ACTIVE_VARYINGS_ARRAY:
|
||||
*params = (void*)&translator->getVaryings();
|
||||
break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
}
|
||||
@ -379,12 +465,62 @@ int ShCheckVariablesWithinPackingLimits(
|
||||
if (varInfoArraySize == 0)
|
||||
return 1;
|
||||
ASSERT(varInfoArray);
|
||||
TVariableInfoList variables;
|
||||
std::vector<sh::ShaderVariable> variables;
|
||||
for (size_t ii = 0; ii < varInfoArraySize; ++ii)
|
||||
{
|
||||
TVariableInfo var(varInfoArray[ii].type, varInfoArray[ii].size);
|
||||
sh::ShaderVariable var(varInfoArray[ii].type, (sh::GLenum)0, "", varInfoArray[ii].size);
|
||||
variables.push_back(var);
|
||||
}
|
||||
VariablePacker packer;
|
||||
return packer.CheckVariablesWithinPackingLimits(maxVectors, variables) ? 1 : 0;
|
||||
}
|
||||
|
||||
bool ShGetInterfaceBlockRegister(const ShHandle handle,
|
||||
const char *interfaceBlockName,
|
||||
unsigned int *indexOut)
|
||||
{
|
||||
if (!handle || !interfaceBlockName || !indexOut)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
|
||||
TranslatorHLSL* translator = base->getAsTranslatorHLSL();
|
||||
if (!translator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!translator->hasInterfaceBlock(interfaceBlockName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*indexOut = translator->getInterfaceBlockRegister(interfaceBlockName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShGetUniformRegister(const ShHandle handle,
|
||||
const char *uniformName,
|
||||
unsigned int *indexOut)
|
||||
{
|
||||
if (!handle || !uniformName || !indexOut)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TShHandleBase* base = static_cast<TShHandleBase*>(handle);
|
||||
TranslatorHLSL* translator = base->getAsTranslatorHLSL();
|
||||
if (!translator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!translator->hasUniform(uniformName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*indexOut = translator->getUniformRegister(uniformName);
|
||||
return true;
|
||||
}
|
||||
|
477
src/3rdparty/angle/src/compiler/translator/StructureHLSL.cpp
vendored
Normal file
477
src/3rdparty/angle/src/compiler/translator/StructureHLSL.cpp
vendored
Normal file
@ -0,0 +1,477 @@
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// StructureHLSL.cpp:
|
||||
// Definitions of methods for HLSL translation of GLSL structures.
|
||||
//
|
||||
|
||||
#include "compiler/translator/StructureHLSL.h"
|
||||
#include "common/utilities.h"
|
||||
#include "compiler/translator/OutputHLSL.h"
|
||||
#include "compiler/translator/Types.h"
|
||||
#include "compiler/translator/util.h"
|
||||
#include "compiler/translator/UtilsHLSL.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
Std140PaddingHelper::Std140PaddingHelper(const std::map<TString, int> &structElementIndexes)
|
||||
: mPaddingCounter(0),
|
||||
mElementIndex(0),
|
||||
mStructElementIndexes(structElementIndexes)
|
||||
{}
|
||||
|
||||
int Std140PaddingHelper::prePadding(const TType &type)
|
||||
{
|
||||
if (type.getBasicType() == EbtStruct || type.isMatrix() || type.isArray())
|
||||
{
|
||||
// no padding needed, HLSL will align the field to a new register
|
||||
mElementIndex = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const GLenum glType = GLVariableType(type);
|
||||
const int numComponents = gl::VariableComponentCount(glType);
|
||||
|
||||
if (numComponents >= 4)
|
||||
{
|
||||
// no padding needed, HLSL will align the field to a new register
|
||||
mElementIndex = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mElementIndex + numComponents > 4)
|
||||
{
|
||||
// no padding needed, HLSL will align the field to a new register
|
||||
mElementIndex = numComponents;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int alignment = numComponents == 3 ? 4 : numComponents;
|
||||
const int paddingOffset = (mElementIndex % alignment);
|
||||
const int paddingCount = (paddingOffset != 0 ? (alignment - paddingOffset) : 0);
|
||||
|
||||
mElementIndex += paddingCount;
|
||||
mElementIndex += numComponents;
|
||||
mElementIndex %= 4;
|
||||
|
||||
return paddingCount;
|
||||
}
|
||||
|
||||
TString Std140PaddingHelper::prePaddingString(const TType &type)
|
||||
{
|
||||
int paddingCount = prePadding(type);
|
||||
|
||||
TString padding;
|
||||
|
||||
for (int paddingIndex = 0; paddingIndex < paddingCount; paddingIndex++)
|
||||
{
|
||||
padding += " float pad_" + str(mPaddingCounter++) + ";\n";
|
||||
}
|
||||
|
||||
return padding;
|
||||
}
|
||||
|
||||
TString Std140PaddingHelper::postPaddingString(const TType &type, bool useHLSLRowMajorPacking)
|
||||
{
|
||||
if (!type.isMatrix() && !type.isArray() && type.getBasicType() != EbtStruct)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int numComponents = 0;
|
||||
TStructure *structure = type.getStruct();
|
||||
|
||||
if (type.isMatrix())
|
||||
{
|
||||
// This method can also be called from structureString, which does not use layout qualifiers.
|
||||
// Thus, use the method parameter for determining the matrix packing.
|
||||
//
|
||||
// Note HLSL row major packing corresponds to GL API column-major, and vice-versa, since we
|
||||
// wish to always transpose GL matrices to play well with HLSL's matrix array indexing.
|
||||
//
|
||||
const bool isRowMajorMatrix = !useHLSLRowMajorPacking;
|
||||
const GLenum glType = GLVariableType(type);
|
||||
numComponents = gl::MatrixComponentCount(glType, isRowMajorMatrix);
|
||||
}
|
||||
else if (structure)
|
||||
{
|
||||
const TString &structName = QualifiedStructNameString(*structure,
|
||||
useHLSLRowMajorPacking, true);
|
||||
numComponents = mStructElementIndexes.find(structName)->second;
|
||||
|
||||
if (numComponents == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const GLenum glType = GLVariableType(type);
|
||||
numComponents = gl::VariableComponentCount(glType);
|
||||
}
|
||||
|
||||
TString padding;
|
||||
for (int paddingOffset = numComponents; paddingOffset < 4; paddingOffset++)
|
||||
{
|
||||
padding += " float pad_" + str(mPaddingCounter++) + ";\n";
|
||||
}
|
||||
return padding;
|
||||
}
|
||||
|
||||
StructureHLSL::StructureHLSL()
|
||||
{}
|
||||
|
||||
TString StructureHLSL::defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing)
|
||||
{
|
||||
if (useStd140Packing)
|
||||
{
|
||||
Std140PaddingHelper padHelper(mStd140StructElementIndexes);
|
||||
return define(structure, useHLSLRowMajorPacking, useStd140Packing, &padHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
return define(structure, useHLSLRowMajorPacking, useStd140Packing, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
TString StructureHLSL::defineNameless(const TStructure &structure)
|
||||
{
|
||||
return define(structure, false, false, NULL);
|
||||
}
|
||||
|
||||
TString StructureHLSL::define(const TStructure &structure, bool useHLSLRowMajorPacking,
|
||||
bool useStd140Packing, Std140PaddingHelper *padHelper)
|
||||
{
|
||||
const TFieldList &fields = structure.fields();
|
||||
const bool isNameless = (structure.name() == "");
|
||||
const TString &structName = QualifiedStructNameString(structure, useHLSLRowMajorPacking,
|
||||
useStd140Packing);
|
||||
const TString declareString = (isNameless ? "struct" : "struct " + structName);
|
||||
|
||||
TString string;
|
||||
string += declareString + "\n"
|
||||
"{\n";
|
||||
|
||||
for (unsigned int i = 0; i < fields.size(); i++)
|
||||
{
|
||||
const TField &field = *fields[i];
|
||||
const TType &fieldType = *field.type();
|
||||
const TStructure *fieldStruct = fieldType.getStruct();
|
||||
const TString &fieldTypeString = fieldStruct ?
|
||||
QualifiedStructNameString(*fieldStruct, useHLSLRowMajorPacking,
|
||||
useStd140Packing) :
|
||||
TypeString(fieldType);
|
||||
|
||||
if (padHelper)
|
||||
{
|
||||
string += padHelper->prePaddingString(fieldType);
|
||||
}
|
||||
|
||||
string += " " + fieldTypeString + " " + DecorateField(field.name(), structure) + ArrayString(fieldType) + ";\n";
|
||||
|
||||
if (padHelper)
|
||||
{
|
||||
string += padHelper->postPaddingString(fieldType, useHLSLRowMajorPacking);
|
||||
}
|
||||
}
|
||||
|
||||
// Nameless structs do not finish with a semicolon and newline, to leave room for an instance variable
|
||||
string += (isNameless ? "} " : "};\n");
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
void StructureHLSL::addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters)
|
||||
{
|
||||
if (name == "")
|
||||
{
|
||||
return; // Nameless structures don't have constructors
|
||||
}
|
||||
|
||||
if (type.getStruct() && mStructNames.find(name) != mStructNames.end())
|
||||
{
|
||||
return; // Already added
|
||||
}
|
||||
|
||||
TType ctorType = type;
|
||||
ctorType.clearArrayness();
|
||||
ctorType.setPrecision(EbpHigh);
|
||||
ctorType.setQualifier(EvqTemporary);
|
||||
|
||||
typedef std::vector<TType> ParameterArray;
|
||||
ParameterArray ctorParameters;
|
||||
|
||||
const TStructure* structure = type.getStruct();
|
||||
if (structure)
|
||||
{
|
||||
mStructNames.insert(name);
|
||||
|
||||
// Add element index
|
||||
storeStd140ElementIndex(*structure, false);
|
||||
storeStd140ElementIndex(*structure, true);
|
||||
|
||||
const TString &structString = defineQualified(*structure, false, false);
|
||||
|
||||
if (std::find(mStructDeclarations.begin(), mStructDeclarations.end(), structString) == mStructDeclarations.end())
|
||||
{
|
||||
// Add row-major packed struct for interface blocks
|
||||
TString rowMajorString = "#pragma pack_matrix(row_major)\n" +
|
||||
defineQualified(*structure, true, false) +
|
||||
"#pragma pack_matrix(column_major)\n";
|
||||
|
||||
TString std140String = defineQualified(*structure, false, true);
|
||||
TString std140RowMajorString = "#pragma pack_matrix(row_major)\n" +
|
||||
defineQualified(*structure, true, true) +
|
||||
"#pragma pack_matrix(column_major)\n";
|
||||
|
||||
mStructDeclarations.push_back(structString);
|
||||
mStructDeclarations.push_back(rowMajorString);
|
||||
mStructDeclarations.push_back(std140String);
|
||||
mStructDeclarations.push_back(std140RowMajorString);
|
||||
}
|
||||
|
||||
const TFieldList &fields = structure->fields();
|
||||
for (unsigned int i = 0; i < fields.size(); i++)
|
||||
{
|
||||
ctorParameters.push_back(*fields[i]->type());
|
||||
}
|
||||
}
|
||||
else if (parameters)
|
||||
{
|
||||
for (TIntermSequence::const_iterator parameter = parameters->begin(); parameter != parameters->end(); parameter++)
|
||||
{
|
||||
ctorParameters.push_back((*parameter)->getAsTyped()->getType());
|
||||
}
|
||||
}
|
||||
else UNREACHABLE();
|
||||
|
||||
TString constructor;
|
||||
|
||||
if (ctorType.getStruct())
|
||||
{
|
||||
constructor += name + " " + name + "_ctor(";
|
||||
}
|
||||
else // Built-in type
|
||||
{
|
||||
constructor += TypeString(ctorType) + " " + name + "(";
|
||||
}
|
||||
|
||||
for (unsigned int parameter = 0; parameter < ctorParameters.size(); parameter++)
|
||||
{
|
||||
const TType &type = ctorParameters[parameter];
|
||||
|
||||
constructor += TypeString(type) + " x" + str(parameter) + ArrayString(type);
|
||||
|
||||
if (parameter < ctorParameters.size() - 1)
|
||||
{
|
||||
constructor += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
constructor += ")\n"
|
||||
"{\n";
|
||||
|
||||
if (ctorType.getStruct())
|
||||
{
|
||||
constructor += " " + name + " structure = {";
|
||||
}
|
||||
else
|
||||
{
|
||||
constructor += " return " + TypeString(ctorType) + "(";
|
||||
}
|
||||
|
||||
if (ctorType.isMatrix() && ctorParameters.size() == 1)
|
||||
{
|
||||
int rows = ctorType.getRows();
|
||||
int cols = ctorType.getCols();
|
||||
const TType ¶meter = ctorParameters[0];
|
||||
|
||||
if (parameter.isScalar())
|
||||
{
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
constructor += TString((row == col) ? "x0" : "0.0");
|
||||
|
||||
if (row < rows - 1 || col < cols - 1)
|
||||
{
|
||||
constructor += ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parameter.isMatrix())
|
||||
{
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
for (int col = 0; col < cols; col++)
|
||||
{
|
||||
if (row < parameter.getRows() && col < parameter.getCols())
|
||||
{
|
||||
constructor += TString("x0") + "[" + str(row) + "][" + str(col) + "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
constructor += TString((row == col) ? "1.0" : "0.0");
|
||||
}
|
||||
|
||||
if (row < rows - 1 || col < cols - 1)
|
||||
{
|
||||
constructor += ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(rows == 2 && cols == 2 && parameter.isVector() && parameter.getNominalSize() == 4);
|
||||
|
||||
constructor += "x0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t remainingComponents = ctorType.getObjectSize();
|
||||
size_t parameterIndex = 0;
|
||||
|
||||
while (remainingComponents > 0)
|
||||
{
|
||||
const TType ¶meter = ctorParameters[parameterIndex];
|
||||
const size_t parameterSize = parameter.getObjectSize();
|
||||
bool moreParameters = parameterIndex + 1 < ctorParameters.size();
|
||||
|
||||
constructor += "x" + str(parameterIndex);
|
||||
|
||||
if (ctorType.getStruct())
|
||||
{
|
||||
ASSERT(remainingComponents == parameterSize || moreParameters);
|
||||
ASSERT(parameterSize <= remainingComponents);
|
||||
|
||||
remainingComponents -= parameterSize;
|
||||
}
|
||||
else if (parameter.isScalar())
|
||||
{
|
||||
remainingComponents -= parameter.getObjectSize();
|
||||
}
|
||||
else if (parameter.isVector())
|
||||
{
|
||||
if (remainingComponents == parameterSize || moreParameters)
|
||||
{
|
||||
ASSERT(parameterSize <= remainingComponents);
|
||||
remainingComponents -= parameterSize;
|
||||
}
|
||||
else if (remainingComponents < static_cast<size_t>(parameter.getNominalSize()))
|
||||
{
|
||||
switch (remainingComponents)
|
||||
{
|
||||
case 1: constructor += ".x"; break;
|
||||
case 2: constructor += ".xy"; break;
|
||||
case 3: constructor += ".xyz"; break;
|
||||
case 4: constructor += ".xyzw"; break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
remainingComponents = 0;
|
||||
}
|
||||
else UNREACHABLE();
|
||||
}
|
||||
else if (parameter.isMatrix())
|
||||
{
|
||||
int column = 0;
|
||||
while (remainingComponents > 0 && column < parameter.getCols())
|
||||
{
|
||||
constructor += "[" + str(column) + "]";
|
||||
|
||||
if (remainingComponents < static_cast<size_t>(parameter.getRows()))
|
||||
{
|
||||
switch (remainingComponents)
|
||||
{
|
||||
case 1: constructor += ".x"; break;
|
||||
case 2: constructor += ".xy"; break;
|
||||
case 3: constructor += ".xyz"; break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
remainingComponents = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingComponents -= parameter.getRows();
|
||||
|
||||
if (remainingComponents > 0)
|
||||
{
|
||||
constructor += ", x" + str(parameterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
column++;
|
||||
}
|
||||
}
|
||||
else UNREACHABLE();
|
||||
|
||||
if (moreParameters)
|
||||
{
|
||||
parameterIndex++;
|
||||
}
|
||||
|
||||
if (remainingComponents)
|
||||
{
|
||||
constructor += ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctorType.getStruct())
|
||||
{
|
||||
constructor += "};\n"
|
||||
" return structure;\n"
|
||||
"}\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
constructor += ");\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
mConstructors.insert(constructor);
|
||||
}
|
||||
|
||||
std::string StructureHLSL::structsHeader() const
|
||||
{
|
||||
TInfoSinkBase out;
|
||||
|
||||
for (size_t structIndex = 0; structIndex < mStructDeclarations.size(); structIndex++)
|
||||
{
|
||||
out << mStructDeclarations[structIndex];
|
||||
}
|
||||
|
||||
for (Constructors::const_iterator constructor = mConstructors.begin();
|
||||
constructor != mConstructors.end();
|
||||
constructor++)
|
||||
{
|
||||
out << *constructor;
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void StructureHLSL::storeStd140ElementIndex(const TStructure &structure, bool useHLSLRowMajorPacking)
|
||||
{
|
||||
Std140PaddingHelper padHelper(mStd140StructElementIndexes);
|
||||
const TFieldList &fields = structure.fields();
|
||||
|
||||
for (unsigned int i = 0; i < fields.size(); i++)
|
||||
{
|
||||
padHelper.prePadding(*fields[i]->type());
|
||||
}
|
||||
|
||||
// Add remaining element index to the global map, for use with nested structs in standard layouts
|
||||
const TString &structName = QualifiedStructNameString(structure, useHLSLRowMajorPacking, true);
|
||||
mStd140StructElementIndexes[structName] = padHelper.elementIndex();
|
||||
}
|
||||
|
||||
}
|
74
src/3rdparty/angle/src/compiler/translator/StructureHLSL.h
vendored
Normal file
74
src/3rdparty/angle/src/compiler/translator/StructureHLSL.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// StructureHLSL.h:
|
||||
// Interfaces of methods for HLSL translation of GLSL structures.
|
||||
//
|
||||
|
||||
#ifndef TRANSLATOR_STRUCTUREHLSL_H_
|
||||
#define TRANSLATOR_STRUCTUREHLSL_H_
|
||||
|
||||
#include "compiler/translator/Common.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
class TInfoSinkBase;
|
||||
class TScopeBracket;
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
// This helper class assists structure and interface block definitions in determining
|
||||
// how to pack std140 structs within HLSL's packing rules.
|
||||
class Std140PaddingHelper
|
||||
{
|
||||
public:
|
||||
explicit Std140PaddingHelper(const std::map<TString, int> &structElementIndexes);
|
||||
|
||||
int elementIndex() const { return mElementIndex; }
|
||||
int prePadding(const TType &type);
|
||||
TString prePaddingString(const TType &type);
|
||||
TString postPaddingString(const TType &type, bool useHLSLRowMajorPacking);
|
||||
|
||||
private:
|
||||
int mPaddingCounter;
|
||||
int mElementIndex;
|
||||
const std::map<TString, int> &mStructElementIndexes;
|
||||
};
|
||||
|
||||
class StructureHLSL
|
||||
{
|
||||
public:
|
||||
StructureHLSL();
|
||||
|
||||
void addConstructor(const TType &type, const TString &name, const TIntermSequence *parameters);
|
||||
std::string structsHeader() const;
|
||||
|
||||
TString defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing);
|
||||
static TString defineNameless(const TStructure &structure);
|
||||
|
||||
Std140PaddingHelper getPaddingHelper() const { return Std140PaddingHelper(mStd140StructElementIndexes); }
|
||||
|
||||
private:
|
||||
std::map<TString, int> mStd140StructElementIndexes;
|
||||
|
||||
typedef std::set<TString> StructNames;
|
||||
StructNames mStructNames;
|
||||
|
||||
typedef std::set<TString> Constructors;
|
||||
Constructors mConstructors;
|
||||
|
||||
typedef std::vector<TString> StructDeclarations;
|
||||
StructDeclarations mStructDeclarations;
|
||||
|
||||
void storeStd140ElementIndex(const TStructure &structure, bool useHLSLRowMajorPacking);
|
||||
static TString define(const TStructure &structure, bool useHLSLRowMajorPacking,
|
||||
bool useStd140Packing, Std140PaddingHelper *padHelper);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COMPILER_STRUCTUREHLSL_H_
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -17,144 +17,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
TType::TType(const TPublicType &p) :
|
||||
type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize), structure(0)
|
||||
{
|
||||
if (p.userDef)
|
||||
structure = p.userDef->getStruct();
|
||||
}
|
||||
|
||||
//
|
||||
// Recursively generate mangled names.
|
||||
//
|
||||
TString TType::buildMangledName() const
|
||||
{
|
||||
TString mangledName;
|
||||
if (isMatrix())
|
||||
mangledName += 'm';
|
||||
else if (isVector())
|
||||
mangledName += 'v';
|
||||
|
||||
switch (type) {
|
||||
case EbtFloat: mangledName += 'f'; break;
|
||||
case EbtInt: mangledName += 'i'; break;
|
||||
case EbtBool: mangledName += 'b'; break;
|
||||
case EbtSampler2D: mangledName += "s2"; break;
|
||||
case EbtSamplerCube: mangledName += "sC"; break;
|
||||
case EbtStruct: mangledName += structure->mangledName(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
mangledName += static_cast<char>('0' + getNominalSize());
|
||||
if (isArray()) {
|
||||
char buf[20];
|
||||
snprintf(buf, sizeof(buf), "%d", arraySize);
|
||||
mangledName += '[';
|
||||
mangledName += buf;
|
||||
mangledName += ']';
|
||||
}
|
||||
return mangledName;
|
||||
}
|
||||
|
||||
size_t TType::getObjectSize() const
|
||||
{
|
||||
size_t totalSize = 0;
|
||||
|
||||
if (getBasicType() == EbtStruct)
|
||||
totalSize = structure->objectSize();
|
||||
else if (matrix)
|
||||
totalSize = size * size;
|
||||
else
|
||||
totalSize = size;
|
||||
|
||||
if (isArray()) {
|
||||
size_t arraySize = getArraySize();
|
||||
if (arraySize > INT_MAX / totalSize)
|
||||
totalSize = INT_MAX;
|
||||
else
|
||||
totalSize *= arraySize;
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
bool TStructure::containsArrays() const
|
||||
{
|
||||
for (size_t i = 0; i < mFields->size(); ++i) {
|
||||
const TType* fieldType = (*mFields)[i]->type();
|
||||
if (fieldType->isArray() || fieldType->isStructureContainingArrays())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TString TStructure::buildMangledName() const
|
||||
{
|
||||
TString mangledName("struct-");
|
||||
mangledName += *mName;
|
||||
for (size_t i = 0; i < mFields->size(); ++i) {
|
||||
mangledName += '-';
|
||||
mangledName += (*mFields)[i]->type()->getMangledName();
|
||||
}
|
||||
return mangledName;
|
||||
}
|
||||
|
||||
size_t TStructure::calculateObjectSize() const
|
||||
{
|
||||
size_t size = 0;
|
||||
for (size_t i = 0; i < mFields->size(); ++i) {
|
||||
size_t fieldSize = (*mFields)[i]->type()->getObjectSize();
|
||||
if (fieldSize > INT_MAX - size)
|
||||
size = INT_MAX;
|
||||
else
|
||||
size += fieldSize;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int TStructure::calculateDeepestNesting() const
|
||||
{
|
||||
int maxNesting = 0;
|
||||
for (size_t i = 0; i < mFields->size(); ++i) {
|
||||
maxNesting = std::max(maxNesting, (*mFields)[i]->type()->getDeepestStructNesting());
|
||||
}
|
||||
return 1 + maxNesting;
|
||||
}
|
||||
|
||||
//
|
||||
// Dump functions.
|
||||
//
|
||||
|
||||
void TVariable::dump(TInfoSink& infoSink) const
|
||||
{
|
||||
infoSink.debug << getName().c_str() << ": " << type.getQualifierString() << " " << type.getPrecisionString() << " " << type.getBasicString();
|
||||
if (type.isArray()) {
|
||||
infoSink.debug << "[0]";
|
||||
}
|
||||
infoSink.debug << "\n";
|
||||
}
|
||||
|
||||
void TFunction::dump(TInfoSink &infoSink) const
|
||||
{
|
||||
infoSink.debug << getName().c_str() << ": " << returnType.getBasicString() << " " << getMangledName().c_str() << "\n";
|
||||
}
|
||||
|
||||
void TSymbolTableLevel::dump(TInfoSink &infoSink) const
|
||||
{
|
||||
tLevel::const_iterator it;
|
||||
for (it = level.begin(); it != level.end(); ++it)
|
||||
(*it).second->dump(infoSink);
|
||||
}
|
||||
|
||||
void TSymbolTable::dump(TInfoSink &infoSink) const
|
||||
{
|
||||
for (int level = currentLevel(); level >= 0; --level) {
|
||||
infoSink.debug << "LEVEL " << level << "\n";
|
||||
table[level]->dump(infoSink);
|
||||
}
|
||||
}
|
||||
int TSymbolTable::uniqueIdCounter = 0;
|
||||
|
||||
//
|
||||
// Functions have buried pointers to delete.
|
||||
@ -174,6 +38,25 @@ TSymbolTableLevel::~TSymbolTableLevel()
|
||||
delete (*it).second;
|
||||
}
|
||||
|
||||
bool TSymbolTableLevel::insert(TSymbol *symbol)
|
||||
{
|
||||
symbol->setUniqueId(TSymbolTable::nextUniqueId());
|
||||
|
||||
// returning true means symbol was added to the table
|
||||
tInsertResult result = level.insert(tLevelPair(symbol->getMangledName(), symbol));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
TSymbol *TSymbolTableLevel::find(const TString &name) const
|
||||
{
|
||||
tLevel::const_iterator it = level.find(name);
|
||||
if (it == level.end())
|
||||
return 0;
|
||||
else
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
//
|
||||
// Change all function entries in the table with the non-mangled name
|
||||
// to be related to the provided built-in operation. This is a low
|
||||
@ -182,9 +65,10 @@ TSymbolTableLevel::~TSymbolTableLevel()
|
||||
//
|
||||
void TSymbolTableLevel::relateToOperator(const char *name, TOperator op)
|
||||
{
|
||||
tLevel::iterator it;
|
||||
for (it = level.begin(); it != level.end(); ++it) {
|
||||
if ((*it).second->isFunction()) {
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
||||
{
|
||||
if ((*it).second->isFunction())
|
||||
{
|
||||
TFunction *function = static_cast<TFunction*>((*it).second);
|
||||
if (function->getName() == name)
|
||||
function->relateToOperator(op);
|
||||
@ -200,17 +84,153 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
|
||||
//
|
||||
void TSymbolTableLevel::relateToExtension(const char *name, const TString &ext)
|
||||
{
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) {
|
||||
for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
|
||||
{
|
||||
TSymbol *symbol = it->second;
|
||||
if (symbol->getName() == name)
|
||||
symbol->relateToExtension(ext);
|
||||
}
|
||||
}
|
||||
|
||||
TSymbol::TSymbol(const TSymbol ©Of)
|
||||
{
|
||||
name = NewPoolTString(copyOf.name->c_str());
|
||||
uniqueId = copyOf.uniqueId;
|
||||
}
|
||||
|
||||
TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtIn, bool *sameScope)
|
||||
{
|
||||
int level = currentLevel();
|
||||
TSymbol *symbol;
|
||||
|
||||
do
|
||||
{
|
||||
if (level == ESSL3_BUILTINS && shaderVersion != 300)
|
||||
level--;
|
||||
if (level == ESSL1_BUILTINS && shaderVersion != 100)
|
||||
level--;
|
||||
|
||||
symbol = table[level]->find(name);
|
||||
}
|
||||
while (symbol == 0 && --level >= 0);
|
||||
|
||||
if (builtIn)
|
||||
*builtIn = (level <= LAST_BUILTIN_LEVEL);
|
||||
if (sameScope)
|
||||
*sameScope = (level == currentLevel());
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
TSymbol *TSymbolTable::findBuiltIn(const TString &name, int shaderVersion)
|
||||
{
|
||||
for (int level = LAST_BUILTIN_LEVEL; level >= 0; level--)
|
||||
{
|
||||
if (level == ESSL3_BUILTINS && shaderVersion != 300)
|
||||
level--;
|
||||
if (level == ESSL1_BUILTINS && shaderVersion != 100)
|
||||
level--;
|
||||
|
||||
TSymbol *symbol = table[level]->find(name);
|
||||
|
||||
if (symbol)
|
||||
return symbol;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TSymbolTable::~TSymbolTable()
|
||||
{
|
||||
for (size_t i = 0; i < table.size(); ++i)
|
||||
delete table[i];
|
||||
for (size_t i = 0; i < precisionStack.size(); ++i)
|
||||
delete precisionStack[i];
|
||||
while (table.size() > 0)
|
||||
pop();
|
||||
}
|
||||
|
||||
void TSymbolTable::insertBuiltIn(
|
||||
ESymbolLevel level, TType *rvalue, const char *name,
|
||||
TType *ptype1, TType *ptype2, TType *ptype3, TType *ptype4, TType *ptype5)
|
||||
{
|
||||
if (ptype1->getBasicType() == EbtGSampler2D)
|
||||
{
|
||||
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
|
||||
new TType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
|
||||
new TType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
|
||||
new TType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5);
|
||||
return;
|
||||
}
|
||||
if (ptype1->getBasicType() == EbtGSampler3D)
|
||||
{
|
||||
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
|
||||
new TType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
|
||||
new TType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
|
||||
new TType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5);
|
||||
return;
|
||||
}
|
||||
if (ptype1->getBasicType() == EbtGSamplerCube)
|
||||
{
|
||||
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
|
||||
new TType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
|
||||
new TType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
|
||||
new TType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5);
|
||||
return;
|
||||
}
|
||||
if (ptype1->getBasicType() == EbtGSampler2DArray)
|
||||
{
|
||||
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
|
||||
new TType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
|
||||
new TType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5);
|
||||
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
|
||||
new TType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5);
|
||||
return;
|
||||
}
|
||||
|
||||
TFunction *function = new TFunction(NewPoolTString(name), *rvalue);
|
||||
|
||||
TType *types[] = {ptype1, ptype2, ptype3, ptype4, ptype5};
|
||||
for (size_t ii = 0; ii < sizeof(types) / sizeof(types[0]); ++ii)
|
||||
{
|
||||
if (types[ii])
|
||||
{
|
||||
TParameter param = {NULL, types[ii]};
|
||||
function->addParameter(param);
|
||||
}
|
||||
}
|
||||
|
||||
insert(level, function);
|
||||
}
|
||||
|
||||
TPrecision TSymbolTable::getDefaultPrecision(TBasicType type)
|
||||
{
|
||||
if (!SupportsPrecision(type))
|
||||
return EbpUndefined;
|
||||
|
||||
// unsigned integers use the same precision as signed
|
||||
TBasicType baseType = (type == EbtUInt) ? EbtInt : type;
|
||||
|
||||
int level = static_cast<int>(precisionStack.size()) - 1;
|
||||
assert(level >= 0); // Just to be safe. Should not happen.
|
||||
// If we dont find anything we return this. Should we error check this?
|
||||
TPrecision prec = EbpUndefined;
|
||||
while (level >= 0)
|
||||
{
|
||||
PrecisionStackLevel::iterator it = precisionStack[level]->find(baseType);
|
||||
if (it != precisionStack[level]->end())
|
||||
{
|
||||
prec = (*it).second;
|
||||
break;
|
||||
}
|
||||
level--;
|
||||
}
|
||||
return prec;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -36,24 +36,53 @@
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
//
|
||||
// Symbol base class. (Can build functions or variables out of these...)
|
||||
//
|
||||
class TSymbol {
|
||||
class TSymbol
|
||||
{
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE();
|
||||
TSymbol(const TString* n) : uniqueId(0), name(n) { }
|
||||
virtual ~TSymbol() { /* don't delete name, it's from the pool */ }
|
||||
TSymbol(const TString *n)
|
||||
: uniqueId(0),
|
||||
name(n)
|
||||
{
|
||||
}
|
||||
virtual ~TSymbol()
|
||||
{
|
||||
// don't delete name, it's from the pool
|
||||
}
|
||||
|
||||
const TString& getName() const { return *name; }
|
||||
virtual const TString& getMangledName() const { return getName(); }
|
||||
virtual bool isFunction() const { return false; }
|
||||
virtual bool isVariable() const { return false; }
|
||||
void setUniqueId(int id) { uniqueId = id; }
|
||||
int getUniqueId() const { return uniqueId; }
|
||||
virtual void dump(TInfoSink &infoSink) const = 0;
|
||||
void relateToExtension(const TString& ext) { extension = ext; }
|
||||
const TString& getExtension() const { return extension; }
|
||||
const TString &getName() const
|
||||
{
|
||||
return *name;
|
||||
}
|
||||
virtual const TString &getMangledName() const
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
virtual bool isFunction() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool isVariable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void setUniqueId(int id)
|
||||
{
|
||||
uniqueId = id;
|
||||
}
|
||||
int getUniqueId() const
|
||||
{
|
||||
return uniqueId;
|
||||
}
|
||||
void relateToExtension(const TString &ext)
|
||||
{
|
||||
extension = ext;
|
||||
}
|
||||
const TString &getExtension() const
|
||||
{
|
||||
return extension;
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(TSymbol);
|
||||
@ -63,7 +92,6 @@ private:
|
||||
TString extension;
|
||||
};
|
||||
|
||||
//
|
||||
// Variable class, meaning a symbol that's not a function.
|
||||
//
|
||||
// There could be a separate class heirarchy for Constant variables;
|
||||
@ -72,18 +100,39 @@ private:
|
||||
// seem worth having separate classes, and "getConst" can't simply return
|
||||
// different values for different types polymorphically, so this is
|
||||
// just simple and pragmatic.
|
||||
//
|
||||
class TVariable : public TSymbol {
|
||||
class TVariable : public TSymbol
|
||||
{
|
||||
public:
|
||||
TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0) { }
|
||||
virtual ~TVariable() { }
|
||||
virtual bool isVariable() const { return true; }
|
||||
TType& getType() { return type; }
|
||||
const TType& getType() const { return type; }
|
||||
bool isUserType() const { return userType; }
|
||||
void setQualifier(TQualifier qualifier) { type.setQualifier(qualifier); }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
TVariable(const TString *name, const TType &t, bool uT = false)
|
||||
: TSymbol(name),
|
||||
type(t),
|
||||
userType(uT),
|
||||
unionArray(0)
|
||||
{
|
||||
}
|
||||
virtual ~TVariable()
|
||||
{
|
||||
}
|
||||
virtual bool isVariable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
TType &getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
const TType &getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
bool isUserType() const
|
||||
{
|
||||
return userType;
|
||||
}
|
||||
void setQualifier(TQualifier qualifier)
|
||||
{
|
||||
type.setQualifier(qualifier);
|
||||
}
|
||||
|
||||
ConstantUnion *getConstPointer()
|
||||
{
|
||||
@ -93,7 +142,10 @@ public:
|
||||
return unionArray;
|
||||
}
|
||||
|
||||
ConstantUnion* getConstPointer() const { return unionArray; }
|
||||
ConstantUnion *getConstPointer() const
|
||||
{
|
||||
return unionArray;
|
||||
}
|
||||
|
||||
void shareConstPointer(ConstantUnion *constArray)
|
||||
{
|
||||
@ -109,40 +161,48 @@ private:
|
||||
|
||||
TType type;
|
||||
bool userType;
|
||||
// we are assuming that Pool Allocator will free the memory allocated to unionArray
|
||||
// when this object is destroyed
|
||||
// we are assuming that Pool Allocator will free the memory
|
||||
// allocated to unionArray when this object is destroyed.
|
||||
ConstantUnion *unionArray;
|
||||
};
|
||||
|
||||
//
|
||||
// The function sub-class of symbols and the parser will need to
|
||||
// share this definition of a function parameter.
|
||||
//
|
||||
struct TParameter {
|
||||
struct TParameter
|
||||
{
|
||||
TString *name;
|
||||
TType *type;
|
||||
};
|
||||
|
||||
//
|
||||
// The function sub-class of a symbol.
|
||||
//
|
||||
class TFunction : public TSymbol {
|
||||
class TFunction : public TSymbol
|
||||
{
|
||||
public:
|
||||
TFunction(TOperator o) :
|
||||
TSymbol(0),
|
||||
TFunction(TOperator o)
|
||||
: TSymbol(0),
|
||||
returnType(TType(EbtVoid, EbpUndefined)),
|
||||
op(o),
|
||||
defined(false) { }
|
||||
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
|
||||
TSymbol(name),
|
||||
defined(false)
|
||||
{
|
||||
}
|
||||
TFunction(const TString *name, const TType &retType, TOperator tOp = EOpNull)
|
||||
: TSymbol(name),
|
||||
returnType(retType),
|
||||
mangledName(TFunction::mangleName(*name)),
|
||||
op(tOp),
|
||||
defined(false) { }
|
||||
defined(false)
|
||||
{
|
||||
}
|
||||
virtual ~TFunction();
|
||||
virtual bool isFunction() const { return true; }
|
||||
virtual bool isFunction() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static TString mangleName(const TString& name) { return name + '('; }
|
||||
static TString mangleName(const TString &name)
|
||||
{
|
||||
return name + '(';
|
||||
}
|
||||
static TString unmangleName(const TString &mangledName)
|
||||
{
|
||||
return TString(mangledName.c_str(), mangledName.find_first_of('('));
|
||||
@ -154,19 +214,41 @@ public:
|
||||
mangledName = mangledName + p.type->getMangledName();
|
||||
}
|
||||
|
||||
const TString& getMangledName() const { return mangledName; }
|
||||
const TType& getReturnType() const { return returnType; }
|
||||
const TString &getMangledName() const
|
||||
{
|
||||
return mangledName;
|
||||
}
|
||||
const TType &getReturnType() const
|
||||
{
|
||||
return returnType;
|
||||
}
|
||||
|
||||
void relateToOperator(TOperator o) { op = o; }
|
||||
TOperator getBuiltInOp() const { return op; }
|
||||
void relateToOperator(TOperator o)
|
||||
{
|
||||
op = o;
|
||||
}
|
||||
TOperator getBuiltInOp() const
|
||||
{
|
||||
return op;
|
||||
}
|
||||
|
||||
void setDefined() { defined = true; }
|
||||
bool isDefined() { return defined; }
|
||||
void setDefined()
|
||||
{
|
||||
defined = true;
|
||||
}
|
||||
bool isDefined()
|
||||
{
|
||||
return defined;
|
||||
}
|
||||
|
||||
size_t getParamCount() const { return parameters.size(); }
|
||||
const TParameter& getParam(size_t i) const { return parameters[i]; }
|
||||
|
||||
virtual void dump(TInfoSink &infoSink) const;
|
||||
size_t getParamCount() const
|
||||
{
|
||||
return parameters.size();
|
||||
}
|
||||
const TParameter &getParam(size_t i) const
|
||||
{
|
||||
return parameters[i];
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(TFunction);
|
||||
@ -179,79 +261,80 @@ private:
|
||||
bool defined;
|
||||
};
|
||||
|
||||
// Interface block name sub-symbol
|
||||
class TInterfaceBlockName : public TSymbol
|
||||
{
|
||||
public:
|
||||
TInterfaceBlockName(const TString *name)
|
||||
: TSymbol(name)
|
||||
{
|
||||
}
|
||||
|
||||
class TSymbolTableLevel {
|
||||
virtual ~TInterfaceBlockName()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class TSymbolTableLevel
|
||||
{
|
||||
public:
|
||||
typedef TMap<TString, TSymbol *> tLevel;
|
||||
typedef tLevel::const_iterator const_iterator;
|
||||
typedef const tLevel::value_type tLevelPair;
|
||||
typedef std::pair<tLevel::iterator, bool> tInsertResult;
|
||||
|
||||
TSymbolTableLevel() { }
|
||||
TSymbolTableLevel()
|
||||
{
|
||||
}
|
||||
~TSymbolTableLevel();
|
||||
|
||||
bool insert(const TString &name, TSymbol &symbol)
|
||||
{
|
||||
//
|
||||
// returning true means symbol was added to the table
|
||||
//
|
||||
tInsertResult result = level.insert(tLevelPair(name, &symbol));
|
||||
bool insert(TSymbol *symbol);
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
bool insert(TSymbol &symbol)
|
||||
{
|
||||
return insert(symbol.getMangledName(), symbol);
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name) const
|
||||
{
|
||||
tLevel::const_iterator it = level.find(name);
|
||||
if (it == level.end())
|
||||
return 0;
|
||||
else
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return level.begin();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return level.end();
|
||||
}
|
||||
TSymbol *find(const TString &name) const;
|
||||
|
||||
void relateToOperator(const char *name, TOperator op);
|
||||
void relateToExtension(const char *name, const TString &ext);
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
|
||||
protected:
|
||||
tLevel level;
|
||||
};
|
||||
|
||||
class TSymbolTable {
|
||||
public:
|
||||
TSymbolTable() : uniqueId(0)
|
||||
enum ESymbolLevel
|
||||
{
|
||||
COMMON_BUILTINS = 0,
|
||||
ESSL1_BUILTINS = 1,
|
||||
ESSL3_BUILTINS = 2,
|
||||
LAST_BUILTIN_LEVEL = ESSL3_BUILTINS,
|
||||
GLOBAL_LEVEL = 3
|
||||
};
|
||||
|
||||
class TSymbolTable
|
||||
{
|
||||
public:
|
||||
TSymbolTable()
|
||||
{
|
||||
//
|
||||
// The symbol table cannot be used until push() is called, but
|
||||
// the lack of an initial call to push() can be used to detect
|
||||
// that the symbol table has not been preloaded with built-ins.
|
||||
//
|
||||
}
|
||||
|
||||
~TSymbolTable();
|
||||
|
||||
//
|
||||
// When the symbol table is initialized with the built-ins, there should
|
||||
// 'push' calls, so that built-ins are at level 0 and the shader
|
||||
// globals are at level 1.
|
||||
//
|
||||
bool isEmpty() { return table.size() == 0; }
|
||||
bool atBuiltInLevel() { return table.size() == 1; }
|
||||
bool atGlobalLevel() { return table.size() <= 2; }
|
||||
bool isEmpty()
|
||||
{
|
||||
return table.empty();
|
||||
}
|
||||
bool atBuiltInLevel()
|
||||
{
|
||||
return currentLevel() <= LAST_BUILTIN_LEVEL;
|
||||
}
|
||||
bool atGlobalLevel()
|
||||
{
|
||||
return currentLevel() <= GLOBAL_LEVEL;
|
||||
}
|
||||
void push()
|
||||
{
|
||||
table.push_back(new TSymbolTableLevel);
|
||||
@ -267,116 +350,80 @@ public:
|
||||
precisionStack.pop_back();
|
||||
}
|
||||
|
||||
bool insert(TSymbol& symbol)
|
||||
bool declare(TSymbol *symbol)
|
||||
{
|
||||
symbol.setUniqueId(++uniqueId);
|
||||
return table[currentLevel()]->insert(symbol);
|
||||
return insert(currentLevel(), symbol);
|
||||
}
|
||||
|
||||
bool insertConstInt(const char *name, int value)
|
||||
bool insert(ESymbolLevel level, TSymbol *symbol)
|
||||
{
|
||||
TVariable *constant = new TVariable(NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1));
|
||||
return table[level]->insert(symbol);
|
||||
}
|
||||
|
||||
bool insertConstInt(ESymbolLevel level, const char *name, int value)
|
||||
{
|
||||
TVariable *constant = new TVariable(
|
||||
NewPoolTString(name), TType(EbtInt, EbpUndefined, EvqConst, 1));
|
||||
constant->getConstPointer()->setIConst(value);
|
||||
return insert(*constant);
|
||||
return insert(level, constant);
|
||||
}
|
||||
|
||||
bool insertBuiltIn(TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0)
|
||||
void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name,
|
||||
TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0,
|
||||
TType *ptype4 = 0, TType *ptype5 = 0);
|
||||
|
||||
TSymbol *find(const TString &name, int shaderVersion,
|
||||
bool *builtIn = NULL, bool *sameScope = NULL);
|
||||
TSymbol *findBuiltIn(const TString &name, int shaderVersion);
|
||||
|
||||
TSymbolTableLevel *getOuterLevel()
|
||||
{
|
||||
TFunction *function = new TFunction(NewPoolTString(name), *rvalue);
|
||||
|
||||
TParameter param1 = {NULL, ptype1};
|
||||
function->addParameter(param1);
|
||||
|
||||
if(ptype2)
|
||||
{
|
||||
TParameter param2 = {NULL, ptype2};
|
||||
function->addParameter(param2);
|
||||
}
|
||||
|
||||
if(ptype3)
|
||||
{
|
||||
TParameter param3 = {NULL, ptype3};
|
||||
function->addParameter(param3);
|
||||
}
|
||||
|
||||
return insert(*function);
|
||||
}
|
||||
|
||||
TSymbol* find(const TString& name, bool* builtIn = 0, bool *sameScope = 0)
|
||||
{
|
||||
int level = currentLevel();
|
||||
TSymbol* symbol;
|
||||
do {
|
||||
symbol = table[level]->find(name);
|
||||
--level;
|
||||
} while (symbol == 0 && level >= 0);
|
||||
level++;
|
||||
if (builtIn)
|
||||
*builtIn = level == 0;
|
||||
if (sameScope)
|
||||
*sameScope = level == currentLevel();
|
||||
return symbol;
|
||||
}
|
||||
|
||||
TSymbol* findBuiltIn(const TString &name)
|
||||
{
|
||||
return table[0]->find(name);
|
||||
}
|
||||
|
||||
TSymbolTableLevel* getOuterLevel() {
|
||||
assert(table.size() >= 2);
|
||||
assert(currentLevel() >= 1);
|
||||
return table[currentLevel() - 1];
|
||||
}
|
||||
|
||||
void relateToOperator(const char* name, TOperator op) {
|
||||
table[0]->relateToOperator(name, op);
|
||||
void relateToOperator(ESymbolLevel level, const char *name, TOperator op)
|
||||
{
|
||||
table[level]->relateToOperator(name, op);
|
||||
}
|
||||
void relateToExtension(const char* name, const TString& ext) {
|
||||
table[0]->relateToExtension(name, ext);
|
||||
void relateToExtension(ESymbolLevel level, const char *name, const TString &ext)
|
||||
{
|
||||
table[level]->relateToExtension(name, ext);
|
||||
}
|
||||
void dump(TInfoSink &infoSink) const;
|
||||
|
||||
bool setDefaultPrecision(const TPublicType& type, TPrecision prec) {
|
||||
if (!supportsPrecision(type.type))
|
||||
bool setDefaultPrecision(const TPublicType &type, TPrecision prec)
|
||||
{
|
||||
if (!SupportsPrecision(type.type))
|
||||
return false;
|
||||
if (type.size != 1 || type.matrix || type.array)
|
||||
if (type.isAggregate())
|
||||
return false; // Not allowed to set for aggregate types
|
||||
int indexOfLastElement = static_cast<int>(precisionStack.size()) - 1;
|
||||
(*precisionStack[indexOfLastElement])[type.type] = prec; // Uses map operator [], overwrites the current value
|
||||
// Uses map operator [], overwrites the current value
|
||||
(*precisionStack[indexOfLastElement])[type.type] = prec;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Searches down the precisionStack for a precision qualifier for the specified TBasicType
|
||||
TPrecision getDefaultPrecision(TBasicType type) {
|
||||
if (!supportsPrecision(type))
|
||||
return EbpUndefined;
|
||||
int level = static_cast<int>(precisionStack.size()) - 1;
|
||||
assert(level >= 0); // Just to be safe. Should not happen.
|
||||
PrecisionStackLevel::iterator it;
|
||||
TPrecision prec = EbpUndefined; // If we dont find anything we return this. Should we error check this?
|
||||
while (level >= 0) {
|
||||
it = precisionStack[level]->find(type);
|
||||
if (it != precisionStack[level]->end()) {
|
||||
prec = (*it).second;
|
||||
break;
|
||||
}
|
||||
level--;
|
||||
}
|
||||
return prec;
|
||||
// Searches down the precisionStack for a precision qualifier
|
||||
// for the specified TBasicType
|
||||
TPrecision getDefaultPrecision(TBasicType type);
|
||||
|
||||
static int nextUniqueId()
|
||||
{
|
||||
return ++uniqueIdCounter;
|
||||
}
|
||||
|
||||
private:
|
||||
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
||||
|
||||
bool supportsPrecision(TBasicType type) {
|
||||
// Only supports precision for int, float, and sampler types.
|
||||
return type == EbtFloat || type == EbtInt || IsSampler(type);
|
||||
ESymbolLevel currentLevel() const
|
||||
{
|
||||
return static_cast<ESymbolLevel>(table.size() - 1);
|
||||
}
|
||||
|
||||
int uniqueId; // for unique identification in code generation
|
||||
std::vector<TSymbolTableLevel *> table;
|
||||
typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
|
||||
std::vector< PrecisionStackLevel *> precisionStack;
|
||||
|
||||
static int uniqueIdCounter;
|
||||
};
|
||||
|
||||
#endif // _SYMBOL_TABLE_INCLUDED_
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -7,9 +7,10 @@
|
||||
#include "compiler/translator/TranslatorESSL.h"
|
||||
|
||||
#include "compiler/translator/OutputESSL.h"
|
||||
#include "angle_gl.h"
|
||||
|
||||
TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
|
||||
: TCompiler(type, spec) {
|
||||
TranslatorESSL::TranslatorESSL(sh::GLenum type, ShShaderSpec spec)
|
||||
: TCompiler(type, spec, SH_ESSL_OUTPUT) {
|
||||
}
|
||||
|
||||
void TranslatorESSL::translate(TIntermNode* root) {
|
||||
@ -20,13 +21,13 @@ void TranslatorESSL::translate(TIntermNode* root) {
|
||||
|
||||
// Write emulated built-in functions if needed.
|
||||
getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
|
||||
sink, getShaderType() == SH_FRAGMENT_SHADER);
|
||||
sink, getShaderType() == GL_FRAGMENT_SHADER);
|
||||
|
||||
// Write array bounds clamping emulation if needed.
|
||||
getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
|
||||
|
||||
// Write translated shader.
|
||||
TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable());
|
||||
TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion());
|
||||
root->traverse(&outputESSL);
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,11 @@
|
||||
#ifndef COMPILER_TRANSLATORESSL_H_
|
||||
#define COMPILER_TRANSLATORESSL_H_
|
||||
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/Compiler.h"
|
||||
|
||||
class TranslatorESSL : public TCompiler {
|
||||
public:
|
||||
TranslatorESSL(ShShaderType type, ShShaderSpec spec);
|
||||
TranslatorESSL(sh::GLenum type, ShShaderSpec spec);
|
||||
|
||||
protected:
|
||||
virtual void translate(TIntermNode* root);
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
||||
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
@ -9,7 +9,7 @@
|
||||
#include "compiler/translator/OutputGLSL.h"
|
||||
#include "compiler/translator/VersionGLSL.h"
|
||||
|
||||
static void writeVersion(ShShaderType type, TIntermNode* root,
|
||||
static void writeVersion(sh::GLenum type, TIntermNode* root,
|
||||
TInfoSinkBase& sink) {
|
||||
TVersionGLSL versionGLSL(type);
|
||||
root->traverse(&versionGLSL);
|
||||
@ -21,8 +21,8 @@ static void writeVersion(ShShaderType type, TIntermNode* root,
|
||||
}
|
||||
}
|
||||
|
||||
TranslatorGLSL::TranslatorGLSL(ShShaderType type, ShShaderSpec spec)
|
||||
: TCompiler(type, spec) {
|
||||
TranslatorGLSL::TranslatorGLSL(sh::GLenum type, ShShaderSpec spec)
|
||||
: TCompiler(type, spec, SH_GLSL_OUTPUT) {
|
||||
}
|
||||
|
||||
void TranslatorGLSL::translate(TIntermNode* root) {
|
||||
@ -31,6 +31,9 @@ void TranslatorGLSL::translate(TIntermNode* root) {
|
||||
// Write GLSL version.
|
||||
writeVersion(getShaderType(), root, sink);
|
||||
|
||||
// Write extension behaviour as needed
|
||||
writeExtensionBehavior();
|
||||
|
||||
// Write emulated built-in functions if needed.
|
||||
getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
|
||||
sink, false);
|
||||
@ -39,6 +42,23 @@ void TranslatorGLSL::translate(TIntermNode* root) {
|
||||
getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
|
||||
|
||||
// Write translated shader.
|
||||
TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable());
|
||||
TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion());
|
||||
root->traverse(&outputGLSL);
|
||||
}
|
||||
|
||||
void TranslatorGLSL::writeExtensionBehavior() {
|
||||
TInfoSinkBase& sink = getInfoSink().obj;
|
||||
const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
|
||||
for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
|
||||
iter != extensionBehavior.end(); ++iter) {
|
||||
if (iter->second == EBhUndefined)
|
||||
continue;
|
||||
|
||||
// For GLSL output, we don't need to emit most extensions explicitly,
|
||||
// but some we need to translate.
|
||||
if (iter->first == "GL_EXT_shader_texture_lod") {
|
||||
sink << "#extension GL_ARB_shader_texture_lod : "
|
||||
<< getBehaviorString(iter->second) << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,17 @@
|
||||
#ifndef COMPILER_TRANSLATORGLSL_H_
|
||||
#define COMPILER_TRANSLATORGLSL_H_
|
||||
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/Compiler.h"
|
||||
|
||||
class TranslatorGLSL : public TCompiler {
|
||||
public:
|
||||
TranslatorGLSL(ShShaderType type, ShShaderSpec spec);
|
||||
TranslatorGLSL(sh::GLenum type, ShShaderSpec spec);
|
||||
|
||||
protected:
|
||||
virtual void translate(TIntermNode* root);
|
||||
|
||||
private:
|
||||
void writeExtensionBehavior();
|
||||
};
|
||||
|
||||
#endif // COMPILER_TRANSLATORGLSL_H_
|
||||
|
@ -9,16 +9,46 @@
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
#include "compiler/translator/OutputHLSL.h"
|
||||
|
||||
TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
|
||||
: TCompiler(type, spec), mOutputType(output)
|
||||
TranslatorHLSL::TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
|
||||
: TCompiler(type, spec, output)
|
||||
{
|
||||
}
|
||||
|
||||
void TranslatorHLSL::translate(TIntermNode *root)
|
||||
{
|
||||
TParseContext& parseContext = *GetGlobalParseContext();
|
||||
sh::OutputHLSL outputHLSL(parseContext, getResources(), mOutputType);
|
||||
sh::OutputHLSL outputHLSL(parseContext, getResources(), getOutputType());
|
||||
|
||||
outputHLSL.output();
|
||||
mActiveUniforms = outputHLSL.getUniforms();
|
||||
|
||||
attributes = outputHLSL.getAttributes();
|
||||
outputVariables = outputHLSL.getOutputVariables();
|
||||
uniforms = outputHLSL.getUniforms();
|
||||
varyings = outputHLSL.getVaryings();
|
||||
interfaceBlocks = outputHLSL.getInterfaceBlocks();
|
||||
|
||||
mInterfaceBlockRegisterMap = outputHLSL.getInterfaceBlockRegisterMap();
|
||||
mUniformRegisterMap = outputHLSL.getUniformRegisterMap();
|
||||
}
|
||||
|
||||
bool TranslatorHLSL::hasInterfaceBlock(const std::string &interfaceBlockName) const
|
||||
{
|
||||
return (mInterfaceBlockRegisterMap.count(interfaceBlockName) > 0);
|
||||
}
|
||||
|
||||
unsigned int TranslatorHLSL::getInterfaceBlockRegister(const std::string &interfaceBlockName) const
|
||||
{
|
||||
ASSERT(hasInterfaceBlock(interfaceBlockName));
|
||||
return mInterfaceBlockRegisterMap.find(interfaceBlockName)->second;
|
||||
}
|
||||
|
||||
bool TranslatorHLSL::hasUniform(const std::string &uniformName) const
|
||||
{
|
||||
return (mUniformRegisterMap.count(uniformName) > 0);
|
||||
}
|
||||
|
||||
unsigned int TranslatorHLSL::getUniformRegister(const std::string &uniformName) const
|
||||
{
|
||||
ASSERT(hasUniform(uniformName));
|
||||
return mUniformRegisterMap.find(uniformName)->second;
|
||||
}
|
||||
|
@ -7,21 +7,26 @@
|
||||
#ifndef COMPILER_TRANSLATORHLSL_H_
|
||||
#define COMPILER_TRANSLATORHLSL_H_
|
||||
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/Uniform.h"
|
||||
#include "compiler/translator/Compiler.h"
|
||||
#include "common/shadervars.h"
|
||||
|
||||
class TranslatorHLSL : public TCompiler {
|
||||
class TranslatorHLSL : public TCompiler
|
||||
{
|
||||
public:
|
||||
TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
|
||||
|
||||
TranslatorHLSL(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output);
|
||||
virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
|
||||
const sh::ActiveUniforms &getUniforms() { return mActiveUniforms; }
|
||||
|
||||
bool hasInterfaceBlock(const std::string &interfaceBlockName) const;
|
||||
unsigned int getInterfaceBlockRegister(const std::string &interfaceBlockName) const;
|
||||
|
||||
bool hasUniform(const std::string &uniformName) const;
|
||||
unsigned int getUniformRegister(const std::string &uniformName) const;
|
||||
|
||||
protected:
|
||||
virtual void translate(TIntermNode* root);
|
||||
|
||||
sh::ActiveUniforms mActiveUniforms;
|
||||
ShShaderOutput mOutputType;
|
||||
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
|
||||
std::map<std::string, unsigned int> mUniformRegisterMap;
|
||||
};
|
||||
|
||||
#endif // COMPILER_TRANSLATORHLSL_H_
|
||||
|
202
src/3rdparty/angle/src/compiler/translator/Types.cpp
vendored
Normal file
202
src/3rdparty/angle/src/compiler/translator/Types.cpp
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
//
|
||||
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4718)
|
||||
#endif
|
||||
|
||||
#include "compiler/translator/Types.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
TType::TType(const TPublicType &p)
|
||||
: type(p.type), precision(p.precision), qualifier(p.qualifier), layoutQualifier(p.layoutQualifier),
|
||||
primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), arraySize(p.arraySize),
|
||||
interfaceBlock(0), structure(0)
|
||||
{
|
||||
if (p.userDef)
|
||||
structure = p.userDef->getStruct();
|
||||
}
|
||||
|
||||
bool TStructure::equals(const TStructure &other) const
|
||||
{
|
||||
return (uniqueId() == other.uniqueId());
|
||||
}
|
||||
|
||||
//
|
||||
// Recursively generate mangled names.
|
||||
//
|
||||
TString TType::buildMangledName() const
|
||||
{
|
||||
TString mangledName;
|
||||
if (isMatrix())
|
||||
mangledName += 'm';
|
||||
else if (isVector())
|
||||
mangledName += 'v';
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EbtFloat:
|
||||
mangledName += 'f';
|
||||
break;
|
||||
case EbtInt:
|
||||
mangledName += 'i';
|
||||
break;
|
||||
case EbtUInt:
|
||||
mangledName += 'u';
|
||||
break;
|
||||
case EbtBool:
|
||||
mangledName += 'b';
|
||||
break;
|
||||
case EbtSampler2D:
|
||||
mangledName += "s2";
|
||||
break;
|
||||
case EbtSampler3D:
|
||||
mangledName += "s3";
|
||||
break;
|
||||
case EbtSamplerCube:
|
||||
mangledName += "sC";
|
||||
break;
|
||||
case EbtSampler2DArray:
|
||||
mangledName += "s2a";
|
||||
break;
|
||||
case EbtSamplerExternalOES:
|
||||
mangledName += "sext";
|
||||
break;
|
||||
case EbtSampler2DRect:
|
||||
mangledName += "s2r";
|
||||
break;
|
||||
case EbtISampler2D:
|
||||
mangledName += "is2";
|
||||
break;
|
||||
case EbtISampler3D:
|
||||
mangledName += "is3";
|
||||
break;
|
||||
case EbtISamplerCube:
|
||||
mangledName += "isC";
|
||||
break;
|
||||
case EbtISampler2DArray:
|
||||
mangledName += "is2a";
|
||||
break;
|
||||
case EbtUSampler2D:
|
||||
mangledName += "us2";
|
||||
break;
|
||||
case EbtUSampler3D:
|
||||
mangledName += "us3";
|
||||
break;
|
||||
case EbtUSamplerCube:
|
||||
mangledName += "usC";
|
||||
break;
|
||||
case EbtUSampler2DArray:
|
||||
mangledName += "us2a";
|
||||
break;
|
||||
case EbtSampler2DShadow:
|
||||
mangledName += "s2s";
|
||||
break;
|
||||
case EbtSamplerCubeShadow:
|
||||
mangledName += "sCs";
|
||||
break;
|
||||
case EbtSampler2DArrayShadow:
|
||||
mangledName += "s2as";
|
||||
break;
|
||||
case EbtStruct:
|
||||
mangledName += structure->mangledName();
|
||||
break;
|
||||
case EbtInterfaceBlock:
|
||||
mangledName += interfaceBlock->mangledName();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
if (isMatrix())
|
||||
{
|
||||
mangledName += static_cast<char>('0' + getCols());
|
||||
mangledName += static_cast<char>('x');
|
||||
mangledName += static_cast<char>('0' + getRows());
|
||||
}
|
||||
else
|
||||
{
|
||||
mangledName += static_cast<char>('0' + getNominalSize());
|
||||
}
|
||||
|
||||
if (isArray())
|
||||
{
|
||||
char buf[20];
|
||||
snprintf(buf, sizeof(buf), "%d", arraySize);
|
||||
mangledName += '[';
|
||||
mangledName += buf;
|
||||
mangledName += ']';
|
||||
}
|
||||
return mangledName;
|
||||
}
|
||||
|
||||
size_t TType::getObjectSize() const
|
||||
{
|
||||
size_t totalSize;
|
||||
|
||||
if (getBasicType() == EbtStruct)
|
||||
totalSize = structure->objectSize();
|
||||
else
|
||||
totalSize = primarySize * secondarySize;
|
||||
|
||||
if (isArray())
|
||||
{
|
||||
size_t arraySize = getArraySize();
|
||||
if (arraySize > INT_MAX / totalSize)
|
||||
totalSize = INT_MAX;
|
||||
else
|
||||
totalSize *= arraySize;
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
bool TStructure::containsArrays() const
|
||||
{
|
||||
for (size_t i = 0; i < mFields->size(); ++i)
|
||||
{
|
||||
const TType *fieldType = (*mFields)[i]->type();
|
||||
if (fieldType->isArray() || fieldType->isStructureContainingArrays())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TString TFieldListCollection::buildMangledName() const
|
||||
{
|
||||
TString mangledName(mangledNamePrefix());
|
||||
mangledName += *mName;
|
||||
for (size_t i = 0; i < mFields->size(); ++i)
|
||||
{
|
||||
mangledName += '-';
|
||||
mangledName += (*mFields)[i]->type()->getMangledName();
|
||||
}
|
||||
return mangledName;
|
||||
}
|
||||
|
||||
size_t TFieldListCollection::calculateObjectSize() const
|
||||
{
|
||||
size_t size = 0;
|
||||
for (size_t i = 0; i < mFields->size(); ++i)
|
||||
{
|
||||
size_t fieldSize = (*mFields)[i]->type()->getObjectSize();
|
||||
if (fieldSize > INT_MAX - size)
|
||||
size = INT_MAX;
|
||||
else
|
||||
size += fieldSize;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int TStructure::calculateDeepestNesting() const
|
||||
{
|
||||
int maxNesting = 0;
|
||||
for (size_t i = 0; i < mFields->size(); ++i)
|
||||
maxNesting = std::max(maxNesting, (*mFields)[i]->type()->getDeepestStructNesting());
|
||||
return 1 + maxNesting;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user