Commit 31d3deb4 by Jeff Gilbert Committed by Commit Bot

Add `formatType` arg to computeSkipBytes.

Fix texture upload format tests: - Format tests should definitely run on ES3 also. - Also set filters to NEAREST since some formats aren't filterable. - Fix RGB9_E5 test reference encoding and add a test for it. - True int/uint textures require i/usamplers. Bug: angleproject:2576 Change-Id: Ia5bac34cdee6554a88db339de443689a71a0cf70 Reviewed-on: https://chromium-review.googlesource.com/1068142 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 64ac5d9e
......@@ -1139,17 +1139,18 @@ ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(const Extents &
return bytes.ValueOrDie();
}
ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLuint rowPitch,
GLuint depthPitch,
const PixelStoreStateBase &state,
bool is3D) const
ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLenum formatType,
GLuint rowPitch,
GLuint depthPitch,
const PixelStoreStateBase &state,
bool is3D) const
{
CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
CheckedNumeric<GLuint> checkedDepthPitch(depthPitch);
CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages));
CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows));
CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels));
CheckedNumeric<GLuint> checkedPixelBytes(pixelBytes);
CheckedNumeric<GLuint> checkedPixelBytes(computePixelBytes(formatType));
auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch;
if (!is3D)
{
......@@ -1198,7 +1199,8 @@ ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte(
}
CheckedNumeric<GLuint> checkedSkipBytes = 0;
ANGLE_TRY_RESULT(computeSkipBytes(rowPitch, depthPitch, state, is3D), checkedSkipBytes);
ANGLE_TRY_RESULT(computeSkipBytes(formatType, rowPitch, depthPitch, state, is3D),
checkedSkipBytes);
CheckedNumeric<GLuint> endByte = checkedCopyBytes + checkedSkipBytes;
......
......@@ -71,7 +71,8 @@ struct InternalFormat
ErrorOrResult<GLuint> computeCompressedImageSize(const Extents &size) const;
ErrorOrResult<GLuint> computeSkipBytes(GLuint rowPitch,
ErrorOrResult<GLuint> computeSkipBytes(GLenum formatType,
GLuint rowPitch,
GLuint depthPitch,
const PixelStoreStateBase &state,
bool is3D) const;
......
......@@ -264,7 +264,7 @@ gl::Error FramebufferD3D::readPixels(const gl::Context *context,
packState.rowLength),
outputPitch);
GLuint outputSkipBytes = 0;
ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(outputPitch, 0, packState, false),
ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(type, outputPitch, 0, packState, false),
outputSkipBytes);
outputSkipBytes +=
(area.x - origArea.x) * sizedFormatInfo.pixelBytes + (area.y - origArea.y) * outputPitch;
......
......@@ -291,7 +291,7 @@ gl::Error Image11::loadData(const gl::Context *context,
inputDepthPitch);
GLuint inputSkipBytes = 0;
ANGLE_TRY_RESULT(
formatInfo.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack, applySkipImages),
formatInfo.computeSkipBytes(type, inputRowPitch, inputDepthPitch, unpack, applySkipImages),
inputSkipBytes);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
......
......@@ -742,9 +742,9 @@ gl::Error TextureStorage11::setData(const gl::Context *context,
ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(height, unpack.imageHeight, srcRowPitch),
srcDepthPitch);
GLuint srcSkipBytes = 0;
ANGLE_TRY_RESULT(
internalFormatInfo.computeSkipBytes(srcRowPitch, srcDepthPitch, unpack, index.usesTex3D()),
srcSkipBytes);
ANGLE_TRY_RESULT(internalFormatInfo.computeSkipBytes(type, srcRowPitch, srcDepthPitch, unpack,
index.usesTex3D()),
srcSkipBytes);
const d3d11::Format &d3d11Format =
d3d11::Format::Get(image->getInternalFormat(), mRenderer->getRenderer11DeviceCaps());
......
......@@ -883,7 +883,7 @@ gl::Error FramebufferGL::readPixelsRowByRow(const gl::Context *context,
ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, pack.alignment, pack.rowLength),
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes);
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(type, rowBytes, 0, pack, false), skipBytes);
gl::PixelPackState directPack;
directPack.alignment = 1;
......@@ -925,7 +925,7 @@ gl::Error FramebufferGL::readPixelsAllAtOnce(const gl::Context *context,
ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, pack.alignment, pack.rowLength),
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, pack, false), skipBytes);
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(type, rowBytes, 0, pack, false), skipBytes);
gl::PixelPackState directPack;
directPack.alignment = 1;
......
......@@ -349,7 +349,7 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(const gl::Context *context,
bool useTexImage3D = nativegl::UseTexImage3D(getType());
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D),
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(type, rowBytes, imageBytes, unpack, useTexImage3D),
skipBytes);
const uint8_t *pixelsWithSkip = pixels + skipBytes;
......@@ -404,7 +404,7 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(const gl::Context *context,
imageBytes);
bool useTexImage3D = nativegl::UseTexImage3D(getType());
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, imageBytes, unpack, useTexImage3D),
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(type, rowBytes, imageBytes, unpack, useTexImage3D),
skipBytes);
stateManager->setPixelUnpackState(unpack);
......
......@@ -153,7 +153,7 @@ gl::Error FramebufferNULL::readPixels(const gl::Context *context,
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, packState, false), skipBytes);
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(type, rowBytes, 0, packState, false), skipBytes);
pixels += skipBytes;
// Skip OOB region up to first in bounds pixel
......
......@@ -307,7 +307,7 @@ gl::Error FramebufferVk::readPixels(const gl::Context *context,
sizedFormatInfo.computeRowPitch(type, area.width, packState.alignment, packState.rowLength),
outputPitch);
GLuint outputSkipBytes = 0;
ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(outputPitch, 0, packState, false),
ANGLE_TRY_RESULT(sizedFormatInfo.computeSkipBytes(type, outputPitch, 0, packState, false),
outputSkipBytes);
outputSkipBytes += (clippedArea.x - area.x) * sizedFormatInfo.pixelBytes +
......
......@@ -103,7 +103,7 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
GLuint inputSkipBytes = 0;
ANGLE_TRY_RESULT(
formatInfo.computeSkipBytes(inputRowPitch, inputDepthPitch, unpack, applySkipImages),
formatInfo.computeSkipBytes(type, inputRowPitch, inputDepthPitch, unpack, applySkipImages),
inputSkipBytes);
RendererVk *renderer = contextVk->getRenderer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment