--- a/gfx/angle/src/libANGLE/formatutils.cpp
+++ b/gfx/angle/src/libANGLE/formatutils.cpp
@@ -1056,67 +1056,58 @@ const InternalFormat &GetInternalFormatI
if (typeIter == internalFormatIter->second.end())
{
return defaultInternalFormat;
}
return typeIter->second;
}
-GLuint InternalFormat::computePixelBytes(GLenum formatType) const
-{
- const auto &typeInfo = GetTypeInfo(formatType);
- GLuint components = typeInfo.specialInterpretation ? 1u : componentCount;
- return components * typeInfo.bytes;
-}
-
-ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLenum formatType,
- GLsizei width,
- GLint alignment,
- GLint rowLength) const
+ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLsizei width,
+ GLint alignment,
+ GLint rowLength) const
{
// Compressed images do not use pack/unpack parameters.
if (compressed)
{
ASSERT(rowLength == 0);
return computeCompressedImageSize(Extents(width, 1, 1));
}
CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width);
- CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * computePixelBytes(formatType);
+ CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * pixelBytes;
ASSERT(alignment > 0 && isPow2(alignment));
CheckedNumeric<GLuint> checkedAlignment(alignment);
auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment);
ANGLE_TRY_CHECKED_MATH(aligned);
return aligned.ValueOrDie();
}
ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei height,
GLint imageHeight,
- GLuint rowPitch) const
+ GLuint rowPitch)
{
GLuint rows =
(imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
auto depthPitch = checkedRowPitch * rows;
ANGLE_TRY_CHECKED_MATH(depthPitch);
return depthPitch.ValueOrDie();
}
-ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType,
- GLsizei width,
- GLsizei height,
- GLint alignment,
- GLint rowLength,
- GLint imageHeight) const
+ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei width,
+ GLsizei height,
+ GLint alignment,
+ GLint rowLength,
+ GLint imageHeight) const
{
GLuint rowPitch = 0;
- ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch);
+ ANGLE_TRY_RESULT(computeRowPitch(width, alignment, rowLength), rowPitch);
return computeDepthPitch(height, imageHeight, rowPitch);
}
ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(const Extents &size) const
{
CheckedNumeric<GLuint> checkedWidth(size.width);
CheckedNumeric<GLuint> checkedHeight(size.height);
CheckedNumeric<GLuint> checkedDepth(size.depth);
@@ -1149,39 +1140,38 @@ ErrorOrResult<GLuint> InternalFormat::co
}
auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch +
checkedSkipPixels * checkedPixelBytes;
ANGLE_TRY_CHECKED_MATH(skipBytes);
return skipBytes.ValueOrDie();
}
ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte(
- GLenum formatType,
const Extents &size,
const PixelStoreStateBase &state,
bool is3D) const
{
GLuint rowPitch = 0;
- ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength),
+ ANGLE_TRY_RESULT(computeRowPitch(size.width, state.alignment, state.rowLength),
rowPitch);
GLuint depthPitch = 0;
if (is3D)
{
ANGLE_TRY_RESULT(computeDepthPitch(size.height, state.imageHeight, rowPitch), depthPitch);
}
CheckedNumeric<GLuint> checkedCopyBytes = 0;
if (compressed)
{
ANGLE_TRY_RESULT(computeCompressedImageSize(size), checkedCopyBytes);
}
else if (size.height != 0 && (!is3D || size.depth != 0))
{
- CheckedNumeric<GLuint> bytes = computePixelBytes(formatType);
+ CheckedNumeric<GLuint> bytes = pixelBytes;
checkedCopyBytes += size.width * bytes;
CheckedNumeric<GLuint> heightMinusOne = size.height - 1;
checkedCopyBytes += heightMinusOne * rowPitch;
if (is3D)
{
CheckedNumeric<GLuint> depthMinusOne = size.depth - 1;
--- a/gfx/angle/src/libANGLE/formatutils.h
+++ b/gfx/angle/src/libANGLE/formatutils.h
@@ -48,43 +48,38 @@ const Type &GetTypeInfo(GLenum type);
// Information about an OpenGL internal format. Can be keyed on the internalFormat and type
// members.
struct InternalFormat
{
InternalFormat();
InternalFormat(const InternalFormat &other);
- GLuint computePixelBytes(GLenum formatType) const;
-
- ErrorOrResult<GLuint> computeRowPitch(GLenum formatType,
- GLsizei width,
+ ErrorOrResult<GLuint> computeRowPitch(GLsizei width,
GLint alignment,
GLint rowLength) const;
- ErrorOrResult<GLuint> computeDepthPitch(GLsizei height,
+ static ErrorOrResult<GLuint> computeDepthPitch(GLsizei height,
GLint imageHeight,
- GLuint rowPitch) const;
- ErrorOrResult<GLuint> computeDepthPitch(GLenum formatType,
- GLsizei width,
+ GLuint rowPitch);
+ ErrorOrResult<GLuint> computeDepthPitch(GLsizei width,
GLsizei height,
GLint alignment,
GLint rowLength,
GLint imageHeight) const;
ErrorOrResult<GLuint> computeCompressedImageSize(const Extents &size) const;
ErrorOrResult<GLuint> computeSkipBytes(GLuint rowPitch,
GLuint depthPitch,
const PixelStoreStateBase &state,
bool is3D) const;
- ErrorOrResult<GLuint> computePackUnpackEndByte(GLenum formatType,
- const Extents &size,
- const PixelStoreStateBase &state,
- bool is3D) const;
+ ErrorOrResult<GLuint> computePackUnpackEndByte(const Extents &size,
+ const PixelStoreStateBase &state,
+ bool is3D) const;
bool isLUMA() const;
GLenum getReadPixelsFormat() const;
GLenum getReadPixelsType(const Version &version) const;
// Return true if the format is a required renderbuffer format in the given version of the core
// spec. Note that it isn't always clear whether all the rules that apply to core required
// renderbuffer formats also apply to additional formats added by extensions. Because of this
--- a/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
@@ -252,27 +252,27 @@ gl::Error FramebufferD3D::readPixels(con
if (!ClipRectangle(origArea, fbRect, &area))
{
// nothing to read
return gl::NoError();
}
const gl::PixelPackState &packState = context->getGLState().getPackState();
- const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(format, type);
+ const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format, type);
GLuint outputPitch = 0;
- ANGLE_TRY_RESULT(sizedFormatInfo.computeRowPitch(type, origArea.width, packState.alignment,
- packState.rowLength),
+
+ ANGLE_TRY_RESULT(formatInfo.computeRowPitch(area.width, packState.alignment, packState.rowLength),
outputPitch);
GLuint outputSkipBytes = 0;
- ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(outputPitch, 0, packState, false),
+ ANGLE_TRY_RESULT(formatInfo.computeSkipBytes(outputPitch, 0, packState, false),
outputSkipBytes);
outputSkipBytes +=
- (area.x - origArea.x) * sizedFormatInfo.pixelBytes + (area.y - origArea.y) * outputPitch;
+ (area.x - origArea.x) * formatInfo.pixelBytes + (area.y - origArea.y) * outputPitch;
return readPixelsImpl(context, area, format, type, outputPitch, packState,
reinterpret_cast<uint8_t *>(pixels) + outputSkipBytes);
}
gl::Error FramebufferD3D::blit(const gl::Context *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
--- a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp
@@ -5,16 +5,17 @@
//
// Image.h: Implements the rx::Image class, an abstract base class for the
// renderer-specific classes which will define the interface to the underlying
// surfaces or resources.
#include "libANGLE/renderer/d3d/ImageD3D.h"
+#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
namespace rx
{
@@ -24,16 +25,25 @@ ImageD3D::ImageD3D()
mDepth(0),
mInternalFormat(GL_NONE),
mRenderable(false),
mTarget(GL_NONE),
mDirty(false)
{
}
+GLenum ImageD3D::getSizedInputFormat(GLenum inputType) const
+{
+ const auto &internalFormat = gl::GetSizedInternalFormatInfo(mInternalFormat);
+ const auto &unsizedInternalFormat = internalFormat.format;
+ const auto &sizedIF = gl::GetInternalFormatInfo(unsizedInternalFormat, inputType);
+ return sizedIF.sizedInternalFormat;
+}
+
+
gl::Error ImageD3D::setManagedSurface2D(const gl::Context *context,
TextureStorage *storage,
int level)
{
return gl::NoError();
}
gl::Error ImageD3D::setManagedSurfaceCube(const gl::Context *context,
--- a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h
+++ b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h
@@ -47,16 +47,18 @@ class ImageD3D : angle::NonCopyable
bool isRenderableFormat() const { return mRenderable; }
void markDirty() { mDirty = true; }
void markClean() { mDirty = false; }
virtual bool isDirty() const = 0;
virtual bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) = 0;
+ GLenum getSizedInputFormat(GLenum inputType) const;
+
virtual gl::Error loadData(const gl::Context *context,
const gl::Box &area,
const gl::PixelUnpackState &unpack,
GLenum type,
const void *input,
bool applySkipImages) = 0;
virtual gl::Error loadCompressedData(const gl::Context *context,
const gl::Box &area,
--- a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp
@@ -703,17 +703,17 @@ gl::Error TextureD3D::initializeContents
ANGLE_TRY(mRenderer->initRenderTarget(renderTarget));
return gl::NoError();
}
// Slow path: non-renderable texture or the texture levels aren't set up.
const auto &formatInfo = gl::GetSizedInternalFormatInfo(image->getInternalFormat());
size_t imageBytes = 0;
- ANGLE_TRY_RESULT(formatInfo.computeRowPitch(formatInfo.type, image->getWidth(), 1, 0),
+ ANGLE_TRY_RESULT(formatInfo.computeRowPitch(image->getWidth(), 1, 0),
imageBytes);
imageBytes *= image->getHeight() * image->getDepth();
gl::PixelUnpackState defaultUnpackState;
angle::MemoryBuffer *zeroBuffer = nullptr;
ANGLE_TRY(context->getZeroFilledBuffer(imageBytes, &zeroBuffer));
if (shouldUseSetData(image))
@@ -2965,24 +2965,25 @@ gl::Error TextureD3D_2DArray::setImage(c
const gl::Extents &size,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels)
{
ASSERT(target == GL_TEXTURE_2D_ARRAY);
+ GLint level = static_cast<GLint>(imageLevel);
+
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
-
- GLint level = static_cast<GLint>(imageLevel);
ANGLE_TRY(redefineImage(context, level, formatInfo.sizedInternalFormat, size, false));
+ const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(format, type);
GLsizei inputDepthPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, size.width, size.height, unpack.alignment,
- unpack.rowLength, unpack.imageHeight),
+ ANGLE_TRY_RESULT(inputFormat.computeDepthPitch(size.width, size.height, unpack.alignment,
+ unpack.rowLength, unpack.imageHeight),
inputDepthPitch);
for (int i = 0; i < size.depth; i++)
{
const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i);
ANGLE_TRY(setImageImpl(context, index, type, unpack, pixels, layerOffset));
}
@@ -2995,22 +2996,22 @@ gl::Error TextureD3D_2DArray::setSubImag
size_t imageLevel,
const gl::Box &area,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels)
{
ASSERT(target == GL_TEXTURE_2D_ARRAY);
- GLint level = static_cast<GLint>(imageLevel);
- const gl::InternalFormat &formatInfo =
- gl::GetInternalFormatInfo(getInternalFormat(level), type);
- GLsizei inputDepthPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment,
- unpack.rowLength, unpack.imageHeight),
+
+ GLint level = static_cast<GLint>(imageLevel);
+ const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(format, type);
+ GLsizei inputDepthPitch = 0;
+ ANGLE_TRY_RESULT(inputFormat.computeDepthPitch(area.width, area.height, unpack.alignment,
+ unpack.rowLength, unpack.imageHeight),
inputDepthPitch);
for (int i = 0; i < area.depth; i++)
{
int layer = area.z + i;
const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1);
@@ -3036,17 +3037,17 @@ gl::Error TextureD3D_2DArray::setCompres
GLint level = static_cast<GLint>(imageLevel);
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
ANGLE_TRY(redefineImage(context, level, internalFormat, size, false));
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT(
- formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, size.width, size.height, 1, 0, 0),
+ formatInfo.computeDepthPitch(size.width, size.height, 1, 0, 0),
inputDepthPitch);
for (int i = 0; i < size.depth; i++)
{
const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, i);
ANGLE_TRY(setCompressedImageImpl(context, index, unpack, pixels, layerOffset));
@@ -3064,17 +3065,17 @@ gl::Error TextureD3D_2DArray::setCompres
size_t imageSize,
const uint8_t *pixels)
{
ASSERT(target == GL_TEXTURE_2D_ARRAY);
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(format);
GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT(
- formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0),
+ formatInfo.computeDepthPitch(area.width, area.height, 1, 0, 0),
inputDepthPitch);
for (int i = 0; i < area.depth; i++)
{
int layer = area.z + i;
const ptrdiff_t layerOffset = (inputDepthPitch * i);
gl::Box layerArea(area.x, area.y, 0, area.width, area.height, 1);
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
@@ -272,39 +272,40 @@ DXGI_FORMAT Image11::getDXGIFormat() con
}
// 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 Image11::loadData(const gl::Context *context,
const gl::Box &area,
const gl::PixelUnpackState &unpack,
- GLenum type,
+ GLenum inputType,
const void *input,
bool applySkipImages)
{
- const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(mInternalFormat);
+ const auto sizedInputFormat = getSizedInputFormat(inputType);
+ const gl::InternalFormat &inputFormat = gl::GetSizedInternalFormatInfo(sizedInputFormat);
GLuint inputRowPitch = 0;
ANGLE_TRY_RESULT(
- formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
+ inputFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength),
inputRowPitch);
GLuint inputDepthPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, unpack.imageHeight, inputRowPitch),
+ ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, inputRowPitch),
inputDepthPitch);
GLuint inputSkipBytes = 0;
ANGLE_TRY_RESULT(
- formatInfo.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack, applySkipImages),
+ inputFormat.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack, applySkipImages),
inputSkipBytes);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
const d3d11::Format &d3dFormatInfo =
d3d11::Format::Get(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
- LoadImageFunction loadFunction = d3dFormatInfo.getLoadFunctions()(type).loadFunction;
+ LoadImageFunction loadFunction = d3dFormatInfo.getLoadFunctions()(inputType).loadFunction;
D3D11_MAPPED_SUBRESOURCE mappedImage;
ANGLE_TRY(map(context, D3D11_MAP_WRITE, &mappedImage));
uint8_t *offsetMappedData = (reinterpret_cast<uint8_t *>(mappedImage.pData) +
(area.y * mappedImage.RowPitch + area.x * outputPixelSize +
area.z * mappedImage.DepthPitch));
loadFunction(area.width, area.height, area.depth,
@@ -317,19 +318,19 @@ gl::Error Image11::loadData(const gl::Co
}
gl::Error Image11::loadCompressedData(const gl::Context *context,
const gl::Box &area,
const void *input)
{
const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
+ ANGLE_TRY_RESULT(formatInfo.computeRowPitch(area.width, 1, 0), inputRowPitch);
GLsizei inputDepthPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputRowPitch), inputDepthPitch);
+ ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, 0, inputRowPitch), inputDepthPitch);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
GLuint outputBlockWidth = dxgiFormatInfo.blockWidth;
GLuint outputBlockHeight = dxgiFormatInfo.blockHeight;
ASSERT(area.x % outputBlockWidth == 0);
ASSERT(area.y % outputBlockHeight == 0);
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
@@ -729,74 +729,74 @@ gl::Error TextureStorage11::copyToStorag
return gl::NoError();
}
gl::Error TextureStorage11::setData(const gl::Context *context,
const gl::ImageIndex &index,
ImageD3D *image,
const gl::Box *destBox,
- GLenum type,
+ GLenum inputType,
const gl::PixelUnpackState &unpack,
const uint8_t *pixelData)
{
ASSERT(!image->isDirty());
markLevelDirty(index.mipIndex);
const TextureHelper11 *resource = nullptr;
ANGLE_TRY(getResource(context, &resource));
ASSERT(resource && resource->valid());
UINT destSubresource = getSubresourceIndex(index);
- const gl::InternalFormat &internalFormatInfo =
- gl::GetInternalFormatInfo(image->getInternalFormat(), type);
+ const auto sizedInputFormat = image->getSizedInputFormat(inputType);
+ const gl::InternalFormat &inputFormat = gl::GetSizedInternalFormatInfo(sizedInputFormat);
gl::Box levelBox(0, 0, 0, getLevelWidth(index.mipIndex), getLevelHeight(index.mipIndex),
getLevelDepth(index.mipIndex));
bool fullUpdate = (destBox == nullptr || *destBox == levelBox);
- ASSERT(internalFormatInfo.depthBits == 0 || fullUpdate);
+ ASSERT(inputFormat.depthBits == 0 || fullUpdate);
// TODO(jmadill): Handle compressed formats
// Compressed formats have different load syntax, so we'll have to handle them with slightly
// different logic. Will implemnent this in a follow-up patch, and ensure we do not use SetData
// with compressed formats in the calling logic.
- ASSERT(!internalFormatInfo.compressed);
+ ASSERT(!inputFormat.compressed);
const int width = destBox ? destBox->width : static_cast<int>(image->getWidth());
const int height = destBox ? destBox->height : static_cast<int>(image->getHeight());
const int depth = destBox ? destBox->depth : static_cast<int>(image->getDepth());
GLuint srcRowPitch = 0;
ANGLE_TRY_RESULT(
- internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength),
+ inputFormat.computeRowPitch(width, unpack.alignment, unpack.rowLength),
srcRowPitch);
GLuint srcDepthPitch = 0;
- ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(height, unpack.imageHeight, srcRowPitch),
+ ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(height, unpack.imageHeight, srcRowPitch),
srcDepthPitch);
GLuint srcSkipBytes = 0;
ANGLE_TRY_RESULT(
- internalFormatInfo.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack, index.is3D()),
+ inputFormat.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack, index.is3D()),
srcSkipBytes);
const d3d11::Format &d3d11Format =
d3d11::Format::Get(image->getInternalFormat(), mRenderer->getRenderer11DeviceCaps());
const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(d3d11Format.texFormat);
const size_t outputPixelSize = dxgiFormatInfo.pixelBytes;
UINT bufferRowPitch = static_cast<unsigned int>(outputPixelSize) * width;
UINT bufferDepthPitch = bufferRowPitch * height;
const size_t neededSize = bufferDepthPitch * depth;
angle::MemoryBuffer *conversionBuffer = nullptr;
const uint8_t *data = nullptr;
- LoadImageFunctionInfo loadFunctionInfo = d3d11Format.getLoadFunctions()(type);
+ LoadImageFunctionInfo loadFunctionInfo = d3d11Format.getLoadFunctions()(inputType);
if (loadFunctionInfo.requiresConversion)
{
ANGLE_TRY(mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer));
loadFunctionInfo.loadFunction(width, height, depth, pixelData + srcSkipBytes, srcRowPitch,
srcDepthPitch, conversionBuffer->data(), bufferRowPitch,
bufferDepthPitch);
data = conversionBuffer->data();
}
--- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
+++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp
@@ -557,27 +557,26 @@ gl::Error Image9::copyToSurface(IDirect3
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::Context *context,
const gl::Box &area,
const gl::PixelUnpackState &unpack,
- GLenum type,
+ GLenum inputType,
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::GetSizedInternalFormatInfo(mInternalFormat);
GLuint inputRowPitch = 0;
ANGLE_TRY_RESULT(
- formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
+ formatInfo.computeRowPitch(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 != nullptr);
@@ -607,17 +606,17 @@ gl::Error Image9::loadCompressedData(con
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::GetSizedInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = 0;
- ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
+ ANGLE_TRY_RESULT(formatInfo.computeRowPitch(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);
--- a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -449,17 +449,17 @@ Error FramebufferGL::readPixels(const gl
int leftClip = area.x - origArea.x;
int topClip = area.y - origArea.y;
if (leftClip || topClip)
{
// Adjust destination to match portion clipped off left and/or top.
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(readFormat, readType);
GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(readType, origArea.width, packState.alignment,
+ ANGLE_TRY_RESULT(glFormat.computeRowPitch(origArea.width, packState.alignment,
packState.rowLength),
rowBytes);
pixels += leftClip * glFormat.pixelBytes + topClip * rowBytes;
}
if (packState.rowLength == 0 && area.width != origArea.width)
{
// No rowLength was specified so it will derive from read width, but clipping changed the
@@ -836,17 +836,17 @@ gl::Error FramebufferGL::readPixelsRowBy
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels) const
{
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, pack.alignment, pack.rowLength),
+ ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, pack.alignment, pack.rowLength),
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes);
gl::PixelPackState directPack;
directPack.alignment = 1;
mStateManager->setPixelPackState(directPack);
@@ -875,17 +875,17 @@ gl::Error FramebufferGL::readPixelsAllAt
mFunctions->readPixels(area.x, area.y, area.width, height, format, type, pixels);
}
if (readLastRowSeparately)
{
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, pack.alignment, pack.rowLength),
+ ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, pack.alignment, pack.rowLength),
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes);
gl::PixelPackState directPack;
directPack.alignment = 1;
mStateManager->setPixelPackState(directPack);
--- a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp
@@ -346,17 +346,17 @@ gl::Error TextureGL::setSubImageRowByRow
{
gl::PixelUnpackState directUnpack;
directUnpack.alignment = 1;
mStateManager->setPixelUnpackState(directUnpack);
mStateManager->setPixelUnpackBuffer(unpackBuffer);
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
+ ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength),
rowBytes);
GLuint imageBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
imageBytes);
bool useTexImage3D = UseTexImage3D(getTarget());
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D),
skipBytes);
@@ -398,17 +398,17 @@ gl::Error TextureGL::setSubImagePaddingW
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const gl::Buffer *unpackBuffer,
const uint8_t *pixels)
{
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
+ ANGLE_TRY_RESULT(glFormat.computeRowPitch(area.width, unpack.alignment, unpack.rowLength),
rowBytes);
GLuint imageBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
imageBytes);
bool useTexImage3D = UseTexImage3D(getTarget());
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D),
skipBytes);
--- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -1286,20 +1286,20 @@ gl::ErrorOrResult<bool> ShouldApplyLastR
// We are using an pack or unpack buffer, compute what the driver thinks is going to be the
// last byte read or written. If it is past the end of the buffer, we will need to use the
// workaround otherwise the driver will generate INVALID_OPERATION and not do the operation.
CheckedNumeric<size_t> checkedEndByte;
CheckedNumeric<size_t> pixelBytes;
size_t rowPitch;
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
- ANGLE_TRY_RESULT(glFormat.computePackUnpackEndByte(type, size, state, is3D), checkedEndByte);
- ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, size.width, state.alignment, state.rowLength),
+ ANGLE_TRY_RESULT(glFormat.computePackUnpackEndByte(size, state, is3D), checkedEndByte);
+ ANGLE_TRY_RESULT(glFormat.computeRowPitch(size.width, state.alignment, state.rowLength),
rowPitch);
- pixelBytes = glFormat.computePixelBytes(type);
+ pixelBytes = glFormat.pixelBytes;
checkedEndByte += reinterpret_cast<intptr_t>(pixels);
// At this point checkedEndByte is the actual last byte read.
// The driver adds an extra row padding (if any), mimic it.
ANGLE_TRY_CHECKED_MATH(pixelBytes);
if (pixelBytes.ValueOrDie() * size.width < rowPitch)
{
--- a/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.cpp
+++ b/gfx/angle/src/libANGLE/renderer/null/FramebufferNULL.cpp
@@ -144,17 +144,17 @@ gl::Error FramebufferNULL::readPixels(co
return gl::NoError();
}
// Compute size of unclipped rows and initial skip
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
ANGLE_TRY_RESULT(
- glFormat.computeRowPitch(type, origArea.width, packState.alignment, packState.rowLength),
+ glFormat.computeRowPitch(origArea.width, packState.alignment, packState.rowLength),
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, packState, false), skipBytes);
pixels += skipBytes;
// Skip OOB region up to first in bounds pixel
int leftClip = area.x - origArea.x;
--- a/gfx/angle/src/libANGLE/validationES.cpp
+++ b/gfx/angle/src/libANGLE/validationES.cpp
@@ -842,17 +842,17 @@ bool ValidImageDataSize(ValidationContex
// ...the data would be unpacked from the buffer object such that the memory reads required
// would exceed the data store size.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format, type);
ASSERT(formatInfo.internalFormat != GL_NONE);
const gl::Extents size(width, height, depth);
const auto &unpack = context->getGLState().getUnpackState();
bool targetIs3D = textureTarget == GL_TEXTURE_3D || textureTarget == GL_TEXTURE_2D_ARRAY;
- auto endByteOrErr = formatInfo.computePackUnpackEndByte(type, size, unpack, targetIs3D);
+ auto endByteOrErr = formatInfo.computePackUnpackEndByte(size, unpack, targetIs3D);
if (endByteOrErr.isError())
{
context->handleError(endByteOrErr.getError());
return false;
}
GLuint endByte = endByteOrErr.getResult();
@@ -5164,17 +5164,17 @@ bool ValidateReadPixelsBase(Context *con
}
// .. the data would be packed to the buffer object such that the memory writes required
// would exceed the data store size.
const InternalFormat &formatInfo = GetInternalFormatInfo(format, type);
const gl::Extents size(width, height, 1);
const auto &pack = context->getGLState().getPackState();
- auto endByteOrErr = formatInfo.computePackUnpackEndByte(type, size, pack, false);
+ auto endByteOrErr = formatInfo.computePackUnpackEndByte(size, pack, false);
if (endByteOrErr.isError())
{
context->handleError(endByteOrErr.getError());
return false;
}
size_t endByte = endByteOrErr.getResult();
if (bufSize >= 0)