Compiler - match pixel and vertex shader profiles
TRAC #11717
Signed-off-by: Daniel Koch

Author:    Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@94 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 3e98ec1..282d874 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -251,6 +251,20 @@
     {
         depthStencil->Release();
     }
+
+    D3DCAPS9 capabilities;
+    device->GetDeviceCaps(&capabilities);
+    
+    if (capabilities.PixelShaderVersion == D3DPS_VERSION(3, 0))
+    {
+        mPsProfile = "ps_3_0";
+        mVsProfile = "vs_3_0";
+    }
+    else  // egl::Display guarantees support for at least 2.0
+    {
+        mPsProfile = "ps_2_0";
+        mVsProfile = "vs_2_0";
+    }
 }
 
 void Context::setClearColor(float red, float green, float blue, float alpha)
@@ -1642,6 +1656,16 @@
     return GL_NO_ERROR;
 }
 
+const char *Context::getPixelShaderProfile()
+{
+    return mPsProfile;
+}
+
+const char *Context::getVertexShaderProfile()
+{
+    return mVsProfile;
+}
+
 void Context::detachBuffer(GLuint buffer)
 {
     // [OpenGL ES 2.0.24] section 2.9 page 22:
diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h
index 649114a..939b5f6 100644
--- a/src/libGLESv2/Context.h
+++ b/src/libGLESv2/Context.h
@@ -277,6 +277,9 @@
 
     GLenum getError();
 
+    const char *getPixelShaderProfile();
+    const char *getVertexShaderProfile();
+
   private:
     DISALLOW_COPY_AND_ASSIGN(Context);
 
@@ -333,6 +336,9 @@
     bool mInvalidFramebufferOperation;
 
     bool mHasBeenCurrent;
+
+    const char *mPsProfile;
+    const char *mVsProfile;
 };
 }
 
diff --git a/src/libGLESv2/Program.cpp b/src/libGLESv2/Program.cpp
index 71de712..df91db5 100644
--- a/src/libGLESv2/Program.cpp
+++ b/src/libGLESv2/Program.cpp
@@ -423,9 +423,9 @@
         return;
     }
 
-    IDirect3DDevice9 *device = getDevice();
-    const char *vertexProfile = D3DXGetVertexShaderProfile(device);
-    const char *pixelProfile = D3DXGetPixelShaderProfile(device);
+    Context *context = getContext();
+    const char *vertexProfile = context->getVertexShaderProfile();
+    const char *pixelProfile = context->getPixelShaderProfile();
 
     const char *pixelHLSL = mFragmentShader->linkHLSL();
     const char *vertexHLSL = mVertexShader->linkHLSL(pixelHLSL);
@@ -434,6 +434,7 @@
 
     if (vertexBinary && pixelBinary)
     {
+        IDirect3DDevice9 *device = getDevice();
         HRESULT vertexResult = device->CreateVertexShader((DWORD*)vertexBinary->GetBufferPointer(), &mVertexExecutable);
         HRESULT pixelResult = device->CreatePixelShader((DWORD*)pixelBinary->GetBufferPointer(), &mPixelExecutable);