Remove copyToRenderTarget methods.
These Renderer methods can be replaced with virtual TextureStorage
methods, now that we do not have TextureStorageInterface to
complicate matters. This reduces the number of stubs in Renderer
as well as allowing cleaner code re-use.
BUG=angle:729
Change-Id: I6d2004d4f1abdb1041420144cee1c173e5ab199e
Reviewed-on: https://chromium-review.googlesource.com/219839
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/renderer/Renderer.h b/src/libGLESv2/renderer/Renderer.h
index 17d759c..ca15a78 100644
--- a/src/libGLESv2/renderer/Renderer.h
+++ b/src/libGLESv2/renderer/Renderer.h
@@ -172,11 +172,6 @@
virtual int getMaxSwapInterval() const = 0;
// Pixel operations
- virtual gl::Error copyToRenderTarget2D(TextureStorage *dest, TextureStorage *source) = 0;
- virtual gl::Error copyToRenderTargetCube(TextureStorage *dest, TextureStorage *source) = 0;
- virtual gl::Error copyToRenderTarget3D(TextureStorage *dest, TextureStorage *source) = 0;
- virtual gl::Error copyToRenderTarget2DArray(TextureStorage *dest, TextureStorage *source) = 0;
-
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
diff --git a/src/libGLESv2/renderer/d3d/TextureD3D.cpp b/src/libGLESv2/renderer/d3d/TextureD3D.cpp
index 52e896e..5554e80 100644
--- a/src/libGLESv2/renderer/d3d/TextureD3D.cpp
+++ b/src/libGLESv2/renderer/d3d/TextureD3D.cpp
@@ -35,7 +35,8 @@
: mRenderer(renderer),
mUsage(GL_NONE),
mDirtyImages(true),
- mImmutable(false)
+ mImmutable(false),
+ mTexStorage(NULL)
{
}
@@ -54,13 +55,12 @@
// ensure the underlying texture is created
initializeStorage(false);
- TextureStorage *storage = getBaseLevelStorage();
- if (storage)
+ if (mTexStorage)
{
updateStorage();
}
- return storage;
+ return mTexStorage;
}
GLint TextureD3D::getBaseLevelWidth() const
@@ -242,6 +242,11 @@
return gl::log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1;
}
+TextureStorage *TextureD3D::getStorage()
+{
+ return mTexStorage;
+}
+
void TextureD3D::generateMipmaps()
{
// Set up proper image sizes.
@@ -280,8 +285,7 @@
}
TextureD3D_2D::TextureD3D_2D(Renderer *renderer)
- : TextureD3D(renderer),
- mTexStorage(NULL)
+ : TextureD3D(renderer)
{
for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
{
@@ -765,7 +769,7 @@
{
TextureStorage *newRenderTargetStorage = createCompleteStorage(true);
- if (mRenderer->copyToRenderTarget2D(newRenderTargetStorage, mTexStorage).isError())
+ if (mTexStorage->copyToStorage(newRenderTargetStorage).isError())
{
delete newRenderTargetStorage;
return gl::error(GL_OUT_OF_MEMORY, false);
@@ -778,11 +782,6 @@
return (mTexStorage && mTexStorage->isRenderTarget());
}
-TextureStorage *TextureD3D_2D::getBaseLevelStorage()
-{
- return mTexStorage;
-}
-
const ImageD3D *TextureD3D_2D::getBaseLevelImage() const
{
return mImageArray[0];
@@ -857,8 +856,7 @@
}
TextureD3D_Cube::TextureD3D_Cube(Renderer *renderer)
- : TextureD3D(renderer),
- mTexStorage(NULL)
+ : TextureD3D(renderer)
{
for (int i = 0; i < 6; i++)
{
@@ -1241,7 +1239,7 @@
{
TextureStorage *newRenderTargetStorage = createCompleteStorage(true);
- if (mRenderer->copyToRenderTargetCube(newRenderTargetStorage, mTexStorage).isError())
+ if (mTexStorage->copyToStorage(newRenderTargetStorage).isError())
{
delete newRenderTargetStorage;
return gl::error(GL_OUT_OF_MEMORY, false);
@@ -1254,11 +1252,6 @@
return (mTexStorage && mTexStorage->isRenderTarget());
}
-TextureStorage *TextureD3D_Cube::getBaseLevelStorage()
-{
- return mTexStorage;
-}
-
const ImageD3D *TextureD3D_Cube::getBaseLevelImage() const
{
// Note: if we are not cube-complete, there is no single base level image that can describe all
@@ -1384,8 +1377,7 @@
}
TextureD3D_3D::TextureD3D_3D(Renderer *renderer)
- : TextureD3D(renderer),
- mTexStorage(NULL)
+ : TextureD3D(renderer)
{
for (int i = 0; i < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++i)
{
@@ -1779,7 +1771,7 @@
{
TextureStorage *newRenderTargetStorage = createCompleteStorage(true);
- if (mRenderer->copyToRenderTarget3D(newRenderTargetStorage, mTexStorage).isError())
+ if (mTexStorage->copyToStorage(newRenderTargetStorage).isError())
{
delete newRenderTargetStorage;
return gl::error(GL_OUT_OF_MEMORY, false);
@@ -1792,11 +1784,6 @@
return (mTexStorage && mTexStorage->isRenderTarget());
}
-TextureStorage *TextureD3D_3D::getBaseLevelStorage()
-{
- return mTexStorage;
-}
-
const ImageD3D *TextureD3D_3D::getBaseLevelImage() const
{
return mImageArray[0];
@@ -1927,8 +1914,7 @@
}
TextureD3D_2DArray::TextureD3D_2DArray(Renderer *renderer)
- : TextureD3D(renderer),
- mTexStorage(NULL)
+ : TextureD3D(renderer)
{
for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; ++level)
{
@@ -2292,7 +2278,7 @@
{
TextureStorage *newRenderTargetStorage = createCompleteStorage(true);
- if (mRenderer->copyToRenderTarget2DArray(newRenderTargetStorage, mTexStorage).isError())
+ if (mTexStorage->copyToStorage(newRenderTargetStorage).isError())
{
delete newRenderTargetStorage;
return gl::error(GL_OUT_OF_MEMORY, false);
@@ -2310,11 +2296,6 @@
return (mLayerCounts[0] > 0 ? mImageArray[0][0] : NULL);
}
-TextureStorage *TextureD3D_2DArray::getBaseLevelStorage()
-{
- return mTexStorage;
-}
-
bool TextureD3D_2DArray::isValidLevel(int level) const
{
return (mTexStorage ? (level >= 0 && level < mTexStorage->getLevelCount()) : 0);
diff --git a/src/libGLESv2/renderer/d3d/TextureD3D.h b/src/libGLESv2/renderer/d3d/TextureD3D.h
index 4822b74..bc378bb 100644
--- a/src/libGLESv2/renderer/d3d/TextureD3D.h
+++ b/src/libGLESv2/renderer/d3d/TextureD3D.h
@@ -59,6 +59,7 @@
virtual gl::ImageIndex getImageIndex(GLint mip, GLint layer) const = 0;
virtual void generateMipmaps();
+ TextureStorage *getStorage();
protected:
gl::Error setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image);
@@ -82,6 +83,7 @@
bool mDirtyImages;
bool mImmutable;
+ TextureStorage *mTexStorage;
private:
DISALLOW_COPY_AND_ASSIGN(TextureD3D);
@@ -89,7 +91,6 @@
virtual void initializeStorage(bool renderTarget) = 0;
virtual void updateStorage() = 0;
- virtual TextureStorage *getBaseLevelStorage() = 0;
virtual const ImageD3D *getBaseLevelImage() const = 0;
};
@@ -135,7 +136,6 @@
virtual void updateStorage();
bool ensureRenderTarget();
- virtual TextureStorage *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
@@ -147,7 +147,6 @@
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height);
gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
- TextureStorage *mTexStorage;
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
};
@@ -194,7 +193,6 @@
virtual void updateStorage();
bool ensureRenderTarget();
- virtual TextureStorage *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
@@ -207,8 +205,6 @@
gl::Error commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
ImageD3D *mImageArray[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- TextureStorage *mTexStorage;
};
class TextureD3D_3D : public TextureD3D
@@ -253,7 +249,6 @@
virtual void updateStorage();
bool ensureRenderTarget();
- virtual TextureStorage *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
@@ -265,8 +260,6 @@
gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- TextureStorage *mTexStorage;
};
class TextureD3D_2DArray : public TextureD3D
@@ -311,7 +304,6 @@
virtual void updateStorage();
bool ensureRenderTarget();
- virtual TextureStorage *getBaseLevelStorage();
virtual const ImageD3D *getBaseLevelImage() const;
virtual void initMipmapsImages();
@@ -329,8 +321,6 @@
// sense for the Image class to not have to worry about layer subresource as well as mip subresources.
GLsizei mLayerCounts[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
ImageD3D **mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- TextureStorage *mTexStorage;
};
}
diff --git a/src/libGLESv2/renderer/d3d/TextureStorage.h b/src/libGLESv2/renderer/d3d/TextureStorage.h
index adfee22..1e1c365 100644
--- a/src/libGLESv2/renderer/d3d/TextureStorage.h
+++ b/src/libGLESv2/renderer/d3d/TextureStorage.h
@@ -10,6 +10,7 @@
#define LIBGLESV2_RENDERER_TEXTURESTORAGE_H_
#include "common/debug.h"
+#include "libGLESv2/Error.h"
#include <GLES2/gl2.h>
@@ -38,6 +39,8 @@
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index) = 0;
virtual void generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex) = 0;
+ virtual gl::Error copyToStorage(TextureStorage *destStorage) = 0;
+
unsigned int getRenderTargetSerial(const gl::ImageIndex &index) const;
unsigned int getTextureSerial() const;
diff --git a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
index c712ee7..4a5a20c 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
@@ -1880,62 +1880,6 @@
return 4;
}
-gl::Error Renderer11::copyToRenderTarget2D(TextureStorage *dest, TextureStorage *source)
-{
- ASSERT(source && dest);
-
- TextureStorage11_2D *source11 = TextureStorage11_2D::makeTextureStorage11_2D(source);
- TextureStorage11_2D *dest11 = TextureStorage11_2D::makeTextureStorage11_2D(dest);
-
- mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
-
- dest11->invalidateSwizzleCache();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::copyToRenderTargetCube(TextureStorage *dest, TextureStorage *source)
-{
- ASSERT(source && dest);
-
- TextureStorage11_Cube *source11 = TextureStorage11_Cube::makeTextureStorage11_Cube(source);
- TextureStorage11_Cube *dest11 = TextureStorage11_Cube::makeTextureStorage11_Cube(dest);
-
- mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
-
- dest11->invalidateSwizzleCache();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::copyToRenderTarget3D(TextureStorage *dest, TextureStorage *source)
-{
- ASSERT(source && dest);
-
- TextureStorage11_3D *source11 = TextureStorage11_3D::makeTextureStorage11_3D(source);
- TextureStorage11_3D *dest11 = TextureStorage11_3D::makeTextureStorage11_3D(dest);
-
- mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
-
- dest11->invalidateSwizzleCache();
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer11::copyToRenderTarget2DArray(TextureStorage *dest, TextureStorage *source)
-{
- ASSERT(source && dest);
-
- TextureStorage11_2DArray *source11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(source);
- TextureStorage11_2DArray *dest11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(dest);
-
- mDeviceContext->CopyResource(dest11->getResource(), source11->getResource());
-
- dest11->invalidateSwizzleCache();
-
- return gl::Error(GL_NO_ERROR);
-}
-
gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level)
{
diff --git a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h
index e435c59..ea0276b 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h
+++ b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h
@@ -115,11 +115,6 @@
virtual int getMaxSwapInterval() const;
// Pixel operations
- virtual gl::Error copyToRenderTarget2D(TextureStorage *dest, TextureStorage *source);
- virtual gl::Error copyToRenderTargetCube(TextureStorage *dest, TextureStorage *source);
- virtual gl::Error copyToRenderTarget3D(TextureStorage *dest, TextureStorage *source);
- virtual gl::Error copyToRenderTarget2DArray(TextureStorage *dest, TextureStorage *source);
-
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
diff --git a/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp b/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp
index 8b4a62e..faec0bb 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.cpp
@@ -400,6 +400,20 @@
}
}
+gl::Error TextureStorage11::copyToStorage(TextureStorage *destStorage)
+{
+ ASSERT(destStorage);
+
+ TextureStorage11 *dest11 = TextureStorage11::makeTextureStorage11(destStorage);
+
+ ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
+ immediateContext->CopyResource(dest11->getResource(), getResource());
+
+ dest11->invalidateSwizzleCache();
+
+ return gl::Error(GL_NO_ERROR);
+}
+
TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, SwapChain11 *swapchain)
: TextureStorage11(renderer, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE),
mTexture(swapchain->getOffscreenTexture()),
diff --git a/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h b/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h
index 8156dc9..4b2d34d 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h
+++ b/src/libGLESv2/renderer/d3d/d3d11/TextureStorage11.h
@@ -70,6 +70,8 @@
virtual bool isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage) = 0;
virtual void releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage) = 0;
+ virtual gl::Error copyToStorage(TextureStorage *destStorage);
+
protected:
TextureStorage11(Renderer *renderer, UINT bindFlags);
int getLevelWidth(int mipLevel) const;
diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
index 2b92d5a..5fef290 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
@@ -2337,76 +2337,6 @@
return mMaxSwapInterval;
}
-gl::Error Renderer9::copyToRenderTarget2D(TextureStorage *dest, TextureStorage *source)
-{
- ASSERT(source && dest);
-
- TextureStorage9_2D *source9 = TextureStorage9_2D::makeTextureStorage9_2D(source);
- TextureStorage9_2D *dest9 = TextureStorage9_2D::makeTextureStorage9_2D(dest);
-
- int levels = source9->getLevelCount();
- for (int i = 0; i < levels; ++i)
- {
- IDirect3DSurface9 *srcSurf = source9->getSurfaceLevel(i, false);
- IDirect3DSurface9 *dstSurf = dest9->getSurfaceLevel(i, false);
-
- gl::Error error = copyToRenderTarget(dstSurf, srcSurf, source9->isManaged());
-
- SafeRelease(srcSurf);
- SafeRelease(dstSurf);
-
- if (error.isError())
- {
- return error;
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::copyToRenderTargetCube(TextureStorage *dest, TextureStorage *source)
-{
- ASSERT(source && dest);
-
- TextureStorage9_Cube *source9 = TextureStorage9_Cube::makeTextureStorage9_Cube(source);
- TextureStorage9_Cube *dest9 = TextureStorage9_Cube::makeTextureStorage9_Cube(dest);
- int levels = source9->getLevelCount();
- for (int f = 0; f < 6; f++)
- {
- for (int i = 0; i < levels; i++)
- {
- IDirect3DSurface9 *srcSurf = source9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, false);
- IDirect3DSurface9 *dstSurf = dest9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, true);
-
- gl::Error error = copyToRenderTarget(dstSurf, srcSurf, source9->isManaged());
-
- SafeRelease(srcSurf);
- SafeRelease(dstSurf);
-
- if (error.isError())
- {
- return error;
- }
- }
- }
-
- return gl::Error(GL_NO_ERROR);
-}
-
-gl::Error Renderer9::copyToRenderTarget3D(TextureStorage *dest, TextureStorage *source)
-{
- // 3D textures are not available in the D3D9 backend.
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
-gl::Error Renderer9::copyToRenderTarget2DArray(TextureStorage *dest, TextureStorage *source)
-{
- // 2D array textures are not supported by the D3D9 backend.
- UNREACHABLE();
- return gl::Error(GL_INVALID_OPERATION);
-}
-
D3DPOOL Renderer9::getBufferPool(DWORD usage) const
{
if (mD3d9Ex != NULL)
diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h
index f570cac..a3e3d8e 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h
+++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h
@@ -119,11 +119,6 @@
virtual int getMaxSwapInterval() const;
// Pixel operations
- virtual gl::Error copyToRenderTarget2D(TextureStorage *dest, TextureStorage *source);
- virtual gl::Error copyToRenderTargetCube(TextureStorage *dest, TextureStorage *source);
- virtual gl::Error copyToRenderTarget3D(TextureStorage *dest, TextureStorage *source);
- virtual gl::Error copyToRenderTarget2DArray(TextureStorage *dest, TextureStorage *source);
-
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
@@ -198,6 +193,8 @@
virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const;
+ gl::Error copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
+
private:
DISALLOW_COPY_AND_ASSIGN(Renderer9);
@@ -215,7 +212,6 @@
gl::Error getCountingIB(size_t count, StaticIndexBufferInterface **outIB);
- gl::Error copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
gl::FramebufferAttachment *getNullColorbuffer(gl::FramebufferAttachment *depthbuffer);
D3DPOOL getBufferPool(DWORD usage) const;
diff --git a/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp b/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp
index 2bed1ae..c9c8806 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.cpp
@@ -195,6 +195,32 @@
}
}
+gl::Error TextureStorage9_2D::copyToStorage(TextureStorage *destStorage)
+{
+ ASSERT(destStorage);
+
+ TextureStorage9_2D *dest9 = TextureStorage9_2D::makeTextureStorage9_2D(destStorage);
+
+ int levels = getLevelCount();
+ for (int i = 0; i < levels; ++i)
+ {
+ IDirect3DSurface9 *srcSurf = getSurfaceLevel(i, false);
+ IDirect3DSurface9 *dstSurf = dest9->getSurfaceLevel(i, false);
+
+ gl::Error error = mRenderer->copyToRenderTarget(dstSurf, srcSurf, isManaged());
+
+ SafeRelease(srcSurf);
+ SafeRelease(dstSurf);
+
+ if (error.isError())
+ {
+ return error;
+ }
+ }
+
+ return gl::Error(GL_NO_ERROR);
+}
+
TextureStorage9_Cube::TextureStorage9_Cube(Renderer *renderer, GLenum internalformat, bool renderTarget, int size, int levels)
: TextureStorage9(renderer, GetTextureUsage(internalformat, renderTarget))
{
@@ -307,4 +333,33 @@
}
}
-}
\ No newline at end of file
+gl::Error TextureStorage9_Cube::copyToStorage(TextureStorage *destStorage)
+{
+ ASSERT(destStorage);
+
+ TextureStorage9_Cube *dest9 = TextureStorage9_Cube::makeTextureStorage9_Cube(destStorage);
+
+ int levels = getLevelCount();
+ for (int f = 0; f < 6; f++)
+ {
+ for (int i = 0; i < levels; i++)
+ {
+ IDirect3DSurface9 *srcSurf = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, false);
+ IDirect3DSurface9 *dstSurf = dest9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, i, true);
+
+ gl::Error error = mRenderer->copyToRenderTarget(dstSurf, srcSurf, isManaged());
+
+ SafeRelease(srcSurf);
+ SafeRelease(dstSurf);
+
+ if (error.isError())
+ {
+ return error;
+ }
+ }
+ }
+
+ return gl::Error(GL_NO_ERROR);
+}
+
+}
diff --git a/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h b/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h
index 75eb90d..3b70a22 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h
+++ b/src/libGLESv2/renderer/d3d/d3d9/TextureStorage9.h
@@ -68,6 +68,7 @@
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual IDirect3DBaseTexture9 *getBaseTexture() const;
virtual void generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
+ virtual gl::Error copyToStorage(TextureStorage *destStorage);
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage9_2D);
@@ -90,6 +91,7 @@
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual IDirect3DBaseTexture9 *getBaseTexture() const;
virtual void generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
+ virtual gl::Error copyToStorage(TextureStorage *destStorage);
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage9_Cube);