Bug 696889 - Upgrade ANGLE to r802 - no review

This is syncing us with the ANGLE project at

   http://code.google.com/p/angleproject/

Also, with this new ANGLE revision, two WebGL conformance tests are now passing on windows so this patch removes them from failing_tests_windows.txt.

--HG--
rename : gfx/angle/angle-instrinsic-msvc2005.patch => gfx/angle/angle-intrinsic-msvc2005.patch
This commit is contained in:
Benoit Jacob 2011-10-25 08:58:43 -04:00
parent d81b4a6adc
commit 257620bd20
31 changed files with 815 additions and 651 deletions

View File

@ -3,11 +3,9 @@ conformance/context/premultiplyalpha-test.html
conformance/glsl/functions/glsl-function-atan.html
conformance/glsl/functions/glsl-function-atan-xy.html
conformance/glsl/functions/glsl-function-mod-gentype.html
conformance/glsl/misc/glsl-function-nodes.html
conformance/glsl/misc/glsl-long-variable-names.html
conformance/glsl/misc/shader-with-256-character-identifier.frag.html
conformance/glsl/misc/shader-with-long-line.html
conformance/glsl/variables/gl-frontfacing.html
conformance/reading/read-pixels-test.html
conformance/renderbuffers/framebuffer-object-attachment.html
conformance/more/conformance/quickCheckAPI-S_V.html

View File

@ -28,6 +28,7 @@ Google Inc.
Adrienne Walker
Mozilla Corp.
Ehsan Akhgari
Benoit Jacob
Makoto Kato
Vladimir Vukicevic
@ -40,3 +41,5 @@ Jim Hauxwell <james at dattrax.co.uk>
ddefrostt
timeless
Yore Apex
Mark Callow

View File

@ -1,6 +1,6 @@
deps = {
"trunk/third_party/gyp":
"http://gyp.googlecode.com/svn/trunk@800",
"http://gyp.googlecode.com/svn/trunk@1080",
}
hooks = [

View File

@ -1,17 +1,14 @@
This is the ANGLE project, from http://code.google.com/p/angleproject/
Current revision: r774
Current revision: r802
== Applied local patches ==
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-instrinsic-msvc2005.patch - work around a MSVC 2005 compile error
angle-renaming-debug.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-limit-identifiers-to-250-chars.patch - see bug 675625
angle-use-xmalloc.patch - see bug 680840. Can drop this patch whenever the new preprocessor lands.
angle-mCurrentValueOffsets-size_t.patch - ANGLE bug 220 - compile fix on win64
angle-pool_allocator-assignable.patch - ANGLE r798
In addition to these patches, the Makefile.in files are ours, they're not present in upsteam ANGLE.

View File

@ -1,2 +0,0 @@
# HG changeset patch
# Parent 6a9ec71ad85de76c551a5398b1427d9f76430b1f

View File

@ -1,17 +1,18 @@
# HG changeset patch
# Parent 74f1894d664435118be4fdefd53cabfdaa9985bc
# Parent fecc64a6df53a9056b21958affad38c80ca38496
diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
--- a/gfx/angle/Makefile.in
+++ b/gfx/angle/Makefile.in
@@ -123,16 +123,18 @@ CSRCS = \
memory.c \
scanner.c \
symbols.c \
tokens.c \
@@ -127,16 +127,18 @@ CSRCS = \
$(NULL)
DEFINES += -DANGLE_USE_NSPR -DANGLE_BUILD
#these defines are from ANGLE's build_angle.gyp
DEFINES += -DANGLE_DISABLE_TRACE
DEFINES += -DANGLE_COMPILE_OPTIMIZATION_LEVEL=D3DCOMPILE_OPTIMIZATION_LEVEL0
+EXTRA_DSO_LDOPTS = $(MOZALLOC_LIB)
+
ifdef MOZ_ANGLE
@ -25,14 +26,14 @@ diff --git a/gfx/angle/Makefile.in b/gfx/angle/Makefile.in
diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla
--- a/gfx/angle/README.mozilla
+++ b/gfx/angle/README.mozilla
@@ -4,16 +4,17 @@ Current revision: r740
@@ -3,16 +3,17 @@ This is the ANGLE project, from http://c
Current revision: r774
== Applied local patches ==
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-instrinsic-msvc2005.patch - work around a MSVC 2005 compile error
angle-limit-identifiers-to-250-chars.patch - see bug 675625
+ angle-use-xmalloc.patch - see bug 680840. Can drop this patch whenever the new preprocessor lands.
@ -118,7 +119,7 @@ diff --git a/gfx/angle/src/compiler/preprocessor/atom.c b/gfx/angle/src/compiler
diff --git a/gfx/angle/src/libEGL/Makefile.in b/gfx/angle/src/libEGL/Makefile.in
--- a/gfx/angle/src/libEGL/Makefile.in
+++ b/gfx/angle/src/libEGL/Makefile.in
@@ -150,8 +150,10 @@ RCFILE = $(srcdir)/libEGL.rc
@@ -153,8 +153,10 @@ RCFILE = $(srcdir)/libEGL.rc
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS = "$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)/d3d9.lib" \
@ -132,7 +133,7 @@ diff --git a/gfx/angle/src/libEGL/Makefile.in b/gfx/angle/src/libEGL/Makefile.in
diff --git a/gfx/angle/src/libGLESv2/Makefile.in b/gfx/angle/src/libGLESv2/Makefile.in
--- a/gfx/angle/src/libGLESv2/Makefile.in
+++ b/gfx/angle/src/libGLESv2/Makefile.in
@@ -159,8 +159,10 @@ CPPSRCS += \
@@ -162,8 +162,10 @@ CPPSRCS += \
DEFFILE = $(srcdir)/libGLESv2.def
RCFILE = $(srcdir)/libGLESv2.rc

View File

@ -4,7 +4,7 @@
{
'variables': {
'library%': 'shared_library',
'component%': 'static_library',
},
'target_defaults': {
'default_configuration': 'Debug',
@ -81,6 +81,11 @@
},
}, # Release
}, # configurations
'conditions': [
['component=="shared_library"', {
'defines': ['COMPONENT_BUILD'],
}],
],
}, # target_defaults
'conditions': [
['OS=="win"', {

View File

@ -0,0 +1,118 @@
Name
ANGLE_translated_shader_source
Name Strings
GL_ANGLE_translated_shader_source
Contributors
Daniel Koch, TransGaming Inc.
Gregg Tavares, Google Inc.
Kenneth Russell, Google Inc.
Zhenyao Mo, Google Inc.
Contact
Zhenyao Mo, Google Inc. (zmo 'at' google 'dot' com)
Status
Implemented in ANGLE ES2
Version
Last Modified Date: October 5, 2011
Author Revision: 2
Number
OpenGL ES Extension #??
Dependencies
OpenGL ES 2.0 is required.
The extension is written against the OpenGL ES 2.0 specification.
Overview
WebGL uses the GLSL ES 2.0 spec on all platforms, and translates these
shaders to the host platform's native language (HLSL, GLSL, and even GLSL
ES). For debugging purposes, it is useful to be able to examine the shader
after translation.
This extension addes a new function to query the translated shader source,
and adds a new enum for GetShaderiv's <pname> parameter to query the
translated shader source length.
IP Status
No known IP claims.
New Types
None
New Procedures and Functions
void GetTranslatedShaderSourceANGLE(uint shader, sizei bufsize,
sizei* length, char* source);
New Tokens
Accepted by the <pname> parameter of GetShaderiv:
TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
Additions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State
Requests)
Append in the end of the fourth paragraph of section 6.1.8 (Shader and
Program Queries):
" If <pname> is TRANSLATED_SHADER_LENGTH_ANGLE, the length of the translated
source string, including a null terminator, is returned. If no source has
been defined, CompileShader has not been called, or the translation has
failed for <shader>, zero is returned."
Append after the last paragraph of section 6.1.8 (Shader and Program
Queries):
"The command
void GetTranslatedShaderSourceANGLE( uint shader, sizei bufSize,
sizei *length, char *source );
returns in <source> the string making up the translated source code for
the shader object <shader>. The string <source> will be null terminated.
The actual number of characters written into <source>, excluding the null
terminator, is returned in <length>. If <length> is NULL, no length is
returned. The maximum number of characters that may be written into
<source>, including the null terminator, is specified by <bufSize>. The
string <source> is the translated string of a concatenation of the strings
passed to the GL using ShaderSource. The length of this translated string
is given by TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, which can be queried
with GetShaderiv.
If no source has been defined, CompileShader has not been called, or the
translation has failed for <shader>, zero is returned for <length>, and
an empty string is returned for <source>.
If the value of SHADER_COMPILER is not TRUE, then the error INVALID_-
OPERATION is generated."
Issues
1) What enum value should be used for TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE?
RESOLVED: The first draft used a temporary enum value. This been replaced
with a enum allocated from the ANGLE range of GL enums.
Revision History
Revision 1, 2011/09/29, zmo
- first draft
Revision 2, 2011/10/05, dgkoch
- assigned enum

View File

@ -21,7 +21,7 @@ Status
Version
Version 1, July 12, 2011
Version 2, October 19, 2011
Number
@ -46,7 +46,7 @@ New Procedures and Functions
New Tokens
None
EGL_SOFTWARE_DISPLAY_ANGLE (EGLNativeDisplayType)-1
Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)
@ -61,3 +61,5 @@ Issues
Revision History
Version 1, 2011/07/12 - first draft.
Version 2, 2011/10/18 - add token definition

View File

@ -217,6 +217,11 @@ typedef void* GLeglImageOES;
#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
#endif
/* GL_ANGLE_translated_shader_source */
#ifndef GL_ANGLE_translated_shader_source
#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
#endif
/*------------------------------------------------------------------------*
* APPLE extension tokens
*------------------------------------------------------------------------*/
@ -810,6 +815,15 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum
#define GL_ANGLE_texture_compression_dxt5 1
#endif
/* GL_ANGLE_translated_shader_source */
#ifndef GL_ANGLE_translated_shader_source
#define GL_ANGLE_translated_shader_source 1
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
#endif
typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
#endif
/*------------------------------------------------------------------------*
* APPLE extension functions
*------------------------------------------------------------------------*/

View File

@ -6,6 +6,23 @@
#ifndef _COMPILER_INTERFACE_INCLUDED_
#define _COMPILER_INTERFACE_INCLUDED_
#if defined(COMPONENT_BUILD)
#if defined(_WIN32) || defined(_WIN64)
#if defined(COMPILER_IMPLEMENTATION)
#define COMPILER_EXPORT __declspec(dllexport)
#else
#define COMPILER_EXPORT __declspec(dllimport)
#endif // defined(COMPILER_IMPLEMENTATION)
#else // defined(WIN32)
#define COMPILER_EXPORT __attribute__((visibility("default")))
#endif
#else // defined(COMPONENT_BUILD)
#define COMPILER_EXPORT
#endif
//
// This is the platform independent interface between an OGL driver
// and the shading language compiler.
@ -93,12 +110,12 @@ typedef enum {
// compiler operations.
// If the function succeeds, the return value is nonzero, else zero.
//
int ShInitialize();
COMPILER_EXPORT int ShInitialize();
//
// Driver should call this at shutdown.
// If the function succeeds, the return value is nonzero, else zero.
//
int ShFinalize();
COMPILER_EXPORT int ShFinalize();
//
// Implementation dependent built-in resources (constants and extensions).
@ -125,7 +142,7 @@ typedef struct
//
// Initialize built-in resources with minimum expected values.
//
void ShInitBuiltInResources(ShBuiltInResources* resources);
COMPILER_EXPORT void ShInitBuiltInResources(ShBuiltInResources* resources);
//
// ShHandle held by but opaque to the driver. It is allocated,
@ -148,10 +165,12 @@ typedef void* ShHandle;
// 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);
COMPILER_EXPORT ShHandle ShConstructCompiler(
ShShaderType type,
ShShaderSpec spec,
ShShaderOutput output,
const ShBuiltInResources* resources);
COMPILER_EXPORT void ShDestruct(ShHandle handle);
//
// Compiles the given shader source.
@ -178,7 +197,7 @@ void ShDestruct(ShHandle handle);
// Can be queried by calling ShGetActiveAttrib() and
// ShGetActiveUniform().
//
int ShCompile(
COMPILER_EXPORT int ShCompile(
const ShHandle handle,
const char* const shaderStrings[],
const int numStrings,
@ -206,7 +225,9 @@ int ShCompile(
// the null termination character.
//
// params: Requested parameter
void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params);
COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
ShShaderInfo pname,
int* params);
// Returns nul-terminated information log for a compiled shader.
// Parameters:
@ -216,7 +237,7 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, int* params);
// to accomodate the information log. The size of the buffer required
// to store the returned information log can be obtained by calling
// ShGetInfo with SH_INFO_LOG_LENGTH.
void ShGetInfoLog(const ShHandle handle, char* infoLog);
COMPILER_EXPORT void ShGetInfoLog(const ShHandle handle, char* infoLog);
// Returns null-terminated object code for a compiled shader.
// Parameters:
@ -226,7 +247,7 @@ void ShGetInfoLog(const ShHandle handle, char* infoLog);
// accomodate the object code. The size of the buffer required to
// store the returned object code can be obtained by calling
// ShGetInfo with SH_OBJECT_CODE_LENGTH.
void ShGetObjectCode(const ShHandle handle, char* objCode);
COMPILER_EXPORT void ShGetObjectCode(const ShHandle handle, char* objCode);
// Returns information about an active attribute variable.
// Parameters:
@ -247,13 +268,13 @@ void ShGetObjectCode(const ShHandle handle, char* objCode);
// memory (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care
// about the mapped name. If the name is not mapped, then name and
// mappedName are the same.
void ShGetActiveAttrib(const ShHandle handle,
int index,
int* length,
int* size,
ShDataType* type,
char* name,
char* mappedName);
COMPILER_EXPORT void ShGetActiveAttrib(const ShHandle handle,
int index,
int* length,
int* size,
ShDataType* type,
char* name,
char* mappedName);
// Returns information about an active uniform variable.
// Parameters:
@ -274,13 +295,13 @@ void ShGetActiveAttrib(const ShHandle handle,
// memory (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care
// about the mapped name. If the name is not mapped, then name and
// mappedName are the same.
void ShGetActiveUniform(const ShHandle handle,
int index,
int* length,
int* size,
ShDataType* type,
char* name,
char* mappedName);
COMPILER_EXPORT void ShGetActiveUniform(const ShHandle handle,
int index,
int* length,
int* size,
ShDataType* type,
char* name,
char* mappedName);
#ifdef __cplusplus
}

View File

@ -25,10 +25,18 @@
],
'include_dirs': [
'../include',
'../src',
],
'sources': [
'translator/translator.cpp',
'../src/common/debug.cpp',
],
'msvs_settings': {
'VCLinkerTool': {
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
'AdditionalDependencies': ['d3d9.lib'],
}
}
},
],
'conditions': [

View File

@ -149,12 +149,12 @@ int main(int argc, char* argv[])
}
if (compiled && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) {
LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE ATTRIBS");
PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, compileOptions & SH_MAP_LONG_VARIABLE_NAMES);
PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) != 0);
LogMsg("END", "COMPILER", numCompiles, "ACTIVE ATTRIBS");
printf("\n\n");
LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE UNIFORMS");
PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, compileOptions & SH_MAP_LONG_VARIABLE_NAMES);
PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) != 0);
LogMsg("END", "COMPILER", numCompiles, "ACTIVE UNIFORMS");
printf("\n\n");
}

View File

@ -63,7 +63,11 @@ void trace(bool traceFileDebugOnly, const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
#if defined(ANGLE_DISABLE_PERF)
output(traceFileDebugOnly, NULL, format, vararg);
#else
output(traceFileDebugOnly, D3DPERF_SetMarker, format, vararg);
#endif
va_end(vararg);
}
@ -79,10 +83,12 @@ bool perfActive()
ScopedPerfEventHelper::ScopedPerfEventHelper(const char* format, ...)
{
#if !defined(ANGLE_DISABLE_PERF)
va_list vararg;
va_start(vararg, format);
output(true, reinterpret_cast<PerfOutputFunction>(D3DPERF_BeginEvent), format, vararg);
va_end(vararg);
#endif
}
ScopedPerfEventHelper::~ScopedPerfEventHelper()

View File

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

View File

@ -1503,7 +1503,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
if (node->usesTernaryOperator())
{
out << "t" << mUnfoldSelect->getTemporaryIndex();
out << "s" << mUnfoldSelect->getNextTemporaryIndex();
}
else // if/else statement
{
@ -1567,21 +1567,6 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
}
else
{
if (node->getInit())
{
mUnfoldSelect->traverse(node->getInit());
}
if (node->getCondition())
{
mUnfoldSelect->traverse(node->getCondition());
}
if (node->getExpression())
{
mUnfoldSelect->traverse(node->getExpression());
}
out << "for(";
if (node->getInit())

View File

@ -20,8 +20,9 @@ UnfoldSelect::UnfoldSelect(TParseContext &context, OutputHLSL *outputHLSL) : mCo
void UnfoldSelect::traverse(TIntermNode *node)
{
mTemporaryIndex++;
int rewindIndex = mTemporaryIndex;
node->traverse(this);
mTemporaryIndex = rewindIndex;
}
bool UnfoldSelect::visitSelection(Visit visit, TIntermSelection *node)
@ -30,36 +31,66 @@ bool UnfoldSelect::visitSelection(Visit visit, TIntermSelection *node)
if (node->usesTernaryOperator())
{
int i = mTemporaryIndex++;
int i = mTemporaryIndex;
out << mOutputHLSL->typeString(node->getType()) << " t" << i << ";\n";
out << mOutputHLSL->typeString(node->getType()) << " s" << i << ";\n";
mTemporaryIndex = i + 1;
node->getCondition()->traverse(this);
out << "if(";
mTemporaryIndex = i + 1;
node->getCondition()->traverse(mOutputHLSL);
out << ")\n"
"{\n";
mTemporaryIndex = i + 1;
node->getTrueBlock()->traverse(this);
out << " t" << i << " = ";
out << " s" << i << " = ";
mTemporaryIndex = i + 1;
node->getTrueBlock()->traverse(mOutputHLSL);
out << ";\n"
"}\n"
"else\n"
"{\n";
mTemporaryIndex = i + 1;
node->getFalseBlock()->traverse(this);
out << " t" << i << " = ";
out << " s" << i << " = ";
mTemporaryIndex = i + 1;
node->getFalseBlock()->traverse(mOutputHLSL);
out << ";\n"
"}\n";
mTemporaryIndex--;
mTemporaryIndex = i + 1;
}
return false;
}
int UnfoldSelect::getTemporaryIndex()
bool UnfoldSelect::visitLoop(Visit visit, TIntermLoop *node)
{
return mTemporaryIndex;
int rewindIndex = mTemporaryIndex;
if (node->getInit())
{
node->getInit()->traverse(this);
}
if (node->getCondition())
{
node->getCondition()->traverse(this);
}
if (node->getExpression())
{
node->getExpression()->traverse(this);
}
mTemporaryIndex = rewindIndex;
return false;
}
int UnfoldSelect::getNextTemporaryIndex()
{
return mTemporaryIndex++;
}
}

View File

@ -23,8 +23,9 @@ class UnfoldSelect : public TIntermTraverser
void traverse(TIntermNode *node);
bool visitSelection(Visit visit, TIntermSelection *node);
bool visitLoop(Visit visit, TIntermLoop *node);
int getTemporaryIndex();
int getNextTemporaryIndex();
protected:
TParseContext &mContext;

View File

@ -261,6 +261,8 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
case EOpRefract: out << "refract"; break;
case EOpMul: out << "component-wise multiply"; break;
case EOpDeclaration: out << "Declaration: "; break;
default: out.message(EPrefixError, "Bad aggregation op");
}

View File

@ -381,6 +381,8 @@ void Context::markAllStateDirty()
mSampleStateDirty = true;
mDitherStateDirty = true;
mFrontFaceDirty = true;
mDxUniformsDirty = true;
mCachedCurrentProgram = NULL;
}
void Context::setClearColor(float red, float green, float blue, float alpha)
@ -893,6 +895,7 @@ void Context::deleteShader(GLuint shader)
void Context::deleteProgram(GLuint program)
{
mResourceManager->deleteProgram(program);
mCachedCurrentProgram = NULL;
}
void Context::deleteTexture(GLuint texture)
@ -973,7 +976,7 @@ Framebuffer *Context::getReadFramebuffer()
Framebuffer *Context::getDrawFramebuffer()
{
return getFramebuffer(mState.drawFramebuffer);
return mBoundDrawFramebuffer;
}
void Context::bindArrayBuffer(unsigned int buffer)
@ -1022,6 +1025,8 @@ void Context::bindDrawFramebuffer(GLuint framebuffer)
}
mState.drawFramebuffer = framebuffer;
mBoundDrawFramebuffer = getFramebuffer(framebuffer);
}
void Context::bindRenderbuffer(GLuint renderbuffer)
@ -1040,6 +1045,8 @@ void Context::useProgram(GLuint program)
{
Program *newProgram = mResourceManager->getProgram(program);
Program *oldProgram = mResourceManager->getProgram(priorProgram);
mCachedCurrentProgram = NULL;
mDxUniformsDirty = true;
if (newProgram)
{
@ -1057,6 +1064,10 @@ void Context::setFramebufferZero(Framebuffer *buffer)
{
delete mFramebufferMap[0];
mFramebufferMap[0] = buffer;
if (mState.drawFramebuffer == 0)
{
mBoundDrawFramebuffer = buffer;
}
}
void Context::setRenderbufferStorage(RenderbufferStorage *renderbuffer)
@ -1105,7 +1116,11 @@ Buffer *Context::getElementArrayBuffer()
Program *Context::getCurrentProgram()
{
return mResourceManager->getProgram(mState.currentProgram);
if (!mCachedCurrentProgram)
{
mCachedCurrentProgram = mResourceManager->getProgram(mState.currentProgram);
}
return mCachedCurrentProgram;
}
Texture2D *Context::getTexture2D()
@ -1614,19 +1629,19 @@ bool Context::applyRenderTarget(bool ignoreViewport)
return error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
}
IDirect3DSurface9 *renderTarget = framebufferObject->getRenderTarget();
if (!renderTarget)
{
return false; // Context must be lost
}
IDirect3DSurface9 *renderTarget = NULL;
IDirect3DSurface9 *depthStencil = NULL;
bool renderTargetChanged = false;
unsigned int renderTargetSerial = framebufferObject->getRenderTargetSerial();
if (renderTargetSerial != mAppliedRenderTargetSerial)
{
renderTarget = framebufferObject->getRenderTarget();
if (!renderTarget)
{
return false; // Context must be lost
}
device->SetRenderTarget(0, renderTarget);
mAppliedRenderTargetSerial = renderTargetSerial;
mScissorStateDirty = true; // Scissor area must be clamped to render target's size-- this is different for different render targets.
@ -1670,6 +1685,15 @@ bool Context::applyRenderTarget(bool ignoreViewport)
if (!mRenderTargetDescInitialized || renderTargetChanged)
{
if (!renderTarget)
{
renderTarget = framebufferObject->getRenderTarget();
if (!renderTarget)
{
return false; // Context must be lost
}
}
renderTarget->GetDesc(&mRenderTargetDesc);
mRenderTargetDescInitialized = true;
}
@ -1709,6 +1733,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
device->SetViewport(&viewport);
mSetViewport = viewport;
mViewportInitialized = true;
mDxUniformsDirty = true;
}
if (mScissorStateDirty)
@ -1731,7 +1756,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
mScissorStateDirty = false;
}
if (mState.currentProgram)
if (mState.currentProgram && mDxUniformsDirty)
{
Program *programObject = getCurrentProgram();
@ -1752,6 +1777,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
GLint depthRange = programObject->getDxDepthRangeLocation();
GLfloat nearFarDiff[3] = {zNear, zFar, zFar - zNear};
programObject->setUniform3fv(depthRange, 1, nearFarDiff);
mDxUniformsDirty = false;
}
return true;
@ -2089,12 +2115,14 @@ void Context::applyTextures(SamplerType type)
Program *programObject = getCurrentProgram();
int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF; // Range of Direct3D 9 samplers of given sampler type
unsigned int *appliedTextureSerial = (type == SAMPLER_PIXEL) ? mAppliedTextureSerialPS : mAppliedTextureSerialVS;
int d3dSamplerOffset = (type == SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int samplerRange = programObject->getUsedSamplerRange(type);
for (int samplerIndex = 0; samplerIndex < samplerCount; samplerIndex++)
for (int samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
{
int textureUnit = programObject->getSamplerMapping(type, samplerIndex); // OpenGL texture image unit index
int d3dSampler = (type == SAMPLER_PIXEL) ? samplerIndex : D3DVERTEXTEXTURESAMPLER0 + samplerIndex;
unsigned int *appliedTextureSerial = (type == SAMPLER_PIXEL) ? mAppliedTextureSerialPS : mAppliedTextureSerialVS;
int d3dSampler = samplerIndex + d3dSamplerOffset;
if (textureUnit != -1)
{
@ -2148,6 +2176,15 @@ void Context::applyTextures(SamplerType type)
}
}
}
for (int samplerIndex = samplerRange; samplerIndex < samplerCount; samplerIndex++)
{
if (appliedTextureSerial[samplerIndex] != 0)
{
device->SetTexture(samplerIndex + d3dSamplerOffset, NULL);
appliedTextureSerial[samplerIndex] = 0;
}
}
}
void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
@ -3434,6 +3471,7 @@ void Context::initExtensionString()
{
mExtensionString += "GL_ANGLE_texture_compression_dxt5 ";
}
mExtensionString += "GL_ANGLE_translated_shader_source ";
// Other vendor-specific extensions
if (supportsEventQueries())

View File

@ -544,6 +544,9 @@ class Context
D3DVIEWPORT9 mSetViewport;
bool mRenderTargetDescInitialized;
D3DSURFACE_DESC mRenderTargetDesc;
bool mDxUniformsDirty;
Program *mCachedCurrentProgram;
Framebuffer *mBoundDrawFramebuffer;
bool mSupportsShaderModel3;
bool mSupportsVertexTexture;

View File

@ -58,19 +58,19 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle) const
void Framebuffer::setColorbuffer(GLenum type, GLuint colorbuffer)
{
mColorbufferType = type;
mColorbufferType = (colorbuffer != 0) ? type : GL_NONE;
mColorbufferPointer.set(lookupRenderbuffer(type, colorbuffer));
}
void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer)
{
mDepthbufferType = type;
mDepthbufferType = (depthbuffer != 0) ? type : GL_NONE;
mDepthbufferPointer.set(lookupRenderbuffer(type, depthbuffer));
}
void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer)
{
mStencilbufferType = type;
mStencilbufferType = (stencilbuffer != 0) ? type : GL_NONE;
mStencilbufferPointer.set(lookupRenderbuffer(type, stencilbuffer));
}

File diff suppressed because it is too large Load Diff

View File

@ -42,9 +42,15 @@ struct Uniform
unsigned char *data;
bool dirty;
D3DXHANDLE vsHandle;
D3DXHANDLE psHandle;
bool handlesSet;
struct RegisterInfo
{
int registerSet;
int registerIndex;
int registerCount;
};
RegisterInfo ps;
RegisterInfo vs;
};
// Struct used for correlating uniforms/elements of uniform arrays to handles
@ -77,6 +83,7 @@ class Program
GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex);
TextureType getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLint getUsedSamplerRange(SamplerType type);
GLint getUniformLocation(std::string name);
bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
@ -149,23 +156,15 @@ class Program
bool defineUniform(const D3DXHANDLE &constantHandle, const D3DXCONSTANT_DESC &constantDescription, std::string name = "");
bool defineUniform(const D3DXCONSTANT_DESC &constantDescription, std::string &name);
Uniform *createUniform(const D3DXCONSTANT_DESC &constantDescription, std::string &name);
bool applyUniform1bv(GLint location, GLsizei count, const GLboolean *v);
bool applyUniform2bv(GLint location, GLsizei count, const GLboolean *v);
bool applyUniform3bv(GLint location, GLsizei count, const GLboolean *v);
bool applyUniform4bv(GLint location, GLsizei count, const GLboolean *v);
bool applyUniform1fv(GLint location, GLsizei count, const GLfloat *v);
bool applyUniform2fv(GLint location, GLsizei count, const GLfloat *v);
bool applyUniform3fv(GLint location, GLsizei count, const GLfloat *v);
bool applyUniform4fv(GLint location, GLsizei count, const GLfloat *v);
bool applyUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value);
bool applyUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value);
bool applyUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value);
bool applyUniform1iv(GLint location, GLsizei count, const GLint *v);
bool applyUniform2iv(GLint location, GLsizei count, const GLint *v);
bool applyUniform3iv(GLint location, GLsizei count, const GLint *v);
bool applyUniform4iv(GLint location, GLsizei count, const GLint *v);
bool applyUniformnfv(Uniform *targetUniform, const GLfloat *v);
bool applyUniform1iv(Uniform *targetUniform, GLsizei count, const GLint *v);
bool applyUniform2iv(Uniform *targetUniform, GLsizei count, const GLint *v);
bool applyUniform3iv(Uniform *targetUniform, GLsizei count, const GLint *v);
bool applyUniform4iv(Uniform *targetUniform, GLsizei count, const GLint *v);
void applyUniformniv(Uniform *targetUniform, GLsizei count, const D3DXVECTOR4 *vector);
void applyUniformnbv(Uniform *targetUniform, GLsizei count, int width, const GLboolean *v);
void getConstantHandles(Uniform *targetUniform, D3DXHANDLE *constantPS, D3DXHANDLE *constantVS);
void initializeConstantHandles(Uniform *targetUniform, Uniform::RegisterInfo *rs, ID3DXConstantTable *constantTable);
void appendToInfoLogSanitized(const char *message);
void appendToInfoLog(const char *info, ...);
@ -197,6 +196,8 @@ class Program
Sampler mSamplersPS[MAX_TEXTURE_IMAGE_UNITS];
Sampler mSamplersVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF];
GLuint mUsedVertexSamplerRange;
GLuint mUsedPixelSamplerRange;
typedef std::vector<Uniform*> UniformArray;
UniformArray mUniforms;

View File

@ -157,22 +157,34 @@ int Shader::getSourceLength() const
}
}
void Shader::getSource(GLsizei bufSize, GLsizei *length, char *source)
int Shader::getTranslatedSourceLength() const
{
if (!mHlsl)
{
return 0;
}
else
{
return strlen(mHlsl) + 1;
}
}
void Shader::getSourceImpl(char *source, GLsizei bufSize, GLsizei *length, char *buffer)
{
int index = 0;
if (mSource)
if (source)
{
while (index < bufSize - 1 && index < (int)strlen(mSource))
while (index < bufSize - 1 && index < (int)strlen(source))
{
source[index] = mSource[index];
buffer[index] = source[index];
index++;
}
}
if (bufSize)
{
source[index] = '\0';
buffer[index] = '\0';
}
if (length)
@ -181,6 +193,16 @@ void Shader::getSource(GLsizei bufSize, GLsizei *length, char *source)
}
}
void Shader::getSource(GLsizei bufSize, GLsizei *length, char *buffer)
{
getSourceImpl(mSource, bufSize, length, buffer);
}
void Shader::getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer)
{
getSourceImpl(mHlsl, bufSize, length, buffer);
}
bool Shader::isCompiled()
{
return mHlsl != NULL;

View File

@ -57,7 +57,9 @@ class Shader
int getInfoLogLength() const;
void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
int getSourceLength() const;
void getSource(GLsizei bufSize, GLsizei *length, char *source);
void getSource(GLsizei bufSize, GLsizei *length, char *buffer);
int getTranslatedSourceLength() const;
void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer);
virtual void compile() = 0;
bool isCompiled();
@ -78,6 +80,8 @@ class Shader
void compileToHLSL(void *compiler);
void getSourceImpl(char *source, GLsizei bufSize, GLsizei *length, char *buffer);
static GLenum parseType(const std::string &type);
static bool compareVarying(const Varying &x, const Varying &y);

View File

@ -1987,7 +1987,7 @@ void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenu
try
{
if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|| renderbuffertarget != GL_RENDERBUFFER)
|| (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
{
return error(GL_INVALID_ENUM);
}
@ -2003,13 +2003,13 @@ void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenu
framebuffer = context->getReadFramebuffer();
framebufferHandle = context->getReadFramebufferHandle();
}
else
else
{
framebuffer = context->getDrawFramebuffer();
framebufferHandle = context->getDrawFramebufferHandle();
}
if (framebufferHandle == 0 || !framebuffer)
if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
{
return error(GL_INVALID_OPERATION);
}
@ -3089,6 +3089,9 @@ void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
case GL_SHADER_SOURCE_LENGTH:
*params = shaderObject->getSourceLength();
return;
case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
*params = shaderObject->getTranslatedSourceLength();
return;
default:
return error(GL_INVALID_ENUM);
}
@ -3209,6 +3212,38 @@ void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length
}
}
void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
{
EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
shader, bufsize, length, source);
try
{
if (bufsize < 0)
{
return error(GL_INVALID_VALUE);
}
gl::Context *context = gl::getContext();
if (context)
{
gl::Shader *shaderObject = context->getShader(shader);
if (!shaderObject)
{
return error(GL_INVALID_OPERATION);
}
shaderObject->getTranslatedSource(bufsize, length, source);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
}
const GLubyte* __stdcall glGetString(GLenum name)
{
EVENT("(GLenum name = 0x%X)", name);
@ -5769,6 +5804,7 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *
{"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
{"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
{"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
{"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
};
for (int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)

View File

@ -154,6 +154,7 @@ EXPORTS
glIsFenceNV @155
glSetFenceNV @156
glTestFenceNV @157
glGetTranslatedShaderSourceANGLE @159
; EGL dependencies
glCreateContext @144 NONAME

View File

@ -54,6 +54,42 @@ int UniformComponentCount(GLenum type)
return 0;
}
// This is how much data we actually store for a uniform
int UniformInternalComponentCount(GLenum type)
{
switch (type)
{
case GL_BOOL:
case GL_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
return 1;
case GL_BOOL_VEC2:
case GL_INT_VEC2:
return 2;
case GL_INT_VEC3:
case GL_BOOL_VEC3:
return 3;
case GL_FLOAT:
case GL_FLOAT_VEC2:
case GL_FLOAT_VEC3:
case GL_BOOL_VEC4:
case GL_FLOAT_VEC4:
case GL_INT_VEC4:
return 4;
case GL_FLOAT_MAT2:
return 8;
case GL_FLOAT_MAT3:
return 12;
case GL_FLOAT_MAT4:
return 16;
default:
UNREACHABLE();
}
return 0;
}
GLenum UniformComponentType(GLenum type)
{
switch(type)
@ -85,16 +121,22 @@ GLenum UniformComponentType(GLenum type)
return GL_NONE;
}
size_t UniformTypeSize(GLenum type)
size_t UniformComponentSize(GLenum type)
{
switch(type)
{
case GL_BOOL: return sizeof(GLboolean);
case GL_FLOAT: return sizeof(GLfloat);
case GL_INT: return sizeof(GLint);
default: UNREACHABLE();
}
return UniformTypeSize(UniformComponentType(type)) * UniformComponentCount(type);
return 0;
}
size_t UniformTypeSize(GLenum type)
{
return UniformComponentSize(UniformComponentType(type)) * UniformInternalComponentCount(type);
}
int VariableRowCount(GLenum type)

View File

@ -22,6 +22,7 @@ namespace gl
struct Color;
int UniformComponentCount(GLenum type);
int UniformInternalComponentCount(GLenum type);
GLenum UniformComponentType(GLenum type);
size_t UniformTypeSize(GLenum type);
int VariableRowCount(GLenum type);