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:
Andrew Knight 2014-08-05 12:59:44 +03:00
parent 14f9c09542
commit a6a12d8c0f
402 changed files with 67012 additions and 35010 deletions

View File

@ -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

View File

@ -52,6 +52,9 @@ Autodesk, Inc.
Cloud Party, Inc.
Conor Dickinson
Digia Plc
Andrew Knight
Intel Corporation
Jin Yang
Andy Chen

View File

@ -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,304 +27,272 @@
** 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) $
*/
#ifndef __egl_h_
#define __egl_h_
/* All platform-dependent types and macro boilerplate (such as EGLAPI
* and EGLAPIENTRY) should go in eglplatform.h.
*/
#include <EGL/eglplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Generated on date 20140610 */
/* EGL Types */
/* EGLint is defined in eglplatform.h */
/* Generated C header for:
* API: egl
* Versions considered: .*
* Versions emitted: .*
* Default extensions included: None
* Additional extensions included: _nomatch_^
* Extensions removed: _nomatch_^
*/
#ifndef EGL_VERSION_1_0
#define EGL_VERSION_1_0 1
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
#include <KHR/khrplatform.h>
#include <EGL/eglplatform.h>
typedef void *EGLConfig;
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.
*/
/* 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
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#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_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#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_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);
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 EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value);
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);
/* 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 *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
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_BLUE_SIZE 0x3022
#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
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#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_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_TRANSPARENT_RGB 0x3052
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRUE 1
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_WIDTH 0x3057
#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 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 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);
#endif /* EGL_VERSION_1_0 */
/* Now, define eglGetProcAddress using the generic function ptr. type */
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname);
#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 */
#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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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);

View File

@ -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,53 +321,49 @@ typedef void* GLeglImageOES;
#define GL_MAX_SAMPLES_ANGLE 0x8D57
#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_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#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
#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
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
#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_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
#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB
@ -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,55 +1288,62 @@ 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
#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
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_ANGLE_texture_compression_dxt3 1
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_ANGLE_texture_compression_dxt5 1
#endif
/* GL_ANGLE_translated_shader_source */
#ifndef GL_ANGLE_translated_shader_source
#define GL_ANGLE_translated_shader_source 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
#endif
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
#endif
/* GL_ANGLE_texture_usage */
#ifndef 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
#ifndef GL_ANGLE_translated_shader_source
#define GL_ANGLE_translated_shader_source 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);
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#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);
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#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

File diff suppressed because it is too large Load Diff

View 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_ */

View 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_ */

View File

@ -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 everytime 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;
// It is incremented every time the API changes.
#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,
@ -116,19 +88,26 @@ typedef enum {
} ShPrecisionType;
typedef enum {
SH_INFO_LOG_LENGTH = 0x8B84,
SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH
SH_ACTIVE_UNIFORMS = 0x8B86,
SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
SH_ACTIVE_ATTRIBUTES = 0x8B89,
SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
SH_VARYINGS = 0x8BBB,
SH_VARYING_MAX_LENGTH = 0x8BBC,
SH_MAPPED_NAME_MAX_LENGTH = 0x6000,
SH_NAME_MAX_LENGTH = 0x6001,
SH_HASHED_NAME_MAX_LENGTH = 0x6002,
SH_HASHED_NAMES_COUNT = 0x6003,
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004
SH_INFO_LOG_LENGTH = 0x8B84,
SH_OBJECT_CODE_LENGTH = 0x8B88, // GL_SHADER_SOURCE_LENGTH
SH_ACTIVE_UNIFORMS = 0x8B86,
SH_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
SH_ACTIVE_ATTRIBUTES = 0x8B89,
SH_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
SH_VARYINGS = 0x8BBB,
SH_VARYING_MAX_LENGTH = 0x8BBC,
SH_MAPPED_NAME_MAX_LENGTH = 0x6000,
SH_NAME_MAX_LENGTH = 0x6001,
SH_HASHED_NAME_MAX_LENGTH = 0x6002,
SH_HASHED_NAMES_COUNT = 0x6003,
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,13 +119,17 @@ 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,
// This is an experimental flag to enforce restrictions that aim to prevent
// This is an experimental flag to enforce restrictions that aim to prevent
// timing attacks.
// It generates compilation errors for shaders that could expose sensitive
// texture information via the timing channel.
@ -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
View 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_

View File

@ -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"

View File

@ -14,8 +14,7 @@
#include <cstddef>
#define GL_APICALL
#include <GLES2/gl2.h>
#include "angle_gl.h"
#include "common/debug.h"
@ -47,7 +46,7 @@ class RefCountObjectBindingPointer
public:
GLuint id() const { return (mObject != NULL) ? mObject->id() : 0; }
bool operator ! () const { return (get() == NULL); }
bool operator!() const { return (get() == NULL); }
private:
RefCountObject *mObject;
@ -59,7 +58,38 @@ class BindingPointer : public RefCountObjectBindingPointer
public:
void set(ObjectType *newObject) { RefCountObjectBindingPointer::set(newObject); }
ObjectType *get() const { return static_cast<ObjectType*>(RefCountObjectBindingPointer::get()); }
ObjectType *operator -> () const { return get(); }
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_

View File

@ -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_

View 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);
}
}

View 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_

View File

@ -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
}

View File

@ -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_

View File

@ -15,7 +15,7 @@ AddTraceEventFunc g_addTraceEvent;
extern "C" {
void TRACE_ENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc getCategoryEnabledFlag,
AddTraceEventFunc addTraceEvent)
AddTraceEventFunc addTraceEvent)
{
gl::g_getCategoryEnabledFlag = getCategoryEnabledFlag;
gl::g_addTraceEvent = addTraceEvent;

View File

@ -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)
#define TRACE_ENTRY __stdcall
#else
#define TRACE_ENTRY
#endif // // _WIN32
# ifdef ANGLE_PLATFORM_WINDOWS
# define TRACE_ENTRY __stdcall
# else
# define TRACE_ENTRY
# endif // ANGLE_PLATFORM_WINDOWS
#endif //TRACE_ENTRY
extern "C" {

View 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
View 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_

View 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_

View 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
View 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
View 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_

View 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);
}

View 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

View File

@ -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)

View File

@ -16,8 +16,8 @@ Diagnostics::~Diagnostics()
}
void Diagnostics::report(ID id,
const SourceLocation& loc,
const std::string& text)
const SourceLocation &loc,
const std::string &text)
{
// TODO(alokp): Keep a count of errors and warnings.
print(id, loc, text);
@ -41,86 +41,86 @@ std::string Diagnostics::message(ID id)
{
// Errors begin.
case PP_INTERNAL_ERROR:
return "internal error";
return "internal error";
case PP_OUT_OF_MEMORY:
return "out of memory";
return "out of memory";
case PP_INVALID_CHARACTER:
return "invalid character";
return "invalid character";
case PP_INVALID_NUMBER:
return "invalid number";
return "invalid number";
case PP_INTEGER_OVERFLOW:
return "integer overflow";
return "integer overflow";
case PP_FLOAT_OVERFLOW:
return "float overflow";
return "float overflow";
case PP_TOKEN_TOO_LONG:
return "token too long";
return "token too long";
case PP_INVALID_EXPRESSION:
return "invalid expression";
return "invalid expression";
case PP_DIVISION_BY_ZERO:
return "division by zero";
return "division by zero";
case PP_EOF_IN_COMMENT:
return "unexpected end of file found in comment";
return "unexpected end of file found in comment";
case PP_UNEXPECTED_TOKEN:
return "unexpected token";
return "unexpected token";
case PP_DIRECTIVE_INVALID_NAME:
return "invalid directive name";
return "invalid directive name";
case PP_MACRO_NAME_RESERVED:
return "macro name is reserved";
return "macro name is reserved";
case PP_MACRO_REDEFINED:
return "macro redefined";
return "macro redefined";
case PP_MACRO_PREDEFINED_REDEFINED:
return "predefined macro redefined";
return "predefined macro redefined";
case PP_MACRO_PREDEFINED_UNDEFINED:
return "predefined macro undefined";
return "predefined macro undefined";
case PP_MACRO_UNTERMINATED_INVOCATION:
return "unterminated macro invocation";
return "unterminated macro invocation";
case PP_MACRO_TOO_FEW_ARGS:
return "Not enough arguments for macro";
return "Not enough arguments for macro";
case PP_MACRO_TOO_MANY_ARGS:
return "Too many arguments for macro";
return "Too many arguments for macro";
case PP_CONDITIONAL_ENDIF_WITHOUT_IF:
return "unexpected #endif found without a matching #if";
return "unexpected #endif found without a matching #if";
case PP_CONDITIONAL_ELSE_WITHOUT_IF:
return "unexpected #else found without a matching #if";
return "unexpected #else found without a matching #if";
case PP_CONDITIONAL_ELSE_AFTER_ELSE:
return "unexpected #else found after another #else";
return "unexpected #else found after another #else";
case PP_CONDITIONAL_ELIF_WITHOUT_IF:
return "unexpected #elif found without a matching #if";
return "unexpected #elif found without a matching #if";
case PP_CONDITIONAL_ELIF_AFTER_ELSE:
return "unexpected #elif found after #else";
return "unexpected #elif found after #else";
case PP_CONDITIONAL_UNTERMINATED:
return "unexpected end of file found in conditional block";
return "unexpected end of file found in conditional block";
case PP_INVALID_EXTENSION_NAME:
return "invalid extension name";
return "invalid extension name";
case PP_INVALID_EXTENSION_BEHAVIOR:
return "invalid extension behavior";
return "invalid extension behavior";
case PP_INVALID_EXTENSION_DIRECTIVE:
return "invalid extension directive";
return "invalid extension directive";
case PP_INVALID_VERSION_NUMBER:
return "invalid version number";
return "invalid version number";
case PP_INVALID_VERSION_DIRECTIVE:
return "invalid version directive";
return "invalid version directive";
case PP_VERSION_NOT_FIRST_STATEMENT:
return "#version directive must occur before anything else, "
"except for comments and white space";
case PP_INVALID_LINE_NUMBER:
return "invalid line number";
return "invalid line number";
case PP_INVALID_FILE_NUMBER:
return "invalid file number";
return "invalid file number";
case PP_INVALID_LINE_DIRECTIVE:
return "invalid line directive";
return "invalid line directive";
// Errors end.
// Warnings begin.
case PP_EOF_IN_DIRECTIVE:
return "unexpected end of file found in directive";
return "unexpected end of file found in directive";
case PP_CONDITIONAL_UNEXPECTED_TOKEN:
return "unexpected token after conditional expression";
return "unexpected token after conditional expression";
case PP_UNRECOGNIZED_PRAGMA:
return "unrecognized pragma";
return "unrecognized pragma";
// Warnings end.
default:
assert(false);
return "";
assert(false);
return "";
}
}

View File

@ -72,15 +72,15 @@ class Diagnostics
virtual ~Diagnostics();
void report(ID id, const SourceLocation& loc, const std::string& text);
void report(ID id, const SourceLocation &loc, const std::string &text);
protected:
Severity severity(ID id);
std::string message(ID id);
virtual void print(ID id,
const SourceLocation& loc,
const std::string& text) = 0;
const SourceLocation &loc,
const std::string &text) = 0;
};
} // namespace pp

View File

@ -23,19 +23,19 @@ class DirectiveHandler
public:
virtual ~DirectiveHandler();
virtual void handleError(const SourceLocation& loc,
const std::string& msg) = 0;
virtual void handleError(const SourceLocation &loc,
const std::string &msg) = 0;
// Handle pragma of form: #pragma name[(value)]
virtual void handlePragma(const SourceLocation& loc,
const std::string& name,
const std::string& value) = 0;
virtual void handlePragma(const SourceLocation &loc,
const std::string &name,
const std::string &value) = 0;
virtual void handleExtension(const SourceLocation& loc,
const std::string& name,
const std::string& behavior) = 0;
virtual void handleExtension(const SourceLocation &loc,
const std::string &name,
const std::string &behavior) = 0;
virtual void handleVersion(const SourceLocation& loc,
virtual void handleVersion(const SourceLocation &loc,
int version) = 0;
};

View File

@ -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,30 +128,32 @@ static bool isMacroNameReserved(const std::string& name)
return false;
}
static bool isMacroPredefined(const std::string& name,
const pp::MacroSet& macroSet)
bool isMacroPredefined(const std::string &name,
const pp::MacroSet &macroSet)
{
pp::MacroSet::const_iterator iter = macroSet.find(name);
return iter != macroSet.end() ? iter->second.predefined : false;
}
} // namespace anonymous
namespace pp
{
class DefinedParser : public Lexer
{
public:
DefinedParser(Lexer* lexer,
const MacroSet* macroSet,
Diagnostics* diagnostics) :
mLexer(lexer),
mMacroSet(macroSet),
mDiagnostics(diagnostics)
DefinedParser(Lexer *lexer,
const MacroSet *macroSet,
Diagnostics *diagnostics)
: mLexer(lexer),
mMacroSet(macroSet),
mDiagnostics(diagnostics)
{
}
protected:
virtual void lex(Token* token)
virtual void lex(Token *token)
{
static const std::string kDefined("defined");
@ -199,24 +200,24 @@ class DefinedParser : public Lexer
}
private:
Lexer* mLexer;
const MacroSet* mMacroSet;
Diagnostics* mDiagnostics;
Lexer *mLexer;
const MacroSet *mMacroSet;
Diagnostics *mDiagnostics;
};
DirectiveParser::DirectiveParser(Tokenizer* tokenizer,
MacroSet* macroSet,
Diagnostics* diagnostics,
DirectiveHandler* directiveHandler) :
mPastFirstStatement(false),
mTokenizer(tokenizer),
mMacroSet(macroSet),
mDiagnostics(diagnostics),
mDirectiveHandler(directiveHandler)
DirectiveParser::DirectiveParser(Tokenizer *tokenizer,
MacroSet *macroSet,
Diagnostics *diagnostics,
DirectiveHandler *directiveHandler)
: mPastFirstStatement(false),
mTokenizer(tokenizer),
mMacroSet(macroSet),
mDiagnostics(diagnostics),
mDirectiveHandler(directiveHandler)
{
}
void DirectiveParser::lex(Token* token)
void DirectiveParser::lex(Token *token)
{
do
{
@ -232,19 +233,20 @@ void DirectiveParser::lex(Token* token)
{
if (!mConditionalStack.empty())
{
const ConditionalBlock& block = mConditionalStack.back();
const ConditionalBlock &block = mConditionalStack.back();
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED,
block.location, block.type);
}
break;
}
} while (skipping() || (token->type == '\n'));
}
while (skipping() || (token->type == '\n'));
mPastFirstStatement = true;
}
void DirectiveParser::parseDirective(Token* token)
void DirectiveParser::parseDirective(Token *token)
{
assert(token->type == Token::PP_HASH);
@ -324,7 +326,7 @@ void DirectiveParser::parseDirective(Token* token)
}
}
void DirectiveParser::parseDefine(Token* token)
void DirectiveParser::parseDefine(Token *token)
{
assert(getDirective(token) == DIRECTIVE_DEFINE);
@ -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 != ')')
{
@ -404,7 +408,7 @@ void DirectiveParser::parseDefine(Token* token)
mMacroSet->insert(std::make_pair(macro.name, macro));
}
void DirectiveParser::parseUndef(Token* token)
void DirectiveParser::parseUndef(Token *token)
{
assert(getDirective(token) == DIRECTIVE_UNDEF);
@ -433,25 +437,25 @@ void DirectiveParser::parseUndef(Token* token)
mTokenizer->lex(token);
}
void DirectiveParser::parseIf(Token* token)
void DirectiveParser::parseIf(Token *token)
{
assert(getDirective(token) == DIRECTIVE_IF);
parseConditionalIf(token);
}
void DirectiveParser::parseIfdef(Token* token)
void DirectiveParser::parseIfdef(Token *token)
{
assert(getDirective(token) == DIRECTIVE_IFDEF);
parseConditionalIf(token);
}
void DirectiveParser::parseIfndef(Token* token)
void DirectiveParser::parseIfndef(Token *token)
{
assert(getDirective(token) == DIRECTIVE_IFNDEF);
parseConditionalIf(token);
}
void DirectiveParser::parseElse(Token* token)
void DirectiveParser::parseElse(Token *token)
{
assert(getDirective(token) == DIRECTIVE_ELSE);
@ -463,7 +467,7 @@ void DirectiveParser::parseElse(Token* token)
return;
}
ConditionalBlock& block = mConditionalStack.back();
ConditionalBlock &block = mConditionalStack.back();
if (block.skipBlock)
{
// No diagnostics. Just skip the whole line.
@ -492,7 +496,7 @@ void DirectiveParser::parseElse(Token* token)
}
}
void DirectiveParser::parseElif(Token* token)
void DirectiveParser::parseElif(Token *token)
{
assert(getDirective(token) == DIRECTIVE_ELIF);
@ -504,7 +508,7 @@ void DirectiveParser::parseElif(Token* token)
return;
}
ConditionalBlock& block = mConditionalStack.back();
ConditionalBlock &block = mConditionalStack.back();
if (block.skipBlock)
{
// No diagnostics. Just skip the whole line.
@ -532,7 +536,7 @@ void DirectiveParser::parseElif(Token* token)
block.foundValidGroup = expression != 0;
}
void DirectiveParser::parseEndif(Token* token)
void DirectiveParser::parseEndif(Token *token)
{
assert(getDirective(token) == DIRECTIVE_ENDIF);
@ -556,7 +560,7 @@ void DirectiveParser::parseEndif(Token* token)
}
}
void DirectiveParser::parseError(Token* token)
void DirectiveParser::parseError(Token *token)
{
assert(getDirective(token) == DIRECTIVE_ERROR);
@ -571,7 +575,7 @@ void DirectiveParser::parseError(Token* token)
}
// Parses pragma of form: #pragma name[(value)].
void DirectiveParser::parsePragma(Token* token)
void DirectiveParser::parsePragma(Token *token)
{
assert(getDirective(token) == DIRECTIVE_PRAGMA);
@ -627,7 +631,7 @@ void DirectiveParser::parsePragma(Token* token)
}
}
void DirectiveParser::parseExtension(Token* token)
void DirectiveParser::parseExtension(Token *token)
{
assert(getDirective(token) == DIRECTIVE_EXTENSION);
@ -694,7 +698,7 @@ void DirectiveParser::parseExtension(Token* token)
mDirectiveHandler->handleExtension(token->location, name, behavior);
}
void DirectiveParser::parseVersion(Token* token)
void DirectiveParser::parseVersion(Token *token)
{
assert(getDirective(token) == DIRECTIVE_VERSION);
@ -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,29 +739,44 @@ void DirectiveParser::parseVersion(Token* token)
token->location, token->text);
valid = false;
}
break;
default:
if (valid)
{
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
state = (version < 300) ? VERSION_ENDLINE : VERSION_PROFILE;
}
break;
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_NUMBER + 1))
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)
void DirectiveParser::parseLine(Token *token)
{
assert(getDirective(token) == DIRECTIVE_LINE);
@ -824,19 +845,21 @@ 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;
}
void DirectiveParser::parseConditionalIf(Token* token)
void DirectiveParser::parseConditionalIf(Token *token)
{
ConditionalBlock block;
block.type = token->text;
@ -877,7 +900,7 @@ void DirectiveParser::parseConditionalIf(Token* token)
mConditionalStack.push_back(block);
}
int DirectiveParser::parseExpressionIf(Token* token)
int DirectiveParser::parseExpressionIf(Token *token)
{
assert((getDirective(token) == DIRECTIVE_IF) ||
(getDirective(token) == DIRECTIVE_ELIF));
@ -901,7 +924,7 @@ int DirectiveParser::parseExpressionIf(Token* token)
return expression;
}
int DirectiveParser::parseExpressionIfdef(Token* token)
int DirectiveParser::parseExpressionIfdef(Token *token)
{
assert((getDirective(token) == DIRECTIVE_IFDEF) ||
(getDirective(token) == DIRECTIVE_IFNDEF));

View File

@ -22,35 +22,35 @@ class Tokenizer;
class DirectiveParser : public Lexer
{
public:
DirectiveParser(Tokenizer* tokenizer,
MacroSet* macroSet,
Diagnostics* diagnostics,
DirectiveHandler* directiveHandler);
DirectiveParser(Tokenizer *tokenizer,
MacroSet *macroSet,
Diagnostics *diagnostics,
DirectiveHandler *directiveHandler);
virtual void lex(Token* token);
virtual void lex(Token *token);
private:
PP_DISALLOW_COPY_AND_ASSIGN(DirectiveParser);
void parseDirective(Token* token);
void parseDefine(Token* token);
void parseUndef(Token* token);
void parseIf(Token* token);
void parseIfdef(Token* token);
void parseIfndef(Token* token);
void parseElse(Token* token);
void parseElif(Token* token);
void parseEndif(Token* token);
void parseError(Token* token);
void parsePragma(Token* token);
void parseExtension(Token* token);
void parseVersion(Token* token);
void parseLine(Token* token);
void parseDirective(Token *token);
void parseDefine(Token *token);
void parseUndef(Token *token);
void parseIf(Token *token);
void parseIfdef(Token *token);
void parseIfndef(Token *token);
void parseElse(Token *token);
void parseElif(Token *token);
void parseEndif(Token *token);
void parseError(Token *token);
void parsePragma(Token *token);
void parseExtension(Token *token);
void parseVersion(Token *token);
void parseLine(Token *token);
bool skipping() const;
void parseConditionalIf(Token* token);
int parseExpressionIf(Token* token);
int parseExpressionIfdef(Token* token);
void parseConditionalIf(Token *token);
int parseExpressionIf(Token *token);
int parseExpressionIfdef(Token *token);
struct ConditionalBlock
{
@ -61,20 +61,20 @@ class DirectiveParser : public Lexer
bool foundValidGroup;
bool foundElseGroup;
ConditionalBlock() :
skipBlock(false),
skipGroup(false),
foundValidGroup(false),
foundElseGroup(false)
ConditionalBlock()
: skipBlock(false),
skipGroup(false),
foundValidGroup(false),
foundElseGroup(false)
{
}
};
bool mPastFirstStatement;
std::vector<ConditionalBlock> mConditionalStack;
Tokenizer* mTokenizer;
MacroSet* mMacroSet;
Diagnostics* mDiagnostics;
DirectiveHandler* mDirectiveHandler;
Tokenizer *mTokenizer;
MacroSet *mMacroSet;
Diagnostics *mDiagnostics;
DirectiveHandler *mDirectiveHandler;
};
} // namespace pp

View File

@ -19,15 +19,15 @@ struct Token;
class ExpressionParser
{
public:
ExpressionParser(Lexer* lexer, Diagnostics* diagnostics);
ExpressionParser(Lexer *lexer, Diagnostics *diagnostics);
bool parse(Token* token, int* result);
bool parse(Token *token, int *result);
private:
PP_DISALLOW_COPY_AND_ASSIGN(ExpressionParser);
Lexer* mLexer;
Diagnostics* mDiagnostics;
Lexer *mLexer;
Diagnostics *mDiagnostics;
};
} // namespace pp

View File

@ -195,15 +195,14 @@ expression
%%
int yylex(YYSTYPE* lvalp, Context* context)
int yylex(YYSTYPE *lvalp, Context *context)
{
int type = 0;
pp::Token* token = context->token;
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,39 +213,59 @@ 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;
}
void yyerror(Context* context, const char* reason)
void yyerror(Context *context, const char *reason)
{
context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
context->token->location,
@ -255,13 +274,13 @@ void yyerror(Context* context, const char* reason)
namespace pp {
ExpressionParser::ExpressionParser(Lexer* lexer, Diagnostics* diagnostics) :
mLexer(lexer),
mDiagnostics(diagnostics)
ExpressionParser::ExpressionParser(Lexer *lexer, Diagnostics *diagnostics)
: mLexer(lexer),
mDiagnostics(diagnostics)
{
}
bool ExpressionParser::parse(Token* token, int* result)
bool ExpressionParser::parse(Token *token, int *result)
{
Context context;
context.diagnostics = mDiagnostics;

View File

@ -17,7 +17,7 @@ Input::Input() : mCount(0), mString(0)
{
}
Input::Input(size_t count, const char* const string[], const int length[]) :
Input::Input(size_t count, const char *const string[], const int length[]) :
mCount(count),
mString(string)
{
@ -29,7 +29,7 @@ Input::Input(size_t count, const char* const string[], const int length[]) :
}
}
size_t Input::read(char* buf, size_t maxSize)
size_t Input::read(char *buf, size_t maxSize)
{
size_t nRead = 0;
while ((nRead < maxSize) && (mReadLoc.sIndex < mCount))

View File

@ -18,27 +18,40 @@ class Input
{
public:
Input();
Input(size_t count, const char* const string[], const int length[]);
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);
size_t read(char *buf, size_t maxSize);
struct Location
{
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; }
const Location &readLoc() const { return mReadLoc; }
private:
// Input.
size_t mCount;
const char* const* mString;
const char * const *mString;
std::vector<size_t> mLength;
Location mReadLoc;

View File

@ -17,7 +17,7 @@ class Lexer
public:
virtual ~Lexer();
virtual void lex(Token* token) = 0;
virtual void lex(Token *token) = 0;
};
} // namespace pp

View File

@ -11,7 +11,7 @@
namespace pp
{
bool Macro::equals(const Macro& other) const
bool Macro::equals(const Macro &other) const
{
return (type == other.type) &&
(name == other.name) &&

View File

@ -26,8 +26,13 @@ struct Macro
typedef std::vector<std::string> Parameters;
typedef std::vector<Token> Replacements;
Macro() : predefined(false), disabled(false), type(kTypeObj) { }
bool equals(const Macro& other) const;
Macro()
: predefined(false),
disabled(false),
type(kTypeObj)
{
}
bool equals(const Macro &other) const;
bool predefined;
mutable bool disabled;

View File

@ -20,13 +20,13 @@ class TokenLexer : public Lexer
public:
typedef std::vector<Token> TokenVector;
TokenLexer(TokenVector* tokens)
TokenLexer(TokenVector *tokens)
{
tokens->swap(mTokens);
mIter = mTokens.begin();
}
virtual void lex(Token* token)
virtual void lex(Token *token)
{
if (mIter == mTokens.end())
{
@ -46,12 +46,12 @@ class TokenLexer : public Lexer
TokenVector::const_iterator mIter;
};
MacroExpander::MacroExpander(Lexer* lexer,
MacroSet* macroSet,
Diagnostics* diagnostics) :
mLexer(lexer),
mMacroSet(macroSet),
mDiagnostics(diagnostics)
MacroExpander::MacroExpander(Lexer *lexer,
MacroSet *macroSet,
Diagnostics *diagnostics)
: mLexer(lexer),
mMacroSet(macroSet),
mDiagnostics(diagnostics)
{
}
@ -63,7 +63,7 @@ MacroExpander::~MacroExpander()
}
}
void MacroExpander::lex(Token* token)
void MacroExpander::lex(Token *token)
{
while (true)
{
@ -97,7 +97,7 @@ void MacroExpander::lex(Token* token)
}
}
void MacroExpander::getToken(Token* token)
void MacroExpander::getToken(Token *token)
{
if (mReserveToken.get())
{
@ -122,11 +122,11 @@ void MacroExpander::getToken(Token* token)
}
}
void MacroExpander::ungetToken(const Token& token)
void MacroExpander::ungetToken(const Token &token)
{
if (!mContextStack.empty())
{
MacroContext* context = mContextStack.back();
MacroContext *context = mContextStack.back();
context->unget();
assert(context->replacements[context->index] == token);
}
@ -148,7 +148,7 @@ bool MacroExpander::isNextTokenLeftParen()
return lparen;
}
bool MacroExpander::pushMacro(const Macro& macro, const Token& identifier)
bool MacroExpander::pushMacro(const Macro &macro, const Token &identifier)
{
assert(!macro.disabled);
assert(!identifier.expansionDisabled());
@ -162,7 +162,7 @@ bool MacroExpander::pushMacro(const Macro& macro, const Token& identifier)
// Macro is disabled for expansion until it is popped off the stack.
macro.disabled = true;
MacroContext* context = new MacroContext;
MacroContext *context = new MacroContext;
context->macro = &macro;
context->replacements.swap(replacements);
mContextStack.push_back(context);
@ -173,7 +173,7 @@ void MacroExpander::popMacro()
{
assert(!mContextStack.empty());
MacroContext* context = mContextStack.back();
MacroContext *context = mContextStack.back();
mContextStack.pop_back();
assert(context->empty());
@ -182,9 +182,9 @@ void MacroExpander::popMacro()
delete context;
}
bool MacroExpander::expandMacro(const Macro& macro,
const Token& identifier,
std::vector<Token>* replacements)
bool MacroExpander::expandMacro(const Macro &macro,
const Token &identifier,
std::vector<Token> *replacements)
{
replacements->clear();
if (macro.type == Macro::kTypeObj)
@ -239,9 +239,9 @@ bool MacroExpander::expandMacro(const Macro& macro,
return true;
}
bool MacroExpander::collectMacroArgs(const Macro& macro,
const Token& identifier,
std::vector<MacroArg>* args)
bool MacroExpander::collectMacroArgs(const Macro &macro,
const Token &identifier,
std::vector<MacroArg> *args)
{
Token token;
getToken(&token);
@ -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:
@ -285,14 +286,15 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
}
if (isArg)
{
MacroArg& arg = args->back();
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);
}
}
const Macro::Parameters& params = macro.parameters;
const Macro::Parameters &params = macro.parameters;
// If there is only one empty argument, it is equivalent to no argument.
if (params.empty() && (args->size() == 1) && args->front().empty())
{
@ -313,7 +315,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
// inserted into the macro body.
for (std::size_t i = 0; i < args->size(); ++i)
{
MacroArg& arg = args->at(i);
MacroArg &arg = args->at(i);
TokenLexer lexer(&arg);
MacroExpander expander(&lexer, mMacroSet, mDiagnostics);
@ -328,13 +330,13 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
return true;
}
void MacroExpander::replaceMacroParams(const Macro& macro,
const std::vector<MacroArg>& args,
std::vector<Token>* replacements)
void MacroExpander::replaceMacroParams(const Macro &macro,
const std::vector<MacroArg> &args,
std::vector<Token> *replacements)
{
for (std::size_t i = 0; i < macro.replacements.size(); ++i)
{
const Token& repl = macro.replacements[i];
const Token &repl = macro.replacements[i];
if (repl.type != Token::IDENTIFIER)
{
replacements->push_back(repl);
@ -353,7 +355,7 @@ void MacroExpander::replaceMacroParams(const Macro& macro,
}
std::size_t iArg = std::distance(macro.parameters.begin(), iter);
const MacroArg& arg = args[iArg];
const MacroArg &arg = args[iArg];
if (arg.empty())
{
continue;

View File

@ -23,51 +23,65 @@ class Diagnostics;
class MacroExpander : public Lexer
{
public:
MacroExpander(Lexer* lexer, MacroSet* macroSet, Diagnostics* diagnostics);
MacroExpander(Lexer *lexer, MacroSet *macroSet, Diagnostics *diagnostics);
virtual ~MacroExpander();
virtual void lex(Token* token);
virtual void lex(Token *token);
private:
PP_DISALLOW_COPY_AND_ASSIGN(MacroExpander);
void getToken(Token* token);
void ungetToken(const Token& token);
void getToken(Token *token);
void ungetToken(const Token &token);
bool isNextTokenLeftParen();
bool pushMacro(const Macro& macro, const Token& identifier);
bool pushMacro(const Macro &macro, const Token &identifier);
void popMacro();
bool expandMacro(const Macro& macro,
const Token& identifier,
std::vector<Token>* replacements);
bool expandMacro(const Macro &macro,
const Token &identifier,
std::vector<Token> *replacements);
typedef std::vector<Token> MacroArg;
bool collectMacroArgs(const Macro& macro,
const Token& identifier,
std::vector<MacroArg>* args);
void replaceMacroParams(const Macro& macro,
const std::vector<MacroArg>& args,
std::vector<Token>* replacements);
bool collectMacroArgs(const Macro &macro,
const Token &identifier,
std::vector<MacroArg> *args);
void replaceMacroParams(const Macro &macro,
const std::vector<MacroArg> &args,
std::vector<Token> *replacements);
struct MacroContext
{
const Macro* macro;
const Macro *macro;
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;
MacroSet* mMacroSet;
Diagnostics* mDiagnostics;
Lexer *mLexer;
MacroSet *mMacroSet;
Diagnostics *mDiagnostics;
std::auto_ptr<Token> mReserveToken;
std::vector<MacroContext*> mContextStack;
std::vector<MacroContext *> mContextStack;
};
} // namespace pp

View File

@ -21,24 +21,24 @@ namespace pp
struct PreprocessorImpl
{
Diagnostics* diagnostics;
Diagnostics *diagnostics;
MacroSet macroSet;
Tokenizer tokenizer;
DirectiveParser directiveParser;
MacroExpander macroExpander;
PreprocessorImpl(Diagnostics* diag,
DirectiveHandler* directiveHandler) :
diagnostics(diag),
tokenizer(diag),
directiveParser(&tokenizer, &macroSet, diag, directiveHandler),
macroExpander(&directiveParser, &macroSet, diag)
PreprocessorImpl(Diagnostics *diag,
DirectiveHandler *directiveHandler)
: diagnostics(diag),
tokenizer(diag),
directiveParser(&tokenizer, &macroSet, diag, directiveHandler),
macroExpander(&directiveParser, &macroSet, diag)
{
}
};
Preprocessor::Preprocessor(Diagnostics* diagnostics,
DirectiveHandler* directiveHandler)
Preprocessor::Preprocessor(Diagnostics *diagnostics,
DirectiveHandler *directiveHandler)
{
mImpl = new PreprocessorImpl(diagnostics, directiveHandler);
}
@ -49,7 +49,7 @@ Preprocessor::~Preprocessor()
}
bool Preprocessor::init(size_t count,
const char* const string[],
const char * const string[],
const int length[])
{
static const int kGLSLVersion = 100;
@ -63,7 +63,7 @@ bool Preprocessor::init(size_t count,
return mImpl->tokenizer.init(count, string, length);
}
void Preprocessor::predefineMacro(const char* name, int value)
void Preprocessor::predefineMacro(const char *name, int value)
{
std::ostringstream stream;
stream << value;
@ -81,12 +81,7 @@ 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)
void Preprocessor::lex(Token *token)
{
bool validToken = false;
while (!validToken)
@ -115,5 +110,9 @@ void Preprocessor::lex(Token* token)
}
}
} // namespace pp
void Preprocessor::setMaxTokenSize(size_t maxTokenSize)
{
mImpl->tokenizer.setMaxTokenSize(maxTokenSize);
}
} // namespace pp

View File

@ -22,7 +22,7 @@ struct Token;
class Preprocessor
{
public:
Preprocessor(Diagnostics* diagnostics, DirectiveHandler* directiveHandler);
Preprocessor(Diagnostics *diagnostics, DirectiveHandler *directiveHandler);
~Preprocessor();
// count: specifies the number of elements in the string and length arrays.
@ -34,22 +34,19 @@ class Preprocessor
// Each element in the length array may contain the length of the
// corresponding string or a value less than 0 to indicate that the string
// is null terminated.
bool init(size_t count, const char* const string[], const int length[]);
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 predefineMacro(const char *name, int value);
void lex(Token* token);
void lex(Token *token);
// Set maximum preprocessor token size
void setMaxTokenSize(size_t maxTokenSize);
private:
PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
PreprocessorImpl* mImpl;
PreprocessorImpl *mImpl;
};
} // namespace pp

View File

@ -12,10 +12,18 @@ 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
bool equals(const SourceLocation &other) const
{
return (file == other.file) && (line == other.line);
}
@ -24,12 +32,12 @@ struct SourceLocation
int line;
};
inline bool operator==(const SourceLocation& lhs, const SourceLocation& rhs)
inline bool operator==(const SourceLocation &lhs, const SourceLocation &rhs)
{
return lhs.equals(rhs);
}
inline bool operator!=(const SourceLocation& lhs, const SourceLocation& rhs)
inline bool operator!=(const SourceLocation &lhs, const SourceLocation &rhs)
{
return !lhs.equals(rhs);
}

View File

@ -21,7 +21,7 @@ void Token::reset()
text.clear();
}
bool Token::equals(const Token& other) const
bool Token::equals(const Token &other) const
{
return (type == other.type) &&
(flags == other.flags) &&
@ -53,25 +53,25 @@ void Token::setExpansionDisabled(bool disable)
flags &= ~EXPANSION_DISABLED;
}
bool Token::iValue(int* value) const
bool Token::iValue(int *value) const
{
assert(type == CONST_INT);
return numeric_lex_int(text, value);
}
bool Token::uValue(unsigned int* value) const
bool Token::uValue(unsigned int *value) const
{
assert(type == CONST_INT);
return numeric_lex_int(text, value);
}
bool Token::fValue(float* value) const
bool Token::fValue(float *value) const
{
assert(type == CONST_FLOAT);
return numeric_lex_float(text, value);
}
std::ostream& operator<<(std::ostream& out, const Token& token)
std::ostream &operator<<(std::ostream &out, const Token &token)
{
if (token.hasLeadingSpace())
out << " ";

View File

@ -62,27 +62,40 @@ struct Token
EXPANSION_DISABLED = 1 << 2
};
Token() : type(0), flags(0) { }
Token()
: type(0),
flags(0)
{
}
void reset();
bool equals(const Token& other) const;
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.
// Returns false if the parsed value cannot fit into an int or float.
bool iValue(int* value) const;
bool uValue(unsigned int* value) const;
bool fValue(float* value) const;
bool iValue(int *value) const;
bool uValue(unsigned int *value) const;
bool fValue(float *value) const;
int type;
unsigned int flags;
@ -90,17 +103,17 @@ struct Token
std::string text;
};
inline bool operator==(const Token& lhs, const Token& rhs)
inline bool operator==(const Token &lhs, const Token &rhs)
{
return lhs.equals(rhs);
}
inline bool operator!=(const Token& lhs, const Token& rhs)
inline bool operator!=(const Token &lhs, const Token &rhs)
{
return !lhs.equals(rhs);
}
extern std::ostream& operator<<(std::ostream& out, const Token& token);
extern std::ostream &operator<<(std::ostream &out, const Token &token);
} // namepsace pp
#endif // COMPILER_PREPROCESSOR_TOKEN_H_

View File

@ -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.
//
@ -21,7 +21,7 @@ class Tokenizer : public Lexer
public:
struct Context
{
Diagnostics* diagnostics;
Diagnostics *diagnostics;
Input input;
// The location where yytext points to. Token location should track
@ -33,25 +33,25 @@ class Tokenizer : public Lexer
bool lineStart;
};
Tokenizer(Diagnostics* diagnostics);
Tokenizer(Diagnostics *diagnostics);
~Tokenizer();
bool init(size_t count, const char* const string[], const int length[]);
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);
virtual void lex(Token *token);
private:
PP_DISALLOW_COPY_AND_ASSIGN(Tokenizer);
bool initScanner();
void destroyScanner();
void* mHandle; // Scanner handle.
void *mHandle; // Scanner handle.
Context mContext; // Scanner extra.
size_t mMaxTokenLength;
size_t mMaxTokenSize; // Maximum token size
};
} // namespace pp

View File

@ -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;
}
@ -279,9 +277,10 @@ Tokenizer::~Tokenizer()
destroyScanner();
}
bool Tokenizer::init(size_t count, const char* const string[], const int length[])
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::lex(Token* token)
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;

View File

@ -13,7 +13,7 @@
namespace pp {
inline std::ios::fmtflags numeric_base_int(const std::string& str)
inline std::ios::fmtflags numeric_base_int(const std::string &str)
{
if ((str.size() >= 2) &&
(str[0] == '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;
}
@ -34,7 +34,7 @@ inline std::ios::fmtflags numeric_base_int(const std::string& str)
// in which case false is returned.
template<typename IntType>
bool numeric_lex_int(const std::string& str, IntType* value)
bool numeric_lex_int(const std::string &str, IntType *value)
{
std::istringstream stream(str);
// This should not be necessary, but MSVS has a buggy implementation.
@ -46,7 +46,7 @@ bool numeric_lex_int(const std::string& str, IntType* value)
}
template<typename FloatType>
bool numeric_lex_float(const std::string& str, FloatType* value)
bool numeric_lex_float(const std::string &str, FloatType *value)
{
std::istringstream stream(str);
// Force "C" locale so that decimal character is always '.', and

View File

@ -12,7 +12,7 @@
// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class.
#define PP_DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
TypeName(const TypeName &); \
void operator=(const TypeName &)
#endif // COMPILER_PREPROCESSOR_PPUTILS_H_

View File

@ -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,
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
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.
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
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
};
@ -54,16 +76,31 @@ inline const char* getBasicString(TBasicType t)
{
switch (t)
{
case EbtVoid: return "void"; break;
case EbtFloat: return "float"; break;
case EbtInt: return "int"; break;
case EbtBool: return "bool"; break;
case EbtSampler2D: return "sampler2D"; break;
case EbtSamplerCube: return "samplerCube"; break;
case EbtSamplerExternalOES: return "samplerExternalOES"; break;
case EbtSampler2DRect: return "sampler2DRect"; break;
case EbtStruct: return "structure"; break;
default: return "unknown type";
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;
@ -140,10 +419,53 @@ inline const char* getQualifierString(TQualifier q)
case EvqFragCoord: return "FragCoord"; break;
case EvqFrontFacing: return "FrontFacing"; break;
case EvqFragColor: return "FragColor"; break;
case EvqFragData: return "FragData"; break;
case EvqFragDepth: return "FragDepth"; 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_

View File

@ -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;

View File

@ -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.

View File

@ -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,17 +14,17 @@
// 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:
case SH_ESSL_OUTPUT:
return new TranslatorESSL(type, spec);
case SH_GLSL_OUTPUT:
case SH_GLSL_OUTPUT:
return new TranslatorGLSL(type, spec);
case SH_HLSL9_OUTPUT:
case SH_HLSL11_OUTPUT:
case SH_HLSL9_OUTPUT:
case SH_HLSL11_OUTPUT:
return new TranslatorHLSL(type, spec, output);
default:
default:
return NULL;
}
}

View File

@ -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,20 +431,20 @@ bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
return false;
}
if (shaderType == SH_FRAGMENT_SHADER)
if (shaderType == GL_FRAGMENT_SHADER)
{
TDependencyGraph graph(root);
// Output any errors first.
bool success = enforceFragmentShaderTimingRestrictions(graph);
// Then, output the dependency graph.
if (outputGraph)
{
TDependencyGraphOutput output(infoSink.info);
output.outputAllSpanningTrees(graph);
}
return success;
}
else
@ -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;

View File

@ -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 {
public:
TCompiler(ShShaderType type, ShShaderSpec spec);
class TCompiler : public TShHandleBase
{
public:
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; }
protected:
ShShaderType getShaderType() const { return shaderType; }
ShShaderSpec getShaderSpec() const { return shaderSpec; }
ShShaderOutput getOutputType() const { return outputType; }
std::string getBuiltInResourcesString() const { return builtInResourcesString; }
protected:
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
@ -114,10 +121,10 @@ protected:
bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph);
// Returns true if the shader does not use samplers.
bool enforceVertexShaderTimingRestrictions(TIntermNode* root);
// Returns true if the shader does not use sampler dependent values to affect control
// 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;
private:
ShShaderType shaderType;
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:
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;
@ -168,12 +180,12 @@ private:
// and the machine dependent code.
//
// The machine dependent code should derive from the classes
// above. Then Construct*() and Delete*() will create and
// above. Then Construct*() and Delete*() will create and
// destroy the machine dependent objects, which contain the
// 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_

View File

@ -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
} ;

View File

@ -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"

View 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.
//

View 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.
//

View 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;

View File

@ -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_

View 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();
}
}

View 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_

View File

@ -6,210 +6,77 @@
#include "compiler/translator/ForLoopUnroll.h"
namespace {
class IntegerForLoopUnrollMarker : public TIntermTraverser {
public:
virtual bool visitLoop(Visit, TIntermLoop* 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)
node->setUnrollFlag(true);
bool ForLoopUnrollMarker::visitBinary(Visit, TIntermBinary *node)
{
if (mUnrollCondition != kSamplerArrayIndex)
return true;
}
};
} // anonymous namepsace
void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info)
{
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();
}
void ForLoopUnroll::Step()
{
ASSERT(mLoopIndexStack.size() > 0);
TLoopIndexInfo& info = mLoopIndexStack[mLoopIndexStack.size() - 1];
info.currentValue += info.incrementValue;
}
bool ForLoopUnroll::SatisfiesLoopCondition()
{
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);
// 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:
UNREACHABLE();
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);
}
TIntermNode *body = node->getBody();
if (body != NULL)
{
mLoopStack.push(node);
body->traverse(this);
mLoopStack.pop();
}
// The loop is fully processed - no need to visit children.
return false;
}
bool ForLoopUnroll::NeedsToReplaceSymbolWithValue(TIntermSymbol* symbol)
void ForLoopUnrollMarker::visitSymbol(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;
if (!mVisitSamplerArrayIndexNodeInsideLoop)
return;
TIntermLoop *loop = mLoopStack.findLoop(symbol);
if (loop)
{
switch (symbol->getBasicType())
{
case EbtFloat:
mSamplerArrayIndexIsFloatLoopIndex = true;
break;
case EOpPostDecrement:
case EOpPreDecrement:
ASSERT((unOp != NULL) && (binOp == NULL));
increment = -1;
case EbtInt:
loop->setUnrollFlag(true);
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);
default:
UNREACHABLE();
}
}
return increment;
}
int ForLoopUnroll::evaluateIntConstant(TIntermConstantUnion* node)
{
ASSERT((node != NULL) && (node->getUnionArrayPointer() != NULL));
return node->getIConst(0);
}

View File

@ -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();
bool samplerArrayIndexIsFloatLoopIndex() const
{
return mSamplerArrayIndexIsFloatLoopIndex;
}
// 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);
private:
int getLoopIncrement(TIntermLoop* node);
int evaluateIntConstant(TIntermConstantUnion* node);
TVector<TLoopIndexInfo> mLoopIndexStack;
private:
UnrollCondition mUnrollCondition;
TLoopStack mLoopStack;
bool mSamplerArrayIndexIsFloatLoopIndex;
bool mVisitSamplerArrayIndexNodeInsideLoop;
};
#endif

View File

@ -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

View File

@ -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);

View File

@ -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()
{

View File

@ -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));
}

View File

@ -10,7 +10,7 @@
namespace
{
TIntermConstantUnion* constructFloatConstUnionNode(const TType& type)
TIntermConstantUnion *constructFloatConstUnionNode(const TType &type)
{
TType myType = type;
unsigned char size = myType.getNominalSize();
@ -26,7 +26,7 @@ TIntermConstantUnion* constructFloatConstUnionNode(const TType& type)
return node;
}
TIntermConstantUnion* constructIndexNode(int index)
TIntermConstantUnion *constructIndexNode(int index)
{
ConstantUnion *u = new ConstantUnion[1];
u[0].setIConst(index);
@ -38,7 +38,7 @@ TIntermConstantUnion* constructIndexNode(int index)
} // namespace anonymous
bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate* node)
bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate *node)
{
bool visitChildren = !mCodeInserted;
switch (node->getOp())
@ -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,18 +76,18 @@ 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)
{
const InitVariableInfo& varInfo = mVariables[ii];
const InitVariableInfo &varInfo = mVariables[ii];
if (varInfo.type.isArray())
{
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);

View File

@ -17,7 +17,7 @@ class InitializeVariables : public TIntermTraverser
TString name;
TType type;
InitVariableInfo(const TString& _name, const TType& _type)
InitVariableInfo(const TString &_name, const TType &_type)
: name(_name),
type(_type)
{
@ -25,23 +25,23 @@ class InitializeVariables : public TIntermTraverser
};
typedef TVector<InitVariableInfo> InitVariableInfoList;
InitializeVariables(const InitVariableInfoList& vars)
InitializeVariables(const InitVariableInfoList &vars)
: mCodeInserted(false),
mVariables(vars)
{
}
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;

View File

@ -45,7 +45,7 @@ void TIntermBinary::traverse(TIntermTraverser *it)
//
if (it->preVisit)
visit = it->visitBinary(PreVisit, this);
//
// Visit the children, in the right order.
//
@ -53,27 +53,27 @@ void TIntermBinary::traverse(TIntermTraverser *it)
{
it->incrementDepth(this);
if (it->rightToLeft)
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,10 +99,10 @@ void TIntermUnary::traverse(TIntermTraverser *it)
if (visit) {
it->incrementDepth(this);
operand->traverse(it);
mOperand->traverse(it);
it->decrementDepth();
}
if (visit && it->postVisit)
it->visitUnary(PostVisit, this);
}
@ -113,41 +113,43 @@ void TIntermUnary::traverse(TIntermTraverser *it)
void TIntermAggregate::traverse(TIntermTraverser *it)
{
bool visit = true;
if (it->preVisit)
visit = it->visitAggregate(PreVisit, this);
if (visit)
{
it->incrementDepth(this);
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);
}
}
}
it->decrementDepth();
}
@ -164,21 +166,25 @@ 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();
}
@ -196,38 +202,38 @@ void TIntermLoop::traverse(TIntermTraverser *it)
if (it->preVisit)
visit = it->visitLoop(PreVisit, this);
if (visit)
{
it->incrementDepth(this);
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();
@ -246,10 +252,10 @@ 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

View 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();
}

View 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_

View File

@ -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;
}

View File

@ -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_

View File

@ -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)
{
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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_

File diff suppressed because it is too large Load Diff

View File

@ -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,71 +9,75 @@
#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
{
public:
TOutputGLSLBase(TInfoSinkBase& objSink,
public:
TOutputGLSLBase(TInfoSinkBase &objSink,
ShArrayIndexClampingStrategy clampingStrategy,
ShHashFunction64 hashFunction,
NameMap& nameMap,
TSymbolTable& symbolTable);
NameMap &nameMap,
TSymbolTable& symbolTable,
int shaderVersion);
protected:
TInfoSinkBase& objSink() { return mObjSink; }
void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
void writeVariableType(const TType& type);
protected:
TInfoSinkBase &objSink() { return mObjSink; }
void writeTriplet(Visit visit, const char *preStr, const char *inStr, const char *postStr);
void writeVariableType(const TType &type);
virtual bool writeVariablePrecision(TPrecision precision) = 0;
void writeFunctionParameters(const TIntermSequence& args);
const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
TString getTypeName(const TType& type);
void writeFunctionParameters(const TIntermSequence &args);
const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *pConstUnion);
TString getTypeName(const TType &type);
virtual void visitSymbol(TIntermSymbol* node);
virtual void visitConstantUnion(TIntermConstantUnion* node);
virtual bool visitBinary(Visit visit, TIntermBinary* node);
virtual bool visitUnary(Visit visit, TIntermUnary* node);
virtual bool visitSelection(Visit visit, TIntermSelection* node);
virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
virtual bool visitLoop(Visit visit, TIntermLoop* node);
virtual bool visitBranch(Visit visit, TIntermBranch* node);
void visitCodeBlock(TIntermNode* node);
virtual void visitSymbol(TIntermSymbol *node);
virtual void visitConstantUnion(TIntermConstantUnion *node);
virtual bool visitBinary(Visit visit, TIntermBinary *node);
virtual bool visitUnary(Visit visit, TIntermUnary *node);
virtual bool visitSelection(Visit visit, TIntermSelection *node);
virtual bool visitAggregate(Visit visit, TIntermAggregate *node);
virtual bool visitLoop(Visit visit, TIntermLoop *node);
virtual bool visitBranch(Visit visit, TIntermBranch *node);
void visitCodeBlock(TIntermNode *node);
// Return the original name if hash function pointer is NULL;
// otherwise return the hashed name.
TString hashName(const TString& name);
TString hashName(const TString &name);
// Same as hashName(), but without hashing built-in variables.
TString hashVariableName(const TString& name);
TString hashVariableName(const TString &name);
// Same as hashName(), but without hashing built-in functions.
TString hashFunctionName(const TString& mangled_name);
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);
private:
bool structDeclared(const TStructure *structure) const;
void declareStruct(const TStructure *structure);
TInfoSinkBase& mObjSink;
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;
// name hashing.
ShHashFunction64 mHashFunction;
NameMap& mNameMap;
NameMap &mNameMap;
TSymbolTable& mSymbolTable;
TSymbolTable &mSymbolTable;
const int mShaderVersion;
};
#endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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);
}
//

View File

@ -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;
}
}

View File

@ -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,
selection->getTrueBlock(), falseBlock);
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;

View File

@ -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);
}

View 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;
}

View 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_

View File

@ -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,14 +46,62 @@ 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;
}
//
@ -58,7 +109,11 @@ int ShInitialize()
//
int ShFinalize()
{
DetachProcess();
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,8 +190,25 @@ 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
// Do an actual compile on the given strings. The result is left
// in the given compile object.
//
// Return: The return value of ShCompile is really boolean, indicating
@ -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;
}

View 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 &parameter = 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 &parameter = 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();
}
}

Some files were not shown because too many files have changed in this diff Show More