200~SWDEV-333583 : hipMallocArray bad channel format

- channel format should be consistent accross parameters

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Change-Id: I1e7680ab9262a66e7bea4aaa21f061044b0f7956


[ROCm/clr commit: 8ed471f210]
This commit is contained in:
sdashmiz
2022-04-25 12:52:35 -04:00
committed by Shadi Dashmiz
parent 693fa73f53
commit 3e667fc98f
2 changed files with 21 additions and 1 deletions
@@ -300,6 +300,24 @@ unsigned int getNumChannels(const hipChannelFormatDesc& desc) {
return ((desc.x != 0) + (desc.y != 0) + (desc.z != 0) + (desc.w != 0));
}
inline
bool CheckArrayFormat(const hipChannelFormatDesc& desc) {
if(desc.x == 0) {
return false;
} else {
if(desc.y != 0 && desc.y != desc.x) {
return false;
}
if(desc.z !=0 && desc.z != desc.x) {
return false;
}
if(desc.w !=0 && desc.w != desc.x) {
return false;
}
}
return true;
}
inline
hipArray_Format getArrayFormat(const hipChannelFormatDesc& desc) {
switch (desc.f) {
+3 -1
View File
@@ -954,7 +954,9 @@ hipError_t hipMallocArray(hipArray** array,
hip::getArrayFormat(*desc),
hip::getNumChannels(*desc),
flags};
if(!hip::CheckArrayFormat(*desc)) {
return hipErrorInvalidValue;
}
HIP_RETURN(ihipArrayCreate(array, &allocateArray, 0 /* numMipLevels */));
}