summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp')
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp303
1 files changed, 205 insertions, 98 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
index fec7e3e19d..179629b362 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
@@ -24,8 +24,8 @@ namespace rx
Image9::Image9(Renderer9 *renderer)
{
- mSurface = NULL;
- mRenderer = NULL;
+ mSurface = nullptr;
+ mRenderer = nullptr;
mD3DPool = D3DPOOL_SYSTEMMEM;
mD3DFormat = D3DFMT_UNKNOWN;
@@ -45,7 +45,9 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to query the source surface description for mipmap generation, result: 0x%X.", result);
+ return gl::OutOfMemory()
+ << "Failed to query the source surface description for mipmap generation, "
+ << gl::FmtHR(result);
}
D3DSURFACE_DESC sourceDesc;
@@ -53,7 +55,9 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to query the destination surface description for mipmap generation, result: 0x%X.", result);
+ return gl::OutOfMemory()
+ << "Failed to query the destination surface description for mipmap generation, "
+ << gl::FmtHR(result);
}
ASSERT(sourceDesc.Format == destDesc.Format);
@@ -61,23 +65,25 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format);
- ASSERT(d3dFormatInfo.mipGenerationFunction != NULL);
+ ASSERT(d3dFormatInfo.info().mipGenerationFunction != nullptr);
D3DLOCKED_RECT sourceLocked = {0};
- result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY);
+ result = sourceSurface->LockRect(&sourceLocked, nullptr, D3DLOCK_READONLY);
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock the source surface for mipmap generation, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to lock the source surface for mipmap generation, "
+ << gl::FmtHR(result);
}
D3DLOCKED_RECT destLocked = {0};
- result = destSurface->LockRect(&destLocked, NULL, 0);
+ result = destSurface->LockRect(&destLocked, nullptr, 0);
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
sourceSurface->UnlockRect();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock the destination surface for mipmap generation, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to lock the destination surface for mipmap generation, "
+ << gl::FmtHR(result);
}
const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(sourceLocked.pBits);
@@ -85,40 +91,29 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceData && destData);
- d3dFormatInfo.mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData, sourceLocked.Pitch, 0,
- destData, destLocked.Pitch, 0);
+ d3dFormatInfo.info().mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData,
+ sourceLocked.Pitch, 0, destData, destLocked.Pitch,
+ 0);
destSurface->UnlockRect();
sourceSurface->UnlockRect();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
gl::Error Image9::generateMipmap(Image9 *dest, Image9 *source)
{
- IDirect3DSurface9 *sourceSurface = NULL;
- gl::Error error = source->getSurface(&sourceSurface);
- if (error.isError())
- {
- return error;
- }
+ IDirect3DSurface9 *sourceSurface = nullptr;
+ ANGLE_TRY(source->getSurface(&sourceSurface));
- IDirect3DSurface9 *destSurface = NULL;
- error = dest->getSurface(&destSurface);
- if (error.isError())
- {
- return error;
- }
+ IDirect3DSurface9 *destSurface = nullptr;
+ ANGLE_TRY(dest->getSurface(&destSurface));
- error = generateMip(destSurface, sourceSurface);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(generateMip(destSurface, sourceSurface));
dest->markDirty();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source)
@@ -128,17 +123,17 @@ gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface
HRESULT result;
- result = source->LockRect(&sourceLock, NULL, 0);
+ result = source->LockRect(&sourceLock, nullptr, 0);
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock source surface for copy, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to lock source surface for copy, " << gl::FmtHR(result);
}
- result = dest->LockRect(&destLock, NULL, 0);
+ result = dest->LockRect(&destLock, nullptr, 0);
if (FAILED(result))
{
source->UnlockRect();
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock source surface for copy, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to lock source surface for copy, " << gl::FmtHR(result);
}
ASSERT(sourceLock.pBits && destLock.pBits);
@@ -161,7 +156,85 @@ gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface
source->UnlockRect();
dest->UnlockRect();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
+}
+
+// static
+gl::Error Image9::CopyImage(const gl::Context *context,
+ Image9 *dest,
+ Image9 *source,
+ const gl::Rectangle &sourceRect,
+ const gl::Offset &destOffset,
+ bool unpackFlipY,
+ bool unpackPremultiplyAlpha,
+ bool unpackUnmultiplyAlpha)
+{
+ IDirect3DSurface9 *sourceSurface = nullptr;
+ ANGLE_TRY(source->getSurface(&sourceSurface));
+
+ IDirect3DSurface9 *destSurface = nullptr;
+ ANGLE_TRY(dest->getSurface(&destSurface));
+
+ D3DSURFACE_DESC destDesc;
+ HRESULT result = destSurface->GetDesc(&destDesc);
+ ASSERT(SUCCEEDED(result));
+ if (FAILED(result))
+ {
+ return gl::OutOfMemory()
+ << "Failed to query the source surface description for mipmap generation, "
+ << gl::FmtHR(result);
+ }
+ const d3d9::D3DFormat &destD3DFormatInfo = d3d9::GetD3DFormatInfo(destDesc.Format);
+
+ D3DSURFACE_DESC sourceDesc;
+ result = sourceSurface->GetDesc(&sourceDesc);
+ ASSERT(SUCCEEDED(result));
+ if (FAILED(result))
+ {
+ return gl::OutOfMemory()
+ << "Failed to query the destination surface description for mipmap generation, "
+ << gl::FmtHR(result);
+ }
+ const d3d9::D3DFormat &sourceD3DFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format);
+
+ D3DLOCKED_RECT sourceLocked = {0};
+ result = sourceSurface->LockRect(&sourceLocked, nullptr, D3DLOCK_READONLY);
+ ASSERT(SUCCEEDED(result));
+ if (FAILED(result))
+ {
+ return gl::OutOfMemory() << "Failed to lock the source surface for CopyImage, "
+ << gl::FmtHR(result);
+ }
+
+ D3DLOCKED_RECT destLocked = {0};
+ result = destSurface->LockRect(&destLocked, nullptr, 0);
+ ASSERT(SUCCEEDED(result));
+ if (FAILED(result))
+ {
+ sourceSurface->UnlockRect();
+ return gl::OutOfMemory() << "Failed to lock the destination surface for CopyImage, "
+ << gl::FmtHR(result);
+ }
+
+ const uint8_t *sourceData = reinterpret_cast<const uint8_t *>(sourceLocked.pBits) +
+ sourceRect.x * sourceD3DFormatInfo.pixelBytes +
+ sourceRect.y * sourceLocked.Pitch;
+ uint8_t *destData = reinterpret_cast<uint8_t *>(destLocked.pBits) +
+ destOffset.x * destD3DFormatInfo.pixelBytes +
+ destOffset.y * destLocked.Pitch;
+ ASSERT(sourceData && destData);
+
+ CopyImageCHROMIUM(sourceData, sourceLocked.Pitch, sourceD3DFormatInfo.pixelBytes,
+ sourceD3DFormatInfo.info().colorReadFunction, destData, destLocked.Pitch,
+ destD3DFormatInfo.pixelBytes, destD3DFormatInfo.info().colorWriteFunction,
+ gl::GetUnsizedFormat(dest->getInternalFormat()),
+ destD3DFormatInfo.info().componentType, sourceRect.width, sourceRect.height,
+ unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha);
+
+ destSurface->UnlockRect();
+ sourceSurface->UnlockRect();
+
+ return gl::NoError();
}
bool Image9::redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease)
@@ -189,7 +262,7 @@ bool Image9::redefine(GLenum target, GLenum internalformat, const gl::Extents &s
mRenderable = (d3d9FormatInfo.renderFormat != D3DFMT_UNKNOWN);
SafeRelease(mSurface);
- mDirty = (d3d9FormatInfo.dataInitializerFunction != NULL);
+ mDirty = (d3d9FormatInfo.dataInitializerFunction != nullptr);
return true;
}
@@ -201,11 +274,11 @@ gl::Error Image9::createSurface()
{
if (mSurface)
{
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
- IDirect3DTexture9 *newTexture = NULL;
- IDirect3DSurface9 *newSurface = NULL;
+ IDirect3DTexture9 *newTexture = nullptr;
+ IDirect3DSurface9 *newSurface = nullptr;
const D3DPOOL poolToUse = D3DPOOL_SYSTEMMEM;
const D3DFORMAT d3dFormat = getD3DFormat();
@@ -218,20 +291,20 @@ gl::Error Image9::createSurface()
IDirect3DDevice9 *device = mRenderer->getDevice();
- HRESULT result = device->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, 0, d3dFormat,
- poolToUse, &newTexture, NULL);
+ HRESULT result = device->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, 0,
+ d3dFormat, poolToUse, &newTexture, nullptr);
if (FAILED(result))
{
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to create image surface, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to create image surface, " << gl::FmtHR(result);
}
newTexture->GetSurfaceLevel(levelToFetch, &newSurface);
SafeRelease(newTexture);
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
- if (d3dFormatInfo.dataInitializerFunction != NULL)
+ if (d3dFormatInfo.dataInitializerFunction != nullptr)
{
RECT entireRect;
entireRect.left = 0;
@@ -244,7 +317,7 @@ gl::Error Image9::createSurface()
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock image surface, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to lock image surface, " << gl::FmtHR(result);
}
d3dFormatInfo.dataInitializerFunction(mWidth, mHeight, 1, reinterpret_cast<uint8_t*>(lockedRect.pBits),
@@ -254,7 +327,7 @@ gl::Error Image9::createSurface()
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock image surface, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to unlock image surface, " << gl::FmtHR(result);
}
}
}
@@ -263,7 +336,7 @@ gl::Error Image9::createSurface()
mDirty = false;
mD3DPool = poolToUse;
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
gl::Error Image9::lock(D3DLOCKED_RECT *lockedRect, const RECT &rect)
@@ -280,13 +353,13 @@ gl::Error Image9::lock(D3DLOCKED_RECT *lockedRect, const RECT &rect)
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock image surface, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Failed to lock image surface, " << gl::FmtHR(result);
}
mDirty = true;
}
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
void Image9::unlock()
@@ -294,7 +367,6 @@ void Image9::unlock()
if (mSurface)
{
HRESULT result = mSurface->UnlockRect();
- UNUSED_ASSERTION_VARIABLE(result);
ASSERT(SUCCEEDED(result));
}
}
@@ -312,7 +384,9 @@ bool Image9::isDirty() const
{
// Make sure to that this image is marked as dirty even if the staging texture hasn't been created yet
// if initialization is required before use.
- return (mSurface || d3d9::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != NULL) && mDirty;
+ return (mSurface ||
+ d3d9::GetTextureFormatInfo(mInternalFormat).dataInitializerFunction != nullptr) &&
+ mDirty;
}
gl::Error Image9::getSurface(IDirect3DSurface9 **outSurface)
@@ -324,14 +398,16 @@ gl::Error Image9::getSurface(IDirect3DSurface9 **outSurface)
}
*outSurface = mSurface;
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Image9::setManagedSurface2D(TextureStorage *storage, int level)
+gl::Error Image9::setManagedSurface2D(const gl::Context *context,
+ TextureStorage *storage,
+ int level)
{
- IDirect3DSurface9 *surface = NULL;
+ IDirect3DSurface9 *surface = nullptr;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
- gl::Error error = storage9->getSurfaceLevel(GL_TEXTURE_2D, level, false, &surface);
+ gl::Error error = storage9->getSurfaceLevel(context, GL_TEXTURE_2D, level, false, &surface);
if (error.isError())
{
return error;
@@ -339,12 +415,15 @@ gl::Error Image9::setManagedSurface2D(TextureStorage *storage, int level)
return setManagedSurface(surface);
}
-gl::Error Image9::setManagedSurfaceCube(TextureStorage *storage, int face, int level)
+gl::Error Image9::setManagedSurfaceCube(const gl::Context *context,
+ TextureStorage *storage,
+ int face,
+ int level)
{
- IDirect3DSurface9 *surface = NULL;
+ IDirect3DSurface9 *surface = nullptr;
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
- gl::Error error =
- storage9->getSurfaceLevel(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, false, &surface);
+ gl::Error error = storage9->getSurfaceLevel(context, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
+ level, false, &surface);
if (error.isError())
{
return error;
@@ -374,10 +453,13 @@ gl::Error Image9::setManagedSurface(IDirect3DSurface9 *surface)
mD3DPool = desc.Pool;
}
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region)
+gl::Error Image9::copyToStorage(const gl::Context *context,
+ TextureStorage *storage,
+ const gl::ImageIndex &index,
+ const gl::Box &region)
{
gl::Error error = createSurface();
if (error.isError())
@@ -387,11 +469,12 @@ gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &i
TextureStorage9 *storage9 = GetAs<TextureStorage9>(storage);
- IDirect3DSurface9 *destSurface = NULL;
+ IDirect3DSurface9 *destSurface = nullptr;
if (index.type == GL_TEXTURE_2D)
{
- error = storage9->getSurfaceLevel(GL_TEXTURE_2D, index.mipIndex, true, &destSurface);
+ error =
+ storage9->getSurfaceLevel(context, GL_TEXTURE_2D, index.mipIndex, true, &destSurface);
if (error.isError())
{
return error;
@@ -400,7 +483,7 @@ gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &i
else
{
ASSERT(gl::IsCubeMapTextureTarget(index.type));
- error = storage9->getSurfaceLevel(index.type, index.mipIndex, true, &destSurface);
+ error = storage9->getSurfaceLevel(context, index.type, index.mipIndex, true, &destSurface);
if (error.isError())
{
return error;
@@ -417,7 +500,7 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, const gl::Box &a
ASSERT(area.width > 0 && area.height > 0 && area.depth == 1);
ASSERT(destSurface);
- IDirect3DSurface9 *sourceSurface = NULL;
+ IDirect3DSurface9 *sourceSurface = nullptr;
gl::Error error = getSurface(&sourceSurface);
if (error.isError())
{
@@ -442,19 +525,22 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, const gl::Box &a
sourceSurface->GetDesc(&desc);
IDirect3DSurface9 *surf = 0;
- HRESULT result = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL);
+ HRESULT result = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format,
+ D3DPOOL_SYSTEMMEM, &surf, nullptr);
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Internal CreateOffscreenPlainSurface call failed, result: 0x%X.", result);
+ return gl::OutOfMemory()
+ << "Internal CreateOffscreenPlainSurface call failed, " << gl::FmtHR(result);
}
- copyLockableSurfaces(surf, sourceSurface);
+ auto err = copyLockableSurfaces(surf, sourceSurface);
result = device->UpdateSurface(surf, &rect, destSurface, &point);
SafeRelease(surf);
+ ANGLE_TRY(err);
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Internal UpdateSurface call failed, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Internal UpdateSurface call failed, " << gl::FmtHR(result);
}
}
else
@@ -464,27 +550,36 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, const gl::Box &a
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
- return gl::Error(GL_OUT_OF_MEMORY, "Internal UpdateSurface call failed, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Internal UpdateSurface call failed, " << gl::FmtHR(result);
}
}
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle.
-gl::Error Image9::loadData(const gl::Box &area, const gl::PixelUnpackState &unpack, GLenum type, const void *input)
+gl::Error Image9::loadData(const gl::Context *context,
+ const gl::Box &area,
+ const gl::PixelUnpackState &unpack,
+ GLenum type,
+ const void *input,
+ bool applySkipImages)
{
// 3D textures are not supported by the D3D9 backend.
ASSERT(area.z == 0 && area.depth == 1);
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
- GLsizei inputRowPitch = formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength);
- GLsizei inputSkipBytes = formatInfo.computeSkipPixels(inputRowPitch, 0, unpack.skipImages,
- unpack.skipRows, unpack.skipPixels);
+ const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(mInternalFormat);
+ GLuint inputRowPitch = 0;
+ ANGLE_TRY_RESULT(
+ formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
+ inputRowPitch);
+ ASSERT(!applySkipImages);
+ ASSERT(unpack.skipPixels == 0);
+ ASSERT(unpack.skipRows == 0);
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
- ASSERT(d3dFormatInfo.loadFunction != NULL);
+ ASSERT(d3dFormatInfo.loadFunction != nullptr);
RECT lockRect =
{
@@ -500,31 +595,34 @@ gl::Error Image9::loadData(const gl::Box &area, const gl::PixelUnpackState &unpa
}
d3dFormatInfo.loadFunction(area.width, area.height, area.depth,
- reinterpret_cast<const uint8_t *>(input) + inputSkipBytes,
- inputRowPitch, 0, reinterpret_cast<uint8_t *>(locked.pBits),
- locked.Pitch, 0);
+ reinterpret_cast<const uint8_t *>(input), inputRowPitch, 0,
+ reinterpret_cast<uint8_t *>(locked.pBits), locked.Pitch, 0);
unlock();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input)
+gl::Error Image9::loadCompressedData(const gl::Context *context,
+ const gl::Box &area,
+ const void *input)
{
// 3D textures are not supported by the D3D9 backend.
ASSERT(area.z == 0 && area.depth == 1);
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
- GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0);
- GLsizei inputDepthPitch =
- formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0);
+ const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(mInternalFormat);
+ GLsizei inputRowPitch = 0;
+ ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
+ GLsizei inputDepthPitch = 0;
+ ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputDepthPitch),
+ inputDepthPitch);
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(area.x % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockWidth == 0);
ASSERT(area.y % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockHeight == 0);
- ASSERT(d3d9FormatInfo.loadFunction != NULL);
+ ASSERT(d3d9FormatInfo.loadFunction != nullptr);
RECT lockRect =
{
@@ -545,7 +643,7 @@ gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input)
unlock();
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures
@@ -565,16 +663,19 @@ gl::Error Image9::copyFromRTInternal(const gl::Offset &destOffset,
IDirect3DDevice9 *device = mRenderer->getDevice();
- IDirect3DSurface9 *renderTargetData = NULL;
+ IDirect3DSurface9 *renderTargetData = nullptr;
D3DSURFACE_DESC description;
surface->GetDesc(&description);
- HRESULT result = device->CreateOffscreenPlainSurface(description.Width, description.Height, description.Format, D3DPOOL_SYSTEMMEM, &renderTargetData, NULL);
+ HRESULT result = device->CreateOffscreenPlainSurface(description.Width, description.Height,
+ description.Format, D3DPOOL_SYSTEMMEM,
+ &renderTargetData, nullptr);
if (FAILED(result))
{
SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "Could not create matching destination surface, result: 0x%X.", result);
+ return gl::OutOfMemory() << "Could not create matching destination surface, "
+ << gl::FmtHR(result);
}
result = device->GetRenderTargetData(surface, renderTargetData);
@@ -583,7 +684,8 @@ gl::Error Image9::copyFromRTInternal(const gl::Offset &destOffset,
{
SafeRelease(renderTargetData);
SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "GetRenderTargetData unexpectedly failed, result: 0x%X.", result);
+ return gl::OutOfMemory() << "GetRenderTargetData unexpectedly failed, "
+ << gl::FmtHR(result);
}
int width = sourceArea.width;
@@ -599,7 +701,9 @@ gl::Error Image9::copyFromRTInternal(const gl::Offset &destOffset,
{
SafeRelease(renderTargetData);
SafeRelease(surface);
- return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock the source surface (rectangle might be invalid), result: 0x%X.", result);
+ return gl::OutOfMemory()
+ << "Failed to lock the source surface (rectangle might be invalid), "
+ << gl::FmtHR(result);
}
D3DLOCKED_RECT destLock = {0};
@@ -776,13 +880,15 @@ gl::Error Image9::copyFromRTInternal(const gl::Offset &destOffset,
SafeRelease(surface);
mDirty = true;
- return gl::Error(GL_NO_ERROR);
+ return gl::NoError();
}
-gl::Error Image9::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureStorage *source)
+gl::Error Image9::copyFromTexStorage(const gl::Context *context,
+ const gl::ImageIndex &imageIndex,
+ TextureStorage *source)
{
RenderTargetD3D *renderTarget = nullptr;
- gl::Error error = source->getRenderTarget(imageIndex, &renderTarget);
+ gl::Error error = source->getRenderTarget(context, imageIndex, &renderTarget);
if (error.isError())
{
return error;
@@ -792,15 +898,16 @@ gl::Error Image9::copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureSt
return copyFromRTInternal(gl::Offset(), sourceArea, renderTarget);
}
-gl::Error Image9::copyFromFramebuffer(const gl::Offset &destOffset,
+gl::Error Image9::copyFromFramebuffer(const gl::Context *context,
+ const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
const gl::Framebuffer *source)
{
const gl::FramebufferAttachment *srcAttachment = source->getReadColorbuffer();
ASSERT(srcAttachment);
- RenderTargetD3D *renderTarget = NULL;
- gl::Error error = srcAttachment->getRenderTarget(&renderTarget);
+ RenderTargetD3D *renderTarget = nullptr;
+ gl::Error error = srcAttachment->getRenderTarget(context, &renderTarget);
if (error.isError())
{
return error;