diff --git a/gfx/angle/src/libANGLE/formatutils.cpp b/gfx/angle/src/libANGLE/formatutils.cpp index 1efb9896d2be..2aa2e75d4f16 100644 --- a/gfx/angle/src/libANGLE/formatutils.cpp +++ b/gfx/angle/src/libANGLE/formatutils.cpp @@ -718,27 +718,19 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat) } } -GLuint InternalFormat::computePixelBytes(GLenum formatType) const -{ - const auto &typeInfo = GetTypeInfo(formatType); - GLuint components = typeInfo.specialInterpretation ? 1u : componentCount; - return components * typeInfo.bytes; -} - -ErrorOrResult InternalFormat::computeRowPitch(GLenum formatType, - GLsizei width, - GLint alignment, - GLint rowLength) const +ErrorOrResult InternalFormat::computeRowPitch(GLsizei width, + GLint alignment, + GLint rowLength) const { // Compressed images do not use pack/unpack parameters. if (compressed) { ASSERT(rowLength == 0); - return computeCompressedImageSize(formatType, Extents(width, 1, 1)); + return computeCompressedImageSize(Extents(width, 1, 1)); } CheckedNumeric checkedWidth(rowLength > 0 ? rowLength : width); - CheckedNumeric checkedRowBytes = checkedWidth * computePixelBytes(formatType); + CheckedNumeric checkedRowBytes = checkedWidth * pixelBytes; ASSERT(alignment > 0 && isPow2(alignment)); CheckedNumeric checkedAlignment(alignment); @@ -749,7 +741,7 @@ ErrorOrResult InternalFormat::computeRowPitch(GLenum formatType, ErrorOrResult InternalFormat::computeDepthPitch(GLsizei height, GLint imageHeight, - GLuint rowPitch) const + GLuint rowPitch) { GLuint rows = (imageHeight > 0 ? static_cast(imageHeight) : static_cast(height)); @@ -760,20 +752,18 @@ ErrorOrResult InternalFormat::computeDepthPitch(GLsizei height, return depthPitch.ValueOrDie(); } -ErrorOrResult InternalFormat::computeDepthPitch(GLenum formatType, - GLsizei width, - GLsizei height, - GLint alignment, - GLint rowLength, - GLint imageHeight) const +ErrorOrResult 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 InternalFormat::computeCompressedImageSize(GLenum formatType, - const Extents &size) const +ErrorOrResult InternalFormat::computeCompressedImageSize(const Extents &size) const { CheckedNumeric checkedWidth(size.width); CheckedNumeric checkedHeight(size.height); @@ -790,9 +780,9 @@ ErrorOrResult InternalFormat::computeCompressedImageSize(GLenum formatTy } ErrorOrResult InternalFormat::computeSkipBytes(GLuint rowPitch, - GLuint depthPitch, - const PixelStoreStateBase &state, - bool is3D) const + GLuint depthPitch, + const PixelStoreStateBase &state, + bool is3D) const { CheckedNumeric checkedRowPitch(rowPitch); CheckedNumeric checkedDepthPitch(depthPitch); @@ -811,14 +801,12 @@ ErrorOrResult InternalFormat::computeSkipBytes(GLuint rowPitch, return skipBytes.ValueOrDie(); } -ErrorOrResult InternalFormat::computePackUnpackEndByte( - GLenum formatType, - const Extents &size, - const PixelStoreStateBase &state, - bool is3D) const +ErrorOrResult InternalFormat::computePackUnpackEndByte(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; @@ -830,11 +818,11 @@ ErrorOrResult InternalFormat::computePackUnpackEndByte( CheckedNumeric checkedCopyBytes = 0; if (compressed) { - ANGLE_TRY_RESULT(computeCompressedImageSize(formatType, size), checkedCopyBytes); + ANGLE_TRY_RESULT(computeCompressedImageSize(size), checkedCopyBytes); } else if (size.height != 0 && (!is3D || size.depth != 0)) { - CheckedNumeric bytes = computePixelBytes(formatType); + CheckedNumeric bytes = pixelBytes; checkedCopyBytes += size.width * bytes; CheckedNumeric heightMinusOne = size.height - 1; @@ -848,7 +836,8 @@ ErrorOrResult InternalFormat::computePackUnpackEndByte( } CheckedNumeric checkedSkipBytes = 0; - ANGLE_TRY_RESULT(computeSkipBytes(rowPitch, depthPitch, state, is3D), checkedSkipBytes); + ANGLE_TRY_RESULT(computeSkipBytes(rowPitch, depthPitch, state, is3D), + checkedSkipBytes); CheckedNumeric endByte = checkedCopyBytes + checkedSkipBytes; diff --git a/gfx/angle/src/libANGLE/formatutils.h b/gfx/angle/src/libANGLE/formatutils.h index 618c17257dd6..d6f9402d4190 100644 --- a/gfx/angle/src/libANGLE/formatutils.h +++ b/gfx/angle/src/libANGLE/formatutils.h @@ -48,34 +48,28 @@ struct InternalFormat { InternalFormat(); - GLuint computePixelBytes(GLenum formatType) const; - - ErrorOrResult computeRowPitch(GLenum formatType, - GLsizei width, + ErrorOrResult computeRowPitch(GLsizei width, GLint alignment, GLint rowLength) const; - ErrorOrResult computeDepthPitch(GLsizei height, - GLint imageHeight, - GLuint rowPitch) const; - ErrorOrResult computeDepthPitch(GLenum formatType, - GLsizei width, + static ErrorOrResult computeDepthPitch(GLsizei height, + GLint imageHeight, + GLuint rowPitch); + ErrorOrResult computeDepthPitch(GLsizei width, GLsizei height, GLint alignment, GLint rowLength, GLint imageHeight) const; - ErrorOrResult computeCompressedImageSize(GLenum formatType, - const Extents &size) const; + ErrorOrResult computeCompressedImageSize(const Extents &size) const; ErrorOrResult computeSkipBytes(GLuint rowPitch, GLuint depthPitch, const PixelStoreStateBase &state, bool is3D) const; - ErrorOrResult computePackUnpackEndByte(GLenum formatType, - const Extents &size, - const PixelStoreStateBase &state, - bool is3D) const; + ErrorOrResult computePackUnpackEndByte(const Extents &size, + const PixelStoreStateBase &state, + bool is3D) const; bool isLUMA() const; GLenum getReadPixelsFormat() const; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp index f6eef6f4cd43..cc8bb0ea714a 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/FramebufferD3D.cpp @@ -240,15 +240,13 @@ gl::Error FramebufferD3D::readPixels(ContextImpl *context, { const gl::PixelPackState &packState = context->getGLState().getPackState(); - GLenum sizedInternalFormat = gl::GetSizedInternalFormat(format, type); - const gl::InternalFormat &sizedFormatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); + const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); GLuint outputPitch = 0; - ANGLE_TRY_RESULT( - sizedFormatInfo.computeRowPitch(type, area.width, packState.alignment, packState.rowLength), - outputPitch); + 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); return readPixelsImpl(area, format, type, outputPitch, packState, diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp index ead5db645356..c9581ccaa86e 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.cpp @@ -10,6 +10,7 @@ #include "libANGLE/renderer/d3d/ImageD3D.h" +#include "libANGLE/formatutils.h" #include "libANGLE/Framebuffer.h" #include "libANGLE/FramebufferAttachment.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h" @@ -29,4 +30,13 @@ ImageD3D::ImageD3D() { } +GLenum +ImageD3D::getSizedInputFormat(GLenum inputType) const +{ + const auto &internalFormat = gl::GetInternalFormatInfo(mInternalFormat); + const auto &unsizedInternalFormat = internalFormat.format; + const auto &sizedInputFormat = gl::GetSizedInternalFormat(unsizedInternalFormat, inputType); + return sizedInputFormat; +} + } // namespace rx diff --git a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h index 947a8328f574..79840c15b951 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h +++ b/gfx/angle/src/libANGLE/renderer/d3d/ImageD3D.h @@ -51,6 +51,8 @@ class ImageD3D : angle::NonCopyable 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::Box &area, const gl::PixelUnpackState &unpack, GLenum type, diff --git a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp index df1eb7bfd6a4..287700264375 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/TextureD3D.cpp @@ -2366,15 +2366,15 @@ gl::Error TextureD3D_2DArray::setImage(GLenum target, { ASSERT(target == GL_TEXTURE_2D_ARRAY); - GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type); - GLint level = static_cast(imageLevel); + GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type); redefineImage(level, sizedInternalFormat, size); - const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedInternalFormat); - GLsizei inputDepthPitch = 0; - ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, size.width, size.height, unpack.alignment, - unpack.rowLength, unpack.imageHeight), + const auto sizedInputFormat = gl::GetSizedInternalFormat(format, type); + const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat); + GLsizei inputDepthPitch = 0; + ANGLE_TRY_RESULT(inputFormat.computeDepthPitch(size.width, size.height, unpack.alignment, + unpack.rowLength, unpack.imageHeight), inputDepthPitch); for (int i = 0; i < size.depth; i++) @@ -2396,11 +2396,12 @@ gl::Error TextureD3D_2DArray::setSubImage(GLenum target, const uint8_t *pixels) { ASSERT(target == GL_TEXTURE_2D_ARRAY); - GLint level = static_cast(imageLevel); - const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(getInternalFormat(level)); - GLsizei inputDepthPitch = 0; - ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment, - unpack.rowLength, unpack.imageHeight), + GLint level = static_cast(imageLevel); + const auto sizedInputFormat = gl::GetSizedInternalFormat(format, type); + const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(sizedInputFormat); + 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++) @@ -2435,7 +2436,7 @@ gl::Error TextureD3D_2DArray::setCompressedImage(GLenum target, const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(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++) @@ -2457,7 +2458,7 @@ gl::Error TextureD3D_2DArray::setCompressedSubImage(GLenum target, size_t level, const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(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++) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp index a7dfec1594da..3c797f8209ca 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp @@ -229,21 +229,22 @@ DXGI_FORMAT Image11::getDXGIFormat() const // into the target pixel rectangle. gl::Error Image11::loadData(const gl::Box &area, const gl::PixelUnpackState &unpack, - GLenum type, + GLenum inputType, const void *input, bool applySkipImages) { - const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); + const auto sizedInputFormat = getSizedInputFormat(inputType); + const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(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); @@ -251,7 +252,7 @@ gl::Error Image11::loadData(const gl::Box &area, 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(D3D11_MAP_WRITE, &mappedImage)); @@ -272,9 +273,9 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input) { const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(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; diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp index 7d1589f7ff88..36c888dd36c7 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp @@ -588,7 +588,7 @@ gl::Error TextureStorage11::copyToStorage(TextureStorage *destStorage) gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image, const gl::Box *destBox, - GLenum type, + GLenum inputType, const gl::PixelUnpackState &unpack, const uint8_t *pixelData) { @@ -602,33 +602,33 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, UINT destSubresource = getSubresourceIndex(index); - const gl::InternalFormat &internalFormatInfo = - gl::GetInternalFormatInfo(image->getInternalFormat()); + const auto sizedInputFormat = image->getSizedInputFormat(inputType); + const gl::InternalFormat &inputFormat = gl::GetInternalFormatInfo(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(image->getWidth()); const int height = destBox ? destBox->height : static_cast(image->getHeight()); const int depth = destBox ? destBox->depth : static_cast(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 = @@ -645,7 +645,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, 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)); diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp index 8f8e70c501a8..ad2c415849d2 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d9/Image9.cpp @@ -475,17 +475,17 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, const gl::Box &a // into the target pixel rectangle. gl::Error Image9::loadData(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); - + ASSERT(getSizedInputFormat(inputType) == mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(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); @@ -523,7 +523,7 @@ gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input) const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(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); diff --git a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp index 9fde07c7d641..b6055e33b5dd 100644 --- a/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/FramebufferGL.cpp @@ -499,7 +499,7 @@ gl::Error FramebufferGL::readPixelsRowByRowWorkaround(const gl::Rectangle &area, const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(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); @@ -530,7 +530,7 @@ gl::Error FramebufferGL::readPixelsPaddingWorkaround(const gl::Rectangle &area, const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(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); diff --git a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp index 91f515228ce8..5f01de96ae9b 100644 --- a/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/TextureGL.cpp @@ -326,11 +326,11 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target, const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(format, type)); - GLuint rowBytes = 0; - ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength), + GLuint rowBytes = 0; + 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), + ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, rowBytes), imageBytes); bool useTexImage3D = UseTexImage3D(getTarget()); GLuint skipBytes = 0; @@ -378,10 +378,10 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(GLenum target, const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(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), + ANGLE_TRY_RESULT(gl::InternalFormat::computeDepthPitch(area.height, unpack.imageHeight, rowBytes), imageBytes); bool useTexImage3D = UseTexImage3D(getTarget()); GLuint skipBytes = 0; @@ -705,8 +705,7 @@ gl::Error TextureGL::setStorage(GLenum target, if (internalFormatInfo.compressed) { GLuint dataSize = 0; - ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize( - GL_UNSIGNED_BYTE, levelSize), + ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize(levelSize), dataSize); mFunctions->compressedTexImage2D(target, static_cast(level), texStorageFormat.internalFormat, @@ -729,7 +728,7 @@ gl::Error TextureGL::setStorage(GLenum target, { GLuint dataSize = 0; ANGLE_TRY_RESULT(internalFormatInfo.computeCompressedImageSize( - GL_UNSIGNED_BYTE, levelSize), + levelSize), dataSize); mFunctions->compressedTexImage2D( face, static_cast(level), texStorageFormat.internalFormat, @@ -780,7 +779,7 @@ gl::Error TextureGL::setStorage(GLenum target, { GLuint dataSize = 0; ANGLE_TRY_RESULT( - internalFormatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, levelSize), + internalFormatInfo.computeCompressedImageSize(levelSize), dataSize); mFunctions->compressedTexImage3D(target, i, texStorageFormat.internalFormat, levelSize.width, levelSize.height, diff --git a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp index 62b3e98e80bd..37012c14c916 100644 --- a/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp +++ b/gfx/angle/src/libANGLE/renderer/gl/renderergl_utils.cpp @@ -1046,10 +1046,10 @@ gl::ErrorOrResult ShouldApplyLastRowPaddingWorkaround(const gl::Extents &s const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(gl::GetSizedInternalFormat(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(pixels); diff --git a/gfx/angle/src/libANGLE/validationES.cpp b/gfx/angle/src/libANGLE/validationES.cpp index c00c0aa47005..5248a3da2cc3 100644 --- a/gfx/angle/src/libANGLE/validationES.cpp +++ b/gfx/angle/src/libANGLE/validationES.cpp @@ -255,7 +255,7 @@ bool ValidateReadPixelsBase(ValidationContext *context, 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()); @@ -1574,7 +1574,7 @@ bool ValidImageDataSize(ValidationContext *context, 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()); diff --git a/gfx/angle/src/libANGLE/validationES2.cpp b/gfx/angle/src/libANGLE/validationES2.cpp index 8faa1fdaefca..b585e8452b9a 100644 --- a/gfx/angle/src/libANGLE/validationES2.cpp +++ b/gfx/angle/src/libANGLE/validationES2.cpp @@ -2081,7 +2081,7 @@ bool ValidateCompressedTexImage2D(Context *context, const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat); auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1)); + formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1)); if (blockSizeOrErr.isError()) { context->handleError(blockSizeOrErr.getError()); @@ -2129,7 +2129,7 @@ bool ValidateCompressedTexSubImage2D(Context *context, const InternalFormat &formatInfo = GetInternalFormatInfo(format); auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1)); + formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1)); if (blockSizeOrErr.isError()) { context->handleError(blockSizeOrErr.getError()); diff --git a/gfx/angle/src/libANGLE/validationES3.cpp b/gfx/angle/src/libANGLE/validationES3.cpp index 9754d5eeedd9..7aed6a63d986 100644 --- a/gfx/angle/src/libANGLE/validationES3.cpp +++ b/gfx/angle/src/libANGLE/validationES3.cpp @@ -1212,7 +1212,7 @@ bool ValidateCompressedTexImage3D(Context *context, } auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, depth)); + formatInfo.computeCompressedImageSize(gl::Extents(width, height, depth)); if (blockSizeOrErr.isError()) { context->handleError(Error(GL_INVALID_VALUE)); @@ -1621,7 +1621,7 @@ bool ValidateCompressedTexSubImage3D(Context *context, const InternalFormat &formatInfo = GetInternalFormatInfo(format); auto blockSizeOrErr = - formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, depth)); + formatInfo.computeCompressedImageSize(gl::Extents(width, height, depth)); if (blockSizeOrErr.isError()) { context->handleError(blockSizeOrErr.getError());