From f45cea29b718edfdf4bdb6befc052d2d16b58203 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Tue, 15 Dec 2020 12:02:04 -0500 Subject: [PATCH] [PAL] Clamp max image buffer size... to the maximum size we can possibly create. Change-Id: Iade51d84fdada4ae1299d9b2410d373a46357c66 --- rocclr/device/pal/paldevice.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rocclr/device/pal/paldevice.cpp b/rocclr/device/pal/paldevice.cpp index d7b7af67ee..2f2f7edd6e 100644 --- a/rocclr/device/pal/paldevice.cpp +++ b/rocclr/device/pal/paldevice.cpp @@ -570,7 +570,11 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp, // OpenCL1.2 device info fields info_.builtInKernels_ = ""; - info_.imageMaxBufferSize_ = MaxImageBufferSize; + // Clamp max image buffer size to the maximum buffer size we can create. + // Image format has max 4 channels per pixel, 1 DWORD per channel. + constexpr size_t kPixelRgbaSize = 4 * sizeof(int); + info_.imageMaxBufferSize_ = std::min(MaxImageBufferSize, + info_.maxMemAllocSize_ / kPixelRgbaSize); info_.image1DMaxWidth_ = maxTextureSize; info_.imageMaxArraySize_ = MaxImageArraySize; info_.preferredInteropUserSync_ = true;