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

Commit f2f5f261 authored by Trevor Black's avatar Trevor Black Committed by Android (Google) Code Review
Browse files

Merge "Add AHardwareBuffer* to VkNativeBufferANDROID" into main

parents a4cf4de2 0db7a091
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -63,7 +63,8 @@ extern "C" {
/*
 * NOTE ON VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 11
 *
 * This version of the extension deprecates the last of grallocusage
 * This version of the extension deprecates the last of grallocusage and
 * extends VkNativeBufferANDROID to support passing AHardwareBuffer*
 */
#define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 11
#define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer"
@@ -111,6 +112,9 @@ typedef struct {
 * usage: gralloc usage requested when the buffer was allocated
 * usage2: gralloc usage requested when the buffer was allocated
 * usage3: gralloc usage requested when the buffer was allocated
 * ahb: The AHardwareBuffer* from the actual ANativeWindowBuffer. Caller
 *      maintains ownership of resource. AHardwareBuffer pointer is only valid
 *      for the duration of the function call
 */
typedef struct {
    VkStructureType                   sType;
@@ -121,6 +125,7 @@ typedef struct {
    int                               usage; /* DEPRECATED in SPEC_VERSION 6 */
    VkNativeBufferUsage2ANDROID       usage2; /* DEPRECATED in SPEC_VERSION 9 */
    uint64_t                          usage3; /* ADDED in SPEC_VERSION 9 */
    AHardwareBuffer*                  ahb; /* ADDED in SPEC_VERSION 11 */
} VkNativeBufferANDROID;

/*
+12 −0
Original line number Diff line number Diff line
@@ -1970,6 +1970,8 @@ VkResult CreateSwapchainKHR(VkDevice device,
                &image_native_buffer.usage2.producer,
                &image_native_buffer.usage2.consumer);
            image_native_buffer.usage3 = img.buffer->usage;
            image_native_buffer.ahb =
                ANativeWindowBuffer_getHardwareBuffer(img.buffer.get());
            image_create.pNext = &image_native_buffer;

            ATRACE_BEGIN("CreateImage");
@@ -2146,7 +2148,12 @@ VkResult AcquireNextImageKHR(VkDevice device,
                    .stride = buffer->stride,
                    .format = buffer->format,
                    .usage = int(buffer->usage),
                    .usage3 = buffer->usage,
                    .ahb = ANativeWindowBuffer_getHardwareBuffer(buffer),
                };
                android_convertGralloc0To1Usage(int(buffer->usage),
                                                &nb.usage2.producer,
                                                &nb.usage2.consumer);
                VkBindImageMemoryInfo bimi = {
                    .sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
                    .pNext = &nb,
@@ -2692,7 +2699,12 @@ static void InterceptBindImageMemory2(
            .stride = buffer->stride,
            .format = buffer->format,
            .usage = int(buffer->usage),
            .usage3 = buffer->usage,
            .ahb = ANativeWindowBuffer_getHardwareBuffer(buffer),
        };
        android_convertGralloc0To1Usage(int(buffer->usage),
                                        &native_buffer.usage2.producer,
                                        &native_buffer.usage2.consumer);
        // Reserve enough space to avoid letting re-allocation invalidate the
        // addresses of the elements inside.
        out_native_buffers->reserve(bind_info_count);
+4 −1
Original line number Diff line number Diff line
@@ -46,5 +46,8 @@ cc_library_shared {
        "hwvulkan_headers",
        "vulkan_headers",
    ],
    shared_libs: ["liblog"],
    shared_libs: [
        "liblog",
        "libnativewindow",
    ],
}
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <android/hardware_buffer.h>
#include <hardware/hwvulkan.h>

#include <errno.h>
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

// WARNING: This file is generated. See ../README.md for instructions.

#include <android/hardware_buffer.h>

#include <algorithm>

#include "null_driver_gen.h"