Commit 6b51c1a0 by Jamie Madill

Use ImageIndex in copyToStorage.

Also change the image association methods in TexStorage to use ImageIndex, for consistency and compatibility. BUG=angle:729 Change-Id: I05afa803735c9b93ae7d623fee5e6899c9ccec28 Reviewed-on: https://chromium-review.googlesource.com/221722Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c8d13843
...@@ -48,6 +48,11 @@ ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex) ...@@ -48,6 +48,11 @@ ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex)
return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex); return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
} }
ImageIndex ImageIndex::MakeInvalid()
{
return ImageIndex(GL_NONE, -1, -1);
}
ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn) ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
: type(typeIn), : type(typeIn),
mipIndex(mipIndexIn), mipIndex(mipIndexIn),
......
...@@ -31,6 +31,7 @@ struct ImageIndex ...@@ -31,6 +31,7 @@ struct ImageIndex
static ImageIndex MakeCube(GLenum target, GLint mipIndex); static ImageIndex MakeCube(GLenum target, GLint mipIndex);
static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex); static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex);
static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL); static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL);
static ImageIndex MakeInvalid();
static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1); static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1);
}; };
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
namespace gl namespace gl
{ {
class Framebuffer; class Framebuffer;
struct ImageIndex;
struct Box;
} }
namespace rx namespace rx
...@@ -37,10 +39,10 @@ class ImageD3D : public Image ...@@ -37,10 +39,10 @@ class ImageD3D : public Image
virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level) {}; virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level) {};
virtual void setManagedSurface3D(TextureStorage *storage, int level) {}; virtual void setManagedSurface3D(TextureStorage *storage, int level) {};
virtual void setManagedSurface2DArray(TextureStorage *storage, int layer, int level) {}; virtual void setManagedSurface2DArray(TextureStorage *storage, int layer, int level) {};
virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; virtual gl::Error copyToStorage2D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0;
virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; virtual gl::Error copyToStorageCube(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0;
virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = 0; virtual gl::Error copyToStorage3D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0;
virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) = 0; virtual gl::Error copyToStorage2DArray(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(ImageD3D); DISALLOW_COPY_AND_ASSIGN(ImageD3D);
......
...@@ -850,7 +850,7 @@ gl::Error TextureD3D_2D::commitRegion(const gl::ImageIndex &index, const gl::Box ...@@ -850,7 +850,7 @@ gl::Error TextureD3D_2D::commitRegion(const gl::ImageIndex &index, const gl::Box
if (isValidLevel(level)) if (isValidLevel(level))
{ {
ImageD3D *image = mImageArray[level]; ImageD3D *image = mImageArray[level];
gl::Error error = image->copyToStorage2D(mTexStorage, level, region.x, region.y, region.width, region.height); gl::Error error = image->copyToStorage2D(mTexStorage, index, region);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -1319,7 +1319,7 @@ gl::Error TextureD3D_Cube::commitRegion(const gl::ImageIndex &index, const gl::B ...@@ -1319,7 +1319,7 @@ gl::Error TextureD3D_Cube::commitRegion(const gl::ImageIndex &index, const gl::B
if (isValidFaceLevel(faceIndex, level)) if (isValidFaceLevel(faceIndex, level))
{ {
ImageD3D *image = mImageArray[faceIndex][level]; ImageD3D *image = mImageArray[faceIndex][level];
gl::Error error = image->copyToStorageCube(mTexStorage, faceIndex, level, region.x, region.y, region.width, region.height); gl::Error error = image->copyToStorageCube(mTexStorage, index, region);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -1813,7 +1813,7 @@ gl::Error TextureD3D_3D::commitRegion(const gl::ImageIndex &index, const gl::Box ...@@ -1813,7 +1813,7 @@ gl::Error TextureD3D_3D::commitRegion(const gl::ImageIndex &index, const gl::Box
if (isValidLevel(level)) if (isValidLevel(level))
{ {
ImageD3D *image = mImageArray[level]; ImageD3D *image = mImageArray[level];
gl::Error error = image->copyToStorage3D(mTexStorage, level, region.x, region.y, region.z, region.width, region.height, region.depth); gl::Error error = image->copyToStorage3D(mTexStorage, index, region);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -2322,7 +2322,7 @@ gl::Error TextureD3D_2DArray::commitRegion(const gl::ImageIndex &index, const gl ...@@ -2322,7 +2322,7 @@ gl::Error TextureD3D_2DArray::commitRegion(const gl::ImageIndex &index, const gl
if (isValidLevel(level) && layerTarget < getLayerCount(level)) if (isValidLevel(level) && layerTarget < getLayerCount(level))
{ {
ImageD3D *image = mImageArray[level][layerTarget]; ImageD3D *image = mImageArray[level][layerTarget];
gl::Error error = image->copyToStorage2DArray(mTexStorage, level, region.x, region.y, layerTarget, region.width, region.height); gl::Error error = image->copyToStorage2DArray(mTexStorage, index, region);
if (error.isError()) if (error.isError())
{ {
return error; return error;
......
...@@ -23,15 +23,16 @@ namespace rx ...@@ -23,15 +23,16 @@ namespace rx
{ {
Image11::Image11() Image11::Image11()
: mRenderer(NULL),
mDXGIFormat(DXGI_FORMAT_UNKNOWN),
mStagingTexture(NULL),
mStagingSubresource(0),
mRecoverFromStorage(false),
mAssociatedStorage(NULL),
mAssociatedImageIndex(gl::ImageIndex::MakeInvalid()),
mRecoveredFromStorageCount(0)
{ {
mStagingTexture = NULL;
mRenderer = NULL;
mDXGIFormat = DXGI_FORMAT_UNKNOWN;
mRecoverFromStorage = false;
mAssociatedStorage = NULL;
mAssociatedStorageLevel = 0;
mAssociatedStorageLayerTarget = 0;
mRecoveredFromStorageCount = 0;
} }
Image11::~Image11() Image11::~Image11()
...@@ -100,31 +101,31 @@ bool Image11::isDirty() const ...@@ -100,31 +101,31 @@ bool Image11::isDirty() const
return mDirty; return mDirty;
} }
gl::Error Image11::copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image11::copyToStorage2D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
TextureStorage11_2D *storage11 = TextureStorage11_2D::makeTextureStorage11_2D(storage); TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(storage);
return copyToStorageImpl(storage11, level, 0, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, index, region);
} }
gl::Error Image11::copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image11::copyToStorageCube(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
TextureStorage11_Cube *storage11 = TextureStorage11_Cube::makeTextureStorage11_Cube(storage); TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(storage);
return copyToStorageImpl(storage11, level, face, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, index, region);
} }
gl::Error Image11::copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) gl::Error Image11::copyToStorage3D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage); TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(storage);
return copyToStorageImpl(storage11, level, 0, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, index, region);
} }
gl::Error Image11::copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height) gl::Error Image11::copyToStorage2DArray(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage); TextureStorage11 *storage11 = TextureStorage11::makeTextureStorage11(storage);
return copyToStorageImpl(storage11, level, arrayLayer, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, index, region);
} }
gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, const gl::ImageIndex &index, const gl::Box &region)
{ {
// If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times, // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times,
// then we should just keep the staging texture around to prevent the copying from impacting perf. // then we should just keep the staging texture around to prevent the copying from impacting perf.
...@@ -135,11 +136,11 @@ gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int ...@@ -135,11 +136,11 @@ gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int
if (attemptToReleaseStagingTexture) if (attemptToReleaseStagingTexture)
{ {
// If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it. // If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it.
storage11->releaseAssociatedImage(level, layerTarget, this); storage11->releaseAssociatedImage(index, this);
} }
gl::Error error = storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, layerTarget, gl::Error error = storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(),
xoffset, yoffset, 0, width, height, 1); index, region);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -148,12 +149,11 @@ gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int ...@@ -148,12 +149,11 @@ gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int
// Once the image data has been copied into the Storage, we can release it locally. // Once the image data has been copied into the Storage, we can release it locally.
if (attemptToReleaseStagingTexture) if (attemptToReleaseStagingTexture)
{ {
storage11->associateImage(this, level, layerTarget); storage11->associateImage(this, index);
releaseStagingTexture(); releaseStagingTexture();
mRecoverFromStorage = true; mRecoverFromStorage = true;
mAssociatedStorage = storage11; mAssociatedStorage = storage11;
mAssociatedStorageLevel = level; mAssociatedImageIndex = index;
mAssociatedStorageLayerTarget = layerTarget;
} }
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
...@@ -170,7 +170,7 @@ bool Image11::recoverFromAssociatedStorage() ...@@ -170,7 +170,7 @@ bool Image11::recoverFromAssociatedStorage()
{ {
createStagingTexture(); createStagingTexture();
bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedStorageLevel, mAssociatedStorageLayerTarget, this); bool textureStorageCorrect = mAssociatedStorage->isAssociatedImageValid(mAssociatedImageIndex, this);
// This means that the cached TextureStorage has been modified after this Image11 released its copy of its data. // This means that the cached TextureStorage has been modified after this Image11 released its copy of its data.
// This should not have happened. The TextureStorage should have told this Image11 to recover its data before it was overwritten. // This should not have happened. The TextureStorage should have told this Image11 to recover its data before it was overwritten.
...@@ -179,7 +179,8 @@ bool Image11::recoverFromAssociatedStorage() ...@@ -179,7 +179,8 @@ bool Image11::recoverFromAssociatedStorage()
if (textureStorageCorrect) if (textureStorageCorrect)
{ {
// CopySubResource from the Storage to the Staging texture // CopySubResource from the Storage to the Staging texture
mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedStorageLevel, mAssociatedStorageLayerTarget, 0, 0, 0, mWidth, mHeight, mDepth); gl::Box region(0, 0, 0, mWidth, mHeight, mDepth);
mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region);
mRecoveredFromStorageCount += 1; mRecoveredFromStorageCount += 1;
} }
...@@ -197,12 +198,11 @@ void Image11::disassociateStorage() ...@@ -197,12 +198,11 @@ void Image11::disassociateStorage()
if (mRecoverFromStorage) if (mRecoverFromStorage)
{ {
// Make the texturestorage release the Image11 too // Make the texturestorage release the Image11 too
mAssociatedStorage->disassociateImage(mAssociatedStorageLevel, mAssociatedStorageLayerTarget, this); mAssociatedStorage->disassociateImage(mAssociatedImageIndex, this);
mRecoverFromStorage = false; mRecoverFromStorage = false;
mAssociatedStorage = NULL; mAssociatedStorage = NULL;
mAssociatedStorageLevel = 0; mAssociatedImageIndex = gl::ImageIndex::MakeInvalid();
mAssociatedStorageLayerTarget = 0;
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_IMAGE11_H_ #define LIBGLESV2_RENDERER_IMAGE11_H_
#include "libGLESv2/renderer/d3d/ImageD3D.h" #include "libGLESv2/renderer/d3d/ImageD3D.h"
#include "libGLESv2/ImageIndex.h"
#include "common/debug.h" #include "common/debug.h"
...@@ -37,10 +38,10 @@ class Image11 : public ImageD3D ...@@ -37,10 +38,10 @@ class Image11 : public ImageD3D
virtual bool isDirty() const; virtual bool isDirty() const;
virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorageCube(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); virtual gl::Error copyToStorage3D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2DArray(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease); virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
...@@ -64,7 +65,7 @@ class Image11 : public ImageD3D ...@@ -64,7 +65,7 @@ class Image11 : public ImageD3D
private: private:
DISALLOW_COPY_AND_ASSIGN(Image11); DISALLOW_COPY_AND_ASSIGN(Image11);
gl::Error copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error copyToStorageImpl(TextureStorage11 *storage11, const gl::ImageIndex &index, const gl::Box &region);
ID3D11Resource *getStagingTexture(); ID3D11Resource *getStagingTexture();
unsigned int getStagingSubresource(); unsigned int getStagingSubresource();
...@@ -79,8 +80,7 @@ class Image11 : public ImageD3D ...@@ -79,8 +80,7 @@ class Image11 : public ImageD3D
bool mRecoverFromStorage; bool mRecoverFromStorage;
TextureStorage11 *mAssociatedStorage; TextureStorage11 *mAssociatedStorage;
int mAssociatedStorageLevel; gl::ImageIndex mAssociatedImageIndex;
int mAssociatedStorageLayerTarget;
unsigned int mRecoveredFromStorageCount; unsigned int mRecoveredFromStorageCount;
}; };
......
...@@ -184,14 +184,17 @@ int TextureStorage11::getLevelDepth(int mipLevel) const ...@@ -184,14 +184,17 @@ int TextureStorage11::getLevelDepth(int mipLevel) const
return std::max(static_cast<int>(mTextureDepth) >> mipLevel, 1); return std::max(static_cast<int>(mTextureDepth) >> mipLevel, 1);
} }
UINT TextureStorage11::getSubresourceIndex(int mipLevel, int layerTarget) const UINT TextureStorage11::getSubresourceIndex(const gl::ImageIndex &index) const
{ {
UINT index = 0; UINT subresource = 0;
if (getResource()) if (getResource())
{ {
index = D3D11CalcSubresource(mipLevel + mTopLevel, layerTarget, mMipLevels); UINT mipSlice = static_cast<UINT>(index.mipIndex + mTopLevel);
UINT arraySlice = static_cast<UINT>(index.hasLayer() ? index.layerIndex : 0);
subresource = D3D11CalcSubresource(mipSlice, arraySlice, mMipLevels);
ASSERT(subresource != std::numeric_limits<UINT>::max());
} }
return index; return subresource;
} }
ID3D11ShaderResourceView *TextureStorage11::getSRV(const gl::SamplerState &samplerState) ID3D11ShaderResourceView *TextureStorage11::getSRV(const gl::SamplerState &samplerState)
...@@ -289,15 +292,15 @@ void TextureStorage11::invalidateSwizzleCache() ...@@ -289,15 +292,15 @@ void TextureStorage11::invalidateSwizzleCache()
} }
gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsigned int sourceSubresource, gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsigned int sourceSubresource,
int level, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, const gl::ImageIndex &index, const gl::Box &copyArea)
GLsizei width, GLsizei height, GLsizei depth)
{ {
ASSERT(srcTexture); ASSERT(srcTexture);
GLint level = index.mipIndex;
invalidateSwizzleCacheLevel(level); invalidateSwizzleCacheLevel(level);
gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level)); gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
gl::Box copyArea(xoffset, yoffset, zoffset, width, height, depth);
bool fullCopy = copyArea.x == 0 && bool fullCopy = copyArea.x == 0 &&
copyArea.y == 0 && copyArea.y == 0 &&
...@@ -307,7 +310,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u ...@@ -307,7 +310,7 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u
copyArea.depth == texSize.depth; copyArea.depth == texSize.depth;
ID3D11Resource *dstTexture = getResource(); ID3D11Resource *dstTexture = getResource();
unsigned int dstSubresource = getSubresourceIndex(level, layerTarget); unsigned int dstSubresource = getSubresourceIndex(index);
ASSERT(dstTexture); ASSERT(dstTexture);
...@@ -328,8 +331,8 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u ...@@ -328,8 +331,8 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u
D3D11_BOX srcBox; D3D11_BOX srcBox;
srcBox.left = copyArea.x; srcBox.left = copyArea.x;
srcBox.top = copyArea.y; srcBox.top = copyArea.y;
srcBox.right = copyArea.x + roundUp((unsigned int)width, dxgiFormatInfo.blockWidth); srcBox.right = copyArea.x + roundUp(static_cast<UINT>(copyArea.width), dxgiFormatInfo.blockWidth);
srcBox.bottom = copyArea.y + roundUp((unsigned int)height, dxgiFormatInfo.blockHeight); srcBox.bottom = copyArea.y + roundUp(static_cast<UINT>(copyArea.height), dxgiFormatInfo.blockHeight);
srcBox.front = copyArea.z; srcBox.front = copyArea.z;
srcBox.back = copyArea.z + copyArea.depth; srcBox.back = copyArea.z + copyArea.depth;
...@@ -342,19 +345,18 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u ...@@ -342,19 +345,18 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u
} }
bool TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource, bool TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
int level, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, const gl::ImageIndex &index, const gl::Box &region)
GLsizei width, GLsizei height, GLsizei depth)
{ {
if (dstTexture) if (dstTexture)
{ {
ID3D11Resource *srcTexture = getResource(); ID3D11Resource *srcTexture = getResource();
unsigned int srcSubresource = getSubresourceIndex(level, layerTarget); unsigned int srcSubresource = getSubresourceIndex(index);
ASSERT(srcTexture); ASSERT(srcTexture);
ID3D11DeviceContext *context = mRenderer->getDeviceContext(); ID3D11DeviceContext *context = mRenderer->getDeviceContext();
context->CopySubresourceRegion(dstTexture, dstSubresource, xoffset, yoffset, zoffset, context->CopySubresourceRegion(dstTexture, dstSubresource, region.x, region.y, region.z,
srcTexture, srcSubresource, NULL); srcTexture, srcSubresource, NULL);
return true; return true;
} }
...@@ -421,7 +423,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, const gl::Box & ...@@ -421,7 +423,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, const gl::Box &
ID3D11Resource *resource = getResource(); ID3D11Resource *resource = getResource();
ASSERT(resource); ASSERT(resource);
UINT destSubresource = getSubresourceIndex(index.mipIndex, index.hasLayer() ? index.layerIndex : 0); UINT destSubresource = getSubresourceIndex(index);
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat); const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
...@@ -616,8 +618,10 @@ TextureStorage11_2D *TextureStorage11_2D::makeTextureStorage11_2D(TextureStorage ...@@ -616,8 +618,10 @@ TextureStorage11_2D *TextureStorage11_2D::makeTextureStorage11_2D(TextureStorage
return static_cast<TextureStorage11_2D*>(storage); return static_cast<TextureStorage11_2D*>(storage);
} }
void TextureStorage11_2D::associateImage(Image11* image, int level, int layerTarget) void TextureStorage11_2D::associateImage(Image11* image, const gl::ImageIndex &index)
{ {
GLint level = index.mipIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
...@@ -626,8 +630,10 @@ void TextureStorage11_2D::associateImage(Image11* image, int level, int layerTar ...@@ -626,8 +630,10 @@ void TextureStorage11_2D::associateImage(Image11* image, int level, int layerTar
} }
} }
bool TextureStorage11_2D::isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage) bool TextureStorage11_2D::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
{ {
// This validation check should never return false. It means the Image/TextureStorage association is broken. // This validation check should never return false. It means the Image/TextureStorage association is broken.
...@@ -640,8 +646,10 @@ bool TextureStorage11_2D::isAssociatedImageValid(int level, int layerTarget, Ima ...@@ -640,8 +646,10 @@ bool TextureStorage11_2D::isAssociatedImageValid(int level, int layerTarget, Ima
} }
// disassociateImage allows an Image to end its association with a Storage. // disassociateImage allows an Image to end its association with a Storage.
void TextureStorage11_2D::disassociateImage(int level, int layerTarget, Image11* expectedImage) void TextureStorage11_2D::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
...@@ -656,8 +664,10 @@ void TextureStorage11_2D::disassociateImage(int level, int layerTarget, Image11* ...@@ -656,8 +664,10 @@ void TextureStorage11_2D::disassociateImage(int level, int layerTarget, Image11*
} }
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association. // releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_2D::releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage) void TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{ {
GLint level = index.mipIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
...@@ -959,8 +969,11 @@ TextureStorage11_Cube *TextureStorage11_Cube::makeTextureStorage11_Cube(TextureS ...@@ -959,8 +969,11 @@ TextureStorage11_Cube *TextureStorage11_Cube::makeTextureStorage11_Cube(TextureS
return static_cast<TextureStorage11_Cube*>(storage); return static_cast<TextureStorage11_Cube*>(storage);
} }
void TextureStorage11_Cube::associateImage(Image11* image, int level, int layerTarget) void TextureStorage11_Cube::associateImage(Image11* image, const gl::ImageIndex &index)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < 6); ASSERT(0 <= layerTarget && layerTarget < 6);
...@@ -973,8 +986,11 @@ void TextureStorage11_Cube::associateImage(Image11* image, int level, int layerT ...@@ -973,8 +986,11 @@ void TextureStorage11_Cube::associateImage(Image11* image, int level, int layerT
} }
} }
bool TextureStorage11_Cube::isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage) bool TextureStorage11_Cube::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
{ {
if (0 <= layerTarget && layerTarget < 6) if (0 <= layerTarget && layerTarget < 6)
...@@ -990,8 +1006,11 @@ bool TextureStorage11_Cube::isAssociatedImageValid(int level, int layerTarget, I ...@@ -990,8 +1006,11 @@ bool TextureStorage11_Cube::isAssociatedImageValid(int level, int layerTarget, I
} }
// disassociateImage allows an Image to end its association with a Storage. // disassociateImage allows an Image to end its association with a Storage.
void TextureStorage11_Cube::disassociateImage(int level, int layerTarget, Image11* expectedImage) void TextureStorage11_Cube::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < 6); ASSERT(0 <= layerTarget && layerTarget < 6);
...@@ -1010,8 +1029,11 @@ void TextureStorage11_Cube::disassociateImage(int level, int layerTarget, Image1 ...@@ -1010,8 +1029,11 @@ void TextureStorage11_Cube::disassociateImage(int level, int layerTarget, Image1
} }
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association. // releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_Cube::releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage) void TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(0 <= layerTarget && layerTarget < 6); ASSERT(0 <= layerTarget && layerTarget < 6);
...@@ -1350,8 +1372,10 @@ TextureStorage11_3D *TextureStorage11_3D::makeTextureStorage11_3D(TextureStorage ...@@ -1350,8 +1372,10 @@ TextureStorage11_3D *TextureStorage11_3D::makeTextureStorage11_3D(TextureStorage
return static_cast<TextureStorage11_3D*>(storage); return static_cast<TextureStorage11_3D*>(storage);
} }
void TextureStorage11_3D::associateImage(Image11* image, int level, int layerTarget) void TextureStorage11_3D::associateImage(Image11* image, const gl::ImageIndex &index)
{ {
GLint level = index.mipIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
...@@ -1360,8 +1384,10 @@ void TextureStorage11_3D::associateImage(Image11* image, int level, int layerTar ...@@ -1360,8 +1384,10 @@ void TextureStorage11_3D::associateImage(Image11* image, int level, int layerTar
} }
} }
bool TextureStorage11_3D::isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage) bool TextureStorage11_3D::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
{ {
// This validation check should never return false. It means the Image/TextureStorage association is broken. // This validation check should never return false. It means the Image/TextureStorage association is broken.
...@@ -1374,8 +1400,10 @@ bool TextureStorage11_3D::isAssociatedImageValid(int level, int layerTarget, Ima ...@@ -1374,8 +1400,10 @@ bool TextureStorage11_3D::isAssociatedImageValid(int level, int layerTarget, Ima
} }
// disassociateImage allows an Image to end its association with a Storage. // disassociateImage allows an Image to end its association with a Storage.
void TextureStorage11_3D::disassociateImage(int level, int layerTarget, Image11* expectedImage) void TextureStorage11_3D::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
...@@ -1390,8 +1418,10 @@ void TextureStorage11_3D::disassociateImage(int level, int layerTarget, Image11* ...@@ -1390,8 +1418,10 @@ void TextureStorage11_3D::disassociateImage(int level, int layerTarget, Image11*
} }
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association. // releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_3D::releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage) void TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{ {
GLint level = index.mipIndex;
ASSERT((0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)); ASSERT((0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS));
if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if (0 <= level && level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
...@@ -1702,8 +1732,11 @@ TextureStorage11_2DArray *TextureStorage11_2DArray::makeTextureStorage11_2DArray ...@@ -1702,8 +1732,11 @@ TextureStorage11_2DArray *TextureStorage11_2DArray::makeTextureStorage11_2DArray
return static_cast<TextureStorage11_2DArray*>(storage); return static_cast<TextureStorage11_2DArray*>(storage);
} }
void TextureStorage11_2DArray::associateImage(Image11* image, int level, int layerTarget) void TextureStorage11_2DArray::associateImage(Image11* image, const gl::ImageIndex &index)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
ASSERT(0 <= level && level < getLevelCount()); ASSERT(0 <= level && level < getLevelCount());
if (0 <= level && level < getLevelCount()) if (0 <= level && level < getLevelCount())
...@@ -1713,8 +1746,11 @@ void TextureStorage11_2DArray::associateImage(Image11* image, int level, int lay ...@@ -1713,8 +1746,11 @@ void TextureStorage11_2DArray::associateImage(Image11* image, int level, int lay
} }
} }
bool TextureStorage11_2DArray::isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage) bool TextureStorage11_2DArray::isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
LevelLayerKey key(level, layerTarget); LevelLayerKey key(level, layerTarget);
// This validation check should never return false. It means the Image/TextureStorage association is broken. // This validation check should never return false. It means the Image/TextureStorage association is broken.
...@@ -1724,8 +1760,11 @@ bool TextureStorage11_2DArray::isAssociatedImageValid(int level, int layerTarget ...@@ -1724,8 +1760,11 @@ bool TextureStorage11_2DArray::isAssociatedImageValid(int level, int layerTarget
} }
// disassociateImage allows an Image to end its association with a Storage. // disassociateImage allows an Image to end its association with a Storage.
void TextureStorage11_2DArray::disassociateImage(int level, int layerTarget, Image11* expectedImage) void TextureStorage11_2DArray::disassociateImage(const gl::ImageIndex &index, Image11* expectedImage)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
LevelLayerKey key(level, layerTarget); LevelLayerKey key(level, layerTarget);
bool imageAssociationCorrect = (mAssociatedImages.find(key) != mAssociatedImages.end() && (mAssociatedImages[key] == expectedImage)); bool imageAssociationCorrect = (mAssociatedImages.find(key) != mAssociatedImages.end() && (mAssociatedImages[key] == expectedImage));
...@@ -1738,8 +1777,11 @@ void TextureStorage11_2DArray::disassociateImage(int level, int layerTarget, Ima ...@@ -1738,8 +1777,11 @@ void TextureStorage11_2DArray::disassociateImage(int level, int layerTarget, Ima
} }
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association. // releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_2DArray::releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage) void TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{ {
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
LevelLayerKey key(level, layerTarget); LevelLayerKey key(level, layerTarget);
ASSERT(mAssociatedImages.find(key) != mAssociatedImages.end()); ASSERT(mAssociatedImages.find(key) != mAssociatedImages.end());
......
...@@ -51,24 +51,22 @@ class TextureStorage11 : public TextureStorage ...@@ -51,24 +51,22 @@ class TextureStorage11 : public TextureStorage
virtual bool isRenderTarget() const; virtual bool isRenderTarget() const;
virtual bool isManaged() const; virtual bool isManaged() const;
virtual int getLevelCount() const; virtual int getLevelCount() const;
UINT getSubresourceIndex(int mipLevel, int layerTarget) const; UINT getSubresourceIndex(const gl::ImageIndex &index) const;
gl::Error generateSwizzles(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha); gl::Error generateSwizzles(GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
void invalidateSwizzleCacheLevel(int mipLevel); void invalidateSwizzleCacheLevel(int mipLevel);
void invalidateSwizzleCache(); void invalidateSwizzleCache();
gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource, int level, gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource,
int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, const gl::ImageIndex &index, const gl::Box &copyArea);
GLsizei width, GLsizei height, GLsizei depth);
bool copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource, int level, bool copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, const gl::ImageIndex &index, const gl::Box &region);
GLsizei width, GLsizei height, GLsizei depth);
virtual void associateImage(Image11* image, int level, int layerTarget) = 0; virtual void associateImage(Image11* image, const gl::ImageIndex &index) = 0;
virtual void disassociateImage(int level, int layerTarget, Image11* expectedImage) = 0; virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage) = 0;
virtual bool isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage) = 0; virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage) = 0;
virtual void releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage) = 0; virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage) = 0;
virtual gl::Error copyToStorage(TextureStorage *destStorage); virtual gl::Error copyToStorage(TextureStorage *destStorage);
virtual gl::Error setData(const gl::ImageIndex &index, const gl::Box &sourceBox, GLenum internalFormat, GLenum type, virtual gl::Error setData(const gl::ImageIndex &index, const gl::Box &sourceBox, GLenum internalFormat, GLenum type,
...@@ -166,10 +164,10 @@ class TextureStorage11_2D : public TextureStorage11 ...@@ -166,10 +164,10 @@ class TextureStorage11_2D : public TextureStorage11
virtual ID3D11Resource *getResource() const; virtual ID3D11Resource *getResource() const;
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index); virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual void associateImage(Image11* image, int level, int layerTarget); virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(int level, int layerTarget, Image11* expectedImage); virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage); virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage); virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected: protected:
virtual ID3D11Resource *getSwizzleTexture(); virtual ID3D11Resource *getSwizzleTexture();
...@@ -200,10 +198,10 @@ class TextureStorage11_Cube : public TextureStorage11 ...@@ -200,10 +198,10 @@ class TextureStorage11_Cube : public TextureStorage11
virtual ID3D11Resource *getResource() const; virtual ID3D11Resource *getResource() const;
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index); virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual void associateImage(Image11* image, int level, int layerTarget); virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(int level, int layerTarget, Image11* expectedImage); virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage); virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage); virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected: protected:
virtual ID3D11Resource *getSwizzleTexture(); virtual ID3D11Resource *getSwizzleTexture();
...@@ -237,10 +235,10 @@ class TextureStorage11_3D : public TextureStorage11 ...@@ -237,10 +235,10 @@ class TextureStorage11_3D : public TextureStorage11
// Handles both layer and non-layer RTs // Handles both layer and non-layer RTs
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index); virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual void associateImage(Image11* image, int level, int layerTarget); virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(int level, int layerTarget, Image11* expectedImage); virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage); virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage); virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected: protected:
virtual ID3D11Resource *getSwizzleTexture(); virtual ID3D11Resource *getSwizzleTexture();
...@@ -276,10 +274,10 @@ class TextureStorage11_2DArray : public TextureStorage11 ...@@ -276,10 +274,10 @@ class TextureStorage11_2DArray : public TextureStorage11
virtual ID3D11Resource *getResource() const; virtual ID3D11Resource *getResource() const;
virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index); virtual RenderTarget *getRenderTarget(const gl::ImageIndex &index);
virtual void associateImage(Image11* image, int level, int layerTarget); virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(int level, int layerTarget, Image11* expectedImage); virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(int level, int layerTarget, Image11* expectedImage); virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(int level, int layerTarget, Image11* incomingImage); virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected: protected:
virtual ID3D11Resource *getSwizzleTexture(); virtual ID3D11Resource *getSwizzleTexture();
......
...@@ -301,36 +301,36 @@ void Image9::setManagedSurface(IDirect3DSurface9 *surface) ...@@ -301,36 +301,36 @@ void Image9::setManagedSurface(IDirect3DSurface9 *surface)
} }
} }
gl::Error Image9::copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToStorage2D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
ASSERT(getSurface() != NULL); ASSERT(getSurface() != NULL);
TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage); TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage);
IDirect3DSurface9 *destSurface = storage9->getSurfaceLevel(level, true); IDirect3DSurface9 *destSurface = storage9->getSurfaceLevel(index.mipIndex, true);
gl::Error error = copyToSurface(destSurface, xoffset, yoffset, width, height); gl::Error error = copyToSurface(destSurface, region.x, region.y, region.width, region.height);
SafeRelease(destSurface); SafeRelease(destSurface);
return error; return error;
} }
gl::Error Image9::copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToStorageCube(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
ASSERT(getSurface() != NULL); ASSERT(getSurface() != NULL);
TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage); TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage);
IDirect3DSurface9 *destSurface = storage9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true); IDirect3DSurface9 *destSurface = storage9->getCubeMapSurface(index.type, index.mipIndex, true);
gl::Error error = copyToSurface(destSurface, xoffset, yoffset, width, height); gl::Error error = copyToSurface(destSurface, region.x, region.y, region.width, region.height);
SafeRelease(destSurface); SafeRelease(destSurface);
return error; return error;
} }
gl::Error Image9::copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) gl::Error Image9::copyToStorage3D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
// 3D textures are not supported by the D3D9 backend. // 3D textures are not supported by the D3D9 backend.
UNREACHABLE(); UNREACHABLE();
return gl::Error(GL_INVALID_OPERATION); return gl::Error(GL_INVALID_OPERATION);
} }
gl::Error Image9::copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToStorage2DArray(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
{ {
// 2D array textures are not supported by the D3D9 backend. // 2D array textures are not supported by the D3D9 backend.
UNREACHABLE(); UNREACHABLE();
......
...@@ -44,10 +44,10 @@ class Image9 : public ImageD3D ...@@ -44,10 +44,10 @@ class Image9 : public ImageD3D
virtual void setManagedSurface2D(TextureStorage *storage, int level); virtual void setManagedSurface2D(TextureStorage *storage, int level);
virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level); virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level);
virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorageCube(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); virtual gl::Error copyToStorage3D(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2DArray(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input); GLint unpackAlignment, GLenum type, const void *input);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment