Bug 682506 - Upgrade ANGLE to r740 - r=upstream

I need this now especially as it gets us the shader modification mechanisms to work around Mac GL crashes, see bug 665578

The relevant ANGLE revisions are 734, 738, and 740 fixes a bug in 738.

This also allows us to reset our set of cherrypicked ANGLE revisions which was starting to be very big.
This commit is contained in:
Benoit Jacob 2011-08-30 18:50:05 -04:00
Родитель d8cc757432
Коммит 3569758375
90 изменённых файлов: 9566 добавлений и 2758 удалений

Просмотреть файл

@ -3969,6 +3969,7 @@ WebGLContext::CompileShader(nsIWebGLShader *sobj)
compiler = ShConstructCompiler((ShShaderType) shader->ShaderType(),
SH_WEBGL_SPEC,
gl->IsGLES2() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT,
&resources);
nsPromiseFlatCString src(shader->Source());

Просмотреть файл

@ -1,38 +1,42 @@
# This is the official list of people who can contribute
# (and who have contributed) code to the ANGLE project
# repository.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
TransGaming Inc.
Nicolas Capens
Daniel Koch
Andrew Lewycky
Gavriel State
Shannon Woods
Google Inc.
Brent Austin
John Bauman
Henry Bridge
Nat Duca
Vangelis Kokkevis
Alastair Patrick
Alok Priyadarshi
Kenneth Russell
Ben Vanik
Adrienne Walker
Mozilla Corp.
Vladimir Vukicevic
Benoit Jacob
Apple Inc.
David Kilzer
Aitor Moreno <aitormoreno at gmail.com>
Jim Hauxwell <james at dattrax.co.uk>
ddefrostt
timeless
# This is the official list of people who can contribute
# (and who have contributed) code to the ANGLE project
# repository.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
TransGaming Inc.
Nicolas Capens
Daniel Koch
Andrew Lewycky
Gavriel State
Shannon Woods
Google Inc.
Brent Austin
John Bauman
Henry Bridge
Nat Duca
Vangelis Kokkevis
Zhenyao Mo
Daniel Nicoara
Alastair Patrick
Alok Priyadarshi
Kenneth Russell
Ben Vanik
Adrienne Walker
Mozilla Corp.
Benoit Jacob
Makoto Kato
Vladimir Vukicevic
Apple Inc.
David Kilzer
Aitor Moreno <aitormoreno at gmail.com>
Jim Hauxwell <james at dattrax.co.uk>
ddefrostt
timeless
Yore Apex

Просмотреть файл

@ -77,27 +77,31 @@ CPPSRCS = \
RemoveTree.cpp \
ShaderLang.cpp \
SymbolTable.cpp \
VariableInfo.cpp \
compilerdebug.cpp \
ossource_nspr.cpp \
util.cpp \
ValidateLimitations.cpp \
ForLoopUnroll.cpp \
MapLongVariableNames.cpp \
$(NULL)
VariableInfo.cpp \
compilerdebug.cpp \
ossource_nspr.cpp \
util.cpp \
ValidateLimitations.cpp \
ForLoopUnroll.cpp \
MapLongVariableNames.cpp \
BuiltInFunctionEmulator.cpp \
$(NULL)
# flex/yacc generated files
CPPSRCS += \
glslang_lex.cpp \
glslang_tab.cpp \
$(NULL)
glslang_lex.cpp \
glslang_tab.cpp \
$(NULL)
# GLSL translator backend
CPPSRCS += \
CodeGenGLSL.cpp \
OutputGLSL.cpp \
TranslatorGLSL.cpp \
VersionGLSL.cpp \
CodeGenGLSL.cpp \
OutputGLSL.cpp \
TranslatorGLSL.cpp \
VersionGLSL.cpp \
OutputESSL.cpp \
OutputGLSLBase.cpp \
TranslatorESSL.cpp \
$(NULL)
# Currently, only one or the other

Просмотреть файл

@ -1,6 +1,6 @@
This is the ANGLE project, from http://code.google.com/p/angleproject/.
Current revision: r686
Current revision: r740
== Applied local patches ==
@ -8,15 +8,7 @@ In this order:
angle-nspr-misc.patch - don't bother with ANGLE_OS detection with NSPR
angle-renaming.patch - rename debug.h to compilerdebug.h to avoid conflict in our makefiles
angle-intrinsic-msvc2005.patch - work around a MSVC 2005 compile error
angle-amap-arev-fix.patch - plain bug fix, this is ANGLE r699
angle-r702.patch - this is ANGLE r702
angle-limit-identifiers-to-250-chars.patch - see bug 675625
angle-r712.patch - this is ANGLE r712
angle-win64.patch - Win64 support. This is ANGLE r697
angle-r707.patch - this is ANGLE r707 for Win64 bug fix
angle-r719.patch - this is ANGLE r719
angle-r711.patch - this is ANGLE r711
fix-angle-surface-assert.patch - this is ANGLE r739
In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.

Просмотреть файл

@ -1,28 +0,0 @@
# HG changeset patch
# Parent c88f8e8921fb6399cf95b5899d2acc60951dddd1
Bug 665934 - fix bug: arev was meant instead of amap - r=upstream
This patch has been taken in ANGLE upstream as r699.
diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler/preprocessor/atom.c
--- a/gfx/angle/src/compiler/preprocessor/atom.c
+++ b/gfx/angle/src/compiler/preprocessor/atom.c
@@ -330,17 +330,17 @@ static int GrowAtomTable(AtomTable *atab
newrev = malloc(sizeof(int)*size);
atable->size = 0;
}
if (!newmap || !newrev) {
/* failed to grow -- error */
if (newmap)
atable->amap = newmap;
if (newrev)
- atable->amap = newrev;
+ atable->arev = newrev;
return -1;
}
memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));
memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));
atable->amap = newmap;
atable->arev = newrev;
atable->size = size;
}

Просмотреть файл

@ -1,84 +0,0 @@
# HG changeset patch
# Parent b410077eaab7f6f851ebefa26fd9e1df938026bb
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
--- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
@@ -134,19 +134,33 @@ GLenum VertexDataManager::prepareVertexD
if (staticBuffer->size() == 0)
{
int totalCount = buffer->size() / attribs[i].stride();
staticBuffer->addRequiredSpace(spaceRequired(attribs[i], totalCount));
}
else if (staticBuffer->lookupAttribute(attribs[i]) == -1)
{
// This static buffer doesn't have matching attributes, so fall back to using the streaming buffer
- mStreamingBuffer->addRequiredSpaceFor(staticBuffer);
buffer->invalidateStaticData();
+ // Add the space of all previous attributes belonging to the invalidated static buffer to the streaming buffer
+ for (int previous = 0; previous < i; previous++)
+ {
+ if (translated[previous].active && attribs[previous].mArrayEnabled)
+ {
+ Buffer *previousBuffer = attribs[previous].mBoundBuffer.get();
+ StaticVertexBuffer *previousStaticBuffer = previousBuffer ? previousBuffer->getStaticVertexBuffer() : NULL;
+
+ if (staticBuffer == previousStaticBuffer)
+ {
+ mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[previous], count));
+ }
+ }
+ }
+
mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count));
}
}
else
{
mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count));
}
}
@@ -578,21 +592,16 @@ ArrayVertexBuffer::~ArrayVertexBuffer()
{
}
void ArrayVertexBuffer::addRequiredSpace(UINT requiredSpace)
{
mRequiredSpace += requiredSpace;
}
-void ArrayVertexBuffer::addRequiredSpaceFor(ArrayVertexBuffer *buffer)
-{
- mRequiredSpace += buffer->mRequiredSpace;
-}
-
StreamingVertexBuffer::StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize) : ArrayVertexBuffer(device, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY)
{
}
StreamingVertexBuffer::~StreamingVertexBuffer()
{
}
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.h b/gfx/angle/src/libGLESv2/VertexDataManager.h
--- a/gfx/angle/src/libGLESv2/VertexDataManager.h
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.h
@@ -62,17 +62,16 @@ class ArrayVertexBuffer : public VertexB
public:
ArrayVertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags);
~ArrayVertexBuffer();
UINT size() const { return mBufferSize; }
virtual void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset) = 0;
virtual void reserveRequiredSpace() = 0;
void addRequiredSpace(UINT requiredSpace);
- void addRequiredSpaceFor(ArrayVertexBuffer *buffer);
protected:
UINT mBufferSize;
UINT mWritePosition;
UINT mRequiredSpace;
};
class StreamingVertexBuffer : public ArrayVertexBuffer

Просмотреть файл

@ -1,45 +0,0 @@
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
--- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
@@ -714,17 +714,17 @@ void StaticVertexBuffer::reserveRequired
{
// Already allocated
}
else UNREACHABLE(); // Static vertex buffers can't be resized
mRequiredSpace = 0;
}
-UINT StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute)
+std::size_t StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute)
{
for (unsigned int element = 0; element < mCache.size(); element++)
{
if (mCache[element].type == attribute.mType && mCache[element].size == attribute.mSize && mCache[element].normalized == attribute.mNormalized)
{
if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride())
{
return mCache[element].streamOffset;
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.h b/gfx/angle/src/libGLESv2/VertexDataManager.h
--- a/gfx/angle/src/libGLESv2/VertexDataManager.h
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.h
@@ -88,17 +88,17 @@ class StaticVertexBuffer : public ArrayV
{
public:
explicit StaticVertexBuffer(IDirect3DDevice9 *device);
~StaticVertexBuffer();
void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset);
void reserveRequiredSpace();
- UINT lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found
+ std::size_t lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found
private:
struct VertexElement
{
GLenum type;
GLint size;
bool normalized;
int attributeOffset;

Просмотреть файл

@ -1,42 +0,0 @@
# HG changeset patch
# Parent 88a5c8710f5cffd568bc21226118cb567850ce28
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
--- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
@@ -134,34 +134,34 @@ GLenum VertexDataManager::prepareVertexD
if (staticBuffer->size() == 0)
{
int totalCount = buffer->size() / attribs[i].stride();
staticBuffer->addRequiredSpace(spaceRequired(attribs[i], totalCount));
}
else if (staticBuffer->lookupAttribute(attribs[i]) == -1)
{
// This static buffer doesn't have matching attributes, so fall back to using the streaming buffer
- buffer->invalidateStaticData();
-
// Add the space of all previous attributes belonging to the invalidated static buffer to the streaming buffer
for (int previous = 0; previous < i; previous++)
{
if (translated[previous].active && attribs[previous].mArrayEnabled)
{
Buffer *previousBuffer = attribs[previous].mBoundBuffer.get();
StaticVertexBuffer *previousStaticBuffer = previousBuffer ? previousBuffer->getStaticVertexBuffer() : NULL;
if (staticBuffer == previousStaticBuffer)
{
mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[previous], count));
}
}
}
mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count));
+
+ buffer->invalidateStaticData();
}
}
else
{
mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count));
}
}
}

Просмотреть файл

@ -1,9 +1,10 @@
# HG changeset patch
# Parent a0dd1332c0e6ebaf429f9a3732b8901f9e46cde0
# Parent 96359f46b01fdb37e791f564495e8b2755a05233
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in
@@ -72,17 +72,17 @@ CPPSRCS = \
@@ -73,17 +73,17 @@ CPPSRCS = \
parseConst.cpp \
ParseHelper.cpp \
PoolAlloc.cpp \
@ -11,44 +12,20 @@ diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
RemoveTree.cpp \
ShaderLang.cpp \
SymbolTable.cpp \
VariableInfo.cpp \
- debug.cpp \
+ compilerdebug.cpp \
ossource_nspr.cpp \
util.cpp \
ValidateLimitations.cpp \
ForLoopUnroll.cpp \
MapLongVariableNames.cpp \
$(NULL)
VariableInfo.cpp \
- debug.cpp \
+ compilerdebug.cpp \
ossource_nspr.cpp \
util.cpp \
ValidateLimitations.cpp \
ForLoopUnroll.cpp \
MapLongVariableNames.cpp \
BuiltInFunctionEmulator.cpp \
$(NULL)
# flex/yacc generated files
diff --git a/gfx/angle/src/build_angle.gyp b/gfx/angle/src/build_angle.gyp
--- a/gfx/angle/src/build_angle.gyp
+++ b/gfx/angle/src/build_angle.gyp
@@ -17,18 +17,18 @@
'.',
'../include',
],
'sources': [
'compiler/BaseTypes.h',
'compiler/Common.h',
'compiler/Compiler.cpp',
'compiler/ConstantUnion.h',
- 'compiler/debug.cpp',
- 'compiler/debug.h',
+ 'compiler/compilerdebug.cpp',
+ 'compiler/compilerdebug.h',
'compiler/glslang.h',
'compiler/glslang_lex.cpp',
'compiler/glslang_tab.cpp',
'compiler/glslang_tab.h',
'compiler/InfoSink.cpp',
'compiler/InfoSink.h',
'compiler/Initialize.cpp',
'compiler/Initialize.h',
diff --git a/gfx/angle/src/compiler/OutputGLSL.cpp b/gfx/angle/src/compiler/OutputGLSL.cpp
--- a/gfx/angle/src/compiler/OutputGLSL.cpp
+++ b/gfx/angle/src/compiler/OutputGLSL.cpp
diff --git a/gfx/angle/src/compiler/OutputGLSLBase.cpp b/gfx/angle/src/compiler/OutputGLSLBase.cpp
--- a/gfx/angle/src/compiler/OutputGLSLBase.cpp
+++ b/gfx/angle/src/compiler/OutputGLSLBase.cpp
@@ -1,16 +1,16 @@
//
// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
@ -56,7 +33,7 @@ diff --git a/gfx/angle/src/compiler/OutputGLSL.cpp b/gfx/angle/src/compiler/Outp
// found in the LICENSE file.
//
#include "compiler/OutputGLSL.h"
#include "compiler/OutputGLSLBase.h"
-#include "compiler/debug.h"
+#include "compiler/compilerdebug.h"
@ -157,7 +134,7 @@ diff --git a/gfx/angle/src/compiler/compilerdebug.h b/gfx/angle/src/compiler/com
diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h
--- a/gfx/angle/src/compiler/osinclude.h
+++ b/gfx/angle/src/compiler/osinclude.h
@@ -30,17 +30,17 @@
@@ -32,17 +32,17 @@
#include <windows.h>
#elif defined(ANGLE_OS_POSIX)
#include <pthread.h>

Просмотреть файл

@ -1,235 +0,0 @@
diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp
--- a/gfx/angle/src/libEGL/Surface.cpp
+++ b/gfx/angle/src/libEGL/Surface.cpp
@@ -285,17 +285,17 @@ void Surface::subclassWindow()
DWORD processId;
DWORD threadId = GetWindowThreadProcessId(mWindow, &processId);
if (processId != GetCurrentProcessId() || threadId != GetCurrentThreadId())
{
return;
}
SetLastError(0);
- LONG oldWndProc = SetWindowLong(mWindow, GWL_WNDPROC, reinterpret_cast<LONG>(SurfaceWindowProc));
+ LONG_PTR oldWndProc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
if(oldWndProc == 0 && GetLastError() != ERROR_SUCCESS)
{
mWindowSubclassed = false;
return;
}
SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
@@ -305,27 +305,27 @@ void Surface::subclassWindow()
void Surface::unsubclassWindow()
{
if(!mWindowSubclassed)
{
return;
}
// un-subclass
- LONG parentWndFunc = reinterpret_cast<LONG>(GetProp(mWindow, kParentWndProc));
+ LONG_PTR parentWndFunc = reinterpret_cast<LONG_PTR>(GetProp(mWindow, kParentWndProc));
// Check the windowproc is still SurfaceWindowProc.
// If this assert fails, then it is likely the application has subclassed the
// hwnd as well and did not unsubclass before destroying its EGL context. The
// application should be modified to either subclass before initializing the
// EGL context, or to unsubclass before destroying the EGL context.
if(parentWndFunc)
{
- LONG prevWndFunc = SetWindowLong(mWindow, GWL_WNDPROC, parentWndFunc);
- ASSERT(prevWndFunc == reinterpret_cast<LONG>(SurfaceWindowProc));
+ LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc);
+ ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
}
RemoveProp(mWindow, kSurfaceProperty);
RemoveProp(mWindow, kParentWndProc);
mWindowSubclassed = false;
}
bool Surface::checkForOutOfDateSwapChain()
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.cpp b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
--- a/gfx/angle/src/libGLESv2/VertexDataManager.cpp
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.cpp
@@ -50,24 +50,24 @@ VertexDataManager::~VertexDataManager()
delete mStreamingBuffer;
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
delete mCurrentValueBuffer[i];
}
}
-UINT VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute)
+std::size_t VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute)
{
Buffer *buffer = attribute.mBoundBuffer.get();
int inputStride = attribute.stride();
int elementSize = attribute.typeSize();
const FormatConverter &converter = formatConverter(attribute);
- UINT streamOffset = 0;
+ std::size_t streamOffset = 0;
void *output = NULL;
if (vertexBuffer)
{
output = vertexBuffer->map(attribute, spaceRequired(attribute, count), &streamOffset);
}
@@ -198,17 +198,17 @@ GLenum VertexDataManager::prepareVertexD
return GL_INVALID_OPERATION;
}
const FormatConverter &converter = formatConverter(attribs[i]);
StaticVertexBuffer *staticBuffer = buffer ? buffer->getStaticVertexBuffer() : NULL;
ArrayVertexBuffer *vertexBuffer = staticBuffer ? staticBuffer : static_cast<ArrayVertexBuffer*>(mStreamingBuffer);
- UINT streamOffset = -1;
+ std::size_t streamOffset = -1;
if (staticBuffer)
{
streamOffset = staticBuffer->lookupAttribute(attribs[i]);
if (streamOffset == -1)
{
// Convert the entire buffer
@@ -666,17 +666,17 @@ void StreamingVertexBuffer::reserveRequi
StaticVertexBuffer::StaticVertexBuffer(IDirect3DDevice9 *device) : ArrayVertexBuffer(device, 0, D3DUSAGE_WRITEONLY)
{
}
StaticVertexBuffer::~StaticVertexBuffer()
{
}
-void *StaticVertexBuffer::map(const VertexAttribute &attribute, std::size_t requiredSpace, UINT *streamOffset)
+void *StaticVertexBuffer::map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset)
{
void *mapPtr = NULL;
if (mVertexBuffer)
{
HRESULT result = mVertexBuffer->Lock(mWritePosition, requiredSpace, &mapPtr, 0);
if (FAILED(result))
diff --git a/gfx/angle/src/libGLESv2/VertexDataManager.h b/gfx/angle/src/libGLESv2/VertexDataManager.h
--- a/gfx/angle/src/libGLESv2/VertexDataManager.h
+++ b/gfx/angle/src/libGLESv2/VertexDataManager.h
@@ -30,17 +30,17 @@ struct TranslatedAttribute
UINT stride; // 0 means not to advance the read pointer at all
IDirect3DVertexBuffer9 *vertexBuffer;
};
class VertexBuffer
{
public:
- VertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags);
+ VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags);
virtual ~VertexBuffer();
void unmap();
IDirect3DVertexBuffer9 *getBuffer() const;
protected:
IDirect3DDevice9 *const mDevice;
@@ -55,60 +55,60 @@ class ConstantVertexBuffer : public Vert
public:
ConstantVertexBuffer(IDirect3DDevice9 *device, float x, float y, float z, float w);
~ConstantVertexBuffer();
};
class ArrayVertexBuffer : public VertexBuffer
{
public:
- ArrayVertexBuffer(IDirect3DDevice9 *device, UINT size, DWORD usageFlags);
+ ArrayVertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usageFlags);
~ArrayVertexBuffer();
- UINT size() const { return mBufferSize; }
- virtual void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset) = 0;
+ std::size_t size() const { return mBufferSize; }
+ virtual void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset) = 0;
virtual void reserveRequiredSpace() = 0;
void addRequiredSpace(UINT requiredSpace);
protected:
- UINT mBufferSize;
- UINT mWritePosition;
- UINT mRequiredSpace;
+ std::size_t mBufferSize;
+ std::size_t mWritePosition;
+ std::size_t mRequiredSpace;
};
class StreamingVertexBuffer : public ArrayVertexBuffer
{
public:
- StreamingVertexBuffer(IDirect3DDevice9 *device, UINT initialSize);
+ StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize);
~StreamingVertexBuffer();
- void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset);
+ void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset);
void reserveRequiredSpace();
};
class StaticVertexBuffer : public ArrayVertexBuffer
{
public:
explicit StaticVertexBuffer(IDirect3DDevice9 *device);
~StaticVertexBuffer();
- void *map(const VertexAttribute &attribute, UINT requiredSpace, UINT *streamOffset);
+ void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset);
void reserveRequiredSpace();
UINT lookupAttribute(const VertexAttribute &attribute); // Returns the offset into the vertex buffer, or -1 if not found
private:
struct VertexElement
{
GLenum type;
GLint size;
bool normalized;
int attributeOffset;
- UINT streamOffset;
+ std::size_t streamOffset;
};
std::vector<VertexElement> mCache;
};
class VertexDataManager
{
public:
@@ -117,18 +117,18 @@ class VertexDataManager
void dirtyCurrentValue(int index) { mDirtyCurrentValue[index] = true; }
GLenum prepareVertexData(GLint start, GLsizei count, TranslatedAttribute *outAttribs);
private:
DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
- UINT spaceRequired(const VertexAttribute &attrib, std::size_t count) const;
- UINT writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute);
+ std::size_t spaceRequired(const VertexAttribute &attrib, std::size_t count) const;
+ std::size_t writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute);
Context *const mContext;
IDirect3DDevice9 *const mDevice;
StreamingVertexBuffer *mStreamingBuffer;
bool mDirtyCurrentValue[MAX_VERTEX_ATTRIBS];
ConstantVertexBuffer *mCurrentValueBuffer[MAX_VERTEX_ATTRIBS];

Просмотреть файл

@ -0,0 +1,73 @@
Name
ANGLE_texture_compression_dxt
Name Strings
GL_ANGLE_texture_compression_dxt3
GL_ANGLE_texture_compression_dxt5
Contributors
Gregg Tavares, Google Inc.
Daniel Koch, TransGaming Inc.
Al Patrick, Google Inc.
Contacts
Gregg Tavares, Google Inc. (gman 'at' google 'dot' com)
Status
Implemented in ANGLE ES2
Version
Last Modified Date: Aug 2, 2011
Number
OpenGL ES Extension #..
Dependencies
Requires OpenGL ES 2.0.
The extension is written against the OpenGL ES 2.0 specification.
Overview
These extensions are exactly the same as EXT_texture_compression_dxt1
except they expose the formats COMPRESSED_RGBA_S3TC_DXT3_ANGLE and
COMPRESSED_RGBA_S3TC_DXT5_ANGLE respectively.
See EXT_texture_compression_dxt1 for the full list of changes. Also
see EXT_texture_compression_s3tc for a description of the formats.
New Procedures and Functions
None.
New Types
None.
New Tokens
Accepted by the <internalformat> parameter of CompressedTexImage2D
and the <format> parameter of CompressedTexSubImage2D:
COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
Errors
None.
New State
None.
Revision History

Просмотреть файл

@ -0,0 +1,63 @@
Name
ANGLE_software_display
Name Strings
EGL_ANGLE_software_display
Contributors
John Bauman
Daniel Koch
Contacts
John Bauman, Google Inc. (jbauman 'at' chromium.org)
Status
In progress
Version
Version 1, July 12, 2011
Number
EGL Extension #??
Dependencies
This extension is written against the wording of the EGL 1.4
Specification.
Overview
This extension allows for receiving a device that uses software rendering.
New Types
None
New Procedures and Functions
None
New Tokens
None
Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)
Add before the last sentence of the first paragraph of section 3.2,
"Initialization":
"If <display_id> is EGL_SOFTWARE_DISPLAY_ANGLE, a display that will render
everything in software will be returned."
Issues
Revision History
Version 1, 2011/07/12 - first draft.

Просмотреть файл

@ -1,42 +0,0 @@
# HG changeset patch
# Parent 9869d707ee367a9a108b663c71388cdea4abb705
diff --git a/gfx/angle/src/libEGL/Surface.cpp b/gfx/angle/src/libEGL/Surface.cpp
--- a/gfx/angle/src/libEGL/Surface.cpp
+++ b/gfx/angle/src/libEGL/Surface.cpp
@@ -210,33 +210,33 @@ bool Surface::resetSwapChain(int backbuf
}
result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET,
presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle);
}
if (FAILED(result))
{
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
+ ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
release();
return error(EGL_BAD_ALLOC, false);
}
if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN)
{
result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight,
presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType,
presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL);
}
if (FAILED(result))
{
- ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
+ ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
ERR("Could not create depthstencil surface for new swap chain: %08lX", result);
release();
return error(EGL_BAD_ALLOC, false);
}
if (mWindow) {
mSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &mRenderTarget);

Просмотреть файл

@ -6,7 +6,7 @@ extern "C" {
#endif
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
** Copyright (c) 2007-2010 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
@ -34,8 +34,8 @@ extern "C" {
/* Header file version number */
/* Current version at http://www.khronos.org/registry/egl/ */
/* $Revision: 10795 $ on $Date: 2010-03-19 17:04:17 -0700 (Fri, 19 Mar 2010) $ */
#define EGL_EGLEXT_VERSION 5
/* $Revision: 15052 $ on $Date: 2011-07-06 17:43:46 -0700 (Wed, 06 Jul 2011) $ */
#define EGL_EGLEXT_VERSION 10
#ifndef EGL_KHR_config_attribs
#define EGL_KHR_config_attribs 1
@ -120,6 +120,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL
#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
#ifndef EGL_KHR_reusable_sync
#define EGL_KHR_reusable_sync 1
@ -149,6 +150,7 @@ typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSy
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif
#endif
#ifndef EGL_KHR_image_base
#define EGL_KHR_image_base 1
@ -169,6 +171,11 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif
#ifndef EGL_KHR_lock_surface2
#define EGL_KHR_lock_surface2 1
#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
#endif
#ifndef EGL_NV_coverage_sample
#define EGL_NV_coverage_sample 1
#define EGL_COVERAGE_BUFFERS_NV 0x30E0
@ -182,6 +189,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG
#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */
#ifndef EGL_NV_sync
#define EGL_NV_sync 1
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6
@ -198,7 +206,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG
#define EGL_SYNC_FENCE_NV 0x30EF
#define EGL_NO_SYNC_NV ((EGLSyncNV)0)
typedef void* EGLSyncNV;
typedef unsigned long long EGLTimeNV;
typedef khronos_utime_nanoseconds_t EGLTimeNV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
EGLBoolean eglDestroySyncNV (EGLSyncNV sync);
@ -214,6 +222,76 @@ typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif
#endif
#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
#ifndef EGL_KHR_fence_sync
#define EGL_KHR_fence_sync 1
/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
#define EGL_SYNC_CONDITION_KHR 0x30F8
#define EGL_SYNC_FENCE_KHR 0x30F9
#endif
#endif
#ifndef EGL_HI_clientpixmap
#define EGL_HI_clientpixmap 1
/* Surface Attribute */
#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
/*
* Structure representing a client pixmap
* (pixmap's data is in client-space memory).
*/
struct EGLClientPixmapHI
{
void* pData;
EGLint iWidth;
EGLint iHeight;
EGLint iStride;
};
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
#endif /* EGL_HI_clientpixmap */
#ifndef EGL_HI_colorformats
#define EGL_HI_colorformats 1
/* Config Attribute */
#define EGL_COLOR_FORMAT_HI 0x8F70
/* Color Formats */
#define EGL_COLOR_RGB_HI 0x8F71
#define EGL_COLOR_RGBA_HI 0x8F72
#define EGL_COLOR_ARGB_HI 0x8F73
#endif /* EGL_HI_colorformats */
#ifndef EGL_MESA_drm_image
#define EGL_MESA_drm_image 1
#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */
#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */
#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */
#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#endif
#ifndef EGL_NV_post_sub_buffer
#define EGL_NV_post_sub_buffer 1
#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif
#ifndef EGL_ANGLE_query_surface_pointer
#define EGL_ANGLE_query_surface_pointer 1
@ -224,8 +302,35 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay
#endif
#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
#endif
#ifndef EGL_ANGLE_software_display
#define EGL_ANGLE_software_display 1
#define EGL_SOFTWARE_DISPLAY_ANGLE ((EGLNativeDisplayType)-1)
#endif
#ifndef EGL_NV_coverage_sample_resolve
#define EGL_NV_coverage_sample_resolve 1
#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
#ifndef EGL_NV_system_time
#define EGL_NV_system_time 1
typedef khronos_utime_nanoseconds_t EGLuint64NV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
#endif
#endif
#ifdef __cplusplus

Просмотреть файл

@ -25,7 +25,7 @@
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $
* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
@ -60,6 +60,11 @@
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*
* Khronos STRONGLY RECOMMENDS that you use the default definitions
* provided below, since these changes affect both binary and source
* portability of applications using EGL running on different EGL
* implementations.
*/
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
@ -78,6 +83,12 @@ typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(WL_EGL_PLATFORM)
typedef struct wl_display *EGLNativeDisplayType;
typedef struct wl_egl_pixmap *EGLNativePixmapType;
typedef struct wl_egl_window *EGLNativeWindowType;
#elif defined(__unix__)
/* X11 (tentative) */

Просмотреть файл

@ -1,7 +1,7 @@
#ifndef __gl2ext_h_
#define __gl2ext_h_
/* $Revision: 10798 $ on $Date:: 2010-03-19 17:34:30 -0700 #$ */
/* $Revision: 15049 $ on $Date:: 2011-07-06 17:28:16 -0700 #$ */
#ifdef __cplusplus
extern "C" {
@ -57,6 +57,15 @@ extern "C" {
typedef void* GLeglImageOES;
#endif
/* GL_OES_EGL_image_external */
#ifndef GL_OES_EGL_image_external
/* GLeglImageOES defined in GL_OES_EGL_image already. */
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
#define GL_SAMPLER_EXTERNAL_OES 0x8D66
#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
#endif
/* GL_OES_element_index_uint */
#ifndef GL_OES_element_index_uint
#define GL_UNSIGNED_INT 0x1405
@ -179,6 +188,79 @@ typedef void* GLeglImageOES;
#define GL_Z400_BINARY_AMD 0x8740
#endif
/*------------------------------------------------------------------------*
* ANGLE extension tokens
*------------------------------------------------------------------------*/
/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9
#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6
#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA
#endif
/* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_framebuffer_multisample
#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
#define GL_MAX_SAMPLES_ANGLE 0x8D57
#endif
/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
#endif
/*------------------------------------------------------------------------*
* APPLE extension tokens
*------------------------------------------------------------------------*/
/* GL_APPLE_rgb_422 */
#ifndef GL_APPLE_rgb_422
#define GL_RGB_422_APPLE 0x8A1F
#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
#endif
/* GL_APPLE_framebuffer_multisample */
#ifndef GL_APPLE_framebuffer_multisample
#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56
#define GL_MAX_SAMPLES_APPLE 0x8D57
#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8
#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9
#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6
#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
#endif
/* GL_APPLE_texture_format_BGRA8888 */
#ifndef GL_APPLE_texture_format_BGRA8888
#define GL_BGRA_EXT 0x80E1
#endif
/* GL_APPLE_texture_max_level */
#ifndef GL_APPLE_texture_max_level
#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D
#endif
/*------------------------------------------------------------------------*
* ARM extension tokens
*------------------------------------------------------------------------*/
/* GL_ARM_mali_shader_binary */
#ifndef GL_ARM_mali_shader_binary
#define GL_MALI_SHADER_BINARY_ARM 0x8F60
#endif
/* GL_ARM_rgba8 */
/* No new tokens introduced by this extension. */
/*------------------------------------------------------------------------*
* EXT extension tokens
*------------------------------------------------------------------------*/
@ -206,6 +288,9 @@ typedef void* GLeglImageOES;
#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
#endif
/* GL_EXT_shader_texture_lod */
/* No new tokens introduced by this extension. */
/* GL_EXT_texture_filter_anisotropic */
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
@ -228,6 +313,22 @@ typedef void* GLeglImageOES;
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#endif
/* GL_EXT_unpack_subimage */
#ifndef GL_EXT_unpack_subimage
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#define GL_UNPACK_SKIP_ROWS 0x0CF3
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
#endif
/*------------------------------------------------------------------------*
* DMP extension tokens
*------------------------------------------------------------------------*/
/* GL_DMP_shader_binary */
#ifndef GL_DMP_shader_binary
#define GL_SHADER_BINARY_DMP 0x9250
#endif
/*------------------------------------------------------------------------*
* IMG extension tokens
*------------------------------------------------------------------------*/
@ -256,17 +357,18 @@ typedef void* GLeglImageOES;
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
#endif
/* GL_IMG_multisampled_render_to_texture */
#ifndef GL_IMG_multisampled_render_to_texture
#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
#define GL_MAX_SAMPLES_IMG 0x9135
#define GL_TEXTURE_SAMPLES_IMG 0x9136
#endif
/*------------------------------------------------------------------------*
* NV extension tokens
*------------------------------------------------------------------------*/
/* GL_NV_fence */
#ifndef GL_NV_fence
#define GL_ALL_COMPLETED_NV 0x84F2
#define GL_FENCE_STATUS_NV 0x84F3
#define GL_FENCE_CONDITION_NV 0x84F4
#endif
/* GL_NV_coverage_sample */
#ifndef GL_NV_coverage_sample
#define GL_COVERAGE_COMPONENT_NV 0x8ED0
@ -285,10 +387,90 @@ typedef void* GLeglImageOES;
#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
#endif
/* GL_NV_draw_buffers */
#ifndef GL_NV_draw_buffers
#define GL_MAX_DRAW_BUFFERS_NV 0x8824
#define GL_DRAW_BUFFER0_NV 0x8825
#define GL_DRAW_BUFFER1_NV 0x8826
#define GL_DRAW_BUFFER2_NV 0x8827
#define GL_DRAW_BUFFER3_NV 0x8828
#define GL_DRAW_BUFFER4_NV 0x8829
#define GL_DRAW_BUFFER5_NV 0x882A
#define GL_DRAW_BUFFER6_NV 0x882B
#define GL_DRAW_BUFFER7_NV 0x882C
#define GL_DRAW_BUFFER8_NV 0x882D
#define GL_DRAW_BUFFER9_NV 0x882E
#define GL_DRAW_BUFFER10_NV 0x882F
#define GL_DRAW_BUFFER11_NV 0x8830
#define GL_DRAW_BUFFER12_NV 0x8831
#define GL_DRAW_BUFFER13_NV 0x8832
#define GL_DRAW_BUFFER14_NV 0x8833
#define GL_DRAW_BUFFER15_NV 0x8834
#define GL_COLOR_ATTACHMENT0_NV 0x8CE0
#define GL_COLOR_ATTACHMENT1_NV 0x8CE1
#define GL_COLOR_ATTACHMENT2_NV 0x8CE2
#define GL_COLOR_ATTACHMENT3_NV 0x8CE3
#define GL_COLOR_ATTACHMENT4_NV 0x8CE4
#define GL_COLOR_ATTACHMENT5_NV 0x8CE5
#define GL_COLOR_ATTACHMENT6_NV 0x8CE6
#define GL_COLOR_ATTACHMENT7_NV 0x8CE7
#define GL_COLOR_ATTACHMENT8_NV 0x8CE8
#define GL_COLOR_ATTACHMENT9_NV 0x8CE9
#define GL_COLOR_ATTACHMENT10_NV 0x8CEA
#define GL_COLOR_ATTACHMENT11_NV 0x8CEB
#define GL_COLOR_ATTACHMENT12_NV 0x8CEC
#define GL_COLOR_ATTACHMENT13_NV 0x8CED
#define GL_COLOR_ATTACHMENT14_NV 0x8CEE
#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
#endif
/* GL_NV_fbo_color_attachments */
#ifndef GL_NV_fbo_color_attachments
#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
#endif
/* GL_NV_fence */
#ifndef GL_NV_fence
#define GL_ALL_COMPLETED_NV 0x84F2
#define GL_FENCE_STATUS_NV 0x84F3
#define GL_FENCE_CONDITION_NV 0x84F4
#endif
/* GL_NV_read_buffer */
#ifndef GL_NV_read_buffer
#define GL_READ_BUFFER_NV 0x0C02
#endif
/* GL_NV_read_buffer_front */
/* No new tokens introduced by this extension. */
/* GL_NV_read_depth */
/* No new tokens introduced by this extension. */
/* GL_NV_read_depth_stencil */
/* No new tokens introduced by this extension. */
/* GL_NV_read_stencil */
/* No new tokens introduced by this extension. */
/* GL_NV_texture_compression_s3tc_update */
/* No new tokens introduced by this extension. */
/* GL_NV_texture_npot_2D_mipmap */
/* No new tokens introduced by this extension. */
/*------------------------------------------------------------------------*
* QCOM extension tokens
*------------------------------------------------------------------------*/
/* GL_QCOM_alpha_test */
#ifndef GL_QCOM_alpha_test
#define GL_ALPHA_TEST_QCOM 0x0BC0
#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
#endif
/* GL_QCOM_driver_control */
/* No new tokens introduced by this extension. */
@ -357,22 +539,12 @@ typedef void* GLeglImageOES;
#endif
/*------------------------------------------------------------------------*
* ANGLE extension tokens
* VIV extension tokens
*------------------------------------------------------------------------*/
/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9
#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 // alias GL_FRAMEBUFFER_BINDING
#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA
#endif
/* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_framebuffer_multisample
#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
#define GL_MAX_SAMPLES_ANGLE 0x8D57
/* GL_VIV_shader_binary */
#ifndef GL_VIV_shader_binary
#define GL_SHADER_BINARY_VIV 0x8FC4
#endif
/*------------------------------------------------------------------------*
@ -419,6 +591,12 @@ typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target,
typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
#endif
/* GL_OES_EGL_image_external */
#ifndef GL_OES_EGL_image_external
#define GL_OES_EGL_image_external 1
/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
#endif
/* GL_OES_element_index_uint */
#ifndef GL_OES_element_index_uint
#define GL_OES_element_index_uint 1
@ -600,6 +778,82 @@ typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monito
#define GL_AMD_program_binary_Z400 1
#endif
/*------------------------------------------------------------------------*
* ANGLE extension functions
*------------------------------------------------------------------------*/
/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_ANGLE_framebuffer_blit 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
/* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_framebuffer_multisample
#define GL_ANGLE_framebuffer_multisample 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_ANGLE_texture_compression_dxt3 1
#endif
/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_ANGLE_texture_compression_dxt5 1
#endif
/*------------------------------------------------------------------------*
* APPLE extension functions
*------------------------------------------------------------------------*/
/* GL_APPLE_rgb_422 */
#ifndef GL_APPLE_rgb_422
#define GL_APPLE_rgb_422 1
#endif
/* GL_APPLE_framebuffer_multisample */
#ifndef GL_APPLE_framebuffer_multisample
#define GL_APPLE_framebuffer_multisample 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
#endif
/* GL_APPLE_texture_format_BGRA8888 */
#ifndef GL_APPLE_texture_format_BGRA8888
#define GL_APPLE_texture_format_BGRA8888 1
#endif
/* GL_APPLE_texture_max_level */
#ifndef GL_APPLE_texture_max_level
#define GL_APPLE_texture_max_level 1
#endif
/*------------------------------------------------------------------------*
* ARM extension functions
*------------------------------------------------------------------------*/
/* GL_ARM_mali_shader_binary */
#ifndef GL_ARM_mali_shader_binary
#define GL_ARM_mali_shader_binary 1
#endif
/* GL_ARM_rgba8 */
#ifndef GL_ARM_rgba8
#define GL_ARM_rgba8 1
#endif
/*------------------------------------------------------------------------*
* EXT extension functions
*------------------------------------------------------------------------*/
@ -633,6 +887,11 @@ typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GL
#define GL_EXT_read_format_bgra 1
#endif
/* GL_EXT_shader_texture_lod */
#ifndef GL_EXT_shader_texture_lod
#define GL_EXT_shader_texture_lod 1
#endif
/* GL_EXT_texture_filter_anisotropic */
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_EXT_texture_filter_anisotropic 1
@ -653,6 +912,20 @@ typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GL
#define GL_EXT_texture_compression_dxt1 1
#endif
/* GL_EXT_unpack_subimage */
#ifndef GL_EXT_unpack_subimage
#define GL_EXT_unpack_subimage 1
#endif
/*------------------------------------------------------------------------*
* DMP extension functions
*------------------------------------------------------------------------*/
/* GL_DMP_shader_binary */
#ifndef GL_DMP_shader_binary
#define GL_DMP_shader_binary 1
#endif
/*------------------------------------------------------------------------*
* IMG extension functions
*------------------------------------------------------------------------*/
@ -677,10 +950,51 @@ typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GL
#define GL_IMG_texture_compression_pvrtc 1
#endif
/* GL_IMG_multisampled_render_to_texture */
#ifndef GL_IMG_multisampled_render_to_texture
#define GL_IMG_multisampled_render_to_texture 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
#endif
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
#endif
/*------------------------------------------------------------------------*
* NV extension functions
*------------------------------------------------------------------------*/
/* GL_NV_coverage_sample */
#ifndef GL_NV_coverage_sample
#define GL_NV_coverage_sample 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
#endif
typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
#endif
/* GL_NV_depth_nonlinear */
#ifndef GL_NV_depth_nonlinear
#define GL_NV_depth_nonlinear 1
#endif
/* GL_NV_draw_buffers */
#ifndef GL_NV_draw_buffers
#define GL_NV_draw_buffers 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
#endif
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
#endif
/* GL_NV_fbo_color_attachments */
#ifndef GL_NV_fbo_color_attachments
#define GL_NV_fbo_color_attachments 1
#endif
/* GL_NV_fence */
#ifndef GL_NV_fence
#define GL_NV_fence 1
@ -702,26 +1016,58 @@ typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
#endif
/* GL_NV_coverage_sample */
#ifndef GL_NV_coverage_sample
#define GL_NV_coverage_sample 1
/* GL_NV_read_buffer */
#ifndef GL_NV_read_buffer
#define GL_NV_read_buffer 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
#endif
typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
#endif
/* GL_NV_depth_nonlinear */
#ifndef GL_NV_depth_nonlinear
#define GL_NV_depth_nonlinear 1
/* GL_NV_read_buffer_front */
#ifndef GL_NV_read_buffer_front
#define GL_NV_read_buffer_front 1
#endif
/* GL_NV_read_depth */
#ifndef GL_NV_read_depth
#define GL_NV_read_depth 1
#endif
/* GL_NV_read_depth_stencil */
#ifndef GL_NV_read_depth_stencil
#define GL_NV_read_depth_stencil 1
#endif
/* GL_NV_read_stencil */
#ifndef GL_NV_read_stencil
#define GL_NV_read_stencil 1
#endif
/* GL_NV_texture_compression_s3tc_update */
#ifndef GL_NV_texture_compression_s3tc_update
#define GL_NV_texture_compression_s3tc_update 1
#endif
/* GL_NV_texture_npot_2D_mipmap */
#ifndef GL_NV_texture_npot_2D_mipmap
#define GL_NV_texture_npot_2D_mipmap 1
#endif
/*------------------------------------------------------------------------*
* QCOM extension functions
*------------------------------------------------------------------------*/
/* GL_QCOM_alpha_test */
#ifndef GL_QCOM_alpha_test
#define GL_QCOM_alpha_test 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
#endif
typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
#endif
/* GL_QCOM_driver_control */
#ifndef GL_QCOM_driver_control
#define GL_QCOM_driver_control 1
@ -797,31 +1143,12 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
#endif
/*------------------------------------------------------------------------*
* ANGLE extension functions
* VIV extension tokens
*------------------------------------------------------------------------*/
/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_ANGLE_framebuffer_blit 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
#endif
typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
#endif
/* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_framebuffer_multisample
#define GL_ANGLE_framebuffer_multisample 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat,
GLsizei width, GLsizei height);
#endif
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat,
GLsizei width, GLsizei height);
/* GL_VIV_shader_binary */
#ifndef GL_VIV_shader_binary
#define GL_VIV_shader_binary 1
#endif
#ifdef __cplusplus

Просмотреть файл

@ -17,7 +17,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define SH_VERSION 104
#define SH_VERSION 105
//
// The names of the following enums have been derived by replacing GL prefix
@ -35,6 +35,12 @@ typedef enum {
SH_WEBGL_SPEC = 0x8B41
} ShShaderSpec;
typedef enum {
SH_ESSL_OUTPUT = 0x8B45,
SH_GLSL_OUTPUT = 0x8B46,
SH_HLSL_OUTPUT = 0x8B47
} ShShaderOutput;
typedef enum {
SH_NONE = 0,
SH_INT = 0x1404,
@ -75,7 +81,11 @@ typedef enum {
SH_ATTRIBUTES_UNIFORMS = 0x0008,
SH_LINE_DIRECTIVES = 0x0010,
SH_SOURCE_PATH = 0x0020,
SH_MAP_LONG_VARIABLE_NAMES = 0x0040
SH_MAP_LONG_VARIABLE_NAMES = 0x0040,
SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX = 0x0080,
// This is needed only as a workaround for certain OpenGL driver bugs.
SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100
} ShCompileOptions;
//
@ -109,6 +119,7 @@ typedef struct
// Extensions.
// Set to 1 to enable the extension, else 0.
int OES_standard_derivatives;
int OES_EGL_image_external;
} ShBuiltInResources;
//
@ -128,13 +139,17 @@ typedef void* ShHandle;
//
// Driver calls these to create and destroy compiler objects.
//
// Returns the handle of constructed compiler.
// Returns the handle of constructed compiler, null if the requested compiler is
// not supported.
// Parameters:
// type: Specifies the type of shader - SH_FRAGMENT_SHADER or SH_VERTEX_SHADER.
// spec: Specifies the language spec the compiler must conform to -
// SH_GLES2_SPEC or SH_WEBGL_SPEC.
// output: Specifies the output code type - SH_ESSL_OUTPUT, SH_GLSL_OUTPUT,
// or SH_HLSL_OUTPUT.
// resources: Specifies the built-in resources.
ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
ShShaderOutput output,
const ShBuiltInResources* resources);
void ShDestruct(ShHandle handle);

Просмотреть файл

@ -53,6 +53,7 @@ void GenerateResources(ShBuiltInResources* resources)
resources->MaxDrawBuffers = 1;
resources->OES_standard_derivatives = 0;
resources->OES_EGL_image_external = 0;
}
int main(int argc, char* argv[])
@ -66,6 +67,7 @@ int main(int argc, char* argv[])
char* buffer = 0;
int bufferLen = 0;
int numAttribs = 0, numUniforms = 0;
ShShaderOutput output = SH_ESSL_OUTPUT;
ShInitialize();
@ -81,6 +83,21 @@ int main(int argc, char* argv[])
case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break;
case 'o': compileOptions |= SH_OBJECT_CODE; break;
case 'u': compileOptions |= SH_ATTRIBUTES_UNIFORMS; break;
case 'l': compileOptions |= SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX; break;
case 'e': compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; break;
case 'b':
if (argv[0][2] == '=') {
switch (argv[0][3]) {
case 'e': output = SH_ESSL_OUTPUT; break;
case 'g': output = SH_GLSL_OUTPUT; break;
case 'h': output = SH_HLSL_OUTPUT; break;
default: failCode = EFailUsage;
}
} else {
failCode = EFailUsage;
}
break;
case 'a': resources.OES_EGL_image_external = 1; break;
default: failCode = EFailUsage;
}
} else {
@ -88,12 +105,14 @@ int main(int argc, char* argv[])
switch (FindShaderType(argv[0])) {
case SH_VERTEX_SHADER:
if (vertexCompiler == 0)
vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources);
vertexCompiler = ShConstructCompiler(
SH_VERTEX_SHADER, SH_GLES2_SPEC, output, &resources);
compiler = vertexCompiler;
break;
case SH_FRAGMENT_SHADER:
if (fragmentCompiler == 0)
fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources);
fragmentCompiler = ShConstructCompiler(
SH_FRAGMENT_SHADER, SH_GLES2_SPEC, output, &resources);
compiler = fragmentCompiler;
break;
default: break;
@ -159,12 +178,18 @@ int main(int argc, char* argv[])
//
void usage()
{
printf("Usage: translate [-i -m -o -u] file1 file2 ...\n"
"Where: filename = filename ending in .frag or .vert\n"
" -i = print intermediate tree\n"
" -m = map long variable names\n"
" -o = print translated code\n"
" -u = print active attribs and uniforms\n");
printf("Usage: translate [-i -m -o -u -l -e -b=e -b=g -b=h -a] file1 file2 ...\n"
"Where: filename : filename ending in .frag or .vert\n"
" -i : print intermediate tree\n"
" -m : map long variable names\n"
" -o : print translated code\n"
" -u : print active attribs and uniforms\n"
" -l : unroll for-loops with integer indices\n"
" -e : emulate certain built-in functions (workaround for driver bugs)\n"
" -b=e : output GLSL ES code (this is by default)\n"
" -b=g : output GLSL code\n"
" -b=h : output HLSL code\n"
" -a : enable GL_OES_EGL_image_external\n");
}
//

Просмотреть файл

@ -21,25 +21,43 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.ActiveCfg = Debug|Win32
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|Win32.Build.0 = Debug|Win32
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.ActiveCfg = Debug|x64
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Debug|x64.Build.0 = Debug|x64
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.ActiveCfg = Release|Win32
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|Win32.Build.0 = Release|Win32
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.ActiveCfg = Release|x64
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}.Release|x64.Build.0 = Release|x64
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.ActiveCfg = Debug|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|Win32.Build.0 = Debug|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.ActiveCfg = Debug|x64
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Debug|x64.Build.0 = Debug|x64
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.ActiveCfg = Release|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|Win32.Build.0 = Release|Win32
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.ActiveCfg = Release|x64
{B5871A7A-968C-42E3-A33B-981E6F448E78}.Release|x64.Build.0 = Release|x64
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.ActiveCfg = Debug|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|Win32.Build.0 = Debug|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.ActiveCfg = Debug|x64
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Debug|x64.Build.0 = Debug|x64
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.ActiveCfg = Release|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|Win32.Build.0 = Release|Win32
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.ActiveCfg = Release|x64
{5620F0E4-6C43-49BC-A178-B804E1A0C3A7}.Release|x64.Build.0 = Release|x64
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.ActiveCfg = Debug|Win32
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|Win32.Build.0 = Debug|Win32
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.ActiveCfg = Debug|x64
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Debug|x64.Build.0 = Debug|x64
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.ActiveCfg = Release|Win32
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|Win32.Build.0 = Release|Win32
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.ActiveCfg = Release|x64
{5B3A6DB8-1E7E-40D7-92B9-DA8AAE619FAD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -19,11 +19,17 @@
],
'sources': [
'compiler/BaseTypes.h',
'compiler/BuiltInFunctionEmulator.cpp',
'compiler/BuiltInFunctionEmulator.h',
'compiler/Common.h',
'compiler/Compiler.cpp',
'compiler/ConstantUnion.h',
'compiler/compilerdebug.cpp',
'compiler/compilerdebug.h',
'compiler/debug.cpp',
'compiler/debug.h',
'compiler/DetectRecursion.cpp',
'compiler/DetectRecursion.h',
'compiler/ForLoopUnroll.cpp',
'compiler/ForLoopUnroll.h',
'compiler/glslang.h',
'compiler/glslang_lex.cpp',
'compiler/glslang_tab.cpp',
@ -59,7 +65,6 @@
'compiler/SymbolTable.cpp',
'compiler/SymbolTable.h',
'compiler/Types.h',
'compiler/unistd.h',
'compiler/util.cpp',
'compiler/util.h',
'compiler/ValidateLimitations.cpp',
@ -102,10 +107,14 @@
],
'sources': [
'compiler/CodeGenGLSL.cpp',
'compiler/ForLoopUnroll.cpp',
'compiler/ForLoopUnroll.h',
'compiler/OutputESSL.cpp',
'compiler/OutputESSL.h',
'compiler/OutputGLSLBase.cpp',
'compiler/OutputGLSLBase.h',
'compiler/OutputGLSL.cpp',
'compiler/OutputGLSL.h',
'compiler/TranslatorESSL.cpp',
'compiler/TranslatorESSL.h',
'compiler/TranslatorGLSL.cpp',
'compiler/TranslatorGLSL.h',
'compiler/VersionGLSL.cpp',
@ -169,6 +178,7 @@
'libGLESv2/HandleAllocator.h',
'libGLESv2/libGLESv2.cpp',
'libGLESv2/libGLESv2.def',
'libGLESv2/libGLESv2.rc',
'libGLESv2/main.cpp',
'libGLESv2/main.h',
'libGLESv2/mathutil.h',
@ -217,6 +227,7 @@
'libEGL/Display.h',
'libEGL/libEGL.cpp',
'libEGL/libEGL.def',
'libEGL/libEGL.rc',
'libEGL/main.cpp',
'libEGL/main.h',
'libEGL/Surface.cpp',

Просмотреть файл

@ -1,7 +1,7 @@
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 686
#define BUILD_REVISION 740
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)

Просмотреть файл

@ -42,6 +42,7 @@ enum TBasicType
EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
EbtSampler2D,
EbtSamplerCube,
EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtStruct,
EbtAddress, // should be deprecated??
@ -57,6 +58,7 @@ inline const char* getBasicString(TBasicType t)
case EbtBool: return "bool"; break;
case EbtSampler2D: return "sampler2D"; break;
case EbtSamplerCube: return "samplerCube"; break;
case EbtSamplerExternalOES: return "samplerExternalOES"; break;
case EbtStruct: return "structure"; break;
default: return "unknown type";
}

Просмотреть файл

@ -0,0 +1,161 @@
//
// 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/BuiltInFunctionEmulator.h"
#include "compiler/SymbolTable.h"
namespace {
const char* kFunctionEmulationSource[] = {
"float webgl_normalize_emu(float a) { return normalize(a) * 1; }",
"vec2 webgl_normalize_emu(vec2 a) { return normalize(a) * 1; }",
"vec3 webgl_normalize_emu(vec3 a) { return normalize(a) * 1; }",
"vec4 webgl_normalize_emu(vec4 a) { return normalize(a) * 1; }",
"float webgl_abs_emu(float a) { float rt = abs(a); if (rt < 0.0) rt = 0.0; return rt; }",
"vec2 webgl_abs_emu(vec2 a) { vec2 rt = abs(a); if (rt[0] < 0.0) rt[0] = 0.0; return rt; }",
"vec3 webgl_abs_emu(vec3 a) { vec3 rt = abs(a); if (rt[0] < 0.0) rt[0] = 0.0; return rt; }",
"vec4 webgl_abs_emu(vec4 a) { vec4 rt = abs(a); if (rt[0] < 0.0) rt[0] = 0.0; return rt; }",
"float webgl_sign_emu(float a) { float rt = sign(a); if (rt > 1.0) rt = 1.0; return rt; }",
"vec2 webgl_sign_emu(vec2 a) { float rt = sign(a); if (rt[0] > 1.0) rt[0] = 1.0; return rt; }",
"vec3 webgl_sign_emu(vec3 a) { float rt = sign(a); if (rt[0] > 1.0) rt[0] = 1.0; return rt; }",
"vec4 webgl_sign_emu(vec4 a) { float rt = sign(a); if (rt[0] > 1.0) rt[0] = 1.0; return rt; }",
};
class BuiltInFunctionEmulationMarker : public TIntermTraverser {
public:
BuiltInFunctionEmulationMarker(BuiltInFunctionEmulator& emulator)
: mEmulator(emulator)
{
}
virtual bool visitUnary(Visit visit, TIntermUnary* node)
{
if (visit == PreVisit) {
bool needToEmulate = mEmulator.SetFunctionCalled(
node->getOp(), node->getOperand()->getType());
if (needToEmulate)
node->setUseEmulatedFunction();
}
return true;
}
private:
BuiltInFunctionEmulator& mEmulator;
};
} // anonymous namepsace
BuiltInFunctionEmulator::BuiltInFunctionEmulator()
: mFunctionGroupMask(TFunctionGroupAll)
{
}
void BuiltInFunctionEmulator::SetFunctionGroupMask(
unsigned int functionGroupMask)
{
mFunctionGroupMask = functionGroupMask;
}
bool BuiltInFunctionEmulator::SetFunctionCalled(
TOperator op, const TType& returnType)
{
TBuiltInFunction function = IdentifyFunction(op, returnType);
if (function == TFunctionUnknown)
return false;
for (size_t i = 0; i < mFunctions.size(); ++i) {
if (mFunctions[i] == function)
return true;
}
switch (function) {
case TFunctionNormalize1:
case TFunctionNormalize2:
case TFunctionNormalize3:
case TFunctionNormalize4:
if (mFunctionGroupMask & TFunctionGroupNormalize) {
mFunctions.push_back(function);
return true;
}
break;
case TFunctionAbs1:
case TFunctionAbs2:
case TFunctionAbs3:
case TFunctionAbs4:
if (mFunctionGroupMask & TFunctionGroupAbs) {
mFunctions.push_back(function);
return true;
}
break;
case TFunctionSign1:
case TFunctionSign2:
case TFunctionSign3:
case TFunctionSign4:
if (mFunctionGroupMask & TFunctionGroupSign) {
mFunctions.push_back(function);
return true;
}
break;
default:
UNREACHABLE();
break;
}
return false;
}
void BuiltInFunctionEmulator::OutputEmulatedFunctionDefinition(
TInfoSinkBase& out, bool withPrecision) const
{
if (mFunctions.size() == 0)
return;
out << "// BEGIN: Generated code for built-in function emulation\n\n";
if (withPrecision) {
out << "#if defined(GL_FRAGMENT_PRECISION_HIGH) && (GL_FRAGMENT_PRECISION_HIGH == 1)\n"
<< "precision highp float;\n"
<< "#else\n"
<< "precision mediump float;\n"
<< "#endif\n\n";
}
for (size_t i = 0; i < mFunctions.size(); ++i) {
out << kFunctionEmulationSource[mFunctions[i]] << "\n\n";
}
out << "// END: Generated code for built-in function emulation\n\n";
}
BuiltInFunctionEmulator::TBuiltInFunction
BuiltInFunctionEmulator::IdentifyFunction(TOperator op, const TType& returnType)
{
unsigned int function = TFunctionUnknown;
if (op == EOpNormalize)
function = TFunctionNormalize1;
else if (op == EOpAbs)
function = TFunctionAbs1;
else if (op == EOpSign)
function = TFunctionSign1;
else
return static_cast<TBuiltInFunction>(function);
if (returnType.isVector())
function += returnType.getNominalSize() - 1;
return static_cast<TBuiltInFunction>(function);
}
void BuiltInFunctionEmulator::MarkBuiltInFunctionsForEmulation(
TIntermNode* root)
{
ASSERT(root);
BuiltInFunctionEmulationMarker marker(*this);
root->traverse(&marker);
}
//static
TString BuiltInFunctionEmulator::GetEmulatedFunctionName(
const TString& name)
{
ASSERT(name[name.length() - 1] == '(');
return "webgl_" + name.substr(0, name.length() - 1) + "_emu(";
}

Просмотреть файл

@ -0,0 +1,86 @@
//
// Copyright (c) 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 COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
#define COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_
#include "compiler/InfoSink.h"
#include "compiler/intermediate.h"
//
// Built-in function groups. We only list the ones that might need to be
// emulated in certain os/drivers, assuming they are no more than 32.
//
enum TBuiltInFunctionGroup {
TFunctionGroupNormalize = 1 << 0,
TFunctionGroupAbs = 1 << 1,
TFunctionGroupSign = 1 << 2,
TFunctionGroupAll =
TFunctionGroupNormalize | TFunctionGroupAbs | TFunctionGroupSign
};
//
// This class decides which built-in functions need to be replaced with the
// emulated ones.
// It's only a workaround for OpenGL driver bugs, and isn't needed in general.
//
class BuiltInFunctionEmulator {
public:
BuiltInFunctionEmulator();
// functionGroupMask is a bitmap of TBuiltInFunctionGroup.
// We only emulate functions that are marked by this mask and are actually
// called in a given shader.
// By default the value is TFunctionGroupAll.
void SetFunctionGroupMask(unsigned int functionGroupMask);
// Records that a function is called by the shader and might needs to be
// emulated. If the function's group is not in mFunctionGroupFilter, this
// becomes an no-op.
// Returns true if the function call needs to be replaced with an emulated
// one.
// TODO(zmo): for now, an operator and a return type is enough to identify
// the function we want to emulate. Should make this more flexible to
// handle any functions.
bool SetFunctionCalled(TOperator op, const TType& returnType);
// Output function emulation definition. This should be before any other
// shader source.
void OutputEmulatedFunctionDefinition(TInfoSinkBase& out, bool withPrecision) const;
void MarkBuiltInFunctionsForEmulation(TIntermNode* root);
// "name(" becomes "webgl_name_emu(".
static TString GetEmulatedFunctionName(const TString& name);
private:
//
// Built-in functions.
//
enum TBuiltInFunction {
TFunctionNormalize1 = 0, // float normalize(float);
TFunctionNormalize2, // vec2 normalize(vec2);
TFunctionNormalize3, // vec3 normalize(vec3);
TFunctionNormalize4, // fec4 normalize(vec4);
TFunctionAbs1, // float abs(float);
TFunctionAbs2, // vec2 abs(vec2);
TFunctionAbs3, // vec3 abs(vec3);
TFunctionAbs4, // vec4 abs(vec4);
TFunctionSign1, // float sign(float);
TFunctionSign2, // vec2 sign(vec2);
TFunctionSign3, // vec3 sign(vec3);
TFunctionSign4, // vec4 sign(vec4);
TFunctionUnknown
};
// Same TODO as SetFunctionCalled.
TBuiltInFunction IdentifyFunction(TOperator op, const TType& returnType);
TVector<TBuiltInFunction> mFunctions;
unsigned int mFunctionGroupMask; // a bitmap of TBuiltInFunctionGroup.
};
#endif // COMPILIER_BUILT_IN_FUNCTION_EMULATOR_H_

Просмотреть файл

@ -5,15 +5,24 @@
//
#include "compiler/TranslatorGLSL.h"
#include "compiler/TranslatorESSL.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)
TCompiler* ConstructCompiler(
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
{
return new TranslatorGLSL(type, spec);
switch (output) {
case SH_GLSL_OUTPUT:
return new TranslatorGLSL(type, spec);
case SH_ESSL_OUTPUT:
return new TranslatorESSL(type, spec);
default:
return NULL;
}
}
//

Просмотреть файл

@ -11,9 +11,15 @@
// compile object used by higher level code. It returns
// a subclass of TCompiler.
//
TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec)
TCompiler* ConstructCompiler(
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
{
return new TranslatorHLSL(type, spec);
switch (output) {
case SH_HLSL_OUTPUT:
return new TranslatorHLSL(type, spec);
default:
return NULL;
}
}
//

Просмотреть файл

@ -4,7 +4,9 @@
// found in the LICENSE file.
//
#include "compiler/BuiltInFunctionEmulator.h"
#include "compiler/DetectRecursion.h"
#include "compiler/ForLoopUnroll.h"
#include "compiler/Initialize.h"
#include "compiler/ParseHelper.h"
#include "compiler/ShHandle.h"
@ -19,7 +21,10 @@ bool InitializeSymbolTable(
{
TIntermediate intermediate(infoSink);
TExtensionBehavior extBehavior;
TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, NULL, infoSink);
InitExtensionBehavior(resources, extBehavior);
// The builtins deliberately don't specify precisions for the function
// arguments and return types. For that reason we don't try to check them.
TParseContext parseContext(symbolTable, extBehavior, intermediate, type, spec, 0, false, NULL, infoSink);
GlobalParseContext = &parseContext;
@ -128,7 +133,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
TIntermediate intermediate(infoSink);
TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
shaderType, shaderSpec, compileOptions,
shaderType, shaderSpec, compileOptions, true,
sourcePath, infoSink);
GlobalParseContext = &parseContext;
@ -152,6 +157,14 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
success = validateLimitations(root);
// Unroll for-loop markup needs to happen after validateLimitations pass.
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(root);
// Built-in function emulation needs to happen after validateLimitations pass.
if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS))
builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root);
// Call mapLongVariableNames() before collectAttribsUniforms() so in
// collectAttribsUniforms() we already have the mapped symbol names and
// we could composite mapped and original variable names.
@ -238,3 +251,13 @@ int TCompiler::getMappedNameMaxLength() const
{
return MAX_IDENTIFIER_NAME_SIZE + 1;
}
const TExtensionBehavior& TCompiler::getExtensionBehavior() const
{
return extensionBehavior;
}
const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const
{
return builtInFunctionEmulator;
}

Просмотреть файл

@ -64,29 +64,6 @@ DetectRecursion::~DetectRecursion()
delete functions[i];
}
void DetectRecursion::visitSymbol(TIntermSymbol*)
{
}
void DetectRecursion::visitConstantUnion(TIntermConstantUnion*)
{
}
bool DetectRecursion::visitBinary(Visit, TIntermBinary*)
{
return true;
}
bool DetectRecursion::visitUnary(Visit, TIntermUnary*)
{
return true;
}
bool DetectRecursion::visitSelection(Visit, TIntermSelection*)
{
return true;
}
bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node)
{
switch (node->getOp())
@ -126,16 +103,6 @@ bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node)
return true;
}
bool DetectRecursion::visitLoop(Visit, TIntermLoop*)
{
return true;
}
bool DetectRecursion::visitBranch(Visit, TIntermBranch*)
{
return true;
}
DetectRecursion::ErrorCode DetectRecursion::detectRecursion()
{
FunctionNode* main = findFunctionByName("main(");

Просмотреть файл

@ -24,14 +24,7 @@ public:
DetectRecursion();
~DetectRecursion();
virtual void visitSymbol(TIntermSymbol*);
virtual void visitConstantUnion(TIntermConstantUnion*);
virtual bool visitBinary(Visit, TIntermBinary*);
virtual bool visitUnary(Visit, TIntermUnary*);
virtual bool visitSelection(Visit, TIntermSelection*);
virtual bool visitAggregate(Visit, TIntermAggregate*);
virtual bool visitLoop(Visit, TIntermLoop*);
virtual bool visitBranch(Visit, TIntermBranch*);
ErrorCode detectRecursion();

Просмотреть файл

@ -13,9 +13,26 @@ typedef enum {
EBhRequire,
EBhEnable,
EBhWarn,
EBhDisable
EBhDisable,
EBhUndefined,
} TBehavior;
inline const char* getBehaviorString(TBehavior b)
{
switch(b) {
case EBhRequire:
return "require";
case EBhEnable:
return "enable";
case EBhWarn:
return "warn";
case EBhDisable:
return "disable";
default:
return NULL;
}
}
typedef TMap<TString, TBehavior> TExtensionBehavior;
#endif // _EXTENSION_TABLE_INCLUDED_

Просмотреть файл

@ -6,6 +6,39 @@
#include "compiler/ForLoopUnroll.h"
namespace {
class IntegerForLoopUnrollMarker : public TIntermTraverser {
public:
virtual bool visitLoop(Visit, TIntermLoop* node)
{
// This is called after ValidateLimitations pass, so all the ASSERT
// should never fail.
// See ValidateLimitations::validateForLoopInit().
ASSERT(node);
ASSERT(node->getType() == ELoopFor);
ASSERT(node->getInit());
TIntermAggregate* decl = node->getInit()->getAsAggregate();
ASSERT(decl && decl->getOp() == EOpDeclaration);
TIntermSequence& declSeq = decl->getSequence();
ASSERT(declSeq.size() == 1);
TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
ASSERT(declInit && declInit->getOp() == EOpInitialize);
ASSERT(declInit->getLeft());
TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
ASSERT(symbol);
TBasicType type = symbol->getBasicType();
ASSERT(type == EbtInt || type == EbtFloat);
if (type == EbtInt)
node->setUnrollFlag(true);
return true;
}
};
} // anonymous namepsace
void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info)
{
ASSERT(node->getType() == ELoopFor);
@ -109,6 +142,16 @@ void ForLoopUnroll::Pop()
mLoopIndexStack.pop_back();
}
// static
void ForLoopUnroll::MarkForLoopsWithIntegerIndicesForUnrolling(
TIntermNode* root)
{
ASSERT(root);
IntegerForLoopUnrollMarker marker;
root->traverse(&marker);
}
int ForLoopUnroll::getLoopIncrement(TIntermLoop* node)
{
TIntermNode* expr = node->getExpression();

Просмотреть файл

@ -36,6 +36,8 @@ public:
void Push(TLoopIndexInfo& info);
void Pop();
static void MarkForLoopsWithIntegerIndicesForUnrolling(TIntermNode* root);
private:
int getLoopIncrement(TIntermLoop* node);

Просмотреть файл

@ -363,6 +363,12 @@ static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources)
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
if (resources.OES_EGL_image_external) {
s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);"));
}
return s;
}
@ -388,6 +394,12 @@ static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources)
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
if (resources.OES_EGL_image_external) {
s.append(TString("vec4 texture2D(samplerExternalOES sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);"));
}
if (resources.OES_standard_derivatives) {
s.append(TString("float dFdx(float p);"));
s.append(TString("vec2 dFdx(vec2 p);"));
@ -625,5 +637,7 @@ void InitExtensionBehavior(const ShBuiltInResources& resources,
TExtensionBehavior& extBehavior)
{
if (resources.OES_standard_derivatives)
extBehavior["GL_OES_standard_derivatives"] = EBhDisable;
extBehavior["GL_OES_standard_derivatives"] = EBhUndefined;
if (resources.OES_EGL_image_external)
extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
}

Просмотреть файл

@ -48,37 +48,10 @@ void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
}
}
void MapLongVariableNames::visitConstantUnion(TIntermConstantUnion*)
{
}
bool MapLongVariableNames::visitBinary(Visit, TIntermBinary*)
{
return true;
}
bool MapLongVariableNames::visitUnary(Visit, TIntermUnary*)
{
return true;
}
bool MapLongVariableNames::visitSelection(Visit, TIntermSelection*)
{
return true;
}
bool MapLongVariableNames::visitAggregate(Visit, TIntermAggregate* node)
{
return true;
}
bool MapLongVariableNames::visitLoop(Visit, TIntermLoop*)
{
return true;
}
bool MapLongVariableNames::visitBranch(Visit, TIntermBranch*)
bool MapLongVariableNames::visitLoop(Visit, TIntermLoop* node)
{
if (node->getInit())
node->getInit()->traverse(this);
return true;
}

Просмотреть файл

@ -22,13 +22,7 @@ public:
MapLongVariableNames(TMap<TString, TString>& varyingLongNameMap);
virtual void visitSymbol(TIntermSymbol*);
virtual void visitConstantUnion(TIntermConstantUnion*);
virtual bool visitBinary(Visit, TIntermBinary*);
virtual bool visitUnary(Visit, TIntermUnary*);
virtual bool visitSelection(Visit, TIntermSelection*);
virtual bool visitAggregate(Visit, TIntermAggregate*);
virtual bool visitLoop(Visit, TIntermLoop*);
virtual bool visitBranch(Visit, TIntermBranch*);
private:
TString mapVaryingLongName(const TString& name);

Просмотреть файл

@ -0,0 +1,22 @@
//
// 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/OutputESSL.h"
TOutputESSL::TOutputESSL(TInfoSinkBase& objSink)
: TOutputGLSLBase(objSink)
{
}
bool TOutputESSL::writeVariablePrecision(TPrecision precision)
{
if (precision == EbpUndefined)
return false;
TInfoSinkBase& out = objSink();
out << getPrecisionString(precision);
return true;
}

Просмотреть файл

@ -0,0 +1,21 @@
//
// 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 CROSSCOMPILERGLSL_OUTPUTESSL_H_
#define CROSSCOMPILERGLSL_OUTPUTESSL_H_
#include "compiler/OutputGLSLBase.h"
class TOutputESSL : public TOutputGLSLBase
{
public:
TOutputESSL(TInfoSinkBase& objSink);
protected:
virtual bool writeVariablePrecision(TPrecision precision);
};
#endif // CROSSCOMPILERGLSL_OUTPUTESSL_H_

Просмотреть файл

@ -5,706 +5,13 @@
//
#include "compiler/OutputGLSL.h"
#include "compiler/compilerdebug.h"
namespace
{
TString getTypeName(const TType& type)
{
TInfoSinkBase out;
if (type.isMatrix())
{
out << "mat";
out << type.getNominalSize();
}
else if (type.isVector())
{
switch (type.getBasicType())
{
case EbtFloat: out << "vec"; break;
case EbtInt: out << "ivec"; break;
case EbtBool: out << "bvec"; break;
default: UNREACHABLE(); break;
}
out << type.getNominalSize();
}
else
{
if (type.getBasicType() == EbtStruct)
out << type.getTypeName();
else
out << type.getBasicString();
}
return TString(out.c_str());
}
TString arrayBrackets(const TType& type)
{
ASSERT(type.isArray());
TInfoSinkBase out;
out << "[" << type.getArraySize() << "]";
return TString(out.c_str());
}
bool isSingleStatement(TIntermNode* node) {
if (const TIntermAggregate* aggregate = node->getAsAggregate())
{
return (aggregate->getOp() != EOpFunction) &&
(aggregate->getOp() != EOpSequence);
}
else if (const TIntermSelection* selection = node->getAsSelectionNode())
{
// Ternary operators are usually part of an assignment operator.
// This handles those rare cases in which they are all by themselves.
return selection->usesTernaryOperator();
}
else if (node->getAsLoopNode())
{
return false;
}
return true;
}
} // namespace
TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink)
: TIntermTraverser(true, true, true),
mObjSink(objSink),
mDeclaringVariables(false)
: TOutputGLSLBase(objSink)
{
}
void TOutputGLSL::writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr)
bool TOutputGLSL::writeVariablePrecision(TPrecision)
{
TInfoSinkBase& out = objSink();
if (visit == PreVisit && preStr)
{
out << preStr;
}
else if (visit == InVisit && inStr)
{
out << inStr;
}
else if (visit == PostVisit && postStr)
{
out << postStr;
}
}
void TOutputGLSL::writeVariableType(const TType& type)
{
TInfoSinkBase& out = objSink();
TQualifier qualifier = type.getQualifier();
// TODO(alokp): Validate qualifier for variable declarations.
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
out << type.getQualifierString() << " ";
// Declare the struct if we have not done so already.
if ((type.getBasicType() == EbtStruct) &&
(mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end()))
{
out << "struct " << type.getTypeName() << "{\n";
const TTypeList* structure = type.getStruct();
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
const TType* fieldType = (*structure)[i].type;
ASSERT(fieldType != NULL);
out << getTypeName(*fieldType) << " " << fieldType->getFieldName();
if (fieldType->isArray())
out << arrayBrackets(*fieldType);
out << ";\n";
}
out << "}";
mDeclaredStructs.insert(type.getTypeName());
}
else
{
out << getTypeName(type);
}
}
void TOutputGLSL::writeFunctionParameters(const TIntermSequence& args)
{
TInfoSinkBase& out = objSink();
for (TIntermSequence::const_iterator iter = args.begin();
iter != args.end(); ++iter)
{
const TIntermSymbol* arg = (*iter)->getAsSymbolNode();
ASSERT(arg != NULL);
const TType& type = arg->getType();
TQualifier qualifier = type.getQualifier();
// TODO(alokp): Validate qualifier for function arguments.
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
out << type.getQualifierString() << " ";
out << getTypeName(type);
const TString& name = arg->getSymbol();
if (!name.empty())
out << " " << name;
if (type.isArray())
out << arrayBrackets(type);
// Put a comma if this is not the last argument.
if (iter != args.end() - 1)
out << ", ";
}
}
const ConstantUnion* TOutputGLSL::writeConstantUnion(const TType& type,
const ConstantUnion* pConstUnion)
{
TInfoSinkBase& out = objSink();
if (type.getBasicType() == EbtStruct)
{
out << type.getTypeName() << "(";
const TTypeList* structure = type.getStruct();
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
const TType* fieldType = (*structure)[i].type;
ASSERT(fieldType != NULL);
pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
if (i != structure->size() - 1) out << ", ";
}
out << ")";
}
else
{
int size = type.getObjectSize();
bool writeType = size > 1;
if (writeType) out << getTypeName(type) << "(";
for (int i = 0; i < size; ++i, ++pConstUnion)
{
switch (pConstUnion->getType())
{
case EbtFloat: out << pConstUnion->getFConst(); break;
case EbtInt: out << pConstUnion->getIConst(); break;
case EbtBool: out << pConstUnion->getBConst(); break;
default: UNREACHABLE();
}
if (i != size - 1) out << ", ";
}
if (writeType) out << ")";
}
return pConstUnion;
}
void TOutputGLSL::visitSymbol(TIntermSymbol* node)
{
TInfoSinkBase& out = objSink();
if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node))
out << mLoopUnroll.GetLoopIndexValue(node);
else
out << node->getSymbol();
if (mDeclaringVariables && node->getType().isArray())
out << arrayBrackets(node->getType());
}
void TOutputGLSL::visitConstantUnion(TIntermConstantUnion* node)
{
writeConstantUnion(node->getType(), node->getUnionArrayPointer());
}
bool TOutputGLSL::visitBinary(Visit visit, TIntermBinary* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break;
case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break;
case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break;
case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpIndexDirect:
case EOpIndexIndirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
out << ".";
// TODO(alokp): ASSERT
out << node->getType().getFieldName();
visitChildren = false;
}
break;
case EOpVectorSwizzle:
if (visit == InVisit)
{
out << ".";
TIntermAggregate* rightChild = node->getRight()->getAsAggregate();
TIntermSequence& sequence = rightChild->getSequence();
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
{
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1);
const ConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt);
switch (data.getIConst())
{
case 0: out << "x"; break;
case 1: out << "y"; break;
case 2: out << "z"; break;
case 3: out << "w"; break;
default: UNREACHABLE(); break;
}
}
visitChildren = false;
}
break;
case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break;
case EOpSub: writeTriplet(visit, "(", " - ", ")"); break;
case EOpMul: writeTriplet(visit, "(", " * ", ")"); break;
case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break;
case EOpMod: UNIMPLEMENTED(); break;
case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break;
case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break;
case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break;
case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break;
case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break;
case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break;
// Notice the fall-through.
case EOpVectorTimesScalar:
case EOpVectorTimesMatrix:
case EOpMatrixTimesVector:
case EOpMatrixTimesScalar:
case EOpMatrixTimesMatrix:
writeTriplet(visit, "(", " * ", ")");
break;
case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break;
case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break;
case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break;
default: UNREACHABLE(); break;
}
return visitChildren;
}
bool TOutputGLSL::visitUnary(Visit visit, TIntermUnary* node)
{
switch (node->getOp())
{
case EOpNegative: writeTriplet(visit, "(-", NULL, ")"); break;
case EOpVectorLogicalNot: writeTriplet(visit, "not(", NULL, ")"); break;
case EOpLogicalNot: writeTriplet(visit, "(!", NULL, ")"); break;
case EOpPostIncrement: writeTriplet(visit, "(", NULL, "++)"); break;
case EOpPostDecrement: writeTriplet(visit, "(", NULL, "--)"); break;
case EOpPreIncrement: writeTriplet(visit, "(++", NULL, ")"); break;
case EOpPreDecrement: writeTriplet(visit, "(--", NULL, ")"); break;
case EOpConvIntToBool:
case EOpConvFloatToBool:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: writeTriplet(visit, "bool(", NULL, ")"); break;
case 2: writeTriplet(visit, "bvec2(", NULL, ")"); break;
case 3: writeTriplet(visit, "bvec3(", NULL, ")"); break;
case 4: writeTriplet(visit, "bvec4(", NULL, ")"); break;
default: UNREACHABLE();
}
break;
case EOpConvBoolToFloat:
case EOpConvIntToFloat:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: writeTriplet(visit, "float(", NULL, ")"); break;
case 2: writeTriplet(visit, "vec2(", NULL, ")"); break;
case 3: writeTriplet(visit, "vec3(", NULL, ")"); break;
case 4: writeTriplet(visit, "vec4(", NULL, ")"); break;
default: UNREACHABLE();
}
break;
case EOpConvFloatToInt:
case EOpConvBoolToInt:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: writeTriplet(visit, "int(", NULL, ")"); break;
case 2: writeTriplet(visit, "ivec2(", NULL, ")"); break;
case 3: writeTriplet(visit, "ivec3(", NULL, ")"); break;
case 4: writeTriplet(visit, "ivec4(", NULL, ")"); break;
default: UNREACHABLE();
}
break;
case EOpRadians: writeTriplet(visit, "radians(", NULL, ")"); break;
case EOpDegrees: writeTriplet(visit, "degrees(", NULL, ")"); break;
case EOpSin: writeTriplet(visit, "sin(", NULL, ")"); break;
case EOpCos: writeTriplet(visit, "cos(", NULL, ")"); break;
case EOpTan: writeTriplet(visit, "tan(", NULL, ")"); break;
case EOpAsin: writeTriplet(visit, "asin(", NULL, ")"); break;
case EOpAcos: writeTriplet(visit, "acos(", NULL, ")"); break;
case EOpAtan: writeTriplet(visit, "atan(", NULL, ")"); break;
case EOpExp: writeTriplet(visit, "exp(", NULL, ")"); break;
case EOpLog: writeTriplet(visit, "log(", NULL, ")"); break;
case EOpExp2: writeTriplet(visit, "exp2(", NULL, ")"); break;
case EOpLog2: writeTriplet(visit, "log2(", NULL, ")"); break;
case EOpSqrt: writeTriplet(visit, "sqrt(", NULL, ")"); break;
case EOpInverseSqrt: writeTriplet(visit, "inversesqrt(", NULL, ")"); break;
case EOpAbs: writeTriplet(visit, "abs(", NULL, ")"); break;
case EOpSign: writeTriplet(visit, "sign(", NULL, ")"); break;
case EOpFloor: writeTriplet(visit, "floor(", NULL, ")"); break;
case EOpCeil: writeTriplet(visit, "ceil(", NULL, ")"); break;
case EOpFract: writeTriplet(visit, "fract(", NULL, ")"); break;
case EOpLength: writeTriplet(visit, "length(", NULL, ")"); break;
case EOpNormalize: writeTriplet(visit, "normalize(", NULL, ")"); break;
case EOpDFdx: writeTriplet(visit, "dFdx(", NULL, ")"); break;
case EOpDFdy: writeTriplet(visit, "dFdy(", NULL, ")"); break;
case EOpFwidth: writeTriplet(visit, "fwidth(", NULL, ")"); break;
case EOpAny: writeTriplet(visit, "any(", NULL, ")"); break;
case EOpAll: writeTriplet(visit, "all(", NULL, ")"); break;
default: UNREACHABLE(); break;
}
return true;
}
bool TOutputGLSL::visitSelection(Visit visit, TIntermSelection* node)
{
TInfoSinkBase& out = objSink();
if (node->usesTernaryOperator())
{
// Notice two brackets at the beginning and end. The outer ones
// encapsulate the whole ternary expression. This preserves the
// order of precedence when ternary expressions are used in a
// compound expression, i.e., c = 2 * (a < b ? 1 : 2).
out << "((";
node->getCondition()->traverse(this);
out << ") ? (";
node->getTrueBlock()->traverse(this);
out << ") : (";
node->getFalseBlock()->traverse(this);
out << "))";
}
else
{
out << "if (";
node->getCondition()->traverse(this);
out << ")\n";
incrementDepth();
visitCodeBlock(node->getTrueBlock());
if (node->getFalseBlock())
{
out << "else\n";
visitCodeBlock(node->getFalseBlock());
}
decrementDepth();
}
return false;
}
bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpSequence: {
// Scope the sequences except when at the global scope.
if (depth > 0) out << "{\n";
incrementDepth();
const TIntermSequence& sequence = node->getSequence();
for (TIntermSequence::const_iterator iter = sequence.begin();
iter != sequence.end(); ++iter)
{
TIntermNode* node = *iter;
ASSERT(node != NULL);
node->traverse(this);
if (isSingleStatement(node))
out << ";\n";
}
decrementDepth();
// Scope the sequences except when at the global scope.
if (depth > 0) out << "}\n";
visitChildren = false;
break;
}
case EOpPrototype: {
// Function declaration.
ASSERT(visit == PreVisit);
TString returnType = getTypeName(node->getType());
out << returnType << " " << node->getName();
out << "(";
writeFunctionParameters(node->getSequence());
out << ")";
visitChildren = false;
break;
}
case EOpFunction: {
// Function definition.
ASSERT(visit == PreVisit);
TString returnType = getTypeName(node->getType());
TString functionName = TFunction::unmangleName(node->getName());
out << returnType << " " << functionName;
incrementDepth();
// Function definition node contains one or two children nodes
// representing function parameters and function body. The latter
// is not present in case of empty function bodies.
const TIntermSequence& sequence = node->getSequence();
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
TIntermSequence::const_iterator seqIter = sequence.begin();
// Traverse function parameters.
TIntermAggregate* params = (*seqIter)->getAsAggregate();
ASSERT(params != NULL);
ASSERT(params->getOp() == EOpParameters);
params->traverse(this);
// Traverse function body.
TIntermAggregate* body = ++seqIter != sequence.end() ?
(*seqIter)->getAsAggregate() : NULL;
visitCodeBlock(body);
decrementDepth();
// Fully processed; no need to visit children.
visitChildren = false;
break;
}
case EOpFunctionCall:
// Function call.
if (visit == PreVisit)
{
TString functionName = TFunction::unmangleName(node->getName());
out << functionName << "(";
}
else if (visit == InVisit)
{
out << ", ";
}
else
{
out << ")";
}
break;
case EOpParameters: {
// Function parameters.
ASSERT(visit == PreVisit);
out << "(";
writeFunctionParameters(node->getSequence());
out << ")";
visitChildren = false;
break;
}
case EOpDeclaration: {
// Variable declaration.
if (visit == PreVisit)
{
const TIntermSequence& sequence = node->getSequence();
const TIntermTyped* variable = sequence.front()->getAsTyped();
writeVariableType(variable->getType());
out << " ";
mDeclaringVariables = true;
}
else if (visit == InVisit)
{
out << ", ";
mDeclaringVariables = true;
}
else
{
mDeclaringVariables = false;
}
break;
}
case EOpConstructFloat: writeTriplet(visit, "float(", NULL, ")"); break;
case EOpConstructVec2: writeTriplet(visit, "vec2(", ", ", ")"); break;
case EOpConstructVec3: writeTriplet(visit, "vec3(", ", ", ")"); break;
case EOpConstructVec4: writeTriplet(visit, "vec4(", ", ", ")"); break;
case EOpConstructBool: writeTriplet(visit, "bool(", NULL, ")"); break;
case EOpConstructBVec2: writeTriplet(visit, "bvec2(", ", ", ")"); break;
case EOpConstructBVec3: writeTriplet(visit, "bvec3(", ", ", ")"); break;
case EOpConstructBVec4: writeTriplet(visit, "bvec4(", ", ", ")"); break;
case EOpConstructInt: writeTriplet(visit, "int(", NULL, ")"); break;
case EOpConstructIVec2: writeTriplet(visit, "ivec2(", ", ", ")"); break;
case EOpConstructIVec3: writeTriplet(visit, "ivec3(", ", ", ")"); break;
case EOpConstructIVec4: writeTriplet(visit, "ivec4(", ", ", ")"); break;
case EOpConstructMat2: writeTriplet(visit, "mat2(", ", ", ")"); break;
case EOpConstructMat3: writeTriplet(visit, "mat3(", ", ", ")"); break;
case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break;
case EOpConstructStruct:
if (visit == PreVisit)
{
const TType& type = node->getType();
ASSERT(type.getBasicType() == EbtStruct);
out << type.getTypeName() << "(";
}
else if (visit == InVisit)
{
out << ", ";
}
else
{
out << ")";
}
break;
case EOpLessThan: writeTriplet(visit, "lessThan(", ", ", ")"); break;
case EOpGreaterThan: writeTriplet(visit, "greaterThan(", ", ", ")"); break;
case EOpLessThanEqual: writeTriplet(visit, "lessThanEqual(", ", ", ")"); break;
case EOpGreaterThanEqual: writeTriplet(visit, "greaterThanEqual(", ", ", ")"); break;
case EOpVectorEqual: writeTriplet(visit, "equal(", ", ", ")"); break;
case EOpVectorNotEqual: writeTriplet(visit, "notEqual(", ", ", ")"); break;
case EOpComma: writeTriplet(visit, NULL, ", ", NULL); break;
case EOpMod: writeTriplet(visit, "mod(", ", ", ")"); break;
case EOpPow: writeTriplet(visit, "pow(", ", ", ")"); break;
case EOpAtan: writeTriplet(visit, "atan(", ", ", ")"); break;
case EOpMin: writeTriplet(visit, "min(", ", ", ")"); break;
case EOpMax: writeTriplet(visit, "max(", ", ", ")"); break;
case EOpClamp: writeTriplet(visit, "clamp(", ", ", ")"); break;
case EOpMix: writeTriplet(visit, "mix(", ", ", ")"); break;
case EOpStep: writeTriplet(visit, "step(", ", ", ")"); break;
case EOpSmoothStep: writeTriplet(visit, "smoothstep(", ", ", ")"); break;
case EOpDistance: writeTriplet(visit, "distance(", ", ", ")"); break;
case EOpDot: writeTriplet(visit, "dot(", ", ", ")"); break;
case EOpCross: writeTriplet(visit, "cross(", ", ", ")"); break;
case EOpFaceForward: writeTriplet(visit, "faceforward(", ", ", ")"); break;
case EOpReflect: writeTriplet(visit, "reflect(", ", ", ")"); break;
case EOpRefract: writeTriplet(visit, "refract(", ", ", ")"); break;
case EOpMul: writeTriplet(visit, "matrixCompMult(", ", ", ")"); break;
default: UNREACHABLE(); break;
}
return visitChildren;
}
bool TOutputGLSL::visitLoop(Visit visit, TIntermLoop* node)
{
TInfoSinkBase& out = objSink();
incrementDepth();
// Loop header.
TLoopType loopType = node->getType();
if (loopType == ELoopFor) // for loop
{
if (!node->getUnrollFlag()) {
out << "for (";
if (node->getInit())
node->getInit()->traverse(this);
out << "; ";
if (node->getCondition())
node->getCondition()->traverse(this);
out << "; ";
if (node->getExpression())
node->getExpression()->traverse(this);
out << ")\n";
}
}
else if (loopType == ELoopWhile) // while loop
{
out << "while (";
ASSERT(node->getCondition() != NULL);
node->getCondition()->traverse(this);
out << ")\n";
}
else // do-while loop
{
ASSERT(loopType == ELoopDoWhile);
out << "do\n";
}
// Loop body.
if (node->getUnrollFlag())
{
TLoopIndexInfo indexInfo;
mLoopUnroll.FillLoopIndexInfo(node, indexInfo);
mLoopUnroll.Push(indexInfo);
while (mLoopUnroll.SatisfiesLoopCondition())
{
visitCodeBlock(node->getBody());
mLoopUnroll.Step();
}
mLoopUnroll.Pop();
}
else
{
visitCodeBlock(node->getBody());
}
// Loop footer.
if (loopType == ELoopDoWhile) // do-while loop
{
out << "while (";
ASSERT(node->getCondition() != NULL);
node->getCondition()->traverse(this);
out << ");\n";
}
decrementDepth();
// No need to visit children. They have been already processed in
// this function.
return false;
}
bool TOutputGLSL::visitBranch(Visit visit, TIntermBranch* node)
{
switch (node->getFlowOp())
{
case EOpKill: writeTriplet(visit, "discard", NULL, NULL); break;
case EOpBreak: writeTriplet(visit, "break", NULL, NULL); break;
case EOpContinue: writeTriplet(visit, "continue", NULL, NULL); break;
case EOpReturn: writeTriplet(visit, "return ", NULL, NULL); break;
default: UNREACHABLE(); break;
}
return true;
}
void TOutputGLSL::visitCodeBlock(TIntermNode* node) {
TInfoSinkBase &out = objSink();
if (node != NULL)
{
node->traverse(this);
// Single statements not part of a sequence need to be terminated
// with semi-colon.
if (isSingleStatement(node))
out << ";\n";
}
else
{
out << "{\n}\n"; // Empty code block.
}
}

Просмотреть файл

@ -1,5 +1,5 @@
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// 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.
//
@ -7,46 +7,15 @@
#ifndef CROSSCOMPILERGLSL_OUTPUTGLSL_H_
#define CROSSCOMPILERGLSL_OUTPUTGLSL_H_
#include <set>
#include "compiler/OutputGLSLBase.h"
#include "compiler/ForLoopUnroll.h"
#include "compiler/intermediate.h"
#include "compiler/ParseHelper.h"
class TOutputGLSL : public TIntermTraverser
class TOutputGLSL : public TOutputGLSLBase
{
public:
TOutputGLSL(TInfoSinkBase& objSink);
protected:
TInfoSinkBase& objSink() { return mObjSink; }
void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
void writeVariableType(const TType& type);
void writeFunctionParameters(const TIntermSequence& args);
const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
virtual void visitSymbol(TIntermSymbol* node);
virtual void visitConstantUnion(TIntermConstantUnion* node);
virtual bool visitBinary(Visit visit, TIntermBinary* node);
virtual bool visitUnary(Visit visit, TIntermUnary* node);
virtual bool visitSelection(Visit visit, TIntermSelection* node);
virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
virtual bool visitLoop(Visit visit, TIntermLoop* node);
virtual bool visitBranch(Visit visit, TIntermBranch* node);
void visitCodeBlock(TIntermNode* node);
private:
TInfoSinkBase& mObjSink;
bool mDeclaringVariables;
// Structs are declared as the tree is traversed. This set contains all
// the structs already declared. It is maintained so that a struct is
// declared only once.
typedef std::set<TString> DeclaredStructs;
DeclaredStructs mDeclaredStructs;
ForLoopUnroll mLoopUnroll;
virtual bool writeVariablePrecision(TPrecision);
};
#endif // CROSSCOMPILERGLSL_OUTPUTGLSL_H_

Просмотреть файл

@ -0,0 +1,714 @@
//
// 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/OutputGLSLBase.h"
#include "compiler/compilerdebug.h"
namespace
{
TString getTypeName(const TType& type)
{
TInfoSinkBase out;
if (type.isMatrix())
{
out << "mat";
out << type.getNominalSize();
}
else if (type.isVector())
{
switch (type.getBasicType())
{
case EbtFloat: out << "vec"; break;
case EbtInt: out << "ivec"; break;
case EbtBool: out << "bvec"; break;
default: UNREACHABLE(); break;
}
out << type.getNominalSize();
}
else
{
if (type.getBasicType() == EbtStruct)
out << type.getTypeName();
else
out << type.getBasicString();
}
return TString(out.c_str());
}
TString arrayBrackets(const TType& type)
{
ASSERT(type.isArray());
TInfoSinkBase out;
out << "[" << type.getArraySize() << "]";
return TString(out.c_str());
}
bool isSingleStatement(TIntermNode* node) {
if (const TIntermAggregate* aggregate = node->getAsAggregate())
{
return (aggregate->getOp() != EOpFunction) &&
(aggregate->getOp() != EOpSequence);
}
else if (const TIntermSelection* selection = node->getAsSelectionNode())
{
// Ternary operators are usually part of an assignment operator.
// This handles those rare cases in which they are all by themselves.
return selection->usesTernaryOperator();
}
else if (node->getAsLoopNode())
{
return false;
}
return true;
}
} // namespace
TOutputGLSLBase::TOutputGLSLBase(TInfoSinkBase& objSink)
: TIntermTraverser(true, true, true),
mObjSink(objSink),
mDeclaringVariables(false)
{
}
void TOutputGLSLBase::writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr)
{
TInfoSinkBase& out = objSink();
if (visit == PreVisit && preStr)
{
out << preStr;
}
else if (visit == InVisit && inStr)
{
out << inStr;
}
else if (visit == PostVisit && postStr)
{
out << postStr;
}
}
void TOutputGLSLBase::writeVariableType(const TType& type)
{
TInfoSinkBase& out = objSink();
TQualifier qualifier = type.getQualifier();
// TODO(alokp): Validate qualifier for variable declarations.
if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
out << type.getQualifierString() << " ";
// Declare the struct if we have not done so already.
if ((type.getBasicType() == EbtStruct) &&
(mDeclaredStructs.find(type.getTypeName()) == mDeclaredStructs.end()))
{
out << "struct " << type.getTypeName() << "{\n";
const TTypeList* structure = type.getStruct();
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
const TType* fieldType = (*structure)[i].type;
ASSERT(fieldType != NULL);
if (writeVariablePrecision(fieldType->getPrecision()))
out << " ";
out << getTypeName(*fieldType) << " " << fieldType->getFieldName();
if (fieldType->isArray())
out << arrayBrackets(*fieldType);
out << ";\n";
}
out << "}";
mDeclaredStructs.insert(type.getTypeName());
}
else
{
if (writeVariablePrecision(type.getPrecision()))
out << " ";
out << getTypeName(type);
}
}
void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence& args)
{
TInfoSinkBase& out = objSink();
for (TIntermSequence::const_iterator iter = args.begin();
iter != args.end(); ++iter)
{
const TIntermSymbol* arg = (*iter)->getAsSymbolNode();
ASSERT(arg != NULL);
const TType& type = arg->getType();
writeVariableType(type);
const TString& name = arg->getSymbol();
if (!name.empty())
out << " " << name;
if (type.isArray())
out << arrayBrackets(type);
// Put a comma if this is not the last argument.
if (iter != args.end() - 1)
out << ", ";
}
}
const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
const ConstantUnion* pConstUnion)
{
TInfoSinkBase& out = objSink();
if (type.getBasicType() == EbtStruct)
{
out << type.getTypeName() << "(";
const TTypeList* structure = type.getStruct();
ASSERT(structure != NULL);
for (size_t i = 0; i < structure->size(); ++i)
{
const TType* fieldType = (*structure)[i].type;
ASSERT(fieldType != NULL);
pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
if (i != structure->size() - 1) out << ", ";
}
out << ")";
}
else
{
int size = type.getObjectSize();
bool writeType = size > 1;
if (writeType) out << getTypeName(type) << "(";
for (int i = 0; i < size; ++i, ++pConstUnion)
{
switch (pConstUnion->getType())
{
case EbtFloat: out << pConstUnion->getFConst(); break;
case EbtInt: out << pConstUnion->getIConst(); break;
case EbtBool: out << pConstUnion->getBConst(); break;
default: UNREACHABLE();
}
if (i != size - 1) out << ", ";
}
if (writeType) out << ")";
}
return pConstUnion;
}
void TOutputGLSLBase::visitSymbol(TIntermSymbol* node)
{
TInfoSinkBase& out = objSink();
if (mLoopUnroll.NeedsToReplaceSymbolWithValue(node))
out << mLoopUnroll.GetLoopIndexValue(node);
else
out << node->getSymbol();
if (mDeclaringVariables && node->getType().isArray())
out << arrayBrackets(node->getType());
}
void TOutputGLSLBase::visitConstantUnion(TIntermConstantUnion* node)
{
writeConstantUnion(node->getType(), node->getUnionArrayPointer());
}
bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break;
case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break;
case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break;
case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpIndexDirect:
case EOpIndexIndirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
out << ".";
// TODO(alokp): ASSERT
out << node->getType().getFieldName();
visitChildren = false;
}
break;
case EOpVectorSwizzle:
if (visit == InVisit)
{
out << ".";
TIntermAggregate* rightChild = node->getRight()->getAsAggregate();
TIntermSequence& sequence = rightChild->getSequence();
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
{
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1);
const ConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt);
switch (data.getIConst())
{
case 0: out << "x"; break;
case 1: out << "y"; break;
case 2: out << "z"; break;
case 3: out << "w"; break;
default: UNREACHABLE(); break;
}
}
visitChildren = false;
}
break;
case EOpAdd: writeTriplet(visit, "(", " + ", ")"); break;
case EOpSub: writeTriplet(visit, "(", " - ", ")"); break;
case EOpMul: writeTriplet(visit, "(", " * ", ")"); break;
case EOpDiv: writeTriplet(visit, "(", " / ", ")"); break;
case EOpMod: UNIMPLEMENTED(); break;
case EOpEqual: writeTriplet(visit, "(", " == ", ")"); break;
case EOpNotEqual: writeTriplet(visit, "(", " != ", ")"); break;
case EOpLessThan: writeTriplet(visit, "(", " < ", ")"); break;
case EOpGreaterThan: writeTriplet(visit, "(", " > ", ")"); break;
case EOpLessThanEqual: writeTriplet(visit, "(", " <= ", ")"); break;
case EOpGreaterThanEqual: writeTriplet(visit, "(", " >= ", ")"); break;
// Notice the fall-through.
case EOpVectorTimesScalar:
case EOpVectorTimesMatrix:
case EOpMatrixTimesVector:
case EOpMatrixTimesScalar:
case EOpMatrixTimesMatrix:
writeTriplet(visit, "(", " * ", ")");
break;
case EOpLogicalOr: writeTriplet(visit, "(", " || ", ")"); break;
case EOpLogicalXor: writeTriplet(visit, "(", " ^^ ", ")"); break;
case EOpLogicalAnd: writeTriplet(visit, "(", " && ", ")"); break;
default: UNREACHABLE(); break;
}
return visitChildren;
}
bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary* node)
{
TString preString;
TString postString = ")";
switch (node->getOp())
{
case EOpNegative: preString = "(-"; break;
case EOpVectorLogicalNot: preString = "not("; break;
case EOpLogicalNot: preString = "(!"; break;
case EOpPostIncrement: preString = "("; postString = "++)"; break;
case EOpPostDecrement: preString = "("; postString = "--)"; break;
case EOpPreIncrement: preString = "(++"; break;
case EOpPreDecrement: preString = "(--"; break;
case EOpConvIntToBool:
case EOpConvFloatToBool:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: preString = "bool("; break;
case 2: preString = "bvec2("; break;
case 3: preString = "bvec3("; break;
case 4: preString = "bvec4("; break;
default: UNREACHABLE();
}
break;
case EOpConvBoolToFloat:
case EOpConvIntToFloat:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: preString = "float("; break;
case 2: preString = "vec2("; break;
case 3: preString = "vec3("; break;
case 4: preString = "vec4("; break;
default: UNREACHABLE();
}
break;
case EOpConvFloatToInt:
case EOpConvBoolToInt:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: preString = "int("; break;
case 2: preString = "ivec2("; break;
case 3: preString = "ivec3("; break;
case 4: preString = "ivec4("; break;
default: UNREACHABLE();
}
break;
case EOpRadians: preString = "radians("; break;
case EOpDegrees: preString = "degrees("; break;
case EOpSin: preString = "sin("; break;
case EOpCos: preString = "cos("; break;
case EOpTan: preString = "tan("; break;
case EOpAsin: preString = "asin("; break;
case EOpAcos: preString = "acos("; break;
case EOpAtan: preString = "atan("; break;
case EOpExp: preString = "exp("; break;
case EOpLog: preString = "log("; break;
case EOpExp2: preString = "exp2("; break;
case EOpLog2: preString = "log2("; break;
case EOpSqrt: preString = "sqrt("; break;
case EOpInverseSqrt: preString = "inversesqrt("; break;
case EOpAbs: preString = "abs("; break;
case EOpSign: preString = "sign("; break;
case EOpFloor: preString = "floor("; break;
case EOpCeil: preString = "ceil("; break;
case EOpFract: preString = "fract("; break;
case EOpLength: preString = "length("; break;
case EOpNormalize: preString = "normalize("; break;
case EOpDFdx: preString = "dFdx("; break;
case EOpDFdy: preString = "dFdy("; break;
case EOpFwidth: preString = "fwidth("; break;
case EOpAny: preString = "any("; break;
case EOpAll: preString = "all("; break;
default: UNREACHABLE(); break;
}
if (visit == PreVisit && node->getUseEmulatedFunction())
preString = BuiltInFunctionEmulator::GetEmulatedFunctionName(preString);
writeTriplet(visit, preString.c_str(), NULL, postString.c_str());
return true;
}
bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection* node)
{
TInfoSinkBase& out = objSink();
if (node->usesTernaryOperator())
{
// Notice two brackets at the beginning and end. The outer ones
// encapsulate the whole ternary expression. This preserves the
// order of precedence when ternary expressions are used in a
// compound expression, i.e., c = 2 * (a < b ? 1 : 2).
out << "((";
node->getCondition()->traverse(this);
out << ") ? (";
node->getTrueBlock()->traverse(this);
out << ") : (";
node->getFalseBlock()->traverse(this);
out << "))";
}
else
{
out << "if (";
node->getCondition()->traverse(this);
out << ")\n";
incrementDepth();
visitCodeBlock(node->getTrueBlock());
if (node->getFalseBlock())
{
out << "else\n";
visitCodeBlock(node->getFalseBlock());
}
decrementDepth();
}
return false;
}
bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpSequence: {
// Scope the sequences except when at the global scope.
if (depth > 0) out << "{\n";
incrementDepth();
const TIntermSequence& sequence = node->getSequence();
for (TIntermSequence::const_iterator iter = sequence.begin();
iter != sequence.end(); ++iter)
{
TIntermNode* node = *iter;
ASSERT(node != NULL);
node->traverse(this);
if (isSingleStatement(node))
out << ";\n";
}
decrementDepth();
// Scope the sequences except when at the global scope.
if (depth > 0) out << "}\n";
visitChildren = false;
break;
}
case EOpPrototype: {
// Function declaration.
ASSERT(visit == PreVisit);
writeVariableType(node->getType());
out << " " << node->getName();
out << "(";
writeFunctionParameters(node->getSequence());
out << ")";
visitChildren = false;
break;
}
case EOpFunction: {
// Function definition.
ASSERT(visit == PreVisit);
writeVariableType(node->getType());
out << " " << TFunction::unmangleName(node->getName());
incrementDepth();
// Function definition node contains one or two children nodes
// representing function parameters and function body. The latter
// is not present in case of empty function bodies.
const TIntermSequence& sequence = node->getSequence();
ASSERT((sequence.size() == 1) || (sequence.size() == 2));
TIntermSequence::const_iterator seqIter = sequence.begin();
// Traverse function parameters.
TIntermAggregate* params = (*seqIter)->getAsAggregate();
ASSERT(params != NULL);
ASSERT(params->getOp() == EOpParameters);
params->traverse(this);
// Traverse function body.
TIntermAggregate* body = ++seqIter != sequence.end() ?
(*seqIter)->getAsAggregate() : NULL;
visitCodeBlock(body);
decrementDepth();
// Fully processed; no need to visit children.
visitChildren = false;
break;
}
case EOpFunctionCall:
// Function call.
if (visit == PreVisit)
{
TString functionName = TFunction::unmangleName(node->getName());
out << functionName << "(";
}
else if (visit == InVisit)
{
out << ", ";
}
else
{
out << ")";
}
break;
case EOpParameters: {
// Function parameters.
ASSERT(visit == PreVisit);
out << "(";
writeFunctionParameters(node->getSequence());
out << ")";
visitChildren = false;
break;
}
case EOpDeclaration: {
// Variable declaration.
if (visit == PreVisit)
{
const TIntermSequence& sequence = node->getSequence();
const TIntermTyped* variable = sequence.front()->getAsTyped();
writeVariableType(variable->getType());
out << " ";
mDeclaringVariables = true;
}
else if (visit == InVisit)
{
out << ", ";
mDeclaringVariables = true;
}
else
{
mDeclaringVariables = false;
}
break;
}
case EOpConstructFloat: writeTriplet(visit, "float(", NULL, ")"); break;
case EOpConstructVec2: writeTriplet(visit, "vec2(", ", ", ")"); break;
case EOpConstructVec3: writeTriplet(visit, "vec3(", ", ", ")"); break;
case EOpConstructVec4: writeTriplet(visit, "vec4(", ", ", ")"); break;
case EOpConstructBool: writeTriplet(visit, "bool(", NULL, ")"); break;
case EOpConstructBVec2: writeTriplet(visit, "bvec2(", ", ", ")"); break;
case EOpConstructBVec3: writeTriplet(visit, "bvec3(", ", ", ")"); break;
case EOpConstructBVec4: writeTriplet(visit, "bvec4(", ", ", ")"); break;
case EOpConstructInt: writeTriplet(visit, "int(", NULL, ")"); break;
case EOpConstructIVec2: writeTriplet(visit, "ivec2(", ", ", ")"); break;
case EOpConstructIVec3: writeTriplet(visit, "ivec3(", ", ", ")"); break;
case EOpConstructIVec4: writeTriplet(visit, "ivec4(", ", ", ")"); break;
case EOpConstructMat2: writeTriplet(visit, "mat2(", ", ", ")"); break;
case EOpConstructMat3: writeTriplet(visit, "mat3(", ", ", ")"); break;
case EOpConstructMat4: writeTriplet(visit, "mat4(", ", ", ")"); break;
case EOpConstructStruct:
if (visit == PreVisit)
{
const TType& type = node->getType();
ASSERT(type.getBasicType() == EbtStruct);
out << type.getTypeName() << "(";
}
else if (visit == InVisit)
{
out << ", ";
}
else
{
out << ")";
}
break;
case EOpLessThan: writeTriplet(visit, "lessThan(", ", ", ")"); break;
case EOpGreaterThan: writeTriplet(visit, "greaterThan(", ", ", ")"); break;
case EOpLessThanEqual: writeTriplet(visit, "lessThanEqual(", ", ", ")"); break;
case EOpGreaterThanEqual: writeTriplet(visit, "greaterThanEqual(", ", ", ")"); break;
case EOpVectorEqual: writeTriplet(visit, "equal(", ", ", ")"); break;
case EOpVectorNotEqual: writeTriplet(visit, "notEqual(", ", ", ")"); break;
case EOpComma: writeTriplet(visit, NULL, ", ", NULL); break;
case EOpMod: writeTriplet(visit, "mod(", ", ", ")"); break;
case EOpPow: writeTriplet(visit, "pow(", ", ", ")"); break;
case EOpAtan: writeTriplet(visit, "atan(", ", ", ")"); break;
case EOpMin: writeTriplet(visit, "min(", ", ", ")"); break;
case EOpMax: writeTriplet(visit, "max(", ", ", ")"); break;
case EOpClamp: writeTriplet(visit, "clamp(", ", ", ")"); break;
case EOpMix: writeTriplet(visit, "mix(", ", ", ")"); break;
case EOpStep: writeTriplet(visit, "step(", ", ", ")"); break;
case EOpSmoothStep: writeTriplet(visit, "smoothstep(", ", ", ")"); break;
case EOpDistance: writeTriplet(visit, "distance(", ", ", ")"); break;
case EOpDot: writeTriplet(visit, "dot(", ", ", ")"); break;
case EOpCross: writeTriplet(visit, "cross(", ", ", ")"); break;
case EOpFaceForward: writeTriplet(visit, "faceforward(", ", ", ")"); break;
case EOpReflect: writeTriplet(visit, "reflect(", ", ", ")"); break;
case EOpRefract: writeTriplet(visit, "refract(", ", ", ")"); break;
case EOpMul: writeTriplet(visit, "matrixCompMult(", ", ", ")"); break;
default: UNREACHABLE(); break;
}
return visitChildren;
}
bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node)
{
TInfoSinkBase& out = objSink();
incrementDepth();
// Loop header.
TLoopType loopType = node->getType();
if (loopType == ELoopFor) // for loop
{
if (!node->getUnrollFlag()) {
out << "for (";
if (node->getInit())
node->getInit()->traverse(this);
out << "; ";
if (node->getCondition())
node->getCondition()->traverse(this);
out << "; ";
if (node->getExpression())
node->getExpression()->traverse(this);
out << ")\n";
}
}
else if (loopType == ELoopWhile) // while loop
{
out << "while (";
ASSERT(node->getCondition() != NULL);
node->getCondition()->traverse(this);
out << ")\n";
}
else // do-while loop
{
ASSERT(loopType == ELoopDoWhile);
out << "do\n";
}
// Loop body.
if (node->getUnrollFlag())
{
TLoopIndexInfo indexInfo;
mLoopUnroll.FillLoopIndexInfo(node, indexInfo);
mLoopUnroll.Push(indexInfo);
while (mLoopUnroll.SatisfiesLoopCondition())
{
visitCodeBlock(node->getBody());
mLoopUnroll.Step();
}
mLoopUnroll.Pop();
}
else
{
visitCodeBlock(node->getBody());
}
// Loop footer.
if (loopType == ELoopDoWhile) // do-while loop
{
out << "while (";
ASSERT(node->getCondition() != NULL);
node->getCondition()->traverse(this);
out << ");\n";
}
decrementDepth();
// No need to visit children. They have been already processed in
// this function.
return false;
}
bool TOutputGLSLBase::visitBranch(Visit visit, TIntermBranch* node)
{
switch (node->getFlowOp())
{
case EOpKill: writeTriplet(visit, "discard", NULL, NULL); break;
case EOpBreak: writeTriplet(visit, "break", NULL, NULL); break;
case EOpContinue: writeTriplet(visit, "continue", NULL, NULL); break;
case EOpReturn: writeTriplet(visit, "return ", NULL, NULL); break;
default: UNREACHABLE(); break;
}
return true;
}
void TOutputGLSLBase::visitCodeBlock(TIntermNode* node) {
TInfoSinkBase &out = objSink();
if (node != NULL)
{
node->traverse(this);
// Single statements not part of a sequence need to be terminated
// with semi-colon.
if (isSingleStatement(node))
out << ";\n";
}
else
{
out << "{\n}\n"; // Empty code block.
}
}

Просмотреть файл

@ -0,0 +1,53 @@
//
// 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 CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
#define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
#include <set>
#include "compiler/ForLoopUnroll.h"
#include "compiler/intermediate.h"
#include "compiler/ParseHelper.h"
class TOutputGLSLBase : public TIntermTraverser
{
public:
TOutputGLSLBase(TInfoSinkBase& objSink);
protected:
TInfoSinkBase& objSink() { return mObjSink; }
void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
void writeVariableType(const TType& type);
virtual bool writeVariablePrecision(TPrecision precision) = 0;
void writeFunctionParameters(const TIntermSequence& args);
const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
virtual void visitSymbol(TIntermSymbol* node);
virtual void visitConstantUnion(TIntermConstantUnion* node);
virtual bool visitBinary(Visit visit, TIntermBinary* node);
virtual bool visitUnary(Visit visit, TIntermUnary* node);
virtual bool visitSelection(Visit visit, TIntermSelection* node);
virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
virtual bool visitLoop(Visit visit, TIntermLoop* node);
virtual bool visitBranch(Visit visit, TIntermBranch* node);
void visitCodeBlock(TIntermNode* node);
private:
TInfoSinkBase& mObjSink;
bool mDeclaringVariables;
// Structs are declared as the tree is traversed. This set contains all
// the structs already declared. It is maintained so that a struct is
// declared only once.
typedef std::set<TString> DeclaredStructs;
DeclaredStructs mDeclaredStructs;
ForLoopUnroll mLoopUnroll;
};
#endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_

Просмотреть файл

@ -196,7 +196,6 @@ bool TParseContext::parseMatrixFields(const TString& compString, int matSize, TM
//
void TParseContext::recover()
{
recoveredFromError = true;
}
//
@ -261,6 +260,8 @@ void TParseContext::binaryOpError(int line, const char* op, TString left, TStrin
}
bool TParseContext::precisionErrorCheck(int line, TPrecision precision, TBasicType type){
if (!checksPrecisionErrors)
return false;
switch( type ){
case EbtFloat:
if( precision == EbpUndefined ){
@ -941,6 +942,12 @@ bool TParseContext::extensionErrorCheck(int line, const TString& extension)
return false;
}
bool TParseContext::supportsExtension(const char* extension)
{
TExtensionBehavior::const_iterator iter = extensionBehavior.find(extension);
return (iter != extensionBehavior.end());
}
/////////////////////////////////////////////////////////////////////////////////
//
// Non-Errors.

Просмотреть файл

@ -30,36 +30,41 @@ struct TPragma {
// they can be passed to the parser without needing a global.
//
struct TParseContext {
TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, const char* sourcePath, TInfoSink& is) :
intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), sourcePath(sourcePath), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), scanner(NULL), contextPragma(true, false) { }
TParseContext(TSymbolTable& symt, TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, int options, bool checksPrecErrors, const char* sourcePath, TInfoSink& is) :
intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), compileOptions(options), checksPrecisionErrors(checksPrecErrors), sourcePath(sourcePath), treeRoot(0),
numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), contextPragma(true, false), scanner(NULL) { }
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
TExtensionBehavior extensionBehavior; // mapping between supported extensions and current behavior.
TExtensionBehavior& extensionBehavior; // mapping between supported extensions and current behavior.
TInfoSink& infoSink;
ShShaderType shaderType; // vertex or fragment language (future: pack or unpack)
ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
int compileOptions;
const char* sourcePath; // Path of source file or NULL.
TIntermNode* treeRoot; // root of parse tree being created
bool recoveredFromError; // true if a parse error has occurred, but we continue to parse
int numErrors;
bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
int loopNestingLevel; // 0 if outside all loops
bool inTypeParen; // true if in parentheses, looking only for an identifier
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
struct TPragma contextPragma;
TString HashErrMsg;
bool AfterEOF;
void* scanner;
void error(TSourceLoc loc, const char *reason, const char* token,
const char* extraInfoFormat, ...);
void warning(TSourceLoc loc, const char* reason, const char* token,
const char* extraInfoFormat, ...);
bool reservedErrorCheck(int line, const TString& identifier);
void recover();
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);
bool reservedErrorCheck(int line, const TString& identifier);
void assignError(int line, const char* op, TString left, TString right);
void unaryOpError(int line, const char* op, TString operand);
void binaryOpError(int line, const char* op, TString left, TString right);
@ -79,15 +84,19 @@ struct TParseContext {
bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
bool structQualifierErrorCheck(int line, const TPublicType& pType);
bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
bool containsSampler(TType& type);
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type, TVariable*& variable);
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
bool extensionErrorCheck(int line, const TString&);
bool supportsExtension(const char* extension);
bool containsSampler(TType& type);
bool areAllChildConst(TIntermAggregate* aggrNode);
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
bool areAllChildConst(TIntermAggregate* aggrNode);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc);
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
@ -96,11 +105,6 @@ struct TParseContext {
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
void* scanner;
struct TPragma contextPragma;
TString HashErrMsg;
bool AfterEOF;
};
int PaParseStrings(int count, const char* const string[], const int length[],

Просмотреть файл

@ -16,6 +16,7 @@
#include "GLSLANG/ShaderLang.h"
#include "compiler/BuiltInFunctionEmulator.h"
#include "compiler/ExtensionBehavior.h"
#include "compiler/InfoSink.h"
#include "compiler/SymbolTable.h"
@ -77,6 +78,10 @@ protected:
void mapLongVariableNames(TIntermNode* root);
// Translate to object code.
virtual void translate(TIntermNode* root) = 0;
// Get built-in extensions with default behavior.
const TExtensionBehavior& getExtensionBehavior() const;
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
private:
ShShaderType shaderType;
@ -88,6 +93,8 @@ private:
// Built-in extensions with default behavior.
TExtensionBehavior extensionBehavior;
BuiltInFunctionEmulator builtInFunctionEmulator;
// Results of compilation.
TInfoSink infoSink; // Output sink.
TVariableInfoList attribs; // Active attributes in the compiled shader.
@ -106,7 +113,8 @@ private:
// destroy the machine dependent objects, which contain the
// above machine independent information.
//
TCompiler* ConstructCompiler(ShShaderType type, ShShaderSpec spec);
TCompiler* ConstructCompiler(
ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
void DeleteCompiler(TCompiler*);
#endif // _SHHANDLE_INCLUDED_

Просмотреть файл

@ -104,18 +104,20 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
// Extensions.
resources->OES_standard_derivatives = 0;
resources->OES_EGL_image_external = 0;
}
//
// Driver calls these to create and destroy compiler objects.
//
ShHandle ShConstructCompiler(ShShaderType type, ShShaderSpec spec,
ShShaderOutput output,
const ShBuiltInResources* resources)
{
if (!InitThread())
return 0;
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec));
TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output));
TCompiler* compiler = base->getAsCompiler();
if (compiler == 0)
return 0;

Просмотреть файл

@ -0,0 +1,40 @@
//
// 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/TranslatorESSL.h"
#include "compiler/OutputESSL.h"
TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
: TCompiler(type, spec) {
}
void TranslatorESSL::translate(TIntermNode* root) {
TInfoSinkBase& sink = getInfoSink().obj;
// Write built-in extension behaviors.
writeExtensionBehavior();
// Write emulated built-in functions if needed.
getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
sink, getShaderType() == SH_FRAGMENT_SHADER);
// Write translated shader.
TOutputESSL outputESSL(sink);
root->traverse(&outputESSL);
}
void TranslatorESSL::writeExtensionBehavior() {
TInfoSinkBase& sink = getInfoSink().obj;
const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
iter != extensionBehavior.end(); ++iter) {
if (iter->second != EBhUndefined) {
sink << "#extension " << iter->first << " : "
<< getBehaviorString(iter->second) << "\n";
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
//
// 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_TRANSLATORESSL_H_
#define COMPILER_TRANSLATORESSL_H_
#include "compiler/ShHandle.h"
class TranslatorESSL : public TCompiler {
public:
TranslatorESSL(ShShaderType type, ShShaderSpec spec);
protected:
virtual void translate(TIntermNode* root);
private:
void writeExtensionBehavior();
};
#endif // COMPILER_TRANSLATORESSL_H_

Просмотреть файл

@ -31,6 +31,10 @@ void TranslatorGLSL::translate(TIntermNode* root) {
// Write GLSL version.
writeVersion(getShaderType(), root, sink);
// Write emulated built-in functions if needed.
getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
sink, false);
// Write translated shader.
TOutputGLSL outputGLSL(sink);
root->traverse(&outputGLSL);

Просмотреть файл

@ -53,13 +53,6 @@ public:
IsLoopIndex(symbol, mLoopStack);
}
}
virtual void visitConstantUnion(TIntermConstantUnion*) {}
virtual bool visitBinary(Visit, TIntermBinary*) { return true; }
virtual bool visitUnary(Visit, TIntermUnary*) { return true; }
virtual bool visitSelection(Visit, TIntermSelection*) { return true; }
virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; }
virtual bool visitLoop(Visit, TIntermLoop*) { return true; }
virtual bool visitBranch(Visit, TIntermBranch*) { return true; }
private:
bool mValid;
@ -94,13 +87,6 @@ public:
}
}
}
virtual void visitConstantUnion(TIntermConstantUnion*) {}
virtual bool visitBinary(Visit, TIntermBinary*) { return true; }
virtual bool visitUnary(Visit, TIntermUnary*) { return true; }
virtual bool visitSelection(Visit, TIntermSelection*) { return true; }
virtual bool visitAggregate(Visit, TIntermAggregate*) { return true; }
virtual bool visitLoop(Visit, TIntermLoop*) { return true; }
virtual bool visitBranch(Visit, TIntermBranch*) { return true; }
private:
bool mUsesFloatLoopIndex;
@ -117,14 +103,6 @@ ValidateLimitations::ValidateLimitations(ShShaderType shaderType,
{
}
void ValidateLimitations::visitSymbol(TIntermSymbol*)
{
}
void ValidateLimitations::visitConstantUnion(TIntermConstantUnion*)
{
}
bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node)
{
// Check if loop index is modified in the loop body.
@ -170,11 +148,6 @@ bool ValidateLimitations::visitUnary(Visit, TIntermUnary* node)
return true;
}
bool ValidateLimitations::visitSelection(Visit, TIntermSelection*)
{
return true;
}
bool ValidateLimitations::visitAggregate(Visit, TIntermAggregate* node)
{
switch (node->getOp()) {
@ -209,11 +182,6 @@ bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node)
return false;
}
bool ValidateLimitations::visitBranch(Visit, TIntermBranch*)
{
return true;
}
void ValidateLimitations::error(TSourceLoc loc,
const char *reason, const char* token)
{

Просмотреть файл

@ -25,14 +25,10 @@ public:
int numErrors() const { return mNumErrors; }
virtual void visitSymbol(TIntermSymbol*);
virtual void visitConstantUnion(TIntermConstantUnion*);
virtual bool visitBinary(Visit, TIntermBinary*);
virtual bool visitUnary(Visit, TIntermUnary*);
virtual bool visitSelection(Visit, TIntermSelection*);
virtual bool visitAggregate(Visit, TIntermAggregate*);
virtual bool visitLoop(Visit, TIntermLoop*);
virtual bool visitBranch(Visit, TIntermBranch*);
private:
void error(TSourceLoc loc, const char *reason, const char* token);

Просмотреть файл

@ -1,11 +0,0 @@
#!/bin/bash
# Copyright (c) 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.
# Generates GLSL ES lexer - glslang_lex.cpp
script_dir=$(dirname $0)
input_file=$script_dir/glslang.l
output_file=$script_dir/glslang_lex.cpp
flex --noline --nounistd --outfile=$output_file $input_file

Просмотреть файл

@ -1,12 +0,0 @@
#!/bin/bash
# Copyright (c) 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.
# Generates GLSL ES parser - glslang_tab.h and glslang_tab.cpp
script_dir=$(dirname $0)
input_file=$script_dir/glslang.y
output_header=$script_dir/glslang_tab.h
output_source=$script_dir/glslang_tab.cpp
bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file

Просмотреть файл

@ -0,0 +1,27 @@
#!/bin/bash
# Copyright (c) 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.
# Generates GLSL ES parser - glslang_lex.cpp, glslang_tab.h, and glslang_tab.cpp
run_flex()
{
input_file=$script_dir/$1.l
output_source=$script_dir/$1_lex.cpp
flex --noline --nounistd --outfile=$output_source $input_file
}
run_bison()
{
input_file=$script_dir/$1.y
output_header=$script_dir/$1_tab.h
output_source=$script_dir/$1_tab.cpp
bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file
}
script_dir=$(dirname $0)
# Generate Parser
run_flex glslang
run_bison glslang

Просмотреть файл

@ -9,7 +9,7 @@ This file contains the Lex specification for GLSL ES.
Based on ANSI C grammar, Lex specification:
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
*/
@ -20,7 +20,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
// found in the LICENSE file.
//
// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
}
%{
@ -120,6 +120,7 @@ O [0-7]
"sampler2D" { context->lexAfterType = true; return SAMPLER2D; }
"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; }
"samplerExternalOES" { context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; }
"struct" { context->lexAfterType = true; return(STRUCT); }

Просмотреть файл

@ -9,7 +9,7 @@ This file contains the Yacc grammar for GLSL ES.
Based on ANSI C Yacc grammar:
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_parser.sh,
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
*/
@ -20,7 +20,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
// found in the LICENSE file.
//
// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT!
// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
#include "compiler/SymbolTable.h"
#include "compiler/ParseHelper.h"
@ -98,7 +98,7 @@ extern void yyerror(TParseContext* context, const char* reason);
%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
%token <lex> STRUCT VOID_TYPE WHILE
%token <lex> SAMPLER2D SAMPLERCUBE
%token <lex> SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES
%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT
%token <lex> FIELD_SELECTION
@ -591,17 +591,10 @@ function_call_header
// Grammar Note: Constructors look like functions, but are recognized as types.
function_identifier
: type_specifier {
: type_specifier_nonarray {
//
// Constructor
//
if ($1.array) {
// Constructors for arrays are not allowed.
context->error($1.line, "cannot construct this type", "array", "");
context->recover();
$1.setArray(false);
}
TOperator op = EOpNull;
if ($1.userDef) {
op = EOpConstructStruct;
@ -1176,13 +1169,6 @@ parameter_type_specifier
init_declarator_list
: single_declaration {
$$ = $1;
if ($$.type.precision == EbpUndefined) {
$$.type.precision = context->symbolTable.getDefaultPrecision($1.type.type);
if (context->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) {
context->recover();
}
}
}
| init_declarator_list COMMA IDENTIFIER {
TIntermSymbol* symbol = context->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line);
@ -1490,6 +1476,13 @@ type_qualifier
type_specifier
: type_specifier_no_prec {
$$ = $1;
if ($$.precision == EbpUndefined) {
$$.precision = context->symbolTable.getDefaultPrecision($1.type);
if (context->precisionErrorCheck($1.line, $$.precision, $1.type)) {
context->recover();
}
}
}
| precision_qualifier type_specifier_no_prec {
$$ = $2;
@ -1622,6 +1615,15 @@ type_specifier_nonarray
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerCube, qual, $1.line);
}
| SAMPLER_EXTERNAL_OES {
if (!context->supportsExtension("GL_OES_EGL_image_external")) {
context->error($1.line, "unsupported type", "samplerExternalOES", "");
context->recover();
}
FRAG_VERT_ONLY("samplerExternalOES", $1.line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerExternalOES, qual, $1.line);
}
| struct_specifier {
FRAG_VERT_ONLY("struct", $1.line);
$$ = $1;
@ -1693,6 +1695,7 @@ struct_declaration
type->setBasicType($1.type);
type->setNominalSize($1.size);
type->setMatrix($1.matrix);
type->setPrecision($1.precision);
// don't allow arrays of arrays
if (type->isArray()) {

Просмотреть файл

@ -5,7 +5,7 @@
// found in the LICENSE file.
//
// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
@ -371,8 +371,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 145
#define YY_END_OF_BUFFER 146
#define YY_NUM_RULES 146
#define YY_END_OF_BUFFER 147
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@ -380,53 +380,55 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[411] =
static yyconst flex_int16_t yy_accept[422] =
{ 0,
0, 0, 0, 0, 0, 0, 146, 144, 143, 143,
128, 134, 139, 123, 124, 132, 131, 120, 129, 127,
133, 92, 92, 121, 117, 135, 122, 136, 140, 88,
125, 126, 138, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 118, 137, 119, 130, 3, 4, 3,
142, 145, 141, 114, 100, 119, 108, 103, 98, 106,
96, 107, 97, 95, 2, 1, 99, 94, 90, 91,
0, 0, 92, 126, 118, 125, 115, 111, 113, 112,
116, 88, 104, 110, 88, 88, 88, 88, 88, 88,
0, 0, 0, 0, 0, 0, 147, 145, 144, 144,
129, 135, 140, 124, 125, 133, 132, 121, 130, 128,
134, 93, 93, 122, 118, 136, 123, 137, 141, 89,
126, 127, 139, 89, 89, 89, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
89, 89, 89, 119, 138, 120, 131, 3, 4, 3,
143, 146, 142, 115, 101, 120, 109, 104, 99, 107,
97, 108, 98, 96, 2, 1, 100, 95, 91, 92,
0, 0, 93, 127, 119, 126, 116, 112, 114, 113,
117, 89, 105, 111, 89, 89, 89, 89, 89, 89,
88, 88, 88, 88, 17, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 20, 22,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 105, 109, 5, 141,
0, 1, 94, 0, 0, 93, 89, 101, 102, 48,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 18, 88, 88,
88, 88, 88, 88, 88, 88, 26, 88, 88, 88,
88, 88, 88, 88, 88, 23, 88, 88, 88, 88,
89, 89, 89, 89, 17, 89, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 89, 89, 20, 22,
89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 106, 110, 5, 142,
0, 1, 95, 0, 0, 94, 90, 102, 103, 49,
89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 89, 18, 89, 89,
89, 89, 89, 89, 89, 89, 26, 89, 89, 89,
89, 89, 89, 89, 89, 23, 89, 89, 89, 89,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 0, 95,
0, 94, 88, 28, 88, 88, 85, 88, 88, 88,
88, 88, 88, 88, 21, 51, 88, 88, 88, 88,
88, 56, 70, 88, 88, 88, 88, 88, 88, 88,
88, 67, 9, 33, 34, 35, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 54, 29, 88, 88, 88, 88, 88, 88, 36,
37, 38, 27, 88, 88, 88, 15, 42, 43, 44,
49, 12, 88, 88, 88, 88, 81, 82, 83, 88,
89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 89, 89, 0, 96,
0, 95, 89, 28, 89, 89, 86, 89, 89, 89,
89, 89, 89, 89, 21, 52, 89, 89, 89, 89,
89, 57, 71, 89, 89, 89, 89, 89, 89, 89,
89, 68, 9, 33, 34, 35, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
89, 55, 29, 89, 89, 89, 89, 89, 89, 36,
37, 38, 27, 89, 89, 89, 15, 42, 43, 44,
50, 12, 89, 89, 89, 89, 82, 83, 84, 89,
30, 71, 25, 78, 79, 80, 7, 75, 76, 77,
88, 24, 73, 88, 88, 39, 40, 41, 88, 88,
88, 88, 88, 88, 88, 88, 88, 68, 88, 88,
88, 88, 88, 88, 88, 50, 88, 87, 88, 88,
19, 88, 88, 88, 88, 69, 64, 59, 88, 88,
88, 88, 88, 74, 55, 88, 62, 32, 88, 84,
63, 47, 57, 88, 88, 88, 88, 88, 88, 88,
88, 58, 31, 88, 88, 88, 8, 88, 88, 88,
88, 88, 52, 13, 88, 14, 88, 88, 16, 65,
88, 88, 88, 60, 88, 88, 88, 53, 72, 61,
30, 72, 25, 79, 80, 81, 7, 76, 77, 78,
89, 24, 74, 89, 89, 39, 40, 41, 89, 89,
89, 89, 89, 89, 89, 89, 89, 69, 89, 89,
89, 89, 89, 89, 89, 51, 89, 88, 89, 89,
19, 89, 89, 89, 89, 70, 65, 60, 89, 89,
89, 89, 89, 75, 56, 89, 63, 32, 89, 85,
64, 48, 58, 89, 89, 89, 89, 89, 89, 89,
89, 59, 31, 89, 89, 89, 8, 89, 89, 89,
89, 89, 53, 13, 89, 14, 89, 89, 16, 66,
89, 89, 89, 61, 89, 89, 89, 89, 54, 73,
11, 66, 6, 86, 10, 45, 88, 88, 46, 0
62, 11, 67, 6, 87, 10, 45, 89, 89, 89,
89, 46, 89, 89, 89, 89, 89, 89, 89, 47,
0
} ;
static yyconst flex_int32_t yy_ec[256] =
@ -438,13 +440,13 @@ static yyconst flex_int32_t yy_ec[256] =
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 16, 16, 16, 20, 20, 21, 22, 23,
24, 25, 26, 1, 27, 27, 28, 29, 30, 27,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 32, 31, 31,
33, 1, 34, 35, 31, 1, 36, 37, 38, 39,
31, 31, 31, 31, 31, 31, 31, 31, 32, 31,
31, 31, 33, 31, 31, 31, 31, 34, 31, 31,
35, 1, 36, 37, 31, 1, 38, 39, 40, 41,
40, 41, 42, 43, 44, 31, 45, 46, 47, 48,
49, 50, 31, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 1, 1, 1, 1,
42, 43, 44, 45, 46, 31, 47, 48, 49, 50,
51, 52, 31, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -461,195 +463,199 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[64] =
static yyconst flex_int32_t yy_meta[66] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
1, 1, 1, 1, 1, 1, 3, 3, 3, 3,
4, 4, 1, 1, 1, 3, 3, 3, 3, 3,
3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 1, 1
4, 4, 4, 4, 1, 1, 1, 3, 3, 3,
3, 3, 3, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 1, 1, 1, 1
} ;
static yyconst flex_int16_t yy_base[416] =
static yyconst flex_int16_t yy_base[427] =
{ 0,
0, 0, 61, 62, 71, 0, 606, 607, 607, 607,
581, 42, 129, 607, 607, 580, 126, 607, 125, 123,
137, 149, 157, 578, 607, 175, 578, 44, 607, 0,
607, 607, 120, 95, 103, 142, 146, 136, 156, 552,
168, 162, 551, 120, 158, 545, 173, 558, 172, 178,
111, 186, 554, 607, 159, 607, 607, 607, 607, 582,
607, 607, 0, 607, 607, 607, 607, 607, 607, 607,
607, 607, 607, 222, 607, 0, 607, 228, 254, 262,
281, 0, 290, 607, 607, 607, 571, 607, 607, 607,
570, 0, 607, 607, 546, 539, 542, 550, 549, 536,
0, 0, 63, 64, 73, 0, 621, 622, 622, 622,
596, 44, 133, 622, 622, 595, 130, 622, 129, 127,
141, 153, 161, 593, 622, 177, 593, 46, 622, 0,
622, 622, 124, 97, 105, 137, 148, 154, 168, 565,
151, 167, 564, 121, 158, 558, 111, 571, 177, 176,
157, 188, 567, 622, 168, 622, 622, 622, 622, 597,
622, 622, 0, 622, 622, 622, 622, 622, 622, 622,
622, 622, 622, 225, 622, 0, 622, 231, 259, 267,
288, 0, 297, 622, 622, 622, 586, 622, 622, 622,
585, 0, 622, 622, 559, 552, 555, 563, 562, 549,
551, 538, 544, 532, 529, 542, 529, 526, 526, 532,
520, 527, 524, 534, 520, 526, 529, 530, 0, 204,
529, 207, 515, 528, 519, 521, 511, 525, 522, 524,
507, 512, 509, 498, 183, 512, 508, 510, 499, 502,
212, 507, 499, 511, 186, 504, 607, 607, 607, 0,
306, 0, 316, 332, 270, 342, 0, 607, 607, 0,
496, 500, 509, 506, 490, 490, 161, 505, 502, 502,
500, 497, 489, 495, 482, 493, 496, 0, 493, 481,
488, 485, 489, 482, 471, 470, 483, 486, 483, 478,
469, 294, 474, 477, 468, 465, 469, 475, 466, 457,
564, 551, 557, 545, 542, 555, 542, 539, 539, 545,
533, 540, 537, 547, 533, 539, 542, 543, 0, 205,
542, 170, 528, 541, 532, 534, 524, 538, 535, 537,
520, 525, 522, 511, 199, 525, 521, 523, 512, 515,
212, 520, 512, 524, 138, 517, 622, 622, 622, 0,
313, 0, 325, 341, 275, 353, 0, 622, 622, 0,
509, 513, 522, 519, 503, 503, 179, 518, 515, 515,
513, 510, 502, 508, 495, 506, 509, 0, 506, 494,
501, 498, 502, 495, 484, 483, 496, 499, 496, 491,
482, 246, 487, 490, 481, 478, 482, 488, 479, 470,
460, 458, 468, 454, 452, 452, 454, 451, 462, 461,
278, 456, 451, 440, 320, 458, 460, 449, 348, 354,
360, 366, 450, 0, 448, 336, 0, 440, 438, 446,
435, 452, 441, 370, 0, 0, 435, 445, 445, 430,
373, 0, 0, 432, 376, 433, 427, 426, 427, 426,
379, 0, 0, 0, 0, 0, 422, 423, 428, 419,
432, 427, 426, 418, 422, 414, 417, 421, 426, 425,
416, 0, 0, 422, 411, 411, 416, 415, 412, 0,
0, 0, 0, 402, 414, 416, 0, 0, 0, 0,
0, 0, 404, 405, 399, 409, 0, 0, 0, 400,
473, 471, 481, 467, 465, 465, 467, 464, 475, 474,
245, 469, 464, 453, 251, 471, 473, 462, 359, 365,
371, 377, 463, 0, 461, 301, 0, 453, 451, 459,
448, 465, 454, 317, 0, 0, 448, 458, 458, 443,
329, 0, 0, 445, 345, 446, 440, 439, 440, 439,
381, 0, 0, 0, 0, 0, 435, 436, 441, 432,
445, 440, 439, 431, 435, 427, 430, 434, 439, 438,
429, 0, 0, 435, 424, 424, 429, 428, 425, 0,
0, 0, 0, 415, 427, 429, 0, 0, 0, 0,
0, 0, 417, 418, 412, 422, 0, 0, 0, 413,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
407, 0, 0, 405, 401, 0, 0, 0, 397, 393,
398, 388, 401, 387, 400, 389, 396, 0, 394, 396,
380, 389, 395, 390, 378, 0, 380, 0, 379, 382,
0, 371, 370, 370, 383, 0, 385, 0, 384, 383,
368, 381, 368, 0, 0, 371, 0, 0, 363, 0,
0, 0, 0, 360, 371, 364, 368, 303, 297, 288,
300, 0, 0, 283, 290, 269, 0, 277, 274, 255,
232, 255, 0, 0, 244, 0, 236, 226, 0, 0,
225, 208, 211, 0, 185, 202, 131, 0, 0, 0,
420, 0, 0, 418, 414, 0, 0, 0, 410, 406,
411, 401, 414, 400, 413, 402, 409, 0, 407, 409,
393, 402, 408, 403, 391, 0, 393, 0, 392, 395,
0, 384, 383, 383, 396, 0, 398, 0, 397, 396,
381, 394, 381, 0, 0, 384, 0, 0, 376, 0,
0, 0, 0, 373, 384, 377, 383, 380, 375, 367,
379, 0, 0, 372, 379, 368, 0, 377, 374, 364,
294, 372, 0, 0, 372, 0, 368, 324, 0, 0,
323, 299, 310, 0, 300, 320, 282, 278, 0, 0,
0, 0, 0, 0, 0, 0, 134, 117, 0, 607,
398, 400, 402, 406, 142
0, 0, 0, 0, 0, 0, 0, 287, 266, 260,
257, 0, 228, 221, 221, 206, 206, 197, 160, 0,
622, 400, 402, 404, 408, 157
} ;
static yyconst flex_int16_t yy_def[416] =
static yyconst flex_int16_t yy_def[427] =
{ 0,
410, 1, 411, 411, 410, 5, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 412,
410, 410, 410, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 410, 410, 410, 410, 410, 410, 410,
410, 410, 413, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 414, 410, 410, 410, 410,
410, 415, 410, 410, 410, 410, 410, 410, 410, 410,
410, 412, 410, 410, 412, 412, 412, 412, 412, 412,
421, 1, 422, 422, 421, 5, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 423,
421, 421, 421, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 421, 421, 421, 421, 421, 421, 421,
421, 421, 424, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 425, 421, 421, 421, 421,
421, 426, 421, 421, 421, 421, 421, 421, 421, 421,
421, 423, 421, 421, 423, 423, 423, 423, 423, 423,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 410, 410, 410, 413,
410, 414, 410, 410, 410, 410, 415, 410, 410, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 421, 421, 421, 424,
421, 425, 421, 421, 421, 421, 426, 421, 421, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 410, 410,
410, 410, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 421, 421,
421, 421, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
412, 412, 412, 412, 412, 412, 412, 412, 412, 0,
410, 410, 410, 410, 410
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
423, 423, 423, 423, 423, 423, 423, 423, 423, 423,
0, 421, 421, 421, 421, 421
} ;
static yyconst flex_int16_t yy_nxt[671] =
static yyconst flex_int16_t yy_nxt[688] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 23, 23, 23, 23,
24, 25, 26, 27, 28, 29, 30, 30, 30, 30,
30, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 30, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 30, 30, 30, 54,
55, 56, 57, 59, 59, 65, 66, 90, 91, 60,
60, 8, 61, 62, 8, 8, 8, 8, 8, 8,
30, 30, 30, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 30, 43, 44, 45,
46, 47, 48, 49, 50, 51, 52, 53, 30, 30,
30, 54, 55, 56, 57, 59, 59, 65, 66, 90,
91, 60, 60, 8, 61, 62, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 63, 63, 63,
8, 8, 8, 8, 8, 8, 8, 8, 8, 63,
63, 63, 63, 8, 8, 8, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 8, 8, 8,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
8, 8, 8, 8, 67, 70, 72, 74, 74, 74,
74, 74, 74, 93, 157, 75, 95, 96, 73, 71,
76, 97, 68, 98, 94, 123, 409, 99, 141, 124,
77, 78, 142, 79, 79, 79, 79, 79, 80, 78,
408, 83, 83, 83, 83, 83, 83, 100, 81, 85,
82, 107, 147, 108, 407, 103, 81, 101, 81, 104,
102, 110, 109, 125, 105, 86, 81, 87, 88, 111,
63, 63, 63, 63, 8, 8, 8, 8, 67, 70,
72, 74, 74, 74, 74, 74, 74, 93, 128, 75,
95, 96, 73, 71, 76, 97, 68, 98, 123, 157,
94, 99, 124, 129, 77, 78, 130, 79, 79, 79,
79, 79, 80, 78, 100, 83, 83, 83, 83, 83,
83, 85, 81, 216, 101, 217, 82, 102, 116, 103,
81, 147, 420, 104, 81, 125, 117, 86, 105, 87,
106, 112, 119, 116, 113, 82, 126, 132, 128, 120,
114, 117, 229, 230, 133, 134, 121, 137, 204, 148,
138, 143, 118, 129, 135, 144, 130, 136, 139, 216,
406, 217, 405, 205, 145, 140, 74, 74, 74, 74,
74, 74, 153, 153, 153, 153, 153, 153, 396, 184,
404, 151, 185, 186, 190, 211, 187, 154, 188, 397,
403, 151, 191, 212, 402, 401, 78, 154, 79, 79,
79, 79, 79, 80, 78, 400, 80, 80, 80, 80,
80, 80, 399, 81, 156, 156, 156, 156, 156, 156,
155, 81, 155, 81, 398, 156, 156, 156, 156, 156,
88, 107, 81, 108, 106, 110, 141, 118, 126, 119,
142, 82, 109, 111, 132, 112, 120, 137, 113, 190,
138, 133, 134, 121, 114, 143, 419, 191, 139, 144,
148, 135, 229, 230, 136, 140, 204, 418, 145, 74,
74, 74, 74, 74, 74, 153, 153, 153, 153, 153,
153, 205, 184, 417, 151, 185, 186, 211, 416, 187,
154, 188, 254, 255, 256, 212, 151, 280, 281, 282,
415, 78, 154, 79, 79, 79, 79, 79, 80, 78,
414, 80, 80, 80, 80, 80, 80, 275, 81, 156,
156, 156, 156, 156, 156, 276, 81, 155, 413, 155,
156, 81, 78, 395, 83, 83, 83, 83, 83, 83,
254, 255, 256, 394, 393, 219, 392, 219, 275, 81,
220, 220, 220, 220, 220, 220, 276, 391, 390, 81,
153, 153, 153, 153, 153, 153, 280, 281, 282, 389,
388, 221, 387, 221, 386, 154, 222, 222, 222, 222,
222, 222, 288, 289, 290, 154, 156, 156, 156, 156,
156, 156, 220, 220, 220, 220, 220, 220, 220, 220,
220, 220, 220, 220, 222, 222, 222, 222, 222, 222,
222, 222, 222, 222, 222, 222, 297, 298, 299, 304,
305, 306, 308, 309, 310, 316, 317, 318, 58, 58,
81, 412, 156, 156, 156, 156, 156, 156, 81, 78,
396, 83, 83, 83, 83, 83, 83, 288, 289, 290,
411, 397, 219, 398, 219, 410, 81, 220, 220, 220,
220, 220, 220, 297, 298, 299, 409, 408, 81, 153,
153, 153, 153, 153, 153, 304, 305, 306, 407, 406,
221, 405, 221, 404, 154, 222, 222, 222, 222, 222,
222, 308, 309, 310, 403, 402, 154, 156, 156, 156,
156, 156, 156, 220, 220, 220, 220, 220, 220, 220,
220, 220, 220, 220, 220, 222, 222, 222, 222, 222,
222, 222, 222, 222, 222, 222, 222, 316, 317, 318,
58, 58, 92, 92, 150, 150, 152, 385, 152, 152,
384, 383, 382, 381, 380, 379, 378, 377, 376, 375,
374, 373, 372, 371, 370, 369, 368, 367, 366, 365,
364, 363, 362, 361, 360, 359, 358, 357, 356, 355,
354, 353, 352, 351, 350, 349, 348, 347, 346, 345,
344, 343, 342, 341, 340, 339, 338, 337, 336, 335,
334, 333, 332, 331, 330, 329, 328, 327, 326, 325,
324, 323, 322, 321, 320, 319, 315, 314, 313, 312,
311, 307, 303, 302, 301, 300, 296, 295, 294, 293,
292, 291, 287, 286, 285, 284, 283, 279, 278, 277,
58, 58, 58, 58, 92, 92, 150, 150, 152, 401,
152, 152, 400, 399, 395, 394, 393, 392, 391, 390,
389, 388, 387, 386, 385, 384, 383, 382, 381, 380,
379, 378, 377, 376, 375, 374, 373, 372, 371, 370,
369, 368, 367, 366, 365, 364, 363, 362, 361, 360,
359, 358, 357, 356, 355, 354, 353, 352, 351, 350,
349, 348, 347, 346, 345, 344, 343, 342, 341, 340,
339, 338, 337, 336, 335, 334, 333, 332, 331, 330,
329, 328, 327, 326, 325, 324, 323, 322, 321, 320,
319, 315, 314, 313, 312, 311, 307, 303, 302, 301,
274, 273, 272, 271, 270, 269, 268, 267, 266, 265,
264, 263, 262, 261, 260, 259, 258, 257, 253, 252,
251, 250, 249, 248, 247, 246, 245, 244, 243, 242,
241, 240, 239, 238, 237, 236, 235, 234, 233, 232,
231, 228, 227, 226, 225, 224, 223, 218, 215, 214,
213, 210, 209, 208, 207, 206, 203, 202, 201, 200,
199, 198, 197, 196, 195, 194, 193, 192, 189, 183,
182, 181, 180, 179, 178, 177, 176, 175, 174, 173,
172, 171, 170, 169, 168, 167, 166, 165, 164, 163,
162, 161, 160, 159, 158, 149, 146, 131, 127, 122,
300, 296, 295, 294, 293, 292, 291, 287, 286, 285,
284, 283, 279, 278, 277, 274, 273, 272, 271, 270,
269, 268, 267, 266, 265, 264, 263, 262, 261, 260,
259, 258, 257, 253, 252, 251, 250, 249, 248, 247,
246, 245, 244, 243, 242, 241, 240, 239, 238, 237,
236, 235, 234, 233, 232, 231, 228, 227, 226, 225,
224, 223, 218, 215, 214, 213, 210, 209, 208, 207,
206, 203, 202, 201, 200, 199, 198, 197, 196, 195,
194, 193, 192, 189, 183, 182, 181, 180, 179, 178,
177, 176, 175, 174, 173, 172, 171, 170, 169, 168,
115, 89, 84, 69, 64, 410, 7, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410
167, 166, 165, 164, 163, 162, 161, 160, 159, 158,
149, 146, 131, 127, 122, 115, 89, 84, 69, 64,
421, 7, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421
} ;
static yyconst flex_int16_t yy_chk[671] =
static yyconst flex_int16_t yy_chk[688] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -657,77 +663,79 @@ static yyconst flex_int16_t yy_chk[671] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 3, 4, 12, 12, 28, 28, 3,
4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1, 1, 1, 1, 1, 3, 4, 12, 12, 28,
28, 3, 4, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 13, 17, 19, 20, 20, 20,
20, 20, 20, 33, 415, 21, 34, 34, 19, 17,
21, 35, 13, 35, 33, 44, 408, 35, 51, 44,
21, 22, 51, 22, 22, 22, 22, 22, 22, 23,
407, 23, 23, 23, 23, 23, 23, 36, 22, 26,
22, 38, 55, 38, 397, 37, 23, 36, 22, 37,
36, 39, 38, 45, 37, 26, 23, 26, 26, 39,
5, 5, 5, 5, 5, 5, 5, 5, 13, 17,
19, 20, 20, 20, 20, 20, 20, 33, 47, 21,
34, 34, 19, 17, 21, 35, 13, 35, 44, 426,
33, 35, 44, 47, 21, 22, 47, 22, 22, 22,
22, 22, 22, 23, 36, 23, 23, 23, 23, 23,
23, 26, 22, 145, 36, 145, 22, 36, 41, 37,
23, 55, 419, 37, 22, 45, 41, 26, 37, 26,
37, 39, 42, 41, 39, 22, 45, 49, 47, 42,
39, 41, 167, 167, 49, 49, 42, 50, 135, 55,
50, 52, 41, 47, 49, 52, 47, 49, 50, 145,
396, 145, 395, 135, 52, 50, 74, 74, 74, 74,
74, 74, 78, 78, 78, 78, 78, 78, 381, 120,
393, 74, 120, 120, 122, 141, 120, 78, 120, 381,
392, 74, 122, 141, 391, 388, 79, 78, 79, 79,
79, 79, 79, 79, 80, 387, 80, 80, 80, 80,
80, 80, 385, 79, 155, 155, 155, 155, 155, 155,
81, 80, 81, 79, 382, 81, 81, 81, 81, 81,
26, 38, 23, 38, 37, 39, 51, 41, 45, 42,
51, 22, 38, 39, 49, 39, 42, 50, 39, 122,
50, 49, 49, 42, 39, 52, 418, 122, 50, 52,
55, 49, 167, 167, 49, 50, 135, 417, 52, 74,
74, 74, 74, 74, 74, 78, 78, 78, 78, 78,
78, 135, 120, 416, 74, 120, 120, 141, 415, 120,
78, 120, 192, 192, 192, 141, 74, 215, 215, 215,
414, 79, 78, 79, 79, 79, 79, 79, 79, 80,
413, 80, 80, 80, 80, 80, 80, 211, 79, 155,
155, 155, 155, 155, 155, 211, 80, 81, 411, 81,
81, 80, 83, 380, 83, 83, 83, 83, 83, 83,
192, 192, 192, 379, 378, 151, 376, 151, 211, 83,
151, 151, 151, 151, 151, 151, 211, 375, 374, 83,
153, 153, 153, 153, 153, 153, 215, 215, 215, 371,
370, 154, 369, 154, 368, 153, 154, 154, 154, 154,
154, 154, 226, 226, 226, 153, 156, 156, 156, 156,
156, 156, 219, 219, 219, 219, 219, 219, 220, 220,
220, 220, 220, 220, 221, 221, 221, 221, 221, 221,
222, 222, 222, 222, 222, 222, 234, 234, 234, 241,
241, 241, 245, 245, 245, 251, 251, 251, 411, 411,
79, 410, 81, 81, 81, 81, 81, 81, 80, 83,
381, 83, 83, 83, 83, 83, 83, 226, 226, 226,
409, 381, 151, 381, 151, 408, 83, 151, 151, 151,
151, 151, 151, 234, 234, 234, 398, 397, 83, 153,
153, 153, 153, 153, 153, 241, 241, 241, 396, 395,
154, 393, 154, 392, 153, 154, 154, 154, 154, 154,
154, 245, 245, 245, 391, 388, 153, 156, 156, 156,
156, 156, 156, 219, 219, 219, 219, 219, 219, 220,
220, 220, 220, 220, 220, 221, 221, 221, 221, 221,
221, 222, 222, 222, 222, 222, 222, 251, 251, 251,
411, 411, 412, 412, 413, 413, 414, 367, 414, 414,
366, 365, 364, 359, 356, 353, 352, 351, 350, 349,
347, 345, 344, 343, 342, 340, 339, 337, 335, 334,
333, 332, 331, 330, 329, 327, 326, 325, 324, 323,
322, 321, 320, 319, 315, 314, 311, 300, 296, 295,
294, 293, 286, 285, 284, 279, 278, 277, 276, 275,
274, 271, 270, 269, 268, 267, 266, 265, 264, 263,
262, 261, 260, 259, 258, 257, 250, 249, 248, 247,
246, 244, 240, 239, 238, 237, 233, 232, 231, 230,
229, 228, 225, 223, 218, 217, 216, 214, 213, 212,
422, 422, 422, 422, 423, 423, 424, 424, 425, 387,
425, 425, 385, 382, 380, 379, 378, 376, 375, 374,
371, 370, 369, 368, 367, 366, 365, 364, 359, 356,
353, 352, 351, 350, 349, 347, 345, 344, 343, 342,
340, 339, 337, 335, 334, 333, 332, 331, 330, 329,
327, 326, 325, 324, 323, 322, 321, 320, 319, 315,
314, 311, 300, 296, 295, 294, 293, 286, 285, 284,
279, 278, 277, 276, 275, 274, 271, 270, 269, 268,
267, 266, 265, 264, 263, 262, 261, 260, 259, 258,
257, 250, 249, 248, 247, 246, 244, 240, 239, 238,
210, 209, 208, 207, 206, 205, 204, 203, 202, 201,
200, 199, 198, 197, 196, 195, 194, 193, 191, 190,
189, 188, 187, 186, 185, 184, 183, 182, 181, 180,
179, 177, 176, 175, 174, 173, 172, 171, 170, 169,
168, 166, 165, 164, 163, 162, 161, 146, 144, 143,
142, 140, 139, 138, 137, 136, 134, 133, 132, 131,
130, 129, 128, 127, 126, 125, 124, 123, 121, 118,
117, 116, 115, 114, 113, 112, 111, 110, 109, 108,
107, 106, 105, 104, 103, 102, 101, 100, 99, 98,
97, 96, 95, 91, 87, 60, 53, 48, 46, 43,
237, 233, 232, 231, 230, 229, 228, 225, 223, 218,
217, 216, 214, 213, 212, 210, 209, 208, 207, 206,
205, 204, 203, 202, 201, 200, 199, 198, 197, 196,
195, 194, 193, 191, 190, 189, 188, 187, 186, 185,
184, 183, 182, 181, 180, 179, 177, 176, 175, 174,
173, 172, 171, 170, 169, 168, 166, 165, 164, 163,
162, 161, 146, 144, 143, 142, 140, 139, 138, 137,
136, 134, 133, 132, 131, 130, 129, 128, 127, 126,
125, 124, 123, 121, 118, 117, 116, 115, 114, 113,
112, 111, 110, 109, 108, 107, 106, 105, 104, 103,
40, 27, 24, 16, 11, 7, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410
102, 101, 100, 99, 98, 97, 96, 95, 91, 87,
60, 53, 48, 46, 43, 40, 27, 24, 16, 11,
7, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421, 421, 421, 421,
421, 421, 421, 421, 421, 421, 421
} ;
/* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[146] =
static yyconst flex_int32_t yy_rule_can_match_eol[147] =
{ 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -736,7 +744,7 @@ static yyconst flex_int32_t yy_rule_can_match_eol[146] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, };
0, 0, 0, 0, 1, 0, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@ -756,7 +764,7 @@ This file contains the Lex specification for GLSL ES.
Based on ANSI C grammar, Lex specification:
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh,
WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
*/
@ -1062,13 +1070,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 411 )
if ( yy_current_state >= 422 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 410 );
while ( yy_current_state != 421 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@ -1285,11 +1293,11 @@ YY_RULE_SETUP
YY_BREAK
case 47:
YY_RULE_SETUP
{ context->lexAfterType = true; return(STRUCT); }
{ context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; }
YY_BREAK
case 48:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
{ context->lexAfterType = true; return(STRUCT); }
YY_BREAK
case 49:
YY_RULE_SETUP
@ -1449,30 +1457,30 @@ YY_RULE_SETUP
YY_BREAK
case 88:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 89:
YY_RULE_SETUP
{
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
YY_BREAK
case 89:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 90:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 91:
YY_RULE_SETUP
{ context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;}
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 92:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{ context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;}
YY_BREAK
case 93:
YY_RULE_SETUP
{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 94:
YY_RULE_SETUP
@ -1484,198 +1492,202 @@ YY_RULE_SETUP
YY_BREAK
case 96:
YY_RULE_SETUP
{ return(ADD_ASSIGN); }
{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
YY_BREAK
case 97:
YY_RULE_SETUP
{ return(SUB_ASSIGN); }
{ return(ADD_ASSIGN); }
YY_BREAK
case 98:
YY_RULE_SETUP
{ return(MUL_ASSIGN); }
{ return(SUB_ASSIGN); }
YY_BREAK
case 99:
YY_RULE_SETUP
{ return(DIV_ASSIGN); }
{ return(MUL_ASSIGN); }
YY_BREAK
case 100:
YY_RULE_SETUP
{ return(MOD_ASSIGN); }
{ return(DIV_ASSIGN); }
YY_BREAK
case 101:
YY_RULE_SETUP
{ return(LEFT_ASSIGN); }
{ return(MOD_ASSIGN); }
YY_BREAK
case 102:
YY_RULE_SETUP
{ return(RIGHT_ASSIGN); }
{ return(LEFT_ASSIGN); }
YY_BREAK
case 103:
YY_RULE_SETUP
{ return(AND_ASSIGN); }
{ return(RIGHT_ASSIGN); }
YY_BREAK
case 104:
YY_RULE_SETUP
{ return(XOR_ASSIGN); }
{ return(AND_ASSIGN); }
YY_BREAK
case 105:
YY_RULE_SETUP
{ return(OR_ASSIGN); }
{ return(XOR_ASSIGN); }
YY_BREAK
case 106:
YY_RULE_SETUP
{ return(INC_OP); }
{ return(OR_ASSIGN); }
YY_BREAK
case 107:
YY_RULE_SETUP
{ return(DEC_OP); }
{ return(INC_OP); }
YY_BREAK
case 108:
YY_RULE_SETUP
{ return(AND_OP); }
{ return(DEC_OP); }
YY_BREAK
case 109:
YY_RULE_SETUP
{ return(OR_OP); }
{ return(AND_OP); }
YY_BREAK
case 110:
YY_RULE_SETUP
{ return(XOR_OP); }
{ return(OR_OP); }
YY_BREAK
case 111:
YY_RULE_SETUP
{ return(LE_OP); }
{ return(XOR_OP); }
YY_BREAK
case 112:
YY_RULE_SETUP
{ return(GE_OP); }
{ return(LE_OP); }
YY_BREAK
case 113:
YY_RULE_SETUP
{ return(EQ_OP); }
{ return(GE_OP); }
YY_BREAK
case 114:
YY_RULE_SETUP
{ return(NE_OP); }
{ return(EQ_OP); }
YY_BREAK
case 115:
YY_RULE_SETUP
{ return(LEFT_OP); }
{ return(NE_OP); }
YY_BREAK
case 116:
YY_RULE_SETUP
{ return(RIGHT_OP); }
{ return(LEFT_OP); }
YY_BREAK
case 117:
YY_RULE_SETUP
{ context->lexAfterType = false; return(SEMICOLON); }
{ return(RIGHT_OP); }
YY_BREAK
case 118:
YY_RULE_SETUP
{ context->lexAfterType = false; return(LEFT_BRACE); }
{ context->lexAfterType = false; return(SEMICOLON); }
YY_BREAK
case 119:
YY_RULE_SETUP
{ return(RIGHT_BRACE); }
{ context->lexAfterType = false; return(LEFT_BRACE); }
YY_BREAK
case 120:
YY_RULE_SETUP
{ if (context->inTypeParen) context->lexAfterType = false; return(COMMA); }
{ return(RIGHT_BRACE); }
YY_BREAK
case 121:
YY_RULE_SETUP
{ return(COLON); }
{ if (context->inTypeParen) context->lexAfterType = false; return(COMMA); }
YY_BREAK
case 122:
YY_RULE_SETUP
{ context->lexAfterType = false; return(EQUAL); }
{ return(COLON); }
YY_BREAK
case 123:
YY_RULE_SETUP
{ context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); }
{ context->lexAfterType = false; return(EQUAL); }
YY_BREAK
case 124:
YY_RULE_SETUP
{ context->inTypeParen = false; return(RIGHT_PAREN); }
{ context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); }
YY_BREAK
case 125:
YY_RULE_SETUP
{ return(LEFT_BRACKET); }
{ context->inTypeParen = false; return(RIGHT_PAREN); }
YY_BREAK
case 126:
YY_RULE_SETUP
{ return(RIGHT_BRACKET); }
{ return(LEFT_BRACKET); }
YY_BREAK
case 127:
YY_RULE_SETUP
{ BEGIN(FIELDS); return(DOT); }
{ return(RIGHT_BRACKET); }
YY_BREAK
case 128:
YY_RULE_SETUP
{ return(BANG); }
{ BEGIN(FIELDS); return(DOT); }
YY_BREAK
case 129:
YY_RULE_SETUP
{ return(DASH); }
{ return(BANG); }
YY_BREAK
case 130:
YY_RULE_SETUP
{ return(TILDE); }
{ return(DASH); }
YY_BREAK
case 131:
YY_RULE_SETUP
{ return(PLUS); }
{ return(TILDE); }
YY_BREAK
case 132:
YY_RULE_SETUP
{ return(STAR); }
{ return(PLUS); }
YY_BREAK
case 133:
YY_RULE_SETUP
{ return(SLASH); }
{ return(STAR); }
YY_BREAK
case 134:
YY_RULE_SETUP
{ return(PERCENT); }
{ return(SLASH); }
YY_BREAK
case 135:
YY_RULE_SETUP
{ return(LEFT_ANGLE); }
{ return(PERCENT); }
YY_BREAK
case 136:
YY_RULE_SETUP
{ return(RIGHT_ANGLE); }
{ return(LEFT_ANGLE); }
YY_BREAK
case 137:
YY_RULE_SETUP
{ return(VERTICAL_BAR); }
{ return(RIGHT_ANGLE); }
YY_BREAK
case 138:
YY_RULE_SETUP
{ return(CARET); }
{ return(VERTICAL_BAR); }
YY_BREAK
case 139:
YY_RULE_SETUP
{ return(AMPERSAND); }
{ return(CARET); }
YY_BREAK
case 140:
YY_RULE_SETUP
{ return(QUESTION); }
{ return(AMPERSAND); }
YY_BREAK
case 141:
YY_RULE_SETUP
{ return(QUESTION); }
YY_BREAK
case 142:
YY_RULE_SETUP
{
BEGIN(INITIAL);
yylval->lex.string = NewPoolTString(yytext);
return FIELD_SELECTION;
}
YY_BREAK
case 142:
case 143:
YY_RULE_SETUP
{}
YY_BREAK
case 143:
/* rule 143 can match eol */
case 144:
/* rule 144 can match eol */
YY_RULE_SETUP
{ }
YY_BREAK
@ -1684,11 +1696,11 @@ case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(FIELDS):
{ context->AfterEOF = true; yyterminate(); }
YY_BREAK
case 144:
case 145:
YY_RULE_SETUP
{ context->warning(yylineno, "Unknown char", yytext, ""); return 0; }
YY_BREAK
case 145:
case 146:
YY_RULE_SETUP
ECHO;
YY_BREAK
@ -1984,7 +1996,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 411 )
if ( yy_current_state >= 422 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -2013,11 +2025,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 411 )
if ( yy_current_state >= 422 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 410);
yy_is_jam = (yy_current_state == 421);
return yy_is_jam ? 0 : yy_current_state;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -79,57 +79,58 @@
WHILE = 295,
SAMPLER2D = 296,
SAMPLERCUBE = 297,
IDENTIFIER = 298,
TYPE_NAME = 299,
FLOATCONSTANT = 300,
INTCONSTANT = 301,
BOOLCONSTANT = 302,
FIELD_SELECTION = 303,
LEFT_OP = 304,
RIGHT_OP = 305,
INC_OP = 306,
DEC_OP = 307,
LE_OP = 308,
GE_OP = 309,
EQ_OP = 310,
NE_OP = 311,
AND_OP = 312,
OR_OP = 313,
XOR_OP = 314,
MUL_ASSIGN = 315,
DIV_ASSIGN = 316,
ADD_ASSIGN = 317,
MOD_ASSIGN = 318,
LEFT_ASSIGN = 319,
RIGHT_ASSIGN = 320,
AND_ASSIGN = 321,
XOR_ASSIGN = 322,
OR_ASSIGN = 323,
SUB_ASSIGN = 324,
LEFT_PAREN = 325,
RIGHT_PAREN = 326,
LEFT_BRACKET = 327,
RIGHT_BRACKET = 328,
LEFT_BRACE = 329,
RIGHT_BRACE = 330,
DOT = 331,
COMMA = 332,
COLON = 333,
EQUAL = 334,
SEMICOLON = 335,
BANG = 336,
DASH = 337,
TILDE = 338,
PLUS = 339,
STAR = 340,
SLASH = 341,
PERCENT = 342,
LEFT_ANGLE = 343,
RIGHT_ANGLE = 344,
VERTICAL_BAR = 345,
CARET = 346,
AMPERSAND = 347,
QUESTION = 348
SAMPLER_EXTERNAL_OES = 298,
IDENTIFIER = 299,
TYPE_NAME = 300,
FLOATCONSTANT = 301,
INTCONSTANT = 302,
BOOLCONSTANT = 303,
FIELD_SELECTION = 304,
LEFT_OP = 305,
RIGHT_OP = 306,
INC_OP = 307,
DEC_OP = 308,
LE_OP = 309,
GE_OP = 310,
EQ_OP = 311,
NE_OP = 312,
AND_OP = 313,
OR_OP = 314,
XOR_OP = 315,
MUL_ASSIGN = 316,
DIV_ASSIGN = 317,
ADD_ASSIGN = 318,
MOD_ASSIGN = 319,
LEFT_ASSIGN = 320,
RIGHT_ASSIGN = 321,
AND_ASSIGN = 322,
XOR_ASSIGN = 323,
OR_ASSIGN = 324,
SUB_ASSIGN = 325,
LEFT_PAREN = 326,
RIGHT_PAREN = 327,
LEFT_BRACKET = 328,
RIGHT_BRACKET = 329,
LEFT_BRACE = 330,
RIGHT_BRACE = 331,
DOT = 332,
COMMA = 333,
COLON = 334,
EQUAL = 335,
SEMICOLON = 336,
BANG = 337,
DASH = 338,
TILDE = 339,
PLUS = 340,
STAR = 341,
SLASH = 342,
PERCENT = 343,
LEFT_ANGLE = 344,
RIGHT_ANGLE = 345,
VERTICAL_BAR = 346,
CARET = 347,
AMPERSAND = 348,
QUESTION = 349
};
#endif
/* Tokens. */
@ -173,57 +174,58 @@
#define WHILE 295
#define SAMPLER2D 296
#define SAMPLERCUBE 297
#define IDENTIFIER 298
#define TYPE_NAME 299
#define FLOATCONSTANT 300
#define INTCONSTANT 301
#define BOOLCONSTANT 302
#define FIELD_SELECTION 303
#define LEFT_OP 304
#define RIGHT_OP 305
#define INC_OP 306
#define DEC_OP 307
#define LE_OP 308
#define GE_OP 309
#define EQ_OP 310
#define NE_OP 311
#define AND_OP 312
#define OR_OP 313
#define XOR_OP 314
#define MUL_ASSIGN 315
#define DIV_ASSIGN 316
#define ADD_ASSIGN 317
#define MOD_ASSIGN 318
#define LEFT_ASSIGN 319
#define RIGHT_ASSIGN 320
#define AND_ASSIGN 321
#define XOR_ASSIGN 322
#define OR_ASSIGN 323
#define SUB_ASSIGN 324
#define LEFT_PAREN 325
#define RIGHT_PAREN 326
#define LEFT_BRACKET 327
#define RIGHT_BRACKET 328
#define LEFT_BRACE 329
#define RIGHT_BRACE 330
#define DOT 331
#define COMMA 332
#define COLON 333
#define EQUAL 334
#define SEMICOLON 335
#define BANG 336
#define DASH 337
#define TILDE 338
#define PLUS 339
#define STAR 340
#define SLASH 341
#define PERCENT 342
#define LEFT_ANGLE 343
#define RIGHT_ANGLE 344
#define VERTICAL_BAR 345
#define CARET 346
#define AMPERSAND 347
#define QUESTION 348
#define SAMPLER_EXTERNAL_OES 298
#define IDENTIFIER 299
#define TYPE_NAME 300
#define FLOATCONSTANT 301
#define INTCONSTANT 302
#define BOOLCONSTANT 303
#define FIELD_SELECTION 304
#define LEFT_OP 305
#define RIGHT_OP 306
#define INC_OP 307
#define DEC_OP 308
#define LE_OP 309
#define GE_OP 310
#define EQ_OP 311
#define NE_OP 312
#define AND_OP 313
#define OR_OP 314
#define XOR_OP 315
#define MUL_ASSIGN 316
#define DIV_ASSIGN 317
#define ADD_ASSIGN 318
#define MOD_ASSIGN 319
#define LEFT_ASSIGN 320
#define RIGHT_ASSIGN 321
#define AND_ASSIGN 322
#define XOR_ASSIGN 323
#define OR_ASSIGN 324
#define SUB_ASSIGN 325
#define LEFT_PAREN 326
#define RIGHT_PAREN 327
#define LEFT_BRACKET 328
#define RIGHT_BRACKET 329
#define LEFT_BRACE 330
#define RIGHT_BRACE 331
#define DOT 332
#define COMMA 333
#define COLON 334
#define EQUAL 335
#define SEMICOLON 336
#define BANG 337
#define DASH 338
#define TILDE 339
#define PLUS 340
#define STAR 341
#define SLASH 342
#define PERCENT 343
#define LEFT_ANGLE 344
#define RIGHT_ANGLE 345
#define VERTICAL_BAR 346
#define CARET 347
#define AMPERSAND 348
#define QUESTION 349
@ -262,7 +264,7 @@ typedef union YYSTYPE
};
} interm;
}
/* Line 1529 of yacc.c. */
/* Line 1489 of yacc.c. */
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */

Просмотреть файл

@ -410,8 +410,8 @@ protected:
//
class TIntermUnary : public TIntermOperator {
public:
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0), useEmulatedFunction(false) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0), useEmulatedFunction(false) {}
virtual void traverse(TIntermTraverser*);
virtual TIntermUnary* getAsUnaryNode() { return this; }
@ -420,8 +420,12 @@ public:
TIntermTyped* getOperand() { return operand; }
bool promote(TInfoSink&);
void setUseEmulatedFunction() { useEmulatedFunction = true; }
bool getUseEmulatedFunction() { return useEmulatedFunction; }
protected:
TIntermTyped* operand;
bool useEmulatedFunction; // if set to true, replace the function call by an emulated one.
};
typedef TVector<TIntermNode*> TIntermSequence;

Просмотреть файл

@ -0,0 +1,21 @@
//
// Copyright (c) 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 "Context.h"
namespace pp
{
Context::Context(int count, const char* const string[], const int length[],
TokenVector* output)
: input(count, string, length),
output(output),
lexer(NULL)
{
}
} // namespace pp

Просмотреть файл

@ -0,0 +1,31 @@
//
// Copyright (c) 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_PREPROCESSOR_CONTEXT_H_
#define COMPILER_PREPROCESSOR_CONTEXT_H_
#include "Input.h"
#include "Macro.h"
#include "Token.h"
namespace pp
{
struct Context
{
Context(int count, const char* const string[], const int length[],
TokenVector* output);
Input input;
TokenVector* output;
void* lexer; // Lexer handle.
MacroSet macros; // Defined macros.
};
} // namespace pp
#endif // COMPILER_PREPROCESSOR_CONTEXT_H_

Просмотреть файл

@ -0,0 +1,165 @@
//
// Copyright (c) 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 "Input.h"
#include <cstdio>
#include "compiler/debug.h"
namespace pp
{
Input::Input(int count, const char* const string[], const int length[])
: mCount(count),
mString(string),
mLength(length),
mIndex(-1),
mSize(0),
mError(kErrorNone),
mState(kStateInitial)
{
ASSERT(mCount >= 0);
switchToNextString();
}
bool Input::eof() const
{
ASSERT(mIndex <= mCount);
return mIndex == mCount;
}
int Input::read(char* buf, int bufSize)
{
int nread = 0;
int startIndex = mIndex;
// Keep reading until the buffer is full or the current string is exhausted.
while ((mIndex == startIndex) && (nread < bufSize))
{
int c = getChar();
if (c == EOF)
{
if (mState == kStateBlockComment)
mError = kErrorUnexpectedEOF;
break;
}
switch (mState)
{
case kStateInitial:
if (c == '/')
{
// Potentially a comment.
switch (peekChar())
{
case '/':
getChar(); // Eat '/'.
mState = kStateLineComment;
break;
case '*':
getChar(); // Eat '*'.
mState = kStateBlockComment;
break;
default:
// Not a comment.
buf[nread++] = c;
break;
}
} else
{
buf[nread++] = c;
}
break;
case kStateLineComment:
if (c == '\n')
{
buf[nread++] = c;
mState = kStateInitial;
}
break;
case kStateBlockComment:
if (c == '*' && (peekChar() == '/'))
{
getChar(); // Eat '/'.
buf[nread++] = ' '; // Replace comment with whitespace.
mState = kStateInitial;
} else if (c == '\n')
{
// Line breaks are never skipped.
buf[nread++] = c;
}
break;
default:
ASSERT(false);
break;
}
}
return nread;
}
int Input::getChar()
{
if (eof()) return EOF;
const char* str = mString[mIndex];
int c = str[mSize++];
// Switch to next string if the current one is fully read.
int length = stringLength(mIndex);
// We never read from empty string.
ASSERT(length != 0);
if (((length < 0) && (str[mSize] == '\0')) ||
((length > 0) && (mSize == length)))
switchToNextString();
return c;
}
int Input::peekChar()
{
// Save the current read position.
int index = mIndex;
int size = mSize;
int c = getChar();
// Restore read position.
mIndex = index;
mSize = size;
return c;
}
void Input::switchToNextString()
{
ASSERT(mIndex < mCount);
mSize = 0;
do
{
++mIndex;
} while (!eof() && isStringEmpty(mIndex));
}
bool Input::isStringEmpty(int index)
{
ASSERT(index < mCount);
const char* str = mString[mIndex];
int length = stringLength(mIndex);
return (length == 0) || ((length < 0) && (str[0] == '\0'));
}
int Input::stringLength(int index)
{
ASSERT(index < mCount);
return mLength ? mLength[index] : -1;
}
} // namespace pp

Просмотреть файл

@ -0,0 +1,74 @@
//
// Copyright (c) 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_PREPROCESSOR_INPUT_H_
#define COMPILER_PREPROCESSOR_INPUT_H_
namespace pp
{
// Reads the given set of strings into input buffer.
// Strips comments.
class Input
{
public:
Input(int count, const char* const string[], const int length[]);
enum Error
{
kErrorNone,
kErrorUnexpectedEOF
};
Error error() const { return mError; }
// Returns the index of string currently being scanned.
int stringIndex() const { return mIndex; }
// Returns true if EOF has reached.
bool eof() const;
// Reads up to bufSize characters into buf.
// Returns the number of characters read.
// It replaces each comment by a whitespace. It reads only one string
// at a time so that the lexer has opportunity to update the string number
// for meaningful diagnostic messages.
int read(char* buf, int bufSize);
private:
enum State
{
kStateInitial,
kStateLineComment,
kStateBlockComment
};
int getChar();
int peekChar();
// Switches input buffer to the next non-empty string.
// This is called when the current string is fully read.
void switchToNextString();
// Returns true if the given string is empty.
bool isStringEmpty(int index);
// Return the length of the given string.
// Returns a negative value for null-terminated strings.
int stringLength(int index);
// Input.
int mCount;
const char* const* mString;
const int* mLength;
// Current read position.
int mIndex; // Index of string currently being scanned.
int mSize; // Size of string already scanned.
// Current error and state.
Error mError;
State mState;
};
} // namespace pp
#endif // COMPILER_PREPROCESSOR_INPUT_H_

Просмотреть файл

@ -0,0 +1,34 @@
//
// Copyright (c) 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_PREPROCESSOR_MACRO_H_
#define COMPILER_PREPROCESSOR_MACRO_H_
#include <map>
#include <string>
#include "Token.h"
namespace pp
{
struct Macro
{
enum Type
{
kTypeObj,
kTypeFunc
};
Type type;
std::string identifier;
TokenVector parameters;
TokenVector replacements;
};
typedef std::map<std::string, Macro> MacroSet;
} // namespace pp
#endif COMPILER_PREPROCESSOR_MACRO_H_

Просмотреть файл

@ -0,0 +1,43 @@
//
// Copyright (c) 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 "Preprocessor.h"
#include "compiler/debug.h"
#include "Context.h"
namespace pp
{
bool Preprocessor::process(int count,
const char* const string[],
const int length[])
{
ASSERT((count >=0) && (string != NULL));
if ((count < 0) || (string == NULL))
return false;
clearResults();
Context context(count, string, length, &mTokens);
if (!initLexer(&context))
return false;
bool success = parse(&context);
destroyLexer(&context);
return success;
}
void Preprocessor::clearResults()
{
for (TokenVector::iterator i = mTokens.begin(); i != mTokens.end(); ++i)
delete (*i);
mTokens.clear();
}
} // namespace pp

Просмотреть файл

@ -0,0 +1,42 @@
//
// Copyright (c) 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_PREPROCESSOR_PREPROCESSOR_H_
#define COMPILER_PREPROCESSOR_PREPROCESSOR_H_
#include "common/angleutils.h"
#include "Token.h"
namespace pp
{
struct Context;
class Preprocessor
{
public:
Preprocessor() { }
bool process(int count, const char* const string[], const int length[]);
TokenIterator begin() const { return mTokens.begin(); }
TokenIterator end() const { return mTokens.end(); }
private:
DISALLOW_COPY_AND_ASSIGN(Preprocessor);
static bool initLexer(Context* context);
static void destroyLexer(Context* context);
static bool parse(Context* context);
void clearResults();
TokenVector mTokens; // Output.
};
} // namespace pp
#endif // COMPILER_PREPROCESSOR_PREPROCESSOR_H_

Просмотреть файл

@ -0,0 +1,58 @@
//
// Copyright (c) 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 "Token.h"
#include "token_type.h"
static const int kLocationLineSize = 16; // in bits.
static const int kLocationLineMask = (1 << kLocationLineSize) - 1;
namespace pp
{
Token::Location Token::encodeLocation(int line, int file)
{
return (file << kLocationLineSize) | (line & kLocationLineMask);
}
void Token::decodeLocation(Location loc, int* line, int* file)
{
if (file) *file = loc >> kLocationLineSize;
if (line) *line = loc & kLocationLineMask;
}
Token::Token(Location location, int type, std::string* value)
: mLocation(location),
mType(type),
mValue(value)
{
}
Token::~Token() {
delete mValue;
}
std::ostream& operator<<(std::ostream& out, const Token& token)
{
switch (token.type())
{
case SPACE:
out << " ";
break;
case INT_CONSTANT:
case FLOAT_CONSTANT:
case IDENTIFIER:
out << *(token.value());
break;
default:
out << static_cast<char>(token.type());
break;
}
return out;
}
} // namespace pp

Просмотреть файл

@ -0,0 +1,44 @@
//
// Copyright (c) 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_PREPROCESSOR_TOKEN_H_
#define COMPILER_PREPROCESSOR_TOKEN_H_
#include <string>
#include <vector>
namespace pp
{
class Token
{
public:
typedef int Location;
static Location encodeLocation(int line, int file);
static void decodeLocation(Location loc, int* line, int* file);
// Takes ownership of string.
Token(Location location, int type, std::string* value);
~Token();
Location location() const { return mLocation; }
int type() const { return mType; }
const std::string* value() const { return mValue; }
private:
Location mLocation;
int mType;
std::string* mValue;
};
typedef std::vector<Token*> TokenVector;
typedef TokenVector::const_iterator TokenIterator;
extern std::ostream& operator<<(std::ostream& out, const Token& token);
} // namepsace pp
#endif // COMPILER_PREPROCESSOR_TOKEN_H_

Просмотреть файл

@ -0,0 +1,27 @@
#!/bin/bash
# Copyright (c) 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.
# Generates GLSL ES preprocessor - pp_lex.cpp, pp_tab.h, and pp_tab.cpp
run_flex()
{
input_file=$script_dir/$1.l
output_source=$script_dir/$1_lex.cpp
flex --noline --nounistd --outfile=$output_source $input_file
}
run_bison()
{
input_file=$script_dir/$1.y
output_header=$script_dir/$1_tab.h
output_source=$script_dir/$1_tab.cpp
bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file
}
script_dir=$(dirname $0)
# Generate preprocessor
run_flex pp
run_bison pp

Просмотреть файл

@ -0,0 +1,162 @@
/*
//
// 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.
//
This file contains the Lex specification for GLSL ES preprocessor.
Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
http://msdn.microsoft.com/en-us/library/2scxys89.aspx
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
*/
%top{
//
// Copyright (c) 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.
//
// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
}
%{
#include "compiler/debug.h"
#include "Context.h"
#include "pp_tab.h"
#include "Preprocessor.h"
#define YY_USER_ACTION \
do { \
yylloc->first_line = yylineno; \
yylloc->first_column = yycolumn + 1; \
yycolumn += yyleng; \
} while(0);
#define YY_INPUT(buf, result, maxSize) \
result = readInput(yyextra, buf, maxSize);
static int readInput(pp::Context* context, char* buf, int maxSize);
%}
%option noyywrap nounput never-interactive
%option yylineno reentrant bison-bridge bison-locations
%option stack
%option prefix="pp"
%option extra-type="pp::Context*"
HSPACE [ \t]
HASH ^{HSPACE}*#{HSPACE}*
IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
PUNCTUATOR [][<>(){}.+-/*%^|&~=!:;,?]
DECIMAL_CONSTANT [1-9][0-9]*
OCTAL_CONSTANT 0[0-7]*
HEXADECIMAL_CONSTANT 0[xX][0-9a-fA-F]+
DIGIT [0-9]
EXPONENT_PART [eE][+-]?{DIGIT}+
FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
%%
{HASH} { return HASH; }
{HASH}define { return HASH_DEFINE_OBJ; }
{HASH}define{HSPACE}+/{IDENTIFIER}"(" { return HASH_DEFINE_FUNC; }
{HASH}undef { return HASH_UNDEF; }
{HASH}if { return HASH_IF; }
{HASH}ifdef { return HASH_IFDEF; }
{HASH}ifndef { return HASH_IFNDEF; }
{HASH}else { return HASH_ELSE; }
{HASH}elif { return HASH_ELIF; }
{HASH}endif { return HASH_ENDIF; }
"defined" { return DEFINED; }
{HASH}error { return HASH_ERROR; }
{HASH}pragma { return HASH_PRAGMA; }
{HASH}extension { return HASH_EXTENSION; }
{HASH}version { return HASH_VERSION; }
{HASH}line { return HASH_LINE; }
{IDENTIFIER} {
yylval->sval = new std::string(yytext, yyleng);
return IDENTIFIER;
}
{DECIMAL_CONSTANT}|{OCTAL_CONSTANT}|{HEXADECIMAL_CONSTANT} {
yylval->sval = new std::string(yytext, yyleng);
return INT_CONSTANT;
}
({DIGIT}+{EXPONENT_PART})|({FRACTIONAL_CONSTANT}{EXPONENT_PART}?) {
yylval->sval = new std::string(yytext, yyleng);
return FLOAT_CONSTANT;
}
{PUNCTUATOR} { return yytext[0]; }
{HSPACE}+ { return SPACE; }
\n {
++yylineno; yycolumn = 0;
return yytext[0];
}
<*><<EOF>> { yyterminate(); }
%%
int readInput(pp::Context* context, char* buf, int maxSize)
{
yyscan_t lexer = context->lexer;
ASSERT(lexer);
int nread = YY_NULL;
while (!context->input.eof() &&
(context->input.error() == pp::Input::kErrorNone) &&
(nread == YY_NULL))
{
int line = 0, file = 0;
pp::Token::decodeLocation(yyget_lineno(lexer), &line, &file);
file = context->input.stringIndex();
yyset_lineno(pp::Token::encodeLocation(line, file), lexer);
nread = context->input.read(buf, maxSize);
if (context->input.error() == pp::Input::kErrorUnexpectedEOF)
{
// TODO(alokp): Report error.
}
}
return nread;
}
namespace pp {
bool Preprocessor::initLexer(Context* context)
{
ASSERT(context->lexer == NULL);
yyscan_t lexer = 0;
if (yylex_init_extra(context, &lexer))
return false;
context->lexer = lexer;
yyrestart(0, lexer);
return true;
}
void Preprocessor::destroyLexer(Context* context)
{
ASSERT(context->lexer);
yylex_destroy(context->lexer);
context->lexer = 0;
}
} // namespace pp

Просмотреть файл

@ -0,0 +1,259 @@
/*
//
// Copyright (c) 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.
//
This file contains the Yacc grammar for GLSL ES preprocessor.
Based on Microsoft Visual Studio 2010 Preprocessor Grammar:
http://msdn.microsoft.com/en-us/library/2scxys89.aspx
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glsl_parser.sh,
WHICH GENERATES THE GLSL ES PARSER.
*/
%{
//
// Copyright (c) 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.
//
// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT!
#include "Context.h"
#include "Preprocessor.h"
#define YYLEX_PARAM context->lexer
#define YYDEBUG 1
%}
%pure-parser
%name-prefix="pp"
%locations
%parse-param {pp::Context* context}
%union {
int ival;
std::string* sval;
std::vector<std::string*>* slist;
pp::Token* tval;
pp::TokenVector* tlist;
}
%{
extern int yylex(YYSTYPE* lvalp, YYLTYPE* llocp, void* lexer);
static void yyerror(YYLTYPE* llocp,
pp::Context* context,
const char* reason);
static void defineMacro(pp::Context* context,
YYLTYPE* llocp,
pp::Macro::Type type,
const std::string* identifier,
std::vector<std::string*>* parameters,
pp::TokenVector* replacements);
static void undefineMacro(pp::Context* context, const std::string* identifier);
static bool isMacroDefined(pp::Context* context, const std::string* identifier);
static void pushConditionalBlock(pp::Context* context, bool condition);
static void popConditionalBlock(pp::Context* context);
%}
%token HASH HASH_DEFINE_OBJ HASH_DEFINE_FUNC HASH_UNDEF
%token HASH_IF HASH_IFDEF HASH_IFNDEF HASH_ELSE HASH_ELIF HASH_ENDIF DEFINED
%token HASH_ERROR HASH_PRAGMA HASH_EXTENSION HASH_VERSION HASH_LINE
%token SPACE
%token <sval> INT_CONSTANT FLOAT_CONSTANT IDENTIFIER
%type <ival> operator
%type <slist> parameter_list
%type <tval> conditional_token token
%type <tlist> text_line replacement_token_list conditional_token_list token_list
%%
input
: /* empty */
| input line
;
line
: text_line {
// TODO(alokp): Expand macros.
pp::TokenVector* out = context->output;
out->insert(out->end(), $1->begin(), $1->end());
delete $1;
}
| control_line
;
text_line
: '\n' { $$ = NULL; }
| token_list '\n' { $$ = $1; }
;
control_line
: HASH '\n'
| HASH_DEFINE_OBJ IDENTIFIER replacement_token_list '\n' {
defineMacro(context, & @2, pp::Macro::kTypeObj, $2, NULL, $3);
}
| HASH_DEFINE_FUNC IDENTIFIER '(' parameter_list ')' replacement_token_list '\n' {
defineMacro(context, & @2, pp::Macro::kTypeFunc, $2, $4, $6);
}
| HASH_UNDEF IDENTIFIER '\n' {
undefineMacro(context, $2);
}
| HASH_IF conditional_token_list '\n' {
pushConditionalBlock(context, $2 ? true : false);
}
| HASH_IFDEF IDENTIFIER '\n' {
pushConditionalBlock(context, isMacroDefined(context, $2));
}
| HASH_IFNDEF IDENTIFIER '\n' {
pushConditionalBlock(context, !isMacroDefined(context, $2));
}
| HASH_ELIF conditional_token_list '\n' {
}
| HASH_ELSE '\n' {
}
| HASH_ENDIF '\n' {
popConditionalBlock(context);
}
| HASH_ERROR '\n'
| HASH_PRAGMA '\n'
| HASH_EXTENSION '\n'
| HASH_VERSION '\n'
| HASH_LINE '\n'
;
replacement_token_list
: /* empty */ { $$ = NULL }
| token_list
;
conditional_token_list
: conditional_token {
$$ = new pp::TokenVector;
$$->push_back($1);
}
| conditional_token_list conditional_token {
$$ = $1;
$$->push_back($2);
}
;
conditional_token
: DEFINED IDENTIFIER {
}
| DEFINED '(' IDENTIFIER ')' {
}
| token
;
parameter_list
: /* empty */ { $$ = NULL; }
| IDENTIFIER {
$$ = new std::vector<std::string*>();
$$->push_back($1);
}
| parameter_list ',' IDENTIFIER {
$$ = $1;
$$->push_back($3);
}
;
token_list
: token {
$$ = new pp::TokenVector;
$$->push_back($1);
}
| token_list token {
$$ = $1;
$$->push_back($2);
}
;
token
: operator {
$$ = new pp::Token(@1.first_line, $1, NULL);
}
| SPACE {
$$ = new pp::Token(@1.first_line, SPACE, NULL);
}
| INT_CONSTANT {
$$ = new pp::Token(@1.first_line, INT_CONSTANT, $1);
}
| FLOAT_CONSTANT {
$$ = new pp::Token(@1.first_line, FLOAT_CONSTANT, $1);
}
| IDENTIFIER {
$$ = new pp::Token(@1.first_line, IDENTIFIER, $1);
}
;
operator
: '[' { $$ = '['; }
| ']' { $$ = ']'; }
| '<' { $$ = '<'; }
| '>' { $$ = '>'; }
| '(' { $$ = '('; }
| ')' { $$ = ')'; }
| '{' { $$ = '{'; }
| '}' { $$ = '}'; }
| '.' { $$ = '.'; }
| '+' { $$ = '+'; }
| '-' { $$ = '-'; }
| '/' { $$ = '/'; }
| '*' { $$ = '*'; }
| '%' { $$ = '%'; }
| '^' { $$ = '^'; }
| '|' { $$ = '|'; }
| '&' { $$ = '&'; }
| '~' { $$ = '~'; }
| '=' { $$ = '='; }
| '!' { $$ = '!'; }
| ':' { $$ = ':'; }
| ';' { $$ = ';'; }
| ',' { $$ = ','; }
| '?' { $$ = '?'; }
;
%%
void yyerror(YYLTYPE* llocp, pp::Context* context, const char* reason)
{
}
void defineMacro(pp::Context* context,
YYLTYPE* llocp,
pp::Macro::Type type,
const std::string* identifier,
std::vector<std::string*>* parameters,
pp::TokenVector* replacements)
{
}
void undefineMacro(pp::Context* context, const std::string* identifier)
{
}
bool isMacroDefined(pp::Context* context, const std::string* identifier)
{
return false;
}
void pushConditionalBlock(pp::Context* context, bool condition)
{
}
void popConditionalBlock(pp::Context* context)
{
}
namespace pp {
bool Preprocessor::parse(Context* context)
{
yydebug = 1;
return yyparse(context) == 0 ? true : false;
}
} // namespace pp

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,122 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
HASH = 258,
HASH_DEFINE_OBJ = 259,
HASH_DEFINE_FUNC = 260,
HASH_UNDEF = 261,
HASH_IF = 262,
HASH_IFDEF = 263,
HASH_IFNDEF = 264,
HASH_ELSE = 265,
HASH_ELIF = 266,
HASH_ENDIF = 267,
DEFINED = 268,
HASH_ERROR = 269,
HASH_PRAGMA = 270,
HASH_EXTENSION = 271,
HASH_VERSION = 272,
HASH_LINE = 273,
SPACE = 274,
INT_CONSTANT = 275,
FLOAT_CONSTANT = 276,
IDENTIFIER = 277
};
#endif
/* Tokens. */
#define HASH 258
#define HASH_DEFINE_OBJ 259
#define HASH_DEFINE_FUNC 260
#define HASH_UNDEF 261
#define HASH_IF 262
#define HASH_IFDEF 263
#define HASH_IFNDEF 264
#define HASH_ELSE 265
#define HASH_ELIF 266
#define HASH_ENDIF 267
#define DEFINED 268
#define HASH_ERROR 269
#define HASH_PRAGMA 270
#define HASH_EXTENSION 271
#define HASH_VERSION 272
#define HASH_LINE 273
#define SPACE 274
#define INT_CONSTANT 275
#define FLOAT_CONSTANT 276
#define IDENTIFIER 277
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
int ival;
std::string* sval;
std::vector<std::string*>* slist;
pp::Token* tval;
pp::TokenVector* tlist;
}
/* Line 1489 of yacc.c. */
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif

Просмотреть файл

@ -0,0 +1,13 @@
//
// Copyright (c) 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_PREPROCESSOR_TOKEN_TYPE_H_
#define COMPILER_PREPROCESSOR_TOKEN_TYPE_H_
#include "pp_tab.h"
#endif // COMPILER_PREPROCESSOR_TOKEN_TYPE_H_

Просмотреть файл

@ -11,6 +11,7 @@
#include "libEGL/Display.h"
#include <algorithm>
#include <map>
#include <vector>
#include "common/debug.h"
@ -31,7 +32,41 @@
namespace egl
{
Display::Display(HDC deviceContext) : mDc(deviceContext)
namespace
{
typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
DisplayMap displays;
}
egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
{
if (displays.find(displayId) != displays.end())
{
return displays[displayId];
}
egl::Display *display = NULL;
if (displayId == EGL_DEFAULT_DISPLAY)
{
display = new egl::Display(displayId, (HDC)NULL, false);
}
else if (displayId == EGL_SOFTWARE_DISPLAY_ANGLE)
{
display = new egl::Display(displayId, (HDC)NULL, true);
}
else
{
// FIXME: Check if displayId is a valid display device context
display = new egl::Display(displayId, (HDC)displayId, false);
}
displays[displayId] = display;
return display;
}
Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext)
{
mD3d9Module = NULL;
@ -51,11 +86,20 @@ Display::Display(HDC deviceContext) : mDc(deviceContext)
mMinSwapInterval = 1;
mMaxSwapInterval = 1;
mSoftwareDevice = software;
mDisplayId = displayId;
}
Display::~Display()
{
terminate();
DisplayMap::iterator thisDisplay = displays.find(mDisplayId);
if (thisDisplay != displays.end())
{
displays.erase(thisDisplay);
}
}
bool Display::initialize()
@ -65,7 +109,14 @@ bool Display::initialize()
return true;
}
mD3d9Module = GetModuleHandle(TEXT("d3d9.dll"));
if (mSoftwareDevice)
{
mD3d9Module = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
}
else
{
mD3d9Module = GetModuleHandle(TEXT("d3d9.dll"));
}
if (mD3d9Module == NULL)
{
terminate();
@ -141,6 +192,8 @@ bool Display::initialize()
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);}
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);}
mD3d9->GetAdapterIdentifier(mAdapter, 0, &mAdapterIdentifier);
const D3DFORMAT renderTargetFormats[] =
{
D3DFMT_A1R5G5B5,
@ -295,8 +348,11 @@ void Display::startScene()
if (!mSceneStarted)
{
long result = mDevice->BeginScene();
ASSERT(SUCCEEDED(result));
mSceneStarted = true;
if (SUCCEEDED(result)) {
// This is defensive checking against the device being
// lost at unexpected times.
mSceneStarted = true;
}
}
}
@ -304,8 +360,9 @@ void Display::endScene()
{
if (mSceneStarted)
{
long result = mDevice->EndScene();
ASSERT(SUCCEEDED(result));
// EndScene can fail if the device was lost, for example due
// to a TDR during a draw call.
mDevice->EndScene();
mSceneStarted = false;
}
}
@ -688,6 +745,11 @@ D3DCAPS9 Display::getDeviceCaps()
return mDeviceCaps;
}
D3DADAPTER_IDENTIFIER9 *Display::getAdapterIdentifier()
{
return &mAdapterIdentifier;
}
bool Display::isDeviceLost()
{
if (mDeviceEx)
@ -711,7 +773,7 @@ void Display::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
}
}
bool Display::getCompressedTextureSupport()
bool Display::getDXT1TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
@ -719,6 +781,22 @@ bool Display::getCompressedTextureSupport()
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1));
}
bool Display::getDXT3TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
}
bool Display::getDXT5TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5));
}
bool Display::getFloatTextureSupport(bool *filtering, bool *renderable)
{
D3DDISPLAYMODE currentDisplayMode;
@ -845,6 +923,12 @@ D3DPRESENT_PARAMETERS Display::getDefaultPresentParameters()
void Display::initExtensionString()
{
mExtensionString += "EGL_ANGLE_query_surface_pointer ";
HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
if (swiftShader)
{
mExtensionString += "EGL_ANGLE_software_display ";
}
if (isD3d9ExDevice()) {
mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle ";

Просмотреть файл

@ -29,8 +29,6 @@ namespace egl
class Display
{
public:
Display(HDC deviceContext);
~Display();
bool initialize();
@ -39,6 +37,8 @@ class Display
virtual void startScene();
virtual void endScene();
static egl::Display *getDisplay(EGLNativeDisplayType displayId);
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
@ -60,9 +60,12 @@ class Display
virtual IDirect3DDevice9 *getDevice();
virtual D3DCAPS9 getDeviceCaps();
virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier();
bool isDeviceLost();
virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
virtual bool getCompressedTextureSupport();
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
virtual bool getEventQuerySupport();
virtual bool getFloatTextureSupport(bool *filtering, bool *renderable);
virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable);
@ -78,8 +81,11 @@ class Display
private:
DISALLOW_COPY_AND_ASSIGN(Display);
Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software);
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
EGLNativeDisplayType mDisplayId;
const HDC mDc;
HMODULE mD3d9Module;
@ -91,11 +97,13 @@ class Display
IDirect3DDevice9 *mDevice;
IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported.
D3DCAPS9 mDeviceCaps;
D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
HWND mDeviceWindow;
bool mSceneStarted;
EGLint mMaxSwapInterval;
EGLint mMinSwapInterval;
bool mSoftwareDevice;
typedef std::set<Surface*> SurfaceSet;
SurfaceSet mSurfaceSet;

Просмотреть файл

@ -98,6 +98,7 @@ CPPSRCS = \
ValidateLimitations.cpp \
ForLoopUnroll.cpp \
MapLongVariableNames.cpp \
BuiltInFunctionEmulator.cpp \
$(NULL)
# flex/yacc generated files
@ -113,6 +114,9 @@ CPPSRCS += \
TranslatorHLSL.cpp \
UnfoldSelect.cpp \
SearchSymbol.cpp \
OutputESSL.cpp \
OutputGLSLBase.cpp \
TranslatorESSL.cpp \
$(NULL)
CSRCS = \
@ -141,6 +145,7 @@ CPPSRCS += \
$(NULL)
DEFFILE = $(srcdir)/libEGL.def
RCFILE = $(srcdir)/libEGL.rc
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -22,6 +22,23 @@
namespace egl
{
namespace
{
const int versionWindowsVista = MAKEWORD(0x00, 0x06);
const int versionWindows7 = MAKEWORD(0x01, 0x06);
// Return the version of the operating system in a format suitable for ordering
// comparison.
int getComparableOSVersion()
{
DWORD version = GetVersion();
int majorVersion = LOBYTE(LOWORD(version));
int minorVersion = HIBYTE(LOWORD(version));
return MAKEWORD(minorVersion, majorVersion);
}
}
Surface::Surface(Display *display, const Config *config, HWND window)
: mDisplay(display), mConfig(config), mWindow(window)
{
@ -78,7 +95,7 @@ bool Surface::initialize()
// Modify present parameters for this window, if we are composited,
// to minimize the amount of queuing done by DWM between our calls to
// present and the actual screen.
if (mWindow && (LOWORD(GetVersion()) >= 0x60)) {
if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) {
BOOL isComposited;
HRESULT result = DwmIsCompositionEnabled(&isComposited);
if (SUCCEEDED(result) && isComposited) {
@ -165,7 +182,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
D3DPRESENT_PARAMETERS presentParameters = {0};
HRESULT result;
bool useFlipEx = (LOWORD(GetVersion()) >= 0x61) && mDisplay->isD3d9ExDevice();
bool useFlipEx = (getComparableOSVersion() >= versionWindows7) && mDisplay->isD3d9ExDevice();
// FlipEx causes unseemly stretching when resizing windows AND when one
// draws outside of the WM_PAINT callback. While this is seldom a problem in
@ -215,7 +232,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
if (FAILED(result))
{
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_INVALIDCALL);
ERR("Could not create additional swap chains or offscreen surfaces: %08lX", result);
release();

Просмотреть файл

@ -99,18 +99,7 @@ EGLDisplay __stdcall eglGetDisplay(EGLNativeDisplayType display_id)
try
{
// FIXME: Return the same EGLDisplay handle when display_id already created a display
if (display_id == EGL_DEFAULT_DISPLAY)
{
return new egl::Display((HDC)NULL);
}
else
{
// FIXME: Check if display_id is a valid display device context
return new egl::Display((HDC)display_id);
}
return egl::Display::getDisplay(display_id);
}
catch(std::bad_alloc&)
{

Просмотреть файл

@ -12,6 +12,9 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
@ -144,7 +147,7 @@
AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib"
LinkIncremental="1"
ModuleDefinitionFile="libEGL.def"
DelayLoadDLLs="dwmapi.lib"
DelayLoadDLLs="dwmapi.dll"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
@ -176,6 +179,168 @@
CommandLine="@echo on&#x0D;&#x0A;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(ProjectDir)/..; $(ProjectDir)/../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib"
LinkIncremental="2"
ModuleDefinitionFile="libEGL.def"
DelayLoadDLLs="dwmapi.dll"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="@echo on&#x0D;&#x0A;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
AdditionalIncludeDirectories="$(ProjectDir)/..; $(ProjectDir)/../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBEGL_EXPORTS;_CRT_SECURE_NO_DEPRECATE;NOMINMAX;_SECURE_SCL=0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib"
LinkIncremental="1"
ModuleDefinitionFile="libEGL.def"
DelayLoadDLLs="dwmapi.dll"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="@echo on&#x0D;&#x0A;mkdir &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.dll&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\libEGL.lib&quot; &quot;$(ProjectDir)..\..\lib\$(ConfigurationName)\&quot;&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
<References>
</References>

Просмотреть файл

@ -156,8 +156,11 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext) : m
mHasBeenCurrent = false;
mSupportsCompressedTextures = false;
mSupportsDXT1Textures = false;
mSupportsDXT3Textures = false;
mSupportsDXT5Textures = false;
mSupportsEventQueries = false;
mNumCompressedTextureFormats = 0;
mMaxSupportedSamples = 0;
mMaskedClearSavedState = NULL;
markAllStateDirty();
@ -280,7 +283,9 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mMaxSupportedSamples = max;
mSupportsEventQueries = display->getEventQuerySupport();
mSupportsCompressedTextures = display->getCompressedTextureSupport();
mSupportsDXT1Textures = display->getDXT1TextureSupport();
mSupportsDXT3Textures = display->getDXT3TextureSupport();
mSupportsDXT5Textures = display->getDXT5TextureSupport();
mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloatLinearFilter, &mSupportsFloatRenderableTextures);
mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSupportsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures);
mSupportsLuminanceTextures = display->getLuminanceTextureSupport();
@ -288,7 +293,22 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16);
mNumCompressedTextureFormats = 0;
if (supportsDXT1Textures())
{
mNumCompressedTextureFormats += 2;
}
if (supportsDXT3Textures())
{
mNumCompressedTextureFormats += 1;
}
if (supportsDXT5Textures())
{
mNumCompressedTextureFormats += 1;
}
initExtensionString();
initRendererString();
mState.viewportX = 0;
mState.viewportY = 0;
@ -1240,18 +1260,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
case GL_MAX_TEXTURE_SIZE: *params = getMaximumTextureDimension(); break;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = getMaximumCubeTextureDimension(); break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
{
if (supportsCompressedTextures())
{
// at current, only GL_COMPRESSED_RGB_S3TC_DXT1_EXT and
// GL_COMPRESSED_RGBA_S3TC_DXT1_EXT are supported
*params = 2;
}
else
{
*params = 0;
}
}
params[0] = mNumCompressedTextureFormats;
break;
case GL_MAX_SAMPLES_ANGLE:
{
@ -1307,10 +1316,18 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break;
case GL_COMPRESSED_TEXTURE_FORMATS:
{
if (supportsCompressedTextures())
if (supportsDXT1Textures())
{
params[0] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
params[1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
*params++ = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
}
if (supportsDXT3Textures())
{
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
}
if (supportsDXT5Textures())
{
*params++ = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
}
}
break;
@ -1422,7 +1439,12 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
// application.
switch (pname)
{
case GL_COMPRESSED_TEXTURE_FORMATS: /* no compressed texture formats are supported */
case GL_COMPRESSED_TEXTURE_FORMATS:
{
*type = GL_INT;
*numParams = mNumCompressedTextureFormats;
}
break;
case GL_SHADER_BINARY_FORMATS:
{
*type = GL_INT;
@ -1737,6 +1759,15 @@ void Context::applyState(GLenum drawMode)
GLint alwaysFront = !isTriangleMode(drawMode);
programObject->setUniform1iv(pointsOrLines, 1, &alwaysFront);
egl::Display *display = getDisplay();
D3DADAPTER_IDENTIFIER9 *identifier = display->getAdapterIdentifier();
bool zeroColorMaskAllowed = identifier->VendorId != 0x1002;
// Apparently some ATI cards have a bug where a draw with a zero color
// write mask can cause later draws to have incorrect results. Instead,
// set a nonzero color write mask but modify the blend state so that no
// drawing is done.
// http://code.google.com/p/angleproject/issues/detail?id=169
if (mCullStateDirty || mFrontFaceDirty)
{
if (mState.cullFace)
@ -1766,6 +1797,12 @@ void Context::applyState(GLenum drawMode)
mDepthStateDirty = false;
}
if (!zeroColorMaskAllowed && (mMaskStateDirty || mBlendStateDirty))
{
mBlendStateDirty = true;
mMaskStateDirty = true;
}
if (mBlendStateDirty)
{
if (mState.blend)
@ -1874,8 +1911,22 @@ void Context::applyState(GLenum drawMode)
if (mMaskStateDirty)
{
device->SetRenderState(D3DRS_COLORWRITEENABLE, es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen,
mState.colorMaskBlue, mState.colorMaskAlpha));
int colorMask = es2dx::ConvertColorMask(mState.colorMaskRed, mState.colorMaskGreen,
mState.colorMaskBlue, mState.colorMaskAlpha);
if (colorMask == 0 && !zeroColorMaskAllowed)
{
// Enable green channel, but set blending so nothing will be drawn.
device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_GREEN);
device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
}
else
{
device->SetRenderState(D3DRS_COLORWRITEENABLE, colorMask);
}
device->SetRenderState(D3DRS_ZWRITEENABLE, mState.depthMask ? TRUE : FALSE);
mMaskStateDirty = false;
@ -2129,8 +2180,11 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
switch (result)
{
// It turns out that D3D will sometimes produce more error
// codes than those documented.
case D3DERR_DRIVERINTERNALERROR:
case D3DERR_DEVICELOST:
case D3DERR_DEVICEHUNG:
return error(GL_OUT_OF_MEMORY);
default:
UNREACHABLE();
@ -2854,7 +2908,7 @@ void Context::drawClosingLine(unsigned int first, unsigned int last)
{
device->SetIndices(mClosingIB->getBuffer());
device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, 2, offset, 1);
device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, last, offset, 1);
}
else
{
@ -3021,9 +3075,19 @@ bool Context::supportsEventQueries() const
return mSupportsEventQueries;
}
bool Context::supportsCompressedTextures() const
bool Context::supportsDXT1Textures() const
{
return mSupportsCompressedTextures;
return mSupportsDXT1Textures;
}
bool Context::supportsDXT3Textures() const
{
return mSupportsDXT3Textures;
}
bool Context::supportsDXT5Textures() const
{
return mSupportsDXT5Textures;
}
bool Context::supportsFloatTextures() const
@ -3298,11 +3362,21 @@ void Context::initExtensionString()
mExtensionString += "GL_NV_fence ";
}
if (supportsCompressedTextures())
if (supportsDXT1Textures())
{
mExtensionString += "GL_EXT_texture_compression_dxt1 ";
}
if (supportsDXT3Textures())
{
mExtensionString += "GL_ANGLE_texture_compression_dxt3 ";
}
if (supportsDXT5Textures())
{
mExtensionString += "GL_ANGLE_texture_compression_dxt5 ";
}
if (supportsFloatTextures())
{
mExtensionString += "GL_OES_texture_float ";
@ -3350,6 +3424,21 @@ const char *Context::getExtensionString() const
return mExtensionString.c_str();
}
void Context::initRendererString()
{
egl::Display *display = getDisplay();
D3DADAPTER_IDENTIFIER9 *identifier = display->getAdapterIdentifier();
mRendererString = "ANGLE (";
mRendererString += identifier->Description;
mRendererString += ")";
}
const char *Context::getRendererString() const
{
return mRendererString.c_str();
}
void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask)

Просмотреть файл

@ -436,8 +436,11 @@ class Context
GLsizei getMaxSupportedSamples() const;
int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
const char *getExtensionString() const;
const char *getRendererString() const;
bool supportsEventQueries() const;
bool supportsCompressedTextures() const;
bool supportsDXT1Textures() const;
bool supportsDXT3Textures() const;
bool supportsDXT5Textures() const;
bool supportsFloatTextures() const;
bool supportsFloatLinearFilter() const;
bool supportsFloatRenderableTextures() const;
@ -478,6 +481,9 @@ class Context
bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode);
void initExtensionString();
void initRendererString();
const egl::Config *const mConfig;
State mState;
@ -493,8 +499,8 @@ class Context
FenceMap mFenceMap;
HandleAllocator mFenceHandleAllocator;
void initExtensionString();
std::string mExtensionString;
std::string mRendererString;
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
@ -532,7 +538,9 @@ class Context
std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples;
bool mSupportsEventQueries;
bool mSupportsCompressedTextures;
bool mSupportsDXT1Textures;
bool mSupportsDXT3Textures;
bool mSupportsDXT5Textures;
bool mSupportsFloatTextures;
bool mSupportsFloatLinearFilter;
bool mSupportsFloatRenderableTextures;
@ -542,6 +550,7 @@ class Context
bool mSupportsLuminanceTextures;
bool mSupportsLuminanceAlphaTextures;
bool mSupports32bitIndices;
int mNumCompressedTextureFormats;
// state caching flags
bool mClearStateDirty;

Просмотреть файл

@ -98,6 +98,7 @@ CPPSRCS = \
ValidateLimitations.cpp \
ForLoopUnroll.cpp \
MapLongVariableNames.cpp \
BuiltInFunctionEmulator.cpp \
$(NULL)
# flex/yacc generated files
@ -113,6 +114,9 @@ CPPSRCS += \
TranslatorHLSL.cpp \
UnfoldSelect.cpp \
SearchSymbol.cpp \
OutputESSL.cpp \
OutputGLSLBase.cpp \
TranslatorESSL.cpp \
$(NULL)
CSRCS = \
@ -153,7 +157,7 @@ CPPSRCS += \
$(NULL)
DEFFILE = $(srcdir)/libGLESv2.def
RCFILE = $(srcdir)/libGLESv2.rc
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -36,7 +36,7 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso
{
ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
Context *context = getContext();
Context *context = getContext();
resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS;
resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS;
@ -48,8 +48,8 @@ Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mReso
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
resources.OES_standard_derivatives = 1;
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources);
mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, &resources);
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
mVertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
}
}

Просмотреть файл

@ -14,9 +14,9 @@
#include <algorithm>
#if _MSC_VER <= 1400
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#if _MSC_VER <= 1400
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#endif
#include <intrin.h>
@ -55,6 +55,8 @@ bool Texture::Image::isRenderable() const
case D3DFMT_L8:
case D3DFMT_A8L8:
case D3DFMT_DXT1:
case D3DFMT_DXT3:
case D3DFMT_DXT5:
return false;
case D3DFMT_A8R8G8B8:
case D3DFMT_X8R8G8B8:
@ -75,6 +77,14 @@ D3DFORMAT Texture::Image::getD3DFormat() const
{
return D3DFMT_DXT1;
}
else if (format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE)
{
return D3DFMT_DXT3;
}
else if (format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
{
return D3DFMT_DXT5;
}
else if (type == GL_FLOAT)
{
return D3DFMT_A32B32G32R32F;
@ -773,6 +783,132 @@ void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs
}
void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const {
switch (getD3DFormat())
{
case D3DFMT_DXT1:
loadDXT1ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break;
case D3DFMT_DXT3:
loadDXT3ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break;
case D3DFMT_DXT5:
loadDXT5ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break;
}
}
static void FlipCopyDXT1BlockFull(const unsigned int* source, unsigned int* dest) {
// A DXT1 block layout is:
// [0-1] color0.
// [2-3] color1.
// [4-7] color bitmap, 2 bits per pixel.
// So each of the 4-7 bytes represents one line, flipping a block is just
// flipping those bytes.
// First 32-bits is two RGB565 colors shared by tile and does not need to be modified.
dest[0] = source[0];
// Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors. All rows should be flipped.
dest[1] = (source[1] >> 24) |
((source[1] << 8) & 0x00FF0000) |
((source[1] >> 8) & 0x0000FF00) |
(source[1] << 24);
}
// Flips the first 2 lines of a DXT1 block in the y direction.
static void FlipCopyDXT1BlockHalf(const unsigned int* source, unsigned int* dest) {
// See layout above.
dest[0] = source[0];
dest[1] = ((source[1] << 8) & 0x0000FF00) |
((source[1] >> 8) & 0x000000FF);
}
// Flips a full DXT3 block in the y direction.
static void FlipCopyDXT3BlockFull(const unsigned int* source, unsigned int* dest) {
// A DXT3 block layout is:
// [0-7] alpha bitmap, 4 bits per pixel.
// [8-15] a DXT1 block.
// First and Second 32 bits are 4bit per pixel alpha and need to be flipped.
dest[0] = (source[1] >> 16) | (source[1] << 16);
dest[1] = (source[0] >> 16) | (source[0] << 16);
// And flip the DXT1 block using the above function.
FlipCopyDXT1BlockFull(source + 2, dest + 2);
}
// Flips the first 2 lines of a DXT3 block in the y direction.
static void FlipCopyDXT3BlockHalf(const unsigned int* source, unsigned int* dest) {
// See layout above.
dest[0] = (source[1] >> 16) | (source[1] << 16);
FlipCopyDXT1BlockHalf(source + 2, dest + 2);
}
// Flips a full DXT5 block in the y direction.
static void FlipCopyDXT5BlockFull(const unsigned int* source, unsigned int* dest) {
// A DXT5 block layout is:
// [0] alpha0.
// [1] alpha1.
// [2-7] alpha bitmap, 3 bits per pixel.
// [8-15] a DXT1 block.
// The alpha bitmap doesn't easily map lines to bytes, so we have to
// interpret it correctly. Extracted from
// http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt :
//
// The 6 "bits" bytes of the block are decoded into one 48-bit integer:
//
// bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 +
// 256 * (bits_4 + 256 * bits_5))))
//
// bits is a 48-bit unsigned integer, from which a three-bit control code
// is extracted for a texel at location (x,y) in the block using:
//
// code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0]
//
// where bit 47 is the most significant and bit 0 is the least
// significant bit.
const unsigned char* sourceBytes = static_cast<const unsigned char*>(static_cast<const void*>(source));
unsigned char* destBytes = static_cast<unsigned char*>(static_cast<void*>(dest));
unsigned int line_0_1 = sourceBytes[2] + 256 * (sourceBytes[3] + 256 * sourceBytes[4]);
unsigned int line_2_3 = sourceBytes[5] + 256 * (sourceBytes[6] + 256 * sourceBytes[7]);
// swap lines 0 and 1 in line_0_1.
unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) |
((line_0_1 & 0xfff000) >> 12);
// swap lines 2 and 3 in line_2_3.
unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) |
((line_2_3 & 0xfff000) >> 12);
destBytes[0] = sourceBytes[0];
destBytes[1] = sourceBytes[1];
destBytes[2] = line_3_2 & 0xff;
destBytes[3] = (line_3_2 & 0xff00) >> 8;
destBytes[4] = (line_3_2 & 0xff0000) >> 16;
destBytes[5] = line_1_0 & 0xff;
destBytes[6] = (line_1_0 & 0xff00) >> 8;
destBytes[7] = (line_1_0 & 0xff0000) >> 16;
// And flip the DXT1 block using the above function.
FlipCopyDXT1BlockFull(source + 2, dest + 2);
}
// Flips the first 2 lines of a DXT5 block in the y direction.
static void FlipCopyDXT5BlockHalf(const unsigned int* source, unsigned int* dest) {
// See layout above.
const unsigned char* sourceBytes = static_cast<const unsigned char*>(static_cast<const void*>(source));
unsigned char* destBytes = static_cast<unsigned char*>(static_cast<void*>(dest));
unsigned int line_0_1 = sourceBytes[2] + 256 * (sourceBytes[3] + 256 * sourceBytes[4]);
unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) |
((line_0_1 & 0xfff000) >> 12);
destBytes[0] = sourceBytes[0];
destBytes[1] = sourceBytes[1];
destBytes[2] = line_1_0 & 0xff;
destBytes[3] = (line_1_0 & 0xff00) >> 8;
destBytes[4] = (line_1_0 & 0xff0000) >> 16;
FlipCopyDXT1BlockHalf(source + 2, dest + 2);
}
void Texture::loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const
{
ASSERT(xoffset % 4 == 0);
@ -784,29 +920,24 @@ void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei widt
const unsigned int *source = reinterpret_cast<const unsigned int*>(input);
unsigned int *dest = reinterpret_cast<unsigned int*>(output);
// Round width up in case it is less than 4.
int blocksAcross = (width + 3) / 4;
int intsAcross = blocksAcross * 2;
switch (height)
{
case 1:
// Round width up in case it is 1.
for (int x = 0; x < (width + 1) / 2; x += 2)
for (int x = 0; x < intsAcross; x += 2)
{
// First 32-bits is two RGB565 colors shared by tile and does not need to be modified.
// just copy the block
dest[x] = source[x];
// Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors, the last 3 rows being unused. No flipping should occur.
dest[x + 1] = source[x + 1];
}
break;
case 2:
// Round width up in case it is 1.
for (int x = 0; x < (width + 1) / 2; x += 2)
for (int x = 0; x < intsAcross; x += 2)
{
// First 32-bits is two RGB565 colors shared by tile and does not need to be modified.
dest[x] = source[x];
// Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors, the last 2 rows being unused. Only the top 2 rows should be flipped.
dest[x + 1] = ((source[x + 1] << 8) & 0x0000FF00) |
((source[x + 1] >> 8) & 0x000000FF);
FlipCopyDXT1BlockHalf(source + x, dest + x);
}
break;
default:
@ -816,17 +947,109 @@ void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei widt
const unsigned int *source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch);
unsigned int *dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 8);
// Round width up in case it is 1.
for (int x = 0; x < (width + 1) / 2; x += 2)
for (int x = 0; x < intsAcross; x += 2)
{
// First 32-bits is two RGB565 colors shared by tile and does not need to be modified.
dest[x] = source[x];
FlipCopyDXT1BlockFull(source + x, dest + x);
}
}
break;
}
}
// Second 32-bits contains 4 rows of 4 2-bit interpolants between the colors. All rows should be flipped.
dest[x + 1] = (source[x + 1] >> 24) |
((source[x + 1] << 8) & 0x00FF0000) |
((source[x + 1] >> 8) & 0x0000FF00) |
(source[x + 1] << 24);
void Texture::loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const
{
ASSERT(xoffset % 4 == 0);
ASSERT(yoffset % 4 == 0);
ASSERT(width % 4 == 0 || width == 2 || width == 1);
ASSERT(inputPitch % 16 == 0);
ASSERT(outputPitch % 16 == 0);
const unsigned int *source = reinterpret_cast<const unsigned int*>(input);
unsigned int *dest = reinterpret_cast<unsigned int*>(output);
// Round width up in case it is less than 4.
int blocksAcross = (width + 3) / 4;
int intsAcross = blocksAcross * 4;
switch (height)
{
case 1:
for (int x = 0; x < intsAcross; x += 4)
{
// just copy the block
dest[x] = source[x];
dest[x + 1] = source[x + 1];
dest[x + 2] = source[x + 2];
dest[x + 3] = source[x + 3];
}
break;
case 2:
for (int x = 0; x < intsAcross; x += 4)
{
FlipCopyDXT3BlockHalf(source + x, dest + x);
}
break;
default:
ASSERT(height % 4 == 0);
for (int y = 0; y < height / 4; ++y)
{
const unsigned int *source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch);
unsigned int *dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16);
for (int x = 0; x < intsAcross; x += 4)
{
FlipCopyDXT3BlockFull(source + x, dest + x);
}
}
break;
}
}
void Texture::loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const
{
ASSERT(xoffset % 4 == 0);
ASSERT(yoffset % 4 == 0);
ASSERT(width % 4 == 0 || width == 2 || width == 1);
ASSERT(inputPitch % 16 == 0);
ASSERT(outputPitch % 16 == 0);
const unsigned int *source = reinterpret_cast<const unsigned int*>(input);
unsigned int *dest = reinterpret_cast<unsigned int*>(output);
// Round width up in case it is less than 4.
int blocksAcross = (width + 3) / 4;
int intsAcross = blocksAcross * 4;
switch (height)
{
case 1:
for (int x = 0; x < intsAcross; x += 4)
{
// just copy the block
dest[x] = source[x];
dest[x + 1] = source[x + 1];
dest[x + 2] = source[x + 2];
dest[x + 3] = source[x + 3];
}
break;
case 2:
for (int x = 0; x < intsAcross; x += 4)
{
FlipCopyDXT5BlockHalf(source + x, dest + x);
}
break;
default:
ASSERT(height % 4 == 0);
for (int y = 0; y < height / 4; ++y)
{
const unsigned int *source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch);
unsigned int *dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + (y + yoffset) * outputPitch + xoffset * 16);
for (int x = 0; x < intsAcross; x += 4)
{
FlipCopyDXT5BlockFull(source + x, dest + x);
}
}
break;
@ -2261,6 +2484,9 @@ void TextureCubeMap::convertToRenderTarget()
return error(GL_OUT_OF_MEMORY);
}
source->Release();
dest->Release();
}
}
}

Просмотреть файл

@ -185,6 +185,12 @@ class Texture : public RefCountObject
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
static unsigned int issueSerial();

Просмотреть файл

@ -772,6 +772,8 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
default:
return error(GL_INVALID_ENUM);
@ -821,9 +823,27 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
return error(GL_INVALID_ENUM);
}
if (!context->supportsCompressedTextures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
switch (internalformat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (!context->supportsDXT1Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (!context->supportsDXT3Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (!context->supportsDXT5Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
default: UNREACHABLE();
}
if (imageSize != gl::ComputeCompressedSize(width, height, internalformat))
@ -897,6 +917,8 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
default:
return error(GL_INVALID_ENUM);
@ -916,9 +938,27 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
return error(GL_INVALID_VALUE);
}
if (!context->supportsCompressedTextures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the format switch has failed.
switch (format) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (!context->supportsDXT1Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (!context->supportsDXT3Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (!context->supportsDXT5Textures())
{
return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
}
break;
default: UNREACHABLE();
}
if (imageSize != gl::ComputeCompressedSize(width, height, format))
@ -929,7 +969,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
if (xoffset % 4 != 0 || yoffset % 4 != 0)
{
return error(GL_INVALID_OPERATION); // we wait to check the offsets until this point, because the multiple-of-four restriction
// does not exist unless DXT1 textures are supported.
// does not exist unless DXT textures are supported.
}
if (target == GL_TEXTURE_2D)
@ -1093,7 +1133,27 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (context->supportsCompressedTextures())
if (context->supportsDXT1Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (context->supportsDXT3Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (context->supportsDXT5Textures())
{
return error(GL_INVALID_OPERATION);
}
@ -1245,6 +1305,8 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return error(GL_INVALID_OPERATION);
default:
return error(GL_INVALID_OPERATION);
@ -3160,7 +3222,7 @@ const GLubyte* __stdcall glGetString(GLenum name)
case GL_VENDOR:
return (GLubyte*)"Google Inc.";
case GL_RENDERER:
return (GLubyte*)"ANGLE";
return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
case GL_VERSION:
return (GLubyte*)"OpenGL ES 2.0 (ANGLE "VERSION_STRING")";
case GL_SHADING_LANGUAGE_VERSION:
@ -4467,6 +4529,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
default:
return error(GL_INVALID_VALUE);
@ -4511,10 +4575,10 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
return error(GL_INVALID_ENUM);
}
if (format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
{
if (context->supportsCompressedTextures())
switch (format) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
if (context->supportsDXT1Textures())
{
return error(GL_INVALID_OPERATION);
}
@ -4522,6 +4586,29 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
if (context->supportsDXT3Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if (context->supportsDXT5Textures())
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
break;
default:
break;
}
if (type == GL_FLOAT)

Просмотреть файл

@ -8,10 +8,10 @@
#ifndef LIBGLESV2_MATHUTIL_H_
#define LIBGLESV2_MATHUTIL_H_
#if _MSC_VER <= 1400
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#if _MSC_VER <= 1400
#define _interlockedbittestandreset _interlockedbittestandreset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#define _interlockedbittestandset _interlockedbittestandset_NAME_CHANGED_TO_AVOID_MSVS2005_ERROR
#endif
#include <intrin.h>

Просмотреть файл

@ -200,18 +200,23 @@ GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format)
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return 16 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
default:
return 0;
}
return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
}
bool IsCompressed(GLenum format)
{
if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE ||
format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
{
return true;
}