ANGLE supports GL_OES_standard_derivatives now.
BUG=25
Review URL: http://codereview.appspot.com/2122048
git-svn-id: https://angleproject.googlecode.com/svn/trunk@416 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 510a281..7b692a2 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -84,6 +84,7 @@
mState.scissorTest = false;
mState.dither = true;
mState.generateMipmapHint = GL_DONT_CARE;
+ mState.fragmentShaderDerivativeHint = GL_DONT_CARE;
mState.lineWidth = 1.0f;
@@ -664,6 +665,14 @@
mState.generateMipmapHint = hint;
}
+void Context::setFragmentShaderDerivativeHint(GLenum hint)
+{
+ mState.fragmentShaderDerivativeHint = hint;
+ // TODO: Propagate the hint to shader translator so we can write
+ // ddx, ddx_coarse, or ddx_fine depending on the hint.
+ // Ignore for now. It is valid for implementations to ignore hint.
+}
+
void Context::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height)
{
mState.viewportX = x;
@@ -1212,6 +1221,7 @@
case GL_PACK_ALIGNMENT: *params = mState.packAlignment; break;
case GL_UNPACK_ALIGNMENT: *params = mState.unpackAlignment; break;
case GL_GENERATE_MIPMAP_HINT: *params = mState.generateMipmapHint; break;
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: *params = mState.fragmentShaderDerivativeHint; break;
case GL_ACTIVE_TEXTURE: *params = (mState.activeSampler + GL_TEXTURE0); break;
case GL_STENCIL_FUNC: *params = mState.stencilFunc; break;
case GL_STENCIL_REF: *params = mState.stencilRef; break;
@@ -1445,6 +1455,7 @@
case GL_PACK_ALIGNMENT:
case GL_UNPACK_ALIGNMENT:
case GL_GENERATE_MIPMAP_HINT:
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
case GL_RED_BITS:
case GL_GREEN_BITS:
case GL_BLUE_BITS:
@@ -3115,6 +3126,7 @@
mExtensionString += "GL_EXT_read_format_bgra ";
mExtensionString += "GL_ANGLE_framebuffer_blit ";
mExtensionString += "GL_OES_rgb8_rgba8 ";
+ mExtensionString += "GL_OES_standard_derivatives ";
if (supportsEventQueries())
{
diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h
index fdb0d2b..253fa6a 100644
--- a/src/libGLESv2/Context.h
+++ b/src/libGLESv2/Context.h
@@ -12,6 +12,7 @@
#define GL_APICALL
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#define EGLAPI
#include <EGL/egl.h>
#include <d3d9.h>
@@ -158,6 +159,7 @@
GLfloat lineWidth;
GLenum generateMipmapHint;
+ GLenum fragmentShaderDerivativeHint;
GLint viewportX;
GLint viewportY;
@@ -265,6 +267,7 @@
void setLineWidth(GLfloat width);
void setGenerateMipmapHint(GLenum hint);
+ void setFragmentShaderDerivativeHint(GLenum hint);
void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
diff --git a/src/libGLESv2/Shader.cpp b/src/libGLESv2/Shader.cpp
index b73ef2a..0863a39 100644
--- a/src/libGLESv2/Shader.cpp
+++ b/src/libGLESv2/Shader.cpp
@@ -44,6 +44,7 @@
resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS;
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
+ resources.OES_standard_derivatives = 1;
mFragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecGLES2, &resources);
mVertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecGLES2, &resources);
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 74e2c27..7ac312d 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -3542,28 +3542,27 @@
try
{
- switch (target)
+ switch (mode)
{
- case GL_GENERATE_MIPMAP_HINT:
- switch (mode)
- {
- case GL_FASTEST:
- case GL_NICEST:
- case GL_DONT_CARE:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
+ case GL_FASTEST:
+ case GL_NICEST:
+ case GL_DONT_CARE:
break;
default:
- return error(GL_INVALID_ENUM);
+ return error(GL_INVALID_ENUM);
}
gl::Context *context = gl::getContext();
- if (context)
+ switch (target)
{
- if (target == GL_GENERATE_MIPMAP_HINT)
- context->setGenerateMipmapHint(mode);
+ case GL_GENERATE_MIPMAP_HINT:
+ if (context) context->setGenerateMipmapHint(mode);
+ break;
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
+ if (context) context->setFragmentShaderDerivativeHint(mode);
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
}
}
catch(std::bad_alloc&)