diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-20 13:45:14 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-20 13:45:14 +0000 |
commit | 77d95f2a644bea1870d5262f7a9c8545b1712699 (patch) | |
tree | b1d491620bbe58052053b121b42122cf5a555d75 | |
parent | a3a0f4903ae003169cf95a9045ac3649ba0d9e5f (diff) | |
parent | 169ee4dfa6915590e1cf88116034d66be13a09ca (diff) | |
download | goldfish-opengl-android13-frc-ipsec-release.tar.gz |
Snap for 8745897 from 169ee4dfa6915590e1cf88116034d66be13a09ca to tm-frc-ipsec-releaset_frc_ips_330443010android13-frc-ipsec-release
Change-Id: Ibde7ddd5c050387dd14baac27cb04d5b6ba556c0
-rw-r--r-- | shared/OpenglCodecCommon/GLClientState.cpp | 5 | ||||
-rw-r--r-- | shared/OpenglCodecCommon/GLClientState.h | 2 | ||||
-rw-r--r-- | shared/OpenglCodecCommon/GLESTextureUtils.cpp | 26 | ||||
-rw-r--r-- | shared/OpenglCodecCommon/GLESTextureUtils.h | 11 | ||||
-rwxr-xr-x | system/GLESv2_enc/GL2Encoder.cpp | 3 |
5 files changed, 35 insertions, 12 deletions
diff --git a/shared/OpenglCodecCommon/GLClientState.cpp b/shared/OpenglCodecCommon/GLClientState.cpp index 3e32bbfb..a6dbbd69 100644 --- a/shared/OpenglCodecCommon/GLClientState.cpp +++ b/shared/OpenglCodecCommon/GLClientState.cpp @@ -1203,7 +1203,7 @@ size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLsizei depth pack ? 0 : m_pixelStore.unpack_skip_images); } -size_t GLClientState::pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const +size_t GLClientState::pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack, int ignoreTrailing) const { if (width <= 0 || height <= 0 || depth <= 0) return 0; @@ -1231,7 +1231,8 @@ size_t GLClientState::pboNeededDataSize(GLsizei width, GLsizei height, GLsizei d pack ? 0 : m_pixelStore.unpack_image_height, pack ? m_pixelStore.pack_skip_pixels : m_pixelStore.unpack_skip_pixels, pack ? m_pixelStore.pack_skip_rows : m_pixelStore.unpack_skip_rows, - pack ? 0 : m_pixelStore.unpack_skip_images); + pack ? 0 : m_pixelStore.unpack_skip_images, + ignoreTrailing); } diff --git a/shared/OpenglCodecCommon/GLClientState.h b/shared/OpenglCodecCommon/GLClientState.h index 06399621..308b7374 100644 --- a/shared/OpenglCodecCommon/GLClientState.h +++ b/shared/OpenglCodecCommon/GLClientState.h @@ -332,7 +332,7 @@ public: void setLastEncodedBufferBind(GLenum target, GLuint id); size_t pixelDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const; - size_t pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const; + size_t pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack, int ignoreTrailing = 0) const; size_t clearBufferNumElts(GLenum buffer) const; void getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const; void getUnpackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* bpp, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const; diff --git a/shared/OpenglCodecCommon/GLESTextureUtils.cpp b/shared/OpenglCodecCommon/GLESTextureUtils.cpp index 87d63121..0fa0e236 100644 --- a/shared/OpenglCodecCommon/GLESTextureUtils.cpp +++ b/shared/OpenglCodecCommon/GLESTextureUtils.cpp @@ -1,5 +1,7 @@ #include "GLESTextureUtils.h" +#include <algorithm> + #include "glUtils.h" #include "etc.h" #include "astc-codec.h" @@ -254,7 +256,8 @@ void computeTextureStartEnd( int unpackSkipRows, int unpackSkipImages, int* start, - int* end) { + int* end, + int ignoreTrailing) { GLsizei inputWidth = (unpackRowLength == 0) ? width : unpackRowLength; GLsizei inputPitch = computePitch(inputWidth, format, type, unpackAlignment); @@ -263,7 +266,17 @@ void computeTextureStartEnd( ALOGV("%s: input idim %d %d %d w p h %d %d %d:", __FUNCTION__, width, height, depth, inputWidth, inputPitch, inputHeight); int startVal = computePackingOffset(format, type, inputWidth, inputHeight, unpackAlignment, unpackSkipPixels, unpackSkipRows, unpackSkipImages); - int endVal = startVal + inputPitch * inputHeight * depth; + int endVal; + if (ignoreTrailing) { + // The last row needs to have just enough data per spec, and could + // ignore alignment. + // b/223402256 + endVal = startVal + inputPitch * inputHeight * (depth - 1); + endVal += inputPitch * (std::min(height, inputHeight) - 1); + endVal += computePitch(std::min(width, inputWidth), format, type, 1); + } else { + endVal = startVal + inputPitch * inputHeight * depth; + } if (start) *start = startVal; if (end) *end = endVal; @@ -293,7 +306,8 @@ int computeTotalImageSize( unpackSkipRows, unpackSkipImages, &start, - &end); + &end, + 0); return end; } @@ -305,7 +319,8 @@ int computeNeededBufferSize( int unpackImageHeight, int unpackSkipPixels, int unpackSkipRows, - int unpackSkipImages) { + int unpackSkipImages, + int ignoreTrailing) { int start, end; computeTextureStartEnd( @@ -318,7 +333,8 @@ int computeNeededBufferSize( unpackSkipRows, unpackSkipImages, &start, - &end); + &end, + ignoreTrailing); return end - start; } diff --git a/shared/OpenglCodecCommon/GLESTextureUtils.h b/shared/OpenglCodecCommon/GLESTextureUtils.h index 0b636acd..45af27e9 100644 --- a/shared/OpenglCodecCommon/GLESTextureUtils.h +++ b/shared/OpenglCodecCommon/GLESTextureUtils.h @@ -5,6 +5,11 @@ namespace GLESTextureUtils { +// By spec, the buffer is only required to provide just enough data. The +// last row does not have to fill unpackRowLength. But our decoder is +// written to always read full row. So we add "ignoreTrailing" here. When +// ignoreTrailing == 1 we compute the real size as defined by spec. When +// ignoreTrailing == 0 we compute the size used by decoder/encoder. void computeTextureStartEnd( GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, @@ -15,7 +20,8 @@ void computeTextureStartEnd( int unpackSkipRows, int unpackSkipImages, int* start, - int* end); + int* end, + int ignoreTrailing); int computeTotalImageSize( GLsizei width, GLsizei height, GLsizei depth, @@ -35,7 +41,8 @@ int computeNeededBufferSize( int unpackImageHeight, int unpackSkipPixels, int unpackSkipRows, - int unpackSkipImages); + int unpackSkipImages, + int ignoreTrailing); // Writes out |height| offsets for glReadPixels to read back // data in separate rows of pixels. Returns: diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp index 63b4ff4b..65048cf0 100755 --- a/system/GLESv2_enc/GL2Encoder.cpp +++ b/system/GLESv2_enc/GL2Encoder.cpp @@ -2721,10 +2721,9 @@ void GL2Encoder::s_glTexSubImage2D(void* self, GLenum target, GLint level, } // If unpack buffer is nonzero, verify buffer data fits and is evenly divisible by the type. - SET_ERROR_IF(ctx->boundBuffer(GL_PIXEL_UNPACK_BUFFER) && ctx->getBufferData(GL_PIXEL_UNPACK_BUFFER) && - (state->pboNeededDataSize(width, height, 1, format, type, 0) + (uintptr_t)pixels > + (state->pboNeededDataSize(width, height, 1, format, type, 0, 1) + (uintptr_t)pixels > ctx->getBufferData(GL_PIXEL_UNPACK_BUFFER)->m_size), GL_INVALID_OPERATION); SET_ERROR_IF(ctx->boundBuffer(GL_PIXEL_UNPACK_BUFFER) && |