From d40203e1c43b804b28631e2f0361983bcccdbed8 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Wed, 8 Apr 2020 13:01:15 -0400 Subject: [PATCH] Correctly check max 1D image buffer size VDI reports the limits in pixels, but user provides the size in bytes. Make sure both values are in pixels before doing comparisons. Change-Id: I082c7175c9fa4383e0b0ee38ff8c047c26ff20b4 [ROCm/hip commit: a81e7d63c680c65449afcaa9cfeb31cb86bc8d02] --- projects/hip/vdi/hip_conversions.hpp | 5 +++++ projects/hip/vdi/hip_texture.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/hip/vdi/hip_conversions.hpp b/projects/hip/vdi/hip_conversions.hpp index 8c0726787f..2a78617ad9 100644 --- a/projects/hip/vdi/hip_conversions.hpp +++ b/projects/hip/vdi/hip_conversions.hpp @@ -895,4 +895,9 @@ HIP_RESOURCE_VIEW_DESC getResourceViewDesc(const hipResourceViewDesc& resViewDes return desc; } + +inline +size_t getElementSize(const hipChannelFormatDesc &desc) { + return (desc.x / 4) * getNumChannels(desc); +} }; diff --git a/projects/hip/vdi/hip_texture.cpp b/projects/hip/vdi/hip_texture.cpp index 0f8e818948..b837729721 100644 --- a/projects/hip/vdi/hip_texture.cpp +++ b/projects/hip/vdi/hip_texture.cpp @@ -100,7 +100,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject, if ((pResDesc->resType == hipResourceTypeLinear) && ((pResDesc->res.linear.devPtr == nullptr) || (!amd::isMultipleOf(pResDesc->res.linear.devPtr, info.imageBaseAddressAlignment_)) || - (pResDesc->res.linear.sizeInBytes >= info.imageMaxBufferSize_))) { + ((pResDesc->res.linear.sizeInBytes / hip::getElementSize(pResDesc->res.linear.desc)) >= info.imageMaxBufferSize_))) { return hipErrorInvalidValue; }