Upgrade ANGLE to 1.3.5bb7ec572d0a
This brings Qt's copy of ANGLE up to ANGLE master, which contains a number of bugfixes as well as restructuring for the upcoming ES 3.0 support. This version brings considerable stability improvements to the D3D11 renderer. The static translator project files have been merged to align with the ANGLE source tree. Two new patches have been applied to fix errors in upstream ANGLE: - 0011-ANGLE-Fix-compilation-error-on-MinGW-caused-by-trace.patch The event trace header in ANGLE's third_party directory has an unused template which causes a compilation error on MinGW. Disable this part of the code. - 0012-ANGLE-fix-semantic-index-lookup.patch The sorted semantic index table was returning a direct mapping to the new indices, instead of the old indices. This caused a mismatch in the GL type lookup for the translated attribute. All other patches have been rebased, removed if no longer needed, and renamed to clear up the application order: - 0001-Fix-compilation-for-MSVC-2008-and-std-tuple.patch No changes. - 0001-Fix-compilation-with-MinGW-mingw-tdm64-gcc-4.8.1.patch No changes. Renamed to 0002. - 0001-Fix-compilation-with-MinGW-gcc-64-bit.patch No changes. Renamed to 0003. - 0001-Make-it-possible-to-link-ANGLE-statically-for-single.patch Modified patch to adapt to new DLL loading structure. Renamed to 0004. - 0005-Fix-build-when-SSE2-is-not-available.patch No changes. - 0011-Fix-compilation-of-libGLESv2-with-older-MinGW-w64-he.patch No changes. Renamed to 0006. - 0006-Make-DX9-DX11-mutually-exclusive.patch Made the patch less invasive by allowing D3D9 code to run unless explicitly disabled (e.g. on WinRT, where it doesn't compile). This makes the patch smaller and allows Desktop Windows to compile both D3D9 and D3D11 codepaths. Renamed to 0007. - 0015-ANGLE-Dynamically-load-D3D-compiler-from-a-list-of-k.patch No changes. Renamed to 0008. - 0012-ANGLE-Support-WinRT.patch Made D3D11_level9 initialization only possible if D3D9 is disabled. This makes sure Desktop PCs use the old D3D9 codepath instead of the less-tested D3D11_level9 codepath. Renamed to 0009. - 0013-Enable-D3D11-for-feature-level-9-cards.patch Conveniently smaller patch due to buffer implementation improvements upstream. Renamed to 0010. - 0014-ANGLE-D3D11-Alwayls-execute-QueryInterface.patch This was a fix for patch 0009, so was integrated there. Removed. - 0016-ANGLE-D3D11-Fix-build-on-desktop-Windows.patch This was a fix for patch 0009, so it was integrated there. Removed. - 0001-ANGLE-Fix-compilation-with-MSVC2013.patch Fixed upstream. Removed. - 0007-ANGLE-Fix-typedefs-for-Win64.patch Fixed upstream. Removed. - 0004-Fix-black-screen-after-minimizing-OpenGL-window-with.patch The issue has been fixed in Qt itself. Removed. - 0008-DX11-Prevent-assert-when-view-is-minimized-or-.patch The cause of the problem was the same as patch 0004, but for the D3D11 codepath. Removed. Change-Id: Id69484ab3a3e013050741c462fb1b06dfb0fd112 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
parent
45e17d0cc7
commit
a7d093e740
2
src/3rdparty/angle/AUTHORS
vendored
2
src/3rdparty/angle/AUTHORS
vendored
@ -13,6 +13,8 @@ TransGaming Inc.
|
||||
|
||||
Adobe Systems Inc.
|
||||
Autodesk, Inc.
|
||||
BlackBerry Limited
|
||||
Cable Television Laboratories, Inc.
|
||||
Cloud Party, Inc.
|
||||
Intel Corporation
|
||||
Mozilla Corporation
|
||||
|
45
src/3rdparty/angle/LICENSE.preprocessor
vendored
45
src/3rdparty/angle/LICENSE.preprocessor
vendored
@ -1,45 +0,0 @@
|
||||
Files in src/compiler/preprocessor are provided under the following license:
|
||||
|
||||
****************************************************************************
|
||||
Copyright (c) 2002, NVIDIA Corporation.
|
||||
|
||||
NVIDIA Corporation("NVIDIA") supplies this software to you in
|
||||
consideration of your agreement to the following terms, and your use,
|
||||
installation, modification or redistribution of this NVIDIA software
|
||||
constitutes acceptance of these terms. If you do not agree with these
|
||||
terms, please do not use, install, modify or redistribute this NVIDIA
|
||||
software.
|
||||
|
||||
In consideration of your agreement to abide by the following terms, and
|
||||
subject to these terms, NVIDIA grants you a personal, non-exclusive
|
||||
license, under NVIDIA's copyrights in this original NVIDIA software (the
|
||||
"NVIDIA Software"), to use, reproduce, modify and redistribute the
|
||||
NVIDIA Software, with or without modifications, in source and/or binary
|
||||
forms; provided that if you redistribute the NVIDIA Software, you must
|
||||
retain the copyright notice of NVIDIA, this notice and the following
|
||||
text and disclaimers in all such redistributions of the NVIDIA Software.
|
||||
Neither the name, trademarks, service marks nor logos of NVIDIA
|
||||
Corporation may be used to endorse or promote products derived from the
|
||||
NVIDIA Software without specific prior written permission from NVIDIA.
|
||||
Except as expressly stated in this notice, no other rights or licenses
|
||||
express or implied, are granted by NVIDIA herein, including but not
|
||||
limited to any patent rights that may be infringed by your derivative
|
||||
works or by other works in which the NVIDIA Software may be
|
||||
incorporated. No hardware is licensed hereunder.
|
||||
|
||||
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
|
||||
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
|
||||
PRODUCTS.
|
||||
|
||||
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
|
||||
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
|
||||
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
|
||||
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
|
||||
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
|
||||
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
****************************************************************************
|
33
src/3rdparty/angle/include/GLSLANG/ShaderLang.h
vendored
33
src/3rdparty/angle/include/GLSLANG/ShaderLang.h
vendored
@ -6,20 +6,20 @@
|
||||
#ifndef _COMPILER_INTERFACE_INCLUDED_
|
||||
#define _COMPILER_INTERFACE_INCLUDED_
|
||||
|
||||
#if defined(COMPONENT_BUILD)
|
||||
#if defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC)
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#if defined(COMPILER_IMPLEMENTATION)
|
||||
#if defined(ANGLE_TRANSLATOR_IMPLEMENTATION)
|
||||
#define COMPILER_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define COMPILER_EXPORT __declspec(dllimport)
|
||||
#endif // defined(COMPILER_IMPLEMENTATION)
|
||||
#endif // defined(ANGLE_TRANSLATOR_IMPLEMENTATION)
|
||||
|
||||
#else // defined(WIN32)
|
||||
#else // defined(_WIN32) || defined(_WIN64)
|
||||
#define COMPILER_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#else // defined(COMPONENT_BUILD)
|
||||
#else // defined(COMPONENT_BUILD) && !defined(ANGLE_TRANSLATOR_STATIC)
|
||||
#define COMPILER_EXPORT
|
||||
#endif
|
||||
|
||||
@ -146,14 +146,14 @@ typedef enum {
|
||||
// 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.
|
||||
// To use this flag, you must compile the shader under the WebGL spec
|
||||
// (using the SH_WEBGL_SPEC flag).
|
||||
SH_TIMING_RESTRICTIONS = 0x0200,
|
||||
|
||||
|
||||
// This flag prints the dependency graph that is used to enforce timing
|
||||
// restrictions on fragment shaders.
|
||||
// This flag only has an effect if all of the following are true:
|
||||
@ -184,11 +184,24 @@ typedef enum {
|
||||
// This flag limits the depth of the call stack.
|
||||
SH_LIMIT_CALL_STACK_DEPTH = 0x4000,
|
||||
|
||||
// This flag initializes gl_Position to vec4(0.0, 0.0, 0.0, 1.0) at
|
||||
// the beginning of the vertex shader, and has no effect in the
|
||||
// This flag initializes gl_Position to vec4(0,0,0,0) at the
|
||||
// beginning of the vertex shader's main(), and has no effect in the
|
||||
// fragment shader. It is intended as a workaround for drivers which
|
||||
// incorrectly fail to link programs if gl_Position is not written.
|
||||
SH_INIT_GL_POSITION = 0x8000,
|
||||
|
||||
// This flag replaces
|
||||
// "a && b" with "a ? b : false",
|
||||
// "a || b" with "a ? true : b".
|
||||
// This is to work around a MacOSX driver bug that |b| is executed
|
||||
// independent of |a|'s value.
|
||||
SH_UNFOLD_SHORT_CIRCUIT = 0x10000,
|
||||
|
||||
// This flag initializes varyings without static use in vertex shader
|
||||
// at the beginning of main(), and has no effects in the fragment shader.
|
||||
// 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,
|
||||
} ShCompileOptions;
|
||||
|
||||
// Defines alternate strategies for implementing array index clamping.
|
||||
@ -267,7 +280,7 @@ 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. It's contents
|
||||
// are defined by and used by the compiler.
|
||||
//
|
||||
// If handle creation fails, 0 will be returned.
|
||||
|
8
src/3rdparty/angle/include/KHR/khrplatform.h
vendored
8
src/3rdparty/angle/include/KHR/khrplatform.h
vendored
@ -26,7 +26,7 @@
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
|
||||
* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
@ -221,6 +221,12 @@ typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef _WIN64
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
|
2
src/3rdparty/angle/src/commit.h
vendored
Normal file
2
src/3rdparty/angle/src/commit.h
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#define ANGLE_COMMIT_HASH "5bb7ec572d0a"
|
||||
#define ANGLE_COMMIT_HASH_SIZE 12
|
14
src/3rdparty/angle/src/common/angleutils.h
vendored
14
src/3rdparty/angle/src/common/angleutils.h
vendored
@ -42,6 +42,20 @@ void SafeRelease(T& resource)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SafeDelete(T*& resource)
|
||||
{
|
||||
delete resource;
|
||||
resource = NULL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void SafeDeleteArray(T*& resource)
|
||||
{
|
||||
delete[] resource;
|
||||
resource = NULL;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
44
src/3rdparty/angle/src/common/debug.cpp
vendored
44
src/3rdparty/angle/src/common/debug.cpp
vendored
@ -7,21 +7,23 @@
|
||||
// debug.cpp: Debugging utilities.
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/system.h"
|
||||
#ifndef ANGLE_ENABLE_D3D11
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
#include <d3d9.h>
|
||||
#else
|
||||
typedef DWORD D3DCOLOR;
|
||||
#endif
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
typedef void (WINAPI *PerfOutputFunction)(D3DCOLOR, LPCWSTR);
|
||||
#else
|
||||
typedef void (*PerfOutputFunction)(unsigned int, const wchar_t*);
|
||||
#endif
|
||||
|
||||
static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const char *format, va_list vararg)
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
char message[32768];
|
||||
@ -41,15 +43,15 @@ static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const c
|
||||
|
||||
perfFunc(0, wideMessage);
|
||||
}
|
||||
#endif
|
||||
#endif // ANGLE_ENABLE_PERF
|
||||
|
||||
#if !defined(ANGLE_DISABLE_TRACE)
|
||||
#if defined(ANGLE_ENABLE_TRACE)
|
||||
#if defined(NDEBUG)
|
||||
if (traceFileDebugOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif // NDEBUG
|
||||
|
||||
FILE* file = fopen(TRACE_OUTPUT_FILE, "a");
|
||||
if (file)
|
||||
@ -57,50 +59,50 @@ static void output(bool traceFileDebugOnly, PerfOutputFunction perfFunc, const c
|
||||
vfprintf(file, format, vararg);
|
||||
fclose(file);
|
||||
}
|
||||
#endif
|
||||
#endif // ANGLE_ENABLE_TRACE
|
||||
}
|
||||
|
||||
void trace(bool traceFileDebugOnly, const char *format, ...)
|
||||
{
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
#if defined(ANGLE_DISABLE_PERF)
|
||||
output(traceFileDebugOnly, NULL, format, vararg);
|
||||
#else
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
|
||||
#else
|
||||
output(traceFileDebugOnly, NULL, format, vararg);
|
||||
#endif
|
||||
va_end(vararg);
|
||||
}
|
||||
|
||||
bool perfActive()
|
||||
{
|
||||
#if defined(ANGLE_DISABLE_PERF)
|
||||
return false;
|
||||
#else
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
static bool active = D3DPERF_GetStatus() != 0;
|
||||
return active;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
#if defined(ANGLE_DISABLE_TRACE)
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
#if !defined(ANGLE_ENABLE_TRACE)
|
||||
if (!perfActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif // !ANGLE_ENABLE_TRACE
|
||||
va_list vararg;
|
||||
va_start(vararg, format);
|
||||
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
|
||||
va_end(vararg);
|
||||
#endif
|
||||
#endif // ANGLE_ENABLE_PERF
|
||||
}
|
||||
|
||||
ScopedPerfEventHelper::~ScopedPerfEventHelper()
|
||||
{
|
||||
#if !defined(ANGLE_DISABLE_PERF)
|
||||
#if defined(ANGLE_ENABLE_PERF)
|
||||
if (perfActive())
|
||||
{
|
||||
D3DPERF_EndEvent();
|
||||
|
32
src/3rdparty/angle/src/common/debug.h
vendored
32
src/3rdparty/angle/src/common/debug.h
vendored
@ -39,33 +39,35 @@ namespace gl
|
||||
}
|
||||
|
||||
// A macro to output a trace of a function call and its arguments to the debugging log
|
||||
#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
|
||||
#define TRACE(message, ...) (void(0))
|
||||
#else
|
||||
#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
|
||||
#define TRACE(message, ...) gl::trace(true, "trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
#define TRACE(message, ...) (void(0))
|
||||
#endif
|
||||
|
||||
// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
|
||||
#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
|
||||
#define FIXME(message, ...) (void(0))
|
||||
#else
|
||||
#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
|
||||
#define FIXME(message, ...) gl::trace(false, "fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
#define FIXME(message, ...) (void(0))
|
||||
#endif
|
||||
|
||||
// A macro to output a function call and its arguments to the debugging log, in case of error.
|
||||
#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
|
||||
#define ERR(message, ...) (void(0))
|
||||
#else
|
||||
#if defined(ANGLE_ENABLE_TRACE) || defined(ANGLE_ENABLE_PERF)
|
||||
#define ERR(message, ...) gl::trace(false, "err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
#define ERR(message, ...) (void(0))
|
||||
#endif
|
||||
|
||||
// A macro to log a performance event around a scope.
|
||||
#if defined(ANGLE_DISABLE_TRACE) && defined(ANGLE_DISABLE_PERF)
|
||||
#define EVENT(message, ...) (void(0))
|
||||
#elif defined(_MSC_VER)
|
||||
#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__);
|
||||
#else
|
||||
#define EVENT(message, ...) gl::ScopedPerfEventHelper scopedPerfEventHelper(message "\n", ##__VA_ARGS__);
|
||||
#endif // _MSC_VER
|
||||
#else
|
||||
#define EVENT(message, ...) (void(0))
|
||||
#endif
|
||||
|
||||
// A macro asserting a condition and outputting failures to the debug log
|
||||
@ -99,8 +101,10 @@ 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.
|
||||
#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI))
|
||||
// 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.
|
||||
#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
|
||||
#define HAS_DYNAMIC_TYPE(type, obj) true
|
||||
|
@ -14,7 +14,7 @@ AddTraceEventFunc g_addTraceEvent;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void __stdcall SetTraceFunctionPointers(GetCategoryEnabledFlagFunc getCategoryEnabledFlag,
|
||||
void TRACE_ENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc getCategoryEnabledFlag,
|
||||
AddTraceEventFunc addTraceEvent)
|
||||
{
|
||||
gl::g_getCategoryEnabledFlag = getCategoryEnabledFlag;
|
||||
|
12
src/3rdparty/angle/src/common/event_tracer.h
vendored
12
src/3rdparty/angle/src/common/event_tracer.h
vendored
@ -5,6 +5,14 @@
|
||||
#ifndef COMMON_EVENT_TRACER_H_
|
||||
#define COMMON_EVENT_TRACER_H_
|
||||
|
||||
#if !defined(TRACE_ENTRY)
|
||||
#if defined(_WIN32)
|
||||
#define TRACE_ENTRY __stdcall
|
||||
#else
|
||||
#define TRACE_ENTRY
|
||||
#endif // // _WIN32
|
||||
#endif //TRACE_ENTRY
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef const unsigned char* (*GetCategoryEnabledFlagFunc)(const char* name);
|
||||
@ -14,8 +22,8 @@ typedef void (*AddTraceEventFunc)(char phase, const unsigned char* categoryGroup
|
||||
unsigned char flags);
|
||||
|
||||
// extern "C" so that it has a reasonable name for GetProcAddress.
|
||||
void __stdcall SetTraceFunctionPointers(GetCategoryEnabledFlagFunc get_category_enabled_flag,
|
||||
AddTraceEventFunc add_trace_event_func);
|
||||
void TRACE_ENTRY SetTraceFunctionPointers(GetCategoryEnabledFlagFunc get_category_enabled_flag,
|
||||
AddTraceEventFunc add_trace_event_func);
|
||||
|
||||
}
|
||||
|
||||
|
26
src/3rdparty/angle/src/common/system.h
vendored
26
src/3rdparty/angle/src/common/system.h
vendored
@ -1,26 +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.
|
||||
//
|
||||
|
||||
// system.h: Includes Windows system headers and undefines macros that conflict.
|
||||
|
||||
#ifndef COMMON_SYSTEM_H
|
||||
#define COMMON_SYSTEM_H
|
||||
|
||||
#if !defined(WIN32_LEAN_AND_MEAN)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#if defined(min)
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#if defined(max)
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#endif // COMMON_SYSTEM_H
|
18
src/3rdparty/angle/src/common/version.h
vendored
18
src/3rdparty/angle/src/common/version.h
vendored
@ -1,12 +1,12 @@
|
||||
#define MAJOR_VERSION 1
|
||||
#define MINOR_VERSION 2
|
||||
#define BUILD_VERSION 0
|
||||
#define BUILD_REVISION 2446
|
||||
#include "commit.h"
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
||||
#define ANGLE_MAJOR_VERSION 1
|
||||
#define ANGLE_MINOR_VERSION 3
|
||||
|
||||
#define REVISION_STRING MACRO_STRINGIFY(BUILD_REVISION)
|
||||
#define VERSION_STRING MACRO_STRINGIFY(MAJOR_VERSION) "." MACRO_STRINGIFY(MINOR_VERSION) "." MACRO_STRINGIFY(BUILD_VERSION) "." MACRO_STRINGIFY(BUILD_REVISION)
|
||||
#define ANGLE_STRINGIFY(x) #x
|
||||
#define ANGLE_MACRO_STRINGIFY(x) ANGLE_STRINGIFY(x)
|
||||
|
||||
#define VERSION_DWORD ((MAJOR_VERSION << 24) | (MINOR_VERSION << 16) | BUILD_REVISION)
|
||||
#define ANGLE_VERSION_STRING \
|
||||
ANGLE_MACRO_STRINGIFY(ANGLE_MAJOR_VERSION) "." \
|
||||
ANGLE_MACRO_STRINGIFY(ANGLE_MINOR_VERSION) "." \
|
||||
ANGLE_COMMIT_HASH
|
||||
|
33
src/3rdparty/angle/src/compiler/CodeGenHLSL.cpp
vendored
33
src/3rdparty/angle/src/compiler/CodeGenHLSL.cpp
vendored
@ -1,33 +0,0 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "compiler/TranslatorHLSL.h"
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
// compile object used by higher level code. It returns
|
||||
// a subclass of TCompiler.
|
||||
//
|
||||
TCompiler* ConstructCompiler(
|
||||
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
|
||||
{
|
||||
switch (output)
|
||||
{
|
||||
case SH_HLSL9_OUTPUT:
|
||||
case SH_HLSL11_OUTPUT:
|
||||
return new TranslatorHLSL(type, spec, output);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Delete the compiler made by ConstructCompiler
|
||||
//
|
||||
void DeleteCompiler(TCompiler* compiler)
|
||||
{
|
||||
delete compiler;
|
||||
}
|
125
src/3rdparty/angle/src/compiler/DetectRecursion.cpp
vendored
125
src/3rdparty/angle/src/compiler/DetectRecursion.cpp
vendored
@ -1,125 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 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/DetectRecursion.h"
|
||||
|
||||
DetectRecursion::FunctionNode::FunctionNode(const TString& fname)
|
||||
: name(fname),
|
||||
visit(PreVisit)
|
||||
{
|
||||
}
|
||||
|
||||
const TString& DetectRecursion::FunctionNode::getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
void DetectRecursion::FunctionNode::addCallee(
|
||||
DetectRecursion::FunctionNode* callee)
|
||||
{
|
||||
for (size_t i = 0; i < callees.size(); ++i) {
|
||||
if (callees[i] == callee)
|
||||
return;
|
||||
}
|
||||
callees.push_back(callee);
|
||||
}
|
||||
|
||||
bool DetectRecursion::FunctionNode::detectRecursion()
|
||||
{
|
||||
ASSERT(visit == PreVisit);
|
||||
visit = InVisit;
|
||||
for (size_t i = 0; i < callees.size(); ++i) {
|
||||
switch (callees[i]->visit) {
|
||||
case InVisit:
|
||||
// cycle detected, i.e., recursion detected.
|
||||
return true;
|
||||
case PostVisit:
|
||||
break;
|
||||
case PreVisit: {
|
||||
bool recursion = callees[i]->detectRecursion();
|
||||
if (recursion)
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
visit = PostVisit;
|
||||
return false;
|
||||
}
|
||||
|
||||
DetectRecursion::DetectRecursion()
|
||||
: currentFunction(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
DetectRecursion::~DetectRecursion()
|
||||
{
|
||||
for (size_t i = 0; i < functions.size(); ++i)
|
||||
delete functions[i];
|
||||
}
|
||||
|
||||
bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpPrototype:
|
||||
// Function declaration.
|
||||
// Don't add FunctionNode here because node->getName() is the
|
||||
// unmangled function name.
|
||||
break;
|
||||
case EOpFunction: {
|
||||
// Function definition.
|
||||
if (visit == PreVisit) {
|
||||
currentFunction = findFunctionByName(node->getName());
|
||||
if (currentFunction == NULL) {
|
||||
currentFunction = new FunctionNode(node->getName());
|
||||
functions.push_back(currentFunction);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EOpFunctionCall: {
|
||||
// Function call.
|
||||
if (visit == PreVisit) {
|
||||
ASSERT(currentFunction != NULL);
|
||||
FunctionNode* func = findFunctionByName(node->getName());
|
||||
if (func == NULL) {
|
||||
func = new FunctionNode(node->getName());
|
||||
functions.push_back(func);
|
||||
}
|
||||
currentFunction->addCallee(func);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DetectRecursion::ErrorCode DetectRecursion::detectRecursion()
|
||||
{
|
||||
FunctionNode* main = findFunctionByName("main(");
|
||||
if (main == NULL)
|
||||
return kErrorMissingMain;
|
||||
if (main->detectRecursion())
|
||||
return kErrorRecursion;
|
||||
return kErrorNone;
|
||||
}
|
||||
|
||||
DetectRecursion::FunctionNode* DetectRecursion::findFunctionByName(
|
||||
const TString& name)
|
||||
{
|
||||
for (size_t i = 0; i < functions.size(); ++i) {
|
||||
if (functions[i]->getName() == name)
|
||||
return functions[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2002-2011 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_DETECT_RECURSION_H_
|
||||
#define COMPILER_DETECT_RECURSION_H_
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/VariableInfo.h"
|
||||
|
||||
// Traverses intermediate tree to detect function recursion.
|
||||
class DetectRecursion : public TIntermTraverser {
|
||||
public:
|
||||
enum ErrorCode {
|
||||
kErrorMissingMain,
|
||||
kErrorRecursion,
|
||||
kErrorNone
|
||||
};
|
||||
|
||||
DetectRecursion();
|
||||
~DetectRecursion();
|
||||
|
||||
virtual bool visitAggregate(Visit, TIntermAggregate*);
|
||||
|
||||
ErrorCode detectRecursion();
|
||||
|
||||
private:
|
||||
class FunctionNode {
|
||||
public:
|
||||
FunctionNode(const TString& fname);
|
||||
|
||||
const TString& getName() const;
|
||||
|
||||
// If a function is already in the callee list, this becomes a no-op.
|
||||
void addCallee(FunctionNode* callee);
|
||||
|
||||
// Return true if recursive function calls are detected.
|
||||
bool detectRecursion();
|
||||
|
||||
private:
|
||||
// mangled function name is unique.
|
||||
TString name;
|
||||
|
||||
// functions that are directly called by this function.
|
||||
TVector<FunctionNode*> callees;
|
||||
|
||||
Visit visit;
|
||||
};
|
||||
|
||||
FunctionNode* findFunctionByName(const TString& name);
|
||||
|
||||
TVector<FunctionNode*> functions;
|
||||
FunctionNode* currentFunction;
|
||||
};
|
||||
|
||||
#endif // COMPILER_DETECT_RECURSION_H_
|
@ -1,61 +0,0 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "compiler/InitializeGLPosition.h"
|
||||
#include "compiler/debug.h"
|
||||
|
||||
bool InitializeGLPosition::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
{
|
||||
bool visitChildren = !mCodeInserted;
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence: break;
|
||||
case EOpFunction:
|
||||
{
|
||||
// Function definition.
|
||||
ASSERT(visit == PreVisit);
|
||||
if (node->getName() == "main(")
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
|
||||
TIntermAggregate *body = NULL;
|
||||
if (sequence.size() == 1)
|
||||
{
|
||||
body = new TIntermAggregate(EOpSequence);
|
||||
sequence.push_back(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
body = sequence[1]->getAsAggregate();
|
||||
}
|
||||
ASSERT(body);
|
||||
insertCode(body->getSequence());
|
||||
mCodeInserted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: visitChildren = false; break;
|
||||
}
|
||||
return visitChildren;
|
||||
}
|
||||
|
||||
void InitializeGLPosition::insertCode(TIntermSequence& sequence)
|
||||
{
|
||||
TIntermBinary *binary = new TIntermBinary(EOpAssign);
|
||||
sequence.insert(sequence.begin(), binary);
|
||||
|
||||
TIntermSymbol *left = new TIntermSymbol(
|
||||
0, "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
|
||||
binary->setLeft(left);
|
||||
|
||||
ConstantUnion *u = new ConstantUnion[4];
|
||||
for (int ii = 0; ii < 3; ++ii)
|
||||
u[ii].setFConst(0.0f);
|
||||
u[3].setFConst(1.0f);
|
||||
TIntermConstantUnion *right = new TIntermConstantUnion(
|
||||
u, TType(EbtFloat, EbpUndefined, EvqConst, 4));
|
||||
binary->setRight(right);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_INITIALIZE_GL_POSITION_H_
|
||||
#define COMPILER_INITIALIZE_GL_POSITION_H_
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
|
||||
class InitializeGLPosition : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
InitializeGLPosition() : mCodeInserted(false) { }
|
||||
|
||||
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 visitAggregate(Visit visit, TIntermAggregate* node);
|
||||
|
||||
private:
|
||||
// Insert AST node in the beginning of main() for "gl_Position = vec4(0.0, 0.0, 0.0, 1.0);".
|
||||
void insertCode(TIntermSequence& sequence);
|
||||
|
||||
bool mCodeInserted;
|
||||
};
|
||||
|
||||
#endif // COMPILER_INITIALIZE_GL_POSITION_H_
|
293
src/3rdparty/angle/src/compiler/IntermTraverse.cpp
vendored
293
src/3rdparty/angle/src/compiler/IntermTraverse.cpp
vendored
@ -1,293 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 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/intermediate.h"
|
||||
|
||||
//
|
||||
// Traverse the intermediate representation tree, and
|
||||
// call a node type specific function for each node.
|
||||
// Done recursively through the member function Traverse().
|
||||
// Node types can be skipped if their function to call is 0,
|
||||
// but their subtree will still be traversed.
|
||||
// Nodes with children can have their whole subtree skipped
|
||||
// if preVisit is turned on and the type specific function
|
||||
// returns false.
|
||||
//
|
||||
// preVisit, postVisit, and rightToLeft control what order
|
||||
// nodes are visited in.
|
||||
//
|
||||
|
||||
//
|
||||
// Traversal functions for terminals are straighforward....
|
||||
//
|
||||
void TIntermSymbol::traverse(TIntermTraverser* it)
|
||||
{
|
||||
it->visitSymbol(this);
|
||||
}
|
||||
|
||||
void TIntermConstantUnion::traverse(TIntermTraverser* it)
|
||||
{
|
||||
it->visitConstantUnion(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a binary node.
|
||||
//
|
||||
void TIntermBinary::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
//
|
||||
// visit the node before children if pre-visiting.
|
||||
//
|
||||
if(it->preVisit)
|
||||
{
|
||||
visit = it->visitBinary(PreVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Visit the children, in the right order.
|
||||
//
|
||||
if(visit)
|
||||
{
|
||||
it->incrementDepth();
|
||||
|
||||
if(it->rightToLeft)
|
||||
{
|
||||
if(right)
|
||||
{
|
||||
right->traverse(it);
|
||||
}
|
||||
|
||||
if(it->inVisit)
|
||||
{
|
||||
visit = it->visitBinary(InVisit, this);
|
||||
}
|
||||
|
||||
if(visit && left)
|
||||
{
|
||||
left->traverse(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(left)
|
||||
{
|
||||
left->traverse(it);
|
||||
}
|
||||
|
||||
if(it->inVisit)
|
||||
{
|
||||
visit = it->visitBinary(InVisit, this);
|
||||
}
|
||||
|
||||
if(visit && right)
|
||||
{
|
||||
right->traverse(it);
|
||||
}
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
//
|
||||
// Visit the node after the children, if requested and the traversal
|
||||
// hasn't been cancelled yet.
|
||||
//
|
||||
if(visit && it->postVisit)
|
||||
{
|
||||
it->visitBinary(PostVisit, this);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a unary node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermUnary::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitUnary(PreVisit, this);
|
||||
|
||||
if (visit) {
|
||||
it->incrementDepth();
|
||||
operand->traverse(it);
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitUnary(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse an aggregate node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermAggregate::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if(it->preVisit)
|
||||
{
|
||||
visit = it->visitAggregate(PreVisit, this);
|
||||
}
|
||||
|
||||
if(visit)
|
||||
{
|
||||
it->incrementDepth();
|
||||
|
||||
if(it->rightToLeft)
|
||||
{
|
||||
for(TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++)
|
||||
{
|
||||
(*sit)->traverse(it);
|
||||
|
||||
if(visit && it->inVisit)
|
||||
{
|
||||
if(*sit != sequence.front())
|
||||
{
|
||||
visit = it->visitAggregate(InVisit, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
|
||||
{
|
||||
(*sit)->traverse(it);
|
||||
|
||||
if(visit && it->inVisit)
|
||||
{
|
||||
if(*sit != sequence.back())
|
||||
{
|
||||
visit = it->visitAggregate(InVisit, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if(visit && it->postVisit)
|
||||
{
|
||||
it->visitAggregate(PostVisit, this);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a selection node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermSelection::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitSelection(PreVisit, this);
|
||||
|
||||
if (visit) {
|
||||
it->incrementDepth();
|
||||
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);
|
||||
}
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitSelection(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a loop node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermLoop::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if(it->preVisit)
|
||||
{
|
||||
visit = it->visitLoop(PreVisit, this);
|
||||
}
|
||||
|
||||
if(visit)
|
||||
{
|
||||
it->incrementDepth();
|
||||
|
||||
if(it->rightToLeft)
|
||||
{
|
||||
if(expr)
|
||||
{
|
||||
expr->traverse(it);
|
||||
}
|
||||
|
||||
if(body)
|
||||
{
|
||||
body->traverse(it);
|
||||
}
|
||||
|
||||
if(cond)
|
||||
{
|
||||
cond->traverse(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cond)
|
||||
{
|
||||
cond->traverse(it);
|
||||
}
|
||||
|
||||
if(body)
|
||||
{
|
||||
body->traverse(it);
|
||||
}
|
||||
|
||||
if(expr)
|
||||
{
|
||||
expr->traverse(it);
|
||||
}
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if(visit && it->postVisit)
|
||||
{
|
||||
it->visitLoop(PostVisit, this);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a branch node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermBranch::traverse(TIntermTraverser* it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitBranch(PreVisit, this);
|
||||
|
||||
if (visit && expression) {
|
||||
it->incrementDepth();
|
||||
expression->traverse(it);
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitBranch(PostVisit, this);
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ void Diagnostics::report(ID id,
|
||||
|
||||
Diagnostics::Severity Diagnostics::severity(ID id)
|
||||
{
|
||||
if ((id > ERROR_BEGIN) && (id < ERROR_END))
|
||||
return ERROR;
|
||||
if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END))
|
||||
return PP_ERROR;
|
||||
|
||||
if ((id > WARNING_BEGIN) && (id < WARNING_END))
|
||||
return WARNING;
|
||||
if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
|
||||
return PP_WARNING;
|
||||
|
||||
assert(false);
|
||||
return ERROR;
|
||||
return PP_ERROR;
|
||||
}
|
||||
|
||||
std::string Diagnostics::message(ID id)
|
||||
@ -40,82 +40,82 @@ std::string Diagnostics::message(ID id)
|
||||
switch (id)
|
||||
{
|
||||
// Errors begin.
|
||||
case INTERNAL_ERROR:
|
||||
case PP_INTERNAL_ERROR:
|
||||
return "internal error";
|
||||
case OUT_OF_MEMORY:
|
||||
case PP_OUT_OF_MEMORY:
|
||||
return "out of memory";
|
||||
case INVALID_CHARACTER:
|
||||
case PP_INVALID_CHARACTER:
|
||||
return "invalid character";
|
||||
case INVALID_NUMBER:
|
||||
case PP_INVALID_NUMBER:
|
||||
return "invalid number";
|
||||
case INTEGER_OVERFLOW:
|
||||
case PP_INTEGER_OVERFLOW:
|
||||
return "integer overflow";
|
||||
case FLOAT_OVERFLOW:
|
||||
case PP_FLOAT_OVERFLOW:
|
||||
return "float overflow";
|
||||
case TOKEN_TOO_LONG:
|
||||
case PP_TOKEN_TOO_LONG:
|
||||
return "token too long";
|
||||
case INVALID_EXPRESSION:
|
||||
case PP_INVALID_EXPRESSION:
|
||||
return "invalid expression";
|
||||
case DIVISION_BY_ZERO:
|
||||
case PP_DIVISION_BY_ZERO:
|
||||
return "division by zero";
|
||||
case EOF_IN_COMMENT:
|
||||
case PP_EOF_IN_COMMENT:
|
||||
return "unexpected end of file found in comment";
|
||||
case UNEXPECTED_TOKEN:
|
||||
case PP_UNEXPECTED_TOKEN:
|
||||
return "unexpected token";
|
||||
case DIRECTIVE_INVALID_NAME:
|
||||
case PP_DIRECTIVE_INVALID_NAME:
|
||||
return "invalid directive name";
|
||||
case MACRO_NAME_RESERVED:
|
||||
case PP_MACRO_NAME_RESERVED:
|
||||
return "macro name is reserved";
|
||||
case MACRO_REDEFINED:
|
||||
case PP_MACRO_REDEFINED:
|
||||
return "macro redefined";
|
||||
case MACRO_PREDEFINED_REDEFINED:
|
||||
case PP_MACRO_PREDEFINED_REDEFINED:
|
||||
return "predefined macro redefined";
|
||||
case MACRO_PREDEFINED_UNDEFINED:
|
||||
case PP_MACRO_PREDEFINED_UNDEFINED:
|
||||
return "predefined macro undefined";
|
||||
case MACRO_UNTERMINATED_INVOCATION:
|
||||
case PP_MACRO_UNTERMINATED_INVOCATION:
|
||||
return "unterminated macro invocation";
|
||||
case MACRO_TOO_FEW_ARGS:
|
||||
case PP_MACRO_TOO_FEW_ARGS:
|
||||
return "Not enough arguments for macro";
|
||||
case MACRO_TOO_MANY_ARGS:
|
||||
case PP_MACRO_TOO_MANY_ARGS:
|
||||
return "Too many arguments for macro";
|
||||
case CONDITIONAL_ENDIF_WITHOUT_IF:
|
||||
case PP_CONDITIONAL_ENDIF_WITHOUT_IF:
|
||||
return "unexpected #endif found without a matching #if";
|
||||
case CONDITIONAL_ELSE_WITHOUT_IF:
|
||||
case PP_CONDITIONAL_ELSE_WITHOUT_IF:
|
||||
return "unexpected #else found without a matching #if";
|
||||
case CONDITIONAL_ELSE_AFTER_ELSE:
|
||||
case PP_CONDITIONAL_ELSE_AFTER_ELSE:
|
||||
return "unexpected #else found after another #else";
|
||||
case CONDITIONAL_ELIF_WITHOUT_IF:
|
||||
case PP_CONDITIONAL_ELIF_WITHOUT_IF:
|
||||
return "unexpected #elif found without a matching #if";
|
||||
case CONDITIONAL_ELIF_AFTER_ELSE:
|
||||
case PP_CONDITIONAL_ELIF_AFTER_ELSE:
|
||||
return "unexpected #elif found after #else";
|
||||
case CONDITIONAL_UNTERMINATED:
|
||||
case PP_CONDITIONAL_UNTERMINATED:
|
||||
return "unexpected end of file found in conditional block";
|
||||
case INVALID_EXTENSION_NAME:
|
||||
case PP_INVALID_EXTENSION_NAME:
|
||||
return "invalid extension name";
|
||||
case INVALID_EXTENSION_BEHAVIOR:
|
||||
case PP_INVALID_EXTENSION_BEHAVIOR:
|
||||
return "invalid extension behavior";
|
||||
case INVALID_EXTENSION_DIRECTIVE:
|
||||
case PP_INVALID_EXTENSION_DIRECTIVE:
|
||||
return "invalid extension directive";
|
||||
case INVALID_VERSION_NUMBER:
|
||||
case PP_INVALID_VERSION_NUMBER:
|
||||
return "invalid version number";
|
||||
case INVALID_VERSION_DIRECTIVE:
|
||||
case PP_INVALID_VERSION_DIRECTIVE:
|
||||
return "invalid version directive";
|
||||
case VERSION_NOT_FIRST_STATEMENT:
|
||||
case PP_VERSION_NOT_FIRST_STATEMENT:
|
||||
return "#version directive must occur before anything else, "
|
||||
"except for comments and white space";
|
||||
case INVALID_LINE_NUMBER:
|
||||
case PP_INVALID_LINE_NUMBER:
|
||||
return "invalid line number";
|
||||
case INVALID_FILE_NUMBER:
|
||||
case PP_INVALID_FILE_NUMBER:
|
||||
return "invalid file number";
|
||||
case INVALID_LINE_DIRECTIVE:
|
||||
case PP_INVALID_LINE_DIRECTIVE:
|
||||
return "invalid line directive";
|
||||
// Errors end.
|
||||
// Warnings begin.
|
||||
case EOF_IN_DIRECTIVE:
|
||||
case PP_EOF_IN_DIRECTIVE:
|
||||
return "unexpected end of file found in directive";
|
||||
case CONDITIONAL_UNEXPECTED_TOKEN:
|
||||
case PP_CONDITIONAL_UNEXPECTED_TOKEN:
|
||||
return "unexpected token after conditional expression";
|
||||
case UNRECOGNIZED_PRAGMA:
|
||||
case PP_UNRECOGNIZED_PRAGMA:
|
||||
return "unrecognized pragma";
|
||||
// Warnings end.
|
||||
default:
|
||||
|
@ -21,53 +21,53 @@ class Diagnostics
|
||||
public:
|
||||
enum Severity
|
||||
{
|
||||
ERROR,
|
||||
WARNING
|
||||
PP_ERROR,
|
||||
PP_WARNING
|
||||
};
|
||||
enum ID
|
||||
{
|
||||
ERROR_BEGIN,
|
||||
INTERNAL_ERROR,
|
||||
OUT_OF_MEMORY,
|
||||
INVALID_CHARACTER,
|
||||
INVALID_NUMBER,
|
||||
INTEGER_OVERFLOW,
|
||||
FLOAT_OVERFLOW,
|
||||
TOKEN_TOO_LONG,
|
||||
INVALID_EXPRESSION,
|
||||
DIVISION_BY_ZERO,
|
||||
EOF_IN_COMMENT,
|
||||
UNEXPECTED_TOKEN,
|
||||
DIRECTIVE_INVALID_NAME,
|
||||
MACRO_NAME_RESERVED,
|
||||
MACRO_REDEFINED,
|
||||
MACRO_PREDEFINED_REDEFINED,
|
||||
MACRO_PREDEFINED_UNDEFINED,
|
||||
MACRO_UNTERMINATED_INVOCATION,
|
||||
MACRO_TOO_FEW_ARGS,
|
||||
MACRO_TOO_MANY_ARGS,
|
||||
CONDITIONAL_ENDIF_WITHOUT_IF,
|
||||
CONDITIONAL_ELSE_WITHOUT_IF,
|
||||
CONDITIONAL_ELSE_AFTER_ELSE,
|
||||
CONDITIONAL_ELIF_WITHOUT_IF,
|
||||
CONDITIONAL_ELIF_AFTER_ELSE,
|
||||
CONDITIONAL_UNTERMINATED,
|
||||
INVALID_EXTENSION_NAME,
|
||||
INVALID_EXTENSION_BEHAVIOR,
|
||||
INVALID_EXTENSION_DIRECTIVE,
|
||||
INVALID_VERSION_NUMBER,
|
||||
INVALID_VERSION_DIRECTIVE,
|
||||
VERSION_NOT_FIRST_STATEMENT,
|
||||
INVALID_LINE_NUMBER,
|
||||
INVALID_FILE_NUMBER,
|
||||
INVALID_LINE_DIRECTIVE,
|
||||
ERROR_END,
|
||||
PP_ERROR_BEGIN,
|
||||
PP_INTERNAL_ERROR,
|
||||
PP_OUT_OF_MEMORY,
|
||||
PP_INVALID_CHARACTER,
|
||||
PP_INVALID_NUMBER,
|
||||
PP_INTEGER_OVERFLOW,
|
||||
PP_FLOAT_OVERFLOW,
|
||||
PP_TOKEN_TOO_LONG,
|
||||
PP_INVALID_EXPRESSION,
|
||||
PP_DIVISION_BY_ZERO,
|
||||
PP_EOF_IN_COMMENT,
|
||||
PP_UNEXPECTED_TOKEN,
|
||||
PP_DIRECTIVE_INVALID_NAME,
|
||||
PP_MACRO_NAME_RESERVED,
|
||||
PP_MACRO_REDEFINED,
|
||||
PP_MACRO_PREDEFINED_REDEFINED,
|
||||
PP_MACRO_PREDEFINED_UNDEFINED,
|
||||
PP_MACRO_UNTERMINATED_INVOCATION,
|
||||
PP_MACRO_TOO_FEW_ARGS,
|
||||
PP_MACRO_TOO_MANY_ARGS,
|
||||
PP_CONDITIONAL_ENDIF_WITHOUT_IF,
|
||||
PP_CONDITIONAL_ELSE_WITHOUT_IF,
|
||||
PP_CONDITIONAL_ELSE_AFTER_ELSE,
|
||||
PP_CONDITIONAL_ELIF_WITHOUT_IF,
|
||||
PP_CONDITIONAL_ELIF_AFTER_ELSE,
|
||||
PP_CONDITIONAL_UNTERMINATED,
|
||||
PP_INVALID_EXTENSION_NAME,
|
||||
PP_INVALID_EXTENSION_BEHAVIOR,
|
||||
PP_INVALID_EXTENSION_DIRECTIVE,
|
||||
PP_INVALID_VERSION_NUMBER,
|
||||
PP_INVALID_VERSION_DIRECTIVE,
|
||||
PP_VERSION_NOT_FIRST_STATEMENT,
|
||||
PP_INVALID_LINE_NUMBER,
|
||||
PP_INVALID_FILE_NUMBER,
|
||||
PP_INVALID_LINE_DIRECTIVE,
|
||||
PP_ERROR_END,
|
||||
|
||||
WARNING_BEGIN,
|
||||
EOF_IN_DIRECTIVE,
|
||||
CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
UNRECOGNIZED_PRAGMA,
|
||||
WARNING_END
|
||||
PP_WARNING_BEGIN,
|
||||
PP_EOF_IN_DIRECTIVE,
|
||||
PP_CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
PP_UNRECOGNIZED_PRAGMA,
|
||||
PP_WARNING_END
|
||||
};
|
||||
|
||||
virtual ~Diagnostics();
|
||||
|
@ -172,7 +172,7 @@ class DefinedParser : public Lexer
|
||||
|
||||
if (token->type != Token::IDENTIFIER)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mLexer, token);
|
||||
return;
|
||||
@ -185,7 +185,7 @@ class DefinedParser : public Lexer
|
||||
mLexer->lex(token);
|
||||
if (token->type != ')')
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mLexer, token);
|
||||
return;
|
||||
@ -233,7 +233,7 @@ void DirectiveParser::lex(Token* token)
|
||||
if (!mConditionalStack.empty())
|
||||
{
|
||||
const ConditionalBlock& block = mConditionalStack.back();
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_UNTERMINATED,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED,
|
||||
block.location, block.type);
|
||||
}
|
||||
break;
|
||||
@ -268,7 +268,7 @@ void DirectiveParser::parseDirective(Token* token)
|
||||
switch(directive)
|
||||
{
|
||||
case DIRECTIVE_NONE:
|
||||
mDiagnostics->report(Diagnostics::DIRECTIVE_INVALID_NAME,
|
||||
mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
break;
|
||||
@ -319,7 +319,7 @@ void DirectiveParser::parseDirective(Token* token)
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
if (token->type == Token::LAST)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::EOF_IN_DIRECTIVE,
|
||||
mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE,
|
||||
token->location, token->text);
|
||||
}
|
||||
}
|
||||
@ -331,19 +331,19 @@ void DirectiveParser::parseDefine(Token* token)
|
||||
mTokenizer->lex(token);
|
||||
if (token->type != Token::IDENTIFIER)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
return;
|
||||
}
|
||||
if (isMacroPredefined(token->text, *mMacroSet))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_REDEFINED,
|
||||
mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED,
|
||||
token->location, token->text);
|
||||
return;
|
||||
}
|
||||
if (isMacroNameReserved(token->text))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::MACRO_NAME_RESERVED,
|
||||
mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED,
|
||||
token->location, token->text);
|
||||
return;
|
||||
}
|
||||
@ -368,7 +368,7 @@ void DirectiveParser::parseDefine(Token* token)
|
||||
|
||||
if (token->type != ')')
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location,
|
||||
token->text);
|
||||
return;
|
||||
@ -396,7 +396,7 @@ void DirectiveParser::parseDefine(Token* token)
|
||||
MacroSet::const_iterator iter = mMacroSet->find(macro.name);
|
||||
if (iter != mMacroSet->end() && !macro.equals(iter->second))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::MACRO_REDEFINED,
|
||||
mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED,
|
||||
token->location,
|
||||
macro.name);
|
||||
return;
|
||||
@ -411,7 +411,7 @@ void DirectiveParser::parseUndef(Token* token)
|
||||
mTokenizer->lex(token);
|
||||
if (token->type != Token::IDENTIFIER)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
return;
|
||||
}
|
||||
@ -421,7 +421,7 @@ void DirectiveParser::parseUndef(Token* token)
|
||||
{
|
||||
if (iter->second.predefined)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_UNDEFINED,
|
||||
mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED,
|
||||
token->location, token->text);
|
||||
}
|
||||
else
|
||||
@ -457,7 +457,7 @@ void DirectiveParser::parseElse(Token* token)
|
||||
|
||||
if (mConditionalStack.empty())
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return;
|
||||
@ -472,7 +472,7 @@ void DirectiveParser::parseElse(Token* token)
|
||||
}
|
||||
if (block.foundElseGroup)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return;
|
||||
@ -486,7 +486,7 @@ void DirectiveParser::parseElse(Token* token)
|
||||
mTokenizer->lex(token);
|
||||
if (!isEOD(token))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
}
|
||||
@ -498,7 +498,7 @@ void DirectiveParser::parseElif(Token* token)
|
||||
|
||||
if (mConditionalStack.empty())
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return;
|
||||
@ -513,7 +513,7 @@ void DirectiveParser::parseElif(Token* token)
|
||||
}
|
||||
if (block.foundElseGroup)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return;
|
||||
@ -538,7 +538,7 @@ void DirectiveParser::parseEndif(Token* token)
|
||||
|
||||
if (mConditionalStack.empty())
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return;
|
||||
@ -550,7 +550,7 @@ void DirectiveParser::parseEndif(Token* token)
|
||||
mTokenizer->lex(token);
|
||||
if (!isEOD(token))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
}
|
||||
@ -618,7 +618,7 @@ void DirectiveParser::parsePragma(Token* token)
|
||||
(state == RIGHT_PAREN + 1)); // With value.
|
||||
if (!valid)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNRECOGNIZED_PRAGMA,
|
||||
mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA,
|
||||
token->location, name);
|
||||
}
|
||||
else if (state > PRAGMA_NAME) // Do not notify for empty pragma.
|
||||
@ -650,7 +650,7 @@ void DirectiveParser::parseExtension(Token* token)
|
||||
case EXT_NAME:
|
||||
if (valid && (token->type != Token::IDENTIFIER))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_EXTENSION_NAME,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -659,7 +659,7 @@ void DirectiveParser::parseExtension(Token* token)
|
||||
case COLON:
|
||||
if (valid && (token->type != ':'))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -667,7 +667,7 @@ void DirectiveParser::parseExtension(Token* token)
|
||||
case EXT_BEHAVIOR:
|
||||
if (valid && (token->type != Token::IDENTIFIER))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_EXTENSION_BEHAVIOR,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -676,7 +676,7 @@ void DirectiveParser::parseExtension(Token* token)
|
||||
default:
|
||||
if (valid)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -686,7 +686,7 @@ void DirectiveParser::parseExtension(Token* token)
|
||||
}
|
||||
if (valid && (state != EXT_BEHAVIOR + 1))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_EXTENSION_DIRECTIVE,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -700,7 +700,7 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
|
||||
if (mPastFirstStatement)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::VERSION_NOT_FIRST_STATEMENT,
|
||||
mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return;
|
||||
@ -723,13 +723,13 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
case VERSION_NUMBER:
|
||||
if (valid && (token->type != Token::CONST_INT))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_VERSION_NUMBER,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
if (valid && !token->iValue(&version))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW,
|
||||
mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -737,7 +737,7 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
default:
|
||||
if (valid)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -747,7 +747,7 @@ void DirectiveParser::parseVersion(Token* token)
|
||||
}
|
||||
if (valid && (state != VERSION_NUMBER + 1))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_VERSION_DIRECTIVE,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -778,13 +778,13 @@ void DirectiveParser::parseLine(Token* token)
|
||||
case LINE_NUMBER:
|
||||
if (valid && (token->type != Token::CONST_INT))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_LINE_NUMBER,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_LINE_NUMBER,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
if (valid && !token->iValue(&line))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW,
|
||||
mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -792,13 +792,13 @@ void DirectiveParser::parseLine(Token* token)
|
||||
case FILE_NUMBER:
|
||||
if (valid && (token->type != Token::CONST_INT))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_FILE_NUMBER,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_FILE_NUMBER,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
if (valid && !token->iValue(&file))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW,
|
||||
mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -806,7 +806,7 @@ void DirectiveParser::parseLine(Token* token)
|
||||
default:
|
||||
if (valid)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -817,7 +817,7 @@ void DirectiveParser::parseLine(Token* token)
|
||||
|
||||
if (valid && (state != FILE_NUMBER) && (state != FILE_NUMBER + 1))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::INVALID_LINE_DIRECTIVE,
|
||||
mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE,
|
||||
token->location, token->text);
|
||||
valid = false;
|
||||
}
|
||||
@ -893,7 +893,7 @@ int DirectiveParser::parseExpressionIf(Token* token)
|
||||
// Warn if there are tokens after #if expression.
|
||||
if (!isEOD(token))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
}
|
||||
@ -909,7 +909,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
|
||||
mTokenizer->lex(token);
|
||||
if (token->type != Token::IDENTIFIER)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
return 0;
|
||||
@ -922,7 +922,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
|
||||
mTokenizer->lex(token);
|
||||
if (!isEOD(token))
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
|
||||
token->location, token->text);
|
||||
skipUntilEOD(mTokenizer, token);
|
||||
}
|
||||
|
@ -33,6 +33,12 @@ WHICH GENERATES THE GLSL ES preprocessor expression parser.
|
||||
|
||||
#include "ExpressionParser.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
@ -146,7 +152,7 @@ expression
|
||||
std::ostringstream stream;
|
||||
stream << $1 << " % " << $3;
|
||||
std::string text = stream.str();
|
||||
context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO,
|
||||
context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
|
||||
context->token->location,
|
||||
text.c_str());
|
||||
YYABORT;
|
||||
@ -159,7 +165,7 @@ expression
|
||||
std::ostringstream stream;
|
||||
stream << $1 << " / " << $3;
|
||||
std::string text = stream.str();
|
||||
context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO,
|
||||
context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
|
||||
context->token->location,
|
||||
text.c_str());
|
||||
YYABORT;
|
||||
@ -201,7 +207,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
|
||||
unsigned int val = 0;
|
||||
if (!token->uValue(&val))
|
||||
{
|
||||
context->diagnostics->report(pp::Diagnostics::INTEGER_OVERFLOW,
|
||||
context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
|
||||
token->location, token->text);
|
||||
}
|
||||
*lvalp = static_cast<YYSTYPE>(val);
|
||||
@ -242,7 +248,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
|
||||
|
||||
void yyerror(Context* context, const char* reason)
|
||||
{
|
||||
context->diagnostics->report(pp::Diagnostics::INVALID_EXPRESSION,
|
||||
context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
|
||||
context->token->location,
|
||||
reason);
|
||||
}
|
||||
@ -270,12 +276,12 @@ bool ExpressionParser::parse(Token* token, int* result)
|
||||
break;
|
||||
|
||||
case 2:
|
||||
mDiagnostics->report(Diagnostics::OUT_OF_MEMORY, token->location, "");
|
||||
mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
mDiagnostics->report(Diagnostics::INTERNAL_ERROR, token->location, "");
|
||||
mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
|
||||
|
||||
if (token.type == Token::LAST)
|
||||
{
|
||||
mDiagnostics->report(Diagnostics::MACRO_UNTERMINATED_INVOCATION,
|
||||
mDiagnostics->report(Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION,
|
||||
identifier.location, identifier.text);
|
||||
// Do not lose EOF token.
|
||||
ungetToken(token);
|
||||
@ -302,8 +302,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
|
||||
if (args->size() != params.size())
|
||||
{
|
||||
Diagnostics::ID id = args->size() < macro.parameters.size() ?
|
||||
Diagnostics::MACRO_TOO_FEW_ARGS :
|
||||
Diagnostics::MACRO_TOO_MANY_ARGS;
|
||||
Diagnostics::PP_MACRO_TOO_FEW_ARGS :
|
||||
Diagnostics::PP_MACRO_TOO_MANY_ARGS;
|
||||
mDiagnostics->report(id, identifier.location, identifier.text);
|
||||
return false;
|
||||
}
|
||||
|
@ -101,11 +101,11 @@ void Preprocessor::lex(Token* token)
|
||||
assert(false);
|
||||
break;
|
||||
case Token::PP_NUMBER:
|
||||
mImpl->diagnostics->report(Diagnostics::INVALID_NUMBER,
|
||||
mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER,
|
||||
token->location, token->text);
|
||||
break;
|
||||
case Token::PP_OTHER:
|
||||
mImpl->diagnostics->report(Diagnostics::INVALID_CHARACTER,
|
||||
mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER,
|
||||
token->location, token->text);
|
||||
break;
|
||||
default:
|
||||
|
@ -256,7 +256,7 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
|
||||
|
||||
if (YY_START == COMMENT)
|
||||
{
|
||||
yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT,
|
||||
yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT,
|
||||
pp::SourceLocation(yyfileno, yylineno),
|
||||
"");
|
||||
}
|
||||
@ -304,7 +304,7 @@ void Tokenizer::lex(Token* token)
|
||||
token->type = yylex(&token->text, &token->location, mHandle);
|
||||
if (token->text.size() > mMaxTokenLength)
|
||||
{
|
||||
mContext.diagnostics->report(Diagnostics::TOKEN_TOO_LONG,
|
||||
mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
|
||||
token->location, token->text);
|
||||
token->text.erase(mMaxTokenLength);
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ enum TQualifier
|
||||
{
|
||||
EvqTemporary, // For temporaries (within a function), read/write
|
||||
EvqGlobal, // For globals read/write
|
||||
EvqInternal, // For internal use, not visible to the user
|
||||
EvqConst, // User defined constants and non-output parameters in functions
|
||||
EvqAttribute, // Readonly
|
||||
EvqVaryingIn, // readonly, fragment shaders only
|
@ -4,9 +4,9 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/translator/BuiltInFunctionEmulator.h"
|
||||
|
||||
#include "compiler/SymbolTable.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
namespace {
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
//
|
||||
// This class decides which built-in functions need to be replaced with the
|
@ -4,8 +4,9 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/TranslatorGLSL.h"
|
||||
#include "compiler/TranslatorESSL.h"
|
||||
#include "compiler/translator/TranslatorESSL.h"
|
||||
#include "compiler/translator/TranslatorGLSL.h"
|
||||
#include "compiler/translator/TranslatorHLSL.h"
|
||||
|
||||
//
|
||||
// This function must be provided to create the actual
|
||||
@ -16,10 +17,13 @@ TCompiler* ConstructCompiler(
|
||||
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
|
||||
{
|
||||
switch (output) {
|
||||
case SH_GLSL_OUTPUT:
|
||||
return new TranslatorGLSL(type, spec);
|
||||
case SH_ESSL_OUTPUT:
|
||||
return new TranslatorESSL(type, spec);
|
||||
case SH_GLSL_OUTPUT:
|
||||
return new TranslatorGLSL(type, spec);
|
||||
case SH_HLSL9_OUTPUT:
|
||||
case SH_HLSL11_OUTPUT:
|
||||
return new TranslatorHLSL(type, spec, output);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
@ -11,8 +11,12 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "compiler/PoolAlloc.h"
|
||||
#include "compiler/translator/PoolAlloc.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
#include "common/angleutils.h"
|
||||
|
||||
struct TSourceLoc {
|
||||
int first_file;
|
||||
@ -74,4 +78,15 @@ public:
|
||||
TMap(const tAllocator& a) : std::map<K, D, CMP, tAllocator>(std::map<K, D, CMP, tAllocator>::key_compare(), a) {}
|
||||
};
|
||||
|
||||
// Integer to TString conversion
|
||||
template <typename T>
|
||||
inline TString str(T i)
|
||||
{
|
||||
ASSERT(std::numeric_limits<T>::is_integer);
|
||||
char buffer[((8 * sizeof(T)) / 3) + 3];
|
||||
const char *formatStr = std::numeric_limits<T>::is_signed ? "%d" : "%u";
|
||||
snprintf(buffer, sizeof(buffer), formatStr, i);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif // _COMMON_INCLUDED_
|
@ -4,22 +4,23 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/DetectCallDepth.h"
|
||||
#include "compiler/ForLoopUnroll.h"
|
||||
#include "compiler/Initialize.h"
|
||||
#include "compiler/InitializeGLPosition.h"
|
||||
#include "compiler/InitializeParseContext.h"
|
||||
#include "compiler/MapLongVariableNames.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/RenameFunction.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/ValidateLimitations.h"
|
||||
#include "compiler/VariablePacker.h"
|
||||
#include "compiler/depgraph/DependencyGraph.h"
|
||||
#include "compiler/depgraph/DependencyGraphOutput.h"
|
||||
#include "compiler/timing/RestrictFragmentShaderTiming.h"
|
||||
#include "compiler/timing/RestrictVertexShaderTiming.h"
|
||||
#include "compiler/translator/BuiltInFunctionEmulator.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/UnfoldShortCircuitAST.h"
|
||||
#include "compiler/translator/ValidateLimitations.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"
|
||||
|
||||
bool isWebGLBasedSpec(ShShaderSpec spec)
|
||||
@ -28,43 +29,51 @@ bool isWebGLBasedSpec(ShShaderSpec spec)
|
||||
}
|
||||
|
||||
namespace {
|
||||
class TScopedPoolAllocator {
|
||||
public:
|
||||
TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator) {
|
||||
class TScopedPoolAllocator
|
||||
{
|
||||
public:
|
||||
TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator)
|
||||
{
|
||||
mAllocator->push();
|
||||
SetGlobalPoolAllocator(mAllocator);
|
||||
}
|
||||
~TScopedPoolAllocator() {
|
||||
~TScopedPoolAllocator()
|
||||
{
|
||||
SetGlobalPoolAllocator(NULL);
|
||||
mAllocator->pop();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
TPoolAllocator* mAllocator;
|
||||
};
|
||||
|
||||
class TScopedSymbolTableLevel {
|
||||
public:
|
||||
TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table) {
|
||||
class TScopedSymbolTableLevel
|
||||
{
|
||||
public:
|
||||
TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table)
|
||||
{
|
||||
ASSERT(mTable->atBuiltInLevel());
|
||||
mTable->push();
|
||||
}
|
||||
~TScopedSymbolTableLevel() {
|
||||
~TScopedSymbolTableLevel()
|
||||
{
|
||||
while (!mTable->atBuiltInLevel())
|
||||
mTable->pop();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
TSymbolTable* mTable;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TShHandleBase::TShHandleBase() {
|
||||
TShHandleBase::TShHandleBase()
|
||||
{
|
||||
allocator.push();
|
||||
SetGlobalPoolAllocator(&allocator);
|
||||
}
|
||||
|
||||
TShHandleBase::~TShHandleBase() {
|
||||
TShHandleBase::~TShHandleBase()
|
||||
{
|
||||
SetGlobalPoolAllocator(NULL);
|
||||
allocator.popAll();
|
||||
}
|
||||
@ -150,7 +159,8 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
bool success =
|
||||
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
|
||||
(parseContext.treeRoot != NULL);
|
||||
if (success) {
|
||||
if (success)
|
||||
{
|
||||
TIntermNode* root = parseContext.treeRoot;
|
||||
success = intermediate.postProcess(root);
|
||||
|
||||
@ -189,20 +199,31 @@ bool TCompiler::compile(const char* const shaderStrings[],
|
||||
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
|
||||
mapLongVariableNames(root);
|
||||
|
||||
if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION)) {
|
||||
InitializeGLPosition initGLPosition;
|
||||
root->traverse(&initGLPosition);
|
||||
if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
|
||||
initializeGLPosition(root);
|
||||
|
||||
if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT))
|
||||
{
|
||||
UnfoldShortCircuitAST unfoldShortCircuit;
|
||||
root->traverse(&unfoldShortCircuit);
|
||||
unfoldShortCircuit.updateTree();
|
||||
}
|
||||
|
||||
if (success && (compileOptions & SH_VARIABLES)) {
|
||||
if (success && (compileOptions & SH_VARIABLES))
|
||||
{
|
||||
collectVariables(root);
|
||||
if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) {
|
||||
if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
|
||||
{
|
||||
success = enforcePackingRestrictions();
|
||||
if (!success) {
|
||||
if (!success)
|
||||
{
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "too many uniforms";
|
||||
}
|
||||
}
|
||||
if (success && shaderType == SH_VERTEX_SHADER &&
|
||||
(compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
|
||||
initializeVaryingsWithoutStaticUse(root);
|
||||
}
|
||||
|
||||
if (success && (compileOptions & SH_INTERMEDIATE_TREE))
|
||||
@ -251,12 +272,14 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
|
||||
symbolTable.setDefaultPrecision(integer, EbpHigh);
|
||||
symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
|
||||
break;
|
||||
default: assert(false && "Language not supported");
|
||||
default:
|
||||
assert(false && "Language not supported");
|
||||
}
|
||||
// We set defaults for all the sampler types, even those that are
|
||||
// only available if an extension exists.
|
||||
for (int samplerType = EbtGuardSamplerBegin + 1;
|
||||
samplerType < EbtGuardSamplerEnd; ++samplerType) {
|
||||
samplerType < EbtGuardSamplerEnd; ++samplerType)
|
||||
{
|
||||
sampler.type = static_cast<TBasicType>(samplerType);
|
||||
symbolTable.setDefaultPrecision(sampler, EbpLow);
|
||||
}
|
||||
@ -288,24 +311,25 @@ bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool lim
|
||||
{
|
||||
DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth);
|
||||
root->traverse(&detect);
|
||||
switch (detect.detectCallDepth()) {
|
||||
case DetectCallDepth::kErrorNone:
|
||||
return true;
|
||||
case DetectCallDepth::kErrorMissingMain:
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Missing main()";
|
||||
return false;
|
||||
case DetectCallDepth::kErrorRecursion:
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Function recursion detected";
|
||||
return false;
|
||||
case DetectCallDepth::kErrorMaxDepthExceeded:
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Function call stack too deep";
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
switch (detect.detectCallDepth())
|
||||
{
|
||||
case DetectCallDepth::kErrorNone:
|
||||
return true;
|
||||
case DetectCallDepth::kErrorMissingMain:
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Missing main()";
|
||||
return false;
|
||||
case DetectCallDepth::kErrorRecursion:
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Function recursion detected";
|
||||
return false;
|
||||
case DetectCallDepth::kErrorMaxDepthExceeded:
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Function call stack too deep";
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,7 +339,8 @@ void TCompiler::rewriteCSSShader(TIntermNode* root)
|
||||
root->traverse(&renamer);
|
||||
}
|
||||
|
||||
bool TCompiler::validateLimitations(TIntermNode* root) {
|
||||
bool TCompiler::validateLimitations(TIntermNode* root)
|
||||
{
|
||||
ValidateLimitations validate(shaderType, infoSink.info);
|
||||
root->traverse(&validate);
|
||||
return validate.numErrors() == 0;
|
||||
@ -323,26 +348,30 @@ bool TCompiler::validateLimitations(TIntermNode* root) {
|
||||
|
||||
bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
|
||||
{
|
||||
if (shaderSpec != SH_WEBGL_SPEC) {
|
||||
if (shaderSpec != SH_WEBGL_SPEC)
|
||||
{
|
||||
infoSink.info << "Timing restrictions must be enforced under the WebGL spec.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shaderType == SH_FRAGMENT_SHADER) {
|
||||
if (shaderType == SH_FRAGMENT_SHADER)
|
||||
{
|
||||
TDependencyGraph graph(root);
|
||||
|
||||
// Output any errors first.
|
||||
bool success = enforceFragmentShaderTimingRestrictions(graph);
|
||||
|
||||
// Then, output the dependency graph.
|
||||
if (outputGraph) {
|
||||
if (outputGraph)
|
||||
{
|
||||
TDependencyGraphOutput output(infoSink.info);
|
||||
output.outputAllSpanningTrees(graph);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return enforceVertexShaderTimingRestrictions(root);
|
||||
}
|
||||
}
|
||||
@ -362,7 +391,8 @@ bool TCompiler::limitExpressionComplexity(TIntermNode* root)
|
||||
samplerSymbol->traverse(&graphTraverser);
|
||||
}
|
||||
|
||||
if (traverser.getMaxDepth() > maxExpressionComplexity) {
|
||||
if (traverser.getMaxDepth() > maxExpressionComplexity)
|
||||
{
|
||||
infoSink.info << "Expression too complex.";
|
||||
return false;
|
||||
}
|
||||
@ -395,6 +425,70 @@ bool TCompiler::enforcePackingRestrictions()
|
||||
return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
|
||||
}
|
||||
|
||||
void TCompiler::initializeGLPosition(TIntermNode* root)
|
||||
{
|
||||
InitializeVariables::InitVariableInfoList variables;
|
||||
InitializeVariables::InitVariableInfo var(
|
||||
"gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
|
||||
variables.push_back(var);
|
||||
InitializeVariables initializer(variables);
|
||||
root->traverse(&initializer);
|
||||
}
|
||||
|
||||
void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
|
||||
{
|
||||
InitializeVariables::InitVariableInfoList variables;
|
||||
for (size_t ii = 0; ii < varyings.size(); ++ii)
|
||||
{
|
||||
const TVariableInfo& 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);
|
||||
TString name = varying.name.c_str();
|
||||
if (varying.isArray)
|
||||
{
|
||||
type.setArraySize(varying.size);
|
||||
name = name.substr(0, name.find_first_of('['));
|
||||
}
|
||||
|
||||
InitializeVariables::InitVariableInfo var(name, type);
|
||||
variables.push_back(var);
|
||||
}
|
||||
InitializeVariables initializer(variables);
|
||||
root->traverse(&initializer);
|
||||
}
|
||||
|
||||
void TCompiler::mapLongVariableNames(TIntermNode* root)
|
||||
{
|
||||
ASSERT(longNameMap);
|
@ -4,8 +4,8 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/DetectCallDepth.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/translator/DetectCallDepth.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
|
||||
DetectCallDepth::FunctionNode::FunctionNode(const TString& fname)
|
||||
: name(fname),
|
@ -10,8 +10,8 @@
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/VariableInfo.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/VariableInfo.h"
|
||||
|
||||
class TInfoSink;
|
||||
|
@ -8,9 +8,9 @@
|
||||
// gradients of functions with discontinuities.
|
||||
//
|
||||
|
||||
#include "compiler/DetectDiscontinuity.h"
|
||||
#include "compiler/translator/DetectDiscontinuity.h"
|
||||
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
|
||||
namespace sh
|
||||
{
|
@ -11,7 +11,7 @@
|
||||
#ifndef COMPILER_DETECTDISCONTINUITY_H_
|
||||
#define COMPILER_DETECTDISCONTINUITY_H_
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
namespace sh
|
||||
{
|
@ -4,10 +4,10 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/Diagnostics.h"
|
||||
#include "compiler/translator/Diagnostics.h"
|
||||
|
||||
#include "compiler/debug.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/preprocessor/SourceLocation.h"
|
||||
|
||||
TDiagnostics::TDiagnostics(TInfoSink& infoSink) :
|
||||
@ -30,11 +30,11 @@ void TDiagnostics::writeInfo(Severity severity,
|
||||
TPrefixType prefix = EPrefixNone;
|
||||
switch (severity)
|
||||
{
|
||||
case ERROR:
|
||||
case PP_ERROR:
|
||||
++mNumErrors;
|
||||
prefix = EPrefixError;
|
||||
break;
|
||||
case WARNING:
|
||||
case PP_WARNING:
|
||||
++mNumWarnings;
|
||||
prefix = EPrefixWarning;
|
||||
break;
|
@ -4,12 +4,12 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/DirectiveHandler.h"
|
||||
#include "compiler/translator/DirectiveHandler.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "compiler/debug.h"
|
||||
#include "compiler/Diagnostics.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
#include "compiler/translator/Diagnostics.h"
|
||||
|
||||
static TBehavior getBehavior(const std::string& str)
|
||||
{
|
||||
@ -39,7 +39,7 @@ TDirectiveHandler::~TDirectiveHandler()
|
||||
void TDirectiveHandler::handleError(const pp::SourceLocation& loc,
|
||||
const std::string& msg)
|
||||
{
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, msg, "", "");
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", "");
|
||||
}
|
||||
|
||||
void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
|
||||
@ -73,12 +73,12 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
|
||||
}
|
||||
else
|
||||
{
|
||||
mDiagnostics.report(pp::Diagnostics::UNRECOGNIZED_PRAGMA, loc, name);
|
||||
mDiagnostics.report(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, loc, name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (invalidValue)
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
|
||||
"invalid pragma value", value,
|
||||
"'on' or 'off' expected");
|
||||
}
|
||||
@ -92,7 +92,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
|
||||
TBehavior behaviorVal = getBehavior(behavior);
|
||||
if (behaviorVal == EBhUndefined)
|
||||
{
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
|
||||
"behavior", name, "invalid");
|
||||
return;
|
||||
}
|
||||
@ -101,13 +101,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
|
||||
{
|
||||
if (behaviorVal == EBhRequire)
|
||||
{
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
|
||||
"extension", name,
|
||||
"cannot have 'require' behavior");
|
||||
}
|
||||
else if (behaviorVal == EBhEnable)
|
||||
{
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
|
||||
"extension", name,
|
||||
"cannot have 'enable' behavior");
|
||||
}
|
||||
@ -127,15 +127,15 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
|
||||
return;
|
||||
}
|
||||
|
||||
pp::Diagnostics::Severity severity = pp::Diagnostics::ERROR;
|
||||
pp::Diagnostics::Severity severity = pp::Diagnostics::PP_ERROR;
|
||||
switch (behaviorVal) {
|
||||
case EBhRequire:
|
||||
severity = pp::Diagnostics::ERROR;
|
||||
severity = pp::Diagnostics::PP_ERROR;
|
||||
break;
|
||||
case EBhEnable:
|
||||
case EBhWarn:
|
||||
case EBhDisable:
|
||||
severity = pp::Diagnostics::WARNING;
|
||||
severity = pp::Diagnostics::PP_WARNING;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -155,7 +155,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc,
|
||||
std::stringstream stream;
|
||||
stream << version;
|
||||
std::string str = stream.str();
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
|
||||
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
|
||||
"version number", str, "not supported");
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@
|
||||
#ifndef COMPILER_DIRECTIVE_HANDLER_H_
|
||||
#define COMPILER_DIRECTIVE_HANDLER_H_
|
||||
|
||||
#include "compiler/ExtensionBehavior.h"
|
||||
#include "compiler/Pragma.h"
|
||||
#include "compiler/translator/ExtensionBehavior.h"
|
||||
#include "compiler/translator/Pragma.h"
|
||||
#include "compiler/preprocessor/DirectiveHandlerBase.h"
|
||||
|
||||
class TDiagnostics;
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/ForLoopUnroll.h"
|
||||
#include "compiler/translator/ForLoopUnroll.h"
|
||||
|
||||
namespace {
|
||||
|
@ -4,7 +4,10 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#ifndef COMPILER_FORLOOPUNROLL_H_
|
||||
#define COMPILER_FORLOOPUNROLL_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
struct TLoopIndexInfo {
|
||||
int id;
|
||||
@ -46,3 +49,4 @@ private:
|
||||
TVector<TLoopIndexInfo> mLoopIndexStack;
|
||||
};
|
||||
|
||||
#endif
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#define HASHED_NAME_PREFIX "webgl_"
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
|
||||
void TInfoSinkBase::prefix(TPrefixType p) {
|
||||
switch(p) {
|
@ -8,7 +8,8 @@
|
||||
#define _INFOSINK_INCLUDED_
|
||||
|
||||
#include <math.h>
|
||||
#include "compiler/Common.h"
|
||||
#include <stdlib.h>
|
||||
#include "compiler/translator/Common.h"
|
||||
|
||||
// Returns the fractional part of the given floating-point number.
|
||||
inline float fractionalPart(float f) {
|
@ -10,9 +10,9 @@
|
||||
// built-in functions and operators.
|
||||
//
|
||||
|
||||
#include "compiler/Initialize.h"
|
||||
#include "compiler/translator/Initialize.h"
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable)
|
||||
{
|
||||
@ -363,7 +363,7 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI
|
||||
symbolTable.insertBuiltIn(float2, "dFdx", float2);
|
||||
symbolTable.insertBuiltIn(float3, "dFdx", float3);
|
||||
symbolTable.insertBuiltIn(float4, "dFdx", float4);
|
||||
|
||||
|
||||
symbolTable.insertBuiltIn(float1, "dFdy", float1);
|
||||
symbolTable.insertBuiltIn(float2, "dFdy", float2);
|
||||
symbolTable.insertBuiltIn(float3, "dFdy", float3);
|
@ -7,9 +7,9 @@
|
||||
#ifndef _INITIALIZE_INCLUDED_
|
||||
#define _INITIALIZE_INCLUDED_
|
||||
|
||||
#include "compiler/Common.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/SymbolTable.h"
|
||||
#include "compiler/translator/Common.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table);
|
||||
|
@ -4,11 +4,11 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/InitializeDll.h"
|
||||
#include "compiler/translator/InitializeDll.h"
|
||||
|
||||
#include "compiler/InitializeGlobals.h"
|
||||
#include "compiler/InitializeParseContext.h"
|
||||
#include "compiler/osinclude.h"
|
||||
#include "compiler/translator/InitializeGlobals.h"
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
#include "compiler/translator/osinclude.h"
|
||||
|
||||
bool InitProcess()
|
||||
{
|
@ -4,9 +4,9 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/InitializeParseContext.h"
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
|
||||
#include "compiler/osinclude.h"
|
||||
#include "compiler/translator/osinclude.h"
|
||||
|
||||
OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
|
||||
|
116
src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp
vendored
Normal file
116
src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "compiler/translator/InitializeVariables.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
TIntermConstantUnion* constructFloatConstUnionNode(const TType& type)
|
||||
{
|
||||
TType myType = type;
|
||||
unsigned char size = myType.getNominalSize();
|
||||
if (myType.isMatrix())
|
||||
size *= size;
|
||||
ConstantUnion *u = new ConstantUnion[size];
|
||||
for (int ii = 0; ii < size; ++ii)
|
||||
u[ii].setFConst(0.0f);
|
||||
|
||||
myType.clearArrayness();
|
||||
myType.setQualifier(EvqConst);
|
||||
TIntermConstantUnion *node = new TIntermConstantUnion(u, myType);
|
||||
return node;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
{
|
||||
bool visitChildren = !mCodeInserted;
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence:
|
||||
break;
|
||||
case EOpFunction:
|
||||
{
|
||||
// Function definition.
|
||||
ASSERT(visit == PreVisit);
|
||||
if (node->getName() == "main(")
|
||||
{
|
||||
TIntermSequence &sequence = node->getSequence();
|
||||
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
|
||||
TIntermAggregate *body = NULL;
|
||||
if (sequence.size() == 1)
|
||||
{
|
||||
body = new TIntermAggregate(EOpSequence);
|
||||
sequence.push_back(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
body = sequence[1]->getAsAggregate();
|
||||
}
|
||||
ASSERT(body);
|
||||
insertInitCode(body->getSequence());
|
||||
mCodeInserted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
visitChildren = false;
|
||||
break;
|
||||
}
|
||||
return visitChildren;
|
||||
}
|
||||
|
||||
void InitializeVariables::insertInitCode(TIntermSequence& sequence)
|
||||
{
|
||||
for (size_t ii = 0; ii < mVariables.size(); ++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);
|
||||
|
||||
TIntermBinary *indexDirect = new TIntermBinary(EOpIndexDirect);
|
||||
TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
|
||||
indexDirect->setLeft(symbol);
|
||||
TIntermConstantUnion *indexNode = constructIndexNode(index);
|
||||
indexDirect->setRight(indexNode);
|
||||
|
||||
assign->setLeft(indexDirect);
|
||||
|
||||
TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
|
||||
assign->setRight(zeroConst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TIntermBinary *assign = new TIntermBinary(EOpAssign);
|
||||
sequence.insert(sequence.begin(), assign);
|
||||
TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
|
||||
assign->setLeft(symbol);
|
||||
TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
|
||||
assign->setRight(zeroConst);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
50
src/3rdparty/angle/src/compiler/translator/InitializeVariables.h
vendored
Normal file
50
src/3rdparty/angle/src/compiler/translator/InitializeVariables.h
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_INITIALIZE_VARIABLES_H_
|
||||
#define COMPILER_INITIALIZE_VARIABLES_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
class InitializeVariables : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
struct InitVariableInfo
|
||||
{
|
||||
TString name;
|
||||
TType type;
|
||||
|
||||
InitVariableInfo(const TString& _name, const TType& _type)
|
||||
: name(_name),
|
||||
type(_type)
|
||||
{
|
||||
}
|
||||
};
|
||||
typedef TVector<InitVariableInfo> InitVariableInfoList;
|
||||
|
||||
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 visitAggregate(Visit visit, TIntermAggregate* node);
|
||||
|
||||
private:
|
||||
void insertInitCode(TIntermSequence& sequence);
|
||||
|
||||
InitVariableInfoList mVariables;
|
||||
bool mCodeInserted;
|
||||
};
|
||||
|
||||
#endif // COMPILER_INITIALIZE_VARIABLES_H_
|
259
src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp
vendored
Normal file
259
src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp
vendored
Normal file
@ -0,0 +1,259 @@
|
||||
//
|
||||
// Copyright (c) 2002-2010 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/intermediate.h"
|
||||
|
||||
//
|
||||
// Traverse the intermediate representation tree, and
|
||||
// call a node type specific function for each node.
|
||||
// Done recursively through the member function Traverse().
|
||||
// Node types can be skipped if their function to call is 0,
|
||||
// but their subtree will still be traversed.
|
||||
// Nodes with children can have their whole subtree skipped
|
||||
// if preVisit is turned on and the type specific function
|
||||
// returns false.
|
||||
//
|
||||
// preVisit, postVisit, and rightToLeft control what order
|
||||
// nodes are visited in.
|
||||
//
|
||||
|
||||
//
|
||||
// Traversal functions for terminals are straighforward....
|
||||
//
|
||||
void TIntermSymbol::traverse(TIntermTraverser *it)
|
||||
{
|
||||
it->visitSymbol(this);
|
||||
}
|
||||
|
||||
void TIntermConstantUnion::traverse(TIntermTraverser *it)
|
||||
{
|
||||
it->visitConstantUnion(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a binary node.
|
||||
//
|
||||
void TIntermBinary::traverse(TIntermTraverser *it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
//
|
||||
// visit the node before children if pre-visiting.
|
||||
//
|
||||
if (it->preVisit)
|
||||
visit = it->visitBinary(PreVisit, this);
|
||||
|
||||
//
|
||||
// Visit the children, in the right order.
|
||||
//
|
||||
if (visit)
|
||||
{
|
||||
it->incrementDepth(this);
|
||||
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (right)
|
||||
right->traverse(it);
|
||||
|
||||
if (it->inVisit)
|
||||
visit = it->visitBinary(InVisit, this);
|
||||
|
||||
if (visit && left)
|
||||
left->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left)
|
||||
left->traverse(it);
|
||||
|
||||
if (it->inVisit)
|
||||
visit = it->visitBinary(InVisit, this);
|
||||
|
||||
if (visit && right)
|
||||
right->traverse(it);
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
//
|
||||
// Visit the node after the children, if requested and the traversal
|
||||
// hasn't been cancelled yet.
|
||||
//
|
||||
if (visit && it->postVisit)
|
||||
it->visitBinary(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a unary node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermUnary::traverse(TIntermTraverser *it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitUnary(PreVisit, this);
|
||||
|
||||
if (visit) {
|
||||
it->incrementDepth(this);
|
||||
operand->traverse(it);
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitUnary(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse an aggregate node. Same comments in binary node apply here.
|
||||
//
|
||||
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++)
|
||||
{
|
||||
(*sit)->traverse(it);
|
||||
|
||||
if (visit && it->inVisit)
|
||||
{
|
||||
if (*sit != sequence.front())
|
||||
visit = it->visitAggregate(InVisit, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
|
||||
{
|
||||
(*sit)->traverse(it);
|
||||
|
||||
if (visit && it->inVisit)
|
||||
{
|
||||
if (*sit != sequence.back())
|
||||
visit = it->visitAggregate(InVisit, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitAggregate(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a selection node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermSelection::traverse(TIntermTraverser *it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitSelection(PreVisit, this);
|
||||
|
||||
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);
|
||||
}
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitSelection(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a loop node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermLoop::traverse(TIntermTraverser *it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitLoop(PreVisit, this);
|
||||
|
||||
if (visit)
|
||||
{
|
||||
it->incrementDepth(this);
|
||||
|
||||
if (it->rightToLeft)
|
||||
{
|
||||
if (expr)
|
||||
expr->traverse(it);
|
||||
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
|
||||
if (cond)
|
||||
cond->traverse(it);
|
||||
|
||||
if (init)
|
||||
init->traverse(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (init)
|
||||
init->traverse(it);
|
||||
|
||||
if (cond)
|
||||
cond->traverse(it);
|
||||
|
||||
if (body)
|
||||
body->traverse(it);
|
||||
|
||||
if (expr)
|
||||
expr->traverse(it);
|
||||
}
|
||||
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitLoop(PostVisit, this);
|
||||
}
|
||||
|
||||
//
|
||||
// Traverse a branch node. Same comments in binary node apply here.
|
||||
//
|
||||
void TIntermBranch::traverse(TIntermTraverser *it)
|
||||
{
|
||||
bool visit = true;
|
||||
|
||||
if (it->preVisit)
|
||||
visit = it->visitBranch(PreVisit, this);
|
||||
|
||||
if (visit && expression) {
|
||||
it->incrementDepth(this);
|
||||
expression->traverse(it);
|
||||
it->decrementDepth();
|
||||
}
|
||||
|
||||
if (visit && it->postVisit)
|
||||
it->visitBranch(PostVisit, this);
|
||||
}
|
||||
|
@ -12,18 +12,20 @@
|
||||
#include <limits.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "compiler/HashNames.h"
|
||||
#include "compiler/localintermediate.h"
|
||||
#include "compiler/QualifierAlive.h"
|
||||
#include "compiler/RemoveTree.h"
|
||||
#include "compiler/translator/HashNames.h"
|
||||
#include "compiler/translator/localintermediate.h"
|
||||
#include "compiler/translator/QualifierAlive.h"
|
||||
#include "compiler/translator/RemoveTree.h"
|
||||
|
||||
bool CompareStructure(const TType& leftNodeType, ConstantUnion* rightUnionArray, ConstantUnion* leftUnionArray);
|
||||
|
||||
static TPrecision GetHigherPrecision( TPrecision left, TPrecision right ){
|
||||
static TPrecision GetHigherPrecision(TPrecision left, TPrecision right)
|
||||
{
|
||||
return left > right ? left : right;
|
||||
}
|
||||
|
||||
const char* getOperatorString(TOperator op) {
|
||||
const char* getOperatorString(TOperator op)
|
||||
{
|
||||
switch (op) {
|
||||
case EOpInitialize: return "=";
|
||||
case EOpAssign: return "=";
|
||||
@ -742,12 +744,67 @@ void TIntermediate::remove(TIntermNode* root)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#define REPLACE_IF_IS(node, type, original, replacement) \
|
||||
if (node == original) { \
|
||||
node = static_cast<type *>(replacement); \
|
||||
return true; \
|
||||
}
|
||||
|
||||
bool TIntermLoop::replaceChildNode(
|
||||
TIntermNode *original, TIntermNode *replacement)
|
||||
{
|
||||
REPLACE_IF_IS(init, TIntermNode, original, replacement);
|
||||
REPLACE_IF_IS(cond, TIntermTyped, original, replacement);
|
||||
REPLACE_IF_IS(expr, TIntermTyped, original, replacement);
|
||||
REPLACE_IF_IS(body, TIntermNode, original, replacement);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TIntermBranch::replaceChildNode(
|
||||
TIntermNode *original, TIntermNode *replacement)
|
||||
{
|
||||
REPLACE_IF_IS(expression, TIntermTyped, original, replacement);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TIntermBinary::replaceChildNode(
|
||||
TIntermNode *original, TIntermNode *replacement)
|
||||
{
|
||||
REPLACE_IF_IS(left, TIntermTyped, original, replacement);
|
||||
REPLACE_IF_IS(right, TIntermTyped, original, replacement);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TIntermUnary::replaceChildNode(
|
||||
TIntermNode *original, TIntermNode *replacement)
|
||||
{
|
||||
REPLACE_IF_IS(operand, TIntermTyped, original, replacement);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TIntermAggregate::replaceChildNode(
|
||||
TIntermNode *original, TIntermNode *replacement)
|
||||
{
|
||||
for (size_t ii = 0; ii < sequence.size(); ++ii)
|
||||
{
|
||||
REPLACE_IF_IS(sequence[ii], TIntermNode, original, replacement);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TIntermSelection::replaceChildNode(
|
||||
TIntermNode *original, TIntermNode *replacement)
|
||||
{
|
||||
REPLACE_IF_IS(condition, TIntermTyped, original, replacement);
|
||||
REPLACE_IF_IS(trueBlock, TIntermNode, original, replacement);
|
||||
REPLACE_IF_IS(falseBlock, TIntermNode, original, replacement);
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Say whether or not an operation node changes the value of a variable.
|
||||
//
|
||||
// Returns true if state is modified.
|
||||
//
|
||||
bool TIntermOperator::modifiesState() const
|
||||
bool TIntermOperator::isAssignment() const
|
||||
{
|
||||
switch (op) {
|
||||
case EOpPostIncrement:
|
||||
@ -796,6 +853,7 @@ bool TIntermOperator::isConstructor() const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure the type of a unary operator is appropriate for its
|
||||
// combination of operation and operand type.
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/MapLongVariableNames.h"
|
||||
#include "compiler/translator/MapLongVariableNames.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -102,13 +102,6 @@ void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
|
||||
}
|
||||
}
|
||||
|
||||
bool MapLongVariableNames::visitLoop(Visit, TIntermLoop* node)
|
||||
{
|
||||
if (node->getInit())
|
||||
node->getInit()->traverse(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
TString MapLongVariableNames::mapGlobalLongName(const TString& name)
|
||||
{
|
||||
ASSERT(mGlobalMap);
|
@ -9,8 +9,8 @@
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/VariableInfo.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
|
||||
@ -48,7 +48,6 @@ public:
|
||||
MapLongVariableNames(LongNameMap* globalMap);
|
||||
|
||||
virtual void visitSymbol(TIntermSymbol*);
|
||||
virtual bool visitLoop(Visit, TIntermLoop*);
|
||||
|
||||
private:
|
||||
TString mapGlobalLongName(const TString& name);
|
80
src/3rdparty/angle/src/compiler/translator/NodeSearch.h
vendored
Normal file
80
src/3rdparty/angle/src/compiler/translator/NodeSearch.h
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// NodeSearch.h: Utilities for searching translator node graphs
|
||||
//
|
||||
|
||||
#ifndef TRANSLATOR_NODESEARCH_H_
|
||||
#define TRANSLATOR_NODESEARCH_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
template <class Parent>
|
||||
class NodeSearchTraverser : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
NodeSearchTraverser()
|
||||
: mFound(false)
|
||||
{}
|
||||
|
||||
bool found() const { return mFound; }
|
||||
|
||||
static bool search(TIntermNode *node)
|
||||
{
|
||||
Parent searchTraverser;
|
||||
node->traverse(&searchTraverser);
|
||||
return searchTraverser.found();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool mFound;
|
||||
};
|
||||
|
||||
class FindDiscard : public NodeSearchTraverser<FindDiscard>
|
||||
{
|
||||
public:
|
||||
virtual bool visitBranch(Visit visit, TIntermBranch *node)
|
||||
{
|
||||
switch (node->getFlowOp())
|
||||
{
|
||||
case EOpKill:
|
||||
mFound = true;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return !mFound;
|
||||
}
|
||||
};
|
||||
|
||||
class FindSideEffectRewriting : public NodeSearchTraverser<FindSideEffectRewriting>
|
||||
{
|
||||
public:
|
||||
virtual bool visitBinary(Visit visit, TIntermBinary *node)
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpLogicalOr:
|
||||
case EOpLogicalAnd:
|
||||
if (node->getRight()->hasSideEffects())
|
||||
{
|
||||
mFound = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return !mFound;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TRANSLATOR_NODESEARCH_H_
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/OutputESSL.h"
|
||||
#include "compiler/translator/OutputESSL.h"
|
||||
|
||||
TOutputESSL::TOutputESSL(TInfoSinkBase& objSink,
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
@ -7,7 +7,7 @@
|
||||
#ifndef CROSSCOMPILERGLSL_OUTPUTESSL_H_
|
||||
#define CROSSCOMPILERGLSL_OUTPUTESSL_H_
|
||||
|
||||
#include "compiler/OutputGLSLBase.h"
|
||||
#include "compiler/translator/OutputGLSLBase.h"
|
||||
|
||||
class TOutputESSL : public TOutputGLSLBase
|
||||
{
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/OutputGLSL.h"
|
||||
#include "compiler/translator/OutputGLSL.h"
|
||||
|
||||
TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink,
|
||||
ShArrayIndexClampingStrategy clampingStrategy,
|
@ -7,7 +7,7 @@
|
||||
#ifndef CROSSCOMPILERGLSL_OUTPUTGLSL_H_
|
||||
#define CROSSCOMPILERGLSL_OUTPUTGLSL_H_
|
||||
|
||||
#include "compiler/OutputGLSLBase.h"
|
||||
#include "compiler/translator/OutputGLSLBase.h"
|
||||
|
||||
class TOutputGLSL : public TOutputGLSLBase
|
||||
{
|
@ -4,8 +4,8 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/OutputGLSLBase.h"
|
||||
#include "compiler/debug.h"
|
||||
#include "compiler/translator/OutputGLSLBase.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
@ -435,7 +435,7 @@ bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection* node)
|
||||
node->getCondition()->traverse(this);
|
||||
out << ")\n";
|
||||
|
||||
incrementDepth();
|
||||
incrementDepth(node);
|
||||
visitCodeBlock(node->getTrueBlock());
|
||||
|
||||
if (node->getFalseBlock())
|
||||
@ -460,7 +460,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
// Scope the sequences except when at the global scope.
|
||||
if (depth > 0) out << "{\n";
|
||||
|
||||
incrementDepth();
|
||||
incrementDepth(node);
|
||||
const TIntermSequence& sequence = node->getSequence();
|
||||
for (TIntermSequence::const_iterator iter = sequence.begin();
|
||||
iter != sequence.end(); ++iter)
|
||||
@ -498,7 +498,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
|
||||
writeVariableType(node->getType());
|
||||
out << " " << hashFunctionName(node->getName());
|
||||
|
||||
incrementDepth();
|
||||
incrementDepth(node);
|
||||
// Function definition node contains one or two children nodes
|
||||
// representing function parameters and function body. The latter
|
||||
// is not present in case of empty function bodies.
|
||||
@ -638,7 +638,7 @@ bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node)
|
||||
{
|
||||
TInfoSinkBase& out = objSink();
|
||||
|
||||
incrementDepth();
|
||||
incrementDepth(node);
|
||||
// Loop header.
|
||||
TLoopType loopType = node->getType();
|
||||
if (loopType == ELoopFor) // for loop
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "compiler/ForLoopUnroll.h"
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/translator/ForLoopUnroll.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
|
||||
class TOutputGLSLBase : public TIntermTraverser
|
||||
{
|
@ -4,14 +4,16 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/OutputHLSL.h"
|
||||
#include "compiler/translator/OutputHLSL.h"
|
||||
|
||||
#include "common/angleutils.h"
|
||||
#include "compiler/debug.h"
|
||||
#include "compiler/DetectDiscontinuity.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/SearchSymbol.h"
|
||||
#include "compiler/UnfoldShortCircuit.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
#include "compiler/translator/DetectDiscontinuity.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/SearchSymbol.h"
|
||||
#include "compiler/translator/UnfoldShortCircuit.h"
|
||||
#include "compiler/translator/NodeSearch.h"
|
||||
#include "compiler/translator/RewriteElseBlocks.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
@ -19,13 +21,6 @@
|
||||
|
||||
namespace sh
|
||||
{
|
||||
// Integer to TString conversion
|
||||
TString str(int i)
|
||||
{
|
||||
char buffer[20];
|
||||
snprintf(buffer, sizeof(buffer), "%d", i);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType)
|
||||
: TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
|
||||
@ -72,6 +67,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
|
||||
mUsesAtan2_2 = false;
|
||||
mUsesAtan2_3 = false;
|
||||
mUsesAtan2_4 = false;
|
||||
mUsesDiscardRewriting = false;
|
||||
|
||||
mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
|
||||
|
||||
@ -113,6 +109,13 @@ void OutputHLSL::output()
|
||||
{
|
||||
mContainsLoopDiscontinuity = mContext.shaderType == SH_FRAGMENT_SHADER && containsLoopDiscontinuity(mContext.treeRoot);
|
||||
|
||||
// Work around D3D9 bug that would manifest in vertex shaders with selection blocks which
|
||||
// use a vertex attribute as a condition, and some related computation in the else block.
|
||||
if (mOutputType == SH_HLSL9_OUTPUT && mContext.shaderType == SH_VERTEX_SHADER)
|
||||
{
|
||||
RewriteElseBlocks(mContext.treeRoot);
|
||||
}
|
||||
|
||||
mContext.treeRoot->traverse(this); // Output the body first to determine what has to go in the header
|
||||
header();
|
||||
|
||||
@ -196,6 +199,11 @@ void OutputHLSL::header()
|
||||
attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
|
||||
}
|
||||
|
||||
if (mUsesDiscardRewriting)
|
||||
{
|
||||
out << "#define ANGLE_USES_DISCARD_REWRITING" << "\n";
|
||||
}
|
||||
|
||||
if (shaderType == SH_FRAGMENT_SHADER)
|
||||
{
|
||||
TExtensionBehavior::const_iterator iter = mContext.extensionBehavior().find("GL_EXT_draw_buffers");
|
||||
@ -761,12 +769,12 @@ void OutputHLSL::header()
|
||||
}
|
||||
else if (mOutputType == SH_HLSL11_OUTPUT)
|
||||
{
|
||||
out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw, float lod)\n"
|
||||
out << "float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float3 uvw, float lod)\n"
|
||||
"{\n"
|
||||
" return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), lod);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n"
|
||||
"float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float4 uvw, float lod)\n"
|
||||
"{\n"
|
||||
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n"
|
||||
"}\n"
|
||||
@ -1092,6 +1100,10 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
|
||||
mReferencedVaryings[name] = node;
|
||||
out << decorate(name);
|
||||
}
|
||||
else if (qualifier == EvqInternal)
|
||||
{
|
||||
out << name;
|
||||
}
|
||||
else
|
||||
{
|
||||
out << decorate(name);
|
||||
@ -1299,15 +1311,31 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
|
||||
case EOpMatrixTimesVector: outputTriplet(visit, "mul(transpose(", "), ", ")"); break;
|
||||
case EOpMatrixTimesMatrix: outputTriplet(visit, "transpose(mul(transpose(", "), transpose(", ")))"); break;
|
||||
case EOpLogicalOr:
|
||||
out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
|
||||
return false;
|
||||
if (node->getRight()->hasSideEffects())
|
||||
{
|
||||
out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputTriplet(visit, "(", " || ", ")");
|
||||
return true;
|
||||
}
|
||||
case EOpLogicalXor:
|
||||
mUsesXor = true;
|
||||
outputTriplet(visit, "xor(", ", ", ")");
|
||||
break;
|
||||
case EOpLogicalAnd:
|
||||
out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
|
||||
return false;
|
||||
if (node->getRight()->hasSideEffects())
|
||||
{
|
||||
out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputTriplet(visit, "(", " && ", ")");
|
||||
return true;
|
||||
}
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
@ -1491,7 +1519,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
|
||||
{
|
||||
symbol->traverse(this);
|
||||
out << arrayString(symbol->getType());
|
||||
out << " = " + initializer(variable->getType());
|
||||
out << " = " + initializer(symbol->getType());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1944,7 +1972,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
|
||||
{
|
||||
mUnfoldShortCircuit->traverse(node->getCondition());
|
||||
|
||||
out << "if(";
|
||||
out << "if (";
|
||||
|
||||
node->getCondition()->traverse(this);
|
||||
|
||||
@ -1953,9 +1981,14 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
|
||||
outputLineDirective(node->getLine().first_line);
|
||||
out << "{\n";
|
||||
|
||||
bool discard = false;
|
||||
|
||||
if (node->getTrueBlock())
|
||||
{
|
||||
traverseStatements(node->getTrueBlock());
|
||||
|
||||
// Detect true discard
|
||||
discard = (discard || FindDiscard::search(node->getTrueBlock()));
|
||||
}
|
||||
|
||||
outputLineDirective(node->getLine().first_line);
|
||||
@ -1973,6 +2006,15 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
|
||||
|
||||
outputLineDirective(node->getFalseBlock()->getLine().first_line);
|
||||
out << ";\n}\n";
|
||||
|
||||
// Detect false discard
|
||||
discard = (discard || FindDiscard::search(node->getFalseBlock()));
|
||||
}
|
||||
|
||||
// ANGLE issue 486: Detect problematic conditional discard
|
||||
if (discard && FindSideEffectRewriting::search(node))
|
||||
{
|
||||
mUsesDiscardRewriting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2070,7 +2112,9 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node)
|
||||
|
||||
switch (node->getFlowOp())
|
||||
{
|
||||
case EOpKill: outputTriplet(visit, "discard;\n", "", ""); break;
|
||||
case EOpKill:
|
||||
outputTriplet(visit, "discard;\n", "", "");
|
||||
break;
|
||||
case EOpBreak:
|
||||
if (visit == PreVisit)
|
||||
{
|
||||
@ -2293,7 +2337,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
|
||||
|
||||
if (!firstLoopFragment)
|
||||
{
|
||||
out << "if(!Break";
|
||||
out << "if (!Break";
|
||||
index->traverse(this);
|
||||
out << ") {\n";
|
||||
}
|
@ -14,9 +14,9 @@
|
||||
#define GL_APICALL
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/Uniform.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
#include "compiler/translator/Uniform.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
@ -125,6 +125,7 @@ class OutputHLSL : public TIntermTraverser
|
||||
bool mUsesAtan2_2;
|
||||
bool mUsesAtan2_3;
|
||||
bool mUsesAtan2_4;
|
||||
bool mUsesDiscardRewriting;
|
||||
|
||||
int mNumRenderTargets;
|
||||
|
@ -4,12 +4,12 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "compiler/glslang.h"
|
||||
#include "compiler/translator/glslang.h"
|
||||
#include "compiler/preprocessor/SourceLocation.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@ -182,7 +182,7 @@ void TParseContext::error(const TSourceLoc& loc,
|
||||
pp::SourceLocation srcLoc;
|
||||
srcLoc.file = loc.first_file;
|
||||
srcLoc.line = loc.first_line;
|
||||
diagnostics.writeInfo(pp::Diagnostics::ERROR,
|
||||
diagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
|
||||
srcLoc, reason, token, extraInfo);
|
||||
|
||||
}
|
||||
@ -193,7 +193,7 @@ void TParseContext::warning(const TSourceLoc& loc,
|
||||
pp::SourceLocation srcLoc;
|
||||
srcLoc.file = loc.first_file;
|
||||
srcLoc.line = loc.first_line;
|
||||
diagnostics.writeInfo(pp::Diagnostics::WARNING,
|
||||
diagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
|
||||
srcLoc, reason, token, extraInfo);
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc& line, TIntermNode* n
|
||||
return true;
|
||||
}
|
||||
|
||||
if (op == EOpConstructStruct && !type->isArray() && int(type->getStruct()->fields().size()) != function.getParamCount()) {
|
||||
if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->fields().size() != function.getParamCount()) {
|
||||
error(line, "Number of constructor parameters does not match the number of structure fields", "constructor");
|
||||
return true;
|
||||
}
|
@ -6,12 +6,12 @@
|
||||
#ifndef _PARSER_HELPER_INCLUDED_
|
||||
#define _PARSER_HELPER_INCLUDED_
|
||||
|
||||
#include "compiler/Diagnostics.h"
|
||||
#include "compiler/DirectiveHandler.h"
|
||||
#include "compiler/localintermediate.h"
|
||||
#include "compiler/translator/Diagnostics.h"
|
||||
#include "compiler/translator/DirectiveHandler.h"
|
||||
#include "compiler/translator/localintermediate.h"
|
||||
#include "compiler/preprocessor/Preprocessor.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/SymbolTable.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
struct TMatrixFields {
|
||||
bool wholeRow;
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/PoolAlloc.h"
|
||||
#include "compiler/translator/PoolAlloc.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
@ -12,8 +12,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/angleutils.h"
|
||||
#include "compiler/InitializeGlobals.h"
|
||||
#include "compiler/osinclude.h"
|
||||
#include "compiler/translator/InitializeGlobals.h"
|
||||
#include "compiler/translator/osinclude.h"
|
||||
|
||||
OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX;
|
||||
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
class TAliveTraverser : public TIntermTraverser {
|
||||
public:
|
@ -4,8 +4,8 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/RemoveTree.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/RemoveTree.h"
|
||||
|
||||
//
|
||||
// Code to recursively delete the intermediate tree.
|
@ -7,7 +7,7 @@
|
||||
#ifndef COMPILER_RENAME_FUNCTION
|
||||
#define COMPILER_RENAME_FUNCTION
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
//
|
||||
// Renames a function, including its declaration and any calls to it.
|
98
src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp
vendored
Normal file
98
src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// RewriteElseBlocks.cpp: Implementation for tree transform to change
|
||||
// all if-else blocks to if-if blocks.
|
||||
//
|
||||
|
||||
#include "compiler/translator/RewriteElseBlocks.h"
|
||||
#include "compiler/translator/NodeSearch.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
|
||||
TIntermSymbol *MakeNewTemporary(const TString &name, TBasicType type)
|
||||
{
|
||||
TType variableType(type, EbpHigh, EvqInternal);
|
||||
return new TIntermSymbol(-1, name, variableType);
|
||||
}
|
||||
|
||||
TIntermBinary *MakeNewBinary(TOperator op, TIntermTyped *left, TIntermTyped *right, const TType &resultType)
|
||||
{
|
||||
TIntermBinary *binary = new TIntermBinary(op);
|
||||
binary->setLeft(left);
|
||||
binary->setRight(right);
|
||||
binary->setType(resultType);
|
||||
return binary;
|
||||
}
|
||||
|
||||
TIntermUnary *MakeNewUnary(TOperator op, TIntermTyped *operand)
|
||||
{
|
||||
TIntermUnary *unary = new TIntermUnary(op, operand->getType());
|
||||
unary->setOperand(operand);
|
||||
return unary;
|
||||
}
|
||||
|
||||
bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
|
||||
{
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpSequence:
|
||||
{
|
||||
for (size_t statementIndex = 0; statementIndex != node->getSequence().size(); statementIndex++)
|
||||
{
|
||||
TIntermNode *statement = node->getSequence()[statementIndex];
|
||||
TIntermSelection *selection = statement->getAsSelectionNode();
|
||||
if (selection && selection->getFalseBlock() != NULL)
|
||||
{
|
||||
node->getSequence()[statementIndex] = rewriteSelection(selection);
|
||||
delete selection;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection)
|
||||
{
|
||||
ASSERT(selection->getFalseBlock() != 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,
|
||||
typedCondition, resultType);
|
||||
TIntermUnary *negatedCondition = MakeNewUnary(EOpLogicalNot, conditionSymbolB);
|
||||
TIntermSelection *falseBlock = new TIntermSelection(negatedCondition,
|
||||
selection->getFalseBlock(), NULL);
|
||||
TIntermSelection *newIfElse = new TIntermSelection(conditionSymbolC,
|
||||
selection->getTrueBlock(), falseBlock);
|
||||
|
||||
TIntermAggregate *declaration = new TIntermAggregate(EOpDeclaration);
|
||||
declaration->getSequence().push_back(storeCondition);
|
||||
|
||||
TIntermAggregate *block = new TIntermAggregate(EOpSequence);
|
||||
block->getSequence().push_back(declaration);
|
||||
block->getSequence().push_back(newIfElse);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
void RewriteElseBlocks(TIntermNode *node)
|
||||
{
|
||||
ElseBlockRewriter rewriter;
|
||||
node->traverse(&rewriter);
|
||||
}
|
||||
|
||||
}
|
39
src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h
vendored
Normal file
39
src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// RewriteElseBlocks.h: Prototype for tree transform to change
|
||||
// all if-else blocks to if-if blocks.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_REWRITE_ELSE_BLOCKS_H_
|
||||
#define COMPILER_REWRITE_ELSE_BLOCKS_H_
|
||||
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
#endif // COMPILER_REWRITE_ELSE_BLOCKS_H_
|
@ -6,10 +6,10 @@
|
||||
// SearchSymbol is an AST traverser to detect the use of a given symbol name
|
||||
//
|
||||
|
||||
#include "compiler/SearchSymbol.h"
|
||||
#include "compiler/translator/SearchSymbol.h"
|
||||
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/OutputHLSL.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/OutputHLSL.h"
|
||||
|
||||
namespace sh
|
||||
{
|
@ -9,8 +9,8 @@
|
||||
#ifndef COMPILER_SEARCHSYMBOL_H_
|
||||
#define COMPILER_SEARCHSYMBOL_H_
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
|
||||
namespace sh
|
||||
{
|
@ -16,12 +16,12 @@
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/ExtensionBehavior.h"
|
||||
#include "compiler/HashNames.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/SymbolTable.h"
|
||||
#include "compiler/VariableInfo.h"
|
||||
#include "compiler/translator/BuiltInFunctionEmulator.h"
|
||||
#include "compiler/translator/ExtensionBehavior.h"
|
||||
#include "compiler/translator/HashNames.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
#include "compiler/translator/VariableInfo.h"
|
||||
#include "third_party/compiler/ArrayBoundsClamper.h"
|
||||
|
||||
class LongNameMap;
|
||||
@ -100,6 +100,16 @@ protected:
|
||||
// Returns true if, after applying the packing rules in the GLSL 1.017 spec
|
||||
// Appendix A, section 7, the shader does not use too many uniforms.
|
||||
bool enforcePackingRestrictions();
|
||||
// Insert statements to initialize varyings without static use in the beginning
|
||||
// of main(). It is to work around a Mac driver where such varyings in a vertex
|
||||
// shader may be optimized out incorrectly at compile time, causing a link failure.
|
||||
// This function should only be applied to vertex shaders.
|
||||
void initializeVaryingsWithoutStaticUse(TIntermNode* root);
|
||||
// Insert gl_Position = vec4(0,0,0,0) to the beginning of main().
|
||||
// It is to work around a Linux driver bug where missing this causes compile failure
|
||||
// while spec says it is allowed.
|
||||
// This function should only be applied to vertex shaders.
|
||||
void initializeGLPosition(TIntermNode* root);
|
||||
// Returns true if the shader passes the restrictions that aim to prevent timing attacks.
|
||||
bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph);
|
||||
// Returns true if the shader does not use samplers.
|
@ -11,11 +11,11 @@
|
||||
|
||||
#include "GLSLANG/ShaderLang.h"
|
||||
|
||||
#include "compiler/InitializeDll.h"
|
||||
#include "compiler/translator/InitializeDll.h"
|
||||
#include "compiler/preprocessor/length_limits.h"
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/TranslatorHLSL.h"
|
||||
#include "compiler/VariablePacker.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/TranslatorHLSL.h"
|
||||
#include "compiler/translator/VariablePacker.h"
|
||||
|
||||
//
|
||||
// This is the platform independent interface between an OGL driver
|
||||
@ -91,6 +91,9 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
|
||||
resources->HashFunction = NULL;
|
||||
|
||||
resources->ArrayIndexClampingStrategy = SH_CLAMP_WITH_CLAMP_INTRINSIC;
|
||||
|
||||
resources->MaxExpressionComplexity = 256;
|
||||
resources->MaxCallStackDepth = 256;
|
||||
}
|
||||
|
||||
//
|
@ -13,7 +13,7 @@
|
||||
#pragma warning(disable: 4718)
|
||||
#endif
|
||||
|
||||
#include "compiler/SymbolTable.h"
|
||||
#include "compiler/translator/SymbolTable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
@ -33,8 +33,8 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "common/angleutils.h"
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
//
|
||||
// Symbol base class. (Can build functions or variables out of these...)
|
@ -4,9 +4,9 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/TranslatorESSL.h"
|
||||
#include "compiler/translator/TranslatorESSL.h"
|
||||
|
||||
#include "compiler/OutputESSL.h"
|
||||
#include "compiler/translator/OutputESSL.h"
|
||||
|
||||
TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
|
||||
: TCompiler(type, spec) {
|
@ -7,7 +7,7 @@
|
||||
#ifndef COMPILER_TRANSLATORESSL_H_
|
||||
#define COMPILER_TRANSLATORESSL_H_
|
||||
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
|
||||
class TranslatorESSL : public TCompiler {
|
||||
public:
|
@ -4,10 +4,10 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/TranslatorGLSL.h"
|
||||
#include "compiler/translator/TranslatorGLSL.h"
|
||||
|
||||
#include "compiler/OutputGLSL.h"
|
||||
#include "compiler/VersionGLSL.h"
|
||||
#include "compiler/translator/OutputGLSL.h"
|
||||
#include "compiler/translator/VersionGLSL.h"
|
||||
|
||||
static void writeVersion(ShShaderType type, TIntermNode* root,
|
||||
TInfoSinkBase& sink) {
|
@ -7,7 +7,7 @@
|
||||
#ifndef COMPILER_TRANSLATORGLSL_H_
|
||||
#define COMPILER_TRANSLATORGLSL_H_
|
||||
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
|
||||
class TranslatorGLSL : public TCompiler {
|
||||
public:
|
@ -4,10 +4,10 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/TranslatorHLSL.h"
|
||||
#include "compiler/translator/TranslatorHLSL.h"
|
||||
|
||||
#include "compiler/InitializeParseContext.h"
|
||||
#include "compiler/OutputHLSL.h"
|
||||
#include "compiler/translator/InitializeParseContext.h"
|
||||
#include "compiler/translator/OutputHLSL.h"
|
||||
|
||||
TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
|
||||
: TCompiler(type, spec), mOutputType(output)
|
@ -7,8 +7,8 @@
|
||||
#ifndef COMPILER_TRANSLATORHLSL_H_
|
||||
#define COMPILER_TRANSLATORHLSL_H_
|
||||
|
||||
#include "compiler/ShHandle.h"
|
||||
#include "compiler/Uniform.h"
|
||||
#include "compiler/translator/ShHandle.h"
|
||||
#include "compiler/translator/Uniform.h"
|
||||
|
||||
class TranslatorHLSL : public TCompiler {
|
||||
public:
|
@ -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.
|
||||
//
|
||||
@ -9,9 +9,9 @@
|
||||
|
||||
#include "common/angleutils.h"
|
||||
|
||||
#include "compiler/BaseTypes.h"
|
||||
#include "compiler/Common.h"
|
||||
#include "compiler/debug.h"
|
||||
#include "compiler/translator/BaseTypes.h"
|
||||
#include "compiler/translator/Common.h"
|
||||
#include "compiler/translator/compilerdebug.h"
|
||||
|
||||
struct TPublicType;
|
||||
class TType;
|
||||
@ -95,7 +95,7 @@ class TType
|
||||
public:
|
||||
POOL_ALLOCATOR_NEW_DELETE();
|
||||
TType() {}
|
||||
TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
|
||||
TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, unsigned char s = 1, bool m = false, bool a = false) :
|
||||
type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0)
|
||||
{
|
||||
}
|
||||
@ -116,7 +116,7 @@ public:
|
||||
|
||||
// One-dimensional size of single instance type
|
||||
int getNominalSize() const { return size; }
|
||||
void setNominalSize(int s) { size = s; }
|
||||
void setNominalSize(unsigned char s) { size = s; }
|
||||
// Full size of single instance of type
|
||||
size_t getObjectSize() const;
|
||||
|
||||
@ -234,12 +234,12 @@ public:
|
||||
private:
|
||||
TString buildMangledName() const;
|
||||
|
||||
TBasicType type : 6;
|
||||
TBasicType type;
|
||||
TPrecision precision;
|
||||
TQualifier qualifier : 7;
|
||||
int size : 8; // size of vector or matrix, not size of array
|
||||
unsigned int matrix : 1;
|
||||
unsigned int array : 1;
|
||||
TQualifier qualifier;
|
||||
unsigned char size;
|
||||
bool matrix;
|
||||
bool array;
|
||||
int arraySize;
|
||||
|
||||
TStructure* structure; // 0 unless this is a struct
|
||||
@ -261,7 +261,7 @@ struct TPublicType
|
||||
TBasicType type;
|
||||
TQualifier qualifier;
|
||||
TPrecision precision;
|
||||
int size; // size of vector or matrix, not size of array
|
||||
unsigned char size; // size of vector or matrix, not size of array
|
||||
bool matrix;
|
||||
bool array;
|
||||
int arraySize;
|
||||
@ -281,7 +281,7 @@ struct TPublicType
|
||||
line = ln;
|
||||
}
|
||||
|
||||
void setAggregate(int s, bool m = false)
|
||||
void setAggregate(unsigned char s, bool m = false)
|
||||
{
|
||||
size = s;
|
||||
matrix = m;
|
@ -8,10 +8,10 @@
|
||||
// the original expression.
|
||||
//
|
||||
|
||||
#include "compiler/UnfoldShortCircuit.h"
|
||||
#include "compiler/translator/UnfoldShortCircuit.h"
|
||||
|
||||
#include "compiler/InfoSink.h"
|
||||
#include "compiler/OutputHLSL.h"
|
||||
#include "compiler/translator/InfoSink.h"
|
||||
#include "compiler/translator/OutputHLSL.h"
|
||||
|
||||
namespace sh
|
||||
{
|
||||
@ -31,6 +31,14 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
|
||||
{
|
||||
TInfoSinkBase &out = mOutputHLSL->getBodyStream();
|
||||
|
||||
// If our right node doesn't have side effects, we know we don't need to unfold this
|
||||
// expression: there will be no short-circuiting side effects to avoid
|
||||
// (note: unfolding doesn't depend on the left node -- it will always be evaluated)
|
||||
if (!node->getRight()->hasSideEffects())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpLogicalOr:
|
||||
@ -49,7 +57,7 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
|
||||
mTemporaryIndex = i + 1;
|
||||
node->getLeft()->traverse(mOutputHLSL);
|
||||
out << ";\n";
|
||||
out << "if(!s" << i << ")\n"
|
||||
out << "if (!s" << i << ")\n"
|
||||
"{\n";
|
||||
mTemporaryIndex = i + 1;
|
||||
node->getRight()->traverse(this);
|
||||
@ -80,7 +88,7 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
|
||||
mTemporaryIndex = i + 1;
|
||||
node->getLeft()->traverse(mOutputHLSL);
|
||||
out << ";\n";
|
||||
out << "if(s" << i << ")\n"
|
||||
out << "if (s" << i << ")\n"
|
||||
"{\n";
|
||||
mTemporaryIndex = i + 1;
|
||||
node->getRight()->traverse(this);
|
||||
@ -115,7 +123,7 @@ bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node)
|
||||
|
||||
mTemporaryIndex = i + 1;
|
||||
node->getCondition()->traverse(this);
|
||||
out << "if(";
|
||||
out << "if (";
|
||||
mTemporaryIndex = i + 1;
|
||||
node->getCondition()->traverse(mOutputHLSL);
|
||||
out << ")\n"
|
@ -9,8 +9,8 @@
|
||||
#ifndef COMPILER_UNFOLDSHORTCIRCUIT_H_
|
||||
#define COMPILER_UNFOLDSHORTCIRCUIT_H_
|
||||
|
||||
#include "compiler/intermediate.h"
|
||||
#include "compiler/ParseHelper.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
#include "compiler/translator/ParseContext.h"
|
||||
|
||||
namespace sh
|
||||
{
|
81
src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp
vendored
Normal file
81
src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "compiler/translator/UnfoldShortCircuitAST.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// "x || y" is equivalent to "x ? true : y".
|
||||
TIntermSelection *UnfoldOR(TIntermTyped *x, TIntermTyped *y)
|
||||
{
|
||||
const TType boolType(EbtBool, EbpUndefined);
|
||||
ConstantUnion *u = new ConstantUnion;
|
||||
u->setBConst(true);
|
||||
TIntermConstantUnion *trueNode = new TIntermConstantUnion(
|
||||
u, TType(EbtBool, EbpUndefined, EvqConst, 1));
|
||||
return new TIntermSelection(x, trueNode, y, boolType);
|
||||
}
|
||||
|
||||
// "x && y" is equivalent to "x ? y : false".
|
||||
TIntermSelection *UnfoldAND(TIntermTyped *x, TIntermTyped *y)
|
||||
{
|
||||
const TType boolType(EbtBool, EbpUndefined);
|
||||
ConstantUnion *u = new ConstantUnion;
|
||||
u->setBConst(false);
|
||||
TIntermConstantUnion *falseNode = new TIntermConstantUnion(
|
||||
u, TType(EbtBool, EbpUndefined, EvqConst, 1));
|
||||
return new TIntermSelection(x, y, falseNode, boolType);
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
||||
bool UnfoldShortCircuitAST::visitBinary(Visit visit, TIntermBinary *node)
|
||||
{
|
||||
TIntermSelection *replacement = NULL;
|
||||
|
||||
switch (node->getOp())
|
||||
{
|
||||
case EOpLogicalOr:
|
||||
replacement = UnfoldOR(node->getLeft(), node->getRight());
|
||||
break;
|
||||
case EOpLogicalAnd:
|
||||
replacement = UnfoldAND(node->getLeft(), node->getRight());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (replacement)
|
||||
{
|
||||
replacements.push_back(
|
||||
NodeUpdateEntry(getParentNode(), node, replacement));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UnfoldShortCircuitAST::updateTree()
|
||||
{
|
||||
for (size_t ii = 0; ii < replacements.size(); ++ii)
|
||||
{
|
||||
const NodeUpdateEntry& entry = replacements[ii];
|
||||
ASSERT(entry.parent);
|
||||
bool replaced = entry.parent->replaceChildNode(
|
||||
entry.original, entry.replacement);
|
||||
ASSERT(replaced);
|
||||
|
||||
// In AST traversing, a parent is visited before its children.
|
||||
// After we replace a node, if an immediate child is to
|
||||
// be replaced, we need to make sure we don't update the replaced
|
||||
// node; instead, we update the replacement node.
|
||||
for (size_t jj = ii + 1; jj < replacements.size(); ++jj)
|
||||
{
|
||||
NodeUpdateEntry& entry2 = replacements[jj];
|
||||
if (entry2.parent == entry.original)
|
||||
entry2.parent = entry.replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
51
src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h
vendored
Normal file
51
src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// UnfoldShortCircuitAST is an AST traverser to replace short-circuiting
|
||||
// operations with ternary operations.
|
||||
//
|
||||
|
||||
#ifndef COMPILER_UNFOLD_SHORT_CIRCUIT_AST_H_
|
||||
#define COMPILER_UNFOLD_SHORT_CIRCUIT_AST_H_
|
||||
|
||||
#include "common/angleutils.h"
|
||||
#include "compiler/translator/intermediate.h"
|
||||
|
||||
// This traverser identifies all the short circuit binary nodes that need to
|
||||
// be replaced, and creates the corresponding replacement nodes. However,
|
||||
// the actual replacements happen after the traverse through updateTree().
|
||||
|
||||
class UnfoldShortCircuitAST : public TIntermTraverser
|
||||
{
|
||||
public:
|
||||
UnfoldShortCircuitAST() { }
|
||||
|
||||
virtual bool visitBinary(Visit visit, TIntermBinary *);
|
||||
|
||||
void updateTree();
|
||||
|
||||
private:
|
||||
struct NodeUpdateEntry
|
||||
{
|
||||
NodeUpdateEntry(TIntermNode *_parent,
|
||||
TIntermNode *_original,
|
||||
TIntermNode *_replacement)
|
||||
: parent(_parent),
|
||||
original(_original),
|
||||
replacement(_replacement) {}
|
||||
|
||||
TIntermNode *parent;
|
||||
TIntermNode *original;
|
||||
TIntermNode *replacement;
|
||||
};
|
||||
|
||||
// During traversing, save all the replacements that need to happen;
|
||||
// then replace them by calling updateNodes().
|
||||
std::vector<NodeUpdateEntry> replacements;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(UnfoldShortCircuitAST);
|
||||
};
|
||||
|
||||
#endif // COMPILER_UNFOLD_SHORT_CIRCUIT_AST_H_
|
@ -4,7 +4,7 @@
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
#include "compiler/Uniform.h"
|
||||
#include "compiler/translator/Uniform.h"
|
||||
|
||||
namespace sh
|
||||
{
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user