From f240f5677acdcdb4d28991338863a3504d24954c Mon Sep 17 00:00:00 2001 From: Jason Macnak Date: Tue, 9 Jul 2024 12:23:02 -0700 Subject: [PATCH] Add YUV AHB import and sample end2end tests ... which triggers the device lost failures when aosp/3163776 is reverted. Reviewed-by: Aaron Ruby Acked-by: Yonggang Luo Acked-by: Adam Jackson Part-of: --- .../guest/android/GrallocEmulated.cpp | 368 ++++++++++++++---- src/gfxstream/guest/android/GrallocEmulated.h | 2 + .../guest/android/GrallocGoldfish.cpp | 4 + src/gfxstream/guest/android/GrallocGoldfish.h | 1 + .../guest/android/GrallocMinigbm.cpp | 7 +- src/gfxstream/guest/android/GrallocMinigbm.h | 1 + .../guest/platform/include/VirtGpu.h | 6 +- .../guest/platform/linux/LinuxVirtGpu.h | 2 +- .../platform/linux/LinuxVirtGpuDevice.cpp | 7 +- 9 files changed, 316 insertions(+), 82 deletions(-) diff --git a/src/gfxstream/guest/android/GrallocEmulated.cpp b/src/gfxstream/guest/android/GrallocEmulated.cpp index 103a73e95be..34945a56afb 100644 --- a/src/gfxstream/guest/android/GrallocEmulated.cpp +++ b/src/gfxstream/guest/android/GrallocEmulated.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "drm_fourcc.h" @@ -28,6 +29,18 @@ static constexpr int numInts = 1; #define DRM_FORMAT_R8_BLOB fourcc_code('9', '9', '9', '9') +template +T DivideRoundUp(T n, N divisor) { + const T div = static_cast(divisor); + const T q = n / div; + return n % div == 0 ? q : q + 1; +} + +template +T Align(T number, N n) { + return DivideRoundUp(number, n) * n; +} + std::optional GlFormatToDrmFormat(uint32_t glFormat) { switch (glFormat) { case kGlRGB: @@ -71,70 +84,204 @@ std::optional AhbToDrmFormat(uint32_t ahbFormat) { return DRM_FORMAT_ABGR16161616F; case GFXSTREAM_AHB_FORMAT_R10G10B10A2_UNORM: return DRM_FORMAT_ABGR2101010; + case GFXSTREAM_AHB_FORMAT_Y8Cb8Cr8_420: + return DRM_FORMAT_NV12; } return std::nullopt; } -std::optional DrmToAhbFormat(uint32_t drmFormat) { - switch (drmFormat) { - case DRM_FORMAT_ABGR8888: - return GFXSTREAM_AHB_FORMAT_R8G8B8A8_UNORM; - case DRM_FORMAT_XBGR8888: - return GFXSTREAM_AHB_FORMAT_R8G8B8X8_UNORM; - case DRM_FORMAT_ARGB8888: - return GFXSTREAM_AHB_FORMAT_B8G8R8A8_UNORM; - case DRM_FORMAT_BGR888: - return GFXSTREAM_AHB_FORMAT_R8G8B8_UNORM; - case DRM_FORMAT_RGB565: - return GFXSTREAM_AHB_FORMAT_R5G6B5_UNORM; - case DRM_FORMAT_R8_BLOB: - return GFXSTREAM_AHB_FORMAT_BLOB; - case DRM_FORMAT_R8: - return GFXSTREAM_AHB_FORMAT_R8_UNORM; - case DRM_FORMAT_YVU420: - return GFXSTREAM_AHB_FORMAT_YV12; - case DRM_FORMAT_ABGR16161616F: - return GFXSTREAM_AHB_FORMAT_R16G16B16A16_FLOAT; - case DRM_FORMAT_ABGR2101010: - return GFXSTREAM_AHB_FORMAT_R10G10B10A2_UNORM; - } - return std::nullopt; -} - -std::optional DrmToBpp(uint32_t drmFormat) { - switch (drmFormat) { - case DRM_FORMAT_ABGR8888: - case DRM_FORMAT_ARGB8888: - case DRM_FORMAT_XBGR8888: - return 4; - case DRM_FORMAT_BGR888: - return 3; - case DRM_FORMAT_RGB565: - return 2; - case DRM_FORMAT_R8_BLOB: - case DRM_FORMAT_R8: - return 1; - } - return std::nullopt; -} - -std::optional DrmToVirglFormat(uint32_t drmFormat) { - switch (drmFormat) { - case DRM_FORMAT_ABGR8888: - return VIRGL_FORMAT_R8G8B8A8_UNORM; - case DRM_FORMAT_ARGB8888: - return VIRGL_FORMAT_B8G8R8A8_UNORM; - case DRM_FORMAT_BGR888: - return VIRGL_FORMAT_R8G8B8_UNORM; - case DRM_FORMAT_BGR565: - return VIRGL_FORMAT_B5G6R5_UNORM; - case DRM_FORMAT_YVU420: - return VIRGL_FORMAT_YV12; - case DRM_FORMAT_R8: - case DRM_FORMAT_R8_BLOB: - return VIRGL_FORMAT_R8_UNORM; - } - return std::nullopt; +struct DrmFormatPlaneInfo { + uint32_t horizontalSubsampling; + uint32_t verticalSubsampling; + uint32_t bytesPerPixel; +}; +struct DrmFormatInfo { + uint32_t androidFormat; + uint32_t virglFormat; + bool isYuv; + uint32_t horizontalAlignmentPixels; + uint32_t verticalAlignmentPixels; + std::vector planes; +}; +const std::unordered_map& GetDrmFormatInfoMap() { + static const auto* kFormatInfoMap = new std::unordered_map({ + {DRM_FORMAT_ABGR8888, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_R8G8B8A8_UNORM, + .virglFormat = VIRGL_FORMAT_R8G8B8A8_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 4, + }, + }, + }}, + {DRM_FORMAT_ARGB8888, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_B8G8R8A8_UNORM, + .virglFormat = VIRGL_FORMAT_B8G8R8A8_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 4, + }, + }, + }}, + {DRM_FORMAT_BGR888, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_R8G8B8_UNORM, + .virglFormat = VIRGL_FORMAT_R8G8B8_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 3, + }, + }, + }}, + {DRM_FORMAT_BGR565, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_R5G6B5_UNORM, + .virglFormat = VIRGL_FORMAT_B5G6R5_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 2, + }, + }, + }}, + {DRM_FORMAT_R8, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_R8_UNORM, + .virglFormat = VIRGL_FORMAT_R8_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 1, + }, + }, + }}, + {DRM_FORMAT_R8_BLOB, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_BLOB, + .virglFormat = VIRGL_FORMAT_R8_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 1, + }, + }, + }}, + {DRM_FORMAT_ABGR16161616F, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_R16G16B16A16_FLOAT, + .virglFormat = VIRGL_FORMAT_R16G16B16A16_FLOAT, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 8, + }, + }, + }}, + {DRM_FORMAT_ABGR2101010, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_R10G10B10A2_UNORM, + .virglFormat = VIRGL_FORMAT_R10G10B10A2_UNORM, + .isYuv = false, + .horizontalAlignmentPixels = 1, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 4, + }, + }, + }}, + {DRM_FORMAT_NV12, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_Y8Cb8Cr8_420, + .virglFormat = VIRGL_FORMAT_NV12, + .isYuv = true, + .horizontalAlignmentPixels = 2, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 1, + }, + { + .horizontalSubsampling = 2, + .verticalSubsampling = 2, + .bytesPerPixel = 2, + }, + }, + }}, + {DRM_FORMAT_YVU420, + { + .androidFormat = GFXSTREAM_AHB_FORMAT_YV12, + .virglFormat = VIRGL_FORMAT_YV12, + .isYuv = true, + .horizontalAlignmentPixels = 32, + .verticalAlignmentPixels = 1, + .planes = + { + { + .horizontalSubsampling = 1, + .verticalSubsampling = 1, + .bytesPerPixel = 1, + }, + { + .horizontalSubsampling = 2, + .verticalSubsampling = 2, + .bytesPerPixel = 1, + }, + { + .horizontalSubsampling = 2, + .verticalSubsampling = 2, + .bytesPerPixel = 1, + }, + }, + }}, + }); + return *kFormatInfoMap; } } // namespace @@ -152,12 +299,14 @@ uint32_t EmulatedAHardwareBuffer::getWidth() const { return mWidth; } uint32_t EmulatedAHardwareBuffer::getHeight() const { return mHeight; } int EmulatedAHardwareBuffer::getAndroidFormat() const { - auto ahbFormat = DrmToAhbFormat(mDrmFormat); - if (!ahbFormat) { + const auto& formatInfosMap = GetDrmFormatInfoMap(); + auto formatInfoIt = formatInfosMap.find(mDrmFormat); + if (formatInfoIt == formatInfosMap.end()) { ALOGE("Unhandled DRM format:%u", mDrmFormat); return -1; } - return *ahbFormat; + const auto& formatInfo = formatInfoIt->second; + return formatInfo.androidFormat; } uint32_t EmulatedAHardwareBuffer::getDrmFormat() const { return mDrmFormat; } @@ -199,6 +348,54 @@ int EmulatedAHardwareBuffer::lock(uint8_t** ptr) { return 0; } +int EmulatedAHardwareBuffer::lockPlanes(std::vector* ahbPlanes) { + uint8_t* data = 0; + int ret = lock(&data); + if (ret) { + return ret; + } + + const auto& formatInfosMap = GetDrmFormatInfoMap(); + auto formatInfoIt = formatInfosMap.find(mDrmFormat); + if (formatInfoIt == formatInfosMap.end()) { + ALOGE("Failed to lock: failed to find format info for drm format:%u", mDrmFormat); + return -1; + } + const auto& formatInfo = formatInfoIt->second; + + const uint32_t alignedWidth = Align(mWidth, formatInfo.horizontalAlignmentPixels); + const uint32_t alignedHeight = Align(mHeight, formatInfo.verticalAlignmentPixels); + uint32_t cumulativeSize = 0; + for (const DrmFormatPlaneInfo& planeInfo : formatInfo.planes) { + const uint32_t planeWidth = DivideRoundUp(alignedWidth, planeInfo.horizontalSubsampling); + const uint32_t planeHeight = DivideRoundUp(alignedHeight, planeInfo.verticalSubsampling); + const uint32_t planeBpp = planeInfo.bytesPerPixel; + const uint32_t planeStrideBytes = planeWidth * planeBpp; + const uint32_t planeSizeBytes = planeHeight * planeStrideBytes; + ahbPlanes->emplace_back(Gralloc::LockedPlane{ + .data = data + cumulativeSize, + .pixelStrideBytes = planeBpp, + .rowStrideBytes = planeStrideBytes, + }); + cumulativeSize += planeSizeBytes; + } + + if (mDrmFormat == DRM_FORMAT_NV12) { + const auto& uPlane = (*ahbPlanes)[1]; + auto vPlane = uPlane; + vPlane.data += 1; + + ahbPlanes->push_back(vPlane); + } else if (mDrmFormat == DRM_FORMAT_YVU420) { + // Note: lockPlanes() always returns Y, then U, then V but YV12 is Y, then V, then U. + auto& plane1 = (*ahbPlanes)[1]; + auto& plane2 = (*ahbPlanes)[2]; + std::swap(plane1, plane2); + } + + return 0; +} + int EmulatedAHardwareBuffer::unlock() { if (!mMapped) { ALOGE("Failed to unlock EmulatedAHardwareBuffer: never locked?"); @@ -216,9 +413,13 @@ uint32_t EmulatedGralloc::createColorBuffer(void*, int width, int height, uint32 auto drmFormat = GlFormatToDrmFormat(glFormat); if (!drmFormat) { ALOGE("Unhandled format"); + return -1; } auto ahb = allocate(width, height, *drmFormat); + if (ahb == nullptr) { + return -1; + } EmulatedAHardwareBuffer* rahb = reinterpret_cast(ahb); @@ -254,24 +455,36 @@ AHardwareBuffer* EmulatedGralloc::allocate(uint32_t width, uint32_t height, uint return nullptr; } - auto virglFormat = DrmToVirglFormat(drmFormat); - if (!virglFormat) { - ALOGE("Failed to allocate: Unhandled DRM format:%u to Virgl format conversion.", drmFormat); + const auto& formatInfosMap = GetDrmFormatInfoMap(); + auto formatInfoIt = formatInfosMap.find(drmFormat); + if (formatInfoIt == formatInfosMap.end()) { + ALOGE("Failed to allocate: failed to find format info for drm format:%u", drmFormat); return nullptr; } + const auto& formatInfo = formatInfoIt->second; - auto bpp = DrmToBpp(drmFormat); - if (!virglFormat) { - ALOGE("Failed to allocate: Unhandled DRM format:%u to bpp conversion.", drmFormat); - return nullptr; + const uint32_t alignedWidth = Align(width, formatInfo.horizontalAlignmentPixels); + const uint32_t alignedHeight = Align(height, formatInfo.verticalAlignmentPixels); + uint32_t stride = 0; + uint32_t size = 0; + for (uint32_t i = 0; i < formatInfo.planes.size(); i++) { + const DrmFormatPlaneInfo& planeInfo = formatInfo.planes[i]; + const uint32_t planeWidth = DivideRoundUp(alignedWidth, planeInfo.horizontalSubsampling); + const uint32_t planeHeight = DivideRoundUp(alignedHeight, planeInfo.verticalSubsampling); + const uint32_t planeBpp = planeInfo.bytesPerPixel; + const uint32_t planeStrideBytes = planeWidth * planeBpp; + const uint32_t planeSizeBytes = planeHeight * planeStrideBytes; + size += planeSizeBytes; + if (i == 0) stride = planeStrideBytes; } - const uint32_t bind = - (drmFormat == DRM_FORMAT_R8_BLOB) ? VIRGL_BIND_LINEAR : VIRGL_BIND_RENDER_TARGET; - const uint32_t stride = width * (*bpp); + const uint32_t bind = (drmFormat == DRM_FORMAT_R8_BLOB || drmFormat == DRM_FORMAT_NV12 || + drmFormat == DRM_FORMAT_YVU420) + ? VIRGL_BIND_LINEAR + : VIRGL_BIND_RENDER_TARGET; - auto resource = - device->createResource(width, height, stride, *virglFormat, PIPE_TEXTURE_2D, bind); + auto resource = device->createResource(width, height, stride, size, formatInfo.virglFormat, + PIPE_TEXTURE_2D, bind); if (!resource) { ALOGE("Failed to allocate: failed to create virtio resource."); return nullptr; @@ -298,6 +511,11 @@ int EmulatedGralloc::lock(AHardwareBuffer* ahb, uint8_t** ptr) { return rahb->lock(ptr); } +int EmulatedGralloc::lockPlanes(AHardwareBuffer* ahb, std::vector* ahbPlanes) { + auto* rahb = reinterpret_cast(ahb); + return rahb->lockPlanes(ahbPlanes); +} + int EmulatedGralloc::unlock(AHardwareBuffer* ahb) { auto* rahb = reinterpret_cast(ahb); return rahb->unlock(); diff --git a/src/gfxstream/guest/android/GrallocEmulated.h b/src/gfxstream/guest/android/GrallocEmulated.h index 1412ca35ad1..c5d89854a42 100644 --- a/src/gfxstream/guest/android/GrallocEmulated.h +++ b/src/gfxstream/guest/android/GrallocEmulated.h @@ -51,6 +51,7 @@ class EmulatedAHardwareBuffer { void release(); int lock(uint8_t** ptr); + int lockPlanes(std::vector* ahbPlanes); int unlock(); private: @@ -77,6 +78,7 @@ class EmulatedGralloc : public Gralloc { void release(AHardwareBuffer* ahb) override; int lock(AHardwareBuffer* ahb, uint8_t** ptr) override; + int lockPlanes(AHardwareBuffer* ahb, std::vector* ahbPlanes) override; int unlock(AHardwareBuffer* ahb) override; uint32_t getHostHandle(const native_handle_t* handle) override; diff --git a/src/gfxstream/guest/android/GrallocGoldfish.cpp b/src/gfxstream/guest/android/GrallocGoldfish.cpp index 113cb6d9e4c..6962ab4c108 100644 --- a/src/gfxstream/guest/android/GrallocGoldfish.cpp +++ b/src/gfxstream/guest/android/GrallocGoldfish.cpp @@ -48,6 +48,10 @@ int GoldfishGralloc::lock(AHardwareBuffer* ahb, uint8_t** ptr) { reinterpret_cast(ptr)); } +int GoldfishGralloc::lockPlanes(AHardwareBuffer* ahb, std::vector* ahbPlanes) { + return -1; +} + int GoldfishGralloc::unlock(AHardwareBuffer* ahb) { return AHardwareBuffer_unlock(ahb, nullptr); } uint32_t GoldfishGralloc::getHostHandle(native_handle_t const* handle) { diff --git a/src/gfxstream/guest/android/GrallocGoldfish.h b/src/gfxstream/guest/android/GrallocGoldfish.h index 183c1108ea7..2c83afcadfe 100644 --- a/src/gfxstream/guest/android/GrallocGoldfish.h +++ b/src/gfxstream/guest/android/GrallocGoldfish.h @@ -29,6 +29,7 @@ class GoldfishGralloc : public Gralloc { void release(AHardwareBuffer* ahb) override; int lock(AHardwareBuffer* ahb, uint8_t** ptr) override; + int lockPlanes(AHardwareBuffer* ahb, std::vector* ahbPlanes) override; int unlock(AHardwareBuffer* ahb) override; uint32_t getHostHandle(native_handle_t const* handle) override; diff --git a/src/gfxstream/guest/android/GrallocMinigbm.cpp b/src/gfxstream/guest/android/GrallocMinigbm.cpp index 8d97be61420..be62a2bc206 100644 --- a/src/gfxstream/guest/android/GrallocMinigbm.cpp +++ b/src/gfxstream/guest/android/GrallocMinigbm.cpp @@ -181,12 +181,17 @@ int MinigbmGralloc::lock(AHardwareBuffer* ahb, uint8_t** ptr) { reinterpret_cast(ptr)); } +int MinigbmGralloc::lockPlanes(AHardwareBuffer* ahb, std::vector* ahbPlanes) { + ALOGE("%s: unimplemented", __func__); + return -1; +} + int MinigbmGralloc::unlock(AHardwareBuffer* ahb) { return AHardwareBuffer_unlock(ahb, nullptr); } uint32_t MinigbmGralloc::getHostHandle(const native_handle_t* handle) { struct drm_virtgpu_resource_info info; if (!getVirtioGpuResourceInfo(m_fd, handle, &info)) { - ALOGE("%s: failed to get resource info\n", __func__); + ALOGE("%s: failed to get resource info", __func__); return 0; } diff --git a/src/gfxstream/guest/android/GrallocMinigbm.h b/src/gfxstream/guest/android/GrallocMinigbm.h index 8a70bcaca22..2542d0d3c41 100644 --- a/src/gfxstream/guest/android/GrallocMinigbm.h +++ b/src/gfxstream/guest/android/GrallocMinigbm.h @@ -29,6 +29,7 @@ class MinigbmGralloc : public Gralloc { void release(AHardwareBuffer* ahb) override; int lock(AHardwareBuffer* ahb, uint8_t** ptr) override; + int lockPlanes(AHardwareBuffer* ahb, std::vector* ahbPlanes) override; int unlock(AHardwareBuffer* ahb) override; uint32_t getHostHandle(native_handle_t const* handle) override; diff --git a/src/gfxstream/guest/platform/include/VirtGpu.h b/src/gfxstream/guest/platform/include/VirtGpu.h index d1545a3a76f..b9afbdf41c7 100644 --- a/src/gfxstream/guest/platform/include/VirtGpu.h +++ b/src/gfxstream/guest/platform/include/VirtGpu.h @@ -22,11 +22,13 @@ #include "virtgpu_gfxstream_protocol.h" // See virgl_hw.h and p_defines.h -#define VIRGL_FORMAT_R8_UNORM 64 #define VIRGL_FORMAT_B8G8R8A8_UNORM 1 #define VIRGL_FORMAT_B5G6R5_UNORM 7 +#define VIRGL_FORMAT_R10G10B10A2_UNORM 8 +#define VIRGL_FORMAT_R8_UNORM 64 #define VIRGL_FORMAT_R8G8B8_UNORM 66 #define VIRGL_FORMAT_R8G8B8A8_UNORM 67 +#define VIRGL_FORMAT_R16G16B16A16_FLOAT 94 #define VIRGL_FORMAT_YV12 163 #define VIRGL_FORMAT_YV16 164 #define VIRGL_FORMAT_IYUV 165 @@ -191,7 +193,7 @@ class VirtGpuDevice { virtual VirtGpuResourcePtr createBlob(const struct VirtGpuCreateBlob& blobCreate) = 0; virtual VirtGpuResourcePtr createResource(uint32_t width, uint32_t height, uint32_t stride, - uint32_t virglFormat, uint32_t target, + uint32_t size, uint32_t virglFormat, uint32_t target, uint32_t bind) = 0; virtual VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle) = 0; diff --git a/src/gfxstream/guest/platform/linux/LinuxVirtGpu.h b/src/gfxstream/guest/platform/linux/LinuxVirtGpu.h index 28357f027a8..c1442a838c5 100644 --- a/src/gfxstream/guest/platform/linux/LinuxVirtGpu.h +++ b/src/gfxstream/guest/platform/linux/LinuxVirtGpu.h @@ -69,7 +69,7 @@ class LinuxVirtGpuDevice : public VirtGpuDevice { VirtGpuResourcePtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override; VirtGpuResourcePtr createResource(uint32_t width, uint32_t height, uint32_t stride, - uint32_t virglFormat, uint32_t target, + uint32_t size, uint32_t virglFormat, uint32_t target, uint32_t bind) override; virtual VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle); diff --git a/src/gfxstream/guest/platform/linux/LinuxVirtGpuDevice.cpp b/src/gfxstream/guest/platform/linux/LinuxVirtGpuDevice.cpp index da79b926227..af7b05b4f44 100644 --- a/src/gfxstream/guest/platform/linux/LinuxVirtGpuDevice.cpp +++ b/src/gfxstream/guest/platform/linux/LinuxVirtGpuDevice.cpp @@ -154,8 +154,9 @@ struct VirtGpuCaps LinuxVirtGpuDevice::getCaps(void) { return mCaps; } int64_t LinuxVirtGpuDevice::getDeviceHandle(void) { return mDeviceHandle; } VirtGpuResourcePtr LinuxVirtGpuDevice::createResource(uint32_t width, uint32_t height, - uint32_t stride, uint32_t virglFormat, - uint32_t target, uint32_t bind) { + uint32_t stride, uint32_t size, + uint32_t virglFormat, uint32_t target, + uint32_t bind) { drm_virtgpu_resource_create create = { .target = target, .format = virglFormat, @@ -166,7 +167,7 @@ VirtGpuResourcePtr LinuxVirtGpuDevice::createResource(uint32_t width, uint32_t h .array_size = 1U, .last_level = 0, .nr_samples = 0, - .size = stride * height, + .size = size, .stride = stride, };