Bug 212240 - PVRTC compressed textures are failing with ANGLE backend
Summary: PVRTC compressed textures are failing with ANGLE backend
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-21 16:51 PDT by Dean Jackson
Modified: 2020-05-21 20:26 PDT (History)
8 users (show)

See Also:


Attachments
Patch for testing (4.60 KB, patch)
2020-05-21 19:33 PDT, Kenneth Russell
no flags Details | Formatted Diff | Diff
Patch (7.24 KB, patch)
2020-05-21 20:16 PDT, Dean Jackson
kbr: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2020-05-21 16:51:27 PDT
extensions/webgl-compressed-texture-pvrtc.html is failing.

uploading data with COMPRESSED_RGB_PVRTC_2BPPV1_IMG produces an INVALID_VALUE
Comment 1 Radar WebKit Bug Importer 2020-05-21 16:51:39 PDT
<rdar://problem/63517385>
Comment 2 Kenneth Russell 2020-05-21 17:15:20 PDT
Inside ANGLE, ValidateCompressedTexImage2D in src/libANGLE/validationES2.cpp, this is the code which is failing:

   GLuint blockSize = 0;
    if (!formatInfo.computeCompressedImageSize(Extents(width, height, 1), &blockSize))
    {
        context->validationError(GL_INVALID_OPERATION, kIntegerOverflow);
        return false;
    }

    if (imageSize < 0 || static_cast<GLuint>(imageSize) != blockSize)
    {
        context->validationError(GL_INVALID_VALUE, kCompressedTextureDimensionsMustMatchData);   // <--- fails
        return false;
    }

Here, imageSize is 32 but blockSize is 0. computeCompressedImageSize failed to compute the compressed image size.
Comment 3 Dean Jackson 2020-05-21 17:23:16 PDT
It comes from formatutils.cpp

AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG....

produces a pixelBytes value of 0, because compressedBlockSize is 1, and it is divided by 8 to produce 0.
Comment 4 Dean Jackson 2020-05-21 18:20:06 PDT
If I update the values in formatutils.cpp to use 32 and 16 for blocksize on 4bpp and 2bpp respectively, things start working much better.

The rendering looks good too.

I still get some errors though:

testing COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 4x4
PASS getError was expected value: NO_ERROR : uploading compressed texture
PASS getError was expected value: INVALID_OPERATION : trying to generate mipmaps from compressed texture

expected

actual

PASS texture rendered correctly
PASS getError was expected value: INVALID_VALUE : non 0 border
FAIL getError expected: INVALID_OPERATION. Was INVALID_VALUE : invalid dimensions
FAIL getError expected: INVALID_OPERATION. Was INVALID_VALUE : invalid dimensions
FAIL getError expected: INVALID_OPERATION. Was INVALID_VALUE : invalid dimensions
FAIL getError expected: INVALID_OPERATION. Was INVALID_VALUE : invalid dimensions
PASS getError was expected value: NO_ERROR : compressedTexSubImage2D allowed for reloading of complete textures
PASS getError was expected value: INVALID_OPERATION : compressedTexSubImage2D not allowed for partial texture updates
PASS getError was expected value: INVALID_OPERATION : compressedTexSubImage2D not allowed for partial texture updates
PASS getError was expected value: INVALID_OPERATION : compressedTexSubImage2D not allowed for partial texture updates
PASS getError was expected value: INVALID_OPERATION : compressedTexSubImage2D not allowed for partial texture updates
Comment 5 Kenneth Russell 2020-05-21 19:33:47 PDT
Created attachment 400013 [details]
Patch for testing

Patch for testing
Comment 6 Kenneth Russell 2020-05-21 19:35:00 PDT
Dean, could you try this patch instead? From reading the PVRTC extension spec:

https://www.khronos.org/registry/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt

I think the compressed block size for 2BPP textures is 16x8, and for 4BPP textures, 8x8.

This equates to a block size of 256 bits for both formats.
Comment 7 Dean Jackson 2020-05-21 20:16:27 PDT
Created attachment 400016 [details]
Patch
Comment 8 EWS Watchlist 2020-05-21 20:17:11 PDT
Note that there are important steps to take when updating ANGLE. See http://trac.webkit.org/wiki/UpdatingANGLE
Comment 9 Kenneth Russell 2020-05-21 20:17:35 PDT
Comment on attachment 400016 [details]
Patch

LGTM
Comment 10 Kenneth Russell 2020-05-21 20:17:54 PDT
Looks good to me but I think the CQ's going to reject my review bit!
Comment 11 Dean Jackson 2020-05-21 20:21:47 PDT
I will land manually to avoid any robots checking your status!
Comment 12 Dean Jackson 2020-05-21 20:26:46 PDT
Committed r262044: <https://trac.webkit.org/changeset/262044>