aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-20 13:44:58 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-20 13:44:58 +0000
commit68c43471f28b7a47e9d99b25f446545518351232 (patch)
treeb1d491620bbe58052053b121b42122cf5a555d75
parentab8ef1cd040f767c16c70f8ad23299dd9f68e514 (diff)
parent169ee4dfa6915590e1cf88116034d66be13a09ca (diff)
downloadgoldfish-opengl-android13-frc-odp-release.tar.gz
Snap for 8745897 from 169ee4dfa6915590e1cf88116034d66be13a09ca to tm-frc-odp-releaset_frc_odp_330442040t_frc_odp_330442000android13-frc-odp-release
Change-Id: If9209272bff5d3c2a7c2085b8c46d3b7971b68c9
-rw-r--r--shared/OpenglCodecCommon/GLClientState.cpp5
-rw-r--r--shared/OpenglCodecCommon/GLClientState.h2
-rw-r--r--shared/OpenglCodecCommon/GLESTextureUtils.cpp26
-rw-r--r--shared/OpenglCodecCommon/GLESTextureUtils.h11
-rwxr-xr-xsystem/GLESv2_enc/GL2Encoder.cpp3
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) &&