Place the method responsible for checking for fast pixel unpack buffer support into the Renderer.

TRAC #23997

Signed-off-by: Geoff Lang
Signed-off-by: Shannon Woods
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 0d285f1..dc2e2d1 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -22,6 +22,7 @@
 #include "libEGL/Surface.h"
 #include "libGLESv2/Buffer.h"
 #include "libGLESv2/renderer/BufferStorage.h"
+#include "libGLESv2/renderer/RenderTarget.h"
 
 namespace gl
 {
@@ -232,7 +233,7 @@
 
     // In order to perform the fast copy through the shader, we must have the right format, and be able
     // to create a render target.
-    if (IsFastCopyBufferToTextureSupported(sizedInternalFormat, mRenderer->getCurrentClientVersion()))
+    if (mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat))
     {
         unsigned int offset = reinterpret_cast<unsigned int>(pixels);
         rx::RenderTarget *destRenderTarget = getStorage(true)->getStorageInstance()->getRenderTarget(level);
diff --git a/src/libGLESv2/formatutils.cpp b/src/libGLESv2/formatutils.cpp
index 631301e..c0f6d9e 100644
--- a/src/libGLESv2/formatutils.cpp
+++ b/src/libGLESv2/formatutils.cpp
@@ -1590,9 +1590,4 @@
     return (iter != formats.end()) ? iter->second.mColorWriteFunction : NULL;
 }
 
-bool IsFastCopyBufferToTextureSupported(GLint internalFormat, GLuint clientVersion)
-{
-    return false;
-}
-
 }
diff --git a/src/libGLESv2/formatutils.h b/src/libGLESv2/formatutils.h
index 2cb243a..323a981 100644
--- a/src/libGLESv2/formatutils.h
+++ b/src/libGLESv2/formatutils.h
@@ -88,8 +88,6 @@
 
 ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type, GLuint clientVersion);
 
-bool IsFastCopyBufferToTextureSupported(GLint internalFormat, GLuint clientVersion);
-
 }
 
 #endif LIBGLESV2_FORMATUTILS_H_
diff --git a/src/libGLESv2/renderer/Renderer.h b/src/libGLESv2/renderer/Renderer.h
index 2183781..6fb0bf6 100644
--- a/src/libGLESv2/renderer/Renderer.h
+++ b/src/libGLESv2/renderer/Renderer.h
@@ -260,6 +260,7 @@
     int getCurrentClientVersion() const { return mCurrentClientVersion; }
 
     // Buffer-to-texture and Texture-to-buffer copies
+    virtual bool supportsFastCopyBufferToTexture(GLint internalFormat) const = 0;
     virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
                                          GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea) = 0;
 
diff --git a/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp b/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp
index 54d68a5..4e8908d 100644
--- a/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp
+++ b/src/libGLESv2/renderer/d3d11/PixelTransfer11.cpp
@@ -152,7 +152,7 @@
     int clientVersion = mRenderer->getCurrentClientVersion();
     const gl::Buffer &sourceBuffer = *unpack.pixelBuffer.get();
 
-    ASSERT(gl::IsFastCopyBufferToTextureSupported(destinationFormat, clientVersion));
+    ASSERT(mRenderer->supportsFastCopyBufferToTexture(destinationFormat));
 
     ID3D11PixelShader *pixelShader = findBufferToTexturePS(destinationFormat);
     ASSERT(pixelShader);
diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
index 94974e8..8d2b32d 100644
--- a/src/libGLESv2/renderer/d3d11/Renderer11.cpp
+++ b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
@@ -2767,10 +2767,16 @@
     return new Fence11(this);
 }
 
+bool Renderer11::supportsFastCopyBufferToTexture(GLint internalFormat) const
+{
+    //TODO
+    return false;
+}
+
 bool Renderer11::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
                                          GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
 {
-    ASSERT(gl::IsFastCopyBufferToTextureSupported(destinationFormat, getCurrentClientVersion()));
+    ASSERT(supportsFastCopyBufferToTexture(destinationFormat));
     return mPixelTransfer->copyBufferToTexture(unpack, offset, destRenderTarget, destinationFormat, sourcePixelsType, destArea);
 }
 
diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.h b/src/libGLESv2/renderer/d3d11/Renderer11.h
index 4f3837a..226c963 100644
--- a/src/libGLESv2/renderer/d3d11/Renderer11.h
+++ b/src/libGLESv2/renderer/d3d11/Renderer11.h
@@ -208,6 +208,7 @@
     Blit11 *getBlitter() { return mBlit; }
 
     // Buffer-to-texture and Texture-to-buffer copies
+    virtual bool supportsFastCopyBufferToTexture(GLint internalFormat) const;
     virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
                                          GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
 
diff --git a/src/libGLESv2/renderer/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d9/Renderer9.cpp
index ba318ad..5af41be 100644
--- a/src/libGLESv2/renderer/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d9/Renderer9.cpp
@@ -723,6 +723,12 @@
     return new Fence9(this);
 }
 
+bool Renderer9::supportsFastCopyBufferToTexture(GLint internalFormat) const
+{
+    // Pixel buffer objects are not supported in D3D9, since D3D9 is ES2-only and PBOs are ES3.
+    return false;
+}
+
 bool Renderer9::fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
                                         GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea)
 {
diff --git a/src/libGLESv2/renderer/d3d9/Renderer9.h b/src/libGLESv2/renderer/d3d9/Renderer9.h
index 75af803..3234794 100644
--- a/src/libGLESv2/renderer/d3d9/Renderer9.h
+++ b/src/libGLESv2/renderer/d3d9/Renderer9.h
@@ -217,6 +217,7 @@
     virtual FenceImpl *createFence();
 
     // Buffer-to-texture and Texture-to-buffer copies
+    virtual bool supportsFastCopyBufferToTexture(GLint internalFormat) const;
     virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
                                          GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);