Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4b9ce02 authored by Krzysztof Kosiński's avatar Krzysztof Kosiński
Browse files

Fix AHardwareBuffer_isSupported for cube maps.

Cube maps need a multiple of 6 layers, but the function attempted a trial
allocation with 1 or 2 layers instead, which cannot succeed.

Bug: 121285176
Bug: 122267389
Test: Builds successfully.
Change-Id: Id4cf26359ad2884d597c6571501b452b930fa4fa
parent 7b2e64b9
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -268,7 +268,11 @@ int AHardwareBuffer_isSupported(const AHardwareBuffer_Desc* desc) {
    AHardwareBuffer_Desc trialDesc = *desc;
    trialDesc.width = 4;
    trialDesc.height = desc->format == AHARDWAREBUFFER_FORMAT_BLOB ? 1 : 4;
    if (desc->usage & AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP) {
        trialDesc.layers = desc->layers == 6 ? 6 : 12;
    } else {
        trialDesc.layers = desc->layers == 1 ? 1 : 2;
    }
    AHardwareBuffer* trialBuffer = nullptr;
    int result = AHardwareBuffer_allocate(&trialDesc, &trialBuffer);
    if (result == NO_ERROR) {