Disable GL_OES_standard_derivatives when ps_2_x or later is not available.
BUG=392
Review URL: https://codereview.appspot.com/7027051
Author: bsalomon@google.com
(manual merge from master by daniel@transgaming.com)
git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1704 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index f85ec9a..db06fda 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -259,7 +259,7 @@
mSupportsLuminanceAlphaTextures = mRenderer->getLuminanceAlphaTextureSupport();
mSupportsDepthTextures = mRenderer->getDepthTextureSupport();
mSupportsTextureFilterAnisotropy = mRenderer->getTextureFilterAnisotropySupport();
-
+ mSupportsDerivativeInstructions = mRenderer->getDerivativeInstructionSupport();
mSupports32bitIndices = mRenderer->get32BitIndexSupport();
mNumCompressedTextureFormats = 0;
@@ -2266,6 +2266,11 @@
return mSupportsTextureFilterAnisotropy;
}
+bool Context::supportsDerivativeInstructions() const
+{
+ return mSupportsDerivativeInstructions;
+}
+
float Context::getTextureMaxAnisotropy() const
{
return mMaxTextureAnisotropy;
@@ -2504,7 +2509,10 @@
mExtensionString += "GL_OES_packed_depth_stencil ";
mExtensionString += "GL_OES_get_program_binary ";
mExtensionString += "GL_OES_rgb8_rgba8 ";
- mExtensionString += "GL_OES_standard_derivatives ";
+ if (supportsDerivativeInstructions())
+ {
+ mExtensionString += "GL_OES_standard_derivatives ";
+ }
if (supportsFloat16Textures())
{
diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h
index eb9c75c..6c52f8a 100644
--- a/src/libGLESv2/Context.h
+++ b/src/libGLESv2/Context.h
@@ -409,6 +409,7 @@
bool supportsNonPower2Texture() const;
bool supportsInstancing() const;
bool supportsTextureFilterAnisotropy() const;
+ bool supportsDerivativeInstructions() const;
bool getCurrentReadFormatType(GLenum *format, GLenum *type);
@@ -515,6 +516,7 @@
bool mSupportsDepthTextures;
bool mSupports32bitIndices;
bool mSupportsTextureFilterAnisotropy;
+ bool mSupportsDerivativeInstructions;
int mNumCompressedTextureFormats;
ResourceManager *mResourceManager;
diff --git a/src/libGLESv2/Shader.cpp b/src/libGLESv2/Shader.cpp
index 81dde92..7d9d450 100644
--- a/src/libGLESv2/Shader.cpp
+++ b/src/libGLESv2/Shader.cpp
@@ -240,7 +240,7 @@
resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
resources.MaxFragmentUniformVectors = context->getMaximumFragmentUniformVectors();
resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
- resources.OES_standard_derivatives = 1;
+ resources.OES_standard_derivatives = context->supportsDerivativeInstructions() ? 1 : 0;
// resources.OES_EGL_image_external = getDisplay()->getRenderer()->getShareHandleSupport() ? 1 : 0; // TODO: commented out until the extension is actually supported.
mFragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_GLES2_SPEC, SH_HLSL_OUTPUT, &resources);
diff --git a/src/libGLESv2/renderer/Renderer.h b/src/libGLESv2/renderer/Renderer.h
index dab8d3b..e31594e 100644
--- a/src/libGLESv2/renderer/Renderer.h
+++ b/src/libGLESv2/renderer/Renderer.h
@@ -150,6 +150,7 @@
virtual bool getTextureFilterAnisotropySupport() const = 0;
virtual float getTextureMaxAnisotropy() const = 0;
virtual bool getShareHandleSupport() const = 0;
+ virtual bool getDerivativeInstructionSupport() const = 0;
virtual int getMajorShaderModel() const = 0;
virtual float getMaxPointSize() const = 0;
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 860a35e..9e71cb7 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -1414,6 +1414,13 @@
return false && !gl::perfActive();
}
+bool Renderer11::getDerivativeInstructionSupport() const
+{
+ // TODO
+ // UNIMPLEMENTED();
+ return false;
+}
+
int Renderer11::getMajorShaderModel() const
{
switch (mFeatureLevel)
diff --git a/src/libGLESv2/renderer/Renderer11.h b/src/libGLESv2/renderer/Renderer11.h
index c4d45f7..0a06fd1 100644
--- a/src/libGLESv2/renderer/Renderer11.h
+++ b/src/libGLESv2/renderer/Renderer11.h
@@ -105,6 +105,7 @@
virtual bool getTextureFilterAnisotropySupport() const;
virtual float getTextureMaxAnisotropy() const;
virtual bool getShareHandleSupport() const;
+ virtual bool getDerivativeInstructionSupport() const;
virtual int getMajorShaderModel() const;
virtual float getMaxPointSize() const;
diff --git a/src/libGLESv2/renderer/Renderer9.cpp b/src/libGLESv2/renderer/Renderer9.cpp
index 7b23c94..e0b1b8c 100644
--- a/src/libGLESv2/renderer/Renderer9.cpp
+++ b/src/libGLESv2/renderer/Renderer9.cpp
@@ -2211,6 +2211,11 @@
return (mD3d9Ex != NULL) && !gl::perfActive();
}
+bool Renderer9::getDerivativeInstructionSupport() const
+{
+ return (mDeviceCaps.PS20Caps.Caps & D3DPS20CAPS_GRADIENTINSTRUCTIONS) != 0;
+}
+
int Renderer9::getMajorShaderModel() const
{
return D3DSHADER_VERSION_MAJOR(mDeviceCaps.PixelShaderVersion);
diff --git a/src/libGLESv2/renderer/Renderer9.h b/src/libGLESv2/renderer/Renderer9.h
index b4648a3..03c3d28 100644
--- a/src/libGLESv2/renderer/Renderer9.h
+++ b/src/libGLESv2/renderer/Renderer9.h
@@ -130,6 +130,7 @@
virtual bool getTextureFilterAnisotropySupport() const;
virtual float getTextureMaxAnisotropy() const;
virtual bool getShareHandleSupport() const;
+ virtual bool getDerivativeInstructionSupport() const;
virtual int getMajorShaderModel() const;
virtual float getMaxPointSize() const;